From c327574106f470c72638e9f34c7f8cd26d78a2bf Mon Sep 17 00:00:00 2001
From: ludc
Date: 星期三, 24 一月 2024 23:48:36 +0800
Subject: [PATCH] 分类授权,数据授权接口修改

---
 Source/UBCS-WEB/src/components/Master/MasterTree.vue |  134 +++++++++++++++++++++++++++++++++++---------
 1 files changed, 105 insertions(+), 29 deletions(-)

diff --git a/Source/UBCS-WEB/src/components/Master/MasterTree.vue b/Source/UBCS-WEB/src/components/Master/MasterTree.vue
index 30e20db..3abe4a1 100644
--- a/Source/UBCS-WEB/src/components/Master/MasterTree.vue
+++ b/Source/UBCS-WEB/src/components/Master/MasterTree.vue
@@ -1,10 +1,17 @@
 <template>
-  <div style="overflow: auto; height: calc(100vh - 150px);">
-    <avue-tree ref="tree" v-model="CloneTreeAvueform" v-loading="loading" :data="Treedata" :defaultExpandAll="false" :option="Treeoption" @node-click="nodeClick" style="width: fit-content;">
+  <div class="app" style="position: relative;">
+    <avue-tree ref="tree" v-model="CloneTreeAvueform" v-loading="loading" :data="Treedata" :defaultExpandAll="false"
+               :option="Treeoption" style="width: fit-content;" @node-click="nodeClick">
       <template slot-scope="{ node }">
-        <span style="display: inline-block;">{{ node.label }}</span>
+        <el-tooltip :content="$createElement('div', { domProps: { innerHTML: node.label } })" class="item" effect="dark"
+                    open-delay="350" placement="right-start">
+          <span id="labelSize" v-html="node.label"></span>
+        </el-tooltip>
       </template>
     </avue-tree>
+    <div style="position: absolute; right: 3px; top: -1px;">
+      <el-link class="refresh-icon" icon="el-icon-refresh" @click="getTreeLists"></el-link>
+    </div>
   </div>
 </template>
 
