From 0cd1631ceaa93e6483908fd692d2cb693b85324b Mon Sep 17 00:00:00 2001
From: 石广澎 <shiguangpeng@163.com>
Date: 星期二, 02 一月 2024 14:26:01 +0800
Subject: [PATCH] 增加图片验证码和登录日志 权限管理优化

---
 admin-web/src/views/systemManger/server/user/editRole.vue |  180 ++++++++++++++++++++++++++++-------------------------------
 1 files changed, 85 insertions(+), 95 deletions(-)

diff --git a/admin-web/src/views/systemManger/server/user/editRole.vue b/admin-web/src/views/systemManger/server/user/editRole.vue
index c20acc0..197aac9 100644
--- a/admin-web/src/views/systemManger/server/user/editRole.vue
+++ b/admin-web/src/views/systemManger/server/user/editRole.vue
@@ -1,17 +1,17 @@
 <template>
-  <win :title="setting.title" @close="close" :width="'800px'">
-    <el-form  :model="formData"  class="demo-ruleForm" label-width="100px">
-      <el-form-item label="瑙掕壊閰嶇疆"  prop="roleSetting">
+  <win :title="setting.title" @close="close" :width="'800px'" :loading="loading">
+    <el-form :model="formData" class="demo-ruleForm" label-width="100px">
+      <el-form-item label="瑙掕壊閰嶇疆" prop="roleSetting">
         <el-checkbox v-model="checkAll" @change="handleCheckAllChange">鍏ㄩ��</el-checkbox>
         <div style="margin: 15px 0;"></div>
-        <el-checkbox-group v-model="checkedList" @change="handleCheckedCitiesChange" >
-          <el-checkbox v-for="(r,i) in roleOptions" :label="r.role_id" :key="r.role_id">{{r.role_name}}</el-checkbox>
+        <el-checkbox-group v-model="checkedList" @change="handleCheckedCitiesChange">
+          <el-checkbox v-for="(r,i) in roleOptions" :label="r.role_id" :key="r.role_id">{{ r.role_name }}</el-checkbox>
         </el-checkbox-group>
       </el-form-item>
     </el-form>
     <div slot="footer" align="center" class="dialog-footer">
-      <my-button name="鍙栨秷" site="form" @click="close" />
-      <my-button name="淇濆瓨" site="form" @click="save" />
+      <my-button name="鍙栨秷" site="form" @click="close"/>
+      <my-button name="淇濆瓨" site="form" @click="save"/>
     </div>
   </win>
 </template>
