From 1de2b7a57e13928f0c963d308cea65d10149c1a9 Mon Sep 17 00:00:00 2001 From: lihy2021 <lihy2021@hotmail.com> Date: 星期四, 27 十月 2022 09:25:39 +0800 Subject: [PATCH] 优化代码 --- ruoyi-ui/src/views/system/user/index.vue | 18 ++++++++---------- 1 files changed, 8 insertions(+), 10 deletions(-) diff --git a/ruoyi-ui/src/views/system/user/index.vue b/ruoyi-ui/src/views/system/user/index.vue index 29aca77..2494fa2 100644 --- a/ruoyi-ui/src/views/system/user/index.vue +++ b/ruoyi-ui/src/views/system/user/index.vue @@ -21,13 +21,14 @@ :filter-node-method="filterNode" ref="tree" default-expand-all + highlight-current @node-click="handleNodeClick" /> </div> </el-col> <!--用户数据--> <el-col :span="20" :xs="24"> - <el-form :model="queryParams" ref="queryForm" size="small" inline="true" v-show="showSearch" label-width="68px"> + <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px"> <el-form-item label="用户名称" prop="userName"> <el-input v-model="queryParams.userName" @@ -341,9 +342,8 @@ </template> <script> -import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus } from "@/api/system/user"; +import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, deptTreeSelect } from "@/api/system/user"; import { getToken } from "@/utils/auth"; -import { treeselect } from "@/api/system/dept"; import Treeselect from "@riophae/vue-treeselect"; import "@riophae/vue-treeselect/dist/vue-treeselect.css"; @@ -461,7 +461,7 @@ }, created() { this.getList(); - this.getTreeselect(); + this.getDeptTree(); this.getConfigKey("sys.user.initPassword").then(response => { this.initPassword = response.msg; }); @@ -478,8 +478,8 @@ ); }, /** 查询部门下拉树结构 */ - getTreeselect() { - treeselect().then(response => { + getDeptTree() { + deptTreeSelect().then(response => { this.deptOptions = response.data; }); }, @@ -560,7 +560,6 @@ /** 新增按钮操作 */ handleAdd() { this.reset(); - this.getTreeselect(); getUser().then(response => { this.postOptions = response.posts; this.roleOptions = response.roles; @@ -572,14 +571,13 @@ /** 修改按钮操作 */ handleUpdate(row) { this.reset(); - this.getTreeselect(); const userId = row.userId || this.ids; getUser(userId).then(response => { this.form = response.data; this.postOptions = response.posts; this.roleOptions = response.roles; - this.form.postIds = response.postIds; - this.form.roleIds = response.roleIds; + this.$set(this.form, "postIds", response.postIds); + this.$set(this.form, "roleIds", response.roleIds); this.open = true; this.title = "修改用户"; this.form.password = ""; -- Gitblit v1.9.2