change_information_show.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. 'use strict';
  2. /**
  3. * 变更令详细页js
  4. *
  5. * @author EllisRan.
  6. * @date 2018/11/22
  7. * @version
  8. */
  9. $(document).ready(() => {
  10. const changeSpreadSetting = {
  11. cols: [
  12. {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 80, formatter: '@'},
  13. {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 120, formatter: '@'},
  14. {title: '变更部位', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 120, formatter: '@'},
  15. {title: '变更详情', colSpan: '1', rowSpan: '2', field: 'detail', hAlign: 0, width: 120, formatter: '@'},
  16. {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@'},
  17. {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.unit_price'},
  18. {title: '原设计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'oamount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.oamount'},
  19. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'oa_tp', hAlign: 2, width: 80, formatter: '@', type: 'Number', getValue: 'getValue.oa_tp'},
  20. {title: '申请变更增(+)减(-)|数量', colSpan: '2|1', rowSpan: '1|1', field: 'camount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.camount'},
  21. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'ca_tp', hAlign: 2, width: 80, formatter: '@', type: 'Number', getValue: 'getValue.ca_tp'},
  22. {title: '审批后变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'samount', hAlign: 2, width: 60, type: 'Number', getValue: 'getValue.samount'},
  23. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sa_tp', hAlign: 2, width: 80, formatter: '@', type: 'Number', getValue: 'getValue.sa_tp'},
  24. ],
  25. emptyRows: 0,
  26. headRows: 2,
  27. headRowHeight: [25, 25],
  28. defaultRowHeight: 21,
  29. headerFont: '12px 微软雅黑',
  30. font: '12px 微软雅黑',
  31. readOnly: true,
  32. };
  33. for (const aid of aidList) {
  34. const userinfo = _.find(auditList2, { 'uid': aid });
  35. const newColcount = {
  36. title: userinfo.name + ' 审批|数量',
  37. colSpan: '2|1', rowSpan: '1|1',
  38. field: 'audit_amount_' + aid,
  39. hAlign: 2, width: 60, type: 'Number',
  40. getValue: 'getValue.samount'
  41. };
  42. const newColTp = {
  43. title: '|金额',
  44. colSpan: '|1', rowSpan: '|1',
  45. field: 'sa_tp',
  46. hAlign: 2, width: 80, formatter: '@', type: 'Number',
  47. getValue: 'getValue.sa_tp'};
  48. changeSpreadSetting.cols.push(newColcount);
  49. changeSpreadSetting.cols.push(newColTp);
  50. }
  51. const changeCol = {
  52. getValue: {
  53. unit_price: function(data) {
  54. return ZhCalc.round(data.unit_price, unitPriceUnit);
  55. },
  56. oa_tp: function (data) {
  57. return ZhCalc.round(ZhCalc.mul(data.unit_price, data.oamount), totalPriceUnit);
  58. },
  59. ca_tp: function (data) {
  60. return ZhCalc.round(ZhCalc.mul(data.unit_price, data.camount), totalPriceUnit);
  61. },
  62. oamount: function (data) {
  63. return ZhCalc.round(data.oamount, findDecimal(data.unit));
  64. },
  65. camount: function (data) {
  66. return ZhCalc.round(data.camount, findDecimal(data.unit));
  67. },
  68. samount: function (data) {
  69. return ZhCalc.round(data.samount, findDecimal(data.unit));
  70. },
  71. sa_tp: function (data) {
  72. return ZhCalc.round(ZhCalc.mul(data.unit_price, data.samount), totalPriceUnit);
  73. },
  74. },
  75. };
  76. const changeSpreadObj = {
  77. makeSjsFooter: function () {
  78. // 增加汇总行并设为锁定禁止编辑状态
  79. changeSpreadSheet.addRows(changeSpreadSheet.getRowCount(), 1);
  80. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 0, '合计');
  81. changeSpreadSheet.setStyle(changeSpreadSheet.getRowCount() - 1, -1, style1);
  82. changeSpreadObj.countSum();
  83. },
  84. countSum: function() {
  85. const rowCount = changeSpreadSheet.getRowCount();
  86. let oSum = 0,
  87. cSum = 0,
  88. sSum = 0;
  89. for(let i = 0; i < rowCount - 1; i++){
  90. oSum = ZhCalc.add(oSum, changeSpreadSheet.getValue(i, 7));
  91. cSum = ZhCalc.add(cSum, changeSpreadSheet.getValue(i, 9));
  92. sSum = ZhCalc.add(sSum, changeSpreadSheet.getValue(i, 11));
  93. }
  94. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 7, oSum !== 0 ? oSum : null);
  95. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 9, cSum !== 0 ? cSum : null);
  96. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 11, sSum !== 0 ? sSum : null);
  97. // 用户的数据合计
  98. for (const j in aidList) {
  99. let audit_sum = 0;
  100. for(let i = 0; i < rowCount - 1; i++){
  101. audit_sum = ZhCalc.add(audit_sum, changeSpreadSheet.getValue(i, 13 + j*2));
  102. }
  103. changeSpreadSheet.setValue(changeSpreadSheet.getRowCount() - 1, 13 + j*2, audit_sum !== 0 ? audit_sum : null);
  104. }
  105. },
  106. showHideAudit: function (show = false) {
  107. const count = changeSpreadSetting.cols.length;
  108. for (let i = 12; i < count; i++) {
  109. changeSpreadSheet.setColumnVisible(i, show, GC.Spread.Sheets.SheetArea.viewport);
  110. }
  111. changeSpreadSheet.setColumnVisible(10, !show, GC.Spread.Sheets.SheetArea.viewport);
  112. changeSpreadSheet.setColumnVisible(11, !show, GC.Spread.Sheets.SheetArea.viewport);
  113. }
  114. };
  115. SpreadJsObj.initSpreadSettingEvents(changeSpreadSetting, changeCol);
  116. SpreadJsObj.initSheet(changeSpreadSheet, changeSpreadSetting);
  117. SpreadJsObj.loadSheetData(changeSpreadSheet, SpreadJsObj.DataType.Data, changeList);
  118. changeSpreadObj.makeSjsFooter();
  119. changeSpreadObj.showHideAudit();
  120. // 审批流程展示与隐藏
  121. $('#show-table-detail').on('click', function (e) {
  122. if($(e.target).is('label')){
  123. return;
  124. }
  125. changeSpreadObj.showHideAudit($(this).is(':checked'));
  126. });
  127. });