@@ -23,7 +23,7 @@
 import * as user from "@/api/user";
 
 export default {
-  components: { win, myButton },
+  components: {win, myButton},
   props: {
     // setting 涓』鑷冲皯鍖呭惈鎺у埗dialog鏄剧ず鎴栭殣钘忕殑灞炴��,鍏朵綑灞炴�у彲鎷撳睍
     // 灏嗘坊鍔�/淇敼鐨勫ぇ閲忔暟鎹強閫昏緫浠庡垪琛ㄩ〉闈腑鍒嗙鍑烘潵,閬垮厤鍒楄〃椤甸潰浠g爜杩囧,瀹℃煡鍥伴毦
@@ -36,22 +36,23 @@
   },
   data() {
     return {
+      loading: true,
       data_scope: null,
-      checkAll:false,
-      checkedList:[],
-      roleList:[
-        {'id':1,label:'鐜嬫兜1'},
-        {'id':2,label:'鐜嬫兜2'}
+      checkAll: false,
+      checkedList: [],
+      roleList: [
+        {'id': 1, label: '鐜嬫兜1'},
+        {'id': 2, label: '鐜嬫兜2'}
       ],
-        // 鏌ヨ鍙傛暟
-        queryParams: {
-            pageNum: 1,
-            pageSize: 10,
-            roleName: undefined,
-            roleKey: undefined,
-            status: 0,
-            orgId: 1
-        },
+      // 鏌ヨ鍙傛暟
+      queryParams: {
+        pageNum: 1,
+        pageSize: 10,
+        roleName: undefined,
+        roleKey: undefined,
+        status: 0,
+        orgId: 1
+      },
       roleOptions: [],// 閫夋嫨椤�
       roleCheckStrictly: true,
       defaultProps: {
@@ -69,45 +70,36 @@
       }
     }
   },
-  created() {
-    this.getInfo()
-    this.getAllRole()
+  async created() {
+    this.title = this.setting.title
+    if (this.setting.id != null) {
+      await this.getInfo()
+    }
+    await this.getAllRole()
+    this.loading = false
   },
   methods: {
     // 鑾峰彇鎵�鏈夎鑹�
-    getAllRole() {
-      const user = this.$store.getters.userInfo
-      // debugger
-      // if (user == undefined){
-      //   this.data_scope = 1
-      // } else {
-      //   if (user.lv==null|| user.lv== 1) {
-      //     this.data_scope = 1
-      //   }
-      //   if (user.lv && user.lv== 2) {
-      //     this.data_scope = 2
-      //   }
-      //   if (user.lv && user.lv== 3) {
-      //     this.data_scope = 3
-      //   }
-      // }
-      this.data_scope = 1
-      role.listRoleByDataScope({dataScope: this.data_scope}).then(response => {
-            if (response) {
-              this.roleOptions = response;
-            } else {
-              this.roleOptions = [];
-            }
-                this.loading = false;
-            }
-        );
+    async getAllRole() {
+      // const user = this.$store.getters.userInfo
+      // this.data_scope = 1
+      this.data_scope = this.$store.getters.userInfo ? this.$store.getters.userInfo.lv : ''
+      await role.listRoleByDataScope({dataScope: this.setting.data_scope}).then(response => {
+          if (response) {
+            this.roleOptions = response;
+          } else {
+            this.roleOptions = [];
+          }
+          this.loading = false;
+        }
+      );
     },
-    handleCheckAllChange(val){
-      if(val){
-        this.checkedList = this.roleOptions.map(x=>{
+    handleCheckAllChange(val) {
+      if (val) {
+        this.checkedList = this.roleOptions.map(x => {
           return x.role_id
         })
-      }else{
+      } else {
         this.checkedList = []
       }
     },
@@ -115,52 +107,50 @@
       let checkedCount = value.length;
       this.checkAll = checkedCount === this.roleOptions.length;
     },
-    getInfo() {
-      this.title = this.setting.title
-      if ( this.setting.id != null ) {
-        // 鏌ヨ鏁版嵁
-        user.getUser({ id: this.setting.id }).then(res => {
-          const data = res.data
-          this.formData = Object.assign(this.formData, data)
-          this.checkedList = res.list.map(x=>{
-              return x.role_id
-          })
-          if (res.list.length===this.roleOptions.length){
-              this.handleCheckedCitiesChange(res.list)
-          }
+    async getInfo() {
+      // 鏌ヨ鏁版嵁
+      await user.getUser({id: this.setting.id}).then(res => {
+        const data = res.data
+        this.formData = Object.assign(this.formData, data)
+        this.checkedList = res.list.map(x => {
+          return x.role_id
         })
-      }
+        if (res.list.length === this.roleOptions.length) {
+          this.handleCheckedCitiesChange(res.list)
+        }
+      })
     },
     close() {
-        this.formData = {
-          projectName: '',
-          projectSubName: '',
-          projectCode: '',
-          projectContact: '',
-          projectTel: '',
-          projectEmail: '',
-          projectStart: null,
-          projectEnd: null,
-          projectDesc: '',
-          status: 1
-        },
+      this.formData = {
+        userName: '',
+        userCode: '',
+        userPhone: '',
+        sex: 1,
+        status: 1,
+        remark: '',
+        seq: null
+      }
       this.$emit('close')
     },
     save() {
-        const params = Object.assign({}, this.formData)
-        params.roleList=this.checkedList
-        if (params.id) {
-            console.log(params+'params')
-            user.updRole(params).then(res => {
-                if (res) {
-                    this.$message.success('淇濆瓨鎴愬姛锛�')
-                    this.close()
-                    this.$emit('search')
-                } else {
-                    this.$message.error('淇濆瓨澶辫触')
-                }
-            })
-        }
+      const params = Object.assign({}, this.formData)
+      params.roleList = this.checkedList
+      if (params.id) {
+        if (this.loading) return;
+        this.loading = true
+        user.updRole(params).then(res => {
+          this.loading = false
+          if (res) {
+            this.$message.success('淇濆瓨鎴愬姛锛�')
+            this.close()
+            this.$emit('search')
+          } else {
+            this.$message.error('淇濆瓨澶辫触')
+          }
+        }).catch(() => {
+          this.loading = false
+        })
+      }
     }
   }
 }

--
Gitblit v1.9.1