'use strict'; /** * 多期比较 * * @author Mai * @date * @version */ const billsSpreadSetting = { baseCols: [ {title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 150, formatter: '@', cellType: 'tree'}, {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 80, formatter: '@'}, {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 230, formatter: '@'}, {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 50, formatter: '@', cellType: 'unit'}, {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number'}, {title: '台账|数量', colSpan: '2|1', rowSpan: '1|1', field: 'quantity', hAlign: 2, width: 60, type: 'Number', }, {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 60, type: 'Number', }, ], extraCols: [ {title: '%s|数量', colSpan: '2|1', rowSpan: '1|1', field: '{%s}_qty{%d}', hAlign: 2, width: 60, type: 'Number', }, {title: '|金额', colSpan: '|1', rowSpan: '|1', field: '{%s}_tp{%d}', hAlign: 2, width: 60, type: 'Number', }, ], specExtraCols: [ {title: '合计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'sum_{%s}_qty', hAlign: 2, width: 60, type: 'Number', }, {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sum_{%s}_tp', hAlign: 2, width: 60, type: 'Number', }, ], emptyRows: 3, headRows: 2, headRowHeight: [25, 25], headerFont: '12px 微软雅黑', font: '12px 微软雅黑', defaultRowHeight: 21, readOnly: true, selectedBackColor: '#fffacd', }; const posSpreadSetting = { baseCols: [ {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 230, formatter: '@'}, {title: '台账数量', colSpan: '1', rowSpan: '1', field: 'quantity', hAlign: 2, width: 80, type: 'Number'}, ], extraCols: [ {title: '%s\n数量', colSpan: '1', rowSpan: '1', field: '{%s}_qty{%d}', hAlign: 2, width: 80, type: 'Number'}, ], specExtraCols: [ {title: '合计数量', colSpan: '1', rowSpan: '1', field: 'sum_{%s}_qty', hAlign: 2, width: 80, type: 'Number', }, ], emptyRows: 3, headRows: 1, headRowHeight: [32], headColWidth: [30], defaultRowHeight: 21, headerFont: '12px 微软雅黑', font: '12px 微软雅黑', readOnly: true, selectedBackColor: '#fffacd', }; const exportBillsSpreadSetting = { baseCols: [ {title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 150, formatter: '@', cellType: 'tree'}, {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 80, formatter: '@'}, {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 230, formatter: '@'}, {title: '单位', colSpan: '1', rowSpan: '2', field: 'unit', hAlign: 1, width: 50, formatter: '@', cellType: 'unit'}, {title: '单价', colSpan: '1', rowSpan: '2', field: 'unit_price', hAlign: 2, width: 60, type: 'Number'}, {title: '台账|数量', colSpan: '2|1', rowSpan: '1|1', field: 'quantity', hAlign: 2, width: 60, type: 'Number', }, {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 60, type: 'Number', }, ], extraCols: [ {title: '%s|数量', colSpan: '2|1', rowSpan: '1|1', field: '{%s}_qty{%d}', hAlign: 2, width: 60, type: 'Number', }, {title: '|金额', colSpan: '|1', rowSpan: '|1', field: '{%s}_tp{%d}', hAlign: 2, width: 60, type: 'Number', }, ], specExtraCols: [ {title: '合计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'sum_{%s}_qty', hAlign: 2, width: 60, type: 'Number', }, {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sum_{%s}_tp', hAlign: 2, width: 60, type: 'Number', }, ], endCols: [], emptyRows: 3, headRows: 2, headRowHeight: [25, 25], headerFont: '12px 微软雅黑', font: '12px 微软雅黑', defaultRowHeight: 21, readOnly: true, selectedBackColor: '#fffacd', }; const gclSpreadSetting = { baseCols: [ {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 80, 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: 60, type: 'Number'}, {title: '签约清单|数量', colSpan: '2|1', rowSpan: '1|1', field: 'deal_bills_qty', hAlign: 2, width: 60, type: 'Number'}, {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'deal_bills_tp', hAlign: 2, width: 60, type: 'Number'}, {title: '台账|数量', colSpan: '2|1', rowSpan: '1|1', field: 'quantity', hAlign: 2, width: 60, type: 'Number'}, {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 60, type: 'Number'}, ], extraCols: [ {title: '%s|数量', colSpan: '2|1', rowSpan: '1|1', field: '{%s}_qty{%d}', hAlign: 2, width: 60, type: 'Number', }, {title: '|金额', colSpan: '|1', rowSpan: '|1', field: '{%s}_tp{%d}', hAlign: 2, width: 60, type: 'Number', }, ], specExtraCols: [ {title: '合计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'sum_{%s}_qty', hAlign: 2, width: 60, type: 'Number', }, {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sum_{%s}_tp', hAlign: 2, width: 60, type: 'Number', }, ], emptyRows: 0, headRows: 2, headRowHeight: [25, 25], headColWidth: [30], defaultRowHeight: 21, headerFont: '12px 微软雅黑', font: '12px 微软雅黑', readOnly: true, }; const leafXmjSpreadSetting = { baseCols: [ {title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 100, formatter: '@'}, {title: '单位工程', colSpan: '1', rowSpan: '2', field: 'dwgc', hAlign: 0, width: 80, formatter: '@'}, {title: '分部工程', colSpan: '1', rowSpan: '2', field: 'fbgc', hAlign: 0, width: 80, formatter: '@'}, {title: '分项工程', colSpan: '1', rowSpan: '2', field: 'fxgc', hAlign: 0, width: 80, formatter: '@'}, {title: '细目', colSpan: '1', rowSpan: '2', field: 'jldy', hAlign: 0, width: 80, formatter: '@'}, {title: '计量单元', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 80, formatter: '@'}, {title: '图册号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 80, formatter: '@'}, {title: '台账数量', colSpan: '1', rowSpan: '2', field: 'quantity', hAlign: 2, width: 80, type: 'Number'}, ], extraCols: [ {title: '%s\n数量', colSpan: '1', rowSpan: '2', field: '{%s}_qty{%d}', hAlign: 2, width: 80}, ], specExtraCols: [ {title: '合计数量', colSpan: '1', rowSpan: '2', field: 'sum_{%s}_qty', hAlign: 2, width: 80, type: 'Number', }, ], emptyRows: 0, headRows: 2, headRowHeight: [25, 25], headColWidth: [30], defaultRowHeight: 21, headerFont: '12px 微软雅黑', font: '12px 微软雅黑', readOnly: true, }; const exportGclSpreadSetting = { baseCols: [ {title: '清单编号', colSpan: '1', rowSpan: '2', field: 'b_code', hAlign: 0, width: 80, formatter: '@'}, {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 230, formatter: '@'}, {title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 100, formatter: '@'}, {title: '单位工程', colSpan: '1', rowSpan: '2', field: 'dwgc', hAlign: 0, width: 80, formatter: '@'}, {title: '分部工程', colSpan: '1', rowSpan: '2', field: 'fbgc', hAlign: 0, width: 80, formatter: '@'}, {title: '分项工程', colSpan: '1', rowSpan: '2', field: 'fxgc', hAlign: 0, width: 80, formatter: '@'}, {title: '细目', colSpan: '1', rowSpan: '2', field: 'jldy', hAlign: 0, width: 80, formatter: '@'}, {title: '计量单元', colSpan: '1', rowSpan: '2', field: 'bwmx', hAlign: 0, width: 80, 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: 60, type: 'Number'}, {title: '签约清单|数量', colSpan: '2|1', rowSpan: '1|1', field: 'deal_bills_qty', hAlign: 2, width: 60, type: 'Number'}, {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'deal_bills_tp', hAlign: 2, width: 60, type: 'Number'}, {title: '台账|数量', colSpan: '2|1', rowSpan: '1|1', field: 'quantity', hAlign: 2, width: 60, type: 'Number'}, {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'total_price', hAlign: 2, width: 60, type: 'Number'}, ], extraCols: [ {title: '%s|数量', colSpan: '2|1', rowSpan: '1|1', field: '{%s}_qty{%d}', hAlign: 2, width: 60, type: 'Number', }, {title: '|金额', colSpan: '|1', rowSpan: '|1', field: '{%s}_tp{%d}', hAlign: 2, width: 60, type: 'Number', }, ], specExtraCols: [ {title: '合计|数量', colSpan: '2|1', rowSpan: '1|1', field: 'sum_{%s}_qty', hAlign: 2, width: 60, type: 'Number', }, {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'sum_{%s}_tp', hAlign: 2, width: 60, type: 'Number', }, ], endCols: [ {title: '图册号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 80, formatter: '@'}, ], emptyRows: 0, headRows: 2, headRowHeight: [25, 25], headColWidth: [30], defaultRowHeight: 21, headerFont: '12px 微软雅黑', font: '12px 微软雅黑', readOnly: true, }; const chapterSpreadSetting = { baseCols: [ {title: '章节', colSpan: '1', rowSpan: '1', field: 'code', hAlign: 0, width: 80, formatter: '@'}, {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 230, formatter: '@'}, {title: '签约金额', colSpan: '1', rowSpan: '1', field: 'deal_bills_tp', hAlign: 2, width: 80, type: 'Number'}, {title: '台账金额', colSpan: '1', rowSpan: '1', field: 'total_price', hAlign: 2, width: 80, type: 'Number'}, ], extraCols: [ {title: '%s\n金额', colSpan: '1', rowSpan: '1', field: '{%s}_tp{%d}', hAlign: 2, width: 80, type: 'Number', }, ], specExtraCols: [ {title: '合计金额', colSpan: '1', rowSpan: '1', field: 'sum_{%s}_tp', hAlign: 2, width: 80, type: 'Number', }, ], emptyRows: 0, headRows: 1, headRowHeight: [38], headColWidth: [30], defaultRowHeight: 21, headerFont: '12px 微软雅黑', font: '12px 微软雅黑', readOnly: true, }; function initSpreadSettingWithRoles(compareRoles) { function setSpreadSettingCols(setting, fieldSufs, Roles) { function addExtraCols(fieldSuf, Role) { const sourceType = $('[name=compare-data]:checked').val(); for (const ec of setting.extraCols) { const col = JSON.parse(JSON.stringify(ec)); col.title = _.replace(col.title, '%s', Role); col.field = _.replace(_.replace(col.field, '{%s}', sourceType), '{%d}', fieldSuf); setting.cols.push(col); } } setting.cols = []; for (const col of setting.baseCols) { setting.cols.push(col); } setting.frozenColCount = setting.baseCols.length; setting.frozenLineColor = '#93b5e4'; for (const index in fieldSufs) { addExtraCols(fieldSufs[index], Roles[index]); } if (setting.specExtraCols) { const sourceType = $('[name=compare-data]:checked').val(); for (const col of setting.specExtraCols) { const eCol = JSON.parse(JSON.stringify(col)); eCol.field = _.replace(eCol.field, '{%s}', sourceType); setting.cols.push(eCol); } } if (setting.endCols) { for (const col of setting.endCols) { setting.cols.push(col); } } } const fieldSufs = [], roles = [], trs = $('tr[stage-id]'); for (let r of compareRoles) { if (r > 0) { const tr = trs[r-1]; if (tr) { fieldSufs.push(r + ''); roles.push(`${tr.children[0].textContent}(${tr.children[1].textContent})`); } } } setSpreadSettingCols(billsSpreadSetting, fieldSufs, roles); setSpreadSettingCols(posSpreadSetting, fieldSufs, roles); setSpreadSettingCols(exportBillsSpreadSetting, fieldSufs, roles); setSpreadSettingCols(gclSpreadSetting, fieldSufs, roles); setSpreadSettingCols(leafXmjSpreadSetting, fieldSufs, roles); setSpreadSettingCols(exportGclSpreadSetting, fieldSufs, roles); setSpreadSettingCols(chapterSpreadSetting, fieldSufs, roles); } function calculateStageLedgerData(datas) { for (const d of datas) { d.gather_qty = ZhCalc.add(d.contract_qty, d.qc_qty); d.gather_tp = ZhCalc.sum([d.contract_tp, d.qc_tp, d.pc_tp]); // d.pc_tp = ZhCalc.add(d.qc_tp, d.qc_pc_tp); // d.contract_tp = ZhCalc.add(d.contract_tp, d.contract_pc_tp); } } function calculateStagePosData(datas) { for (const d of datas) { d.gather_qty = ZhCalc.add(d.contract_qty, d.qc_qty); } } $(document).ready(() => { autoFlashHeight(); initSpreadSettingWithRoles([]); const billsSpread = SpreadJsObj.createNewSpread($('#bills-spread')[0]); const billsSheet = billsSpread.getActiveSheet(); sjsSettingObj.setFxTreeStyle(billsSpreadSetting, sjsSettingObj.FxTreeStyle.jz); if (thousandth) sjsSettingObj.setTpThousandthFormat(billsSpreadSetting); SpreadJsObj.initSheet(billsSheet, billsSpreadSetting); const posSpread = SpreadJsObj.createNewSpread($('#pos-spread')[0]); const posSheet = posSpread.getActiveSheet(); if (thousandth) sjsSettingObj.setTpThousandthFormat(posSpreadSetting); SpreadJsObj.initSheet(posSheet, posSpreadSetting); let gclGatherData; const gclSpread = SpreadJsObj.createNewSpread($('#gcl-spread')[0]); const gclSheet = gclSpread.getActiveSheet(); sjsSettingObj.setFxTreeStyle(gclSpreadSetting, sjsSettingObj.FxTreeStyle.jz); if (thousandth) sjsSettingObj.setTpThousandthFormat(gclSpreadSetting); SpreadJsObj.initSheet(gclSheet, gclSpreadSetting); const leafXmjSpread = SpreadJsObj.createNewSpread($('#leaf-xmj-spread')[0]); const leafXmjSheet = leafXmjSpread.getActiveSheet(); if (thousandth) sjsSettingObj.setTpThousandthFormat(leafXmjSpreadSetting); SpreadJsObj.initSheet(leafXmjSheet, leafXmjSpreadSetting); const chapterSpread = SpreadJsObj.createNewSpread($('#chapter-spread')[0]); const chapterSheet = chapterSpread.getActiveSheet(); sjsSettingObj.setGridSelectStyle(gclSpreadSetting, sjsSettingObj.FxTreeStyle.jz); if (thousandth) sjsSettingObj.setTpThousandthFormat(chapterSpreadSetting); SpreadJsObj.initSheet(chapterSheet, chapterSpreadSetting); $.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(); billsSpread.refresh(); posSpread.refresh(); } }); // 上下窗口resizer $.divResizer({ select: '#main-resize', callback: function () { billsSpread.refresh(); let bcontent = $("#main-bottom").length > 0 ? $("#main-bottom").height() : 0; $("#pos-spread").height(bcontent-30); posSpread.refresh(); } }); $.divResizer({ select: '#gcl-resize', callback: function () { gclSpread.refresh(); let bcontent = $("#leafxmj-bottom").length > 0 ? $("#leafxmj-bottom").height() : 0; $("#leaf-xmj-spread").height(bcontent-30); leafXmjSpread.refresh(); } }); const cTree = createNewPathTree('master', { id: 'ledger_id', pid: 'ledger_pid', order: 'order', level: 'level', rootId: -1, keys: ['id', 'tender_id', 'ledger_id'], masterId: 'id', minorId: 'lid', calcFields: ['total_price', 'sum_contract_tp', 'sum_qc_tp', 'sum_gather_tp'], markFoldKey: 'bills-fold', markFoldSubKey: window.location.pathname.split('/')[2], }); const cPos = new MasterPosData({ id: 'id', ledgerId: 'lid', masterId: 'id', minorId: 'pid', calcFun: function (pos) { pos.gather_qty = ZhCalc.add(pos.contract_qty, pos.qc_qty); } }); postData(window.location.pathname + '/load', {main: true}, function (result) { cTree.loadDatas(result.main.ledger); treeCalc.calculateAll(cTree); cPos.loadDatas(result.main.pos); SpreadJsObj.loadSheetData(billsSheet, SpreadJsObj.DataType.Tree, cTree); loadPosData(0); const checkField = function (x) { if (x === 'quantity') return true; if (x === 'total_price') return true; if (x.indexOf('_qty') >= 0) return true; if (x.indexOf('_tp') >= 0) return true; return false; }; gclGatherModel.loadGatherField(checkField, checkField); gclGatherModel.loadLedgerData(result.main.ledger); gclGatherModel.loadPosData(result.main.pos); gclGatherModel.loadDealBillsData(result.main.deal); gclGatherData = gclGatherModel.gatherGclData(); SpreadJsObj.loadSheetData(gclSheet, SpreadJsObj.DataType.Data, gclGatherData); loadLeafXmjData(0); const chapterData = gclGatherModel.gatherChapterData(chapter, result.spec, ['deal_tp', 'total_price', 'sum_contract_tp', 'sum_qc_tp', 'sum_gather_tp']); SpreadJsObj.loadSheetData(chapterSheet, SpreadJsObj.DataType.Data, chapterData); }, null, true); function loadPosData(iRow) { const node = iRow ? billsSheet.zh_tree.nodes[iRow] : SpreadJsObj.getSelectObject(billsSheet); const posRange = node ? (cPos.getLedgerPos(node.id) || []) : []; SpreadJsObj.loadSheetData(posSheet, SpreadJsObj.DataType.Data, posRange); SpreadJsObj.resetTopAndSelect(posSheet); } function loadLeafXmjData(iRow) { const gcl = iRow ? gclSheet.zh_data[iRow] : SpreadJsObj.getSelectObject(gclSheet); if (gcl) { SpreadJsObj.loadSheetData(leafXmjSheet, SpreadJsObj.DataType.Data, gcl.leafXmjs); } else { SpreadJsObj.loadSheetData(leafXmjSheet, SpreadJsObj.DataType.Data, []); } SpreadJsObj.resetTopAndSelect(leafXmjSheet); } billsSheet.bind(spreadNS.Events.SelectionChanged, function (e, info) { console.log(SpreadJsObj.getSelectObject(info.sheet)); if (info.newSelections) { const iNewRow = info.newSelections[0].row; if (info.oldSelections) { const iOldRow = info.oldSelections[0].row; if (iNewRow !== iOldRow) { SpreadJsObj.resetTopAndSelect(posSheet); loadPosData(iNewRow); } } else { SpreadJsObj.resetTopAndSelect(leafXmjSheet); loadPosData(iNewRow); } } }); gclSheet.bind(spreadNS.Events.SelectionChanged, function (e, info) { if (info.newSelections) { const iNewRow = info.newSelections[0].row; if (info.oldSelections) { const iOldRow = info.oldSelections[0].row; if (iNewRow !== iOldRow) { SpreadJsObj.resetTopAndSelect(leafXmjSheet); loadLeafXmjData(iNewRow); } } else { SpreadJsObj.resetTopAndSelect(leafXmjSheet); loadLeafXmjData(iNewRow); } } }); const compareStages = []; $('#select-qi-ok').click(function () { function refreshView (data) { const gatherField = ['deal_tp', 'total_price', 'sum_contract_tp', 'sum_qc_tp', 'sum_gather_tp']; compareStages.length = 0; for (let order = 0, iLength = trs.length; order < iLength; order++) { const tr = trs[order]; if ($('input', tr)[0].checked) { compareStages.push(order + 1); gatherField.push(`contract_tp${order}`, `qc_tp${order}`, `gather_tp${order}`); } } // setLocalCache(cCacheKey, compareStages.join(',')); initSpreadSettingWithRoles(compareStages); SpreadJsObj.initSheet(billsSheet, billsSpreadSetting); treeCalc.calculateAll(cTree); SpreadJsObj.loadSheetData(billsSheet, SpreadJsObj.DataType.Tree, cTree); SpreadJsObj.initSheet(posSheet, posSpreadSetting); loadPosData(); SpreadJsObj.reLoadSheetHeader(gclSheet); SpreadJsObj.reLoadSheetHeader(leafXmjSheet); gclGatherModel.loadLedgerData(cTree.datas); gclGatherModel.loadPosData(cPos.datas); gclGatherData = gclGatherModel.gatherGclData(); SpreadJsObj.loadSheetData(gclSheet, SpreadJsObj.DataType.Data, gclGatherData); loadLeafXmjData(0); const chapterData = gclGatherModel.gatherChapterData(chapter, data.spec, gatherField); SpreadJsObj.reLoadSheetHeader(chapterSheet); SpreadJsObj.loadSheetData(chapterSheet, SpreadJsObj.DataType.Data, chapterData); } let loadData = [], showData = [], trs = $('tr[stage-id]'); for (let order = 0, iLength = trs.length; order < iLength; order++) { const tr = trs[order]; if ($('input[type=checkbox]', tr)[0].checked) { if (!cTree.minorData[order + 1]) { loadData.push(order + 1); } showData.push(order + 1); } } if (loadData.length > 0) { postData(window.location.pathname + '/load', {stages: loadData}, function (result) { for (const aData of result.stages) { calculateStageLedgerData(aData.bills); cTree.loadMinorData(aData.bills, aData.order + '', ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'gather_qty', 'gather_tp'], ['contract_tp', 'qc_tp', 'gather_tp']); calculateStagePosData(aData.pos); cPos.loadMinorData(aData.pos, aData.order + '', ['contract_qty', 'qc_qty', 'gather_qty']); } cTree.reCalcSumData(['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'gather_qty', 'gather_tp'], showData); treeCalc.calculateAll(cTree); cPos.reCalcSumData(['contract_qty', 'qc_qty', 'gather_qty'], showData); refreshView(result); $('#select-qi').modal('hide'); }, null, true); } else { cTree.reCalcSumData(['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'gather_qty', 'gather_tp'], showData); treeCalc.calculateAll(cTree); cPos.reCalcSumData(['contract_qty', 'qc_qty', 'gather_qty'], showData); refreshView(); $('#select-qi').modal('hide'); } }); (function (select, sheet) { $(select).click(function () { if (!sheet.zh_tree) return; const tag = $(this).attr('tag'); const tree = sheet.zh_tree; switch (tag) { case "1": case "2": case "3": case "4": case "5": tree.expandByLevel(parseInt(tag)); SpreadJsObj.refreshTreeRowVisible(sheet); break; case "last": tree.expandByCustom(() => { return true; }); SpreadJsObj.refreshTreeRowVisible(sheet); break; case "leafXmj": tree.expandToLeafXmj(); SpreadJsObj.refreshTreeRowVisible(sheet); break; } }); })('a[name=showLevel]', billsSheet); $('#exportExcel').click(function () { const exportLedger = function () { const data = []; if (!billsSheet.zh_tree) return; for (const node of billsSheet.zh_tree.nodes) { data.push(node); const posRange = cPos.getLedgerPos(node.id); if (posRange && posRange.length > 0) { for (const pr of posRange) { data.push(pr); } } } SpreadExcelObj.exportSimpleXlsxSheet(exportBillsSpreadSetting, data, $('.sidebar-title').attr('data-original-title') + "-多期比较.xlsx"); }; const exportGcl = function () { const data = []; if (!gclSheet.zh_data) return; for (const node of gclSheet.zh_data) { data.push(node); for (const leafXmj of node.leafXmjs) { data.push(leafXmj); } } SpreadExcelObj.exportSimpleXlsxSheet(exportGclSpreadSetting, data, $('.sidebar-title').attr('data-original-title') + "-多期比较.xlsx"); }; const exportChapter = function () { SpreadExcelObj.exportSimpleXlsxSheet(chapterSpreadSetting, chapterSheet.zh_data, $('.sidebar-title').attr('data-original-title') + "-多期比较.xlsx"); }; const cur = $('.active[name=compareType]').attr('href'); if (cur.indexOf('gcl') >= 0) { exportGcl(); } else if (cur.indexOf('chapter') >= 0) { exportChapter(); } else { exportLedger(); } }); $('[name=compare-data]').click(function () { initSpreadSettingWithRoles(compareStages); SpreadJsObj.reLoadSheetHeader(billsSheet); SpreadJsObj.reloadColData(billsSheet, billsSpreadSetting.baseCols.length, compareStages.length * billsSpreadSetting.extraCols.length + billsSpreadSetting.specExtraCols.length); SpreadJsObj.reLoadSheetHeader(posSheet); SpreadJsObj.reloadColData(posSheet, posSpreadSetting.baseCols.length, compareStages.length * posSpreadSetting.extraCols.length + posSpreadSetting.specExtraCols.length); SpreadJsObj.reLoadSheetHeader(gclSheet); SpreadJsObj.reloadColData(gclSheet, gclSpreadSetting.baseCols.length, compareStages.length * gclSpreadSetting.extraCols.length + gclSpreadSetting.specExtraCols.length); SpreadJsObj.reLoadSheetHeader(leafXmjSheet); SpreadJsObj.reloadColData(leafXmjSheet, leafXmjSpreadSetting.baseCols.length, compareStages.length * leafXmjSpreadSetting.extraCols.length + leafXmjSpreadSetting.specExtraCols.length); SpreadJsObj.reLoadSheetHeader(chapterSheet); SpreadJsObj.reloadColData(chapterSheet, chapterSpreadSetting.baseCols.length, compareStages.length * chapterSpreadSetting.extraCols.length + chapterSpreadSetting.specExtraCols.length); }); $('[name=compareType]').click(function () { $('[name=compareType]').removeClass('active'); $(this).addClass('active'); $('#compareType').children().removeClass('active'); $(this.getAttribute('href')).addClass('active'); billsSpread.refresh(); posSpread.refresh(); gclSpread.refresh(); leafXmjSpread.refresh(); chapterSpread.refresh(); }); $('#select-qi-all').click(function() { const check = this.checked; $('input', 'tr[stage-id]').each((i, x) => { x.checked = check; }) }); });