fix(doctorstation): 解决参数验证和数据获取问题
- 在前端api.js中添加encounterId参数验证,避免无效参数导致的错误 - 在后端服务层添加参数检查,当encounterId为空时返回空数据而非报错 - 修改控制器参数注解,将required设置为false以允许空值传递 - 优化住院办理流程中的错误处理和参数验证 - 改进检验申请单获取时的数据验证和错误提示 - 更新maven编译器插件版本并添加必要的模块参数 - 统一错误处理机制,提供更友好的用户提示信息
This commit is contained in:
@@ -244,21 +244,32 @@ const rules = reactive({
|
||||
function openDialog() {
|
||||
console.log('orgId==========>', props.patientInfo.orgId);
|
||||
getOrgList().then((res) => {
|
||||
// organization.value = res.data.records;
|
||||
organization.value = res.data.records[0].children.filter(
|
||||
(record) => record.typeEnum === 2 && record.classEnum === 2
|
||||
);
|
||||
// 确保数据结构正确
|
||||
if (res.data && res.data.records && res.data.records.length > 0) {
|
||||
// 获取第一层级的子节点,筛选出类型为科室(typeEnum===2)且类别为住院(classEnum===2)的组织
|
||||
const firstLevelChildren = res.data.records[0]?.children || [];
|
||||
organization.value = firstLevelChildren.filter(
|
||||
(record) => record.typeEnum === 2 && record.classEnum === 2
|
||||
);
|
||||
|
||||
// 如果当前患者所属科室在筛选结果中,则默认选中
|
||||
if (props.patientInfo.orgId) {
|
||||
submitForm.inHospitalOrgId =
|
||||
organization.value.find((item) => item.id === props.patientInfo.orgId)?.id || '';
|
||||
}
|
||||
} else {
|
||||
organization.value = [];
|
||||
}
|
||||
|
||||
console.log('organization==========>', organization.value);
|
||||
submitForm.inHospitalOrgId =
|
||||
organization.value.find((item) => item.id === props.patientInfo.orgId)?.id || '';
|
||||
});
|
||||
|
||||
// wardList().then((res) => {
|
||||
// wardListOptions.value = res.data;
|
||||
// });
|
||||
// 获取初始化数据
|
||||
getInit().then((response) => {
|
||||
console.log(response, 'response');
|
||||
priorityLevelOptionOptions.value = response.data.priorityLevelOptionOptions; // 优先级
|
||||
if (response.data && response.data.priorityLevelOptionOptions) {
|
||||
priorityLevelOptionOptions.value = response.data.priorityLevelOptionOptions; // 优先级
|
||||
}
|
||||
});
|
||||
console.log(props.patientInfo, 'patientInfo');
|
||||
getDiagnosisInfo(undefined);
|
||||
@@ -268,6 +279,7 @@ function openDialog() {
|
||||
diagnosisDefinitionId = props.mainDiagnosis.definitionId;
|
||||
diagnosisYbNo = props.mainDiagnosis.ybNo || '';
|
||||
submitForm.medTypeCode = props.mainDiagnosis.medTypeCode;
|
||||
submitForm.diagnosisDesc = props.mainDiagnosis.name || ''; // 设置诊断描述
|
||||
diagnosisDefinitionList.value = [props.mainDiagnosis];
|
||||
}
|
||||
}
|
||||
@@ -284,21 +296,53 @@ function handleDiagnosisChange(item) {
|
||||
}
|
||||
|
||||
function handleNodeClick(orgInfo) {
|
||||
wardList({ orgId: orgInfo.id }).then((res) => {
|
||||
wardListOptions.value = res.data;
|
||||
});
|
||||
// 确保传入正确的科室ID
|
||||
if (orgInfo && orgInfo.id) {
|
||||
wardList({ orgId: orgInfo.id }).then((res) => {
|
||||
if (res && res.data) {
|
||||
wardListOptions.value = res.data;
|
||||
// 清空之前选择的病区
|
||||
submitForm.wardLocationId = undefined;
|
||||
} else {
|
||||
wardListOptions.value = [];
|
||||
submitForm.wardLocationId = undefined;
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('获取病区列表失败:', error);
|
||||
wardListOptions.value = [];
|
||||
submitForm.wardLocationId = undefined;
|
||||
proxy.$modal.msgError('获取病区列表失败,请稍后重试');
|
||||
});
|
||||
} else {
|
||||
wardListOptions.value = [];
|
||||
submitForm.wardLocationId = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function handleChange(value) {
|
||||
if (!value) {
|
||||
wardListOptions.value = [];
|
||||
submitForm.wardLocationId = undefined;
|
||||
} else {
|
||||
// 当选择新科室时,清空病区选择
|
||||
submitForm.wardLocationId = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function submit() {
|
||||
proxy.$refs['registerRef'].validate((valid) => {
|
||||
if (valid) {
|
||||
// 验证必要字段
|
||||
if (!props.patientInfo.patientId) {
|
||||
proxy.$modal.msgError('患者信息不完整,无法办理住院');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!props.encounterId && !props.patientInfo.encounterId) {
|
||||
proxy.$modal.msgError('就诊信息不完整,无法办理住院');
|
||||
return;
|
||||
}
|
||||
|
||||
let saveData = {
|
||||
...submitForm,
|
||||
diagnosisYbNo: diagnosisYbNo,
|
||||
@@ -307,7 +351,12 @@ function submit() {
|
||||
ambEncounterId: props.encounterId || props.patientInfo.encounterId,
|
||||
patientId: props.patientInfo.patientId,
|
||||
};
|
||||
|
||||
console.log('提交住院数据:', saveData);
|
||||
|
||||
// 显示加载状态
|
||||
const loading = proxy.$modal.loading('正在办理住院...');
|
||||
|
||||
handleHospitalization(saveData).then((res) => {
|
||||
if (res.code == 200) {
|
||||
proxy.$modal.msgSuccess('办理成功');
|
||||
@@ -318,7 +367,18 @@ function submit() {
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error('提交出错:', error);
|
||||
proxy.$modal.msgError('提交请求失败');
|
||||
let errorMsg = '提交请求失败';
|
||||
if (error.response) {
|
||||
errorMsg += ` (${error.response.status}): ${error.response.data.message || error.response.statusText}`;
|
||||
} else if (error.request) {
|
||||
errorMsg += ': 网络请求失败,请检查网络连接';
|
||||
} else {
|
||||
errorMsg += `: ${error.message}`;
|
||||
}
|
||||
proxy.$modal.msgError(errorMsg);
|
||||
}).finally(() => {
|
||||
// 关闭加载状态
|
||||
proxy.$modal.closeLoading();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user