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); }); //每行的合计 $('.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 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 setTotalCell(index){ if(index < $('.totaltr').find('.sumCell').length){ var totalvalue = 0; for(var i=0; i<$('.edittr').length; i++){ var editcellval; if($('.edittr').eq(i).find('td[totalType="sum"]').eq(index).find("INPUT").length > 0){ editcellval = $('.edittr').eq(i).find('td[totalType="sum"]').eq(index).val(); }else{ editcellval = $('.edittr').eq(i).find('td[totalType="sum"]').eq(index).html(); //console.log("i:"+i+",index:"+index+",subcellval:"+ editcellval); } if(typeof(editcellval) != "undefined") totalvalue += Number(editcellval); } if(totalvalue != 0){ $('.totaltr').find('.sumCell').eq(index).html(numFormat(totalvalue) + ''); } } } 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){ 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 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)); 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 setXiuTotalCell(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(); 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) + ''); } } //获取本网站的顶级节点,解决被其他网站iframe引入时发生的跨域问题 function getTop(obj){ var tp = obj; //alert(obj.name); if (tp.mainFrame == undefined) { tp = tp.parent; return getTop(tp); } else { return tp; } }