ledger_gather.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. $(document).ready(() => {
  10. autoFlashHeight();
  11. const gclSpread = SpreadJsObj.createNewSpread($('#gcl-spread')[0]);
  12. SpreadJsObj.initSheet(gclSpread.getActiveSheet(), {
  13. cols: [
  14. {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 120, formatter: '@'},
  15. {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 230, formatter: '@'},
  16. {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', cellType: 'unit'},
  17. {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 80, type: 'Number'},
  18. {title: '签约清单|数量', colSpan: '2|1', rowSpan: '1|1', field: 'deal_bills_qty', hAlign: 2, width: 80, type: 'Number'},
  19. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'deal_bills_tp', hAlign: 2, width: 80, type: 'Number'},
  20. {title: '台账|数量', colSpan: '2|1', rowSpan: '1|1', field: 'quantity', hAlign: 2, width: 80, type: 'Number'},
  21. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 80, type: 'Number'},
  22. {title: '签约-台账|数量', colSpan: '2|1', rowSpan: '1|1', field: 'compare_qty', hAlign: 2, width: 80, type: 'Number'},
  23. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'compare_tp', hAlign: 2, width: 80, type: 'Number'},
  24. ],
  25. emptyRows: 0,
  26. headRows: 2,
  27. headRowHeight: [25, 25],
  28. defaultRowHeight: 21,
  29. headerFont: '12px 微软雅黑',
  30. font: '12px 微软雅黑',
  31. readOnly: true,
  32. getColor: function (sheet, data, col, defaultColor) {
  33. return data && data.differ ? '#FFE699' : defaultColor;
  34. }
  35. });
  36. const gclSheet = gclSpread.getActiveSheet();
  37. const leafXmjSpread = SpreadJsObj.createNewSpread($('#leaf-xmj-spread')[0]);
  38. SpreadJsObj.initSheet(leafXmjSpread.getActiveSheet(), {
  39. cols: [
  40. {title: '项目节编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 120, formatter: '@'},
  41. {title: '台账数量', colSpan: '1', rowSpan: '1', field: 'quantity', hAlign: 2, width: 80, type: 'Number'},
  42. {title: '单位工程', colSpan: '1', rowSpan: '1', field: 'dwgc', hAlign: 0, width: 100, formatter: '@'},
  43. {title: '分部工程', colSpan: '1', rowSpan: '1', field: 'fbgc', hAlign: 0, width: 100, formatter: '@'},
  44. {title: '分项工程', colSpan: '1', rowSpan: '1', field: 'fxgc', hAlign: 0, width: 100, formatter: '@'},
  45. {title: '细目', colSpan: '1', rowSpan: '1', field: 'jldy', hAlign: 0, width: 100, formatter: '@'},
  46. {title: '计量单元', colSpan: '1', rowSpan: '1', field: 'bwmx', hAlign: 0, width: 100, formatter: '@'},
  47. {title: '图册号', colSpan: '1', rowSpan: '1', field: 'drawing_code', hAlign: 0, width: 120, formatter: '@'},
  48. ],
  49. emptyRows: 0,
  50. headRows: 1,
  51. headRowHeight: [32],
  52. defaultRowHeight: 21,
  53. headerFont: '12px 微软雅黑',
  54. font: '12px 微软雅黑',
  55. readOnly: true,
  56. });
  57. const leafXmjSheet = leafXmjSpread.getActiveSheet();
  58. let gclGatherData;
  59. // 获取项目节数据
  60. function loadLeafXmjData(iGclRow) {
  61. const gcl = gclGatherData[iGclRow];
  62. if (gcl) {
  63. SpreadJsObj.loadSheetData(leafXmjSheet, SpreadJsObj.DataType.Data, gcl.leafXmjs);
  64. } else {
  65. SpreadJsObj.loadSheetData(leafXmjSheet, SpreadJsObj.DataType.Data, []);
  66. }
  67. }
  68. // 切换清单行,读取所属项目节数据
  69. gclSpread.getActiveSheet().bind(spreadNS.Events.SelectionChanged, function (e, info) {
  70. const iNewRow = info.newSelections[0].row;
  71. if (!info.oldSelections || iNewRow !== info.oldSelections[0].row) {
  72. loadLeafXmjData(iNewRow);
  73. }
  74. });
  75. postData(window.location.pathname + '/load', {}, function (data) {
  76. gclGatherModel.loadLedgerData(data.bills);
  77. gclGatherModel.loadPosData(data.pos);
  78. gclGatherModel.loadDealBillsData(data.dealBills);
  79. gclGatherData = gclGatherModel.gatherGclData();
  80. gclGatherModel.checkDiffer(gclGatherData);
  81. for (const gcl of gclGatherData) {
  82. gcl.compare_qty = ZhCalc.sub(gcl.deal_bills_qty, gcl.quantity);
  83. gcl.compare_tp = ZhCalc.sub(gcl.deal_bills_tp, gcl.total_price);
  84. }
  85. SpreadJsObj.loadSheetData(gclSheet, SpreadJsObj.DataType.Data, gclGatherData);
  86. loadLeafXmjData(0);
  87. }, null, true);
  88. $.subMenu({
  89. menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
  90. toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
  91. key: 'menu.1.0.0',
  92. miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
  93. callback: function (info) {
  94. if (info.mini) {
  95. $('.panel-title').addClass('fluid');
  96. $('#sub-menu').removeClass('panel-sidebar');
  97. } else {
  98. $('.panel-title').removeClass('fluid');
  99. $('#sub-menu').addClass('panel-sidebar');
  100. }
  101. autoFlashHeight();
  102. gclSpread.refresh();
  103. leafXmjSpread.refresh();
  104. }
  105. });
  106. $.divResizer({
  107. select: '#main-resize',
  108. callback: function () {
  109. gclSpread.refresh();
  110. let bcontent = $(".bcontent-wrap") ? $(".bcontent-wrap").height() : 0;
  111. $(".sp-wrap").height(bcontent-40);
  112. leafXmjSpread.refresh();
  113. }
  114. });
  115. });