123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- 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<subtotal.length; i++){
- var companyid = subtotal.eq(i).parent().attr("id");
- var var1=subtotal.eq(i).attr("class");
- var var2=var1.split(' ');
- var classname = var2[1];
- setSubTotalCell(companyid,classname,i);
- }
-
-
- //小计序号
- $('.totaltr').find('.indexCell').html($('.edittr').length+1);
- //留痕标红
- //setRecordInfo();
- //数字格式化
- $('td.num').each(function(index,e){
- var num = $(e).html();
- num = numFormat(num);
- $(e).html(num);
- });
-
- $("input.editInput").each(function(index,e){
- var num = $(e).val();
- num = numFormat(num);
- $(e).val(num);
- });
-
- //小修、中修、大修 小计
- $('.fourNum').each(function(index,e){
- setXiuTotalCell(e);
- });
- // 修复养护小修、中修、大修 小计
- $('.eightNum').each(function(index,e){
- setXFYHTotalCell(e);
- });
-
- //小计行的总计列
- var totalcells = $('.totaltr').find('.sumCell');
- for(var i=0; i<totalcells.length; i++){
- setTotalCell(i);
- }
- //除
- $('#Form table tbody tr').each(function(index,e){
- //setTrPercentCell(e);
- setTrPercentCell(e);
- });
- }
- function setRowTotalCell(e, classname){
- var totalvalue = 0;
-
- for(var i=0; i<$(e).parent().find("td[class*="+classname+"]").length; i++){
- /* if(i=="14"){
- debugger;
- }*/
- var subcellval;
- if($(e).parent().find("td[class*="+classname+"]").eq(i).find("INPUT").length > 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;
- }
- }
|