Browse Source

权限项修改

zhaoke 3 years ago
parent
commit
5f8170c941

+ 19 - 6
src/components/organization/index.vue

@@ -71,6 +71,10 @@ export default {
       type: Array,
       default: () => [],
     },
+    orgType: {
+      type: String,
+      default: "org",
+    },
   },
   components: { Rolelist },
   data () {
@@ -100,7 +104,7 @@ export default {
     },
   },
   mounted () {
-    if(this.data!=null){
+    if (this.data != null) {
       this.data = this.formatData(this.data)
     }
   },
@@ -121,11 +125,20 @@ export default {
       return data;
     },
     currentChange (data, isChecked) {
-      const { OrganId } = data
-      this.$emit("getTreeData", this.$refs.tree.getCheckedNodes())
-      if (isChecked) {
-        const checked = [OrganId]
-        this.$refs.tree.setCheckedKeys(checked)
+      if (this.orgType == 'orgType') {
+        const { OrganId } = data
+        this.$emit("getTreeData", this.$refs.tree.getCheckedNodes())
+        if (isChecked) {
+          const checked = [OrganId]
+          this.$refs.tree.setCheckedKeys(checked)
+        }
+      } else if (this.orgType == 'auth') {
+        const { AuthId } = data
+        this.$emit("getTreeData", this.$refs.tree.getCheckedNodes())
+        if (isChecked) {
+          const checked = [AuthId]
+          this.$refs.tree.setCheckedKeys(checked)
+        }
       }
     },
     // 选中后设置初始数据

+ 45 - 88
src/views/authorityManagement/components/authorityPowerEdit.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: your name
  * @Date: 2021-11-29 11:26:07
- * @LastEditTime: 2022-01-12 16:38:02
+ * @LastEditTime: 2022-02-15 10:51:06
  * @LastEditors: Please set LastEditors
  * @Description:权限项
  * @FilePath: \Foshan4A2.0\src\views\authorityManagement\components\authorityPower.vue
@@ -25,49 +25,22 @@
         </div>
       </div>
       <div class="addApp-form-content dialog-public-background">
-        <el-form
-          :inline="true"
-          ref="form"
-          :rules="rules"
-          class="form"
-          :model="form"
-        >
+        <el-form :inline="true" ref="form" :rules="rules" class="form" :model="form">
           <el-form-item prop="name" label="权限项名称">
-            <el-input
-              placeholder="请输入权限项名称"
-              maxlength="32"
-              v-model="form.name"
-            ></el-input>
+            <el-input placeholder="请输入权限项名称" maxlength="32" v-model="form.name"></el-input>
           </el-form-item>
           <el-form-item prop="id" label="标识符">
-            <el-input
-              placeholder="请输入标识符"
-              maxlength="32"
-              v-model="form.id"
-            ></el-input>
+            <el-input placeholder="请输入标识符" maxlength="32" v-model="form.id"></el-input>
           </el-form-item>
           <el-form-item label="描述">
-            <el-input
-              style="width: 640px"
-              maxlength="200"
-              placeholder="请输入描述"
-              v-model="form.app"
-            ></el-input>
+            <el-input style="width: 640px" maxlength="200" placeholder="请输入描述" v-model="form.app"></el-input>
           </el-form-item>
         </el-form>
       </div>
     </div>
     <div class="power-content flex-wrap">
-      <div
-        :class="!openRole && !UserOfficerMulti ? '' : 'r24'"
-        class="flex1 part"
-      >
-        <Organization
-          :defaultProps="defaultProps"
-          :data="data"
-          nodekey="AuthId"
-          title="上级权限项"
-        />
+      <div :class="!openRole && !OpenGroup ? '' : 'r24'" class="flex1 part">
+        <Organization :defaultProps="defaultProps" :checkedKeys="checkedKeys" @getTreeData="getTreeData" :orgType="orgType" :data="data" nodekey="AuthId" title="上级权限项" />
       </div>
       <!--有角色-->
       <template v-if="openRole">
@@ -75,26 +48,16 @@
           <Rulesofcompetency @getData="getData" title="权限规则" />
         </div>
         <div class="flex1 part">
-          <Rolelist
-            @checkChange="checkChange"
-            :dataList="roleList"
-            :number="8"
-            title="角色"
-          />
+          <Rolelist @checkChange="checkChange" :roleType="roleType" :number="8" title="角色" />
         </div>
       </template>
-      <!--有多对多-->
-      <template v-else-if="UserOfficerMulti">
+      <!--有账号组-->
+      <template v-else-if="OpenGroup">
         <div class="r24 flex1 part">
           <Rulesofcompetency @getData="getData" title="权限规则" />
         </div>
         <div class="flex1 part">
-          <Rolelist
-            @checkChange="checkChange"
-            :dataList="roleList"
-            :number="8"
-            title="账号授权"
-          />
+          <Rolelist @checkChange="checkChange" :roleType="roleType" :number="8" title="账号授权" />
         </div>
       </template>
     </div>
@@ -118,7 +81,7 @@ export default {
   name: "AuthorityPower",
   components: { Rolelist, Rulesofcompetency, Organization },
   mixins: [treeData],
-  data() {
+  data () {
     return {
       radio: 1,
       form: {
@@ -142,7 +105,7 @@ export default {
       UpAuthId: null,
       data: [],
       openRole: null,
-      UserOfficerMulti: null,
+      OpenGroup: null,
       roleList: [],
       title: "角色",
       editRoles: [],
@@ -150,6 +113,9 @@ export default {
       authTo: {},
       rulesObj: {},
       msgDatas: [],
+      roleType: '',
+      orgType: '',
+      checkedKeys: []
     };
   },
   computed: {
@@ -157,36 +123,18 @@ export default {
   },
   watch: {
     dataList: {
-      handler(val) {
-        const arr = val.children;
-        this.decompose(arr, this.UpAuthId);
-        if (Array.isArray(this.dataObj)) {
-          this.data = this.dataObj;
-        } else {
-          this.data = [this.dataObj];
-        }
-      },
-      deep: true,
-    },
-    roleList: {
-      handler(arr) {
-        const datas = [];
-        this.msgDatas.forEach((item) => {
-          arr.forEach((p, i) => {
-            if (item.UserId === p.UserId && item.IsSelected) {
-              datas.push(i);
-            }
-          });
-        });
-        this.checkBoxList = datas;
+      handler (val) {
+        const arr = [val];
+        this.data = arr;
+        this.checkedKeys = [this.UpAuthId];
       },
       deep: true,
     },
   },
-  created() {
+  created () {
     this.getAuthTree();
     const { AuthId, Status, UpAuthId } = this.$route.query;
-    const { OpenRole, UserOfficerMulti } =
+    const { OpenRole, OpenGroup } =
       typeof this.systemSet === "string"
         ? JSON.parse(this.systemSet)
         : this.systemSet; //1是请求角色 0是请求用户
@@ -194,17 +142,20 @@ export default {
     this.AppId = AuthId;
     this.UpAuthId = UpAuthId;
     this.openRole = OpenRole;
-    this.UserOfficerMulti = UserOfficerMulti;
+    this.OpenGroup = OpenGroup;
     this.getAuthDetails(AuthId);
-    if (OpenRole) {
-      this.queryRole();
-    } else {
-      this.getUserList();
+  },
+  mounted () {
+    if (this.openRole) {
+      this.roleType = 'onlyRole';
+    } else if (this.OpenGroup) {
+      this.roleType = 'account';
     }
+    this.orgType = 'auth';
   },
   methods: {
     //获取指定数据
-    decompose(data, id) {
+    decompose (data, id) {
       for (let i = 0; i < data.length; i++) {
         if (data[i].AuthId == id) {
           this.dataObj = data[i];
@@ -215,7 +166,7 @@ export default {
       }
     },
     //保存
-    saveBtn(formName) {
+    saveBtn (formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {
           this.editAuth();
@@ -225,12 +176,18 @@ export default {
         }
       });
     },
+    //获取权限树回调
+    getTreeData (arr) {
+      const { AuthId, UpAuthId } = arr[0];
+      this.AppId = AuthId;
+      this.UpAuthId = UpAuthId;
+    },
     //获取权限规则
-    getData(obj) {
+    getData (obj) {
       this.rulesObj = obj;
     },
     //获取应用详情
-    async getAuthDetails(id) {
+    async getAuthDetails (id) {
       try {
         const res = await GetAuthDetails({
           AuthId: id,
@@ -283,7 +240,7 @@ export default {
       }
     },
     //角色列表
-    async queryRole() {
+    async queryRole () {
       try {
         const res = await QueryRole({
           QueryName: "",
@@ -302,7 +259,7 @@ export default {
       }
     },
     //账号列表
-    async getUserList() {
+    async getUserList () {
       try {
         const res = await GetUserList({
           QueryName: "",
@@ -321,7 +278,7 @@ export default {
       }
     },
     //角色选取
-    checkChange(arr) {
+    checkChange (arr) {
       const datas = [];
       for (let i = 0; i < arr.length; i++) {
         datas.push(this.roleList[arr[i]]);
@@ -329,7 +286,7 @@ export default {
       this.msgDatas = datas;
     },
     //权限新增保存
-    async editAuth() {
+    async editAuth () {
       try {
         const arr = this.$store.getters.authArrs;
         const datas = this.msgDatas;
@@ -361,7 +318,7 @@ export default {
       }
     },
     //删除权限
-    async deleteAuth() {
+    async deleteAuth () {
       try {
         const res = await DeleteAuth({
           AuthId: this.AppId,

+ 7 - 1
src/views/authorityManagement/minixs/treeData.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-12-22 17:00:22
- * @LastEditTime: 2022-01-12 09:56:34
+ * @LastEditTime: 2022-02-15 10:16:36
  * @LastEditors: Please set LastEditors
  * @Description: 获取权限树
  * @FilePath: \Foshan4A2.0\src\views\authorityManagement\minixs\treeData.js
@@ -35,6 +35,7 @@ export default {
             Status: 0,
             UpAuthId: -1,
             Type: 0,
+            disabled: true,
             children: translateDataToTreeAll(result.returnData, 'UpAuthId', 'AuthId')
           }
           this.dataList = obj
@@ -46,6 +47,7 @@ export default {
             Status: 0,
             UpAuthId: -2,
             Type: 0,
+            disabled: true,
             children: []
           }
           )
@@ -57,6 +59,7 @@ export default {
             Status: 0,
             UpAuthId: -2,
             Type: 0,
+            disabled: true,
             children: []
           }
           this.dataList = obj
@@ -67,6 +70,7 @@ export default {
             Status: 0,
             UpAuthId: -2,
             Type: 0,
+            disabled: true,
             children: []
           }
           )
@@ -79,6 +83,7 @@ export default {
           Status: 0,
           UpAuthId: -2,
           Type: 0,
+          disabled: true,
           children: []
         }
         this.dataList = obj
@@ -89,6 +94,7 @@ export default {
           Status: 0,
           UpAuthId: -2,
           Type: 0,
+          disabled: true,
           children: []
         }
         )