diff --git a/apps/web-antd/src/store/prescription.ts b/apps/web-antd/src/store/prescription.ts index 07a3d730..37ce411c 100644 --- a/apps/web-antd/src/store/prescription.ts +++ b/apps/web-antd/src/store/prescription.ts @@ -367,8 +367,13 @@ export const usePrescriptionStore = defineStore('prescription', () => { const res = await getRegisterStoreInfoFn(Number(currentRegisterId.value)); registerStoreInfo.value = res; - // 默认选择挂号诊所 - if (res && res.store_id) { + // 如果是转诊挂号,自动使用承接方诊所ID(转接方开处方时) + if (res && res.is_from_transfer === 1 && res.delegate_store_id) { + // 转接方开处方时,自动设置store_id为承接方诊所ID + selectedStoreId.value = res.delegate_store_id; + sendMode.value = 1; // 使用自定义模式,但使用承接方诊所ID + } else if (res && res.store_id) { + // 非转诊挂号,默认选择挂号诊所 selectedStoreId.value = res.store_id; // 如果挂号诊所与医生当前诊所不同,设置为自定义模式 if (res.can_change) { @@ -414,8 +419,13 @@ export const usePrescriptionStore = defineStore('prescription', () => { return currentStoreName.value; }); - // 是否可以更改诊所(使用后端返回的 can_change 字段) + // 是否可以更改诊所(转诊挂号时不允许更改,使用承接方诊所ID) const canChangeStore = computed(() => { + // 如果是转诊挂号,不允许更改诊所(自动使用承接方诊所ID) + if (registerStoreInfo.value?.is_from_transfer === 1) { + return false; + } + // 非转诊挂号,使用后端返回的 can_change 字段 return registerStoreInfo.value?.can_change === true; }); @@ -794,6 +804,16 @@ export const usePrescriptionStore = defineStore('prescription', () => { return false; } try { + // 如果是转诊挂号,自动使用承接方诊所ID(转接方开处方时) + let finalSendMode = customSendMode; + let finalStoreId = customStoreId; + + if (registerStoreInfo.value?.is_from_transfer === 1 && registerStoreInfo.value?.delegate_store_id) { + // 转接方开处方时,自动使用承接方诊所ID,不需要在模态框选择 + finalSendMode = 1; + finalStoreId = registerStoreInfo.value.delegate_store_id; + } + const response = await addWestPrescription({ patient: activePatient.value, drugs: currentDrugs.value, @@ -818,9 +838,9 @@ export const usePrescriptionStore = defineStore('prescription', () => { diseases_id: diseasesSelected.value, method_id: methodSelected.value, syndrome_id: syndromeSelected.value, - // 诊所选择参数(使用传入的参数) - send_mode: customSendMode, - custom_store_id: customSendMode === 1 ? customStoreId : null, + // 诊所选择参数(转诊挂号时自动使用承接方诊所ID) + send_mode: finalSendMode, + custom_store_id: finalSendMode === 1 ? finalStoreId : null, }); const res = await response; diff --git a/apps/web-antd/src/views/business/chat/components/PrescriptionModal.vue b/apps/web-antd/src/views/business/chat/components/PrescriptionModal.vue index 1bdae0f0..632008c3 100644 --- a/apps/web-antd/src/views/business/chat/components/PrescriptionModal.vue +++ b/apps/web-antd/src/views/business/chat/components/PrescriptionModal.vue @@ -213,10 +213,14 @@ const handleSendPrescription = async (doctorSecondSignValue = 0) => { await prescriptionStore.fetchRegisterStoreInfo(); const canChange = prescriptionStore.canChangeStore; + const storeInfo = prescriptionStore.registerStoreInfo; - if (canChange) { + // 如果是转诊挂号,自动使用承接方诊所ID,不需要弹出诊所选择弹窗 + if (storeInfo?.is_from_transfer === 1 && storeInfo?.delegate_store_id) { + // 转接方开处方时,自动使用承接方诊所ID + await executeSendPrescription(doctorSecondSignValue, 1, storeInfo.delegate_store_id); + } else if (canChange) { // 弹出诊所确认弹窗 - 直接从 registerStoreInfo 获取诊所信息 - const storeInfo = prescriptionStore.registerStoreInfo; storeConfirmModalApi.setData({ registerStoreName: storeInfo?.store_name || '挂号诊所', registerStoreId: storeInfo?.store_id,