Selaa lähdekoodia

暂存计量、导入计量台账、导入其他标段计量数据,结算数据不予导入

MaiXinRong 1 vuosi sitten
vanhempi
commit
7df38744a5
4 muutettua tiedostoa jossa 65 lisäystä ja 14 poistoa
  1. 11 0
      app/lib/sum_load.js
  2. 5 5
      app/public/js/stage.js
  3. 30 4
      app/service/stage_change.js
  4. 19 5
      app/service/stage_stash.js

+ 11 - 0
app/lib/sum_load.js

@@ -319,6 +319,7 @@ class gatherStageGclTree extends loadGclBaseTree {
     constructor(ctx, setting) {
         super(ctx, setting);
         this.cover = setting.cover;
+        this.settleStatus = this.ctx.service.settle.settleStatus;
     }
     loadBase(datas, pos) {
         datas.sort((x, y) => { return x.level === y.level ? x.order - y.order : x.level - y.level; });
@@ -378,6 +379,8 @@ class gatherStageGclTree extends loadGclBaseTree {
             return (source.is_tp && node.is_tp) || (!source.is_tp && !node.is_tp);
         };
         const node = this.ignoreParent ? this.addNodeWithoutParent(source, checkFun) : this.addNode(source, parent, checkFun);
+        if (node.settle_status === this.settleStatus.finish) return node;
+
         if (node.is_tp) {
             node.contract_tp = this.ctx.helper.add(node.contract_tp, source.contract_tp);
         } else {
@@ -522,6 +525,7 @@ class sumLoad {
         for (const csb of curStageBills) {
             const b = billsIndex[csb.lid];
             if (!b) continue;
+
             b.contract_qty = csb.contract_qty;
             b.contract_tp = csb.contract_tp;
             b.qc_qty = csb.qc_qty;
@@ -534,6 +538,7 @@ class sumLoad {
 
             const b = billsIndex[csc.lid];
             if (!b) continue;
+
             if (!b.change_detail) b.change_detail = [];
             let c = b.change_detail.find(x => { return x.cbid === csc.cbid });
             if (!c) {
@@ -553,12 +558,18 @@ class sumLoad {
         const extraData = await this.ctx.service.ledgerExtra.getData(this.ctx.tender.id, ['is_tp']);
         const stageBills = await this.ctx.service.stageBills.getLastestStageData2(this.ctx.tender.id, this.ctx.stage.id);
         const importLid = await this.ctx.service.stageImportChange.getLeafXmjImportLid(this.ctx.stage.id, select.id);
+        const settleStatusBills = this.ctx.stage.readySettle ? await this.ctx.service.settleBills.getAllDataByCondition({ where: { settle_id: this.ctx.stage.readySettle.id }}) : [];
         this.ctx.helper.assignRelaData(posterity, [
             { data: extraData, fields: ['is_tp'], prefix: '', relaId: 'id' },
             { data: importLid, fields: ['is_import'], prefix: '', relaId: 'lid' },
             { data: stageBills, fields: ['contract_qty', 'contract_tp', 'qc_qty', 'qc_tp', 'qc_minus_qty', 'positive_qc_qty', 'positive_qc_tp', 'negative_qc_qty', 'negative_qc_tp'], prefix: '', relaId: 'lid' },
+            { data: settleStatusBills, fields: ['settle_status'], prefix: '', relaId: 'lid' },
         ]);
         const pos = await this.ctx.service.pos.getAllDataByCondition({ where: { tid: this.ctx.tender.id } });
+        const settleStatusPos = this.ctx.stage.readySettle ? await this.ctx.service.settlePos.getAllDataByCondition({ where: { settle_id: this.ctx.stage.readySettle.id }}) : [];
+        this.ctx.helper.assignRelaData(pos, [
+            { data: settleStatusPos, fields: ['settle_status'], prefix: '', relaId: 'pid' },
+        ]);
         this.loadTree.loadBase(posterity, pos);
 
         for (const tender of tenders) {

+ 5 - 5
app/public/js/stage.js

@@ -1071,9 +1071,9 @@ $(document).ready(() => {
                                 if (node.b_code && node.b_code !== '') continue;
                             } else if (['postil', 'memo', 'ex_memo1', 'ex_memo2', 'ex_memo3'].indexOf(colSetting.field) < 0) {
                                 if (colSetting.field === 'contract_qty') {
-                                    if (node.is_tp || node.settle_status !== settleStatus.finish) continue;
+                                    if (node.is_tp || node.settle_status === settleStatus.finish) continue;
                                 } else if (colSetting.field === 'contract_tp') {
-                                    if (!node.is_tp || node.settle_status !== settleStatus.finish) continue;
+                                    if (!node.is_tp || node.settle_status === settleStatus.finish) continue;
                                 }
                                 if (node.children && node.children.length > 0) {
                                     continue;
@@ -1155,9 +1155,9 @@ $(document).ready(() => {
                         const curCol = info.cellRange.col + iCol;
                         const col = info.sheet.zh_setting.cols[curCol];
                         if (col.field === 'contract_tp') {
-                            if (!node.is_tp || node.settle_status !== settleStatus.finish) continue;
+                            if (!node.is_tp || node.settle_status === settleStatus.finish) continue;
                         } else if (col.field === 'contract_qty') {
-                            if (node.is_tp || node.settle_status !== settleStatus.finish) continue;
+                            if (node.is_tp || node.settle_status === settleStatus.finish) continue;
                         }
 
                         if (setting.dgnUpFields.indexOf(col.field) !== -1) {
@@ -2170,7 +2170,7 @@ $(document).ready(() => {
                                 toastr.error('部位名称不能为空');
                                 return;
                             }
-                            if (colSetting.Type === 'Number' && node.settle_status !== settleStatus.finish) {
+                            if (colSetting.Type === 'Number' && node.settle_status === settleStatus.finish) {
                                 toastr.error('已结算节点不可计量');
                                 return;
                             }

+ 30 - 4
app/service/stage_change.js

@@ -14,10 +14,11 @@ const timesLen = audit.stage.timesLen;
 const changeConst = require('../const/change');
 
 class autoUseChange {
-    constructor(helper, info) {
+    constructor(helper, info, settleStatus) {
         this.helper = helper;
         this.precision = info.precision;
         this.decimal = info.decimal;
+        this.settleStatus = settleStatus;
 
         this.insertBills = [];
         this.insertPos = [];
@@ -50,9 +51,20 @@ class autoUseChange {
     findBillsPos(changeBills){
         if (changeBills.gcl_id) {
             const node = this.ledgerTree.datas.find(x => {return x.id === changeBills.gcl_id});
+            if (node.settle_status === this.settleStatus.finish) return null;
+
             const posData = this.pos.getLedgerPos(node.id) || [];
             const changePos = posData.find(x => { return x.name === changeBills.bwmx; });
-            return { bills: node, lid: node.id, pid: changePos ? changePos.id : (posData.length > 0 ? posData[0].id : '-1') };
+            if (changePos.settle_status) return null;
+
+            let defaultPos;
+            if (posData.length > 0) {
+                defaultPos = posData.length > 0 ? posData.find(x => { return !x.settle_status}) : null;
+                if (!defaultPos) return null;
+            } else {
+                defaultPos = { id: '-1' };
+            }
+            return { bills: node, lid: node.id, pid: changePos ? changePos.id : defaultPos.id };
         } else {
             const cb = {
                 b_code: changeBills.code || '',
@@ -63,6 +75,7 @@ class autoUseChange {
             };
             for (const node of this.ledgerTree.nodes) {
                 if (node.children && node.children.length > 0) continue;
+                if (node.settle_status === this.settleStatus.finish) return null;
 
                 const b = {
                     b_code: node.b_code || '',
@@ -73,7 +86,14 @@ class autoUseChange {
                 };
                 if (this.helper._.isMatch(cb, b)) {
                     const posData = this.pos.getLedgerPos(node.id) || [];
-                    return { bills: node, lid: node.id, pid: posData.length > 0 ? posData[0].id : '-1' };
+                    let defaultPos;
+                    if (posData.length > 0) {
+                        defaultPos = posData.length > 0 ? posData.find(x => { return !x.settle_status}) : null;
+                        if (!defaultPos) return null;
+                    } else {
+                        defaultPos = { id: '-1' };
+                    }
+                    return { bills: node, lid: node.id, pid: defaultPos.id };
                 }
             }
             return null;
@@ -795,17 +815,23 @@ module.exports = app => {
                 where: { tender_id: stage.tid },
             });
             const extraData = await this.ctx.service.ledgerExtra.getData(this.ctx.tender.id, ['is_tp']);
+            const settleStatusBills = stage.readySettle ? await this.ctx.service.settleBills.getAllDataByCondition({ where: { settle_id: stage.readySettle.id }}) : [];
             this.ctx.helper.assignRelaData(ledgerData, [
                 { data: extraData, fields: ['is_tp'], prefix: '', relaId: 'id' },
+                { data: settleStatusBills, fields: ['settle_status'], prefix: '', relaId: 'lid' },
             ]);
 
             const posData = await this.ctx.service.pos.getAllDataByCondition({
                 columns: ['id', 'lid', 'name', 'porder'],
                 where: { tid: stage.tid },
             });
+            const settleStatusPos = stage.readySettle ? await this.ctx.service.settlePos.getAllDataByCondition({ where: { settle_id: stage.readySettle.id }}) : [];
+            this.ctx.helper.assignRelaData(posData, [
+                { data: settleStatusPos, fields: ['settle_status'], prefix: '', relaId: 'pid' },
+            ]);
             const stageBills = await this.ctx.service.stageBills.getAllDataByCondition({ where: { sid: stage.id } });
             const stagePos = await this.ctx.service.stagePos.getAllDataByCondition({ where: { sid: stage.id } });
-            const useModal = new autoUseChange(this.ctx.helper, tender.info);
+            const useModal = new autoUseChange(this.ctx.helper, tender.info, this.ctx.service.settle.settleStatus);
             useModal.use({ledgerData, posData, stageBills, stagePos, default: { tid: stage.tid, sid: stage.id, said: this.ctx.session.sessionUser.accountId } }, validChangeBills);
 
             // if (useModal.insertChange.length === 0) return '无可调用的清单或计量单元';

+ 19 - 5
app/service/stage_stash.js

@@ -13,6 +13,7 @@ class loadStageExcelTree {
         this.ctx = ctx;
 
         this.decimal = ctx.tender.info.decimal;
+        this.settleStatus === ctx.service.settle.settleStatus;
 
         this.insertBills = [];
         this.insertPos = [];
@@ -66,7 +67,7 @@ class loadStageExcelTree {
             for (const p of node.pos) {
                 if (!p.contract_qty) continue;
                 const sp = sourcePos.find(x => { return x.name === p.name; });
-                if (!sp) continue;
+                if (!sp || sp.settle_status === this.settleStatus.finish) continue;
 
                 contract_qty = this.ctx.helper.add(contract_qty, p.contract_qty);
                 let ssp = sourceStagePos.find(x => { return x.pid === sp.id; });
@@ -123,7 +124,7 @@ class loadStageExcelTree {
         node.is_leaf = !node.children || node.children.length === 0 ? 1 : 0;
         node.has_pos = node.pos && node.pos.length > 0;
         const cur = this.findNode(node, parent);
-        if (!cur) return;
+        if (!cur || cur.settle_status === this.settleStatus.finish) return;
 
         if (cur) {
             if (!node.b_code) this.loadDgn(node, cur);
@@ -226,18 +227,25 @@ module.exports = app => {
         async reCalcStashData(stage, data) {
             const decimal = this.ctx.tender.info.decimal;
             const insertBillsData = [], insertPosData = [], insertChangeData = [];
+            const settleStatus = this.ctx.service.settle.settleStatus;
 
             const bills = await this.ctx.service.ledger.getAllDataByCondition({ where: { tender_id: stage.tid, is_leaf: true } });
             const extraData = await this.ctx.service.ledgerExtra.getData(stage.tid, ['id', 'is_tp']);
+            const settleStatusBills = stage.readySettle ? await this.ctx.service.settleBills.getAllDataByCondition({ where: { settle_id: stage.readySettle.id }}) : [];
             this.ctx.helper.assignRelaData(bills, [
                 { data: extraData, fields: ['is_tp'], prefix: '', relaId: 'id' },
+                { data: settleStatusBills, fields: ['settle_status'], prefix: '', relaId: 'lid' },
             ]);
             const pos = await this.ctx.service.pos.getAllDataByCondition({ where: { tid: stage.tid } });
+            const settleStatusPos = stage.readySettle ? await this.ctx.service.settlePos.getAllDataByCondition({ where: { settle_id: stage.readySettle.id }}) : [];
+            this.ctx.helper.assignRelaData(pos, [
+                { data: settleStatusPos, fields: ['settle_status'], prefix: '', relaId: 'pid' },
+            ]);
 
             const said = this.ctx.session.sessionUser.accountId;
             for (const d of data) {
                 const b = bills.find(x => { return x.id === d.lid });
-                if (!b) continue;
+                if (!b || b.settle_status === settleStatus.finish) continue;
 
                 const nbs = {
                     tid: stage.tid, sid: stage.id, said, lid: b.id, times: 1, order: 0,
@@ -247,7 +255,7 @@ module.exports = app => {
                 if (d.pos) {
                     for (const bp of d.pos) {
                         const p = pos.find(x => { return x.id === bp.pid});
-                        if (!p) continue;
+                        if (!p || p.settle_status === settleStatus.finish) continue;
 
                         const nps = { tid: stage.tid, sid: stage.id, said, lid: b.id, pid: p.id, times: 1, order: 0 };
                         nps.contract_qty = this.ctx.helper.round(bp.contract_qty, decimal.qty);
@@ -366,19 +374,25 @@ module.exports = app => {
                     where: { tender_id: stage.tid},
                 });
                 const extraData = await this.ctx.service.ledgerExtra.getData(this.ctx.tender.id, ['is_tp']);
+                const settleStatusBills = stage.readySettle ? await this.ctx.service.settleBills.getAllDataByCondition({ where: { settle_id: stage.readySettle.id }}) : [];
                 this.ctx.helper.assignRelaData(ledgerData, [
                     { data: extraData, fields: ['is_tp'], prefix: '', relaId: 'id' },
+                    { data: settleStatusBills, fields: ['settle_status'], prefix: '', relaId: 'lid' },
                 ]);
                 const posData = await this.ctx.service.pos.getAllDataByCondition({
                     columns: ['id', 'lid', 'name', 'porder'],
                     where: { tid: stage.tid },
                 });
+                const settleStatusPos = stage.readySettle ? await this.ctx.service.settlePos.getAllDataByCondition({ where: { settle_id: stage.readySettle.id }}) : [];
+                this.ctx.helper.assignRelaData(posData, [
+                    { data: settleStatusPos, fields: ['settle_status'], prefix: '', relaId: 'pid' },
+                ]);
                 const stageBills = await this.ctx.service.stageBills.getAllDataByCondition({ where: { sid: stage.id } });
                 const stagePos = await this.ctx.service.stagePos.getAllDataByCondition({ where: { sid: stage.id } });
                 const stageBillsDgn = await this.ctx.service.stageBillsDgn.getAllDataByCondition({ where: { tid: stage.tid } });
 
                 const loadModal = new loadStageExcelTree(this.ctx);
-                loadModal.load(cacheTree, {ledgerData, posData, stageBills, stagePos, stageBillsDgn, default: { tid: stage.tid, sid: stage.id, said: this.ctx.session.sessionUser.accountId } });
+                loadModal.load(cacheTree, { ledgerData, posData, stageBills, stagePos, stageBillsDgn, default: { tid: stage.tid, sid: stage.id, said: this.ctx.session.sessionUser.accountId } });
 
                 const conn = await this.db.beginTransaction();
                 try {