瀏覽代碼

导入计量台账Excel相关

MaiXinRong 2 年之前
父節點
當前提交
2e65995fc7
共有 2 個文件被更改,包括 10 次插入9 次删除
  1. 5 4
      app/lib/analysis_excel.js
  2. 5 5
      app/service/stage_stash.js

+ 5 - 4
app/lib/analysis_excel.js

@@ -979,11 +979,12 @@ class AnalysisStageExcelTree extends AnalysisExcelTree {
      */
     _loadPos(row) {
         if (this.filter.filterPos) return true;
-        const pos = {};
+        let pos = {};
         pos.name = this.ctx.helper.replaceReturn(row[this.colsDef.name]);
-        pos.quantity = aeUtils.toNumber(row[this.colsDef.quantity]);
-        pos.contrac_qty = pos.contract_qty;
-        return this.cacheTree.addPos(pos, true);
+        pos.quantity = aeUtils.toNumber(row[this.colsDef.contract_qty]);
+        pos = this.cacheTree.addPos(pos, true);
+        pos.contract_qty = pos.quantity;
+        return pos;
     }
 
     /**

+ 5 - 5
app/service/stage_stash.js

@@ -65,12 +65,12 @@ class loadStageExcelTree {
                 if (!sp) continue;
 
                 contract_qty = this.ctx.helper.add(contract_qty, p.contract_qty);
-                let ssp = sourceStagePos.find(x => { return x.lid === sp.id; });
+                let ssp = sourceStagePos.find(x => { return x.pid === sp.id; });
                 sourceStagePos.splice(sourceStagePos.indexOf(ssp), 1);
                 if (ssp) {
                     this.updatePos.push({ id: ssp.id, contract_qty: p.contract_qty });
                 } else {
-                    this.insertPos.push({ tid: this.default.tid, sid: this.default.sid, said: this.default.said, times: 1, order: 0, lid: source.id, contract_qty: p.contract_qty });
+                    this.insertPos.push({ tid: this.default.tid, sid: this.default.sid, said: this.default.said, times: 1, order: 0, lid: source.id, pid:sp.id, contract_qty: p.contract_qty });
                 }
             }
             for (const ssp of sourceStagePos) {
@@ -80,7 +80,7 @@ class loadStageExcelTree {
             if (curStageBills) {
                 this.updateBills.push({ id: curStageBills.id, contract_qty, contract_tp });
             } else {
-                this.insertBills.push({ tid: this.default.tid, sid: this.default.sid, said: this.default.said, times: 1, order: 0, lid: source.id, contract_qty, contract_tp });
+                if (contract_qty) this.insertBills.push({ tid: this.default.tid, sid: this.default.sid, said: this.default.said, times: 1, order: 0, lid: source.id, contract_qty, contract_tp });
             }
         } else {
             if (!node.contract_qty && !node.contract_tp) return;
@@ -314,8 +314,8 @@ module.exports = app => {
                     columns: ['id', 'lid', 'name', 'porder'],
                     where: { tid: stage.tid },
                 });
-                const stageBills = await this.ctx.service.stageBills.getAllDataByCondition({ where: { tid: stage.tid }});
-                const stagePos = await this.ctx.service.stagePos.getAllDataByCondition({ where: { tid: stage.tid }});
+                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 loadModal = new loadStageExcelTree(this.ctx);
                 loadModal.load(cacheTree, {ledgerData, posData, stageBills, stagePos, default: { tid: stage.tid, sid: stage.id, said: this.ctx.session.sessionUser.accountId } });