Bläddra i källkod

导入计价文件调整

MaiXinRong 3 månader sedan
förälder
incheckning
3ec1d479b7
4 ändrade filer med 19 tillägg och 9 borttagningar
  1. 2 1
      app/controller/ledger_controller.js
  2. 12 6
      app/lib/ybp_tree.js
  3. 1 1
      app/public/js/shares/dsk.js
  4. 4 1
      app/service/ledger.js

+ 2 - 1
app/controller/ledger_controller.js

@@ -570,7 +570,8 @@ module.exports = app => {
                 const ybpData = { header: {}, subjects: [] };
                 const dsk = new DSK(ctx);
                 for (const s of data.subjects) {
-                    const subject = { project: { name: '' }, rations: [], };
+                    console.log(s);
+                    const subject = { project: { name: s.name, compilationID: s.compilationId }, rations: [], };
                     subject.bills = await dsk.getProjectBills(s.compilationId, s.subjectId);
                     // 拼凑fees.marketCommon.totalFee,fees.marketLabour.totalFee防止出错
                     subject.bills.forEach(b => {

+ 12 - 6
app/lib/ybp_tree.js

@@ -104,6 +104,7 @@ class YbpImportTree {
         this.importType = type;
         this.helper = helper;
         this.decimal = decimal;
+        this.default = { dgn_qty1: 1, dgn_qty2: 0, qty: 0 };
         this.clearDatas();
     }
     set newId(num) {
@@ -174,7 +175,7 @@ class YbpImportTree {
             ? (node.fees && node.fees.marketCommon ? node.fees.marketCommon.unitPrice : 0)
             : 0;
 
-        let cur = (this.importType === YbpImportType.merge || defaultMerge.indexOf(compareData.kind) >= 0)
+        let cur = (this.importType === YbpImportType.merge && defaultMerge.indexOf(compareData.kind) >= 0)
             ? this._findNode(compareData, parent)
             : null;
         if (!cur) {
@@ -191,15 +192,16 @@ class YbpImportTree {
                 this.children.push(cur);
             }
             this.datas.push(cur);
-            cur.dgn_qty1 = isXmj ? node.quantity || 0 : 0;
+            cur.dgn_qty1 = isXmj ? node.quantity || 1 : 0;
             cur.dgn_qty2 = isXmj ? node.quantity2 || 0 : 0;
             cur.quantity = isXmj ? 0 : node.quantity || 0;
             cur.total_fee = node.fees ? node.fees.marketCommon.totalFee : 0;
             cur.labour_fee = node.fees && node.fees.marketLabour ? node.fees.marketLabour.totalFee : 0;
             cur.remark = node.remark;
+            cur.features = node.itemCharacterText || '';
         } else {
             if (isXmj) {
-                cur.dgn_qty1 = this.helper.add(cur.dgn_qty1, node.quantity || 0);
+                cur.dgn_qty1 = this.helper.add(cur.dgn_qty1, node.quantity || 1);
                 cur.dgn_qty2 = this.helper.add(cur.dgn_qty2, node.quantity2 || 0);
             } else {
                 cur.quantity = this.helper.add(cur.quantity, node.quantity || 0);
@@ -209,14 +211,18 @@ class YbpImportTree {
         }
         if (loadRelaFun) loadRelaFun(cur, node);
         cur.source.push(this.unitName);
-        for (const c of node.children) {
-            this._importNode(c, cur, loadRelaFun);
+        if (node.children) {
+            for (const c of node.children) {
+                this._importNode(c, cur, loadRelaFun,);
+            }
         }
+        return cur;
     }
     importTree(tree, unitName, loadRelaFun) {
+        const parent = this.importType === YbpImportType.flow ? this._importNode({name: unitName}) : null;
         this.unitName = unitName;
         for (const n of tree.children) {
-            this._importNode(n, null, loadRelaFun);
+            this._importNode(n, parent, loadRelaFun);
         }
     }
 

+ 1 - 1
app/public/js/shares/dsk.js

@@ -251,7 +251,7 @@ const dsk = (function () {
             const tree = this.subjectSheet.zh_tree;
             if (!tree) return [];
 
-            return tree.datas.filter(x => { return x.type === projectTypeKey.unit && x.selected; }).map(x => { return { compilationId: x.compilation_id, subjectId: x.dsk_id }; });
+            return tree.datas.filter(x => { return x.type === projectTypeKey.unit && x.selected; }).map(x => { return { name: x.name, compilationId: x.compilation_id, subjectId: x.dsk_id }; });
         },
         csButtonClicked: function(e, info) {
             if (!info.sheet.zh_setting) return;

+ 4 - 1
app/service/ledger.js

@@ -737,7 +737,9 @@ module.exports = app => {
             const ybpTreeSetting = { id: 'ID', pid: 'parentID', order: 'seq', rootId: '-1' };
             const helper = this.ctx.helper;
 
-            const gatherTree = new YbpTrees.YbpImportTree(gatherTreeSetting, YbpTrees.YbpImportType.flow, helper, tender.info.decimal);
+            const mergeCompliation = ['5b52b027fd3bb0000b257cf8', '5c66649650da2d000d8d37ba'];
+            const ybpImportType = mergeCompliation.indexOf(ybpData.subjects[0].project.compilationID) >= 0 ? YbpTrees.YbpImportType.flow : YbpTrees.YbpImportType.merge;
+            const gatherTree = new YbpTrees.YbpImportTree(gatherTreeSetting, ybpImportType, helper, tender.info.decimal);
             for (const subject of ybpData.subjects) {
                 if (!subject.bills || subject.bills.length === 0) continue;
 
@@ -797,6 +799,7 @@ module.exports = app => {
                     dgn_qty1: n.dgn_qty1 || 0,
                     dgn_qty2: n.dgn_qty2 || 0,
                     memo: n.remark,
+                    features: n.features,
                     // memo: n.source.join(';'),
                 });
                 if (!n.glj) continue;