From 3ef0ee19b5991ee38ec6404a36c325171014f7fa Mon Sep 17 00:00:00 2001
From: yuxc <yuxc@vci-tech.com>
Date: 星期二, 07 一月 2025 18:01:47 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 Source/plt-web/plt-web-ui/src/views/authority/ui/uiAuthorization/index.vue |  155 +++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 113 insertions(+), 42 deletions(-)

diff --git a/Source/plt-web/plt-web-ui/src/views/authority/ui/uiAuthorization/index.vue b/Source/plt-web/plt-web-ui/src/views/authority/ui/uiAuthorization/index.vue
index 3fb919b..8a6717e 100644
--- a/Source/plt-web/plt-web-ui/src/views/authority/ui/uiAuthorization/index.vue
+++ b/Source/plt-web/plt-web-ui/src/views/authority/ui/uiAuthorization/index.vue
@@ -1,13 +1,13 @@
 <template>
   <el-container>
     <el-aside>
-      <basic-container>
+      <basic-container v-loading="treeLoading">
         <div ref="TreeBox" style="height: calc(100vh - 154px);!important;">
           <!-- 宸︿晶鏍�         -->
           <div style="height:  calc(100vh - 195px);">
             <avue-tree :data="treeData" :option="treeOption" @node-click="nodeClick">
               <span slot-scope="{ node, data }" class="el-tree-node__label">
-               <span style="font-size: 15px">
+               <span>
                   <i class="el-icon-user-solid"></i>
                     {{ (node || {}).label }}
                 </span>
@@ -19,12 +19,17 @@
     </el-aside>
 
     <el-main>
-      <basic-container>
+      <basic-container v-loading="mainLoading">
         <h3 style="margin: 0 0 10px 0">UI鏉冮檺閰嶇疆</h3>
         <div>
-          <el-button icon="el-icon-place" plain size="small" type="primary" @click="saveHandler">鎺堟潈</el-button>
-          <el-button icon="el-icon-close" plain size="small" style="margin-right: 40px;" type="primary"
-                     @click="clearValue">閲嶇疆
+          <el-button v-if="permissionList.rightBtn" class="button-custom-icon" plain size="small" type="primary" @click="saveHandler">
+            <icon-show :name="permissionList.rightBtn.source"></icon-show>
+            鎺堟潈
+          </el-button>
+          <el-button v-if="permissionList.resetBtn" class="button-custom-icon" plain size="small" style="margin-right: 40px;" type="primary"
+                     @click="clearValue">
+            <icon-show :name="permissionList.resetBtn.source"></icon-show>
+            閲嶇疆
           </el-button>
           涓氬姟绫诲瀷锛�
           <el-select v-model="type" :clearable="true" placeholder="璇烽�夋嫨" size="small"
@@ -49,9 +54,9 @@
           </el-select>
         </div>
         <div style="height:  calc(100vh - 232px);margin-top: 10px;">
-          <avue-tree ref="uiTree" :data="uiTreeData" :option="uiTreeOption">
+          <avue-tree ref="uiTree" :data="uiTreeData" :node-key="oid" :option="uiTreeOption">
             <span slot-scope="{ node, data }" class="el-tree-node__label">
-               <span style="font-size: 15px">
+               <span>
                   <i :class="data.icon"></i>
                     {{ (node || {}).label }}
                 </span>
@@ -65,14 +70,17 @@
 </template>
 
 <script>
-import {gridRoles} from "@/api/system/role/api";
+import {gridRoles, getRightListByRoleId} from "@/api/system/role/api";
 import {getUIAuthor, authorizedUI} from "@/api/authority/ui/uiAuthor";
 import {getBizTree, gridUIContextData} from "@/api/UI/uiDefine";
