fix: OSS客户端直传
This commit is contained in:
@@ -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<any>(null); // 挂号诊所信息
|
||||
const selectedStoreId = ref<number | null>(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,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -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) => {
|
||||
<DiagnosisModals />
|
||||
<DoctorOrderModals />
|
||||
<PrescriptionDetailModal />
|
||||
<StoreConfirmModalComponent />
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { Radio, RadioGroup } from 'ant-design-vue';
|
||||
|
||||
const selectedMode = ref(0); // 0=当前诊所, 1=挂号诊所
|
||||
const modalData = ref<any>({});
|
||||
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
onOpenChange(isOpen) {
|
||||
if (isOpen) {
|
||||
modalData.value = modalApi.getData();
|
||||
// 默认选择挂号诊所(如果可以更改的话)
|
||||
selectedMode.value = modalData.value.canChange ? 1 : 0;
|
||||
}
|
||||
},
|
||||
onConfirm() {
|
||||
const customStoreId = selectedMode.value === 1 ? modalData.value.registerStoreId : 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:'StoreConfirmModal.vue:onConfirm',message:'弹窗确认时的值',data:{selectedMode:selectedMode.value,registerStoreId:modalData.value.registerStoreId,customStoreId:customStoreId},timestamp:Date.now(),sessionId:'debug-session',hypothesisId:'A'})}).catch(()=>{});
|
||||
// #endregion
|
||||
modalData.value.onConfirm?.(selectedMode.value, customStoreId);
|
||||
modalApi.close();
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="确认发送诊所">
|
||||
<div class="space-y-4">
|
||||
<!-- 诊所信息展示 -->
|
||||
<div class="rounded-lg border border-blue-200 bg-blue-50 p-4 dark:border-blue-800 dark:bg-blue-950">
|
||||
<div class="mb-2 flex items-center gap-2">
|
||||
<span class="text-gray-600 dark:text-gray-400">挂号诊所:</span>
|
||||
<span class="font-semibold text-blue-600 dark:text-blue-400">{{
|
||||
modalData.registerStoreName || '未知'
|
||||
}}</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-gray-600 dark:text-gray-400">当前诊所:</span>
|
||||
<span class="font-semibold text-green-600 dark:text-green-400">{{
|
||||
modalData.currentStoreName || '未知'
|
||||
}}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 诊所选择 -->
|
||||
<div v-if="modalData.canChange" class="mt-4">
|
||||
<p class="mb-3 text-gray-700 dark:text-gray-300">请选择处方发送到哪个诊所:</p>
|
||||
<RadioGroup v-model:value="selectedMode" class="w-full">
|
||||
<div class="space-y-3">
|
||||
<div
|
||||
class="cursor-pointer rounded-lg border p-3 transition-all"
|
||||
:class="
|
||||
selectedMode === 1
|
||||
? 'border-blue-500 bg-blue-50 dark:border-blue-600 dark:bg-blue-950'
|
||||
: 'border-gray-200 hover:border-gray-400 dark:border-gray-600 dark:hover:border-gray-500'
|
||||
"
|
||||
@click="selectedMode = 1"
|
||||
>
|
||||
<Radio :value="1" class="w-full">
|
||||
<span class="font-medium">发送到挂号诊所</span>
|
||||
<span class="ml-2 text-sm text-gray-500 dark:text-gray-400"
|
||||
>({{ modalData.registerStoreName }})</span
|
||||
>
|
||||
</Radio>
|
||||
</div>
|
||||
<div
|
||||
class="cursor-pointer rounded-lg border p-3 transition-all"
|
||||
:class="
|
||||
selectedMode === 0
|
||||
? 'border-green-500 bg-green-50 dark:border-green-600 dark:bg-green-950'
|
||||
: 'border-gray-200 hover:border-gray-400 dark:border-gray-600 dark:hover:border-gray-500'
|
||||
"
|
||||
@click="selectedMode = 0"
|
||||
>
|
||||
<Radio :value="0" class="w-full">
|
||||
<span class="font-medium">发送到当前诊所</span>
|
||||
<span class="ml-2 text-sm text-gray-500 dark:text-gray-400"
|
||||
>({{ modalData.currentStoreName }})</span
|
||||
>
|
||||
</Radio>
|
||||
</div>
|
||||
</div>
|
||||
</RadioGroup>
|
||||
</div>
|
||||
|
||||
<!-- 无法更改时的提示 -->
|
||||
<div v-else class="mt-4 text-center text-gray-500 dark:text-gray-400">
|
||||
处方将发送到当前诊所
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* Radio 组件间距调整 */
|
||||
:deep(.ant-radio-wrapper) {
|
||||
margin-right: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -91,3 +91,13 @@ export async function reception(registerId: number) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取挂号诊所信息
|
||||
* @param registerId 挂号ID
|
||||
*/
|
||||
export async function getRegisterStoreInfo(registerId: number) {
|
||||
return requestClient.get<any>(`${prefix}get-register-store-info`, {
|
||||
params: { register_id: registerId }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user