scorpio 2 tahun lalu
induk
melakukan
ec21b1b672
2 mengubah file dengan 62 tambahan dan 33 penghapusan
  1. 40 16
      src/api/role/index.js
  2. 22 17
      src/views/user/manage.vue

+ 40 - 16
src/api/role/index.js

@@ -1,20 +1,44 @@
 import fetch from '../fetch.js'
 
 export default {
-    /**
-     * 用户管理相关借口
-     * @returns {Promise<unknown>}
-     */
-    roleList(params) { // 用户列表
-        return fetch('/blade-user/noRolePage', params, 'get')
-    },
-    roleStart(params) { // 用户启用/停用
-        return fetch('/blade-user/startOrStop', params, 'post')
-    },
-    jobList(params) { // 用户列表
-        return fetch('/blade-system/role/newList', params, 'get')
-    },
-    roleSave(params) { // 保存用户设置信息
-        return fetch('/blade-project-manage-v2/roledept/v2/save', params, 'post', 'json')
-    },
+  /**
+   * 用户管理相关借口
+   * @returns {Promise<unknown>}
+   */
+  roleList(params) {
+    // 用户列表
+    return fetch('/blade-user/noRolePage', params, 'get')
+  },
+  roleStart(params) {
+    // 用户启用/停用
+    return fetch('/blade-user/startOrStop', params, 'post')
+  },
+  jobList(params) {
+    // 用户列表
+    return fetch('/blade-system/role/newList', params, 'get')
+  },
+  roleSave(params) {
+    // 保存用户设置信息
+    return fetch(
+      '/blade-project-manage-v2/roledept/v2/save',
+      params,
+      'post',
+      'json'
+    )
+  },
+  /**
+   * 获取用户机构
+   * @param parmas
+   * @returns {Promise | Promise<unknown>}
+   */
+  deptList() {
+    return fetch('/blade-project-manage-v2/other/v2/addUserDeptList')
+  },
+  /**
+   * 管理股室
+   * @returns {Promise | Promise<unknown>}
+   */
+  managerList(params) {
+    return fetch('blade-project-manage-v2/roledept/v2/list', params)
+  }
 }

+ 22 - 17
src/views/user/manage.vue

@@ -115,7 +115,7 @@
           </div>
           <div class="flex flex-col" style="margin-top: -10px">
             <div class="flex flex-align-center">
-              <span class="bold ml-20">权限选择</span>
+              <span class="bold ml-20">管理股室</span>
               <el-checkbox
                 size="large"
                 style="margin-left: 33px"
@@ -162,7 +162,7 @@
 <route>
 {
 name: '用户管理',
-meta: { keepAlive: true }
+meta: { 'back':true}
 }
 </route>
 
@@ -273,8 +273,8 @@ export default {
     }
   },
   created() {
-    this.getJobList()
     this.getOrg()
+    this.getJobList()
   },
   methods: {
     onLoad() {
@@ -326,26 +326,27 @@ export default {
         this.userInfoForm.realName = this.form.realName
         this.userInfoForm.phone = this.form.phone
         this.userInfoForm.password = this.form.password
+        this.userInfoForm.deptId = this.form.deptId
         this.jobs.find(e => {
           const temp = this.form.roleId.split(',').find(sub => sub === e.id)
           if (temp) {
             this.userInfoForm.roleIds = temp
           }
+          return temp
         })
-        this.deptList.find(e => {
-          const dp = this.form.deptId.split(',').find(sub => sub === e.id)
-          if (dp) {
-            this.userInfoForm.deptId = dp
-          }
-        })
-        this.form.deptId.split(',').forEach(ele => {
-          const tmp = this.deptList.findIndex(sub => sub.id === ele)
-          console.log(tmp)
-          if (tmp > -1) {
-            this.deptList[tmp].checked = true
+        this.$api.role.managerList({ userId: this.form.id }).then(res => {
+          if (res.code === 200) {
+            res.data.forEach(ele => {
+              const tmp = this.deptList.findIndex(sub => sub.id === ele.deptId)
+              if (tmp > -1) {
+                this.deptList[tmp].checked = true
+              }
+              this.userInfoForm.deptIds = this.deptList.map(e => e.id)
+            })
+            this.showEdit = true
           }
-          console.log(this.deptList)
         })
+      } else if (type === 'add') {
         this.showEdit = true
       } else {
         done()
@@ -365,7 +366,7 @@ export default {
       })
     },
     getOrg() {
-      this.$api.common.deptList().then(res => {
+      this.$api.role.deptList().then(res => {
         if (res.code === 200) {
           this.showOrg = true
           this.deptList = res.data.map(e => {
@@ -393,7 +394,9 @@ export default {
       const tmp = this.deptList.find(ele => ele.id === item.id)
       if (tmp) {
         if (tmp.checked) {
-          this.userInfoForm.deptIds.push(tmp.id)
+          if (this.userInfoForm.deptIds.findIndex(e => e === tmp.id) === -1) {
+            this.userInfoForm.deptIds.push(tmp.id)
+          }
         } else {
           this.userInfoForm.deptIds = this.userInfoForm.deptIds.filter(
             ele => ele !== tmp.id
@@ -415,6 +418,8 @@ export default {
           this.showEdit = false
           this.$message.success(res.msg)
           this.onLoad()
+        } else {
+          this.$message.error(res.msg)
         }
       })
     }