Tony Kang 1 gadu atpakaļ
vecāks
revīzija
8b68de24fc

+ 15 - 1
app/controller/report_controller.js

@@ -66,7 +66,21 @@ module.exports = app => {
             const allTreeNodes = await ctx.service.rptTreeNode.getAllNodes([-1]); // 这个得到所有通用的(新业务需求)
             const allTreeItems = JSON.parse(allTreeNodes[0].items);
             const allIndivTreeNodes = await ctx.service.rptTreeNode.getAllNodes([pid]); // 这个得到所有定制的(新业务需求)
-            const allIndivTreeItems = JSON.parse(allIndivTreeNodes[0].items);
+            // const allIndivTreeItems = JSON.parse(allIndivTreeNodes[0].items);
+            const allIndivTreeItems = [];
+            allIndivTreeNodes.forEach(indiTreeNode => {
+                const newTopIndivNode = {
+                    ID: indiTreeNode.id || -1,
+                    name: indiTreeNode.name || '',
+                    // rpt_type: indiTreeNode.rpt_type || 1,
+                    source_type: indiTreeNode.source_type,
+                    // isParent: true,
+                    nodeType: 1,
+                    items: JSON.parse(indiTreeNode.items),
+                };
+                // allIndivTreeItems.push(...JSON.parse(indiTreeNode.items));
+                allIndivTreeItems.push(newTopIndivNode);
+            });
             const nodeItems = JSON.parse(commonTreeNodes[0].items);
             const commonArrs = [];
             nodeItems.forEach(nodeItem => {

+ 1 - 1
app/service/rpt_tree_node.js

@@ -101,7 +101,7 @@ module.exports = app => {
                 value: prjIdArr,
                 operate: 'in',
             });
-            this.sqlBuilder.columns = ['id', 'name', 'rpt_type', 'pid', 'items', 'last_update_time'];
+            this.sqlBuilder.columns = ['id', 'name', 'rpt_type', 'pid', 'items', 'last_update_time', 'source_type'];
             const [sql, sqlParam] = this.sqlBuilder.build(this.tableName);
 
             const list = await this.db.query(sql, sqlParam);

+ 20 - 2
app/view/report/index.ejs

@@ -633,6 +633,22 @@
             }
         }
     }
+    for (let item of ALL_COMMON_TREE_NODES) {
+        // item.items = JSON.parse(item.items);
+        if (item.items && item.items.length > 0) {
+            for (let dtlItem of item.items) {
+                chkAndSetNode(dtlItem);
+            }
+        }
+    }
+    for (let item of ALL_INDIVI_TREE_NODES) {
+        // item.items = JSON.parse(item.items);
+        if (item.items && item.items.length > 0) {
+            for (let dtlItem of item.items) {
+                chkAndSetNode(dtlItem);
+            }
+        }
+    }
     buildTplTree();
 
     function chkAndSetNode(parentItem) {
@@ -670,8 +686,10 @@
         if (CURRENT_SELECTED_BIZ_TYPE === 'change_material_adjustment') bizType = 30; // 材差
         _filterBySourceType(newCommonTreeNodes, bizType);
         _filterBySourceType(newCustomTreeNodes, bizType);
-        TOP_TREE_NODES[0].items = newCustomTreeNodes;
-        TOP_TREE_NODES[1].items = newCommonTreeNodes;
+        TOP_TREE_NODES[0].items = [];
+        TOP_TREE_NODES[0].items.push(...newCustomTreeNodes);
+        TOP_TREE_NODES[1].items = [];
+        TOP_TREE_NODES[1].items.push(...newCommonTreeNodes);
         if (bizType === 1) {
             filterUnchkTplTreeNode(TOP_TREE_NODES[0], CUST_TREE_NODES.customize);
             filterUnchkTplTreeNode(TOP_TREE_NODES[1], CUST_TREE_NODES.common);