From 5186227a467bd34dc253e64b23bc96d3a07bb399 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期三, 17 十一月 2021 17:39:53 +0800
Subject: [PATCH] 添加用户权限控制

---
 src/components/SelectTree/index.vue |  292 +++++++++++++++++++++++++++++-----------------------------
 1 files changed, 146 insertions(+), 146 deletions(-)

diff --git a/src/components/SelectTree/index.vue b/src/components/SelectTree/index.vue
index bacc7dd..d683143 100644
--- a/src/components/SelectTree/index.vue
+++ b/src/components/SelectTree/index.vue
@@ -31,168 +31,168 @@
 </template>
 
 <script>
-  export default {
-    name: 'SelectTreeTemplate',
-    props: {
-      /* 鏍戝舰缁撴瀯鏁版嵁 */
-      treeOptions: {
-        type: Array,
-        default: () => {
-          return []
-        },
-      },
-      /* 鍗曢��/澶氶�� */
-      selectType: {
-        type: String,
-        default: () => {
-          return 'single'
-        },
-      },
-      /* 鍒濆閫変腑鍊糼ey */
-      selectedKey: {
-        type: String,
-        default: () => {
-          return ''
-        },
-      },
-      /* 鍒濆閫変腑鍊糿ame */
-      selectedValue: {
-        type: String,
-        default: () => {
-          return ''
-        },
-      },
-      /* 鍙仛閫夋嫨鐨勫眰绾� */
-      selectLevel: {
-        type: [String, Number],
-        default: () => {
-          return ''
-        },
-      },
-      /* 鍙竻绌洪�夐」 */
-      clearable: {
-        type: Boolean,
-        default: () => {
-          return true
-        },
+export default {
+  name: "SelectTreeTemplate",
+  props: {
+    /* 鏍戝舰缁撴瀯鏁版嵁 */
+    treeOptions: {
+      type: Array,
+      default: () => {
+        return [];
       },
     },
-    data() {
-      return {
-        defaultProps: {
-          children: 'children',
-          label: 'name',
-        },
-        defaultSelectedKeys: [], //鍒濆閫変腑鍊兼暟缁�
-        currentNodeKey: this.selectedKey,
-        selectValue:
-          this.selectType == 'multiple'
-            ? this.selectedValue.split(',')
-            : this.selectedValue, //涓嬫媺妗嗛�変腑鍊糽abel
-        selectKey:
-          this.selectType == 'multiple'
-            ? this.selectedKey.split(',')
-            : this.selectedKey, //涓嬫媺妗嗛�変腑鍊紇alue
+    /* 鍗曢��/澶氶�� */
+    selectType: {
+      type: String,
+      default: () => {
+        return "single";
+      },
+    },
+    /* 鍒濆閫変腑鍊糼ey */
+    selectedKey: {
+      type: String,
+      default: () => {
+        return "";
+      },
+    },
+    /* 鍒濆閫変腑鍊糿ame */
+    selectedValue: {
+      type: String,
+      default: () => {
+        return "";
+      },
+    },
+    /* 鍙仛閫夋嫨鐨勫眰绾� */
+    selectLevel: {
+      type: [String, Number],
+      default: () => {
+        return "";
+      },
+    },
+    /* 鍙竻绌洪�夐」 */
+    clearable: {
+      type: Boolean,
+      default: () => {
+        return true;
+      },
+    },
+  },
+  data() {
+    return {
+      defaultProps: {
+        children: "children",
+        label: "name",
+      },
+      defaultSelectedKeys: [], //鍒濆閫変腑鍊兼暟缁�
+      currentNodeKey: this.selectedKey,
+      selectValue:
+        this.selectType == "multiple"
+          ? this.selectedValue.split(",")
+          : this.selectedValue, //涓嬫媺妗嗛�変腑鍊糽abel
+      selectKey:
+        this.selectType == "multiple"
+          ? this.selectedKey.split(",")
+          : this.selectedKey, //涓嬫媺妗嗛�変腑鍊紇alue
+    };
+  },
+  mounted() {
+    const that = this;
+    this.initTree();
+  },
+  methods: {
+    // 鍒濆鍖栨爲鐨勫��
+    initTree() {
+      const that = this;
+      if (that.selectedKey) {
+        that.defaultSelectedKeys = that.selectedKey.split(","); // 璁剧疆榛樿灞曞紑
+        if (that.selectType == "single") {
+          that.$refs.treeOption.setCurrentKey(that.selectedKey); // 璁剧疆榛樿閫変腑
+        } else {
+          that.$refs.treeOption.setCheckedKeys(that.defaultSelectedKeys);
+        }
       }
     },
-    mounted() {
-      const that = this
-      this.initTree()
+    // 娓呴櫎閫変腑
+    clearHandle() {
+      const that = this;
+      this.selectValue = "";
+      this.selectKey = "";
+      this.defaultSelectedKeys = [];
+      this.currentNodeKey = "";
+      this.clearSelected();
+      if (that.selectType == "single") {
+        that.$refs.treeOption.setCurrentKey(""); // 璁剧疆榛樿閫変腑
+      } else {
+        that.$refs.treeOption.setCheckedKeys([]);
+      }
     },
-    methods: {
-      // 鍒濆鍖栨爲鐨勫��
-      initTree() {
-        const that = this
-        if (that.selectedKey) {
-          that.defaultSelectedKeys = that.selectedKey.split(',') // 璁剧疆榛樿灞曞紑
-          if (that.selectType == 'single') {
-            that.$refs.treeOption.setCurrentKey(that.selectedKey) // 璁剧疆榛樿閫変腑
-          } else {
-            that.$refs.treeOption.setCheckedKeys(that.defaultSelectedKeys)
-          }
-        }
-      },
-      // 娓呴櫎閫変腑
-      clearHandle() {
-        const that = this
-        this.selectValue = ''
-        this.selectKey = ''
-        this.defaultSelectedKeys = []
-        this.currentNodeKey = ''
-        this.clearSelected()
-        if (that.selectType == 'single') {
-          that.$refs.treeOption.setCurrentKey('') // 璁剧疆榛樿閫変腑
-        } else {
-          that.$refs.treeOption.setCheckedKeys([])
-        }
-      },
-      /* 娓呯┖閫変腑鏍峰紡 */
-      clearSelected() {
-        const allNode = document.querySelectorAll('#treeOption .el-tree-node')
-        allNode.forEach((element) => element.classList.remove('is-current'))
-      },
-      // select澶氶�夋椂绉婚櫎鏌愰」鎿嶄綔
-      removeTag(val) {
-        this.$refs.treeOption.setCheckedKeys([])
-      },
-      // 鐐瑰嚮鍙跺瓙鑺傜偣
-      nodeClick(data, node, el) {
-        if (data.rank >= this.selectLevel) {
-          this.selectValue = data.name
-          this.selectKey = data.id
-        }
-      },
-      // 鑺傜偣閫変腑鎿嶄綔
-      checkNode(data, node, el) {
-        const checkedNodes = this.$refs.treeOption.getCheckedNodes()
-        const keyArr = []
-        const valueArr = []
-        checkedNodes.forEach((item) => {
-          if (item.rank >= this.selectLevel) {
-            keyArr.push(item.id)
-            valueArr.push(item.name)
-          }
-        })
-        this.selectValue = valueArr
-        this.selectKey = keyArr
-      },
+    /* 娓呯┖閫変腑鏍峰紡 */
+    clearSelected() {
+      const allNode = document.querySelectorAll("#treeOption .el-tree-node");
+      allNode.forEach((element) => element.classList.remove("is-current"));
     },
-  }
+    // select澶氶�夋椂绉婚櫎鏌愰」鎿嶄綔
+    removeTag(val) {
+      this.$refs.treeOption.setCheckedKeys([]);
+    },
+    // 鐐瑰嚮鍙跺瓙鑺傜偣
+    nodeClick(data, node, el) {
+      if (data.rank >= this.selectLevel) {
+        this.selectValue = data.name;
+        this.selectKey = data.id;
+      }
+    },
+    // 鑺傜偣閫変腑鎿嶄綔
+    checkNode(data, node, el) {
+      const checkedNodes = this.$refs.treeOption.getCheckedNodes();
+      const keyArr = [];
+      const valueArr = [];
+      checkedNodes.forEach((item) => {
+        if (item.rank >= this.selectLevel) {
+          keyArr.push(item.id);
+          valueArr.push(item.name);
+        }
+      });
+      this.selectValue = valueArr;
+      this.selectKey = keyArr;
+    },
+  },
+};
 </script>
 
 <style lang="scss" scoped>
-  .el-scrollbar .el-scrollbar__view .el-select-dropdown__item {
-    height: auto;
-    max-height: 274px;
-    padding: 0;
-    overflow-y: auto;
-  }
+.el-scrollbar .el-scrollbar__view .el-select-dropdown__item {
+  height: auto;
+  max-height: 274px;
+  padding: 0;
+  overflow-y: auto;
+}
 
-  .el-select-dropdown__item.selected {
-    font-weight: normal;
-  }
+.el-select-dropdown__item.selected {
+  font-weight: normal;
+}
 
-  ul li > .el-tree .el-tree-node__content {
-    height: auto;
-    padding: 0 20px;
-  }
+ul li > .el-tree .el-tree-node__content {
+  height: auto;
+  padding: 0 20px;
+}
 
-  .el-tree-node__label {
-    font-weight: normal;
-  }
+.el-tree-node__label {
+  font-weight: normal;
+}
 
-  .el-tree > .is-current .el-tree-node__label {
-    font-weight: 700;
-    color: #409eff;
-  }
+.el-tree > .is-current .el-tree-node__label {
+  font-weight: 700;
+  color: #409eff;
+}
 
-  .el-tree > .is-current .el-tree-node__children .el-tree-node__label {
-    font-weight: normal;
-    color: #606266;
-  }
+.el-tree > .is-current .el-tree-node__children .el-tree-node__label {
+  font-weight: normal;
+  color: #606266;
+}
 </style>
 <style lang="scss">
-  /* .vab-tree-select{
+/* .vab-tree-select{
       .el-tag__close.el-icon-close{
         width:0;
         overflow:hidden;

--
Gitblit v1.8.0