168 入科分配床位填写的住院医生、主治医生、责任护士字段的内容双击查看未显示。

This commit is contained in:
Ranyunqiao
2026-03-16 10:16:49 +08:00
parent e16a70dd50
commit 53d29cbe14
4 changed files with 277 additions and 92 deletions

View File

@@ -396,20 +396,28 @@ const loadPatientInfo = () => {
if (!props.pendingInfo?.encounterId) {
return;
}
console.log('查询患者信息的 encounterId:', props.pendingInfo.encounterId);
getPatientInfo({ encounterId: props.pendingInfo.encounterId }).then((res) => {
console.log('后端返回的患者信息:', res.data);
pendingInfo.value = res.data;
// 从后端获取数据后设置医生和护士 ID
// 医生使用 ToStringSerializer返回字符串护士直接返回数字
console.log('admittingDoctorId:', res.data.admittingDoctorId);
console.log('attendingDoctorId:', res.data.attendingDoctorId);
console.log('chiefDoctorId:', res.data.chiefDoctorId);
console.log('primaryNurseId:', res.data.primaryNurseId);
if (res.data.admittingDoctorId) {
interventionForm.value.admittingDoctorId = res.data.admittingDoctorId;
interventionForm.value.admittingDoctorId = String(res.data.admittingDoctorId);
}
if (res.data.attendingDoctorId) {
interventionForm.value.attendingDoctorId = res.data.attendingDoctorId;
interventionForm.value.attendingDoctorId = String(res.data.attendingDoctorId);
}
if (res.data.chiefDoctorId) {
interventionForm.value.chiefDoctorId = res.data.chiefDoctorId;
interventionForm.value.chiefDoctorId = String(res.data.chiefDoctorId);
}
if (res.data.primaryNurseId) {
interventionForm.value.primaryNurseId = res.data.primaryNurseId;
// 护士ID也转换为字符串以匹配护士选项
interventionForm.value.primaryNurseId = String(res.data.primaryNurseId);
}
if (res.data.startTime) {
interventionForm.value.startTime = dayjs(res.data.startTime).format(
@@ -435,21 +443,23 @@ const loadPatientInfo = () => {
watch(
() => props.pendingInfo?.encounterId,
(newVal, oldVal) => {
// 只在 encounterId 存在且发生变化时才获取数据
if (newVal && newVal !== oldVal) {
// encounterId 存在时就获取数据
if (newVal) {
console.log('watch 触发, newVal:', newVal, 'oldVal:', oldVal);
loadPatientInfo();
}
},
{ immediate: true }
}
);
/* 初始化数据 */
const init = () => {
initCurrentInPatient();
getInit()
const promises = [];
const initPromise = getInit()
.then((res) => {
InitInfoOptions.value = res.data;
// 安全地设置priorityListOptions
if (res.data && res.data.priorityListOptions) {
priorityListOptions.value = res.data.priorityListOptions;
}
@@ -457,9 +467,10 @@ const init = () => {
.catch((error) => {
console.error('获取初始化数据失败:', error);
});
promises.push(initPromise);
if (props.pendingInfo.wardLocationId) {
getBedInfo({ wardLocationId: props.pendingInfo.wardLocationId })
const bedPromise = getBedInfo({ wardLocationId: props.pendingInfo.wardLocationId })
.then((res) => {
bedInfoOptions.value = res.data || [];
})
@@ -467,44 +478,55 @@ const init = () => {
console.error('获取床位信息失败:', error);
bedInfoOptions.value = [];
});
promises.push(bedPromise);
}
if (props.pendingInfo.organizationId) {
// 主任医生
getDoctorInfo({ organizationId: props.pendingInfo.organizationId })
const doctorPromise = getDoctorInfo({ organizationId: props.pendingInfo.organizationId })
.then((res) => {
doctorInfoOptions.value = res.data.records || [];
nextTick(() => {
// 如果存在主任医师显示主任,如果没有选择第一个展示
if (doctorInfoOptions.value.length > 0) {
let selectId = '';
doctorInfoOptions.value.forEach((item: any) => {
if (item.drProfttlCode == '231') {
selectId = item.id;
// 只有在新分配床位模式entranceType != 1时才设置默认主任医生
// 并且只在当前没有选择主任医生时才设置默认值(避免覆盖已从后端获取的数据)
if (props.pendingInfo.entranceType != 1) {
nextTick(() => {
if (doctorInfoOptions.value.length > 0 && !interventionForm.value.chiefDoctorId) {
let selectId = '';
doctorInfoOptions.value.forEach((item: any) => {
if (item.drProfttlCode == '231') {
selectId = item.id;
}
});
if (selectId.length > 0) {
interventionForm.value.chiefDoctorId = selectId;
} else {
interventionForm.value.chiefDoctorId = doctorInfoOptions.value[0].id;
}
});
if (selectId.length > 0) {
interventionForm.value.chiefDoctorId = selectId;
} else {
interventionForm.value.chiefDoctorId = doctorInfoOptions.value[0].id;
}
}
});
});
}
})
.catch((error) => {
console.error('获取医生信息失败:', error);
doctorInfoOptions.value = [];
});
promises.push(doctorPromise);
getNurseInfo({ organizationId: props.pendingInfo.organizationId })
const nursePromise = getNurseInfo({ organizationId: props.pendingInfo.organizationId })
.then((res) => {
nurseInfoOptions.value = res.data || [];
// 将护士ID转换为字符串以匹配医生选项的数据类型
nurseInfoOptions.value = (res.data || []).map((item: any) => ({
...item,
practitionerId: String(item.practitionerId),
}));
})
.catch((error) => {
console.error('获取护士信息失败:', error);
nurseInfoOptions.value = [];
});
promises.push(nursePromise);
}
return Promise.all(promises);
};
const rules = reactive<FormRules>({
@@ -544,16 +566,27 @@ const handleSubmit = async () => {
try {
const valid = await interventionFormRef.value.validate();
if (valid) {
// 过滤掉空字符串的字段,只保留用户实际选择的值
const formData = {};
Object.keys(interventionForm.value).forEach(key => {
const value = interventionForm.value[key];
// 保留非空的值0、false等有效值也需要保留
if (value !== '' && value !== null && value !== undefined) {
formData[key] = value;
}
});
const params = {
...pendingInfo.value,
...interventionForm.value,
...formData,
targetBedId: props.pendingInfo.bedId,
busNo: props.pendingInfo.busNo,
inHosTime: props.pendingInfo.inHosTime,
targetHouseId: props.pendingInfo.targetHouseId,
targetEncounterId: props.pendingInfo.targetEncounterId,
editFlag: props.pendingInfo.entranceType == 1 ? 1 : 0,
editFlag: props.pendingInfo.entranceType == 1 ? '1' : '0',
};
console.log('提交参数:', params);
console.log('startTime:', interventionForm.value.startTime);
bedAssignment(params)
.then((res: any) => {
@@ -583,9 +616,10 @@ const handleSubmit = async () => {
};
const openAct = () => {
init();
// 重新加载患者详细信息(包括医生、护士等)
loadPatientInfo();
// 先初始化数据(包括医生护士列表),等待完成后再加载患者信息
init().then(() => {
loadPatientInfo();
});
};
const closedAct = () => {