ledger_gather.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. const showTools = function (show) {
  10. const left = $('#left-view'), right = $('#right-view'), parent = left.parent();
  11. if (show) {
  12. right.show();
  13. autoFlashHeight();
  14. /**
  15. * right.show()后, parent被撑开成2倍left.height, 导致parent.width减少了10px
  16. * 第一次left.width调整后,parent的缩回left.height, 此时parent.width又增加了10px
  17. * 故需要通过最终的parent.width再计算一次left.width
  18. *
  19. * Q: 为什么不通过先计算left.width的宽度,以避免计算两次left.width?
  20. * A: 右侧工具栏不一定显示,当右侧工具栏显示过一次后,就必须使用parent和right来计算left.width
  21. *
  22. */
  23. //left.css('width', parent.width() - right.outerWidth());
  24. //left.css('width', parent.width() - right.outerWidth());
  25. const percent = 100 - right.outerWidth() /parent.width() * 100;
  26. left.css('width', percent + '%');
  27. } else {
  28. right.hide();
  29. left.css('width', '100%');
  30. }
  31. };
  32. $(document).ready(() => {
  33. showTools(true);
  34. autoFlashHeight();
  35. const gclSpread = SpreadJsObj.createNewSpread($('#gcl-spread')[0]);
  36. const gclSpreadSetting = {
  37. cols: [
  38. {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 120, formatter: '@'},
  39. {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 230, formatter: '@'},
  40. {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', cellType: 'unit'},
  41. {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 80, type: 'Number'},
  42. {title: '签约清单|数量', colSpan: '2|1', rowSpan: '1|1', field: 'deal_bills_qty', hAlign: 2, width: 80, type: 'Number'},
  43. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'deal_bills_tp', hAlign: 2, width: 80, type: 'Number'},
  44. {title: '台账|数量', colSpan: '2|1', rowSpan: '1|1', field: 'quantity', hAlign: 2, width: 80, type: 'Number'},
  45. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 80, type: 'Number'},
  46. {title: '台账-签约|数量', colSpan: '2|1', rowSpan: '1|1', field: 'compare_qty', hAlign: 2, width: 80, type: 'Number'},
  47. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'compare_tp', hAlign: 2, width: 80, type: 'Number'},
  48. ],
  49. emptyRows: 0,
  50. headRows: 2,
  51. headRowHeight: [25, 25],
  52. headColWidth: [30],
  53. defaultRowHeight: 21,
  54. headerFont: '12px 微软雅黑',
  55. font: '12px 微软雅黑',
  56. readOnly: true,
  57. localCache: {
  58. key: 'ledger-gather-gcl',
  59. colWidth: true,
  60. },
  61. tipsSum: true,
  62. getColor: function (sheet, data, row, col, defaultColor) {
  63. return data
  64. ? $('#compare-tag')[0].checked && data.compare_differ
  65. ? spreadColor.gcl.calc_differ
  66. : (data.differ ? spreadColor.gcl.differ : '#FFFFFF')
  67. : '#FFFFFF';
  68. }
  69. };
  70. if (thousandth) sjsSettingObj.setTpThousandthFormat(gclSpreadSetting);
  71. SpreadJsObj.initSheet(gclSpread.getActiveSheet(), gclSpreadSetting);
  72. const gclSheet = gclSpread.getActiveSheet();
  73. const leafXmjSpread = SpreadJsObj.createNewSpread($('#leaf-xmj-spread')[0]);
  74. const leafXmjSpreadSetting = {
  75. cols: [
  76. {title: '项目节编号', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 120, formatter: '@'},
  77. {title: '台账数量', colSpan: '1', rowSpan: '1', field: 'quantity', hAlign: 2, width: 80, type: 'Number'},
  78. {title: '单位工程', colSpan: '1', rowSpan: '1', field: 'dwgc', hAlign: 0, width: 100, formatter: '@'},
  79. {title: '分部工程', colSpan: '1', rowSpan: '1', field: 'fbgc', hAlign: 0, width: 100, formatter: '@'},
  80. {title: '分项工程', colSpan: '1', rowSpan: '1', field: 'fxgc', hAlign: 0, width: 100, formatter: '@'},
  81. {title: '细目', colSpan: '1', rowSpan: '1', field: 'jldy', hAlign: 0, width: 100, formatter: '@'},
  82. {title: '计量单元', colSpan: '1', rowSpan: '1', field: 'bwmx', hAlign: 0, width: 100, formatter: '@'},
  83. {title: '图册号', colSpan: '1', rowSpan: '1', field: 'drawing_code', hAlign: 0, width: 120, formatter: '@'},
  84. ],
  85. emptyRows: 0,
  86. headRows: 1,
  87. headRowHeight: [32],
  88. headColWidth: [30],
  89. defaultRowHeight: 21,
  90. headerFont: '12px 微软雅黑',
  91. font: '12px 微软雅黑',
  92. readOnly: true,
  93. localCache: {
  94. key: 'ledger-gather-leafXmj',
  95. colWidth: true,
  96. },
  97. tipsSum: true,
  98. };
  99. if (thousandth) sjsSettingObj.setTpThousandthFormat(leafXmjSpreadSetting);
  100. SpreadJsObj.initSheet(leafXmjSpread.getActiveSheet(), leafXmjSpreadSetting);
  101. const leafXmjSheet = leafXmjSpread.getActiveSheet();
  102. const gatherLeafXmjSpread = SpreadJsObj.createNewSpread($('#leaf-xmj-gather-spread')[0]);
  103. const gatherLeafXmjSpreadSetting = {
  104. cols: [
  105. {title: '单位工程', colSpan: '1', rowSpan: '1', field: 'dwgc', hAlign: 0, width: 100, formatter: '@', visible: false},
  106. {title: '分部工程', colSpan: '1', rowSpan: '1', field: 'fbgc', hAlign: 0, width: 100, formatter: '@', visible: false},
  107. {title: '分项工程', colSpan: '1', rowSpan: '1', field: 'fxgc', hAlign: 0, width: 100, formatter: '@', visible: false},
  108. {title: '细目', colSpan: '1', rowSpan: '1', field: 'jldy', hAlign: 0, width: 100, formatter: '@', visible: false},
  109. {title: '计量单元', colSpan: '1', rowSpan: '1', field: 'bwmx', hAlign: 0, width: 100, formatter: '@'},
  110. {title: '位置', colSpan: '1', rowSpan: '1', field: 'position', hAlign: 0, width: 100, formatter: '@', visible: false},
  111. {title: '台账数量', colSpan: '1', rowSpan: '1', field: 'quantity', hAlign: 2, width: 80, type: 'Number'},
  112. ],
  113. emptyRows: 0,
  114. headRows: 1,
  115. headRowHeight: [32],
  116. headColWidth: [30],
  117. defaultRowHeight: 21,
  118. headerFont: '12px 微软雅黑',
  119. font: '12px 微软雅黑',
  120. readOnly: true,
  121. localCache: {
  122. key: 'ledger-gather-leafXmj',
  123. colWidth: true,
  124. },
  125. tipsSum: true,
  126. };
  127. if (thousandth) sjsSettingObj.setTpThousandthFormat(gatherLeafXmjSpreadSetting);
  128. const gatherLeafXmjSheet = gatherLeafXmjSpread.getActiveSheet();
  129. SpreadJsObj.initSheet(gatherLeafXmjSheet, gatherLeafXmjSpreadSetting);
  130. const gatherAncGclSpread = SpreadJsObj.createNewSpread($('#anc-gcl-gather-spread')[0]);
  131. const gatherAncGclSpreadSetting = {
  132. cols: [
  133. {title: '单位工程', colSpan: '1', rowSpan: '1', field: 'dwgc', hAlign: 0, width: 100, formatter: '@', visible: false},
  134. {title: '分部工程', colSpan: '1', rowSpan: '1', field: 'fbgc', hAlign: 0, width: 100, formatter: '@', visible: false},
  135. {title: '分项工程', colSpan: '1', rowSpan: '1', field: 'fxgc', hAlign: 0, width: 100, formatter: '@', visible: false},
  136. {title: '细目', colSpan: '1', rowSpan: '1', field: 'jldy', hAlign: 0, width: 100, formatter: '@'},
  137. {title: '计量单元', colSpan: '1', rowSpan: '1', field: 'bwmx', hAlign: 0, width: 100, formatter: '@', visible: false},
  138. {title: '辅材', colSpan: '1', rowSpan: '1', field: 'is_aux', hAlign: 1, width: 60, formatter: '@', fixed: 1, cellType: 'checkbox'},
  139. {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 100, formatter: '@', fixed: 1},
  140. {title: '单位', colSpan: '1', rowSpan: '1', field: 'unit', hAlign: 1, width: 50, formatter: '@', fixed: 1},
  141. {title: '设计量', colSpan: '1', rowSpan: '1', field: 'quantity', hAlign: 2, width: 80, type: 'Number', fixed: 1},
  142. ],
  143. emptyRows: 0,
  144. headRows: 1,
  145. headRowHeight: [32],
  146. headColWidth: [30],
  147. defaultRowHeight: 21,
  148. headerFont: '12px 微软雅黑',
  149. font: '12px 微软雅黑',
  150. readOnly: true,
  151. localCache: {
  152. key: 'ledger-gather-ancGcl',
  153. colWidth: true,
  154. },
  155. tipsSum: true,
  156. };
  157. if (thousandth) sjsSettingObj.setTpThousandthFormat(gatherAncGclSpreadSetting);
  158. const gatherAncGclSheet = gatherAncGclSpread.getActiveSheet();
  159. SpreadJsObj.initSheet(gatherAncGclSheet, gatherAncGclSpreadSetting);
  160. const changeSpread = SpreadJsObj.createNewSpread($('#change-spread')[0]);
  161. const changeSpreadSetting = {
  162. cols: [
  163. {title: '变更令号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 200, formatter: '@'},
  164. {title: '变更名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 200, formatter: '@'},
  165. {title: '计价', colSpan: '1', rowSpan: '2', field: 'is_valuation', hAlign: 1, width: 40, cellType: 'checkbox'},
  166. {title: '原设计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'org_qty', hAlign: 2, width: 100, formatter: '@'},
  167. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'org_tp', hAlign: 2, width: 100, formatter: '@'},
  168. {title: '批复变更|数量', colSpan: '2|1', rowSpan: '1|1', field: 'c_qty', hAlign: 2, width: 100, formatter: '@'},
  169. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'c_tp', hAlign: 2, width: 100, formatter: '@'},
  170. ],
  171. emptyRows: 0,
  172. headRows: 2,
  173. headRowHeight: [25, 25],
  174. headColWidth: [30],
  175. defaultRowHeight: 21,
  176. headerFont: '12px 微软雅黑',
  177. font: '12px 微软雅黑',
  178. readOnly: true,
  179. localCache: {
  180. key: 'ledger-gather-change',
  181. colWidth: true,
  182. },
  183. tipsSum: true,
  184. };
  185. if (thousandth) sjsSettingObj.setTpThousandthFormat(changeSpreadSetting);
  186. const changeSheet = changeSpread.getActiveSheet();
  187. SpreadJsObj.initSheet(changeSheet, changeSpreadSetting);
  188. let gclGatherData;
  189. // 获取项目节数据
  190. function loadLeafXmjData(iGclRow) {
  191. const gcl = iGclRow ? gclGatherData[iGclRow] : SpreadJsObj.getSelectObject(gclSheet);
  192. if (gcl) {
  193. SpreadJsObj.loadSheetData(leafXmjSheet, SpreadJsObj.DataType.Data, gcl.leafXmjs);
  194. } else {
  195. SpreadJsObj.loadSheetData(leafXmjSheet, SpreadJsObj.DataType.Data, []);
  196. }
  197. SpreadJsObj.resetTopAndSelect(leafXmjSheet);
  198. }
  199. function loadGatherLeafXmjData(iGclRow) {
  200. const gcl = iGclRow ? gclGatherData[iGclRow] : SpreadJsObj.getSelectObject(gclSheet);
  201. if (gcl) {
  202. SpreadJsObj.loadSheetData(gatherLeafXmjSheet, SpreadJsObj.DataType.Data, gcl.gatherLeafXmjs);
  203. } else {
  204. SpreadJsObj.loadSheetData(gatherLeafXmjSheet, SpreadJsObj.DataType.Data, []);
  205. }
  206. SpreadJsObj.resetTopAndSelect(gatherLeafXmjSheet);
  207. }
  208. function loadGatherAncGclData(iGclRow) {
  209. const gcl = iGclRow ? gclGatherData[iGclRow] : SpreadJsObj.getSelectObject(gclSheet);
  210. if (gcl) {
  211. SpreadJsObj.loadSheetData(gatherAncGclSheet, SpreadJsObj.DataType.Data, gcl.gatherAncGcl);
  212. } else {
  213. SpreadJsObj.loadSheetData(gatherAncGclSheet, SpreadJsObj.DataType.Data, []);
  214. }
  215. SpreadJsObj.resetTopAndSelect(gatherAncGclSheet);
  216. }
  217. function loadChangeData(iGclRow) {
  218. const gcl = iGclRow ? gclGatherData[iGclRow] : SpreadJsObj.getSelectObject(gclSheet);
  219. if (gcl) {
  220. SpreadJsObj.loadSheetData(changeSheet, SpreadJsObj.DataType.Data, gcl.change);
  221. } else {
  222. SpreadJsObj.loadSheetData(changeSheet, SpreadJsObj.DataType.Data, []);
  223. }
  224. SpreadJsObj.resetTopAndSelect(changeSheet);
  225. }
  226. function loadGclGatherRelaData(iGclRow) {
  227. loadLeafXmjData(iGclRow);
  228. loadChangeData(iGclRow);
  229. loadGatherLeafXmjData(iGclRow);
  230. loadGatherAncGclData(iGclRow);
  231. }
  232. function refreshRelaSpread() {
  233. leafXmjSpread.refresh();
  234. gatherLeafXmjSpread.refresh();
  235. gatherAncGclSpread.refresh();
  236. changeSpread.refresh();
  237. }
  238. // 标红显示 签约-台账≠0
  239. function checkCompareData() {
  240. const sheet = gclSheet;
  241. const bCompare = $('#compare-tag')[0].checked;
  242. SpreadJsObj.beginMassOperation(gclSheet);
  243. for (let iRow = 0, iLength = gclSheet.getRowCount(); iRow < iLength; iRow++) {
  244. const node = gclSheet.zh_data[iRow];
  245. if (node) {
  246. const bDiffer = node.compare_qty ? !checkZero(Math.abs(node.compare_qty)) : !checkZero(Math.abs(node.compare_tp));
  247. const color = bCompare && bDiffer ? '#f8d7da' : '';
  248. sheet.getRange(iRow, -1, 1, -1).backColor(color);
  249. }
  250. }
  251. SpreadJsObj.endMassOperation(gclSheet);
  252. }
  253. // 切换清单行,读取所属项目节数据
  254. gclSpread.getActiveSheet().bind(spreadNS.Events.SelectionChanged, function (e, info) {
  255. const iNewRow = info.newSelections[0].row;
  256. if (!info.oldSelections || iNewRow !== info.oldSelections[0].row) {
  257. loadGclGatherRelaData(iNewRow);
  258. }
  259. });
  260. function generateChapterHtml(data) {
  261. const html = [];
  262. if (data) {
  263. for (const d of data) {
  264. if (['1000', '1100', '1200', '1300'].indexOf(d.code) >= 0) {
  265. if (checkZero(d.total_price) && checkZero(d.deal_bills_tp)) {
  266. continue;
  267. }
  268. }
  269. html.push('<tr>');
  270. if (d.code) {
  271. html.push('<td>', d.code, '</td>');
  272. html.push('<td>', d.name, '</td>');
  273. } else {
  274. html.push('<td colspan="2">', d.name, '</td>');
  275. }
  276. html.push('<td class="text-right">', d.deal_bills_tp ? d.deal_bills_tp : '', '</td>');
  277. html.push('<td class="text-right">', d.total_price ? d.total_price : '', '</td>');
  278. html.push('<td class="text-right">', d.compare_tp ? d.compare_tp : '', '</td>');
  279. html.push('</tr>');
  280. }
  281. }
  282. $('#chapter-list').html(html.join(''));
  283. }
  284. postData(window.location.pathname + '/load', {}, function (data) {
  285. gclGatherModel.loadLedgerData(data.bills);
  286. gclGatherModel.loadPosData(data.pos);
  287. gclGatherModel.loadDealBillsData(data.dealBills);
  288. gclGatherModel.loadAncillaryGclData(data.ancGcl);
  289. gclGatherModel.loadChangeData(data.change);
  290. gclGatherData = gclGatherModel.gatherGclData();
  291. gclGatherModel.checkDiffer(gclGatherData);
  292. gclGatherModel.reGatherLeafXmj();
  293. gclGatherModel.reGatherAncillaryGcl();
  294. for (const gcl of gclGatherData) {
  295. gcl.compare_qty = ZhCalc.sub(gcl.quantity, gcl.deal_bills_qty);
  296. gcl.compare_tp = ZhCalc.sub(gcl.total_price, gcl.deal_bills_tp);
  297. gcl.compare_differ = !checkZero(gcl.compare_qty) || !checkZero(gcl.compare_tp);
  298. }
  299. SpreadJsObj.loadSheetData(gclSheet, SpreadJsObj.DataType.Data, gclGatherData);
  300. checkCompareData();
  301. loadGclGatherRelaData(0);
  302. const chapterData = gclGatherModel.gatherChapterData(chapter, data.spec, ['total_price']);
  303. for (const c of chapterData) {
  304. c.compare_tp = ZhCalc.sub(c.total_price, c.deal_bills_tp);
  305. }
  306. generateChapterHtml(chapterData);
  307. }, null, true);
  308. $('#compare-tag').click(() => {
  309. // const rows = [];
  310. // for (let i = 0; i< gclSheet.getRowCount(); ++i) {
  311. // rows.push(i);
  312. // }
  313. // SpreadJsObj.reloadRowsBackColor(gclSheet, rows);
  314. SpreadJsObj.reLoadSheetData(gclSheet);
  315. });
  316. const searchBills = $.listSearch({
  317. selector: '#search',
  318. searchSpread: gclSpread,
  319. searchRangeStr: '清单编号/名称',
  320. resultSpreadSetting: {
  321. cols: [
  322. {title: '清单编号', field: 'b_code', hAlign: 0, width: 80, formatter: '@'},
  323. {title: '名称', field: 'name', width: 150, hAlign: 0, formatter: '@'},
  324. {title: '单位', field: 'unit', width: 50, hAlign: 1, formatter: '@'},
  325. {title: '单价', field: 'unit_price', hAlign: 2, width: 50},
  326. {title: '台账数量', field: 'quantity', hAlign: 2, width: 60},
  327. {title: '台账金额', field: 'total_price', hAlign: 2, width: 60},
  328. ],
  329. emptyRows: 0,
  330. headRows: 1,
  331. headRowHeight: [32],
  332. headColWidth: [30],
  333. defaultRowHeight: 21,
  334. headerFont: '12px 微软雅黑',
  335. font: '12px 微软雅黑',
  336. selectedBackColor: '#fffacd',
  337. readOnly: true,
  338. },
  339. check: function(data, keyword) {
  340. return !keyword ||
  341. (data.b_code && data.b_code.indexOf(keyword) > -1) ||
  342. (data.name && data.name.indexOf(keyword) > -1);
  343. },
  344. afterLocated: function () {
  345. loadGclGatherRelaData();
  346. },
  347. calcSum: function (result) {
  348. const sum = { name: '合计', searchIndex: -1 };
  349. for (const r of result) {
  350. sum.quantity = ZhCalc.add(r.quantity, sum.quantity);
  351. sum.total_price = ZhCalc.add(r.total_price, sum.total_price);
  352. }
  353. return sum;
  354. }
  355. });
  356. // 展开收起附件
  357. $('a', '#side-menu').bind('click', function (e) {
  358. e.preventDefault();
  359. const tab = $(this), tabPanel = $(tab.attr('content'));
  360. if (!tab.hasClass('active')) {
  361. $('a', '#side-menu').removeClass('active');
  362. $('#right-view .tab-content .tab-pane.active').removeClass('active');
  363. tab.addClass('active');
  364. tabPanel.addClass('active');
  365. showTools(tab.hasClass('active'));
  366. if (tab.attr('content') === '#search') searchBills.spread.refresh();
  367. } else {
  368. tab.removeClass('active');
  369. tabPanel.removeClass('active');
  370. showTools(tab.hasClass('active'));
  371. }
  372. gclSpread.refresh();
  373. refreshRelaSpread();
  374. });
  375. // 下部设置显示相关
  376. $('a', '[name=pos-tab]').click(function() {
  377. const relaTab = this.getAttribute('href');
  378. const optionTab = $('#optionTab').children();
  379. for (const ot of optionTab) {
  380. if (ot.getAttribute('rela-tab') === relaTab) {
  381. $(ot).show();
  382. } else {
  383. $(ot).hide();
  384. }
  385. }
  386. setTimeout(refreshRelaSpread, 100);
  387. });
  388. $('[name=gather-xmj]').change(function() {
  389. const checkOption = $('[name=gather-xmj]:checked');
  390. if (checkOption.length === 0) {
  391. toastr.warning('请至少选择一个汇总条件');
  392. return;
  393. }
  394. const fields = [];
  395. for (const co of checkOption) {
  396. fields.push(co.value);
  397. }
  398. for (const col of gatherLeafXmjSpreadSetting.cols) {
  399. col.visible = col.type === 'Number' || fields.indexOf(col.field) >= 0;
  400. }
  401. gclGatherModel.reGatherLeafXmj(fields);
  402. SpreadJsObj.refreshColumnVisible(gatherLeafXmjSheet);
  403. loadGatherLeafXmjData();
  404. });
  405. $('[name=gather-anc-gcl]').change(function() {
  406. const checkOption = $('[name=gather-anc-gcl]:checked');
  407. // if (checkOption.length === 0) {
  408. // toastr.warning('请至少选择一个汇总条件');
  409. // return;
  410. // }
  411. const fields = [];
  412. for (const co of checkOption) {
  413. fields.push(co.value);
  414. }
  415. for (const col of gatherAncGclSpreadSetting.cols) {
  416. col.visible = col.fixed || fields.indexOf(col.field) >= 0;
  417. }
  418. gclGatherModel.reGatherAncillaryGcl(fields);
  419. SpreadJsObj.refreshColumnVisible(gatherAncGclSheet);
  420. loadGatherAncGclData();
  421. });
  422. $.subMenu({
  423. menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
  424. toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
  425. key: 'menu.1.0.0',
  426. miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
  427. callback: function (info) {
  428. if (info.mini) {
  429. $('.panel-title').addClass('fluid');
  430. $('#sub-menu').removeClass('panel-sidebar');
  431. } else {
  432. $('.panel-title').removeClass('fluid');
  433. $('#sub-menu').addClass('panel-sidebar');
  434. }
  435. autoFlashHeight();
  436. gclSpread.refresh();
  437. refreshRelaSpread();
  438. }
  439. });
  440. $.divResizer({
  441. select: '#main-resize',
  442. callback: function () {
  443. gclSpread.refresh();
  444. let bcontent = $(".bcontent-wrap") ? $(".bcontent-wrap").height() : 0;
  445. $(".sp-wrap").height(bcontent-30);
  446. refreshRelaSpread();
  447. }
  448. });
  449. $.divResizer({
  450. select: '#right-spr',
  451. callback: function () {
  452. gclSpread.refresh();
  453. refreshRelaSpread();
  454. }
  455. });
  456. $('#exportExcel').click(function () {
  457. const data = [];
  458. const setting = {
  459. cols: [
  460. {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 70, formatter: '@'},
  461. {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 300, formatter: '@'},
  462. {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@'},
  463. {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 80, type: 'Number'},
  464. {title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 100, formatter: '@'},
  465. {title: '签约清单|数量', colSpan: '2|1', rowSpan: '1|1', field: 'deal_bills_qty', hAlign: 2, width: 80, type: 'Number'},
  466. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'deal_bills_tp', hAlign: 2, width: 80, type: 'Number'},
  467. {title: '台账|数量', colSpan: '2|1', rowSpan: '1|1', field: 'quantity', hAlign: 2, width: 80, type: 'Number'},
  468. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 80, type: 'Number'},
  469. {title: '台账-签约|数量', colSpan: '2|1', rowSpan: '1|1', field: 'compare_qty', hAlign: 2, width: 80, type: 'Number'},
  470. {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'compare_tp', hAlign: 2, width: 80, type: 'Number'},
  471. {title: '单位工程', colSpan: '1', rowSpan: '2', field: 'dwgc', hAlign: 0, width: 80, formatter: '@'},
  472. {title: '分部工程', colSpan: '1', rowSpan: '2', field: 'fbgc', hAlign: 0, width: 80, formatter: '@'},
  473. {title: '分项工程', colSpan: '1', rowSpan: '2', field: 'fxgc', hAlign: 0, width: 80, formatter: '@'},
  474. {title: '细目', colSpan: '1', rowSpan: '2', field: 'jldy', hAlign: 0, width: 80, formatter: '@'},
  475. {title: '计量单元', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 80, formatter: '@'},
  476. {title: '图册号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 80, formatter: '@'},
  477. ],
  478. headRows: 2,
  479. headRowHeight: [25, 25],
  480. defaultRowHeight: 21,
  481. headerFont: 'bold 10px 微软雅黑',
  482. font: '10px 微软雅黑'
  483. };
  484. if (!gclSheet.zh_data || gclSheet.zh_data.length === 0) return;
  485. for (const gcl of gclSheet.zh_data) {
  486. data.push({
  487. b_code: gcl.b_code, name: gcl.name, unit: gcl.unit,
  488. unit_price: gcl.unit_price,
  489. deal_bills_qty: gcl.deal_bills_qty, deal_bills_tp: gcl.deal_bills_tp,
  490. quantity: gcl.quantity, total_price: gcl.total_price,
  491. compare_qty: gcl.compare_qty, compare_tp: gcl.compare_tp,
  492. });
  493. if (gcl.leafXmjs && gcl.leafXmjs.length > 0) {
  494. for (const xmj of gcl.leafXmjs) {
  495. data.push({
  496. code: xmj.code,
  497. quantity: xmj.quantity,
  498. dwgc: xmj.dwgc, fbgc: xmj.fbgc, fxgc: xmj.fxgc,
  499. jldy: xmj.jldy, bwmx: xmj.bwmx, drawing_code: xmj.drawing_code,
  500. });
  501. }
  502. }
  503. }
  504. SpreadExcelObj.exportSimpleXlsxSheet(setting, data, $('.sidebar-title').attr('data-original-title') + "-清单对比.xlsx");
  505. });
  506. });