Merge branch 'master' of https://codeup.aliyun.com/61c0318acd8b75daa5a125f7/medical/openhis
This commit is contained in:
@@ -4,73 +4,35 @@
|
||||
<!--部门数据-->
|
||||
<el-col :span="4" :xs="24">
|
||||
<div class="head-container">
|
||||
<el-input
|
||||
v-model="deptName"
|
||||
placeholder="请输入部门名称"
|
||||
clearable
|
||||
prefix-icon="Search"
|
||||
style="margin-bottom: 20px"
|
||||
/>
|
||||
<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: 'name', children: 'children' }"
|
||||
:expand-on-click-node="false"
|
||||
:filter-node-method="filterNode"
|
||||
ref="deptTreeRef"
|
||||
node-key="id"
|
||||
highlight-current
|
||||
default-expand-all
|
||||
@node-click="handleNodeClick"
|
||||
/>
|
||||
<el-tree :data="deptOptions" :props="{ label: 'name', 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-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-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 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-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>
|
||||
@@ -80,33 +42,16 @@
|
||||
|
||||
<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-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-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-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
|
||||
@@ -132,18 +77,18 @@
|
||||
<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="orgId_dictText" prop="orgId_dictText" 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="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="orgId_dictText" prop="orgId_dictText"
|
||||
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>
|
||||
<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">
|
||||
@@ -154,27 +99,26 @@
|
||||
<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-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-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-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-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.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
@@ -190,16 +134,11 @@
|
||||
<el-input v-model="form.nickName" placeholder="请输入用户昵称" maxlength="30" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="归属部门" prop="orgId">
|
||||
<el-tree-select
|
||||
v-model="form.orgId"
|
||||
:data="deptOptions"
|
||||
:props="{ value: 'id', label: 'name', children: 'children' }"
|
||||
value-key="id"
|
||||
placeholder="请选择归属部门"
|
||||
check-strictly
|
||||
/>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="责任科室" prop="responsibilityOrgDtoList" style="width: 100%">
|
||||
<el-tree-select style="width: 100%" multiple v-model="form.responsibilityOrgDtoListIds" @change="handleChange"
|
||||
:data="deptOptions" :props="{ value: 'id', label: 'name', children: 'children' }" value-key="id"
|
||||
placeholder="请选择责任科室" check-strictly />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@@ -223,7 +162,8 @@
|
||||
</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-input v-model="form.password" placeholder="请输入用户密码" type="password" maxlength="20"
|
||||
show-password />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@@ -231,23 +171,16 @@
|
||||
<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-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 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>
|
||||
@@ -255,13 +188,8 @@
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="出生日期">
|
||||
<el-date-picker
|
||||
v-model="form.birthDate"
|
||||
type="date"
|
||||
placeholder="选择日期"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
/>
|
||||
<el-date-picker v-model="form.birthDate" type="date" placeholder="选择日期" format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
@@ -276,59 +204,28 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="角色">
|
||||
<el-select v-model="form.roleIds" multiple placeholder="请选择" @change="handleRoleChange">
|
||||
<el-option
|
||||
v-for="item in roleOptions"
|
||||
:key="item.roleId"
|
||||
:label="item.roleName"
|
||||
:value="item.roleId"
|
||||
:disabled="item.status == 1"
|
||||
></el-option>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="角色" style="width: 100%;">
|
||||
<el-select v-model="form.practitionerRolesDtoListIds" multiple placeholder="请选择" @change="handleRoleChange"
|
||||
style="width: 100%;">
|
||||
<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>
|
||||
<div v-if="form.roleIds.length > 0" class="form-subtitle">
|
||||
角色信息
|
||||
</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-col :span="24">
|
||||
<el-form-item label="出诊科室" style="width: 100%;">
|
||||
<el-tree-select :disabled="doctorShow" multiple style="width: 100%;" v-model="form.doctorVisitOrgDtoListIds" @change="handleLOrgDtoChange"
|
||||
: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}.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-col :span="24">
|
||||
<el-form-item label="管理库房" style="width: 100%;">
|
||||
<el-tree-select :disabled="locationAdminShow" multiple style="width: 100%;" @change="handleLocationChange"
|
||||
v-model="form.manageLocationDtoListIds" :data="locationOptions"
|
||||
:props="{ value: 'id', label: 'name', children: 'children' }" value-key="id" placeholder="请选择管理库房"
|
||||
check-strictly />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@@ -353,18 +250,9 @@
|
||||
|
||||
<!-- 用户导入对话框 -->
|
||||
<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-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>
|
||||
@@ -373,7 +261,8 @@
|
||||
<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>
|
||||
<el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;"
|
||||
@click="importTemplate">下载模板</el-link>
|
||||
</div>
|
||||
</template>
|
||||
</el-upload>
|
||||
@@ -390,6 +279,7 @@
|
||||
<script setup name="User">
|
||||
import { getToken } from "@/utils/auth";
|
||||
import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, getRole, updateUser, addUser, deptTreeSelect, locationTreeSelect } from "@/api/system/user";
|
||||
import { ref } from "vue";
|
||||
|
||||
const router = useRouter();
|
||||
const { proxy } = getCurrentInstance();
|
||||
@@ -411,7 +301,8 @@ const locationOptions = ref([]);
|
||||
const initPassword = ref(undefined);
|
||||
const postOptions = ref([]);
|
||||
const roleOptions = ref([]);
|
||||
const selectRole = ref([]);
|
||||
const doctorShow = ref(true)
|
||||
const locationAdminShow = ref(true)
|
||||
/*** 用户导入参数 */
|
||||
const upload = reactive({
|
||||
// 是否显示弹出层(用户导入)
|
||||
@@ -454,7 +345,6 @@ const data = reactive({
|
||||
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" }],
|
||||
childList: []
|
||||
}
|
||||
});
|
||||
|
||||
@@ -618,10 +508,11 @@ function reset() {
|
||||
sex: undefined,
|
||||
status: "0",
|
||||
remark: undefined,
|
||||
roleIds: [],
|
||||
childList:[]
|
||||
practitionerRolesDtoList: [],
|
||||
responsibilityOrgDtoList: [],
|
||||
manageLocationDtoList: [],
|
||||
doctorVisitOrgDtoList: []
|
||||
};
|
||||
data.rules.childList = []; // 清空现有的校验规则
|
||||
proxy.resetForm("userRef");
|
||||
};
|
||||
/** 取消按钮 */
|
||||
@@ -636,6 +527,9 @@ function handleAdd() {
|
||||
postOptions.value = response.posts;
|
||||
roleOptions.value = response.roles;
|
||||
open.value = true;
|
||||
// 默认设置为 true
|
||||
doctorShow.value = true;
|
||||
locationAdminShow.value = true;
|
||||
title.value = "添加用户";
|
||||
form.value.password = initPassword.value;
|
||||
});
|
||||
@@ -645,33 +539,21 @@ function handleUpdate(row) {
|
||||
reset();
|
||||
const userId = row.userId || ids.value;
|
||||
getUser(userId).then(response => {
|
||||
selectRole.value = []
|
||||
form.value = response.data;
|
||||
form.value.roleIds = response.data.childList.map(res => res.roleId);
|
||||
response.data.childList.forEach(res => {
|
||||
const role = roleOptions.value.find(role => role.roleId === res.roleId);
|
||||
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" }
|
||||
]
|
||||
}));
|
||||
|
||||
form.value.responsibilityOrgDtoListIds = response.data.responsibilityOrgDtoList.map(res => res.orgId);
|
||||
form.value.practitionerRolesDtoListIds = response.data.practitionerRolesDtoList.map(res => Number(res.roleId));
|
||||
form.value.manageLocationDtoListIds = response.data.manageLocationDtoList.map(res => res.orgId);
|
||||
form.value.doctorVisitOrgDtoListIds = response.data.doctorVisitOrgDtoList.map(res => res.orgId);
|
||||
// 检查 practitionerRolesDtoList 中是否有 roleCode 为 "doctor" 或 "locationAdmin"
|
||||
const hasDoctorRole = response.data.practitionerRolesDtoList.some(role => role.roleCode === "doctor");
|
||||
const hasLocationAdminRole = response.data.practitionerRolesDtoList.some(role => role.roleCode === "locationAdmin");
|
||||
// 根据检查结果设置 doctorShow 和 locationAdminShow
|
||||
doctorShow.value = !hasDoctorRole;
|
||||
locationAdminShow.value = !hasLocationAdminRole;
|
||||
open.value = true;
|
||||
title.value = "修改用户";
|
||||
form.password = "";
|
||||
console.log(form.value)
|
||||
});
|
||||
getRole().then(response => {
|
||||
postOptions.value = response.posts;
|
||||
@@ -679,37 +561,84 @@ function handleUpdate(row) {
|
||||
});
|
||||
};
|
||||
|
||||
function handleRoleChange(e) {
|
||||
selectRole.value = [];
|
||||
form.value.childList = []
|
||||
data.rules.childList = []; // 清空现有的校验规则
|
||||
console.log(e)
|
||||
function handleRoleChange(selectedRoleIds) {
|
||||
form.value.practitionerRolesDtoList = []
|
||||
// 默认设置为 true
|
||||
doctorShow.value = true;
|
||||
locationAdminShow.value = true;
|
||||
|
||||
// 遍历选中的角色 ID 数组
|
||||
e.forEach(roleId => {
|
||||
selectedRoleIds.forEach(roleId => {
|
||||
// 从 roleOptions 中找到对应的角色对象
|
||||
const role = roleOptions.value.find(role => role.roleId === roleId);
|
||||
console.log(role)
|
||||
form.value.practitionerRolesDtoList.push({ roleId: role.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" }
|
||||
]
|
||||
});
|
||||
if (role.roleKey.includes("doctor")) {
|
||||
doctorShow.value = false;
|
||||
}
|
||||
if (role.roleKey.includes("locationAdmin")) {
|
||||
locationAdminShow.value = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
// 循环结束后检查
|
||||
if (doctorShow.value) {
|
||||
form.value.doctorVisitOrgDtoListIds = [];
|
||||
form.value.doctorVisitOrgDtoList = [];
|
||||
}
|
||||
if (locationAdminShow.value) {
|
||||
form.value.manageLocationDtoListIds = [];
|
||||
form.value.manageLocationDtoList = [];
|
||||
}
|
||||
}
|
||||
|
||||
function handleLocationChange(e) {
|
||||
form.value.manageLocationDtoList = []
|
||||
e.forEach(id => {
|
||||
// 使用递归函数查找节点
|
||||
const location = findNodeById(locationOptions.value, id);
|
||||
if (location) {
|
||||
form.value.manageLocationDtoList.push({ orgId: location.id, locationId: location.organizationId });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function handleChange(e) {
|
||||
form.value.responsibilityOrgDtoList = []
|
||||
e.forEach(id => {
|
||||
// 使用递归函数查找节点
|
||||
const OrgDto = findNodeById(deptOptions.value, id);
|
||||
if (OrgDto) {
|
||||
form.value.responsibilityOrgDtoList.push({ orgId: OrgDto.id });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function handleLOrgDtoChange(e) {
|
||||
form.value.doctorVisitOrgDtoList = []
|
||||
e.forEach(id => {
|
||||
// 使用递归函数查找节点
|
||||
const OrgDto = findNodeById(deptOptions.value, id);
|
||||
if (OrgDto) {
|
||||
form.value.doctorVisitOrgDtoList.push({ orgId: OrgDto.id });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function findNodeById(tree, id) {
|
||||
for (const node of tree) {
|
||||
if (node.id === id) {
|
||||
return node;
|
||||
}
|
||||
if (node.children) {
|
||||
const result = findNodeById(node.children, id);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// 自定义校验规则:确保 roleCode 不重复
|
||||
|
||||
Reference in New Issue
Block a user