Browse Source

修改角色授权

zhaoke 2 years ago
parent
commit
bdd5610741

+ 29 - 41
src/components/permissiontree/index.vue

@@ -50,12 +50,12 @@
                 <div class="four" v-if="data.AuthList && data.AuthList.Action == '2'"></div> -->
                 <div class="three" v-if="
                     data.AuthList &&
-                    (data.AuthList.EditCol || data.EditCol ||
-                      data.AuthList.DeleteRow || data.DeleteRow ||
-                      data.AuthList.EditRow || data.EditRow ||
-                      data.AuthList.NewCol || data.NewCol ||
-                      data.AuthList.QueryCol || data.QueryCol ||
-                      data.AuthList.QueryRow || data.QueryRow)
+                    (data.AuthList.edit_col_condition || data.edit_col_condition ||
+                      data.AuthList.delete_row_condition || data.delete_row_condition ||
+                      data.AuthList.edit_row_condition || data.edit_row_condition ||
+                      data.AuthList.new_col_condition || data.new_col_condition ||
+                      data.AuthList.query_col_conditon || data.query_col_conditon ||
+                      data.AuthList.query_row_condition || data.query_row_condition)
                   "></div>
               </div>
             </span>
@@ -135,8 +135,13 @@ export default {
     "$store.state.auth.authList": {
       handler (val) {
         if (val && val.length) {
-          this.AuthList = val;
-          this.resetData();
+          setTimeout(() => {
+            this.AuthList = val;
+            this.resetData();
+            if (this.$store.getters.authId) {
+              this.defaultExpandedKeys = [this.$store.getters.authId]
+            }
+          }, 150);
         } else {
           this.getAuthList();
         }
@@ -200,6 +205,9 @@ export default {
         if (arr && arr.length) {
           this.AuthList = arr;
           this.resetData();
+          if (this.$store.getters.authId) {
+            this.defaultExpandedKeys = [this.$store.getters.authId]
+          }
         } else {
           this.getAuthList();
         }
@@ -269,36 +277,20 @@ export default {
     //数据转树形
     toTree () {
       this.data = [];
-      this.dataObj = {};
-      this.treeTitles = [];
-      let arr = null;
-      arr = translateDataToTreeAll(this.AuthArrList, "up_auth_id", "auth_id");
-      let items = null;
-      items = {
+      const arr = translateDataToTreeAll(
+        this.AuthArrList,
+        "up_auth_id",
+        "auth_id"
+      )
+      const items = {
         auth_id: -1,
         auth_name: "所有权限",
-        QueryTarget: 0,
         auth_status: 0,
         up_auth_id: -2,
         auth_type: 0,
-        disabled: true,
         children: arr,
       };
-      this.dataObj = _.cloneDeep(items);
-      this.data = [items];
-      let obj = null;
-      obj = _.cloneDeep(items);
-      let datas = null;
-      datas = obj.children.filter((item) => item.auth_type == 1);
-      datas.forEach((item) => {
-        delete item.children;
-      });
-      delete obj.children;
-      datas.unshift(obj);
-      this.treeTitles = datas;
-      if (this.$refs.tree) {
-        this.$refs.tree.setCheckedKeys(this.checkedList);
-      }
+      this.data = [items]
     },
     //数据切换
     upActive (item, index) {
@@ -342,16 +334,12 @@ export default {
       arr.forEach((item) => {
         if (!item.AuthList) {
           item.AuthList = {
-            AuthId: item.auth_id,
-            ValidBegin: "",
-            ValidEnd: "",
-            Action: "1",
-            QueryRow: "",
-            QueryCol: "",
-            NewCol: "",
-            EditRow: "",
-            EditCol: "",
-            DeleteRow: "",
+            query_row_condition: "",
+            query_col_conditon: "",
+            delete_row_condition: "",
+            new_col_condition: "",
+            edit_row_condition: "",
+            edit_col_condition: ""
           };
         }
       });

+ 26 - 112
src/components/rulesofcompetency/index.vue

@@ -21,27 +21,27 @@
         </div> -->
         <div class="juris_list" :style="{ marginBottom: marginB }">
           <p>许可查询行</p>
-          <el-input v-model="form.input1" placeholder="请输入内容" size="small"></el-input>
+          <el-input v-model="form.query_row_condition" placeholder="请输入内容" size="small"></el-input>
         </div>
         <div class="juris_list" :style="{ marginBottom: marginB }">
           <p>许可查询列</p>
-          <el-input v-model="form.input2" placeholder="请输入内容" size="small"></el-input>
+          <el-input v-model="form.query_col_conditon" placeholder="请输入内容" size="small"></el-input>
         </div>
         <div class="juris_list" :style="{ marginBottom: marginB }">
           <p>许可删除行</p>
-          <el-input v-model="form.input3" placeholder="请输入内容" size="small"></el-input>
+          <el-input v-model="form.delete_row_condition" placeholder="请输入内容" size="small"></el-input>
         </div>
         <div class="juris_list" :style="{ marginBottom: marginB }">
           <p>许可新增列</p>
-          <el-input v-model="form.input4" placeholder="请输入内容" size="small"></el-input>
+          <el-input v-model="form.new_col_condition" placeholder="请输入内容" size="small"></el-input>
         </div>
         <div class="juris_list" :style="{ marginBottom: marginB }">
           <p>许可编辑行</p>
-          <el-input v-model="form.input5" placeholder="请输入内容" size="small"></el-input>
+          <el-input v-model="form.edit_row_condition" placeholder="请输入内容" size="small"></el-input>
         </div>
         <div class="juris_list" :style="{ marginBottom: marginB }">
           <p>许可编辑列</p>
-          <el-input v-model="form.input6" placeholder="请输入内容" size="small"></el-input>
+          <el-input v-model="form.edit_col_condition" placeholder="请输入内容" size="small"></el-input>
         </div>
       </div>
     </div>
@@ -69,34 +69,13 @@ export default {
   },
   data () {
     return {
-      pickerOptionsStart: {
-        disabledDate: (time) => {
-          if (this.form.endWeeks) {
-            return time.getTime() >= new Date(this.endWeeks).getTime();
-          }
-        },
-      },
-      pickerOptionsEnd: {
-        disabledDate: (time) => {
-          if (this.form.firstWeeks) {
-            return (
-              time.getTime() <= new Date(this.firstWeeks).getTime() - 86400000
-            );
-          }
-        },
-      },
       form: {
-        // endWeeks: "",
-        // firstWeeks: "",
-        // radio: 1,
-        value1: "",
-        value2: "",
-        input1: "",
-        input2: "",
-        input3: "",
-        input4: "",
-        input5: "",
-        input6: "",
+        query_row_condition: "",
+        query_col_conditon: "",
+        delete_row_condition: "",
+        new_col_condition: "",
+        edit_row_condition: "",
+        edit_col_condition: ""
       },
       option: [
         {
@@ -113,26 +92,8 @@ export default {
   watch: {
     authTo: {
       handler (obj) {
-        const {
-          // Action,
-          // ValidBegin,
-          // ValidEnd,
-          QueryRow,
-          QueryCol,
-          NewCol,
-          EditCol,
-          EditRow,
-          DeleteRow,
-        } = obj;
-        // this.form.radio = Number(Action);
-        // this.form.firstWeeks = ValidBegin;
-        // this.form.endWeeks = ValidEnd;
-        this.form.input1 = QueryRow;
-        this.form.input2 = QueryCol;
-        this.form.input3 = DeleteRow;
-        this.form.input4 = NewCol;
-        this.form.input5 = EditRow;
-        this.form.input6 = EditCol;
+        this.form = _.cloneDeep(obj)
+        this.$store.dispatch("auth/changeAuthId", obj.auth_id)
       },
       deep: true,
     },
@@ -145,6 +106,8 @@ export default {
     authList: {
       handler (arr) {
         this.$store.dispatch("auth/changeAuthList", arr);
+        this.$store.dispatch("auth/changeAuthMsg", arr);
+        this.$store.dispatch("auth/changeAuthArrs", arr);
       },
       deep: true,
     },
@@ -153,41 +116,14 @@ export default {
         const id = this.$store.getters.authId;
         const obj = arr.filter((item) => item.auth_id === id)[0];
         this.clearFormData();
-        this.setFormData(obj);
+        this.setFormData(_.cloneDeep(obj));
       },
       deep: true,
-    },
-    // "$store.state.auth.authStatus": {
-    //   handler (arr) {
-    //     if (arr && arr.length) {
-    //       const datas = this.$store.getters.authList;
-    //       const res = datas.filter(item => !arr.some(p => item.authId == p.auth_id))
-    //       this.$store.dispatch('auth/changeAuthList', res)
-    //       this.clearFormData()
-    //     }
-    //   },
-    //   deep: true,
-    // },
+    }
   },
   methods: {
-    setTime () {
-      if (this.form.endWeeks <= this.form.firstWeeks) {
-        this.form.endWeeks = "";
-        this.$message.error("结束时间不能小于开始时间,请重新选择");
-      }
-    },
     getData () {
-      const obj = {
-        // Action: this.form.radio,
-        // ValidBegin: this.form.firstWeeks,
-        // ValidEnd: this.form.endWeeks,
-        QueryRow: this.form.input1,
-        QueryCol: this.form.input2,
-        NewCol: this.form.input4,
-        EditCol: this.form.input6,
-        EditRow: this.form.input5,
-        DeleteRow: this.form.input3,
-      };
+      const obj = _.cloneDeep(this.form);
       this.$emit("getData", obj);
       const arr = this.$store.getters.authArrs;
       const datas = _.unionBy(arr, "auth_id");
@@ -212,15 +148,12 @@ export default {
       }
     },
     clearFormData () {
-      // this.form.radio = "";
-      // this.form.firstWeeks = "";
-      // this.form.endWeeks = "";
-      this.form.input1 = "";
-      this.form.input2 = "";
-      this.form.input3 = "";
-      this.form.input4 = "";
-      this.form.input5 = "";
-      this.form.input6 = "";
+      this.form.query_row_condition = "";
+      this.form.query_col_conditon = "";
+      this.form.delete_row_condition = "";
+      this.form.new_col_condition = "";
+      this.form.edit_row_condition = "";
+      this.form.edit_col_condition = "";
     },
     setFormData (obj) {
       let data = {};
@@ -229,26 +162,7 @@ export default {
       } else {
         data = obj;
       }
-      const {
-        // Action = "",
-        // ValidBegin = "",
-        // ValidEnd = "",
-        QueryRow = "",
-        QueryCol = "",
-        NewCol = "",
-        EditCol = "",
-        EditRow = "",
-        DeleteRow = "",
-      } = data;
-      // this.form.radio = Number(Action);
-      // this.form.firstWeeks = ValidBegin;
-      // this.form.endWeeks = ValidEnd;
-      this.form.input1 = QueryRow;
-      this.form.input2 = QueryCol;
-      this.form.input3 = DeleteRow;
-      this.form.input4 = NewCol;
-      this.form.input5 = EditRow;
-      this.form.input6 = EditCol;
+      this.form = _.cloneDeep(data);
     },
   },
 };

+ 2 - 2
src/views/authorityManagement/components/authorityRoleHome.vue

@@ -197,7 +197,7 @@ export default {
       this.editType = "edit";
       this.editDialogTitle = "编辑角色";
       this.roleId = item.role_id;
-      this.ruleForm = JSON.parse(JSON.stringify(item));
+      this.ruleForm = _.cloneDeep(item);
     },
     pageInit () {
       this.needPage = 1
@@ -264,7 +264,7 @@ export default {
     },
     // 重置
     resetForm (formName) {
-      this.ruleForm = [];
+      this.ruleForm = {};
       this.$refs[formName].resetFields();
       this.editDialogVisible = false;
     },