Przeglądaj źródła

1. 上传yup/ybpx文件,导入单项工程层次
2. 获取在线计价,用户选择的单项工程,按结构导入

MaiXinRong 2 tygodni temu
rodzic
commit
cf21a41ce9

+ 2 - 1
app/base/base_budget_service.js

@@ -492,9 +492,10 @@ class BaseBudget extends TreeService {
         for (const subject of ybpData.subjects) {
             if (!subject.bills || subject.bills.length === 0) continue;
 
+            const parents = YbpTrees.YbpUtils.getSubjectParentPath(subject, ybpData.subjects);
             const ybpTree = new YbpTrees.YbpTree(ybpTreeSetting);
             ybpTree.loadDatas(subject.bills);
-            gatherTree.importTree(ybpTree, subject.project.name, null, needGcl ? null : filterGcl);
+            gatherTree.importTree(ybpTree, subject.project.name, parents, null, needGcl ? null : filterGcl);
         }
         gatherTree.sort(false);
         gatherTree.calculateAll();

+ 2 - 2
app/controller/budget_controller.js

@@ -166,7 +166,7 @@ module.exports = app => {
                     {title: '图册号', colSpan: '1', rowSpan: '2', field: 'drawing_code', hAlign: 0, width: 100, formatter: '@'},
                     {title: '备注', colSpan: '1', rowSpan: '2', field: 'memo', hAlign: 0, width: 100, formatter: '@'},
                 ],
-                emptyRows: 3,
+                emptyRows: 0,
                 headRows: 2,
                 headRowHeight: [25, 25],
                 defaultRowHeight: 21,
@@ -377,7 +377,7 @@ module.exports = app => {
                 const ybpData = { header: {}, subjects: [] };
                 const dsk = new DSK(ctx);
                 for (const s of data.subjects) {
-                    const subject = { project: { name: s.name, compilationID: s.compilationId }, rations: [], };
+                    const subject = { project: { ID: s.ID, parentID: s.parentID, type: s.type, 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 => {

+ 1 - 1
app/controller/ledger_controller.js

@@ -571,7 +571,7 @@ module.exports = app => {
                 const dsk = new DSK(ctx);
                 for (const s of data.subjects) {
                     console.log(s);
-                    const subject = { project: { name: s.name, compilationID: s.compilationId }, rations: [], };
+                    const subject = { project: { ID: s.ID, parentID: s.parentID, type: s.type, 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 => {

+ 35 - 4
app/lib/ybp_tree.js

@@ -162,7 +162,7 @@ class YbpImportTree {
         //       x.unit_price === data.unit_price;
         // });
     }
-    _importNode(node, parent, loadRelaFun, filter) {
+    _importNode(node, parent, loadRelaFun, filter, forceMerge = false) {
 
         const setting = this.setting;
         const compareData = { kind: node.kind };
@@ -178,7 +178,7 @@ class YbpImportTree {
             : 0;
         if (filter && filter(node, compareData, isXmj)) return;
 
-        let cur = (this.importType === YbpImportType.merge && defaultMerge.indexOf(compareData.kind) >= 0)
+        let cur = forceMerge || (this.importType === YbpImportType.merge && defaultMerge.indexOf(compareData.kind) >= 0)
             ? this._findNode(compareData, parent)
             : null;
         if (!cur) {
@@ -221,8 +221,16 @@ class YbpImportTree {
         }
         return cur;
     }
-    importTree(tree, unitName, loadRelaFun, filter) {
-        const parent = this.importType === YbpImportType.flow ? this._importNode({name: unitName}) : null;
+    _importUnitParent(unitParents) {
+        let cur;
+        for (const up of unitParents) {
+            cur = this._importNode({ name: up }, cur, null, null, true);
+        }
+        return cur;
+    }
+    importTree(tree, unitName, unitParents, loadRelaFun, filter) {
+        const unitTop = this.importType === YbpImportType.flow ? this._importUnitParent(unitParents) : null;
+        const parent = this.importType === YbpImportType.flow ? this._importNode({name: unitName}, unitTop) : null;
         this.unitName = unitName;
         for (const n of tree.children) {
             this._importNode(n, parent, loadRelaFun, filter);
@@ -309,8 +317,31 @@ class YbpImportTree {
     }
 }
 
+const YbpUtils = {
+    /**
+     * (限制3层)在subjects中获取节点的所有父结构节点名称project.name
+     * PS:仅供外部用Utils,实际上与YbpTree内部数据无关,依赖ID,parentID,如果树结构需先转换再使用
+     *
+     * @param node 节点
+     * @param nodes 所有节点Array
+     * @returns {Array} 父节点名称
+     */
+    getSubjectParentPath(node, nodes) {
+        const result = [];
+        let parent = nodes.find(x => { return x.project.ID === node.project.parentID; });
+        let i = 0;
+        while (parent && i < 4 && [3, 4].indexOf(parent.project.type) >= 0) {
+            result.unshift(parent.project.name);
+            parent = nodes.find(y => { return y.project.ID === parent.project.parentID; });
+            i++;
+        }
+        return result;
+    }
+};
+
 module.exports = {
     YbpImportType,
     YbpTree,
     YbpImportTree,
+    YbpUtils,
 };

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

@@ -205,7 +205,8 @@ 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 { name: x.name, compilationId: x.compilation_id, subjectId: x.dsk_id }; });
+            return tree.nodes.filter(x => { return x.selected; }).map(x => { return { name: x.name, compilationId: x.compilation_id, subjectId: x.dsk_id, ID: x.id, parentID: x.pid, type: x.type }; });
+            // 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;

+ 2 - 1
app/service/ledger.js

@@ -745,6 +745,7 @@ module.exports = app => {
             for (const subject of ybpData.subjects) {
                 if (!subject.bills || subject.bills.length === 0) continue;
 
+                const parents = YbpTrees.YbpUtils.getSubjectParentPath(subject, ybpData.subjects);
                 const ybpTree = new YbpTrees.YbpTree(ybpTreeSetting);
                 ybpTree.loadDatas(subject.bills);
                 const loadRelaFun = function(cur, node) {
@@ -770,7 +771,7 @@ module.exports = app => {
                         }
                     }
                 };
-                gatherTree.importTree(ybpTree, subject.project.name, loadRelaFun);
+                gatherTree.importTree(ybpTree, subject.project.name, parents, loadRelaFun);
             }
             gatherTree.sort(false);
             gatherTree.calculateAll();