feat(organization): 支持科室分类多选功能

- 修改前端界面组件支持科室分类多选下拉框
- 更新后端接口参数类型从Integer改为String以支持多选值
- 实现FIND_IN_SET查询方式处理多选分类条件
- 添加parseClassEnumValues函数处理字符串或数组格式转换
- 在医院住院对话框中扩展筛选条件支持多选分类
- 优化错误信息显示逻辑提供更详细的错误提示
- 在患者列表组件中添加入院日期和主治医生信息展示
- 修复多个服务调用中科室分类参数传递的数据类型问题
This commit is contained in:
2026-01-18 13:39:57 +08:00
parent 2fe6d45ad4
commit 59157fda56
19 changed files with 216 additions and 47 deletions

View File

@@ -23,7 +23,7 @@ public interface IOrganizationAppService {
* @param request 请求数据
* @return 机构树分页列表
*/
Page<OrganizationDto> getOrganizationTree(Integer pageNo, Integer pageSize, String name, Integer typeEnum, Integer classEnum,
Page<OrganizationDto> getOrganizationTree(Integer pageNo, Integer pageSize, String name, Integer typeEnum, String classEnum,
String sortField, String sortOrder, HttpServletRequest request);
/**

View File

@@ -39,7 +39,7 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService {
private AssignSeqUtil assignSeqUtil;
@Override
public Page<OrganizationDto> getOrganizationTree(Integer pageNo, Integer pageSize, String name, Integer typeEnum, Integer classEnum,
public Page<OrganizationDto> getOrganizationTree(Integer pageNo, Integer pageSize, String name, Integer typeEnum, String classEnum,
String sortField, String sortOrder, HttpServletRequest request) {
// 创建查询条件
LambdaQueryWrapper<Organization> queryWrapper = new LambdaQueryWrapper<>();
@@ -51,8 +51,14 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService {
if (typeEnum != null) {
queryWrapper.eq(Organization::getTypeEnum, typeEnum);
}
if (classEnum != null) {
queryWrapper.eq(Organization::getClassEnum, classEnum);
if (StringUtils.isNotEmpty(classEnum)) {
// 对于多选,需要处理逗号分隔的值
queryWrapper.and(wrapper -> {
String[] classEnums = classEnum.split(",");
for (String cls : classEnums) {
wrapper.or().apply("FIND_IN_SET(?, class_enum)", cls.trim());
}
});
}
// 创建Page对象
@@ -89,7 +95,7 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService {
OrganizationDto node = new OrganizationDto();
BeanUtils.copyProperties(record, node);
node.setTypeEnum_dictText(EnumUtils.getInfoByValue(OrganizationType.class, node.getTypeEnum()));
node.setClassEnum_dictText(EnumUtils.getInfoByValue(OrganizationClass.class, node.getClassEnum()));
node.setClassEnum_dictText(formatClassEnumDictText(node.getClassEnum()));
node.setActiveFlag_dictText(EnumUtils.getInfoByValue(AccountStatus.class, node.getActiveFlag()));
// 将当前节点加入映射
nodeMap.put(bNo, node);
@@ -130,7 +136,7 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService {
OrganizationDto organizationDto = new OrganizationDto();
BeanUtils.copyProperties(organization, organizationDto);
organizationDto.setTypeEnum_dictText(EnumUtils.getInfoByValue(OrganizationType.class, organizationDto.getTypeEnum()));
organizationDto.setClassEnum_dictText(EnumUtils.getInfoByValue(OrganizationClass.class, organizationDto.getClassEnum()));
organizationDto.setClassEnum_dictText(formatClassEnumDictText(organizationDto.getClassEnum()));
organizationDto.setActiveFlag_dictText(EnumUtils.getInfoByValue(AccountStatus.class, organizationDto.getActiveFlag()));
return R.ok(organizationDto, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"机构信息查询"}));
@@ -221,6 +227,35 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService {
: R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[] {"机构信息停用"}));
}
/**
* 格式化多选的分类字典文本
*/
private String formatClassEnumDictText(String classEnum) {
if (StringUtils.isEmpty(classEnum)) {
return "";
}
String[] classEnums = classEnum.split(",");
List<String> dictTexts = new ArrayList<>();
for (String cls : classEnums) {
String trimmedCls = cls.trim();
if (StringUtils.isNotEmpty(trimmedCls)) {
try {
Integer enumValue = Integer.parseInt(trimmedCls);
String dictText = EnumUtils.getInfoByValue(OrganizationClass.class, enumValue);
if (dictText != null) {
dictTexts.add(dictText);
}
} catch (NumberFormatException e) {
// 如果转换失败,跳过该值
}
}
}
return String.join(",", dictTexts);
}
/**
* 校验字段是否为指定类中的有效属性
*/

View File

@@ -54,7 +54,7 @@ public class OrganizationController {
@RequestParam(value = "pageSize", defaultValue = "100") Integer pageSize,
@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "typeEnum", required = false) Integer typeEnum,
@RequestParam(value = "classEnum", required = false) Integer classEnum,
@RequestParam(value = "classEnum", required = false) String classEnum,
@RequestParam(value = "sortField", required = false) String sortField,
@RequestParam(value = "sortOrder", required = false) String sortOrder, HttpServletRequest request) {
Page<OrganizationDto> organizationTree =

View File

@@ -3,6 +3,7 @@
*/
package com.openhis.web.basedatamanage.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
@@ -39,7 +40,8 @@ public class OrganizationDto {
private String typeEnum_dictText;
/** 机构分类枚举 */
private Integer classEnum;
@JsonFormat(shape = JsonFormat.Shape.STRING)
private String classEnum;
private String classEnum_dictText;
/** 拼音码 */

View File

@@ -157,7 +157,7 @@ public class OutpatientRegistrationAppServiceImpl implements IOutpatientRegistra
@Override
public List<OrgMetadata> getOrgMetadata() {
List<Organization> list =
iOrganizationService.getList(OrganizationType.DEPARTMENT.getValue(), OrganizationClass.CLINIC.getValue());
iOrganizationService.getList(OrganizationType.DEPARTMENT.getValue(), String.valueOf(OrganizationClass.CLINIC.getValue()));
List<OrgMetadata> orgMetadataList = new ArrayList<>();
OrgMetadata orgMetadata;
for (Organization organization : list) {

View File

@@ -187,7 +187,7 @@ public class PatientHomeAppServiceImpl implements IPatientHomeAppService {
@Override
public List<OrgMetadata> getCaty() {
List<Organization> list = iOrganizationService.getList(OrganizationType.DEPARTMENT.getValue(),
OrganizationClass.INPATIENT.getValue());
OrganizationClass.INPATIENT.getCode());
List<OrgMetadata> orgMetadataList = new ArrayList<>();
OrgMetadata orgMetadata;
for (Organization organization : list) {

View File

@@ -94,7 +94,7 @@ public class MedicalDeviceDispenseAppServiceImpl implements IMedicalDeviceDispen
// 获取科室下拉选列表
List<Organization> organizationList
= organizationService.getList(OrganizationType.DEPARTMENT.getValue(), OrganizationClass.CLINIC.getValue());
= organizationService.getList(OrganizationType.DEPARTMENT.getValue(), String.valueOf(OrganizationClass.CLINIC.getValue()));
List<DispenseInitDto.DepartmentOption> organizationOptions = organizationList.stream()
.map(organization -> new DispenseInitDto.DepartmentOption(organization.getId(), organization.getName()))
.collect(Collectors.toList());

View File

@@ -130,7 +130,7 @@ public class ReturnMedicineAppServiceImpl implements IReturnMedicineAppService {
// 获取科室下拉选列表
List<Organization> organizationList
= iOrganizationService.getList(OrganizationType.DEPARTMENT.getValue(), OrganizationClass.CLINIC.getValue());
= iOrganizationService.getList(OrganizationType.DEPARTMENT.getValue(), String.valueOf(OrganizationClass.CLINIC.getValue()));
List<ReturnMedicineInitDto.DepartmentOption> organizationOptions = organizationList.stream().map(
organization -> new ReturnMedicineInitDto.DepartmentOption(organization.getId(), organization.getName()))
.collect(Collectors.toList());

View File

@@ -127,7 +127,7 @@ public class WesternMedicineDispenseAppServiceImpl implements IWesternMedicineDi
// 获取科室下拉选列表
List<Organization> organizationList
= organizationService.getList(OrganizationType.DEPARTMENT.getValue(), OrganizationClass.CLINIC.getValue());
= organizationService.getList(OrganizationType.DEPARTMENT.getValue(), String.valueOf(OrganizationClass.CLINIC.getValue()));
List<DispenseInitDto.DepartmentOption> organizationOptions = organizationList.stream()
.map(organization -> new DispenseInitDto.DepartmentOption(organization.getId(), organization.getName()))
.collect(Collectors.toList());

View File

@@ -52,7 +52,7 @@ public class RegisterReportAppServiceImpl implements IRegisterReportAppService {
RegisterReportInitDto initDto = new RegisterReportInitDto();
// 查询科室列表
List<Organization> organizationList =
organizationService.getList(OrganizationType.DEPARTMENT.getValue(), OrganizationClass.CLINIC.getValue());
organizationService.getList(OrganizationType.DEPARTMENT.getValue(), String.valueOf(OrganizationClass.CLINIC.getValue()));
// 科室
List<RegisterReportInitDto.longCommonStatusOption> departmentOptions = organizationList.stream()
.map(organization -> new RegisterReportInitDto.longCommonStatusOption(organization.getId(),

View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.core.common.core.domain.HisBaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
@@ -40,7 +41,8 @@ public class Organization extends HisBaseEntity {
private Integer typeEnum;
/** 机构分类枚举 */
private Integer classEnum;
@JsonFormat(shape = JsonFormat.Shape.STRING)
private String classEnum;
/** 拼音码 */
private String pyStr;

View File

@@ -37,7 +37,7 @@ public interface IOrganizationService extends IService<Organization> {
* @param organizationClass 机构分类
* @return 机构下拉列表
*/
List<Organization> getList(Integer organizationType, Integer organizationClass);
List<Organization> getList(Integer organizationType, String organizationClass);
/**
* 根据id查询科室集合

View File

@@ -61,12 +61,19 @@ public class OrganizationServiceImpl extends ServiceImpl<OrganizationMapper, Org
* @return 机构下拉列表
*/
@Override
public List<Organization> getList(Integer organizationType, Integer organizationClass) {
return baseMapper.selectList(new LambdaQueryWrapper<Organization>()
public List<Organization> getList(Integer organizationType, String organizationClass) {
LambdaQueryWrapper<Organization> queryWrapper = new LambdaQueryWrapper<Organization>()
.select(Organization::getId, Organization::getName, Organization::getDisplayOrder)
.eq(Organization::getTypeEnum, organizationType)
.eq(organizationClass != null, Organization::getClassEnum, organizationClass)
.orderByAsc(Organization::getDisplayOrder)); // 按 displayOrder 升序排序
.orderByAsc(Organization::getDisplayOrder); // 按 displayOrder 升序排序
// 如果organizationClass不为null则添加查询条件
if (organizationClass != null) {
// 支持多选值使用FIND_IN_SET进行查询
queryWrapper.apply("FIND_IN_SET({0}, class_enum)", organizationClass.toString());
}
return baseMapper.selectList(queryWrapper);
}
/**

View File

@@ -93,6 +93,16 @@
</el-tag>
</div>
</div>
<!-- 添加入院日期等关键信息 -->
<div class="admission-info" v-if="item.admissionDate">
<span class="admission-date">入院日期{{ item.admissionDate }}</span>
</div>
<!-- 添加主治医生信息 -->
<div class="attending-doctor" v-if="item.attendingDoctorName">
<span class="doctor-name">主管医生{{ item.attendingDoctorName }}</span>
</div>
</div>
</div>
</div>
@@ -456,7 +466,9 @@ watch(
padding: 8px 12px 10px;
.personal-info-container {
display: block;
display: flex;
flex-direction: column;
gap: 4px;
.name-container {
display: flex;
@@ -469,6 +481,10 @@ watch(
color: #111827;
font-weight: 600;
font-size: 16px;
flex: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.age {
@@ -485,6 +501,19 @@ watch(
}
}
}
.admission-info, .attending-doctor {
display: flex;
font-size: 12px;
color: #6b7280;
margin-top: 2px;
.admission-date, .doctor-name {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
}
}
}
}

View File

@@ -22,7 +22,7 @@
</el-select>
</el-form-item>
<el-form-item label="科室分类" prop="classEnum">
<el-select v-model="queryParams.classEnum" placeholder="请选择科室分类" clearable style="width: 200px">
<el-select v-model="queryParams.classEnum" placeholder="请选择科室分类" clearable multiple style="width: 200px">
<el-option
v-for="item in classEnumOption"
:key="item.value"
@@ -75,7 +75,21 @@
<el-table-column type="selection" width="55" />
<el-table-column label="科室名称" align="left" prop="name" />
<el-table-column label="科室类型" align="center" prop="typeEnum_dictText" />
<el-table-column label="科室分类" align="center" prop="classEnum_dictText" />
<el-table-column label="科室分类" align="center">
<template #default="scope">
<span v-if="scope.row.classEnum_dictText">
<el-tag
v-for="item in scope.row.classEnum_dictText.split(',')"
:key="item"
size="small"
style="margin-right: 2px;"
>
{{ item }}
</el-tag>
</span>
<span v-else></span>
</template>
</el-table-column>
<el-table-column label="医保码" align="center" prop="ybNo" />
<el-table-column label="医保名称" align="center" prop="ybName" />
<el-table-column label="挂号科室" align="center">
@@ -154,6 +168,7 @@
v-model="form.classEnum"
placeholder="请选择科室分类"
clearable
multiple
style="width: 100%"
:disabled="form.typeEnum != 2"
>
@@ -353,6 +368,21 @@ function getDictLabel(value) {
return dict ? dict.label : '';
}
// 解析科室分类值,处理字符串或数组格式
function parseClassEnumValues(value) {
if (!value) return [];
if (Array.isArray(value)) {
return value.filter(item => item !== null && item !== undefined && item !== '');
} else if (typeof value === 'string') {
// 如果是逗号分隔的字符串,分割并过滤空值
return value.split(',').map(item => item.trim()).filter(item => item !== '');
} else {
// 如果是单个值,转换为字符串
return [String(value)].filter(item => item !== '');
}
}
/** 搜索按钮操作 */
function handleQuery() {
queryParams.value.pageNo = 1;
@@ -378,11 +408,18 @@ function getPageList() {
// 如果系统标准字典存在,尝试使用字典中的文本覆盖原有文本
if (organization_class.value && organization_class.value.length > 0) {
const dictLabel = getDictLabel(item.classEnum);
// 处理多选值的情况
let newText = '';
if (item.classEnum) {
// 如果classEnum是逗号分隔的字符串则处理每个值
const classEnumValues = parseClassEnumValues(item.classEnum);
const labels = classEnumValues.map(val => getDictLabel(val)).filter(label => label);
newText = labels.join(',');
}
// 只有在字典中找到匹配值时才替换,否则保留原有文本
return {
...item,
classEnum_dictText: dictLabel || originalText
classEnum_dictText: newText || originalText
};
}
return item;
@@ -423,8 +460,16 @@ function handelEdit(row) {
form.value.ybNo = orgInfo.ybNo;
form.value.ybName = orgInfo.ybName;
form.value.typeEnum = orgInfo.typeEnum;
// 确保科室分类值的类型正确,使其能正确匹配下拉选项中的值
form.value.classEnum = orgInfo.classEnum !== undefined ? String(orgInfo.classEnum) : undefined;
// 处理多选的科室分类,如果是逗号分隔的字符串则转换为数组
if (orgInfo.classEnum) {
if (typeof orgInfo.classEnum === 'string' && orgInfo.classEnum.includes(',')) {
form.value.classEnum = orgInfo.classEnum.split(',').map(item => item.trim());
} else {
form.value.classEnum = [String(orgInfo.classEnum)];
}
} else {
form.value.classEnum = [];
}
form.value.busNoParent = orgInfo.busNo.split('.').length > 1 ? orgInfo.busNo.split('.')[0] : undefined;
form.value.registerFlag = !!orgInfo.registerFlag;
form.value.location = orgInfo.location;
@@ -452,14 +497,15 @@ function submitForm() {
// 确保registerFlag从布尔值转换为整数true=1, false=0
formData.registerFlag = Number(formData.registerFlag ? 1 : 0);
// 确保classEnum字段有值数据库必填
// 如果未定义设置默认值1
if (formData.classEnum === undefined || formData.classEnum === null || formData.classEnum === '') {
formData.classEnum = 1;
// 处理多选的科室分类,如果是数组则转换为逗号分隔的字符串
if (Array.isArray(formData.classEnum)) {
formData.classEnum = formData.classEnum.length > 0 ? formData.classEnum.join(',') : null;
}
// 确保classEnum为数字类型
formData.classEnum = Number(formData.classEnum);
// 如果未定义设置默认值1
if (formData.classEnum === undefined || formData.classEnum === null || formData.classEnum === '') {
formData.classEnum = null;
}
// 验证提交数据
console.log('提交的数据:', formData);

View File

@@ -257,8 +257,11 @@ function openDialog() {
const flattenTree = (nodes) => {
let result = [];
nodes.forEach(node => {
// 检查当前节点是否符合条件
if (node && node.typeEnum === 2 && node.classEnum === 2) {
// 检查当前节点是否符合条件 - 扩展筛选条件
if (node &&
node.typeEnum === 2 && // 科室类型
checkClassEnumValue(node.classEnum, 2) && // 住院类别(支持多选)
node.activeFlag !== 0) { // 活跃状态(非停用)
result.push(node);
}
// 递归处理子节点
@@ -288,7 +291,9 @@ function openDialog() {
}).catch(error => {
console.error('获取组织机构数据失败:', error);
organization.value = [];
proxy.$modal.msgError('获取组织机构数据失败,请稍后重试');
// 显示详细的错误信息
const errorMessage = error.message || error.msg || '获取组织机构数据失败,请稍后重试';
proxy.$modal.msgError(errorMessage);
});
// 获取初始化数据
@@ -338,7 +343,9 @@ function handleNodeClick(orgInfo) {
console.error('获取病区列表失败:', error);
wardListOptions.value = [];
submitForm.wardLocationId = undefined;
proxy.$modal.msgError('获取病区列表失败,请稍后重试');
// 显示详细的错误信息
const errorMessage = error.message || error.msg || '获取病区列表失败,请稍后重试';
proxy.$modal.msgError(errorMessage);
});
} else {
wardListOptions.value = [];
@@ -402,13 +409,22 @@ function submit() {
}
}).catch(error => {
console.error('提交出错:', error);
let errorMsg = '提交请求失败';
// 构建详细的错误信息
let errorMsg = '办理住院过程中发生错误';
if (error.response) {
errorMsg += ` (${error.response.status}): ${error.response.data.message || error.response.statusText}`;
} else if (error.request) {
errorMsg += ': 网络请求失败,请检查网络连接';
// 如果后端返回了具体错误信息,优先使用
if (error.response.data && error.response.data.message) {
errorMsg = error.response.data.message;
} else if (error.response.data) {
// 如果响应体中有其他可读信息
errorMsg = typeof error.response.data === 'string' ? error.response.data : `${errorMsg} (${error.response.status})`;
} else {
errorMsg += `: ${error.message}`;
errorMsg = `${errorMsg} (${error.response.status}): ${error.response.statusText}`;
}
} else if (error.request) {
errorMsg = '网络请求失败,请检查网络连接';
} else {
errorMsg = error.message || errorMsg;
}
proxy.$modal.msgError(errorMsg);
}).finally(() => {
@@ -424,6 +440,20 @@ function submit() {
function close() {
emit('close');
}
// 检查classEnum值是否包含指定值支持多选
function checkClassEnumValue(classEnum, targetValue) {
if (!classEnum) return false;
// 如果是字符串且包含逗号,说明是多选值
if (typeof classEnum === 'string' && classEnum.includes(',')) {
const values = classEnum.split(',').map(v => v.trim());
return values.some(v => v == targetValue);
}
// 单个值的情况
return classEnum == targetValue;
}
</script>
<style lang="scss" scoped>

View File

@@ -225,7 +225,7 @@ import {formatDate, formatDateStr} from '@/utils/index';
import useUserStore from '@/store/modules/user';
import {nextTick} from 'vue';
import {updatePatientInfo} from './components/store/patient.js';
import {ElMessage} from 'element-plus';
import {ElMessage, ElMessageBox} from 'element-plus';
// // 监听路由离开事件
// onBeforeRouteLeave((to, from, next) => {
@@ -707,9 +707,12 @@ const onHospitalization = async () => {
}
} catch (error) {
console.error('办理住院检查过程中发生错误:', error);
// 显示详细的错误信息
const errorMessage = error.message || error.msg || '办理住院过程中发生错误,请稍后重试!';
ElMessage({
type: 'error',
message: '办理住院过程中发生错误,请稍后重试!',
message: errorMessage,
duration: 5000 // 增加显示时长以便用户阅读
});
}
};

View File

@@ -426,7 +426,7 @@ function getInitOptions() {
getOrgList().then((res) => {
// organization.value = res.data.records
organization.value = res.data.records[0].children.filter(
(record) => record.typeEnum === 2 && record.classEnum === 2
(record) => record.typeEnum === 2 && checkClassEnumValue(record.classEnum, 2)
);
});
// if (!props.noFile) {
@@ -537,6 +537,21 @@ const init = () => {
submitForm.wardLocationId = '';
}
};
// 检查classEnum值是否包含指定值支持多选
function checkClassEnumValue(classEnum, targetValue) {
if (!classEnum) return false;
// 如果是字符串且包含逗号,说明是多选值
if (typeof classEnum === 'string' && classEnum.includes(',')) {
const values = classEnum.split(',').map(v => v.trim());
return values.some(v => v == targetValue);
}
// 单个值的情况
return classEnum == targetValue;
}
defineExpose({ validateData, submitForm, init, medicalInsuranceTitle });
</script>
<style lang="scss" scoped>

View File

@@ -195,7 +195,7 @@
<!-- 新增或修改手术对话框 -->
<el-dialog :title="title" v-model="open" width="800px" @close="cancel" append-to-body :close-on-click-modal="false">
<!-- 编辑模式下显示当前状态 -->
<!-- 编辑模式下显示当前状态 -->ElMessageBox is not defined
<el-alert v-if="isEditMode && form.statusEnum !== undefined" :title="'当前状态: ' + getStatusText(form.statusEnum)" :type="getStatusType(form.statusEnum)" :closable="false" style="margin-bottom: 20px;" />
<!-- 查看模式下显示提示 -->
<el-alert v-if="isViewMode" title="当前为查看模式,所有字段均为只读状态" type="info" :closable="false" style="margin-bottom: 20px;" />