提交
This commit is contained in:
1 parent
3b3d2bb157
commit
94f07a059b
69 files changed
+2787
-643
No files matched your search
@@ -2,7 +2,7 @@
|
||||
<div class="p-2">
|
||||
<div style="display: flex; gap: 16px">
|
||||
<!-- 部门树 -->
|
||||
<div style="width: 300px">
|
||||
<div style="width: 360px">
|
||||
<el-card shadow="hover">
|
||||
<el-input v-model="deptName" placeholder="请输入部门名称" prefix-icon="Search" clearable />
|
||||
<el-tree
|
||||
@@ -10,7 +10,7 @@
|
||||
class="mt-2 dept-tree"
|
||||
node-key="id"
|
||||
:data="deptOptions"
|
||||
:props="{ label: 'label', children: 'children' } as any"
|
||||
:props="{ label: 'label', children: 'children' }"
|
||||
:expand-on-click-node="false"
|
||||
:filter-node-method="filterNode"
|
||||
highlight-current
|
||||
@@ -66,10 +66,14 @@
|
||||
<el-button v-has-permi="['system:user:add']" type="primary" plain icon="Plus" @click="handleAdd()">新增</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button v-has-permi="['system:user:edit']" :disabled="single" icon="Edit" @click="handleUpdate()"> 修改 </el-button>
|
||||
<el-button v-has-permi="['system:user:edit']" :disabled="single || isSelectedStudentUser" icon="Edit" @click="handleUpdate()">
|
||||
修改
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button v-has-permi="['system:user:remove']" :disabled="multiple" icon="Delete" @click="handleDelete()"> 删除 </el-button>
|
||||
<el-button v-has-permi="['system:user:remove']" :disabled="multiple || hasSelectedStudentUser" icon="Delete" @click="handleDelete()">
|
||||
删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-dropdown class="mt-[1px]">
|
||||
@@ -100,7 +104,13 @@
|
||||
<el-table-column v-if="columns[4].visible" key="phonenumber" label="手机号码" align="center" prop="phonenumber" width="120" />
|
||||
<el-table-column v-if="columns[5].visible" key="status" label="状态" align="center">
|
||||
<template #default="scope">
|
||||
<el-switch v-model="scope.row.status" active-value="0" inactive-value="1" @change="handleStatusChange(scope.row)"></el-switch>
|
||||
<el-switch
|
||||
v-model="scope.row.status"
|
||||
active-value="0"
|
||||
inactive-value="1"
|
||||
:disabled="scope.row.accountType === '2'"
|
||||
@change="handleStatusChange(scope.row)"
|
||||
></el-switch>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
@@ -112,10 +122,10 @@
|
||||
|
||||
<el-table-column label="操作" fixed="right" width="280" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip v-if="scope.row.userId !== 1" content="修改" placement="top">
|
||||
<el-tooltip v-if="scope.row.userId !== 1 && scope.row.accountType !== '2'" content="修改" placement="top">
|
||||
<el-button v-hasPermi="['system:user:edit']" link type="primary" icon="Edit" @click="handleUpdate(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip v-if="scope.row.userId !== 1" content="删除" placement="top">
|
||||
<el-tooltip v-if="scope.row.userId !== 1 && scope.row.accountType !== '2'" content="删除" placement="top">
|
||||
<el-button v-hasPermi="['system:user:remove']" link type="primary" icon="Delete" @click="handleDelete(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
|
||||
@@ -126,6 +136,11 @@
|
||||
<el-tooltip v-if="scope.row.userId !== 1" content="分配角色" placement="top">
|
||||
<el-button v-hasPermi="['system:user:edit']" link type="primary" icon="CircleCheck" @click="handleAuthRole(scope.row)"></el-button>
|
||||
</el-tooltip>
|
||||
|
||||
<!-- 学生用户显示提示信息 -->
|
||||
<el-tooltip v-if="scope.row.accountType === '2'" content="学生用户不允许操作" placement="top">
|
||||
<span class="text-gray-400">学生用户</span>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -155,7 +170,7 @@
|
||||
<el-tree-select
|
||||
v-model="form.deptId"
|
||||
:data="enabledDeptOptions"
|
||||
:props="{ value: 'id', label: 'label', children: 'children' } as any"
|
||||
:props="{ value: 'id', label: 'label', children: 'children' }"
|
||||
value-key="id"
|
||||
placeholder="请选择归属部门"
|
||||
check-strictly
|
||||
@@ -316,6 +331,20 @@ const enabledDeptOptions = ref<DeptTreeVO[]>([]);
|
||||
const initPassword = ref<string>('');
|
||||
const postOptions = ref<PostVO[]>([]);
|
||||
const roleOptions = ref<RoleVO[]>([]);
|
||||
|
||||
// 选中的用户相关计算属性
|
||||
const selectedUsers = ref<UserVO[]>([]);
|
||||
|
||||
// 计算属性:是否选中了学生用户
|
||||
const isSelectedStudentUser = computed(() => {
|
||||
return selectedUsers.value.length === 1 && selectedUsers.value[0].accountType === '2';
|
||||
});
|
||||
|
||||
// 计算属性:选中的用户中是否包含学生用户
|
||||
const hasSelectedStudentUser = computed(() => {
|
||||
return selectedUsers.value.some((user) => user.accountType === '2');
|
||||
});
|
||||
|
||||
/*** 用户导入参数 */
|
||||
const upload = reactive<ImportOption>({
|
||||
// 是否显示弹出层(用户导入)
|
||||
@@ -489,6 +518,19 @@ const resetQuery = () => {
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: UserVO) => {
|
||||
const userIds = row?.userId || ids.value;
|
||||
|
||||
// 检查是否是学生用户
|
||||
if (row && row.accountType === '2') {
|
||||
proxy?.$modal.msgError('学生用户不允许删除操作');
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查批量删除时是否包含学生用户
|
||||
if (!row && hasSelectedStudentUser.value) {
|
||||
proxy?.$modal.msgError('选中的用户中包含学生用户,不允许删除操作');
|
||||
return;
|
||||
}
|
||||
|
||||
const [err] = await to(proxy?.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项?') as any);
|
||||
if (!err) {
|
||||
await api.delUser(userIds);
|
||||
@@ -499,6 +541,14 @@ const handleDelete = async (row?: UserVO) => {
|
||||
|
||||
/** 用户状态修改 */
|
||||
const handleStatusChange = async (row: UserVO) => {
|
||||
// 检查是否是学生用户
|
||||
if (row.accountType === '2') {
|
||||
// 恢复原状态
|
||||
row.status = row.status === '0' ? '1' : '0';
|
||||
proxy?.$modal.msgError('学生用户不允许修改状态');
|
||||
return;
|
||||
}
|
||||
|
||||
const text = row.status === '0' ? '启用' : '停用';
|
||||
try {
|
||||
await proxy?.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?');
|
||||
@@ -510,12 +560,24 @@ const handleStatusChange = async (row: UserVO) => {
|
||||
};
|
||||
/** 跳转角色分配 */
|
||||
const handleAuthRole = (row: UserVO) => {
|
||||
// 检查是否是学生用户
|
||||
// if (row.accountType === '2') {
|
||||
// proxy?.$modal.msgError('学生用户不允许分配角色操作');
|
||||
// return;
|
||||
// }
|
||||
|
||||
const userId = row.userId;
|
||||
router.push('/system/user-auth/role/' + userId);
|
||||
};
|
||||
|
||||
/** 重置密码按钮操作 */
|
||||
const handleResetPwd = async (row: UserVO) => {
|
||||
// 检查是否是学生用户
|
||||
// if (row.accountType === '2') {
|
||||
// proxy?.$modal.msgError('学生用户不允许重置密码操作');
|
||||
// return;
|
||||
// }
|
||||
|
||||
const [err, res] = await to(
|
||||
ElMessageBox.prompt('请输入"' + row.userName + '"的新密码', '提示', {
|
||||
confirmButtonText: '确定',
|
||||
@@ -538,6 +600,7 @@ const handleResetPwd = async (row: UserVO) => {
|
||||
|
||||
/** 选择条数 */
|
||||
const handleSelectionChange = (selection: UserVO[]) => {
|
||||
selectedUsers.value = selection;
|
||||
ids.value = selection.map((item) => item.userId);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
@@ -607,6 +670,18 @@ const handleAdd = async () => {
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: UserForm) => {
|
||||
// 检查是否是学生用户
|
||||
if (row && (row as UserVO).accountType === '2') {
|
||||
proxy?.$modal.msgError('学生用户不允许修改操作');
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查选中的用户是否是学生用户
|
||||
if (!row && isSelectedStudentUser.value) {
|
||||
proxy?.$modal.msgError('学生用户不允许修改操作');
|
||||
return;
|
||||
}
|
||||
|
||||
reset();
|
||||
const userId = row?.userId || ids.value[0];
|
||||
const { data } = await api.getUser(userId);
|
||||
@@ -671,24 +746,30 @@ async function handleDeptChange(value: number | string) {
|
||||
height: 600px;
|
||||
overflow-y: auto;
|
||||
overflow-x: auto;
|
||||
width: 270px; /* 固定宽度,超出时显示滚动条 */
|
||||
min-width: 270px;
|
||||
width: 330px; /* 固定宽度,超出时显示滚动条 */
|
||||
min-width: 330px;
|
||||
}
|
||||
|
||||
/* 强制覆盖el-tree的默认样式 */
|
||||
.dept-tree :deep(.el-tree-node) {
|
||||
white-space: nowrap !important;
|
||||
width: max-content !important;
|
||||
min-width: max-content !important;
|
||||
width: 100% !important;
|
||||
min-width: 300px !important;
|
||||
}
|
||||
|
||||
.dept-tree :deep(.el-tree-node__content) {
|
||||
white-space: nowrap !important;
|
||||
min-width: max-content !important;
|
||||
width: max-content !important;
|
||||
width: 100% !important;
|
||||
min-width: 300px !important;
|
||||
overflow: visible !important;
|
||||
text-overflow: unset !important; /* 移除省略号 */
|
||||
max-width: none !important;
|
||||
padding-right: 20px !important; /* 增加右侧内边距,确保hover效果完整显示 */
|
||||
}
|
||||
|
||||
/* 树节点hover效果优化 */
|
||||
.dept-tree :deep(.el-tree-node__content:hover) {
|
||||
background-color: var(--el-tree-node-hover-bg-color, #f5f7fa) !important;
|
||||
}
|
||||
|
||||
.dept-tree :deep(.el-tree-node__label) {
|
||||
@@ -698,7 +779,7 @@ async function handleDeptChange(value: number | string) {
|
||||
max-width: none !important;
|
||||
overflow: visible !important;
|
||||
text-overflow: unset !important; /* 移除省略号效果 */
|
||||
width: max-content !important;
|
||||
width: auto !important;
|
||||
}
|
||||
|
||||
.dept-tree :deep(.el-tree-node__expand-icon) {
|
||||
@@ -707,10 +788,10 @@ async function handleDeptChange(value: number | string) {
|
||||
|
||||
/* 确保树容器内部元素都不被截断 */
|
||||
.dept-tree :deep(.el-tree-node__children) {
|
||||
width: max-content !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
|
||||
.dept-tree :deep(.el-tree-node > .el-tree-node__children) {
|
||||
width: max-content !important;
|
||||
width: 100% !important;
|
||||
}
|
||||
</style>
|
||||
Reference in new issue
Block a user