yusheng 1 week ago
parent
commit
9f5e03286f

+ 19 - 6
src/components/contact/parentList.vue

@@ -217,15 +217,13 @@
         try {
           this.treeLoading = true;
 
-          const res = null;
-          if (this.code) {
-            res = await getProduceTreeByCode(this.code);
-          } else {
-            res = await getTreeByPid(this.type);
-          }
+          const res = await getTreeByPid(this.type);
 
           this.treeLoading = false;
           this.treeList = res.data;
+          if (this.code) {
+            this.treeList = this.filterTreeByCode(this.treeList, this.code);
+          }
           this.$nextTick(() => {
             // 默认高亮第一级树节点
             if (this.treeList[0]) {
@@ -238,6 +236,21 @@
         } catch (error) {}
         this.treeLoading = false;
       },
+      /* 递归过滤树节点 */
+      filterTreeByCode(list, code) {
+        return list.reduce((acc, node) => {
+          if (node.code === code) {
+            acc.push(node);
+          } else if (node.children && node.children.length) {
+            const filteredChildren = this.filterTreeByCode(node.children, code);
+            if (filteredChildren.length) {
+              acc.push({ ...node, children: filteredChildren });
+            }
+          }
+          return acc;
+        }, []);
+      },
+
       /* 刷新表格 */
       reload(where) {
         this.$refs.table.reload({ page: 1, where });

+ 4 - 3
src/views/recordComponents/workOrderReport.vue

@@ -352,12 +352,13 @@
           : '1'
       "
       :type="
-        pageName == 'solidWasteRecord' || pageName == 'productionRecords'
+        pageName == 'solidWasteRecord' ||
+        pageName == 'QualityInspection' ||
+        pageName == 'productionRecords'
           ? '19'
-          : pageName == 'QualityInspection'
-          ? '2065024200690151426'
           : '17'
       "
+      :code="pageName == 'QualityInspection' ? '06mei' : ''"
       ref="parentListRef"
       @changeParent="changeParent"
     >