+import {mapGetters} from "vuex";
 
 export default {
   name: "index",
   data() {
     return {
+      treeLoading: false,
+      mainLoading:false,
       type: '',//涓氬姟绫诲瀷
       context: '',//UI涓婁笅鏂嘽ode
       treeOption: {
@@ -104,60 +112,88 @@
       contextData: []
     }
   },
+  computed:{
+    ...mapGetters(["permission"]),
+    permissionList() {
+      return {
+        rightBtn: this.vaildData(this.permission[this.$route.query.id].RIGHT, false),
+        resetBtn: this.vaildData(this.permission[this.$route.query.id].RESET, false),
+      };
+    },
+  },
   created() {
     this.getTreeList();
-    this.getTypeList()
+    // this.getUITree();
+    this.getTypeList();
   },
   methods: {
     getTreeList() {
-      const loading = this.$loading({});
+      this.treeLoading = true;
       gridRoles().then(res => {
         this.treeData = res.data.data;
-        loading.close();
+        this.treeLoading = false;
       }).catch(error => {
-        loading.close();
+        this.treeLoading = false;
       })
     },
+
     // 瑙掕壊鐐瑰嚮
     nodeClick(row) {
       this.nodeRow = row;
       this.getUITree();
     },
+
     getUITree() {
-      if (this.nodeRow && this.nodeRow.oid) {
-        const loading = this.$loading({});
-        const params = {
-          'conditionMap[roleId]': this.nodeRow.oid,
-          'conditionMap[type]': this.type,
-          'conditionMap[context]': this.context,
-          'conditionMap[showCheckbox]': true
-        }
-        this.defaultExpandKeys = ['root'];
-        getUIAuthor(params).then(res => {
-          this.processChildren(res.data.data[0]); // 澶勭悊姣忎釜鑺傜偣
-          this.uiTreeOption.defaultExpandedKeys = this.defaultExpandKeys;
-          this.uiTreeData = [{
-            attributes: {},
-            checked: false,
-            expanded: true,
-            data: "root",
-            level: 0,
-            icon: 'el-icon-s-home',
-            oid: res.data.data[0].oid,
-            label: res.data.data[0].text,
-            children: res.data.data[0].children
-          }];
-          loading.close();
-        }).catch(error => {
-          loading.close();
-        })
+      this.mainLoading = true;
+      const params = {
+        'conditionMap[roleId]': this.nodeRow.oid,
+        'conditionMap[type]': this.type,
+        'conditionMap[context]': this.context,
+        'conditionMap[showCheckbox]': true
       }
+      this.defaultExpandKeys = ['root'];
+      getUIAuthor(params).then(res => {
+        this.processChildren(res.data.data[0]); // 澶勭悊姣忎釜鑺傜偣
+        this.uiTreeOption.defaultExpandedKeys = this.defaultExpandKeys;
+        this.uiTreeData = [{
+          attributes: {},
+          checked: false,
+          expanded: true,
+          data: "root",
+          level: 0,
+          icon: 'el-icon-s-home',
+          oid: res.data.data[0].oid,
+          label: res.data.data[0].text,
+          children: res.data.data[0].children
+        }];
+        const checkedData = this.findCheckedOids(res.data.data[0]);
+        this.$refs.uiTree.setCheckedKeys(checkedData);
+
+        this.mainLoading = false;
+      }).catch(error => {
+        this.mainLoading = false;
+      })
     },
+
+    // 鏌ユ壘宸查�夋嫨鑺傜偣
+    findCheckedOids(obj, result = []) {
+      if (obj.checked === true) {
+        result.push(obj.oid);
+      }
+      // 濡傛灉鏈� children锛屽垯缁х画閬嶅巻
+      if (obj.children && obj.children.length > 0) {
+        obj.children.forEach(child => {
+          this.findCheckedOids(child, result);
+        });
+      }
+      return result;
+    },
+
     //澶勭悊鏍�
     processChildren(item) {
       if (item.children && item.children.length > 0) {
         item.children = item.children.map(child => {
-          if (child.level < 2) {
+          if (child.level < 3) {
             // 榛樿鏍戣妭鐐瑰睍寮�涓ゅ眰鏁堟灉
             this.defaultExpandKeys.push(child.oid)
           }
@@ -182,11 +218,13 @@
         });
       }
     },
+
     getTypeList() {
       getBizTree().then(res => {
         this.typeData = res.data.obj.children;
       })
     },
+
     typeChange(data) {
       this.contextData = [];
       this.type = data;
@@ -202,21 +240,53 @@
       }
       this.getUITree();
     },
+
     contextChange(data) {
       this.context = data;
       this.getUITree();
     },
+
     saveHandler() {
       const selectTreeList = this.$refs.uiTree.getCheckedNodes();
+      const selectParentList = this.$refs.uiTree.getHalfCheckedNodes();
       if (selectTreeList.length == 0) {
         this.$message.error("璇烽�夋嫨鍔熻兘妯″潡");
         return;
       }
+      const selectTreeData = selectTreeList.map(item => {
+        return {
+          checked: true,
+          expanded: true,
+          data:item.data,
+          parentId:item.parentId,
+          level: item.level,
+          leaf:item.leaf,
+          oid: item.oid,
+          text: item.text
+        }
+      })
+
+      const parentData = selectParentList.map(item => {
+        return {
+          checked: false,
+          expanded: true,
+          data:item.data,
+          parentId:item.parentId,
+          level: item.level,
+          leaf:item.leaf,
+          oid: item.oid,
+          text: item.text
+        }
+      })
+      // 鍦ㄥ崐閫夌姸鎬佷腑杩囨护鎺夐《绾ц妭鐐� oid 涓� root
+      const filterSelectTreeData = parentData.filter(item => item.oid !== 'root');
+
+      const data = [...selectTreeData,...filterSelectTreeData];
       const formData = {
         roleId: this.nodeRow.oid,
         type: this.type,
         context: this.context,
-        selectTreeList: selectTreeList
+        selectTreeList: data
       }
       authorizedUI(formData).then(res => {
         if (res.data.success) {
@@ -225,6 +295,7 @@
         }
       });
     },
+
     clearValue() {
       this.$refs.uiTree.setCheckedNodes([]);
     }

--
Gitblit v1.9.3