From c02bff2911f720d54388f4abb6456ec1777f8a96 Mon Sep 17 00:00:00 2001
From: zhangxiao <898441624@qq.com>
Date: 星期五, 30 八月 2024 10:40:02 +0800
Subject: [PATCH] fix: 修改bug

---
 src/views/authority/role/index.vue |   50 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/src/views/authority/role/index.vue b/src/views/authority/role/index.vue
index 300fc72..ea318ca 100644
--- a/src/views/authority/role/index.vue
+++ b/src/views/authority/role/index.vue
@@ -87,6 +87,9 @@
         </template>
         <template #operations="{ record }">
           <a-space>
+            <a-button type="outline" @click="operation(2, record)"
+            >缂栬緫</a-button
+            >
             <a-button
               type="dashed"
               status="warning"
@@ -285,6 +288,8 @@
   import Authheader from '@/views/authority/components/authheader.vue';
   import router from "@/router";
   import { queryCanvasList } from "@/api/Agent";
+  import { getUserInfo, getUserResources } from "@/utils/auth";
+  import { forEach } from "lodash";
 
   let treeDataMenu = ref([]);
   let checkedKeysMenu = ref([]);
@@ -336,6 +341,7 @@
   let resourcevisible = ref(false);
   let selectRole = ref({});
 
+  let u =JSON.parse(getUserInfo());
 
   const eachChildrenAdd=(node)=>{
     if (node.children?.length > 0) {
@@ -578,6 +584,14 @@
       editform.value.remark = "";
     }
 
+    if (t == 2) {
+      visible.value = true;
+      formRef.value?.resetFields();
+      save.value = '缂栬緫';
+      editform.value.roleId=record.roleId
+      editform.value.roleName = record.roleName;
+    }
+
     //鍒犻櫎
     if (t == 3) {
       await RoleDelete(record.roleId).then((res) => {
@@ -595,6 +609,7 @@
       checkStrictlyKnowledge.value = [];
       checkedKeysKnowledge.value = [];
       checkStrictlyDialog.value = [];
+      checkStrictlyAgent.value = [];
       checkedKeysDialog.value = [];
       selectRole.value = record;
       if (record.resources) {
@@ -667,18 +682,45 @@
   };
 
 
+  let userResources = JSON.parse(getUserResources());
+  const isExist = (val): boolean => {
+    let isok = false;
+    userResources.forEach((r) => {
+      if (val == r.menuId) {
+        isok = true;
+      }
+    });
+    return isok;
+  };
+  const removeChild = (nodes,newT) => {
+    nodes.forEach((child) => {
+      if (isExist(child.menuId)){
+        newT.push(child);
+        let nt = [];
+        if (child.children?.length > 0) {
+          removeChild(child.children, nt);
+          child.children = nt;
+        }
+      }
+    });
+  };
+
   const MenuData = async (key) => {
     await ResourceList(key).then((res) => {
+      let newTree = [];
+      if (u.role != "admin") {
+        removeChild(res.rows, newTree);
+      }
       treeDataMenu.value = [...res.rows];
     });
   };
 
-  KnowledgeList().then((res) => {
-    knowledgeList.value = res.rows;
+  KnowledgeList(u.role).then((res) => {
+    knowledgeList.value = res.data;
   });
 
-  DialogList().then((res) => {
-    DialogsList.value = res.rows;
+  DialogList(u.role).then((res) => {
+    DialogsList.value = res.data;
   });
   queryCanvasList(null).then((canvas) => {
     AgentList= canvas.data

--
Gitblit v1.8.0