Parcourir la source

fix: 用户信息编辑时,角色,组织,岗位显示状态为0的数据,禁止选择

yanglzh il y a 1 an
Parent
commit
a02cbbf463

+ 10 - 3
src/views/system/manage/user/component/editUser.vue

@@ -20,7 +20,9 @@
 					</el-col>
 					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
 						<el-form-item label="关联角色" prop="roleIds">
-							<el-cascader :options="roleData" :props="{ checkStrictly: true, multiple: true, emitPath: false, value: 'id', label: 'name' }" placeholder="请选择角色" clearable class="w100" v-model="ruleForm.roleIds">
+							<el-cascader :options="roleData" :props="{
+								checkStrictly: true, multiple: true, emitPath: false, value: 'id', label: 'name', disabled: disabledFn
+							}" placeholder="请选择角色" clearable class="w100" v-model="ruleForm.roleIds">
 								<template #default="{ node, data }">
 									<span>{{ data.name }}</span>
 									<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
@@ -30,7 +32,7 @@
 					</el-col>
 					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
 						<el-form-item label="组织" prop="deptId">
-							<el-cascader :options="deptData" :props="{ checkStrictly: true, emitPath: false, value: 'deptId', label: 'deptName' }" placeholder="请选择组织" clearable class="w100" v-model="ruleForm.deptId">
+							<el-cascader :options="deptData" :props="{ checkStrictly: true, emitPath: false, value: 'deptId', label: 'deptName', disabled: disabledFn }" placeholder="请选择组织" clearable class="w100" v-model="ruleForm.deptId">
 								<template #default="{ node, data }">
 									<span>{{ data.deptName }}</span>
 									<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
@@ -59,7 +61,7 @@
 					</el-col>
 					<el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12">
 						<el-form-item label="岗位" prop="postIds">
-							<el-cascader :options="postData" :props="{ checkStrictly: true, multiple: true, emitPath: false, value: 'postId', label: 'postName' }" placeholder="请选择岗位" clearable class="w100" v-model="ruleForm.postIds">
+							<el-cascader :options="postData" :props="{ checkStrictly: true, multiple: true, emitPath: false, value: 'postId', label: 'postName', disabled: disabledFn }" placeholder="请选择岗位" clearable class="w100" v-model="ruleForm.postIds">
 								<template #default="{ node, data }">
 									<span>{{ data.postName }}</span>
 									<span v-if="!node.isLeaf"> ({{ data.children.length }}) </span>
@@ -159,6 +161,11 @@ export default defineComponent({
 			default: () => [],
 		},
 	},
+	methods: {
+		disabledFn(row: any) {
+			return row.status === 0
+		}
+	},
 	setup(prop, { emit }) {
 		const postList = ref([]);
 		const formRef = ref<HTMLElement | null>(null);

+ 3 - 5
src/views/system/manage/user/index.vue

@@ -93,7 +93,6 @@ import { ElMessageBox, ElMessage, ElTree, FormInstance } from 'element-plus';
 import { Search } from '@element-plus/icons-vue';
 import EditUser from './component/editUser.vue';
 import api from '/@/api/system';
-import useCommon from '/@/hooks/useCommon';
 import { encrypt } from '/@/utils/rsa'
 
 interface Tree {
@@ -135,7 +134,6 @@ export default defineComponent({
 		const filterText = ref('');
 		const treeRef = ref<InstanceType<typeof ElTree>>();
 		const search = Search;
-		const { statusParams } = useCommon();
 		const state = reactive<TableDataState>({
 			loading: false,
 			ids: [],
@@ -165,13 +163,13 @@ export default defineComponent({
 		});
 		// 初始化表格数据
 		const initTableData = () => {
-			api.dept.getList(statusParams).then((res: any) => {
+			api.dept.getList({ status: -1 }).then((res: any) => {
 				state.deptData = res;
 			});
-			api.post.getList(statusParams).then((res: any) => {
+			api.post.getList({ status: -1 }).then((res: any) => {
 				state.postData = res;
 			});
-			api.role.getList(statusParams).then((res: any) => {
+			api.role.getList({ status: -1 }).then((res: any) => {
 				state.roleData = res;
 			});
 			userList();