|
@@ -294,6 +294,21 @@
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-col>
|
|
</el-col>
|
|
</el-row>
|
|
</el-row>
|
|
|
|
+ <el-form-item label="菜单权限">
|
|
|
|
+ <el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event, 'menu')">展开/折叠</el-checkbox>
|
|
|
|
+ <el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">全选/全不选</el-checkbox>
|
|
|
|
+ <el-checkbox v-model="form.menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')">父子联动</el-checkbox>
|
|
|
|
+ <el-tree
|
|
|
|
+ class="tree-border"
|
|
|
|
+ :data="menuOptions"
|
|
|
|
+ show-checkbox
|
|
|
|
+ ref="menu"
|
|
|
|
+ node-key="id"
|
|
|
|
+ :check-strictly="!form.menuCheckStrictly"
|
|
|
|
+ empty-text="加载中,请稍候"
|
|
|
|
+ :props="defaultProps"
|
|
|
|
+ ></el-tree>
|
|
|
|
+ </el-form-item>
|
|
<el-row>
|
|
<el-row>
|
|
<el-col :span="24">
|
|
<el-col :span="24">
|
|
<el-form-item label="备注">
|
|
<el-form-item label="备注">
|
|
@@ -342,6 +357,7 @@
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, deptTreeSelect } from "@/api/system/user";
|
|
import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, deptTreeSelect } from "@/api/system/user";
|
|
|
|
+import { treeselect as menuTreeselect, roleMenuTreeselect,roleUserMenuTreeselect } from "@/api/system/menu";
|
|
import { getToken } from "@/utils/auth";
|
|
import { getToken } from "@/utils/auth";
|
|
import Treeselect from "@riophae/vue-treeselect";
|
|
import Treeselect from "@riophae/vue-treeselect";
|
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
|
@@ -376,6 +392,11 @@ export default {
|
|
deptName: undefined,
|
|
deptName: undefined,
|
|
// 默认密码
|
|
// 默认密码
|
|
initPassword: undefined,
|
|
initPassword: undefined,
|
|
|
|
+ // 菜单列表
|
|
|
|
+ menuOptions: [],
|
|
|
|
+ // 是否显示弹出层(数据权限)
|
|
|
|
+ menuExpand: false,
|
|
|
|
+ menuNodeAll: false,
|
|
// 日期范围
|
|
// 日期范围
|
|
dateRange: [],
|
|
dateRange: [],
|
|
// 岗位选项
|
|
// 岗位选项
|
|
@@ -510,6 +531,11 @@ export default {
|
|
},
|
|
},
|
|
// 表单重置
|
|
// 表单重置
|
|
reset() {
|
|
reset() {
|
|
|
|
+ if (this.$refs.menu != undefined) {
|
|
|
|
+ this.$refs.menu.setCheckedKeys([]);
|
|
|
|
+ }
|
|
|
|
+ this.menuExpand = false,
|
|
|
|
+ this.menuNodeAll = false,
|
|
this.form = {
|
|
this.form = {
|
|
userId: undefined,
|
|
userId: undefined,
|
|
deptId: undefined,
|
|
deptId: undefined,
|
|
@@ -522,7 +548,10 @@ export default {
|
|
status: "0",
|
|
status: "0",
|
|
remark: undefined,
|
|
remark: undefined,
|
|
postIds: [],
|
|
postIds: [],
|
|
- roleIds: []
|
|
|
|
|
|
+ roleIds: [],
|
|
|
|
+ menuIds: [],
|
|
|
|
+ menuCheckStrictly: true,
|
|
|
|
+ deptCheckStrictly: true,
|
|
};
|
|
};
|
|
this.resetForm("form");
|
|
this.resetForm("form");
|
|
},
|
|
},
|
|
@@ -561,6 +590,7 @@ export default {
|
|
/** 新增按钮操作 */
|
|
/** 新增按钮操作 */
|
|
handleAdd() {
|
|
handleAdd() {
|
|
this.reset();
|
|
this.reset();
|
|
|
|
+ this.getMenuTreeselect();
|
|
getUser().then(response => {
|
|
getUser().then(response => {
|
|
this.postOptions = response.posts;
|
|
this.postOptions = response.posts;
|
|
this.roleOptions = response.roles;
|
|
this.roleOptions = response.roles;
|
|
@@ -569,10 +599,33 @@ export default {
|
|
this.form.password = this.initPassword;
|
|
this.form.password = this.initPassword;
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ /** 查询菜单树结构 */
|
|
|
|
+ getMenuTreeselect() {
|
|
|
|
+ menuTreeselect().then(response => {
|
|
|
|
+ this.menuOptions = response.data;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ // 所有菜单节点数据
|
|
|
|
+ getMenuAllCheckedKeys() {
|
|
|
|
+ // 目前被选中的菜单节点
|
|
|
|
+ let checkedKeys = this.$refs.menu.getCheckedKeys();
|
|
|
|
+ // 半选中的菜单节点
|
|
|
|
+ let halfCheckedKeys = this.$refs.menu.getHalfCheckedKeys();
|
|
|
|
+ checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
|
|
|
|
+ return checkedKeys;
|
|
|
|
+ },
|
|
|
|
+ /** 根据用户ID查询菜单树结构 */
|
|
|
|
+ getRoleUserMenuTreeselect(userId) {
|
|
|
|
+ return roleUserMenuTreeselect(userId).then(response => {
|
|
|
|
+ this.menuOptions = response.menus;
|
|
|
|
+ return response;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
/** 修改按钮操作 */
|
|
/** 修改按钮操作 */
|
|
handleUpdate(row) {
|
|
handleUpdate(row) {
|
|
this.reset();
|
|
this.reset();
|
|
const userId = row.userId || this.ids;
|
|
const userId = row.userId || this.ids;
|
|
|
|
+ const userMenu = this.getRoleUserMenuTreeselect(userId);
|
|
getUser(userId).then(response => {
|
|
getUser(userId).then(response => {
|
|
this.form = response.data;
|
|
this.form = response.data;
|
|
this.postOptions = response.posts;
|
|
this.postOptions = response.posts;
|
|
@@ -580,6 +633,16 @@ export default {
|
|
this.$set(this.form, "postIds", response.postIds);
|
|
this.$set(this.form, "postIds", response.postIds);
|
|
this.$set(this.form, "roleIds", response.roleIds);
|
|
this.$set(this.form, "roleIds", response.roleIds);
|
|
this.open = true;
|
|
this.open = true;
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ userMenu.then(res => {
|
|
|
|
+ let checkedKeys = res.checkedKeys
|
|
|
|
+ checkedKeys.forEach((v) => {
|
|
|
|
+ this.$nextTick(()=>{
|
|
|
|
+ this.$refs.menu.setChecked(v, true ,false);
|
|
|
|
+ })
|
|
|
|
+ })
|
|
|
|
+ });
|
|
|
|
+ });
|
|
this.title = "修改用户";
|
|
this.title = "修改用户";
|
|
this.form.password = "";
|
|
this.form.password = "";
|
|
});
|
|
});
|
|
@@ -608,12 +671,14 @@ export default {
|
|
this.$refs["form"].validate(valid => {
|
|
this.$refs["form"].validate(valid => {
|
|
if (valid) {
|
|
if (valid) {
|
|
if (this.form.userId != undefined) {
|
|
if (this.form.userId != undefined) {
|
|
|
|
+ this.form.menuIds = this.getMenuAllCheckedKeys();
|
|
updateUser(this.form).then(response => {
|
|
updateUser(this.form).then(response => {
|
|
this.$modal.msgSuccess("修改成功");
|
|
this.$modal.msgSuccess("修改成功");
|
|
this.open = false;
|
|
this.open = false;
|
|
this.getList();
|
|
this.getList();
|
|
});
|
|
});
|
|
} else {
|
|
} else {
|
|
|
|
+ this.form.menuIds = this.getMenuAllCheckedKeys();
|
|
addUser(this.form).then(response => {
|
|
addUser(this.form).then(response => {
|
|
this.$modal.msgSuccess("新增成功");
|
|
this.$modal.msgSuccess("新增成功");
|
|
this.open = false;
|
|
this.open = false;
|
|
@@ -623,6 +688,36 @@ export default {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
+ // 树权限(展开/折叠)
|
|
|
|
+ handleCheckedTreeExpand(value, type) {
|
|
|
|
+ if (type == 'menu') {
|
|
|
|
+ let treeList = this.menuOptions;
|
|
|
|
+ for (let i = 0; i < treeList.length; i++) {
|
|
|
|
+ this.$refs.menu.store.nodesMap[treeList[i].id].expanded = value;
|
|
|
|
+ }
|
|
|
|
+ } else if (type == 'dept') {
|
|
|
|
+ let treeList = this.deptOptions;
|
|
|
|
+ for (let i = 0; i < treeList.length; i++) {
|
|
|
|
+ this.$refs.dept.store.nodesMap[treeList[i].id].expanded = value;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 树权限(全选/全不选)
|
|
|
|
+ handleCheckedTreeNodeAll(value, type) {
|
|
|
|
+ if (type == 'menu') {
|
|
|
|
+ this.$refs.menu.setCheckedNodes(value ? this.menuOptions: []);
|
|
|
|
+ } else if (type == 'dept') {
|
|
|
|
+ this.$refs.dept.setCheckedNodes(value ? this.deptOptions: []);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 树权限(父子联动)
|
|
|
|
+ handleCheckedTreeConnect(value, type) {
|
|
|
|
+ if (type == 'menu') {
|
|
|
|
+ this.form.menuCheckStrictly = value ? true: false;
|
|
|
|
+ } else if (type == 'dept') {
|
|
|
|
+ this.form.deptCheckStrictly = value ? true: false;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
/** 删除按钮操作 */
|
|
/** 删除按钮操作 */
|
|
handleDelete(row) {
|
|
handleDelete(row) {
|
|
const userIds = row.userId || this.ids;
|
|
const userIds = row.userId || this.ids;
|