From 7f2ed4b30a48b613e91717848e5323664ab8d8ce Mon Sep 17 00:00:00 2001 From: lq Date: Thu, 25 Dec 2025 14:27:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20OSS=E5=AE=A2=E6=88=B7=E7=AB=AF=E7=9B=B4?= =?UTF-8?q?=E4=BC=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/store/prescription.ts | 92 +++++++++++++++- .../chat/components/PrescriptionModal.vue | 51 +++++++++ .../chat/components/StoreConfirmModal.vue | 104 ++++++++++++++++++ .../doctor/online-consultation/api/index.ts | 10 ++ 4 files changed, 256 insertions(+), 1 deletion(-) create mode 100644 apps/web-antd/src/views/business/chat/components/StoreConfirmModal.vue diff --git a/apps/web-antd/src/store/prescription.ts b/apps/web-antd/src/store/prescription.ts index 5322d8ef..6d21ec54 100644 --- a/apps/web-antd/src/store/prescription.ts +++ b/apps/web-antd/src/store/prescription.ts @@ -16,6 +16,7 @@ import { getProcessRuleList, getProductListDoctorReception, } from '#/views/doctor/doctor-reception/api'; +import { getRegisterStoreInfo } from '#/views/doctor/online-consultation/api'; import traditionalJson from '#/views/business/chat/config/traditional.json'; export const usePrescriptionStore = defineStore('prescription', () => { @@ -79,6 +80,11 @@ export const usePrescriptionStore = defineStore('prescription', () => { const methodSelected = ref(); const syndromeSelected = ref(); + // 诊所选择相关状态 + const registerStoreInfo = ref(null); // 挂号诊所信息 + const selectedStoreId = ref(null); // 用户选择的诊所ID + const sendMode = ref(0); // 0=默认(使用医生当前诊所),1=自定义(使用挂号诊所) + // 获取localStorage key(修改为在线复诊前缀) const getStorageKey = () => `onlineConsultation-prescriptionData${currentRegisterId.value}`; @@ -291,6 +297,68 @@ export const usePrescriptionStore = defineStore('prescription', () => { } }; + // 获取挂号诊所信息(同时包含当前诊所信息) + const fetchRegisterStoreInfo = async () => { + if (!currentRegisterId.value) { + console.warn('currentRegisterId为空,无法获取挂号诊所信息'); + return; + } + try { + const res = await getRegisterStoreInfo(Number(currentRegisterId.value)); + registerStoreInfo.value = res; + + // 默认选择挂号诊所 + if (res && res.store_id) { + selectedStoreId.value = res.store_id; + // 如果挂号诊所与医生当前诊所不同,设置为自定义模式 + if (res.can_change) { + sendMode.value = 1; + } else { + sendMode.value = 0; + } + } + console.log('获取挂号诊所信息成功:', res); + } catch (error) { + console.error('获取挂号诊所信息失败:', error); + } + }; + + // 切换诊所选择 + const toggleStoreSelection = (useRegisterStore: boolean) => { + if (useRegisterStore && registerStoreInfo.value?.store_id) { + selectedStoreId.value = registerStoreInfo.value.store_id; + sendMode.value = 1; + } else { + selectedStoreId.value = null; + sendMode.value = 0; + } + }; + + // 计算当前诊所名称(医生所属诊所,优先使用后端返回的数据) + const currentStoreName = computed(() => { + // 优先使用后端返回的当前诊所名称 + if (registerStoreInfo.value?.current_store_name) { + return registerStoreInfo.value.current_store_name; + } + // 回退到本地诊所列表 + const currentStore = myStoreList.value.find((s: any) => s.id === myStoreId.value); + return currentStore?.name || '当前诊所'; + }); + + // 计算目标诊所名称(根据发送模式决定) + const targetStoreName = computed(() => { + if (sendMode.value === 1 && registerStoreInfo.value?.store_name) { + return registerStoreInfo.value.store_name; + } + // 默认使用医生当前诊所 + return currentStoreName.value; + }); + + // 是否可以更改诊所(使用后端返回的 can_change 字段) + const canChangeStore = computed(() => { + return registerStoreInfo.value?.can_change === true; + }); + // 药品搜索 const getDrugList = debounce(async (searchText = '') => { if (searchText === '' && activeCategory.value === 1) { @@ -598,7 +666,14 @@ export const usePrescriptionStore = defineStore('prescription', () => { }; // 发送处方 - const sendPrescription = async (doctorSecondSignValue = 0) => { + const sendPrescription = async ( + doctorSecondSignValue = 0, + customSendMode: number = 0, + customStoreId: number | null = null, + ) => { + // #region agent log + fetch('http://127.0.0.1:7242/ingest/3cda25fa-2f46-4a02-889c-2ffb76bc49fe',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'prescription.ts:sendPrescription:entry',message:'sendPrescription接收的参数',data:{customSendMode:customSendMode,customStoreId:customStoreId,doctorSecondSignValue:doctorSecondSignValue},timestamp:Date.now(),sessionId:'debug-session',hypothesisId:'D'})}).catch(()=>{}); + // #endregion if (currentDrugs.value.length === 0) { message.error('请选择药品'); @@ -660,7 +735,13 @@ 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, }).then((res) => { + // #region agent log + fetch('http://127.0.0.1:7242/ingest/3cda25fa-2f46-4a02-889c-2ffb76bc49fe',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'prescription.ts:sendPrescription:afterAPI',message:'API请求成功后',data:{send_mode:customSendMode,custom_store_id:customSendMode === 1 ? customStoreId : null,res:res},timestamp:Date.now(),sessionId:'debug-session',hypothesisId:'D'})}).catch(()=>{}); + // #endregion message.success('处方已发送'); sendMessage({ roomId: chatStore.currentFriend.room_id, @@ -821,5 +902,14 @@ export const usePrescriptionStore = defineStore('prescription', () => { diseasesSelected, methodSelected, syndromeSelected, + // 诊所选择相关 + registerStoreInfo, + selectedStoreId, + sendMode, + fetchRegisterStoreInfo, + toggleStoreSelection, + currentStoreName, + targetStoreName, + canChangeStore, }; }); 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 b97b6e50..d296f4ec 100644 --- a/apps/web-antd/src/views/business/chat/components/PrescriptionModal.vue +++ b/apps/web-antd/src/views/business/chat/components/PrescriptionModal.vue @@ -38,6 +38,7 @@ import DiagnosisModal from '#/views/doctor/doctor-reception/components/Diagnosis import DoctorOrderModal from '#/views/doctor/doctor-reception/components/DoctorOrderModal.vue'; import PrescriptionDetail from '#/views/doctor/doctor-reception/components/PrescriptionDetail.vue'; import WesternModal from '#/views/doctor/doctor-reception/components/WesternModal.vue'; +import StoreConfirmModal from './StoreConfirmModal.vue'; const splitString = (input: string) => input.split(','); @@ -84,6 +85,8 @@ const [Modal, modalApi] = useVbenModal({ true, ); prescriptionStore.loadFromLocalStorage(); + // 获取挂号诊所信息 + await prescriptionStore.fetchRegisterStoreInfo(); } else { console.warn('未提供registerId'); } @@ -116,6 +119,11 @@ const [PrescriptionDetailModal, PrescriptionDetailModalApi] = useVbenModal({ connectedComponent: PrescriptionDetail, }); +// 诊所确认弹窗 +const [StoreConfirmModalComponent, storeConfirmModalApi] = useVbenModal({ + connectedComponent: StoreConfirmModal, +}); + const setVisible = (value: boolean, instruction = ''): void => { previewImage.value = []; if (instruction === '') { @@ -142,9 +150,51 @@ const handleCheckChineseMedicineConflict = async () => { } }; +// 处方发送前的确认流程 const handleSendPrescription = async (doctorSecondSignValue = 0) => { + // 确保基础数据已初始化(包括当前诊所列表) + await prescriptionStore.initializeBasicData(); + + // 获取挂号诊所信息 + await prescriptionStore.fetchRegisterStoreInfo(); + + const canChange = prescriptionStore.canChangeStore; + + if (canChange) { + // 弹出诊所确认弹窗 - 直接从 registerStoreInfo 获取诊所信息 + const storeInfo = prescriptionStore.registerStoreInfo; + storeConfirmModalApi.setData({ + registerStoreName: storeInfo?.store_name || '挂号诊所', + registerStoreId: storeInfo?.store_id, + currentStoreName: storeInfo?.current_store_name || '当前诊所', // 直接从后端数据获取 + canChange: true, + onConfirm: async (mode: number, customStoreId: number | null) => { + // #region agent log + fetch('http://127.0.0.1:7242/ingest/3cda25fa-2f46-4a02-889c-2ffb76bc49fe',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'PrescriptionModal.vue:onConfirm',message:'回调接收到的值',data:{mode:mode,customStoreId:customStoreId,doctorSecondSignValue:doctorSecondSignValue},timestamp:Date.now(),sessionId:'debug-session',hypothesisId:'B'})}).catch(()=>{}); + // #endregion + await executeSendPrescription(doctorSecondSignValue, mode, customStoreId); + }, + }); + storeConfirmModalApi.open(); + } else { + // 直接发送 + await executeSendPrescription(doctorSecondSignValue, 0, null); + } +}; + +// 执行发送处方 +const executeSendPrescription = async ( + doctorSecondSignValue: number, + sendMode: number, + customStoreId: number | null, +) => { + // #region agent log + fetch('http://127.0.0.1:7242/ingest/3cda25fa-2f46-4a02-889c-2ffb76bc49fe',{method:'POST',headers:{'Content-Type':'application/json'},body:JSON.stringify({location:'PrescriptionModal.vue:executeSendPrescription',message:'执行发送前的参数',data:{sendMode:sendMode,customStoreId:customStoreId,doctorSecondSignValue:doctorSecondSignValue},timestamp:Date.now(),sessionId:'debug-session',hypothesisId:'C'})}).catch(()=>{}); + // #endregion const success = await prescriptionStore.sendPrescription( doctorSecondSignValue, + sendMode, + customStoreId, ); if (success) { if (modalData.value?.onPrescriptionSent) { @@ -1268,6 +1318,7 @@ const filterOption = (input: string, option: any) => { + diff --git a/apps/web-antd/src/views/business/chat/components/StoreConfirmModal.vue b/apps/web-antd/src/views/business/chat/components/StoreConfirmModal.vue new file mode 100644 index 00000000..a2fc7668 --- /dev/null +++ b/apps/web-antd/src/views/business/chat/components/StoreConfirmModal.vue @@ -0,0 +1,104 @@ + + + + + + diff --git a/apps/web-antd/src/views/doctor/online-consultation/api/index.ts b/apps/web-antd/src/views/doctor/online-consultation/api/index.ts index 04c81fed..64599781 100644 --- a/apps/web-antd/src/views/doctor/online-consultation/api/index.ts +++ b/apps/web-antd/src/views/doctor/online-consultation/api/index.ts @@ -91,3 +91,13 @@ export async function reception(registerId: number) { }); } +/** + * 获取挂号诊所信息 + * @param registerId 挂号ID + */ +export async function getRegisterStoreInfo(registerId: number) { + return requestClient.get(`${prefix}get-register-store-info`, { + params: { register_id: registerId } + }); +} +