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,
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user