guhongwei пре 3 година
родитељ
комит
632b433177

+ 65 - 8
java代码/ruoyi-ui/src/views/merits/account/index.vue

@@ -133,7 +133,16 @@
       custom-class="dialog"
     >
       <div class="info">
-        <form-1 :form="form" @onSubmit="onSubmit" @resetForm="toClose"></form-1>
+        <form-1
+          :form="form"
+          :deptOptions="deptOptions"
+          :sexOptions="sexOptions"
+          :statusOptions="statusOptions"
+          :postOptions="postOptions"
+          :roleOptions="roleOptions"
+          @onSubmit="onSubmit"
+          @resetForm="toClose"
+        ></form-1>
       </div>
     </el-dialog>
   </div>
@@ -146,18 +155,19 @@ import {
   delUser,
   addUser,
   updateUser,
-  exportUser,
   resetUserPwd,
-  changeUserStatus,
-  importTemplate,
 } from "@/api/system/user";
 import form1 from "./parts/form-1.vue";
+import { treeselect } from "@/api/system/dept";
+import Treeselect from "@riophae/vue-treeselect";
+import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 import { mapState, mapGetters, createNamespacedHelpers } from "vuex";
 const { mapActions: merits_user } = createNamespacedHelpers("merits_user");
+const { mapActions: role_relation } = createNamespacedHelpers("role_relation");
 export default {
   name: "index",
   props: {},
-  components: { form1 },
+  components: { form1, Treeselect },
   data: function () {
     return {
       // 显示搜索条件
@@ -172,12 +182,23 @@ export default {
       form: { status: "0" },
       // 默认密码
       initPassword: undefined,
+      // 归属部门
+      deptOptions: undefined,
+      // 性别状态字典
+      sexOptions: [],
+      // 状态数据字典
+      statusOptions: [],
+      // 岗位选项
+      postOptions: [],
+      // 角色选项
+      roleOptions: [],
       // 分页
       currentPage: 1,
       limit: 10,
     };
   },
   created() {
+    this.searchOther();
     this.getList();
     this.getConfigKey("sys.user.initPassword").then((response) => {
       this.initPassword = response.msg;
@@ -185,6 +206,7 @@ export default {
   },
   methods: {
     ...merits_user(["query", "create", "delete"]),
+    ...role_relation({ roleQuery: "query" }),
     async getList({ skip = 0, limit = this.limit, ...info } = {}) {
       info.superior_id = this.user_id;
       let res = await this.query({ skip, limit, ...info });
@@ -195,8 +217,14 @@ export default {
     },
     // 修改信息
     toEdit(row) {
-      this.$set(this, `form`, row);
-      this.dialog = { title: "修改信息", show: true };
+      const userId = row.userId;
+      getUser(userId).then((response) => {
+        this.form = response.data;
+        this.postOptions = response.posts;
+        this.form.postIds = response.postIds;
+        this.form.roleIds = response.roleIds;
+        this.dialog = { title: "修改信息", show: true };
+      });
     },
     // 删除信息
     async toDel(row) {
@@ -277,6 +305,35 @@ export default {
         });
       }
     },
+    // 其他信息
+    async searchOther() {
+      treeselect().then((response) => {
+        this.deptOptions = response.data;
+      });
+      this.getDicts("sys_user_sex").then((response) => {
+        this.sexOptions = response.data;
+      });
+      this.getDicts("sys_normal_disable").then((response) => {
+        this.statusOptions = response.data;
+      });
+      getUser().then(async (response) => {
+        this.postOptions = response.posts;
+        let res = await this.roleQuery();
+        if (this.$checkRes(res)) {
+          let levelInfo = res.data.relation.find(
+            (i) => i.roleKey == this.roles[0]
+          );
+          if (levelInfo) {
+            let nextLevel = parseInt(levelInfo.level) + 1;
+            let p1 = res.data.relation.filter((i) => i.level == nextLevel)[0];
+            let roleList = response.roles.filter(
+              (i) => i.roleKey == p1.roleKey
+            );
+            if (roleList) this.roleOptions = roleList;
+          }
+        }
+      });
+    },
     // 关闭
     toClose() {
       this.form = { status: "0" };
@@ -293,7 +350,7 @@ export default {
   },
 
   computed: {
-    ...mapGetters(["user_id"]),
+    ...mapGetters(["user_id", "roles"]),
   },
   metaInfo() {
     return { title: this.$route.meta.title };

+ 11 - 43
java代码/ruoyi-ui/src/views/merits/account/parts/form-1.vue

@@ -132,11 +132,20 @@ import { getUser } from "@/api/system/user";
 import { treeselect } from "@/api/system/dept";
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
-const { mapActions: role_relation } = createNamespacedHelpers("role_relation");
 export default {
   name: "form-1",
   props: {
     form: { type: Object },
+    // 归属部门
+    deptOptions: { type: Array },
+    // 性别状态字典
+    sexOptions: { type: Array },
+    // 状态数据字典
+    statusOptions: { type: Array },
+    // 岗位选项
+    postOptions: { type: Array },
+    // 角色选项
+    roleOptions: { type: Array },
   },
   components: { Treeselect },
   data: function () {
@@ -166,51 +175,10 @@ export default {
           },
         ],
       },
-      // 归属部门
-      deptOptions: undefined,
-      // 性别状态字典
-      sexOptions: [],
-      // 状态数据字典
-      statusOptions: [],
-      // 岗位选项
-      postOptions: [],
-      // 角色选项
-      roleOptions: [],
     };
   },
-  created() {
-    this.searchOther();
-  },
+  created() {},
   methods: {
-    ...role_relation(["query"]),
-    async searchOther() {
-      treeselect().then((response) => {
-        this.deptOptions = response.data;
-      });
-      this.getDicts("sys_user_sex").then((response) => {
-        this.sexOptions = response.data;
-      });
-      this.getDicts("sys_normal_disable").then((response) => {
-        this.statusOptions = response.data;
-      });
-      getUser().then(async (response) => {
-        this.postOptions = response.posts;
-        let res = await this.query();
-        if (this.$checkRes(res)) {
-          let levelInfo = res.data.relation.find(
-            (i) => i.roleKey == this.roles[0]
-          );
-          if (levelInfo) {
-            let nextLevel = parseInt(levelInfo.level) + 1;
-            let p1 = res.data.relation.filter((i) => i.level == nextLevel)[0];
-            let roleList = response.roles.filter(
-              (i) => i.roleKey == p1.roleKey
-            );
-            if (roleList) this.roleOptions = roleList;
-          }
-        }
-      });
-    },
     onSubmit(formName) {
       this.$refs[formName].validate((valid) => {
         if (valid) {