ledger_gather.js 24 KB

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