Quellcode durchsuchen

统一鉴权-新建权限组- 页面逻辑修复;行为权限,添加角色权限组问题修复;

Bella vor 2 Jahren
Ursprung
Commit
1344d8952a
3 geänderte Dateien mit 96 neuen und 29 gelöschten Zeilen
  1. 71 20
      src/components/auth/authAction.vue
  2. 23 7
      src/components/auth/authRole.vue
  3. 2 2
      vite.config.js

+ 71 - 20
src/components/auth/authAction.vue

@@ -8,6 +8,7 @@ export default {
         groupChecked: "",
         systemChecked: "",
       },
+      inputName: "",
       visible: {
         actionGroup: false,
         user: false,
@@ -410,26 +411,28 @@ export default {
         // 最终需要的数组
         this.addedSystemArr = [];
 
-        this.addedSystemMap.forEach((list, i) => {
-          if (JSON.stringify(list) !== "{}") {
-            for (let key in list) {
-              let deviceArr = list[key].map((m) => {
-                return `[${m.name}]`;
-              });
-              let deviceId = list[key].map((m) => {
-                return m.id;
-              });
-              this.addedSystemArr.push({
-                id: publicFunc.buildGuid("checked"),
-                group: i.split("-")[0],
-                system: i.split("-")[1],
-                floor: key,
-                deviceName: deviceArr.join(" "),
-                deviceId: deviceId,
-              });
+        if (this.addedSystemMap.size > 0) {
+          this.addedSystemMap.forEach((list, i) => {
+            if (JSON.stringify(list) !== "{}") {
+              for (let key in list) {
+                let deviceArr = list[key].map((m) => {
+                  return `[${m.name}]`;
+                });
+                let deviceId = list[key].map((m) => {
+                  return m.id;
+                });
+                this.addedSystemArr.push({
+                  id: publicFunc.buildGuid("checked"),
+                  group: i.split("-")[0],
+                  system: i.split("-")[1],
+                  floor: key,
+                  deviceName: deviceArr.join(" "),
+                  deviceId: deviceId,
+                });
+              }
             }
-          }
-        });
+          });
+        }
       }
     },
     treeValue(data) {
@@ -450,7 +453,11 @@ export default {
       this.checkedObj.groupChecked = data;
     },
     systemClick(data) {
-      this.checkedObj.systemChecked = data;
+      if (this.checkedObj.groupChecked == "") {
+        this.$message.info("请先选择角色组");
+      } else {
+        this.checkedObj.systemChecked = data;
+      }
     },
     deleteEvent(data) {
       let targetObj = this.addedSystemMap.get(`${data.group}-${data.system}`);
@@ -480,6 +487,11 @@ export default {
       this.addedSystemArr = this.addedSystemArr.filter((v) => {
         return v.id !== data.id;
       });
+
+      if (this.addedSystemArr.length === 0) {
+        this.checkedObj.groupChecked = "";
+        this.checkedObj.systemChecked = "";
+      }
     },
     // 打开新建权限行为组对话框
     createActionDialog() {
@@ -491,6 +503,13 @@ export default {
     },
     addActionGroupEvent() {
       this.visible.actionGroup = false;
+      this.$message.success("角色组添加成功!");
+      let groupName = this.inputName;
+      this.roleListData.push({
+        id: publicFunc.buildGuid("group"),
+        label: groupName,
+        type: "group",
+      });
     },
     addUserEvent() {
       this.visible.user = false;
@@ -563,6 +582,15 @@ export default {
                   title="新建行为权限组"
                   @ok="addActionGroupEvent"
                 >
+                  <div class="dialog-content">
+                    <div class="dialog-content-title">组名:</div>
+                    <div class="dialog-content-input">
+                      <a-input
+                        placeholder="请输入名称"
+                        v-model="inputName"
+                      ></a-input>
+                    </div>
+                  </div>
                 </a-modal>
               </div>
               <div
@@ -763,6 +791,29 @@ export default {
 <style lang="less" scoped>
 @fontDefaultColor: #7f7f7f;
 @fontColor: #66beff;
+.ant-modal-body {
+  .dialog-content {
+    width: 100%;
+    height: 100%;
+    display: flex;
+    align-items: center;
+    &-title {
+      width: 20%;
+      height: 100%;
+      display: flex;
+      align-items: center;
+      justify-content: center;
+      font-size: 16px;
+    }
+    &-input {
+      width: 75%;
+      height: 100%;
+      display: flex;
+      align-items: center;
+      justify-content: center;
+    }
+  }
+}
 .auth-action {
   width: 100%;
   height: 100%;

+ 23 - 7
src/components/auth/authRole.vue

@@ -282,13 +282,18 @@ export default {
         this.checkedObj.groupChecked != "" &&
         this.checkedObj.systemChecked != ""
       ) {
-        // group-system,作为key单独存
-        this.addedRoleMap.set(
-          `${this.checkedObj.groupChecked}-${this.checkedObj.systemChecked}`,
-          data
-        );
-        this.addedRoleArr = [];
+        let currentKey = `${this.checkedObj.groupChecked}-${this.checkedObj.systemChecked}`;
+
         if (data.length > 0) {
+          this.addedRoleMap.set(currentKey, data);
+        }
+
+        if (data.length == 0) {
+          this.addedRoleMap.set(currentKey, []);
+        }
+
+        this.addedRoleArr = [];
+        if (this.addedRoleMap.size > 0) {
           this.addedRoleMap.forEach((v, i) => {
             v.forEach((ele, index) => {
               this.addedRoleArr.push({
@@ -321,7 +326,11 @@ export default {
       this.checkedObj.groupChecked = data;
     },
     systemClick(data) {
-      this.checkedObj.systemChecked = data;
+      if (this.checkedObj.groupChecked == "") {
+        this.$message.info("请先选择角色组");
+      } else {
+        this.checkedObj.systemChecked = data;
+      }
     },
     // 删除添加的角色权限组列
     deleteEvent(data) {
@@ -377,6 +386,13 @@ export default {
     },
     addRoleGroupEvent() {
       this.visible.roleGroup = false;
+      this.$message.success("角色组添加成功!");
+      let groupName = this.inputName;
+      this.roleListData.push({
+        id: publicFunc.buildGuid("group"),
+        label: groupName,
+        type: "group",
+      });
     },
     addUserEvent() {
       this.visible.user = false;

+ 2 - 2
vite.config.js

@@ -112,8 +112,8 @@ export default defineConfig(({ command }) => {
       port: 8081,
       proxy: {
         "/ioc-api": {
-          target: "http://127.0.0.1:10099",
-          //target: "http://121.43.55.7:10091/ioc-server",
+          // target: "http://127.0.0.1:10099",
+          target: "http://121.43.55.7:10091/ioc-server",
           changeOrigin: true,
           rewrite: (path) => path.replace(/^\/ioc-api/, ""),
         },