|
@@ -0,0 +1,279 @@
|
|
|
+function getGxbyText(data) {
|
|
|
+ const def = thirdParty.gxby.find(function (x) {
|
|
|
+ return x.value === data.gxby_status;
|
|
|
+ });
|
|
|
+ return def ? def.name : '';
|
|
|
+}
|
|
|
+function getDaglText(data) {
|
|
|
+ const def = thirdParty.dagl.find(function (x) {
|
|
|
+ return x.value === data.dagl_status;
|
|
|
+ });
|
|
|
+ return def ? def.name : '';
|
|
|
+}
|
|
|
+
|
|
|
+const ckBillsSpread = window.location.pathname + '-billsSelect';
|
|
|
+$(document).ready(() => {
|
|
|
+ autoFlashHeight();
|
|
|
+
|
|
|
+ let searchLedger;
|
|
|
+ const settleTreeSetting = {
|
|
|
+ id: 'ledger_id',
|
|
|
+ pid: 'ledger_pid',
|
|
|
+ order: 'order',
|
|
|
+ level: 'level',
|
|
|
+ rootId: -1,
|
|
|
+ keys: ['id', 'tender_id', 'ledger_id'],
|
|
|
+ stageId: 'id',
|
|
|
+ autoExpand: 3,
|
|
|
+ markExpandKey: 'settle-select-expand',
|
|
|
+ markExpandSubKey: window.location.pathname.split('/')[2],
|
|
|
+ calcFields: ['total_price', 'end_contract_tp', 'end_qc_tp', 'end_gather_tp', 'end_correct_tp'],
|
|
|
+ calcFun: function(node) {
|
|
|
+ if (!node.children || node.children.length === 0) {
|
|
|
+ node.end_gather_qty = ZhCalc.add(node.end_contract_qty, node.end_qc_qty);
|
|
|
+ if (node.end_contract_qty) {
|
|
|
+ node.end_correct_tp = ZhCalc.add(node.end_qc_tp, ZhCalc.mul(node.end_contract_qty, node.unit_price, tenderInfo.decimal.tp));
|
|
|
+ } else {
|
|
|
+ node.end_correct_tp = node.end_gather_tp;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ node.end_gather_tp = ZhCalc.add(node.end_contract_tp, node.end_qc_tp);
|
|
|
+ node.end_gather_percent = ZhCalc.mul(ZhCalc.div(node.end_gather_tp, node.end_final_tp), 100, 2);
|
|
|
+ node.end_correct_percent = ZhCalc.mul(ZhCalc.div(node.end_correct_tp, node.end_final_tp), 100, 2);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const settleTree = createNewPathTree('stage', settleTreeSetting);
|
|
|
+ const settlePosSetting = {
|
|
|
+ id: 'id', ledgerId: 'lid',
|
|
|
+ calcFun: function(pos) {
|
|
|
+ pos.end_gather_qty = ZhCalc.add(pos.end_contract_qty, pos.end_qc_qty);
|
|
|
+ pos.sum = ZhCalc.add(pos.end_qc_qty, pos.quantity);
|
|
|
+ pos.end_gather_percent = ZhCalc.mul(ZhCalc.div(pos.end_gather_qty, pos.sum), 100, 2);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ const settlePos = new StagePosData(settlePosSetting);
|
|
|
+
|
|
|
+ const slSpread = SpreadJsObj.createNewSpread($('#settle-bills')[0]);
|
|
|
+ const slSheet = slSpread.getActiveSheet();
|
|
|
+ slSheet.frozenColumnCount(billsSpreadSetting.cols.findIndex(x => { return x.field === 'total_price'; }) + 1);
|
|
|
+ slSheet.options.frozenlineColor = '#93b5e4';
|
|
|
+ const ratioCol = billsSpreadSetting.cols.find(x => {return x.field === 'end_final_1_percent' || x.field === 'end_correct_1_percent'});
|
|
|
+ if (ratioCol) ratioCol.field = tenderInfo.display.stage.correct ? 'end_correct_1_percent' : 'end_final_1_percent';
|
|
|
+ billsSpreadSetting.getColor = function (sheet, data, row, col, defaultColor) {
|
|
|
+ if (!data) return defaultColor;
|
|
|
+ if (data.children && data.children.length > 0) return defaultColor;
|
|
|
+
|
|
|
+ if (col.field === 'gxby') {
|
|
|
+ const def = thirdParty.gxby.find(function (x) {
|
|
|
+ return x.value === data.gxby_status;
|
|
|
+ });
|
|
|
+ if (def && def.color) return def.color;
|
|
|
+ } else if (col.field === 'dagl') {
|
|
|
+ const def = thirdParty.dagl.find(function (x) {
|
|
|
+ return x.value === data.dagl_status;
|
|
|
+ });
|
|
|
+ if (def && def.color) return def.color;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ sjsSettingObj.setFxTreeStyle(billsSpreadSetting, sjsSettingObj.FxTreeStyle.jz);
|
|
|
+ sjsSettingObj.set3FCols(billsSpreadSetting.cols, [
|
|
|
+ {field: 'gxby', getValue: getGxbyText, url_field: 'gxby_url'},
|
|
|
+ {field: 'dagl', getValue: getDaglText, url_field: 'dagl_url'},
|
|
|
+ ]);
|
|
|
+ SpreadJsObj.initSheet(slSheet, billsSpreadSetting);
|
|
|
+
|
|
|
+ const spSpread = SpreadJsObj.createNewSpread($('#settle-pos')[0]);
|
|
|
+ const spSheet = spSpread.getActiveSheet();
|
|
|
+ spSheet.frozenColumnCount(posSpreadSetting.cols.findIndex(x => { return x.field === 'total_price'; }) + 1);
|
|
|
+ spSheet.options.frozenlineColor = '#93b5e4';
|
|
|
+ posSpreadSetting.getColor = function (sheet, data, row, col, defaultColor) {
|
|
|
+ if (!data) return defaultColor;
|
|
|
+
|
|
|
+ if (col.field === 'gxby') {
|
|
|
+ const def = thirdParty.gxby.find(function (x) {
|
|
|
+ return x.value === data.gxby_status;
|
|
|
+ });
|
|
|
+ if (def && def.color) return def.color;
|
|
|
+ } else if (col.field === 'dagl') {
|
|
|
+ const def = thirdParty.dagl.find(function (x) {
|
|
|
+ return x.value === data.dagl_status;
|
|
|
+ });
|
|
|
+ if (def && def.color) return def.color;
|
|
|
+ }
|
|
|
+ };
|
|
|
+ sjsSettingObj.set3FCols(posSpreadSetting.cols, [
|
|
|
+ {field: 'gxby', getValue: getGxbyText, url_field: 'gxby_url'},
|
|
|
+ {field: 'dagl', getValue: getDaglText, url_field: 'dagl_url'},
|
|
|
+ ]);
|
|
|
+ SpreadJsObj.initSheet(spSheet, posSpreadSetting);
|
|
|
+
|
|
|
+ const settleBillsObj = {
|
|
|
+ loadRelaData: function() {
|
|
|
+ SpreadJsObj.saveTopAndSelect(slSheet, ckBillsSpread);
|
|
|
+ SpreadJsObj.resetTopAndSelect(spSheet);
|
|
|
+ settlePosObj.loadCurPosData();
|
|
|
+ },
|
|
|
+ selectionChanged: function(e, info) {
|
|
|
+ if (!info.oldSelections || !info.oldSelections[0] || info.newSelections[0].row !== info.oldSelections[0].row) {
|
|
|
+ settleBillsObj.loadRelaData();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ topRowChanged(e, info) {
|
|
|
+ SpreadJsObj.saveTopAndSelect(info.sheet, ckBillsSpread);
|
|
|
+ },
|
|
|
+ buttonClicked: function(e, info) {
|
|
|
+ if (!info.sheet.zh_setting) return;
|
|
|
+
|
|
|
+ const col = info.sheet.zh_setting.cols[info.col];
|
|
|
+ if (col.field !== 'selected') return;
|
|
|
+
|
|
|
+ const node = SpreadJsObj.getSelectObject(info.sheet);
|
|
|
+ node.selected = !node.selected;
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ const posterity = tsObj.tenderSourceTree.getPosterity(node);
|
|
|
+ for (const p of posterity) {
|
|
|
+ p.selected = node.selected;
|
|
|
+ if (!p.children || p.children.length === 0){
|
|
|
+ if (p.selected) {
|
|
|
+ tsObj._addTender(p);
|
|
|
+ } else {
|
|
|
+ tsObj._removeTender(p);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row, posterity.length + 1);
|
|
|
+ } else {
|
|
|
+ if (node.selected) {
|
|
|
+ tsObj._addTender(node);
|
|
|
+ } else {
|
|
|
+ tsObj._removeTender(node);
|
|
|
+ }
|
|
|
+ SpreadJsObj.reLoadRowData(info.sheet, info.row, 1);
|
|
|
+ }
|
|
|
+ tsObj.reloadResultData();
|
|
|
+ },
|
|
|
+ };
|
|
|
+ slSpread.bind(spreadNS.Events.ButtonClicked, stageTreeSpreadObj.buttonClicked);
|
|
|
+ slSpread.bind(spreadNS.Events.SelectionChanged, settleBillsObj.selectionChanged);
|
|
|
+ slSpread.bind(spreadNS.Events.TopRowChanged, settleBillsObj.topRowChanged);
|
|
|
+
|
|
|
+ const settlePosObj = {
|
|
|
+ loadCurPosData: function() {
|
|
|
+ const billsNode = SpreadJsObj.getSelectObject(slSheet);
|
|
|
+ if (billsNode) {
|
|
|
+ spSheet.zh_setting.readOnly = readOnly;
|
|
|
+ const posRange = settlePos.getLedgerPos(billsNode.id) || [];
|
|
|
+ SpreadJsObj.loadSheetData(spSheet, SpreadJsObj.DataType.Data, posRange, readOnly);
|
|
|
+ } else {
|
|
|
+ spSheet.zh_setting.readOnly = true;
|
|
|
+ SpreadJsObj.loadSheetData(spSheet, SpreadJsObj.DataType.Data, [], true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ postData('load', {filter: 'stageBills;stagePos;settleSelect;tag'}, function(result) {
|
|
|
+ for (const select of result.settleSelect) {
|
|
|
+ if (select.pid) {
|
|
|
+ const sp = result.stagePos.find(x => { return x.id === select.pid });
|
|
|
+ if (sp) sp.selected = true;
|
|
|
+ } else {
|
|
|
+ const sb = result.stageBills.find(x => { return x.id === select.lid });
|
|
|
+ if (sb) sb.selected = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ settleTree.loadDatas(result.stageBills);
|
|
|
+ treeCalc.calculateAll(settleTree);
|
|
|
+ settlePos.loadDatas(result.stagePos);
|
|
|
+ settlePos.calculateAll();
|
|
|
+
|
|
|
+ SpreadJsObj.loadSheetData(slSheet, SpreadJsObj.DataType.Tree, settleTree);
|
|
|
+ SpreadJsObj.loadTopAndSelect(slSpread.getActiveSheet(), ckBillsSpread);
|
|
|
+ settlePosObj.loadCurPosData();
|
|
|
+ });
|
|
|
+
|
|
|
+ // 展开收起工具栏
|
|
|
+ $('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');
|
|
|
+ showSideTools(tab.hasClass('active'));
|
|
|
+ if (tab.attr('content') === '#search' && !searchLedger) {
|
|
|
+ searchLedger = $.billsSearch({
|
|
|
+ selector: '#search',
|
|
|
+ searchSpread: slSpread,
|
|
|
+ searchOver: true,
|
|
|
+ searchEmpty: true,
|
|
|
+ resultSpreadSetting: {
|
|
|
+ cols: [
|
|
|
+ {title: '项目节编号', field: 'code', hAlign: 0, width: 90, formatter: '@'},
|
|
|
+ {title: '清单编号', field: 'b_code', hAlign: 0, width: 80, formatter: '@'},
|
|
|
+ {title: '名称', field: 'name', width: 150, hAlign: 0, formatter: '@'},
|
|
|
+ {title: '单位', field: 'unit', width: 50, hAlign: 1, formatter: '@'},
|
|
|
+ {title: '单价', field: 'unit_price', hAlign: 2, width: 50},
|
|
|
+ {title: '数量', field: 'quantity', hAlign: 2, width: 50},
|
|
|
+ ],
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 1,
|
|
|
+ headRowHeight: [32],
|
|
|
+ headColWidth: [30],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ selectedBackColor: '#fffacd',
|
|
|
+ readOnly: true,
|
|
|
+ },
|
|
|
+ afterLocated: function () {
|
|
|
+ settlePosObj.loadCurPosData();
|
|
|
+ },
|
|
|
+ });
|
|
|
+ searchLedger.spread.refresh();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ tab.removeClass('active');
|
|
|
+ tabPanel.removeClass('active');
|
|
|
+ showSideTools(tab.hasClass('active'));
|
|
|
+ }
|
|
|
+ slSpread.refresh();
|
|
|
+ spSpread.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();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 加载上下窗口resizer
|
|
|
+ $.divResizer({
|
|
|
+ select: '#main-resize',
|
|
|
+ callback: function () {
|
|
|
+ slSpread.refresh();
|
|
|
+ let bcontent = $(".bcontent-wrap") ? $(".bcontent-wrap").height() : 0;
|
|
|
+ $(".sp-wrap").height(bcontent-30);
|
|
|
+ spSpread.refresh();
|
|
|
+ window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 工具栏resizer
|
|
|
+ $.divResizer({
|
|
|
+ select: '#right-spr',
|
|
|
+ callback: function () {
|
|
|
+ slSpread.refresh();
|
|
|
+ spSpread.refresh();
|
|
|
+ window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty();
|
|
|
+ }
|
|
|
+ });
|
|
|
+});
|