feat(system): 添加用户管理功能
- 新增用户管理相关的 API 接口 - 实现用户列表、用户详情、新增用户、修改用户、删除用户等功能 - 添加用户导入、导出功能 - 实现用户密码重置和用户状态修改 - 新增用户个人信息页面,包括基本资料和密码修改
This commit is contained in:
135
openhis-ui-vue3/src/api/system/user copy.js
Normal file
135
openhis-ui-vue3/src/api/system/user copy.js
Normal file
@@ -0,0 +1,135 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
import { parseStrEmpty } from "@/utils/openhis";
|
||||||
|
|
||||||
|
// 查询用户列表
|
||||||
|
export function listUser(query) {
|
||||||
|
return request({
|
||||||
|
url: '/system/user/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询用户详细
|
||||||
|
export function getUser(userId) {
|
||||||
|
return request({
|
||||||
|
url: '/system/user/' + parseStrEmpty(userId),
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增用户
|
||||||
|
export function addUser(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/user',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改用户
|
||||||
|
export function updateUser(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/user',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除用户
|
||||||
|
export function delUser(userId) {
|
||||||
|
return request({
|
||||||
|
url: '/system/user/' + userId,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户密码重置
|
||||||
|
export function resetUserPwd(userId, password) {
|
||||||
|
const data = {
|
||||||
|
userId,
|
||||||
|
password
|
||||||
|
}
|
||||||
|
return request({
|
||||||
|
url: '/system/user/resetPwd',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户状态修改
|
||||||
|
export function changeUserStatus(userId, status) {
|
||||||
|
const data = {
|
||||||
|
userId,
|
||||||
|
status
|
||||||
|
}
|
||||||
|
return request({
|
||||||
|
url: '/system/user/changeStatus',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询用户个人信息
|
||||||
|
export function getUserProfile() {
|
||||||
|
return request({
|
||||||
|
url: '/system/user/profile',
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 修改用户个人信息
|
||||||
|
export function updateUserProfile(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/user/profile',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户密码重置
|
||||||
|
export function updateUserPwd(oldPassword, newPassword) {
|
||||||
|
const data = {
|
||||||
|
oldPassword,
|
||||||
|
newPassword
|
||||||
|
}
|
||||||
|
return request({
|
||||||
|
url: '/system/user/profile/updatePwd',
|
||||||
|
method: 'put',
|
||||||
|
params: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户头像上传
|
||||||
|
export function uploadAvatar(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/user/profile/avatar',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询授权角色
|
||||||
|
export function getAuthRole(userId) {
|
||||||
|
return request({
|
||||||
|
url: '/system/user/authRole/' + userId,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存授权角色
|
||||||
|
export function updateAuthRole(data) {
|
||||||
|
return request({
|
||||||
|
url: '/system/user/authRole',
|
||||||
|
method: 'put',
|
||||||
|
params: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询部门下拉树结构
|
||||||
|
export function deptTreeSelect() {
|
||||||
|
return request({
|
||||||
|
url: '/system/user/deptTree',
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -4,7 +4,7 @@ import { parseStrEmpty } from "@/utils/openhis";
|
|||||||
// 查询用户列表
|
// 查询用户列表
|
||||||
export function listUser(query) {
|
export function listUser(query) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/list',
|
url: '/base-data-manage/practitioner/user-practitioner-page',
|
||||||
method: 'get',
|
method: 'get',
|
||||||
params: query
|
params: query
|
||||||
})
|
})
|
||||||
@@ -12,6 +12,14 @@ export function listUser(query) {
|
|||||||
|
|
||||||
// 查询用户详细
|
// 查询用户详细
|
||||||
export function getUser(userId) {
|
export function getUser(userId) {
|
||||||
|
return request({
|
||||||
|
url: '/base-data-manage/practitioner/user-practitioner-detail?userId=' + parseStrEmpty(userId),
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询角色
|
||||||
|
export function getRole(userId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/' + parseStrEmpty(userId),
|
url: '/system/user/' + parseStrEmpty(userId),
|
||||||
method: 'get'
|
method: 'get'
|
||||||
@@ -21,7 +29,7 @@ export function getUser(userId) {
|
|||||||
// 新增用户
|
// 新增用户
|
||||||
export function addUser(data) {
|
export function addUser(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user',
|
url: '/base-data-manage/practitioner/user-practitioner',
|
||||||
method: 'post',
|
method: 'post',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
@@ -30,7 +38,7 @@ export function addUser(data) {
|
|||||||
// 修改用户
|
// 修改用户
|
||||||
export function updateUser(data) {
|
export function updateUser(data) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user',
|
url: '/base-data-manage/practitioner/user-practitioner',
|
||||||
method: 'put',
|
method: 'put',
|
||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
@@ -39,7 +47,7 @@ export function updateUser(data) {
|
|||||||
// 删除用户
|
// 删除用户
|
||||||
export function delUser(userId) {
|
export function delUser(userId) {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/' + userId,
|
url: '/base-data-manage/practitioner/user-practitioner?userId=' + userId,
|
||||||
method: 'delete'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -129,7 +137,15 @@ export function updateAuthRole(data) {
|
|||||||
// 查询部门下拉树结构
|
// 查询部门下拉树结构
|
||||||
export function deptTreeSelect() {
|
export function deptTreeSelect() {
|
||||||
return request({
|
return request({
|
||||||
url: '/system/user/deptTree',
|
url: '/base-data-manage/organization/organization',
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询位下拉树结构
|
||||||
|
export function locationTreeSelect() {
|
||||||
|
return request({
|
||||||
|
url: '/base-data-manage/cabinet-location/cabinet-location',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
112
openhis-ui-vue3/src/views/system/user copy/authRole.vue
Normal file
112
openhis-ui-vue3/src/views/system/user copy/authRole.vue
Normal file
@@ -0,0 +1,112 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<h4 class="form-header h4">基本信息</h4>
|
||||||
|
<el-form :model="form" label-width="80px">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="8" :offset="2">
|
||||||
|
<el-form-item label="用户昵称" prop="nickName">
|
||||||
|
<el-input v-model="form.nickName" disabled />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8" :offset="2">
|
||||||
|
<el-form-item label="登录账号" prop="userName">
|
||||||
|
<el-input v-model="form.userName" disabled />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<h4 class="form-header h4">角色信息</h4>
|
||||||
|
<el-table v-loading="loading" :row-key="getRowKey" @row-click="clickRow" ref="roleRef" @selection-change="handleSelectionChange" :data="roles.slice((pageNum - 1) * pageSize, pageNum * pageSize)">
|
||||||
|
<el-table-column label="序号" width="55" type="index" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<span>{{ (pageNum - 1) * pageSize + scope.$index + 1 }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column type="selection" :reserve-selection="true" width="55"></el-table-column>
|
||||||
|
<el-table-column label="角色编号" align="center" prop="roleId" />
|
||||||
|
<el-table-column label="角色名称" align="center" prop="roleName" />
|
||||||
|
<el-table-column label="权限字符" align="center" prop="roleKey" />
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
|
||||||
|
<template #default="scope">
|
||||||
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination v-show="total > 0" :total="total" v-model:page="pageNum" v-model:limit="pageSize" />
|
||||||
|
|
||||||
|
<el-form label-width="100px">
|
||||||
|
<div style="text-align: center;margin-left:-120px;margin-top:30px;">
|
||||||
|
<el-button type="primary" @click="submitForm()">提交</el-button>
|
||||||
|
<el-button @click="close()">返回</el-button>
|
||||||
|
</div>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="AuthRole">
|
||||||
|
import { getAuthRole, updateAuthRole } from "@/api/system/user copy";
|
||||||
|
|
||||||
|
const route = useRoute();
|
||||||
|
const { proxy } = getCurrentInstance();
|
||||||
|
|
||||||
|
const loading = ref(true);
|
||||||
|
const total = ref(0);
|
||||||
|
const pageNum = ref(1);
|
||||||
|
const pageSize = ref(10);
|
||||||
|
const roleIds = ref([]);
|
||||||
|
const roles = ref([]);
|
||||||
|
const form = ref({
|
||||||
|
nickName: undefined,
|
||||||
|
userName: undefined,
|
||||||
|
userId: undefined
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 单击选中行数据 */
|
||||||
|
function clickRow(row) {
|
||||||
|
proxy.$refs["roleRef"].toggleRowSelection(row);
|
||||||
|
};
|
||||||
|
/** 多选框选中数据 */
|
||||||
|
function handleSelectionChange(selection) {
|
||||||
|
roleIds.value = selection.map(item => item.roleId);
|
||||||
|
};
|
||||||
|
/** 保存选中的数据编号 */
|
||||||
|
function getRowKey(row) {
|
||||||
|
return row.roleId;
|
||||||
|
};
|
||||||
|
/** 关闭按钮 */
|
||||||
|
function close() {
|
||||||
|
const obj = { path: "/system/user" };
|
||||||
|
proxy.$tab.closeOpenPage(obj);
|
||||||
|
};
|
||||||
|
/** 提交按钮 */
|
||||||
|
function submitForm() {
|
||||||
|
const userId = form.value.userId;
|
||||||
|
const rIds = roleIds.value.join(",");
|
||||||
|
updateAuthRole({ userId: userId, roleIds: rIds }).then(response => {
|
||||||
|
proxy.$modal.msgSuccess("授权成功");
|
||||||
|
close();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
(() => {
|
||||||
|
const userId = route.params && route.params.userId;
|
||||||
|
if (userId) {
|
||||||
|
loading.value = true;
|
||||||
|
getAuthRole(userId).then(response => {
|
||||||
|
form.value = response.user;
|
||||||
|
roles.value = response.roles;
|
||||||
|
total.value = roles.value.length;
|
||||||
|
nextTick(() => {
|
||||||
|
roles.value.forEach(row => {
|
||||||
|
if (row.flag) {
|
||||||
|
proxy.$refs["roleRef"].toggleRowSelection(row);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
loading.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
612
openhis-ui-vue3/src/views/system/user copy/index.vue
Normal file
612
openhis-ui-vue3/src/views/system/user copy/index.vue
Normal file
@@ -0,0 +1,612 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<!--部门数据-->
|
||||||
|
<el-col :span="4" :xs="24">
|
||||||
|
<div class="head-container">
|
||||||
|
<el-input
|
||||||
|
v-model="deptName"
|
||||||
|
placeholder="请输入部门名称"
|
||||||
|
clearable
|
||||||
|
prefix-icon="Search"
|
||||||
|
style="margin-bottom: 20px"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="head-container">
|
||||||
|
<el-tree
|
||||||
|
:data="deptOptions"
|
||||||
|
:props="{ label: 'label', children: 'children' }"
|
||||||
|
:expand-on-click-node="false"
|
||||||
|
:filter-node-method="filterNode"
|
||||||
|
ref="deptTreeRef"
|
||||||
|
node-key="id"
|
||||||
|
highlight-current
|
||||||
|
default-expand-all
|
||||||
|
@node-click="handleNodeClick"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-col>
|
||||||
|
<!--用户数据-->
|
||||||
|
<el-col :span="20" :xs="24">
|
||||||
|
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="用户名称" prop="userName">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.userName"
|
||||||
|
placeholder="请输入用户名称"
|
||||||
|
clearable
|
||||||
|
style="width: 240px"
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="手机号码" prop="phonenumber">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.phonenumber"
|
||||||
|
placeholder="请输入手机号码"
|
||||||
|
clearable
|
||||||
|
style="width: 240px"
|
||||||
|
@keyup.enter="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="状态" prop="status">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.status"
|
||||||
|
placeholder="用户状态"
|
||||||
|
clearable
|
||||||
|
style="width: 240px"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in sys_normal_disable"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="创建时间" style="width: 308px;">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="dateRange"
|
||||||
|
value-format="YYYY-MM-DD"
|
||||||
|
type="daterange"
|
||||||
|
range-separator="-"
|
||||||
|
start-placeholder="开始日期"
|
||||||
|
end-placeholder="结束日期"
|
||||||
|
></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="Plus"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['system:user:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
icon="Edit"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
v-hasPermi="['system:user:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="Delete"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['system:user:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="info"
|
||||||
|
plain
|
||||||
|
icon="Upload"
|
||||||
|
@click="handleImport"
|
||||||
|
v-hasPermi="['system:user:import']"
|
||||||
|
>导入</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="warning"
|
||||||
|
plain
|
||||||
|
icon="Download"
|
||||||
|
@click="handleExport"
|
||||||
|
v-hasPermi="['system:user:export']"
|
||||||
|
>导出</el-button>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
|
||||||
|
<el-table-column type="selection" width="50" align="center" />
|
||||||
|
<el-table-column label="用户编号" align="center" key="userId" prop="userId" v-if="columns[0].visible" />
|
||||||
|
<el-table-column label="用户名称" align="center" key="userName" prop="userName" v-if="columns[1].visible" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="用户昵称" align="center" key="nickName" prop="nickName" v-if="columns[2].visible" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="部门" align="center" key="deptName" prop="dept.deptName" v-if="columns[3].visible" :show-overflow-tooltip="true" />
|
||||||
|
<el-table-column label="手机号码" align="center" key="phonenumber" prop="phonenumber" v-if="columns[4].visible" width="120" />
|
||||||
|
<el-table-column label="状态" align="center" key="status" v-if="columns[5].visible">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-switch
|
||||||
|
v-model="scope.row.status"
|
||||||
|
active-value="0"
|
||||||
|
inactive-value="1"
|
||||||
|
@change="handleStatusChange(scope.row)"
|
||||||
|
></el-switch>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" v-if="columns[6].visible" width="160">
|
||||||
|
<template #default="scope">
|
||||||
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" width="150" class-name="small-padding fixed-width">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tooltip content="修改" placement="top" v-if="scope.row.userId !== 1">
|
||||||
|
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:user:edit']"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip content="删除" placement="top" v-if="scope.row.userId !== 1">
|
||||||
|
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:user:remove']"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip content="重置密码" placement="top" v-if="scope.row.userId !== 1">
|
||||||
|
<el-button link type="primary" icon="Key" @click="handleResetPwd(scope.row)" v-hasPermi="['system:user:resetPwd']"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
<el-tooltip content="分配角色" placement="top" v-if="scope.row.userId !== 1">
|
||||||
|
<el-button link type="primary" icon="CircleCheck" @click="handleAuthRole(scope.row)" v-hasPermi="['system:user:edit']"></el-button>
|
||||||
|
</el-tooltip>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<pagination
|
||||||
|
v-show="total > 0"
|
||||||
|
:total="total"
|
||||||
|
v-model:page="queryParams.pageNum"
|
||||||
|
v-model:limit="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<!-- 添加或修改用户配置对话框 -->
|
||||||
|
<el-dialog :title="title" v-model="open" width="600px" append-to-body>
|
||||||
|
<el-form :model="form" :rules="rules" ref="userRef" label-width="80px">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="用户昵称" prop="nickName">
|
||||||
|
<el-input v-model="form.nickName" placeholder="请输入用户昵称" maxlength="30" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="归属部门" prop="deptId">
|
||||||
|
<el-tree-select
|
||||||
|
v-model="form.deptId"
|
||||||
|
:data="deptOptions"
|
||||||
|
:props="{ value: 'id', label: 'label', children: 'children' }"
|
||||||
|
value-key="id"
|
||||||
|
placeholder="请选择归属部门"
|
||||||
|
check-strictly
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="手机号码" prop="phonenumber">
|
||||||
|
<el-input v-model="form.phonenumber" placeholder="请输入手机号码" maxlength="11" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="邮箱" prop="email">
|
||||||
|
<el-input v-model="form.email" placeholder="请输入邮箱" maxlength="50" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item v-if="form.userId == undefined" label="用户名称" prop="userName">
|
||||||
|
<el-input v-model="form.userName" placeholder="请输入用户名称" maxlength="30" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item v-if="form.userId == undefined" label="用户密码" prop="password">
|
||||||
|
<el-input v-model="form.password" placeholder="请输入用户密码" type="password" maxlength="20" show-password />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="用户性别">
|
||||||
|
<el-select v-model="form.sex" placeholder="请选择">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in sys_user_sex"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="状态">
|
||||||
|
<el-radio-group v-model="form.status">
|
||||||
|
<el-radio
|
||||||
|
v-for="dict in sys_normal_disable"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.value"
|
||||||
|
>{{ dict.label }}</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="岗位">
|
||||||
|
<el-select v-model="form.postIds" multiple placeholder="请选择">
|
||||||
|
<el-option
|
||||||
|
v-for="item in postOptions"
|
||||||
|
:key="item.postId"
|
||||||
|
:label="item.postName"
|
||||||
|
:value="item.postId"
|
||||||
|
:disabled="item.status == 1"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="角色">
|
||||||
|
<el-select v-model="form.roleIds" multiple placeholder="请选择">
|
||||||
|
<el-option
|
||||||
|
v-for="item in roleOptions"
|
||||||
|
:key="item.roleId"
|
||||||
|
:label="item.roleName"
|
||||||
|
:value="item.roleId"
|
||||||
|
:disabled="item.status == 1"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="备注">
|
||||||
|
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 用户导入对话框 -->
|
||||||
|
<el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body>
|
||||||
|
<el-upload
|
||||||
|
ref="uploadRef"
|
||||||
|
:limit="1"
|
||||||
|
accept=".xlsx, .xls"
|
||||||
|
:headers="upload.headers"
|
||||||
|
:action="upload.url + '?updateSupport=' + upload.updateSupport"
|
||||||
|
:disabled="upload.isUploading"
|
||||||
|
:on-progress="handleFileUploadProgress"
|
||||||
|
:on-success="handleFileSuccess"
|
||||||
|
:auto-upload="false"
|
||||||
|
drag
|
||||||
|
>
|
||||||
|
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
||||||
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
||||||
|
<template #tip>
|
||||||
|
<div class="el-upload__tip text-center">
|
||||||
|
<div class="el-upload__tip">
|
||||||
|
<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
|
||||||
|
</div>
|
||||||
|
<span>仅允许导入xls、xlsx格式文件。</span>
|
||||||
|
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;" @click="importTemplate">下载模板</el-link>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-upload>
|
||||||
|
<template #footer>
|
||||||
|
<div class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitFileForm">确 定</el-button>
|
||||||
|
<el-button @click="upload.open = false">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="User">
|
||||||
|
import { getToken } from "@/utils/auth";
|
||||||
|
import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, updateUser, addUser, deptTreeSelect } from "@/api/system/user copy";
|
||||||
|
|
||||||
|
const router = useRouter();
|
||||||
|
const { proxy } = getCurrentInstance();
|
||||||
|
const { sys_normal_disable, sys_user_sex } = proxy.useDict("sys_normal_disable", "sys_user_sex");
|
||||||
|
|
||||||
|
const userList = ref([]);
|
||||||
|
const open = ref(false);
|
||||||
|
const loading = ref(true);
|
||||||
|
const showSearch = ref(true);
|
||||||
|
const ids = ref([]);
|
||||||
|
const single = ref(true);
|
||||||
|
const multiple = ref(true);
|
||||||
|
const total = ref(0);
|
||||||
|
const title = ref("");
|
||||||
|
const dateRange = ref([]);
|
||||||
|
const deptName = ref("");
|
||||||
|
const deptOptions = ref(undefined);
|
||||||
|
const initPassword = ref(undefined);
|
||||||
|
const postOptions = ref([]);
|
||||||
|
const roleOptions = ref([]);
|
||||||
|
/*** 用户导入参数 */
|
||||||
|
const upload = reactive({
|
||||||
|
// 是否显示弹出层(用户导入)
|
||||||
|
open: false,
|
||||||
|
// 弹出层标题(用户导入)
|
||||||
|
title: "",
|
||||||
|
// 是否禁用上传
|
||||||
|
isUploading: false,
|
||||||
|
// 是否更新已经存在的用户数据
|
||||||
|
updateSupport: 0,
|
||||||
|
// 设置上传的请求头部
|
||||||
|
headers: { Authorization: "Bearer " + getToken() },
|
||||||
|
// 上传的地址
|
||||||
|
url: import.meta.env.VITE_APP_BASE_API + "/system/user/importData"
|
||||||
|
});
|
||||||
|
// 列显隐信息
|
||||||
|
const columns = ref([
|
||||||
|
{ key: 0, label: `用户编号`, visible: true },
|
||||||
|
{ key: 1, label: `用户名称`, visible: true },
|
||||||
|
{ key: 2, label: `用户昵称`, visible: true },
|
||||||
|
{ key: 3, label: `部门`, visible: true },
|
||||||
|
{ key: 4, label: `手机号码`, visible: true },
|
||||||
|
{ key: 5, label: `状态`, visible: true },
|
||||||
|
{ key: 6, label: `创建时间`, visible: true }
|
||||||
|
]);
|
||||||
|
|
||||||
|
const data = reactive({
|
||||||
|
form: {},
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
userName: undefined,
|
||||||
|
phonenumber: undefined,
|
||||||
|
status: undefined,
|
||||||
|
deptId: undefined
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
userName: [{ required: true, message: "用户名称不能为空", trigger: "blur" }, { min: 2, max: 20, message: "用户名称长度必须介于 2 和 20 之间", trigger: "blur" }],
|
||||||
|
nickName: [{ required: true, message: "用户昵称不能为空", trigger: "blur" }],
|
||||||
|
password: [{ required: true, message: "用户密码不能为空", trigger: "blur" }, { min: 5, max: 20, message: "用户密码长度必须介于 5 和 20 之间", trigger: "blur" }, { pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }],
|
||||||
|
email: [{ type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }],
|
||||||
|
phonenumber: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }]
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const { queryParams, form, rules } = toRefs(data);
|
||||||
|
|
||||||
|
/** 通过条件过滤节点 */
|
||||||
|
const filterNode = (value, data) => {
|
||||||
|
if (!value) return true;
|
||||||
|
return data.label.indexOf(value) !== -1;
|
||||||
|
};
|
||||||
|
/** 根据名称筛选部门树 */
|
||||||
|
watch(deptName, val => {
|
||||||
|
proxy.$refs["deptTreeRef"].filter(val);
|
||||||
|
});
|
||||||
|
/** 查询部门下拉树结构 */
|
||||||
|
function getDeptTree() {
|
||||||
|
deptTreeSelect().then(response => {
|
||||||
|
deptOptions.value = response.data;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/** 查询用户列表 */
|
||||||
|
function getList() {
|
||||||
|
loading.value = true;
|
||||||
|
listUser(proxy.addDateRange(queryParams.value, dateRange.value)).then(res => {
|
||||||
|
loading.value = false;
|
||||||
|
userList.value = res.rows;
|
||||||
|
total.value = res.total;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/** 节点单击事件 */
|
||||||
|
function handleNodeClick(data) {
|
||||||
|
queryParams.value.deptId = data.id;
|
||||||
|
handleQuery();
|
||||||
|
};
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
function handleQuery() {
|
||||||
|
queryParams.value.pageNum = 1;
|
||||||
|
getList();
|
||||||
|
};
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
function resetQuery() {
|
||||||
|
dateRange.value = [];
|
||||||
|
proxy.resetForm("queryRef");
|
||||||
|
queryParams.value.deptId = undefined;
|
||||||
|
proxy.$refs.deptTreeRef.setCurrentKey(null);
|
||||||
|
handleQuery();
|
||||||
|
};
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
function handleDelete(row) {
|
||||||
|
const userIds = row.userId || ids.value;
|
||||||
|
proxy.$modal.confirm('是否确认删除用户编号为"' + userIds + '"的数据项?').then(function () {
|
||||||
|
return delUser(userIds);
|
||||||
|
}).then(() => {
|
||||||
|
getList();
|
||||||
|
proxy.$modal.msgSuccess("删除成功");
|
||||||
|
}).catch(() => {});
|
||||||
|
};
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
function handleExport() {
|
||||||
|
proxy.download("system/user/export", {
|
||||||
|
...queryParams.value,
|
||||||
|
},`user_${new Date().getTime()}.xlsx`);
|
||||||
|
};
|
||||||
|
/** 用户状态修改 */
|
||||||
|
function handleStatusChange(row) {
|
||||||
|
let text = row.status === "0" ? "启用" : "停用";
|
||||||
|
proxy.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function () {
|
||||||
|
return changeUserStatus(row.userId, row.status);
|
||||||
|
}).then(() => {
|
||||||
|
proxy.$modal.msgSuccess(text + "成功");
|
||||||
|
}).catch(function () {
|
||||||
|
row.status = row.status === "0" ? "1" : "0";
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/** 更多操作 */
|
||||||
|
function handleCommand(command, row) {
|
||||||
|
switch (command) {
|
||||||
|
case "handleResetPwd":
|
||||||
|
handleResetPwd(row);
|
||||||
|
break;
|
||||||
|
case "handleAuthRole":
|
||||||
|
handleAuthRole(row);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/** 跳转角色分配 */
|
||||||
|
function handleAuthRole(row) {
|
||||||
|
const userId = row.userId;
|
||||||
|
router.push("/system/user-auth/role/" + userId);
|
||||||
|
};
|
||||||
|
/** 重置密码按钮操作 */
|
||||||
|
function handleResetPwd(row) {
|
||||||
|
proxy.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
|
||||||
|
confirmButtonText: "确定",
|
||||||
|
cancelButtonText: "取消",
|
||||||
|
closeOnClickModal: false,
|
||||||
|
inputPattern: /^.{5,20}$/,
|
||||||
|
inputErrorMessage: "用户密码长度必须介于 5 和 20 之间",
|
||||||
|
inputValidator: (value) => {
|
||||||
|
if (/<|>|"|'|\||\\/.test(value)) {
|
||||||
|
return "不能包含非法字符:< > \" ' \\\ |"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}).then(({ value }) => {
|
||||||
|
resetUserPwd(row.userId, value).then(response => {
|
||||||
|
proxy.$modal.msgSuccess("修改成功,新密码是:" + value);
|
||||||
|
});
|
||||||
|
}).catch(() => {});
|
||||||
|
};
|
||||||
|
/** 选择条数 */
|
||||||
|
function handleSelectionChange(selection) {
|
||||||
|
ids.value = selection.map(item => item.userId);
|
||||||
|
single.value = selection.length != 1;
|
||||||
|
multiple.value = !selection.length;
|
||||||
|
};
|
||||||
|
/** 导入按钮操作 */
|
||||||
|
function handleImport() {
|
||||||
|
upload.title = "用户导入";
|
||||||
|
upload.open = true;
|
||||||
|
};
|
||||||
|
/** 下载模板操作 */
|
||||||
|
function importTemplate() {
|
||||||
|
proxy.download("system/user/importTemplate", {
|
||||||
|
}, `user_template_${new Date().getTime()}.xlsx`);
|
||||||
|
};
|
||||||
|
/**文件上传中处理 */
|
||||||
|
const handleFileUploadProgress = (event, file, fileList) => {
|
||||||
|
upload.isUploading = true;
|
||||||
|
};
|
||||||
|
/** 文件上传成功处理 */
|
||||||
|
const handleFileSuccess = (response, file, fileList) => {
|
||||||
|
upload.open = false;
|
||||||
|
upload.isUploading = false;
|
||||||
|
proxy.$refs["uploadRef"].handleRemove(file);
|
||||||
|
proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
|
||||||
|
getList();
|
||||||
|
};
|
||||||
|
/** 提交上传文件 */
|
||||||
|
function submitFileForm() {
|
||||||
|
proxy.$refs["uploadRef"].submit();
|
||||||
|
};
|
||||||
|
/** 重置操作表单 */
|
||||||
|
function reset() {
|
||||||
|
form.value = {
|
||||||
|
userId: undefined,
|
||||||
|
deptId: undefined,
|
||||||
|
userName: undefined,
|
||||||
|
nickName: undefined,
|
||||||
|
password: undefined,
|
||||||
|
phonenumber: undefined,
|
||||||
|
email: undefined,
|
||||||
|
sex: undefined,
|
||||||
|
status: "0",
|
||||||
|
remark: undefined,
|
||||||
|
postIds: [],
|
||||||
|
roleIds: []
|
||||||
|
};
|
||||||
|
proxy.resetForm("userRef");
|
||||||
|
};
|
||||||
|
/** 取消按钮 */
|
||||||
|
function cancel() {
|
||||||
|
open.value = false;
|
||||||
|
reset();
|
||||||
|
};
|
||||||
|
/** 新增按钮操作 */
|
||||||
|
function handleAdd() {
|
||||||
|
reset();
|
||||||
|
getUser().then(response => {
|
||||||
|
postOptions.value = response.posts;
|
||||||
|
roleOptions.value = response.roles;
|
||||||
|
open.value = true;
|
||||||
|
title.value = "添加用户";
|
||||||
|
form.value.password = initPassword.value;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
function handleUpdate(row) {
|
||||||
|
reset();
|
||||||
|
const userId = row.userId || ids.value;
|
||||||
|
getUser(userId).then(response => {
|
||||||
|
form.value = response.data;
|
||||||
|
postOptions.value = response.posts;
|
||||||
|
roleOptions.value = response.roles;
|
||||||
|
form.value.postIds = response.postIds;
|
||||||
|
form.value.roleIds = response.roleIds;
|
||||||
|
open.value = true;
|
||||||
|
title.value = "修改用户";
|
||||||
|
form.password = "";
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/** 提交按钮 */
|
||||||
|
function submitForm() {
|
||||||
|
proxy.$refs["userRef"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (form.value.userId != undefined) {
|
||||||
|
updateUser(form.value).then(response => {
|
||||||
|
proxy.$modal.msgSuccess("修改成功");
|
||||||
|
open.value = false;
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
addUser(form.value).then(response => {
|
||||||
|
proxy.$modal.msgSuccess("新增成功");
|
||||||
|
open.value = false;
|
||||||
|
getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
getDeptTree();
|
||||||
|
getList();
|
||||||
|
</script>
|
||||||
87
openhis-ui-vue3/src/views/system/user copy/profile/index.vue
Normal file
87
openhis-ui-vue3/src/views/system/user copy/profile/index.vue
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="6" :xs="24">
|
||||||
|
<el-card class="box-card">
|
||||||
|
<template v-slot:header>
|
||||||
|
<div class="clearfix">
|
||||||
|
<span>个人信息</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<div>
|
||||||
|
<div class="text-center">
|
||||||
|
<userAvatar />
|
||||||
|
</div>
|
||||||
|
<ul class="list-group list-group-striped">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<svg-icon icon-class="user" />用户名称
|
||||||
|
<div class="pull-right">{{ state.user.userName }}</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<svg-icon icon-class="phone" />手机号码
|
||||||
|
<div class="pull-right">{{ state.user.phonenumber }}</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<svg-icon icon-class="email" />用户邮箱
|
||||||
|
<div class="pull-right">{{ state.user.email }}</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<svg-icon icon-class="tree" />所属部门
|
||||||
|
<div class="pull-right" v-if="state.user.dept">{{ state.user.dept.deptName }} / {{ state.postGroup }}</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<svg-icon icon-class="peoples" />所属角色
|
||||||
|
<div class="pull-right">{{ state.roleGroup }}</div>
|
||||||
|
</li>
|
||||||
|
<li class="list-group-item">
|
||||||
|
<svg-icon icon-class="date" />创建日期
|
||||||
|
<div class="pull-right">{{ state.user.createTime }}</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="18" :xs="24">
|
||||||
|
<el-card>
|
||||||
|
<template v-slot:header>
|
||||||
|
<div class="clearfix">
|
||||||
|
<span>基本资料</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<el-tabs v-model="activeTab">
|
||||||
|
<el-tab-pane label="基本资料" name="userinfo">
|
||||||
|
<userInfo :user="state.user" />
|
||||||
|
</el-tab-pane>
|
||||||
|
<el-tab-pane label="修改密码" name="resetPwd">
|
||||||
|
<resetPwd />
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup name="Profile">
|
||||||
|
import userAvatar from "./userAvatar";
|
||||||
|
import userInfo from "./userInfo";
|
||||||
|
import resetPwd from "./resetPwd";
|
||||||
|
import { getUserProfile } from "@/api/system/user copy";
|
||||||
|
|
||||||
|
const activeTab = ref("userinfo");
|
||||||
|
const state = reactive({
|
||||||
|
user: {},
|
||||||
|
roleGroup: {},
|
||||||
|
postGroup: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
function getUser() {
|
||||||
|
getUserProfile().then(response => {
|
||||||
|
state.user = response.data;
|
||||||
|
state.roleGroup = response.roleGroup;
|
||||||
|
state.postGroup = response.postGroup;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
getUser();
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
<!--
|
||||||
|
* @Author: 徐靖博 xujb@ccjb.com.cn
|
||||||
|
* @Date: 2025-03-26 10:49:30
|
||||||
|
* @LastEditTime: 2025-03-26 13:57:02
|
||||||
|
* @LastEditors: 徐靖博 xujb@ccjb.com.cn
|
||||||
|
* @Description:
|
||||||
|
* @FilePath: \openhis-ui-vue3\src\views\system\user copy\profile\resetPwd.vue
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<el-form ref="pwdRef" :model="user" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="旧密码" prop="oldPassword">
|
||||||
|
<el-input v-model="user.oldPassword" placeholder="请输入旧密码" type="password" show-password />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="新密码" prop="newPassword">
|
||||||
|
<el-input v-model="user.newPassword" placeholder="请输入新密码" type="password" show-password />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="确认密码" prop="confirmPassword">
|
||||||
|
<el-input v-model="user.confirmPassword" placeholder="请确认新密码" type="password" show-password/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="submit">保存</el-button>
|
||||||
|
<el-button type="danger" @click="close">关闭</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { updateUserPwd } from "@/api/system/user copy";
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance();
|
||||||
|
|
||||||
|
const user = reactive({
|
||||||
|
oldPassword: undefined,
|
||||||
|
newPassword: undefined,
|
||||||
|
confirmPassword: undefined
|
||||||
|
});
|
||||||
|
|
||||||
|
const equalToPassword = (rule, value, callback) => {
|
||||||
|
if (user.newPassword !== value) {
|
||||||
|
callback(new Error("两次输入的密码不一致"));
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const rules = ref({
|
||||||
|
oldPassword: [{ required: true, message: "旧密码不能为空", trigger: "blur" }],
|
||||||
|
newPassword: [{ required: true, message: "新密码不能为空", trigger: "blur" }, { min: 6, max: 20, message: "长度在 6 到 20 个字符", trigger: "blur" }, { pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }],
|
||||||
|
confirmPassword: [{ required: true, message: "确认密码不能为空", trigger: "blur" }, { required: true, validator: equalToPassword, trigger: "blur" }]
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 提交按钮 */
|
||||||
|
function submit() {
|
||||||
|
proxy.$refs.pwdRef.validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
updateUserPwd(user.oldPassword, user.newPassword).then(response => {
|
||||||
|
proxy.$modal.msgSuccess("修改成功");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/** 关闭按钮 */
|
||||||
|
function close() {
|
||||||
|
proxy.$tab.closePage();
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,171 @@
|
|||||||
|
<template>
|
||||||
|
<div class="user-info-head" @click="editCropper()">
|
||||||
|
<img :src="options.img" title="点击上传头像" class="img-circle img-lg" />
|
||||||
|
<el-dialog :title="title" v-model="open" width="800px" append-to-body @opened="modalOpened" @close="closeDialog">
|
||||||
|
<el-row>
|
||||||
|
<el-col :xs="24" :md="12" :style="{ height: '350px' }">
|
||||||
|
<vue-cropper
|
||||||
|
ref="cropper"
|
||||||
|
:img="options.img"
|
||||||
|
:info="true"
|
||||||
|
:autoCrop="options.autoCrop"
|
||||||
|
:autoCropWidth="options.autoCropWidth"
|
||||||
|
:autoCropHeight="options.autoCropHeight"
|
||||||
|
:fixedBox="options.fixedBox"
|
||||||
|
:outputType="options.outputType"
|
||||||
|
@realTime="realTime"
|
||||||
|
v-if="visible"
|
||||||
|
/>
|
||||||
|
</el-col>
|
||||||
|
<el-col :xs="24" :md="12" :style="{ height: '350px' }">
|
||||||
|
<div class="avatar-upload-preview">
|
||||||
|
<img :src="options.previews.url" :style="options.previews.img" />
|
||||||
|
</div>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<br />
|
||||||
|
<el-row>
|
||||||
|
<el-col :lg="2" :md="2">
|
||||||
|
<el-upload
|
||||||
|
action="#"
|
||||||
|
:http-request="requestUpload"
|
||||||
|
:show-file-list="false"
|
||||||
|
:before-upload="beforeUpload"
|
||||||
|
>
|
||||||
|
<el-button>
|
||||||
|
选择
|
||||||
|
<el-icon class="el-icon--right"><Upload /></el-icon>
|
||||||
|
</el-button>
|
||||||
|
</el-upload>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="{ span: 1, offset: 2 }" :md="2">
|
||||||
|
<el-button icon="Plus" @click="changeScale(1)"></el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="{ span: 1, offset: 1 }" :md="2">
|
||||||
|
<el-button icon="Minus" @click="changeScale(-1)"></el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="{ span: 1, offset: 1 }" :md="2">
|
||||||
|
<el-button icon="RefreshLeft" @click="rotateLeft()"></el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="{ span: 1, offset: 1 }" :md="2">
|
||||||
|
<el-button icon="RefreshRight" @click="rotateRight()"></el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :lg="{ span: 2, offset: 6 }" :md="2">
|
||||||
|
<el-button type="primary" @click="uploadImg()">提 交</el-button>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import "vue-cropper/dist/index.css";
|
||||||
|
import { VueCropper } from "vue-cropper";
|
||||||
|
import { uploadAvatar } from "@/api/system/user copy";
|
||||||
|
import useUserStore from "@/store/modules/user";
|
||||||
|
|
||||||
|
const userStore = useUserStore();
|
||||||
|
const { proxy } = getCurrentInstance();
|
||||||
|
|
||||||
|
const open = ref(false);
|
||||||
|
const visible = ref(false);
|
||||||
|
const title = ref("修改头像");
|
||||||
|
|
||||||
|
//图片裁剪数据
|
||||||
|
const options = reactive({
|
||||||
|
img: userStore.avatar, // 裁剪图片的地址
|
||||||
|
autoCrop: true, // 是否默认生成截图框
|
||||||
|
autoCropWidth: 200, // 默认生成截图框宽度
|
||||||
|
autoCropHeight: 200, // 默认生成截图框高度
|
||||||
|
fixedBox: true, // 固定截图框大小 不允许改变
|
||||||
|
outputType: "png", // 默认生成截图为PNG格式
|
||||||
|
filename: 'avatar', // 文件名称
|
||||||
|
previews: {} //预览数据
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 编辑头像 */
|
||||||
|
function editCropper() {
|
||||||
|
open.value = true;
|
||||||
|
}
|
||||||
|
/** 打开弹出层结束时的回调 */
|
||||||
|
function modalOpened() {
|
||||||
|
visible.value = true;
|
||||||
|
}
|
||||||
|
/** 覆盖默认上传行为 */
|
||||||
|
function requestUpload() {}
|
||||||
|
/** 向左旋转 */
|
||||||
|
function rotateLeft() {
|
||||||
|
proxy.$refs.cropper.rotateLeft();
|
||||||
|
}
|
||||||
|
/** 向右旋转 */
|
||||||
|
function rotateRight() {
|
||||||
|
proxy.$refs.cropper.rotateRight();
|
||||||
|
}
|
||||||
|
/** 图片缩放 */
|
||||||
|
function changeScale(num) {
|
||||||
|
num = num || 1;
|
||||||
|
proxy.$refs.cropper.changeScale(num);
|
||||||
|
}
|
||||||
|
/** 上传预处理 */
|
||||||
|
function beforeUpload(file) {
|
||||||
|
if (file.type.indexOf("image/") == -1) {
|
||||||
|
proxy.$modal.msgError("文件格式错误,请上传图片类型,如:JPG,PNG后缀的文件。");
|
||||||
|
} else {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
reader.onload = () => {
|
||||||
|
options.img = reader.result;
|
||||||
|
options.filename = file.name;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/** 上传图片 */
|
||||||
|
function uploadImg() {
|
||||||
|
proxy.$refs.cropper.getCropBlob(data => {
|
||||||
|
let formData = new FormData();
|
||||||
|
formData.append("avatarfile", data, options.filename);
|
||||||
|
uploadAvatar(formData).then(response => {
|
||||||
|
open.value = false;
|
||||||
|
options.img = import.meta.env.VITE_APP_BASE_API + response.imgUrl;
|
||||||
|
userStore.avatar = options.img;
|
||||||
|
proxy.$modal.msgSuccess("修改成功");
|
||||||
|
visible.value = false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/** 实时预览 */
|
||||||
|
function realTime(data) {
|
||||||
|
options.previews = data;
|
||||||
|
}
|
||||||
|
/** 关闭窗口 */
|
||||||
|
function closeDialog() {
|
||||||
|
options.img = userStore.avatar;
|
||||||
|
options.visible = false;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang='scss' scoped>
|
||||||
|
.user-info-head {
|
||||||
|
position: relative;
|
||||||
|
display: inline-block;
|
||||||
|
height: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-info-head:hover:after {
|
||||||
|
content: "+";
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
color: #eee;
|
||||||
|
background: rgba(0, 0, 0, 0.5);
|
||||||
|
font-size: 24px;
|
||||||
|
font-style: normal;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
cursor: pointer;
|
||||||
|
line-height: 110px;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
<template>
|
||||||
|
<el-form ref="userRef" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="用户昵称" prop="nickName">
|
||||||
|
<el-input v-model="form.nickName" maxlength="30" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="手机号码" prop="phonenumber">
|
||||||
|
<el-input v-model="form.phonenumber" maxlength="11" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="邮箱" prop="email">
|
||||||
|
<el-input v-model="form.email" maxlength="50" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="性别">
|
||||||
|
<el-radio-group v-model="form.sex">
|
||||||
|
<el-radio label="0">男</el-radio>
|
||||||
|
<el-radio label="1">女</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="submit">保存</el-button>
|
||||||
|
<el-button type="danger" @click="close">关闭</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { updateUserProfile } from "@/api/system/user copy";
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
user: {
|
||||||
|
type: Object
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const { proxy } = getCurrentInstance();
|
||||||
|
|
||||||
|
const form = ref({});
|
||||||
|
const rules = ref({
|
||||||
|
nickName: [{ required: true, message: "用户昵称不能为空", trigger: "blur" }],
|
||||||
|
email: [{ required: true, message: "邮箱地址不能为空", trigger: "blur" }, { type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }],
|
||||||
|
phonenumber: [{ required: true, message: "手机号码不能为空", trigger: "blur" }, { pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }],
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 提交按钮 */
|
||||||
|
function submit() {
|
||||||
|
proxy.$refs.userRef.validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
updateUserProfile(form.value).then(response => {
|
||||||
|
proxy.$modal.msgSuccess("修改成功");
|
||||||
|
props.user.phonenumber = form.value.phonenumber;
|
||||||
|
props.user.email = form.value.email;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
/** 关闭按钮 */
|
||||||
|
function close() {
|
||||||
|
proxy.$tab.closePage();
|
||||||
|
};
|
||||||
|
|
||||||
|
// 回显当前登录用户信息
|
||||||
|
watch(() => props.user, user => {
|
||||||
|
if (user) {
|
||||||
|
form.value = { nickName: user.nickName, phonenumber: user.phonenumber, email: user.email, sex: user.sex };
|
||||||
|
}
|
||||||
|
},{ immediate: true });
|
||||||
|
</script>
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<div class="head-container">
|
<div class="head-container">
|
||||||
<el-tree
|
<el-tree
|
||||||
:data="deptOptions"
|
:data="deptOptions"
|
||||||
:props="{ label: 'label', children: 'children' }"
|
:props="{ label: 'name', children: 'children' }"
|
||||||
:expand-on-click-node="false"
|
:expand-on-click-node="false"
|
||||||
:filter-node-method="filterNode"
|
:filter-node-method="filterNode"
|
||||||
ref="deptTreeRef"
|
ref="deptTreeRef"
|
||||||
@@ -108,7 +108,7 @@
|
|||||||
v-hasPermi="['system:user:remove']"
|
v-hasPermi="['system:user:remove']"
|
||||||
>删除</el-button>
|
>删除</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="1.5">
|
<!-- <el-col :span="1.5">
|
||||||
<el-button
|
<el-button
|
||||||
type="info"
|
type="info"
|
||||||
plain
|
plain
|
||||||
@@ -125,7 +125,7 @@
|
|||||||
@click="handleExport"
|
@click="handleExport"
|
||||||
v-hasPermi="['system:user:export']"
|
v-hasPermi="['system:user:export']"
|
||||||
>导出</el-button>
|
>导出</el-button>
|
||||||
</el-col>
|
</el-col> -->
|
||||||
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
|
<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@
|
|||||||
<pagination
|
<pagination
|
||||||
v-show="total > 0"
|
v-show="total > 0"
|
||||||
:total="total"
|
:total="total"
|
||||||
v-model:page="queryParams.pageNum"
|
v-model:page="queryParams.pageNo"
|
||||||
v-model:limit="queryParams.pageSize"
|
v-model:limit="queryParams.pageSize"
|
||||||
@pagination="getList"
|
@pagination="getList"
|
||||||
/>
|
/>
|
||||||
@@ -188,11 +188,11 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="归属部门" prop="deptId">
|
<el-form-item label="归属部门" prop="orgId">
|
||||||
<el-tree-select
|
<el-tree-select
|
||||||
v-model="form.deptId"
|
v-model="form.orgId"
|
||||||
:data="deptOptions"
|
:data="deptOptions"
|
||||||
:props="{ value: 'id', label: 'label', children: 'children' }"
|
:props="{ value: 'id', label: 'name', children: 'children' }"
|
||||||
value-key="id"
|
value-key="id"
|
||||||
placeholder="请选择归属部门"
|
placeholder="请选择归属部门"
|
||||||
check-strictly
|
check-strictly
|
||||||
@@ -251,21 +251,31 @@
|
|||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="岗位">
|
<el-form-item label="出生日期">
|
||||||
<el-select v-model="form.postIds" multiple placeholder="请选择">
|
<el-date-picker
|
||||||
<el-option
|
v-model="form.birthDate"
|
||||||
v-for="item in postOptions"
|
type="date"
|
||||||
:key="item.postId"
|
placeholder="选择日期"
|
||||||
:label="item.postName"
|
format="YYYY-MM-DD"
|
||||||
:value="item.postId"
|
value-format="YYYY-MM-DD"
|
||||||
:disabled="item.status == 1"
|
/>
|
||||||
></el-option>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="地址" prop="address">
|
||||||
|
<el-input v-model="form.address" placeholder="请输入地址" maxlength="30" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="医保码" prop="ybNo">
|
||||||
|
<el-input v-model="form.ybNo" placeholder="请输入医保码" maxlength="30" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="角色">
|
<el-form-item label="角色">
|
||||||
<el-select v-model="form.roleIds" multiple placeholder="请选择">
|
<el-select v-model="form.roleIds" multiple placeholder="请选择" @change="handleRoleChange">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in roleOptions"
|
v-for="item in roleOptions"
|
||||||
:key="item.roleId"
|
:key="item.roleId"
|
||||||
@@ -277,6 +287,48 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
<div v-if="form.roleIds.length > 0">
|
||||||
|
角色信息
|
||||||
|
</div>
|
||||||
|
<el-row v-for="(item, index) in form.roleIds" :key="index">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="角色" :prop="`childList.${index}.roleCode`" :rules="data.rules.childList[index].roleCode">
|
||||||
|
<el-select v-model="form.childList[index].roleCode" placeholder="请选择">
|
||||||
|
<el-option
|
||||||
|
v-for="item in selectRole"
|
||||||
|
:key="item.roleKey"
|
||||||
|
:label="item.roleName"
|
||||||
|
:value="item.roleKey"
|
||||||
|
:disabled="item.status == 1"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="归属部门" :prop="`childList.${index}.orgId`" :rules="data.rules.childList[index].orgId">
|
||||||
|
<el-tree-select
|
||||||
|
v-model="form.childList[index].orgId"
|
||||||
|
:data="deptOptions"
|
||||||
|
:props="{ value: 'id', label: 'name', children: 'children' }"
|
||||||
|
value-key="id"
|
||||||
|
placeholder="请选择归属部门"
|
||||||
|
check-strictly
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="位置" :prop="`childList.${index}.locationId`" :rules="data.rules.childList[index].locationId">
|
||||||
|
<el-tree-select
|
||||||
|
v-model="form.childList[index].locationId"
|
||||||
|
:data="locationOptions"
|
||||||
|
:props="{ value: 'id', label: 'name', children: 'children' }"
|
||||||
|
value-key="id"
|
||||||
|
placeholder="请选择位置"
|
||||||
|
check-strictly
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="24">
|
<el-col :span="24">
|
||||||
<el-form-item label="备注">
|
<el-form-item label="备注">
|
||||||
@@ -331,7 +383,7 @@
|
|||||||
|
|
||||||
<script setup name="User">
|
<script setup name="User">
|
||||||
import { getToken } from "@/utils/auth";
|
import { getToken } from "@/utils/auth";
|
||||||
import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, updateUser, addUser, deptTreeSelect } from "@/api/system/user";
|
import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, getRole, updateUser, addUser, deptTreeSelect, locationTreeSelect } from "@/api/system/user";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { proxy } = getCurrentInstance();
|
const { proxy } = getCurrentInstance();
|
||||||
@@ -349,9 +401,11 @@ const title = ref("");
|
|||||||
const dateRange = ref([]);
|
const dateRange = ref([]);
|
||||||
const deptName = ref("");
|
const deptName = ref("");
|
||||||
const deptOptions = ref(undefined);
|
const deptOptions = ref(undefined);
|
||||||
|
const locationOptions = ref([]);
|
||||||
const initPassword = ref(undefined);
|
const initPassword = ref(undefined);
|
||||||
const postOptions = ref([]);
|
const postOptions = ref([]);
|
||||||
const roleOptions = ref([]);
|
const roleOptions = ref([]);
|
||||||
|
const selectRole = ref([]);
|
||||||
/*** 用户导入参数 */
|
/*** 用户导入参数 */
|
||||||
const upload = reactive({
|
const upload = reactive({
|
||||||
// 是否显示弹出层(用户导入)
|
// 是否显示弹出层(用户导入)
|
||||||
@@ -381,19 +435,20 @@ const columns = ref([
|
|||||||
const data = reactive({
|
const data = reactive({
|
||||||
form: {},
|
form: {},
|
||||||
queryParams: {
|
queryParams: {
|
||||||
pageNum: 1,
|
pageNo: 1,
|
||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
userName: undefined,
|
userName: undefined,
|
||||||
phonenumber: undefined,
|
phonenumber: undefined,
|
||||||
status: undefined,
|
status: undefined,
|
||||||
deptId: undefined
|
orgId: undefined
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
userName: [{ required: true, message: "用户名称不能为空", trigger: "blur" }, { min: 2, max: 20, message: "用户名称长度必须介于 2 和 20 之间", trigger: "blur" }],
|
userName: [{ required: true, message: "用户名称不能为空", trigger: "blur" }, { min: 2, max: 20, message: "用户名称长度必须介于 2 和 20 之间", trigger: "blur" }],
|
||||||
nickName: [{ required: true, message: "用户昵称不能为空", trigger: "blur" }],
|
nickName: [{ required: true, message: "用户昵称不能为空", trigger: "blur" }],
|
||||||
password: [{ required: true, message: "用户密码不能为空", trigger: "blur" }, { min: 5, max: 20, message: "用户密码长度必须介于 5 和 20 之间", trigger: "blur" }, { pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }],
|
password: [{ required: true, message: "用户密码不能为空", trigger: "blur" }, { min: 5, max: 20, message: "用户密码长度必须介于 5 和 20 之间", trigger: "blur" }, { pattern: /^[^<>"'|\\]+$/, message: "不能包含非法字符:< > \" ' \\\ |", trigger: "blur" }],
|
||||||
email: [{ type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }],
|
email: [{ type: "email", message: "请输入正确的邮箱地址", trigger: ["blur", "change"] }],
|
||||||
phonenumber: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }]
|
phonenumber: [{ pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }],
|
||||||
|
childList: []
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -411,7 +466,13 @@ watch(deptName, val => {
|
|||||||
/** 查询部门下拉树结构 */
|
/** 查询部门下拉树结构 */
|
||||||
function getDeptTree() {
|
function getDeptTree() {
|
||||||
deptTreeSelect().then(response => {
|
deptTreeSelect().then(response => {
|
||||||
deptOptions.value = response.data;
|
deptOptions.value = response.data.records;
|
||||||
|
});
|
||||||
|
};
|
||||||
|
/** 查询位置下拉树结构 */
|
||||||
|
function getLocationTree() {
|
||||||
|
locationTreeSelect().then(response => {
|
||||||
|
locationOptions.value = response.data.records;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
/** 查询用户列表 */
|
/** 查询用户列表 */
|
||||||
@@ -419,25 +480,25 @@ function getList() {
|
|||||||
loading.value = true;
|
loading.value = true;
|
||||||
listUser(proxy.addDateRange(queryParams.value, dateRange.value)).then(res => {
|
listUser(proxy.addDateRange(queryParams.value, dateRange.value)).then(res => {
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
userList.value = res.rows;
|
userList.value = res.data.records
|
||||||
total.value = res.total;
|
total.value = res.data.total;
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
/** 节点单击事件 */
|
/** 节点单击事件 */
|
||||||
function handleNodeClick(data) {
|
function handleNodeClick(data) {
|
||||||
queryParams.value.deptId = data.id;
|
queryParams.value.orgId = data.id;
|
||||||
handleQuery();
|
handleQuery();
|
||||||
};
|
};
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
function handleQuery() {
|
function handleQuery() {
|
||||||
queryParams.value.pageNum = 1;
|
queryParams.value.pageNo = 1;
|
||||||
getList();
|
getList();
|
||||||
};
|
};
|
||||||
/** 重置按钮操作 */
|
/** 重置按钮操作 */
|
||||||
function resetQuery() {
|
function resetQuery() {
|
||||||
dateRange.value = [];
|
dateRange.value = [];
|
||||||
proxy.resetForm("queryRef");
|
proxy.resetForm("queryRef");
|
||||||
queryParams.value.deptId = undefined;
|
queryParams.value.orgId = undefined;
|
||||||
proxy.$refs.deptTreeRef.setCurrentKey(null);
|
proxy.$refs.deptTreeRef.setCurrentKey(null);
|
||||||
handleQuery();
|
handleQuery();
|
||||||
};
|
};
|
||||||
@@ -459,6 +520,7 @@ function handleExport() {
|
|||||||
};
|
};
|
||||||
/** 用户状态修改 */
|
/** 用户状态修改 */
|
||||||
function handleStatusChange(row) {
|
function handleStatusChange(row) {
|
||||||
|
console.log(row)
|
||||||
let text = row.status === "0" ? "启用" : "停用";
|
let text = row.status === "0" ? "启用" : "停用";
|
||||||
proxy.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function () {
|
proxy.$modal.confirm('确认要"' + text + '""' + row.userName + '"用户吗?').then(function () {
|
||||||
return changeUserStatus(row.userId, row.status);
|
return changeUserStatus(row.userId, row.status);
|
||||||
@@ -541,7 +603,7 @@ function submitFileForm() {
|
|||||||
function reset() {
|
function reset() {
|
||||||
form.value = {
|
form.value = {
|
||||||
userId: undefined,
|
userId: undefined,
|
||||||
deptId: undefined,
|
orgId: undefined,
|
||||||
userName: undefined,
|
userName: undefined,
|
||||||
nickName: undefined,
|
nickName: undefined,
|
||||||
password: undefined,
|
password: undefined,
|
||||||
@@ -550,9 +612,10 @@ function reset() {
|
|||||||
sex: undefined,
|
sex: undefined,
|
||||||
status: "0",
|
status: "0",
|
||||||
remark: undefined,
|
remark: undefined,
|
||||||
postIds: [],
|
roleIds: [],
|
||||||
roleIds: []
|
childList:[]
|
||||||
};
|
};
|
||||||
|
data.rules.childList = []; // 清空现有的校验规则
|
||||||
proxy.resetForm("userRef");
|
proxy.resetForm("userRef");
|
||||||
};
|
};
|
||||||
/** 取消按钮 */
|
/** 取消按钮 */
|
||||||
@@ -563,7 +626,7 @@ function cancel() {
|
|||||||
/** 新增按钮操作 */
|
/** 新增按钮操作 */
|
||||||
function handleAdd() {
|
function handleAdd() {
|
||||||
reset();
|
reset();
|
||||||
getUser().then(response => {
|
getRole().then(response => {
|
||||||
postOptions.value = response.posts;
|
postOptions.value = response.posts;
|
||||||
roleOptions.value = response.roles;
|
roleOptions.value = response.roles;
|
||||||
open.value = true;
|
open.value = true;
|
||||||
@@ -576,19 +639,88 @@ function handleUpdate(row) {
|
|||||||
reset();
|
reset();
|
||||||
const userId = row.userId || ids.value;
|
const userId = row.userId || ids.value;
|
||||||
getUser(userId).then(response => {
|
getUser(userId).then(response => {
|
||||||
|
selectRole.value = []
|
||||||
form.value = response.data;
|
form.value = response.data;
|
||||||
postOptions.value = response.posts;
|
form.value.roleIds = response.data.childList.map(res => res.roleId);
|
||||||
roleOptions.value = response.roles;
|
response.data.childList.forEach(res => {
|
||||||
form.value.postIds = response.postIds;
|
const role = roleOptions.value.find(role => role.roleId === res.roleId);
|
||||||
form.value.roleIds = response.roleIds;
|
if (role) {
|
||||||
|
// 将角色对象插入到 selectRole 数组中
|
||||||
|
selectRole.value.push(role);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
data.rules.childList = form.value.childList.map((_, index) => ({
|
||||||
|
roleCode: [
|
||||||
|
{ required: true, message: "请选择角色", trigger: "change" },
|
||||||
|
{ validator: validateUniqueRole, trigger: "change" }
|
||||||
|
],
|
||||||
|
orgId: [
|
||||||
|
{ required: true, message: "请选择归属部门", trigger: "change" }
|
||||||
|
],
|
||||||
|
locationId: [
|
||||||
|
{ required: true, message: "请选择位置", trigger: "change" }
|
||||||
|
]
|
||||||
|
}));
|
||||||
|
|
||||||
open.value = true;
|
open.value = true;
|
||||||
title.value = "修改用户";
|
title.value = "修改用户";
|
||||||
form.password = "";
|
form.password = "";
|
||||||
});
|
});
|
||||||
|
getRole().then(response => {
|
||||||
|
postOptions.value = response.posts;
|
||||||
|
roleOptions.value = response.roles;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function handleRoleChange(e) {
|
||||||
|
selectRole.value = [];
|
||||||
|
form.value.childList = []
|
||||||
|
data.rules.childList = []; // 清空现有的校验规则
|
||||||
|
console.log(e)
|
||||||
|
// 遍历选中的角色 ID 数组
|
||||||
|
e.forEach(roleId => {
|
||||||
|
// 从 roleOptions 中找到对应的角色对象
|
||||||
|
const role = roleOptions.value.find(role => role.roleId === roleId);
|
||||||
|
if (role) {
|
||||||
|
// 将角色对象插入到 selectRole 数组中
|
||||||
|
selectRole.value.push(role);
|
||||||
|
form.value.childList.push({
|
||||||
|
roleCode: '', // 确保 role 对象中有 roleCode 属性
|
||||||
|
orgId: undefined, // 初始化 orgId
|
||||||
|
locationId: undefined // 初始化 locationId
|
||||||
|
});
|
||||||
|
data.rules.childList.push({
|
||||||
|
roleCode: [
|
||||||
|
{ required: true, message: "请选择角色", trigger: "change" },
|
||||||
|
{ validator: validateUniqueRole, trigger: "change" }
|
||||||
|
],
|
||||||
|
orgId: [
|
||||||
|
{ required: true, message: "请选择归属部门", trigger: "change" }
|
||||||
|
],
|
||||||
|
locationId: [
|
||||||
|
{ required: true, message: "请选择位置", trigger: "change" }
|
||||||
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 自定义校验规则:确保 roleCode 不重复
|
||||||
|
function validateUniqueRole(rule, value, callback) {
|
||||||
|
const roleCodes = form.value.childList.map(child => child.roleCode);
|
||||||
|
const duplicates = roleCodes.filter((item, index) => roleCodes.indexOf(item) !== index);
|
||||||
|
if (duplicates.length > 0) {
|
||||||
|
callback(new Error("角色不能重复"));
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 提交按钮 */
|
/** 提交按钮 */
|
||||||
function submitForm() {
|
function submitForm() {
|
||||||
proxy.$refs["userRef"].validate(valid => {
|
proxy.$refs["userRef"].validate(valid => {
|
||||||
|
console.log(form.value)
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (form.value.userId != undefined) {
|
if (form.value.userId != undefined) {
|
||||||
updateUser(form.value).then(response => {
|
updateUser(form.value).then(response => {
|
||||||
@@ -608,5 +740,6 @@ function submitForm() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
getDeptTree();
|
getDeptTree();
|
||||||
|
getLocationTree()
|
||||||
getList();
|
getList();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user