|
@@ -0,0 +1,220 @@
|
|
|
+'use strict';
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ *
|
|
|
+ * @author Mai
|
|
|
+ * @date 2020/10/28
|
|
|
+ * @version
|
|
|
+ */
|
|
|
+const showTools = function (show) {
|
|
|
+ const left = $('#left-view'), right = $('#right-view'), parent = left.parent();
|
|
|
+ if (show) {
|
|
|
+ right.show();
|
|
|
+ autoFlashHeight();
|
|
|
+ /**
|
|
|
+ * right.show()后, parent被撑开成2倍left.height, 导致parent.width减少了10px
|
|
|
+ * 第一次left.width调整后,parent的缩回left.height, 此时parent.width又增加了10px
|
|
|
+ * 故需要通过最终的parent.width再计算一次left.width
|
|
|
+ *
|
|
|
+ * Q: 为什么不通过先计算left.width的宽度,以避免计算两次left.width?
|
|
|
+ * A: 右侧工具栏不一定显示,当右侧工具栏显示过一次后,就必须使用parent和right来计算left.width
|
|
|
+ *
|
|
|
+ */
|
|
|
+ //left.css('width', parent.width() - right.outerWidth());
|
|
|
+ //left.css('width', parent.width() - right.outerWidth());
|
|
|
+ const percent = 100 - right.outerWidth() /parent.width() * 100;
|
|
|
+ left.css('width', percent + '%');
|
|
|
+ } else {
|
|
|
+ right.hide();
|
|
|
+ left.css('width', '100%');
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
+$(document).ready(() => {
|
|
|
+ showTools(true);
|
|
|
+ autoFlashHeight();
|
|
|
+ const gclSpread = SpreadJsObj.createNewSpread($('#gcl-spread')[0]);
|
|
|
+ const gclSpreadSetting = {
|
|
|
+ cols: [
|
|
|
+ {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 120, formatter: '@'},
|
|
|
+ {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 230, formatter: '@'},
|
|
|
+ {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 60, formatter: '@', cellType: 'unit'},
|
|
|
+ {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '签约清单|数量', colSpan: '2|1', rowSpan: '1|1', field: 'deal_bills_qty', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'deal_bills_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '台账修订|数量', colSpan: '2|1', rowSpan: '1|1', field: 'new_quantity', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'new_total_price', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '台账|数量', colSpan: '2|1', rowSpan: '1|1', field: 'org_quantity', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'org_total_price', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ ],
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 2,
|
|
|
+ headRowHeight: [25, 25],
|
|
|
+ headColWidth: [30],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ readOnly: true,
|
|
|
+ localCache: {
|
|
|
+ key: 'ledger-gather-gcl',
|
|
|
+ colWidth: true,
|
|
|
+ },
|
|
|
+ getColor: function (sheet, data, row, col, defaultColor) {
|
|
|
+ return data
|
|
|
+ ? (data.differ ? '#FFE699' : '#ffffff')
|
|
|
+ : '#ffffff';
|
|
|
+ }
|
|
|
+ };
|
|
|
+ if (thousandth) sjsSettingObj.setTpThousandthFormat(gclSpreadSetting);
|
|
|
+ SpreadJsObj.initSheet(gclSpread.getActiveSheet(), gclSpreadSetting);
|
|
|
+ const gclSheet = gclSpread.getActiveSheet();
|
|
|
+ const leafXmjSpread = SpreadJsObj.createNewSpread($('#leaf-xmj-spread')[0]);
|
|
|
+ const leafXmjSpreadSetting = {
|
|
|
+ cols: [
|
|
|
+ {title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 120, formatter: '@'},
|
|
|
+ {title: '修订台账|数量', colSpan: '1', rowSpan: '1|1', field: 'new_quantity', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '原台账|数量', colSpan: '1', rowSpan: '1|1', field: 'org_quantity', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '单位工程', colSpan: '1', rowSpan: '2', field: 'dwgc', hAlign: 0, width: 100, formatter: '@'},
|
|
|
+ {title: '分部工程', colSpan: '1', rowSpan: '2', field: 'fbgc', hAlign: 0, width: 100, formatter: '@'},
|
|
|
+ {title: '分项工程', colSpan: '1', rowSpan: '2', field: 'fxgc', hAlign: 0, width: 100, formatter: '@'},
|
|
|
+ {title: '细目', colSpan: '1', rowSpan: '2', field: 'jldy', hAlign: 0, width: 100, formatter: '@'},
|
|
|
+ {title: '计量单元', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 100, formatter: '@'},
|
|
|
+ {title: '图册号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 120, formatter: '@'},
|
|
|
+ ],
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [25, 25],
|
|
|
+ headColWidth: [30],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ readOnly: true,
|
|
|
+ localCache: {
|
|
|
+ key: 'ledger-gather-leafXmj',
|
|
|
+ colWidth: true,
|
|
|
+ },
|
|
|
+ };
|
|
|
+ if (thousandth) sjsSettingObj.setTpThousandthFormat(leafXmjSpreadSetting);
|
|
|
+ SpreadJsObj.initSheet(leafXmjSpread.getActiveSheet(), leafXmjSpreadSetting);
|
|
|
+ const leafXmjSheet = leafXmjSpread.getActiveSheet();
|
|
|
+
|
|
|
+ let gclData = [];
|
|
|
+ // 获取项目节数据
|
|
|
+ function loadLeafXmjData(iGclRow) {
|
|
|
+ const gcl = gclData[iGclRow];
|
|
|
+ SpreadJsObj.resetTopAndSelect(leafXmjSheet);
|
|
|
+ if (gcl) {
|
|
|
+ SpreadJsObj.loadSheetData(leafXmjSheet, SpreadJsObj.DataType.Data, gcl.leafXmjs);
|
|
|
+ } else {
|
|
|
+ SpreadJsObj.loadSheetData(leafXmjSheet, SpreadJsObj.DataType.Data, []);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 切换清单行,读取所属项目节数据
|
|
|
+ gclSpread.getActiveSheet().bind(spreadNS.Events.SelectionChanged, function (e, info) {
|
|
|
+ const iNewRow = info.newSelections[0].row;
|
|
|
+ if (!info.oldSelections || iNewRow !== info.oldSelections[0].row) {
|
|
|
+ loadLeafXmjData(iNewRow);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ function generateChapterHtml(data) {
|
|
|
+ const html = [];
|
|
|
+ if (data) {
|
|
|
+ for (const d of data) {
|
|
|
+ if (['1000', '1100', '1200', '1300'].indexOf(d.code) >= 0) {
|
|
|
+ if (checkZero(d.total_price) && checkZero(d.deal_bills_tp)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ html.push('<tr>');
|
|
|
+ if (d.code) {
|
|
|
+ html.push('<td>', d.code, '</td>');
|
|
|
+ html.push('<td>', d.name, '</td>');
|
|
|
+ } else {
|
|
|
+ html.push('<td colspan="2">', d.name, '</td>');
|
|
|
+ }
|
|
|
+ html.push('<td class="text-right">', d.deal_bills_tp ? d.deal_bills_tp : '', '</td>');
|
|
|
+ html.push('<td class="text-right">', d.new_total_price ? d.new_total_price : '', '</td>');
|
|
|
+ html.push('<td class="text-right">', d.org_total_price ? d.org_total_price : '', '</td>');
|
|
|
+ html.push('</tr>');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $('#chapter-list').html(html.join(''));
|
|
|
+ }
|
|
|
+
|
|
|
+ postData('/tender/' + window.location.pathname.split('/')[2] + '/revise/load', {filter: 'bills;pos;reviseBills;revisePos;dealBills'}, function (data) {
|
|
|
+ const setting = {
|
|
|
+ tree: {
|
|
|
+ id: 'ledger_id',
|
|
|
+ pid: 'ledger_pid',
|
|
|
+ order: 'order',
|
|
|
+ level: 'level',
|
|
|
+ rootId: -1,
|
|
|
+ keys: ['id', 'tender_id', 'ledger_id'],
|
|
|
+ stageId: 'id',
|
|
|
+ },
|
|
|
+ pos: { id: 'id', ledgerId: 'lid' },
|
|
|
+ billsFields: ['quantity', 'total_price'],
|
|
|
+ posFields: ['quantity'],
|
|
|
+ chapterFields: ['total_price'],
|
|
|
+ };
|
|
|
+ gclCompareModel.init(gclData, chapter);
|
|
|
+ setting.prefix = 'new_';
|
|
|
+ gclCompareModel.gatherLedgerData(data.reviseBills, data.revisePos, setting);
|
|
|
+ setting.prefix = 'org_';
|
|
|
+ gclCompareModel.gatherLedgerData(data.bills, data.pos, setting);
|
|
|
+ gclCompareModel.gatherDealBills(data.dealBills);
|
|
|
+ gclCompareModel.checkDiffer();
|
|
|
+ SpreadJsObj.loadSheetData(gclSheet, SpreadJsObj.DataType.Data, gclData);
|
|
|
+ loadLeafXmjData(0);
|
|
|
+
|
|
|
+ const chapterData = gclCompareModel.chapterData();
|
|
|
+ generateChapterHtml(chapterData);
|
|
|
+ }, null, true);
|
|
|
+
|
|
|
+ // 展开收起附件
|
|
|
+ $('a', '.right-nav').bind('click', function () {
|
|
|
+ const tab = $(this), tabPanel = $(tab.attr('content'));
|
|
|
+ if (!tab.hasClass('active')) {
|
|
|
+ $('a', '.side-menu').removeClass('active');
|
|
|
+ $('.tab-content .tab-select-show').removeClass('active');
|
|
|
+ tab.addClass('active');
|
|
|
+ tabPanel.addClass('active');
|
|
|
+ showTools(tab.hasClass('active'));
|
|
|
+ } else {
|
|
|
+ tab.removeClass('active');
|
|
|
+ tabPanel.removeClass('active');
|
|
|
+ showTools(tab.hasClass('active'));
|
|
|
+ }
|
|
|
+ gclSpread.refresh();
|
|
|
+ leafXmjSpread.refresh();
|
|
|
+ });
|
|
|
+ $.subMenu({
|
|
|
+ menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
|
|
|
+ toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
|
|
|
+ key: 'menu.1.0.0',
|
|
|
+ miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
|
|
|
+ callback: function (info) {
|
|
|
+ if (info.mini) {
|
|
|
+ $('.panel-title').addClass('fluid');
|
|
|
+ $('#sub-menu').removeClass('panel-sidebar');
|
|
|
+ } else {
|
|
|
+ $('.panel-title').removeClass('fluid');
|
|
|
+ $('#sub-menu').addClass('panel-sidebar');
|
|
|
+ }
|
|
|
+ autoFlashHeight();
|
|
|
+ gclSpread.refresh();
|
|
|
+ leafXmjSpread.refresh();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ $.divResizer({
|
|
|
+ select: '#main-resize',
|
|
|
+ callback: function () {
|
|
|
+ gclSpread.refresh();
|
|
|
+ let bcontent = $(".bcontent-wrap") ? $(".bcontent-wrap").height() : 0;
|
|
|
+ $(".sp-wrap").height(bcontent-30);
|
|
|
+ leafXmjSpread.refresh();
|
|
|
+ }
|
|
|
+ });
|
|
|
+});
|