From 5167d73c1e36d0f9ddeb2a473d7164737b560fe0 Mon Sep 17 00:00:00 2001
From: pengwei <2071057782@qq.com>
Date: 星期一, 21 四月 2025 08:55:51 +0800
Subject: [PATCH] 优化

---
 项目代码/client/src/views/system/Permission.vue |   96 ++++++++++++++++++++++++++++++++++++------------
 1 files changed, 72 insertions(+), 24 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/client/src/views/system/Permission.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/client/src/views/system/Permission.vue"
index 54e3e4a..c2795d9 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/client/src/views/system/Permission.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/client/src/views/system/Permission.vue"
@@ -1,6 +1,14 @@
 <template>
-  <div style="width: 100%;height: 100%;display: flex;overflow: hidden;">
-    <div class="role-tree-left flex-col">
+  <div
+    style="
+      width: 100%;
+      height: 100%;
+      display: flex;
+      flex-direction: row;
+      overflow: hidden;
+    "
+  >
+    <!-- <div class="role-tree-left flex-col">
       <div class="title"><i class="el-icon-user"></i>瑙掕壊鍒楄〃</div>
       <el-scrollbar class="el-role-list">
         <el-tree :data="tree" @node-click="nodeClick" node-key="id" :default-expanded-keys="openKeys"
@@ -14,26 +22,55 @@
           </template>
         </el-tree>
       </el-scrollbar>
-    </div>
-    <div style="height: calc(100vh - 6.5rem);flex: 1;overflow: hidden;background-color: white;" class="role-tree-right flex-col">
+    </div> -->
+
+    <div
+      style="
+        height: calc(100vh - 6.5rem);
+        flex: 1;
+        overflow: hidden;
+        background-color: white;
+      "
+      class="role-tree-right flex-col"
+    >
+      <div class="title" style="display: flex; justify-content: space-between">
+        <div>瑙掕壊鏉冮檺绠$悊锛坽{ info.roleName }}锛�</div>
+        <el-icon @click="goBack" size="25"><CloseBold /></el-icon>
+      </div>
       <div class="title">
         <div><i class="el-icon-folder-opened"></i>鑿滃崟鏉冮檺</div>
         <el-button type="primary" @click="save">淇濆瓨</el-button>
       </div>
-      <el-scrollbar class="el-role-list" style="height: 100%;">
-        <el-tree @check-change="leftCheckChange" @check="nodeCheck" :data="roleTree" :show-checkbox="false"
-          style="padding: 15px" node-key="id" default-expand-all :expand-on-click-node="false">
+      <el-scrollbar class="el-role-list" style="height: 100%">
+        <el-tree
+          @check-change="leftCheckChange"
+          @check="nodeCheck"
+          :data="roleTree"
+          :show-checkbox="false"
+          style="padding: 15px"
+          node-key="id"
+          default-expand-all
+          :expand-on-click-node="false"
+        >
           <template #default="{ data }">
             <div class="action-group">
-              <div class="action-text" :style="{ width: (4 - data.lv) * 18 + 150 + 'px' }">
+              <div
+                class="action-text"
+                :style="{ width: (4 - data.lv) * 18 + 150 + 'px' }"
+              >
                 <el-checkbox v-model="data.leftCk" @change="allChange(data)">{{
                   // data.text + (data.isApp ? "(app)" : "")
                   data.text
                 }}</el-checkbox>
               </div>
               <div class="action-item">
-                <el-checkbox v-for="(item, index) in data.actions" :key="index" v-model="item.checked"
-                  @change="actionChange(data, item.checked)">{{ item.text }}</el-checkbox>
+                <el-checkbox
+                  v-for="(item, index) in data.actions"
+                  :key="index"
+                  v-model="item.checked"
+                  @change="actionChange(data, item.checked)"
+                  >{{ item.text }}</el-checkbox
+                >
               </div>
             </div>
           </template>
@@ -41,12 +78,18 @@
       </el-scrollbar>
     </div>
   </div>
-  
 </template>
 
 <script>
-import { defineComponent, ref, reactive, getCurrentInstance } from "vue";
+import {
+  defineComponent,
+  ref,
+  reactive,
+  getCurrentInstance,
+  onActivated,
+} from "vue";
 import http from "@/../src/api/http.js";
+import { useRoute, useRouter } from "vue-router";
 export default defineComponent({
   setup() {
     const selectId = ref(-1);
@@ -57,6 +100,11 @@
     const roleList = reactive([]);
     const roleTree = reactive([]);
     const openKeys = reactive([]);
+    const route = useRoute();
+    const router = useRouter();
+    const userInfo = reactive({});
+    const info = ref({});
+    info.value = JSON.parse(history.state?.info);
 
     const leftCheckChange = (node, selected) => {
       node.actions.forEach((x, index) => {
@@ -109,7 +157,6 @@
     const load = () => {
       const url = "api/Sys_Role/getUserChildRoles";
       http.post(url, {}, true).then((result) => {
-
         if (!result.status) return;
         list.splice(0);
         list.push(...result.data);
@@ -140,13 +187,12 @@
       getUserRole(node);
     };
     const getUserRole = (item) => {
-      selectId.value = item.id;
       roleList.forEach((x) => {
         x.actions.forEach((a) => {
           a.checked = false;
         });
       });
-      let url = `/api/Sys_Role/getUserTreePermission?roleId=${item.id}`;
+      let url = `/api/Sys_Role/getUserTreePermission?roleId=${info.value.roleId}`;
       http.post(url, {}, true).then((result) => {
         if (!result.status) return;
         result.data.forEach((item) => {
@@ -164,6 +210,9 @@
       });
     };
 
+    const goBack = () => {
+      router.push("/Usermanagement");
+    };
     const getRoleTree = (id, data, isRootId) => {
       roleList.forEach((x) => {
         if (x.pid == id) {
@@ -199,9 +248,6 @@
     let $message =
       getCurrentInstance().appContext.config.globalProperties.$message;
     const save = () => {
-      if (selectId.value <= 0) {
-        return $message.error("璇烽�夋嫨瑙掕壊!");
-      }
       let userPermissions = [];
       roleList.forEach((x) => {
         let checkedPermission = x.actions.filter((f) => {
@@ -217,7 +263,7 @@
           });
         }
       });
-      let url = `api/Sys_Role/SavePermission?roleId=${selectId.value}`;
+      let url = `api/Sys_Role/SavePermission?roleId=${info.value.roleId}`;
       http.post(url, userPermissions, true).then((result) => {
         $message[result.status ? "success" : "error"](result.message);
       });
@@ -225,6 +271,9 @@
 
     load();
     getCurrentTreePermission();
+    getUserRole();
+    console.log("123", info.value);
+
     return {
       list,
       nodeClick,
@@ -242,12 +291,15 @@
       allChange,
       actionChange,
       save,
+      route,
+      goBack,
+      router,
+      info,
     };
   },
 });
 </script>
 <style lang="less" scoped>
-
 .flex-col {
   display: flex;
   flex-direction: column;
@@ -265,8 +317,6 @@
     }
   }
 }
-
-
 
 .title {
   display: flex;
@@ -299,7 +349,6 @@
   }
 }
 
-
 .title {
   padding: 10px;
   background: rgb(246 250 255);
@@ -313,7 +362,6 @@
   height: 0;
   overflow-x: hidden;
 }
-
 
 .role-tree-left ::v-deep(.el-tree-node__content) {
   cursor: pointer;

--
Gitblit v1.9.3