@@ -30,8 +37,9 @@
   },
   data() {
     return {
-      TreeValue:'',
+      TreeValue: '',
       idData: '',
+      referTreeId: '',
       masterVrBtnList: [],
       tableHeadFindData: [],
       tableHeadDataFateher: [],
@@ -49,20 +57,21 @@
         delBtn: false,
         defaultExpandAll: false,
         menu: false,
-        lazy: true,
-        // treeLoad:function (node,resolve){
-        //   console.log(node)
-        //   console.log(resolve)
-        // }
-        treeLoad: function (node, resolve) {
+        // lazy: true,
+        treeLoad: (node, resolve) => {
           if (node.data != false) {
             const parentId = (node.level === 0) ? 0 : node.data.oid;
-            const parentBtmName = node.data.attributes.btmname
-            getTreeList({parentOid: parentId, parentBtmName: parentBtmName}).then(res => {
+            const parentBtmName = node.data.attributes.btmname;
+            getTreeList({
+              parentOid: parentId,
+              parentBtmName: parentBtmName,
+              'conditionMap[btmTypeId]': this.referTreeId
+            }).then(res => {
               resolve(res.data.map(item => {
                 return {
                   ...item,
-                  label: item.text
+                  label: `<span style="color:#409EFF">${item.count}</span> ${item.text}`,
+                  count: item.count
                 }
               }))
             })
@@ -74,34 +83,64 @@
   created() {
     this.getTreeLists()
   },
-  computed: {},
+  mounted() {
+
+  },
+  computed: {
+    formatCount() {
+      return (label) => {
+        const countIndex = label.indexOf('</span>') + '</span>'.length;
+        const count = label.slice(countIndex);
+        const coloredCount = `<span class="count">${count}</span>`;
+        return `${label.slice(0, countIndex)}${coloredCount}`;
+      };
+    },
+  },
   methods: {
     //鑾峰彇鏁版嵁
     getTreeLists() {
       const index = this.$route.query.id.indexOf('@');
       const result = this.$route.query.id.substring(0, index);
-      this.idData = result
-      // console.log(this.$route)
-      getTreeList({'conditionMap[id]': this.idData}).then(res => {
-        if(res){
-          if(res.data.length === 0){
+      this.idData = result;
+      this.removeList();
+      let conditionMaps = {};
+      conditionMaps["conditionMap[id]"] = this.idData;
+      conditionMaps["conditionMap[authType]"] = "data_auth";
+      conditionMaps["conditionMap[buttonCode]"] = this.idData;
+      // 鏁版嵁鎺堟潈涓槸鍚﹀叿澶囨煡鐪嬫潈闄�
+      conditionMaps["conditionMap[menuCode]"] = "data_view";
+      getTreeList(conditionMaps).then(res => {
+        if (res) {
+          if (res.data.length === 0) {
             this.$message.error("涓绘暟鎹垎绫绘煡璇负绌猴紒");
-          }else{
+          } else {
             this.Treedata = res.data;
             const [firstProperty] = res.data;
             this.ModifyProperties(this.Treedata, 'text', 'label');
+            this.referTreeId = firstProperty.attributes.btmTypeId;
+            // console.log(this.referTreeId)
             this.codeClassifyOid = firstProperty.oid;
             this.coderuleoid = firstProperty.attributes.coderuleoid;
+            this.$emit("coderuleoid", this.coderuleoid)
+            this.$emit('Treedata', this.Treedata)
+            this.Treedata.forEach((item, index) => {
+              item.label = `<span style="color:#409EFF">${item.count}</span> ${item.label}`;
+            });
             this.$emit("coderuleoid", this.coderuleoid)
             this.$emit('Treedata', this.Treedata)
           }
         }
       }).catch(res => {
-        // console.log(res)
         this.$message.error(res)
       });
     },
-
+    removeList() {
+      this.$emit('tableHeadDataFateher', []);
+      this.$emit('tableHeadFindData', []);
+      this.$emit('tableHeadBttoms', []);
+      this.$emit('tableDataArray', [])
+      this.$emit('total', null)
+    },
     //瀹氫箟涓�涓慨鏀规暟鎹睘鎬у悕鐨勬柟娉�
     ModifyProperties(obj, oldName, newName) {
       for (let key in obj) {
@@ -116,12 +155,17 @@
     },
     //琛ㄦ牸鍒锋柊
     TableRend() {
+      this.loading = true;
+      this.$emit('loading', this.loading)
       TableData({
         templateOid: this.templateOids,
         codeClassifyOid: this.nodeClickList.oid,
         page: this.currentPage,
         limit: this.pageSize,
       }).then(res => {
+        // console.log('tab',res)
+        this.loading = false;
+        this.$emit('loading', this.loading)
         this.tableDataArray = res.data.data;
         this.$emit('tableDataArray', this.tableDataArray)
         this.$emit('total', res.data.total)
@@ -131,6 +175,7 @@
     TableHeadRend() {
       const index = this.$route.query.id.indexOf('@');
       const result = this.$route.query.id.substring(0, index);
+      // console.log(this.$route)
       return new Promise((resolve, reject) => {
         MasterTable({
           codeClassifyOid: this.nodeClickList.oid,
@@ -152,7 +197,8 @@
               prop: item.field,
               // type: this.columnType[item.type],
               sortable: item.sort,
-              width: item.minWidth
+              width: item.minWidth,
+              query: item.queryField
             };
             this.tableHeadFindData.push(Object.assign(item, columnItem))
           })
@@ -168,18 +214,19 @@
     //鏍戠偣鍑讳簨浠�
     async nodeClick(data) {
       try {
-        // console.log(data)
-        this.TreeValue=data.label.split(" ")[0].trim();
-        this.$emit('TreeValue',this.TreeValue)
+        console.log(data)
+        this.TreeValue = data.label.split("</span>")[1].trim();
+        // console.log('TreeValue',this.TreeValue)
+        this.$emit('TreeValue', this.TreeValue)
         this.nodeClickList = data;
         this.tableHeadDataFateher = []
         this.tableHeadFindData = []
         await this.TableHeadRend(); // 鍏堟墽琛� TableHeadRend()
         this.TableRend(); // TableHeadRend() 鏂规硶瀹屾垚鍚庡啀鎵ц TableRend()
-        this.$emit('nodeClick', this.templateOids)
+        this.$emit('nodeClickTemplateOids', this.templateOids)
         this.$emit("codeClassifyOid", this.nodeClickList.oid)
+        this.$emit("nodeClickList", this.nodeClickList)
       } catch (error) {
-        // 澶勭悊閿欒
         this.$message.error(error)
       }
     }
@@ -187,6 +234,35 @@
 }
 </script>
 
-<style scoped>
+<style lang="scss" scoped>
+.app {
+  overflow: auto;
+  height: calc(100vh - 145px);
+}
 
+.app::-webkit-scrollbar {
+  height: 15px; // 绾靛悜婊氬姩鏉� 蹇呭啓
+  background: white;
+  border: white;
+  width: 10px;
+
+}
+
+// 婊氬姩鏉$殑婊戝潡
+.app::-webkit-scrollbar-thumb {
+  background-color: #ececec;
+  border-radius: 20px;
+  border: #ececec;
+}
+
+.refresh-icon {
+  color: #409EFF;
+  margin-top: 8px;
+  margin-left: 6px;
+  font-size: 18px;
+}
+
+#labelSize {
+  font-size: 14px !important;
+}
 </style>

--
Gitblit v1.9.3