annualSumTableComp.js 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. var locat = (window.location+'').split('/');
  2. $(function(){if('fhsms'== locat[3]){locat = locat[0]+'//'+locat[2];}else{locat = locat[0]+'//'+locat[2]+'/'+locat[3];};});
  3. $(getTop(globalThis).hangge());
  4. var editflag = 0;
  5. var recordData = new Object();
  6. var recordBeforeValue = new Object();
  7. $(function(){
  8. tableInit();
  9. //highlightInit();
  10. });
  11. function tableInit(){
  12. //行内小计列
  13. //setRowSumCell(e);
  14. //预防、修复小中大修分别计算总和
  15. $('.threeNum').each(function(index,e){
  16. setPreTotalCell(e);
  17. });
  18. //数字格式化
  19. $('td.num').each(function(index,e){
  20. var num = $(e).html();
  21. num = numFormat(num);
  22. $(e).html(num);
  23. });
  24. //每行的合计
  25. $('.rowSum').each(function(index,e){
  26. var temp = $(e).attr("class").split(' ');
  27. var classname = temp[2];
  28. //console.log("index:"+index + ",e:"+e + ",classname:"+classname);
  29. setRowTotalCell(e, classname);
  30. });
  31. //计划费用万元格式化
  32. $('td.wnum').each(function(index,e){
  33. var num = $(e).html();
  34. //单位 元=>万元
  35. num = num/10000;
  36. num = numFormat(num);
  37. $(e).html(num);
  38. });
  39. //公司小计
  40. var subtotal = $('.subtotal').find('td[totalType="subtotal"]');
  41. for(var i=0; i<subtotal.length; i++){
  42. var companyid = subtotal.eq(i).parent().attr("id");
  43. var var1=subtotal.eq(i).attr("class");
  44. var var2=var1.split(' ');
  45. var classname = var2[1];
  46. setSubTotalCell(companyid,classname,i);
  47. }
  48. //公司里程小计
  49. var subtotal = $('.subtotal').find('td[totalType="km_subtotal"]');
  50. for(var i=0; i<subtotal.length; i++){
  51. var companyid = subtotal.eq(i).parent().attr("id");
  52. var var1=subtotal.eq(i).attr("class");
  53. var var2=var1.split(' ');
  54. var classname = var2[1];
  55. setKmSubTotalCell(companyid,classname,i);
  56. }
  57. //小计序号
  58. $('.totaltr').find('.indexCell').html($('.edittr').length+1);
  59. //留痕标红
  60. //setRecordInfo();
  61. //数字格式化-里程格式化
  62. $('td.kmnum').each(function(index,e){
  63. var num = $(e).html();
  64. if(""!= num){
  65. num = Number(num).toFixed(3) ;
  66. }
  67. $(e).html(num);
  68. });
  69. $("input.editInput").each(function(index,e){
  70. var num = $(e).val();
  71. if(num.indexOf("input") != -1){
  72. num = numFormat(num);
  73. $(e).val(num);
  74. }
  75. });
  76. //预防小修、中修、大修 小计
  77. $('.fourNum').each(function(index,e){
  78. setYFTotalCell(e);
  79. });
  80. $('.sevenNum').each(function(index,e){
  81. setYHJHTotalCell(e);
  82. });
  83. $('.3Num').each(function(index,e){
  84. setXJCell(e);
  85. });
  86. // 修复养护小修、中修、大修 小计
  87. $('.eightNum').each(function(index,e){
  88. setXFYHTotalCell(e);
  89. });
  90. // 计划养护汇总-合计
  91. $('.eightNumJHHZ').each(function(index,e){
  92. eightNumJHHZ(e);
  93. });
  94. //小计行的总计列
  95. var totalcells = $('.totaltr').find('.sumCell');
  96. for(var i=0; i<totalcells.length; i++){
  97. setTotalCell(i);
  98. }
  99. //里程的总计列
  100. var totalkmcells = $('.totaltr').find('.sumkmCell');
  101. for(var i=0; i<totalkmcells.length; i++){
  102. setKMTotalCell(i);
  103. }
  104. //百分比初始化
  105. $('#Form table tbody tr').each(function(index,e){
  106. //setTrPercentCell(e);
  107. setTrPercentCell2(e);
  108. setTrKmPercentCell2(e);
  109. });
  110. //除法
  111. $('#Form table tbody tr').each(function(index,e){
  112. //setTrPercentCell(e);
  113. setTrDivisionCell(e);
  114. });
  115. }
  116. //明细表input失焦后操作(计算公司审批费用小计)
  117. function editValue(e){
  118. if(!$(e).attr('readonly')){
  119. //公司小计
  120. var subtotal = $('.edittr').find('td[tType="subtotal"]');
  121. for(var i=0; i<subtotal.length; i++){
  122. var companyid = subtotal.eq(i).parent().attr("id");
  123. var var1=subtotal.eq(i).attr("class");
  124. var var2=var1.split(' ');
  125. var classname = var2[2];
  126. setSTotalCell(companyid,classname,i);
  127. }
  128. //小计行的总计列
  129. var totalcells = $('.totaltr').find('.sumCell');
  130. for(var i=0; i<totalcells.length; i++){
  131. setTotalCell(i);
  132. }
  133. }
  134. }
  135. function setSTotalCell(companyid,classname,index){
  136. var totalvalue = 0;
  137. for(var i=0; i<$('.edittr.date.'+companyid).length; i++){
  138. var subcellval = $('.edittr.date.'+companyid).eq(i).find('.AUDIT_FEE').find("INPUT").val();
  139. if(typeof(subcellval) != "undefined")
  140. totalvalue += Number(subcellval);
  141. }
  142. if(totalvalue != 0){
  143. $('.edittr').find('td[tType="subtotal"]').eq(index).html(numFormat(totalvalue) + '');
  144. }
  145. }
  146. function editTable(){
  147. if(editflag == 0){
  148. $('#editbutton').html('编辑中');
  149. $(".editInput").removeAttr("readonly");
  150. $("#savebutton").removeAttr("disabled");
  151. editflag = 1;
  152. }else if(editflag == 1){
  153. $('#editbutton').html('编辑');
  154. $(".editInput").attr("readonly","readonly" );
  155. $("#savebutton").attr("disabled","disabled");
  156. editflag = 0;
  157. }
  158. }
  159. function saveTable(type,year){
  160. $("#savebutton").attr("disabled","disabled");
  161. if(editflag == 1){
  162. $('#editbutton').html('编辑');
  163. $(".editInput").attr("readonly","readonly");
  164. editflag = 0;
  165. }
  166. var tabledata = dataResult();
  167. $.ajax({
  168. type : "get",
  169. url : locat+'/annualPlanKG/saveData.do?data='+JSON.stringify(tabledata)+'&TABLETYPE='+type+'&YEAR='+year,
  170. dataType : 'json',
  171. success : function(data){
  172. if(JSON.stringify(recordData) != "{}") saveRecordInfo();
  173. //保存后更新input原始值
  174. for(var i=0;i<$('.editInput').length;i++){
  175. var e = $('.editInput')[i];
  176. $(e).attr('value',$(e).val());
  177. }
  178. if(data.msg == 'success'){
  179. getTop(globalThis).hangge();
  180. bootbox.dialog({
  181. message: "<span class='bigger-110'>保存成功!</span>",
  182. buttons:
  183. {
  184. "button" :
  185. {
  186. "label" : "确定",
  187. "className" : "btn-sm btn-success",
  188. "callback" : function(){
  189. var selfhref = self.location.href;
  190. self.location.href = selfhref;
  191. }
  192. }
  193. }
  194. });
  195. }else{
  196. getTop(globalThis).hangge();
  197. bootbox.dialog({
  198. message: "<span class='bigger-110'>"+data.msg+"</span>",
  199. buttons:
  200. {
  201. "button" :
  202. {
  203. "label" : "确定",
  204. "className" : "btn-sm btn-success"
  205. }
  206. }
  207. });
  208. }
  209. }
  210. });
  211. }
  212. function dataResult(){
  213. var mapArry = $("#Form").serializeArray();
  214. var dataArry = [];
  215. var cellcount = $('.edittr:eq(0) >td').length;
  216. var recordcount = $('.edittr.date').length;
  217. for(var i=0; i<recordcount; i++){
  218. var recordmap = new Object();
  219. for(var j=0; j<5; j++){
  220. recordmap[mapArry[i*5+j].name] = mapArry[i*5+j].value;
  221. }
  222. dataArry.push(recordmap);
  223. }
  224. return dataArry;
  225. }
  226. function setRowTotalCell(e, classname){
  227. var totalvalue = 0;
  228. for(var i=0; i<$(e).parent().find("td[class*="+classname+"]").length; i++){
  229. /* if(i=="14"){
  230. debugger;
  231. }*/
  232. if($(e).parent().find("td[class*="+classname+"]").eq(i)[0].className.indexOf("kmnum") == -1){
  233. console.log("******className****"+$(e).parent().find("td[class*="+classname+"]").eq(i)[0].className);
  234. var subcellval;
  235. if($(e).parent().find("td[class*="+classname+"]").eq(i).find("INPUT").length > 0){
  236. subcellval = $(e).parent().find("td[class*="+classname+"]").eq(i).val();
  237. //console.log("INPUT:" + "i:"+i+",subcellval:"+ subcellval);
  238. }else{
  239. subcellval = $(e).parent().find("td[class*="+classname+"]").eq(i).html();
  240. }
  241. if(typeof(subcellval) != "undefined" && subcellval != "")
  242. //console.log("i:"+i+",subcellval:"+ subcellval);
  243. totalvalue += Number(subcellval);
  244. }
  245. }
  246. if(totalvalue != 0 && totalvalue != 'NaN'){
  247. $(e).html(numFormat(totalvalue) + '');
  248. //console.log("totalvalue:"+ numFormat(totalvalue));
  249. }
  250. }
  251. function setPreTotalCell(e){
  252. var totalvalue = 0;
  253. var num1 = $(e).parent().find("."+$(e).attr("num3")).html();
  254. var num2 = $(e).parent().find("."+$(e).attr("num4")).html();
  255. var num3 = $(e).parent().find("."+$(e).attr("num5")).html();
  256. if(typeof(num1) != "undefined" && typeof(num2) != "undefined" && typeof(num3) != "undefined"){
  257. totalvalue = Number(num1) + Number(num2) + Number(num3);
  258. }
  259. if(totalvalue != 0){
  260. $(e).html(numFormat(totalvalue) + '');
  261. }
  262. }
  263. function setSubTotalCell(companyid,classname,index){
  264. var totalvalue = 0;
  265. for(var i=0; i<$('.edittr.'+companyid +' .'+classname).length; i++){
  266. var subcellval;
  267. if($('.edittr.'+companyid +' .'+classname).eq(i).find("INPUT").length > 0){
  268. subcellval = $('.edittr.'+companyid +' .'+classname).eq(i).val();
  269. }else{
  270. subcellval = $('.edittr.'+companyid +' .'+classname).eq(i).html();
  271. }
  272. if(typeof(subcellval) != "undefined")
  273. totalvalue += Number(subcellval);
  274. }
  275. if(totalvalue != 0){
  276. $('.subtotal').find('td[totalType="subtotal"]').eq(index).html(numFormat(totalvalue) + '');
  277. }
  278. }
  279. function setKmSubTotalCell(companyid,classname,index){
  280. var totalvalue = 0;
  281. for(var i=0; i<$('.edittr.'+companyid +' .'+classname).length; i++){
  282. var subcellval;
  283. if($('.edittr.'+companyid +' .'+classname).eq(i).find("INPUT").length > 0){
  284. subcellval = $('.edittr.'+companyid +' .'+classname).eq(i).val();
  285. }else{
  286. subcellval = $('.edittr.'+companyid +' .'+classname).eq(i).html();
  287. }
  288. if(typeof(subcellval) != "undefined")
  289. totalvalue += Number(subcellval);
  290. }
  291. if(totalvalue != 0){
  292. $('.subtotal').find('td[totalType="km_subtotal"]').eq(index).html(Number(totalvalue).toFixed(3) + '');
  293. }
  294. }
  295. function setTotalCell(index){
  296. if(index < $('.totaltr').find('.sumCell').length){
  297. var totalvalue = 0;
  298. if($('.subtotal').length>0){
  299. for(var i=0; i<$('.subtotal').length; i++){
  300. var editcellval;
  301. if($('.subtotal').eq(i).find('td[totalType="subtotal"]').eq(index).find("INPUT").length > 0){
  302. editcellval = $('.subtotal').eq(i).find('td[totalType="subtotal"]').eq(index).val();
  303. }else{
  304. editcellval = $('.subtotal').eq(i).find('td[totalType="subtotal"]').eq(index).html();
  305. //console.log("i:"+i+",index:"+index+",subcellval:"+ editcellval);
  306. }
  307. console.log("---editcellval---"+editcellval);
  308. if(typeof(editcellval) != "undefined")
  309. totalvalue += Number(editcellval);
  310. }
  311. for(var i=0; i<$('.edittr').length; i++){
  312. var rycellval=0;
  313. var myArray=new Array();
  314. myArray = $('.edittr').eq(i).attr("class").split(" ");
  315. //加上无小计
  316. if(myArray != null && myArray.length > 0){
  317. if(myArray[1] == "006" || myArray[1] == "013" ){
  318. if($('.edittr').eq(i).find('td[totalType="sum"]').eq(index).find("INPUT").length > 0){
  319. rycellval = $('.edittr').eq(i).find('td[totalType="sum"]').eq(index).val();
  320. }else{
  321. rycellval = $('.edittr').eq(i).find('td[totalType="sum"]').eq(index).html();
  322. }
  323. break;
  324. }
  325. }
  326. }
  327. if(typeof(rycellval) != "undefined"){
  328. totalvalue += Number(rycellval);
  329. }
  330. }
  331. else{
  332. for (var i = 0; i < $('.edittr').length; i++) {
  333. var rycellval = 0;
  334. var myArray = new Array();
  335. myArray = $('.edittr').eq(i).attr("class").split(" ");
  336. if (myArray != null && myArray.length == 2) {
  337. if ($('.edittr').eq(i).find('td[totalType="sum"]')
  338. .eq(index).find("INPUT").length > 0) {
  339. rycellval = $('.edittr').eq(i).find(
  340. 'td[totalType="sum"]').eq(index).val();
  341. } else {
  342. rycellval = $('.edittr').eq(i).find(
  343. 'td[totalType="sum"]').eq(index).html();
  344. }
  345. console.log("rycellval:::"+rycellval);
  346. if (typeof (rycellval) != "undefined") {
  347. totalvalue += Number(rycellval);
  348. }
  349. }
  350. }
  351. }
  352. if(totalvalue != 0){
  353. $('.totaltr').find('.sumCell').eq(index).html(numFormat(totalvalue) + '');
  354. }
  355. }
  356. }
  357. function setKMTotalCell(index){
  358. if(index < $('.totaltr').find('.sumkmCell').length){
  359. var totalvalue = 0;
  360. for(var i=0; i<$('.edittr').length; i++){
  361. var editcellval;
  362. if($('.edittr').eq(i).find('td[totalType="kmsum"]').eq(index).find("INPUT").length > 0){
  363. editcellval = $('.edittr').eq(i).find('td[totalType="kmsum"]').eq(index).val();
  364. }else{
  365. editcellval = $('.edittr').eq(i).find('td[totalType="kmsum"]').eq(index).html();
  366. }
  367. if(typeof(editcellval) != "undefined")
  368. totalvalue += Number(editcellval);
  369. }
  370. if(totalvalue != 0){
  371. $('.totaltr').find('.sumkmCell').eq(index).html(Number(totalvalue).toFixed(3) + '');
  372. }
  373. }
  374. }
  375. function setSubtotal(tr){
  376. // $(tr).find("td>.subtotal").each(function(index,e){
  377. // var name = $(e).attr("name");
  378. var totalNum;
  379. $(tr).find("td[name='PREVENTION_DESIGN']").each(function(index,e){
  380. var num = $(e).text();
  381. totalNum = totalNum + num;
  382. });
  383. //$(e).val(totalNum);
  384. // });
  385. }
  386. function setTrPercentCell(tr){
  387. $(tr).find("td>.percentCell").each(function(index,e){
  388. if(e.tagName == "INPUT"){
  389. var num1 = $(tr).find("td>."+$(e).attr("num1")).val();
  390. var num2 = $(tr).find("td>."+$(e).attr("num2")).val();
  391. var result = percentage(num1, num2);
  392. $(e).val(result);
  393. }else if(e.tagName == "SPAN"){
  394. var num1 = $(tr).find("td>."+$(e).attr("num1")).html();
  395. var num2 = $(tr).find("td>."+$(e).attr("num2")).html();
  396. var result = percentage(num1, num2);
  397. $(e).html(result);
  398. }
  399. });
  400. }
  401. function setTrPercentCell2(tr){
  402. $(tr).find("td.percentCell").each(function(index,e){
  403. var num1 = $(tr).find("td."+$(e).attr("num1")).html();
  404. var num2 = $(tr).find("td."+$(e).attr("num2")).html();
  405. var result = percentage(num1, num2);
  406. $(e).html(result);
  407. });
  408. }
  409. function setTrKmPercentCell2(tr){
  410. $(tr).find("td.percentKmCell").each(function(index,e){
  411. var num1 = $(tr).find("td."+$(e).attr("num1")).html();
  412. var num2 = $(tr).find("td."+$(e).attr("num2")).html();
  413. var result = percentagekm(num1, num2);
  414. $(e).html(result);
  415. });
  416. }
  417. function setTrDivisionCell(tr){
  418. $(tr).find("td.divisionCell").each(function(index,e){
  419. var num1 = $(tr).find("td."+$(e).attr("num1")).html();
  420. var num2 = $(tr).find("td."+$(e).attr("num2")).html();
  421. var result = division(num1, num2);
  422. $(e).html(result);
  423. });
  424. }
  425. function percentage(num1, num2){
  426. var percent = "";
  427. if(!isNaN(Number(num1)) && !isNaN(Number(num2)) && Number(num2) != "0" )
  428. // percent = Math.round(Number(num1) / Number(num2) * 10000) / 100.00 + "%";
  429. // percent = Math.round(Number(num1) / Number(num2) * 100) + "%";
  430. percent = Math.round(Number(num1) / Number(num2) * 100);
  431. return percent;
  432. }
  433. function percentagekm(num1, num2){
  434. var percent = "";
  435. if(!isNaN(Number(num1)) && !isNaN(Number(num2)) && Number(num2) != "0" )
  436. percent = (Number(num1) / Number(num2)).toFixed(1);
  437. return percent;
  438. }
  439. function division(num1, num2){
  440. var percent = "";
  441. if(!isNaN(Number(num1)) && !isNaN(Number(num2)) && Number(num2) != "0" )
  442. percent = (Number(num1) / Number(num2)).toFixed(1);
  443. return percent;
  444. }
  445. function numFormat(num){
  446. if(!isNaN(Number(num)) && Number(num) != "0"){
  447. if(num<10) num = Number(num).toFixed(1);
  448. else num = Math.round(Number(num));
  449. }
  450. return num;
  451. }
  452. //预防小修、中修、大修小计
  453. function setYFTotalCell(e){
  454. var totalvalue = 0;
  455. var num1 = $(e).parent().find("."+$(e).attr("num6")).html();
  456. var num2 = $(e).parent().find("."+$(e).attr("num7")).html();
  457. var num3 = $(e).parent().find("."+$(e).attr("num8")).html();
  458. var num4 = $(e).parent().find("."+$(e).attr("num9")).html();
  459. if(typeof(num1) != "undefined" && typeof(num2) != "undefined"
  460. && typeof(num3) != "undefined"&& typeof(num4) != "undefined"){
  461. totalvalue = Number(num1) + Number(num2) + Number(num3) + Number(num4);
  462. }
  463. if(totalvalue != 0){
  464. $(e).html(numFormat(totalvalue) + '');
  465. }
  466. }
  467. //修复养护小修、中修、大修小计
  468. function setXFYHTotalCell(e){
  469. var totalvalue = 0;
  470. var num1 = $(e).parent().find("."+$(e).attr("num10")).html();
  471. var num2 = $(e).parent().find("."+$(e).attr("num11")).html();
  472. var num3 = $(e).parent().find("."+$(e).attr("num12")).html();
  473. var num4 = $(e).parent().find("."+$(e).attr("num13")).html();
  474. var num5 = $(e).parent().find("."+$(e).attr("num14")).html();
  475. var num6 = $(e).parent().find("."+$(e).attr("num15")).html();
  476. var num7 = $(e).parent().find("."+$(e).attr("num16")).html();
  477. var num8 = $(e).parent().find("."+$(e).attr("num17")).html();
  478. //num17下有文本框时取name为$(e).attr("num24")的input值
  479. var tdInput = $(e).parent().find("."+$(e).attr("num17"));
  480. if($(tdInput).find('input').length > 0){
  481. num8 = $(tdInput).find('input[name="'+$(e).attr("num17")+'"]').val();
  482. }
  483. if(typeof(num1) != "undefined" && typeof(num2) != "undefined"
  484. && typeof(num3) != "undefined"&& typeof(num4) != "undefined"
  485. && typeof(num5) != "undefined"&& typeof(num6) != "undefined"
  486. && typeof(num7) != "undefined"&& typeof(num8) != "undefined"){
  487. totalvalue = Number(num1) + Number(num2) + Number(num3) + Number(num4)
  488. +Number(num5) + Number(num6) + Number(num7) + Number(num8);
  489. }
  490. if(totalvalue != 0){
  491. $(e).html(numFormat(totalvalue) + '');
  492. }
  493. }
  494. function eightNumJHHZ(e){
  495. var totalvalue = 0;
  496. var num1 = $(e).parent().find("."+$(e).attr("num10")).html();
  497. var num2 = $(e).parent().find("."+$(e).attr("num11")).html();
  498. var num3 = $(e).parent().find("."+$(e).attr("num12")).html();
  499. var num4 = $(e).parent().find("."+$(e).attr("num13")).html();
  500. var num5 = $(e).parent().find("."+$(e).attr("num14")).html();
  501. var num6 = $(e).parent().find("."+$(e).attr("num15")).html();
  502. var num7 = $(e).parent().find("."+$(e).attr("num16")).html();
  503. var num8 = $(e).parent().find("."+$(e).attr("num17")).html();
  504. //num17下有文本框时取name为$(e).attr("num24")的input值
  505. var tdInput = $(e).parent().find("."+$(e).attr("num17"));
  506. if($(tdInput).find('input').length > 0){
  507. num8 = $(tdInput).find('input[name="'+$(e).attr("num17")+'"]').val();
  508. }
  509. if(num8 == ""){
  510. num8 = $(e).parent().find("."+$(e).attr("num18")).html();
  511. }
  512. if(typeof(num1) != "undefined" && typeof(num2) != "undefined"
  513. && typeof(num3) != "undefined"&& typeof(num4) != "undefined"
  514. && typeof(num5) != "undefined"&& typeof(num6) != "undefined"
  515. && typeof(num7) != "undefined"&& typeof(num8) != "undefined"){
  516. totalvalue = Number(num1) + Number(num2) + Number(num3) + Number(num4)
  517. +Number(num5) + Number(num6) + Number(num7) + Number(num8);
  518. }
  519. if(totalvalue != 0){
  520. $(e).html(numFormat(totalvalue) + '');
  521. }
  522. }
  523. function setYHJHTotalCell(e){
  524. var totalvalue = 0;
  525. var num1 = $(e).parent().find("."+$(e).attr("num18")).html();
  526. var num2 = $(e).parent().find("."+$(e).attr("num19")).html();
  527. var num3 = $(e).parent().find("."+$(e).attr("num20")).html();
  528. var num4 = $(e).parent().find("."+$(e).attr("num21")).html();
  529. var num5 = $(e).parent().find("."+$(e).attr("num22")).html();
  530. var num6 = $(e).parent().find("."+$(e).attr("num23")).html();
  531. var num7 = $(e).parent().find("."+$(e).attr("num24")).html();
  532. if(typeof(num1) != "undefined" && typeof(num2) != "undefined"
  533. && typeof(num3) != "undefined"&& typeof(num4) != "undefined"
  534. && typeof(num5) != "undefined"&& typeof(num6) != "undefined"&& typeof(num7) != "undefined"){
  535. totalvalue = Number(num1) + Number(num2) + Number(num3) + Number(num4)
  536. +Number(num5) + Number(num6) + Number(num7) ;
  537. }
  538. if(totalvalue != 0){
  539. $(e).html(numFormat(totalvalue) + '');
  540. }
  541. }
  542. function setXJCell(e){
  543. var totalvalue = 0;
  544. var num1 = $(e).parent().find("."+$(e).attr("num3")).html();
  545. var num2 = $(e).parent().find("."+$(e).attr("num4")).html();
  546. var num3 = $(e).parent().find("."+$(e).attr("num5")).html();
  547. if(typeof(num1) != "undefined" && typeof(num2) != "undefined"
  548. && typeof(num3) != "undefined"){
  549. totalvalue = Number(num1) + Number(num2) + Number(num3) ;
  550. }
  551. if(totalvalue != 0){
  552. $(e).html(numFormat(totalvalue) + '');
  553. }
  554. }
  555. //获取本网站的顶级节点,解决被其他网站iframe引入时发生的跨域问题
  556. function getTop(obj){
  557. var tp = obj;
  558. //alert(obj.name);
  559. if (tp.mainFrame == undefined) {
  560. tp = tp.parent;
  561. return getTop(tp);
  562. } else {
  563. return tp;
  564. }
  565. }