var locat = (window.location+'').split('/'); $(function(){if('fhsms'== locat[3]){locat = locat[0]+'//'+locat[2];}else{locat = locat[0]+'//'+locat[2]+'/'+locat[3];};}); $(getTop(globalThis).hangge()); var editflag = 0; var recordData = new Object(); var recordBeforeValue = new Object(); $(function(){ tableInit(); //highlightInit(); }); function tableInit(){ //行内小计列 //setRowSumCell(e); //预防、修复小中大修分别计算总和 $('.threeNum').each(function(index,e){ setPreTotalCell(e); }); //数字格式化 $('td.num').each(function(index,e){ var num = $(e).html(); num = numFormat(num); $(e).html(num); }); //每行的合计 $('.rowSum').each(function(index,e){ var temp = $(e).attr("class").split(' '); var classname = temp[2]; //console.log("index:"+index + ",e:"+e + ",classname:"+classname); setRowTotalCell(e, classname); }); //计划费用万元格式化 $('td.wnum').each(function(index,e){ var num = $(e).html(); //单位 元=>万元 num = num/10000; num = numFormat(num); $(e).html(num); }); //公司小计 var subtotal = $('.subtotal').find('td[totalType="subtotal"]'); for(var i=0; i保存成功!", buttons: { "button" : { "label" : "确定", "className" : "btn-sm btn-success", "callback" : function(){ var selfhref = self.location.href; self.location.href = selfhref; } } } }); }else{ getTop(globalThis).hangge(); bootbox.dialog({ message: ""+data.msg+"", buttons: { "button" : { "label" : "确定", "className" : "btn-sm btn-success" } } }); } } }); } function dataResult(){ var mapArry = $("#Form").serializeArray(); var dataArry = []; var cellcount = $('.edittr:eq(0) >td').length; var recordcount = $('.edittr.date').length; for(var i=0; i 0){ subcellval = $(e).parent().find("td[class*="+classname+"]").eq(i).val(); //console.log("INPUT:" + "i:"+i+",subcellval:"+ subcellval); }else{ subcellval = $(e).parent().find("td[class*="+classname+"]").eq(i).html(); } if(typeof(subcellval) != "undefined" && subcellval != "") //console.log("i:"+i+",subcellval:"+ subcellval); totalvalue += Number(subcellval); } } if(totalvalue != 0 && totalvalue != 'NaN'){ $(e).html(numFormat(totalvalue) + ''); //console.log("totalvalue:"+ numFormat(totalvalue)); } } function setPreTotalCell(e){ var totalvalue = 0; var num1 = $(e).parent().find("."+$(e).attr("num3")).html(); var num2 = $(e).parent().find("."+$(e).attr("num4")).html(); var num3 = $(e).parent().find("."+$(e).attr("num5")).html(); if(typeof(num1) != "undefined" && typeof(num2) != "undefined" && typeof(num3) != "undefined"){ totalvalue = Number(num1) + Number(num2) + Number(num3); } if(totalvalue != 0){ $(e).html(numFormat(totalvalue) + ''); } } function setSubTotalCell(companyid,classname,index){ var totalvalue = 0; for(var i=0; i<$('.edittr.'+companyid +' .'+classname).length; i++){ var subcellval; if($('.edittr.'+companyid +' .'+classname).eq(i).find("INPUT").length > 0){ subcellval = $('.edittr.'+companyid +' .'+classname).eq(i).val(); }else{ subcellval = $('.edittr.'+companyid +' .'+classname).eq(i).html(); } if(typeof(subcellval) != "undefined") totalvalue += Number(subcellval); } if(totalvalue != 0){ $('.subtotal').find('td[totalType="subtotal"]').eq(index).html(numFormat(totalvalue) + ''); } } function setKmSubTotalCell(companyid,classname,index){ var totalvalue = 0; for(var i=0; i<$('.edittr.'+companyid +' .'+classname).length; i++){ var subcellval; if($('.edittr.'+companyid +' .'+classname).eq(i).find("INPUT").length > 0){ subcellval = $('.edittr.'+companyid +' .'+classname).eq(i).val(); }else{ subcellval = $('.edittr.'+companyid +' .'+classname).eq(i).html(); } if(typeof(subcellval) != "undefined") totalvalue += Number(subcellval); } if(totalvalue != 0){ $('.subtotal').find('td[totalType="km_subtotal"]').eq(index).html(Number(totalvalue).toFixed(3) + ''); } } function setTotalCell(index){ if(index < $('.totaltr').find('.sumCell').length){ var totalvalue = 0; if($('.subtotal').length>0){ for(var i=0; i<$('.subtotal').length; i++){ var editcellval; if($('.subtotal').eq(i).find('td[totalType="subtotal"]').eq(index).find("INPUT").length > 0){ editcellval = $('.subtotal').eq(i).find('td[totalType="subtotal"]').eq(index).val(); }else{ editcellval = $('.subtotal').eq(i).find('td[totalType="subtotal"]').eq(index).html(); //console.log("i:"+i+",index:"+index+",subcellval:"+ editcellval); } console.log("---editcellval---"+editcellval); if(typeof(editcellval) != "undefined") totalvalue += Number(editcellval); } for(var i=0; i<$('.edittr').length; i++){ var rycellval=0; var myArray=new Array(); myArray = $('.edittr').eq(i).attr("class").split(" "); //加上无小计 if(myArray != null && myArray.length > 0){ if(myArray[1] == "006" || myArray[1] == "013" ){ if($('.edittr').eq(i).find('td[totalType="sum"]').eq(index).find("INPUT").length > 0){ rycellval = $('.edittr').eq(i).find('td[totalType="sum"]').eq(index).val(); }else{ rycellval = $('.edittr').eq(i).find('td[totalType="sum"]').eq(index).html(); } break; } } } if(typeof(rycellval) != "undefined"){ totalvalue += Number(rycellval); } } else{ for (var i = 0; i < $('.edittr').length; i++) { var rycellval = 0; var myArray = new Array(); myArray = $('.edittr').eq(i).attr("class").split(" "); if (myArray != null && myArray.length == 2) { if ($('.edittr').eq(i).find('td[totalType="sum"]') .eq(index).find("INPUT").length > 0) { rycellval = $('.edittr').eq(i).find( 'td[totalType="sum"]').eq(index).val(); } else { rycellval = $('.edittr').eq(i).find( 'td[totalType="sum"]').eq(index).html(); } console.log("rycellval:::"+rycellval); if (typeof (rycellval) != "undefined") { totalvalue += Number(rycellval); } } } } if(totalvalue != 0){ $('.totaltr').find('.sumCell').eq(index).html(numFormat(totalvalue) + ''); } } } function setKMTotalCell(index){ if(index < $('.totaltr').find('.sumkmCell').length){ var totalvalue = 0; for(var i=0; i<$('.edittr').length; i++){ var editcellval; if($('.edittr').eq(i).find('td[totalType="kmsum"]').eq(index).find("INPUT").length > 0){ editcellval = $('.edittr').eq(i).find('td[totalType="kmsum"]').eq(index).val(); }else{ editcellval = $('.edittr').eq(i).find('td[totalType="kmsum"]').eq(index).html(); } if(typeof(editcellval) != "undefined") totalvalue += Number(editcellval); } if(totalvalue != 0){ $('.totaltr').find('.sumkmCell').eq(index).html(Number(totalvalue).toFixed(3) + ''); } } } function setSubtotal(tr){ // $(tr).find("td>.subtotal").each(function(index,e){ // var name = $(e).attr("name"); var totalNum; $(tr).find("td[name='PREVENTION_DESIGN']").each(function(index,e){ var num = $(e).text(); totalNum = totalNum + num; }); //$(e).val(totalNum); // }); } function setTrPercentCell(tr){ $(tr).find("td>.percentCell").each(function(index,e){ if(e.tagName == "INPUT"){ var num1 = $(tr).find("td>."+$(e).attr("num1")).val(); var num2 = $(tr).find("td>."+$(e).attr("num2")).val(); var result = percentage(num1, num2); $(e).val(result); }else if(e.tagName == "SPAN"){ var num1 = $(tr).find("td>."+$(e).attr("num1")).html(); var num2 = $(tr).find("td>."+$(e).attr("num2")).html(); var result = percentage(num1, num2); $(e).html(result); } }); } function setTrPercentCell2(tr){ $(tr).find("td.percentCell").each(function(index,e){ var num1 = $(tr).find("td."+$(e).attr("num1")).html(); var num2 = $(tr).find("td."+$(e).attr("num2")).html(); var result = percentage(num1, num2); $(e).html(result); }); } function setTrKmPercentCell2(tr){ $(tr).find("td.percentKmCell").each(function(index,e){ var num1 = $(tr).find("td."+$(e).attr("num1")).html(); var num2 = $(tr).find("td."+$(e).attr("num2")).html(); var result = percentagekm(num1, num2); $(e).html(result); }); } function setTrDivisionCell(tr){ $(tr).find("td.divisionCell").each(function(index,e){ var num1 = $(tr).find("td."+$(e).attr("num1")).html(); var num2 = $(tr).find("td."+$(e).attr("num2")).html(); var result = division(num1, num2); $(e).html(result); }); } function percentage(num1, num2){ var percent = ""; if(!isNaN(Number(num1)) && !isNaN(Number(num2)) && Number(num2) != "0" ) // percent = Math.round(Number(num1) / Number(num2) * 10000) / 100.00 + "%"; // percent = Math.round(Number(num1) / Number(num2) * 100) + "%"; percent = Math.round(Number(num1) / Number(num2) * 100); return percent; } function percentagekm(num1, num2){ var percent = ""; if(!isNaN(Number(num1)) && !isNaN(Number(num2)) && Number(num2) != "0" ) percent = (Number(num1) / Number(num2)).toFixed(1); return percent; } function division(num1, num2){ var percent = ""; if(!isNaN(Number(num1)) && !isNaN(Number(num2)) && Number(num2) != "0" ) percent = (Number(num1) / Number(num2)).toFixed(1); return percent; } function numFormat(num){ if(!isNaN(Number(num)) && Number(num) != "0"){ if(num<10) num = Number(num).toFixed(1); else num = Math.round(Number(num)); } return num; } //预防小修、中修、大修小计 function setYFTotalCell(e){ var totalvalue = 0; var num1 = $(e).parent().find("."+$(e).attr("num6")).html(); var num2 = $(e).parent().find("."+$(e).attr("num7")).html(); var num3 = $(e).parent().find("."+$(e).attr("num8")).html(); var num4 = $(e).parent().find("."+$(e).attr("num9")).html(); if(typeof(num1) != "undefined" && typeof(num2) != "undefined" && typeof(num3) != "undefined"&& typeof(num4) != "undefined"){ totalvalue = Number(num1) + Number(num2) + Number(num3) + Number(num4); } if(totalvalue != 0){ $(e).html(numFormat(totalvalue) + ''); } } //修复养护小修、中修、大修小计 function setXFYHTotalCell(e){ var totalvalue = 0; var num1 = $(e).parent().find("."+$(e).attr("num10")).html(); var num2 = $(e).parent().find("."+$(e).attr("num11")).html(); var num3 = $(e).parent().find("."+$(e).attr("num12")).html(); var num4 = $(e).parent().find("."+$(e).attr("num13")).html(); var num5 = $(e).parent().find("."+$(e).attr("num14")).html(); var num6 = $(e).parent().find("."+$(e).attr("num15")).html(); var num7 = $(e).parent().find("."+$(e).attr("num16")).html(); var num8 = $(e).parent().find("."+$(e).attr("num17")).html(); //num17下有文本框时取name为$(e).attr("num24")的input值 var tdInput = $(e).parent().find("."+$(e).attr("num17")); if($(tdInput).find('input').length > 0){ num8 = $(tdInput).find('input[name="'+$(e).attr("num17")+'"]').val(); } if(typeof(num1) != "undefined" && typeof(num2) != "undefined" && typeof(num3) != "undefined"&& typeof(num4) != "undefined" && typeof(num5) != "undefined"&& typeof(num6) != "undefined" && typeof(num7) != "undefined"&& typeof(num8) != "undefined"){ totalvalue = Number(num1) + Number(num2) + Number(num3) + Number(num4) +Number(num5) + Number(num6) + Number(num7) + Number(num8); } if(totalvalue != 0){ $(e).html(numFormat(totalvalue) + ''); } } function eightNumJHHZ(e){ var totalvalue = 0; var num1 = $(e).parent().find("."+$(e).attr("num10")).html(); var num2 = $(e).parent().find("."+$(e).attr("num11")).html(); var num3 = $(e).parent().find("."+$(e).attr("num12")).html(); var num4 = $(e).parent().find("."+$(e).attr("num13")).html(); var num5 = $(e).parent().find("."+$(e).attr("num14")).html(); var num6 = $(e).parent().find("."+$(e).attr("num15")).html(); var num7 = $(e).parent().find("."+$(e).attr("num16")).html(); var num8 = $(e).parent().find("."+$(e).attr("num17")).html(); //num17下有文本框时取name为$(e).attr("num24")的input值 var tdInput = $(e).parent().find("."+$(e).attr("num17")); if($(tdInput).find('input').length > 0){ num8 = $(tdInput).find('input[name="'+$(e).attr("num17")+'"]').val(); } if(num8 == ""){ num8 = $(e).parent().find("."+$(e).attr("num18")).html(); } if(typeof(num1) != "undefined" && typeof(num2) != "undefined" && typeof(num3) != "undefined"&& typeof(num4) != "undefined" && typeof(num5) != "undefined"&& typeof(num6) != "undefined" && typeof(num7) != "undefined"&& typeof(num8) != "undefined"){ totalvalue = Number(num1) + Number(num2) + Number(num3) + Number(num4) +Number(num5) + Number(num6) + Number(num7) + Number(num8); } if(totalvalue != 0){ $(e).html(numFormat(totalvalue) + ''); } } function setYHJHTotalCell(e){ var totalvalue = 0; var num1 = $(e).parent().find("."+$(e).attr("num18")).html(); var num2 = $(e).parent().find("."+$(e).attr("num19")).html(); var num3 = $(e).parent().find("."+$(e).attr("num20")).html(); var num4 = $(e).parent().find("."+$(e).attr("num21")).html(); var num5 = $(e).parent().find("."+$(e).attr("num22")).html(); var num6 = $(e).parent().find("."+$(e).attr("num23")).html(); var num7 = $(e).parent().find("."+$(e).attr("num24")).html(); if(typeof(num1) != "undefined" && typeof(num2) != "undefined" && typeof(num3) != "undefined"&& typeof(num4) != "undefined" && typeof(num5) != "undefined"&& typeof(num6) != "undefined"&& typeof(num7) != "undefined"){ totalvalue = Number(num1) + Number(num2) + Number(num3) + Number(num4) +Number(num5) + Number(num6) + Number(num7) ; } if(totalvalue != 0){ $(e).html(numFormat(totalvalue) + ''); } } function setXJCell(e){ var totalvalue = 0; var num1 = $(e).parent().find("."+$(e).attr("num3")).html(); var num2 = $(e).parent().find("."+$(e).attr("num4")).html(); var num3 = $(e).parent().find("."+$(e).attr("num5")).html(); if(typeof(num1) != "undefined" && typeof(num2) != "undefined" && typeof(num3) != "undefined"){ totalvalue = Number(num1) + Number(num2) + Number(num3) ; } if(totalvalue != 0){ $(e).html(numFormat(totalvalue) + ''); } } //获取本网站的顶级节点,解决被其他网站iframe引入时发生的跨域问题 function getTop(obj){ var tp = obj; //alert(obj.name); if (tp.mainFrame == undefined) { tp = tp.parent; return getTop(tp); } else { return tp; } }