From 78ab9cd3f487cc271ea5b3a10cb9d2491b78767e Mon Sep 17 00:00:00 2001
From: Surpriseplus <845948745@qq.com>
Date: 星期二, 11 四月 2023 18:01:42 +0800
Subject: [PATCH] 目录修改

---
 src/views/datamanage/dictionaryManage.vue |  119 ++++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 68 insertions(+), 51 deletions(-)

diff --git a/src/views/datamanage/dictionaryManage.vue b/src/views/datamanage/dictionaryManage.vue
index 28dc766..b13b259 100644
--- a/src/views/datamanage/dictionaryManage.vue
+++ b/src/views/datamanage/dictionaryManage.vue
@@ -18,14 +18,19 @@
           :placeholder="$t('shuJuGuanLi.shuJuJianSuo.valueone')"
           suffix-icon="el-icon-search"
         ></el-input>
-
         <el-tree
+          :data="domainData"
+          :props="defaultProps"
+        >
+
+        </el-tree>
+        <!-- <el-tree
           :data="domainData"
           :props="defaultProps"
           @node-click="getTableDesc"
           :filter-node-method="filterNode"
           ref="tree"
-        ></el-tree>
+        ></el-tree> -->
         <!-- <ul>
           <li
             @click="getTableDesc(item)"
@@ -574,6 +579,10 @@
   insertDict,
 } from "../../api/api";
 import MyBread from "../../components/MyBread.vue";
+import { conditions } from '../Archive/Archive';
+import {
+  getTreeData
+} from "../../utils/treeData.js"
 export default {
   name: "dictionaryManage",
   components: { MyBread },
@@ -611,7 +620,7 @@
       domainData: [],
       defaultProps: {
         children: "children",
-        label: "val",
+        label: "label",
       },
     };
   },
@@ -757,7 +766,7 @@
       var m = time.getMonth() + 1;
       var d = time.getDate();
       var h = time.getHours();
-      var mm = time.getMinutes();
+      var mm = time.getMvinutes();
       var s = time.getSeconds();
       return y + "-" + this.add0(m) + "-" + this.add0(d);
     },
@@ -769,59 +778,67 @@
       this.formInline.tab = null;
       this.getSelectDictTab();
     },
+    treeData(source) {
+      let cloneData = JSON.parse(JSON.stringify(source));// 瀵规簮鏁版嵁娣卞害鍏嬮殕
+      if (cloneData.length != 0) {
+        return cloneData.filter((father) => {
+          // 寰幆鎵�鏈夐」
+          let branchArr = cloneData.filter((child) => father.label == child.pname); // 瀵规瘮ID锛屽垎鍒笂涓嬬骇鑿滃崟锛屽苟杩斿洖鏁版嵁
+          branchArr.length > 0 ? (father.children = branchArr) : ''; // 缁欑埗绾ф坊鍔犱竴涓猚hildren灞炴�э紝骞惰祴鍊�
+          // 灞炰簬鍚屼竴瀵硅薄闂锛屼緥濡傦細浠� a=b銆乧=1 锛岀劧鍚庡啀浠� b.c=c 锛� 閭d箞 a.c=b.c=c=1 锛涘悓鐞嗭紝鍚庣画浠� c.d=2 ,閭d箞 a.c.d 涔熸槸=2锛�
+          // 鐢辨寰幆澶氭鍚庯紝灏辫兘褰㈡垚鐩稿簲鐨勬爲褰㈡暟鎹粨鏋�
+          return father.pname == -1; // 杩斿洖涓�绾ц彍鍗�
+        });
+      }
+    },
     //鐩綍鏍戣幏鍙�
     async getSelectDictTab() {
       const data = await selectDictTab({ name: this.formInline.tab });
       if (data.code != 200) {
-        this.$message.error("涓嬫媺璋冪敤澶辫触");
+        this.$message.error("鍒楄〃璋冪敤澶辫触");
       }
-      var val = data.result;
-      var std = [];
-      val.filter((item) => {
-        if (std.indexOf(item.bak) == -1) {
-          std.push(item.bak);
-          this.domainData.push(
-            {
-              val: item.bak,
-              children: [],
-            }
-          )
-        }
-      });
-      this.domainData.filter((item) => {
-        val.filter((res) => {
-          if (item.val === res.bak) {
-            res.val = res.tabDesc
-            item.children.push(res)
+      var val = JSON.parse(JSON.stringify(data.result));
+      var tree = getTreeData(data.result);
+      this.domainData = tree
+      this.getQueryNameData(tree[0]);
+      // var = this.domainData[0].children;
+      // 
+    },
+    getQueryNameData(res) {
+
+      if (res.children) {
+        this.getQueryNameData(res.children);
+      } else {
+
+        if (res.length != 1) {
+          if (res[0].children) {
+            this.getQueryNameData(res[0].children);
+          } else {
+
+            var result = res[0]
+            this.insertform.tab = result.tab;
+            this.insertform.tabDesc = result.tabDesc;
+            this.insertform.ns = result.ns;
+            this.listData.tab = result.tab;
+            this.listData.ns = result.ns;
+            this.activeName = result.tab;
+            this.startQueryNameData();
           }
-        })
-      })
-      // let bdres = data.result.filter((item) => item.ns == "bd");
-      // let bsres = data.result.filter((item) => item.ns == "bs");
-      // let mdres = data.result.filter((item) => item.ns == "md");
-      // for (var i in bdres) {
-      //   // bdres[i].val = bdres[i].tabDesc + '(' + bdres[i].tab + ')';
-      //   bdres[i].val = bdres[i].tabDesc;
-      // }
-      // for (var i in bsres) {
-      //   // bsres[i].val = bsres[i].tabDesc + '(' + bsres[i].tab + ')';
-      //   bsres[i].val = bsres[i].tabDesc;
-      // }
-      // for (var i in mdres) {
-      //   // bsres[i].val = bsres[i].tabDesc + '(' + bsres[i].tab + ')';
-      //   mdres[i].val = mdres[i].tabDesc;
-      // }
-      // this.domainData[0].children = bdres;
-      // this.domainData[1].children = bsres;
-      // this.domainData[2].children = mdres;
-      var result = this.domainData[0].children;
-      this.insertform.tab = result[0].tab;
-      this.insertform.tabDesc = result[0].tabDesc;
-      this.insertform.ns = result[0].ns;
-      this.listData.tab = result[0].tab;
-      this.listData.ns = result[0].ns;
-      this.activeName = result[0].tab;
-      this.startQueryNameData();
+        } else {
+          if (res.children) {
+            this.getQueryNameData(res.children);
+          } else {
+            var result = res
+            this.insertform.tab = result.tab;
+            this.insertform.tabDesc = result.tabDesc;
+            this.insertform.ns = result.ns;
+            this.listData.tab = result.tab;
+            this.listData.ns = result.ns;
+            this.activeName = result.tab;
+            this.startQueryNameData();
+          }
+        }
+      }
     },
     handleClose() {
       this.$confirm("鍏抽棴鍚庢棤娉曚繚瀛橈紝鏄惁鍏抽棴?")

--
Gitblit v1.9.3