fix: 在线复诊

This commit is contained in:
2025-12-23 11:05:12 +08:00
parent f2d7317982
commit e9b79b2963
23 changed files with 2526 additions and 254 deletions

View File

@@ -79,9 +79,9 @@ export const usePrescriptionStore = defineStore('prescription', () => {
const methodSelected = ref();
const syndromeSelected = ref();
// 获取localStorage key
// 获取localStorage key(修改为在线复诊前缀)
const getStorageKey = () =>
`prescriptionData-chat-${currentRegisterId.value}`;
`onlineConsultation-prescriptionData${currentRegisterId.value}`;
// 计算属性
const totalProductCost = computed(() => {
@@ -188,9 +188,10 @@ export const usePrescriptionStore = defineStore('prescription', () => {
};
// 完整初始化(包含患者信息,仅用于 PrescriptionModal)
const initializePrescription = async (registerId: number | string) => {
console.log('初始化处方,registerId:', registerId);
const initializePrescription = async (
registerId: number | string,
shouldFetchPatientInfo: boolean = false
) => {
// 设置当前注册ID
currentRegisterId.value = registerId;
@@ -202,13 +203,15 @@ export const usePrescriptionStore = defineStore('prescription', () => {
await initializeBasicData();
}
// 获取患者信息(只在 PrescriptionModal 中调用)
// 获取患者信息(只在需要时调用,如 PrescriptionModal)
if (shouldFetchPatientInfo) {
if (
!isPatientInfoLoaded.value ||
patientInfo.value?.register_id !== registerId
) {
await getPatientInfo();
isPatientInfoLoaded.value = true;
}
}
};
@@ -641,7 +644,7 @@ export const usePrescriptionStore = defineStore('prescription', () => {
total: totalCost.value,
category: category.value,
drug_type: 2,
register_id: patientInfo.value.id,
register_id: currentRegisterId.value,
treatment_price: treatmentPrice.value,
package_method_id: packageMethodId.value,
process_rule_id: processRuleId.value,
@@ -661,22 +664,28 @@ export const usePrescriptionStore = defineStore('prescription', () => {
message.success('处方已发送');
sendMessage({
roomId: chatStore.currentFriend.room_id,
senderId: userStore.currentUser.id,
senderId: userStore.currentUser.doctor_id,
receiverId: chatStore.currentFriend.id,
type: 'prescription',
content: JSON.stringify(res),
});
chatStore.addMessage(
{
roomId: chatStore.currentFriend.room_id,
senderId: userStore.currentUser.id,
receiverId: chatStore.currentFriend.id,
type: 'prescription',
content: res,
id: Date.now().toString(),
room_id: chatStore.currentFriend.room_id,
sender_user_id: `doctor-${userStore.currentUser.doctor_id}`,
receiver_user_id: chatStore.currentFriend.id,
message_type: 4,
message_content: JSON.stringify(res),
messageTypeName: 'prescription',
created_at: Date.now(),
created_at_text: new Date().toLocaleTimeString().slice(0, 5),
timestamp: Date.now(),
isSent: true,
time: new Date().toLocaleTimeString().slice(0, 5),
read: true,
duration: 0,
},
userStore.currentUser.id,
userStore.currentUser.doctor_id,
);
resetForm();
});
@@ -704,7 +713,7 @@ export const usePrescriptionStore = defineStore('prescription', () => {
activeCategory.value = categoryValue;
updateCurrentDrugs([]);
localStorage.setItem(
`activeCategory-chat-${currentRegisterId.value}`,
`onlineConsultation-activeCategory${currentRegisterId.value}`,
categoryValue.toString(),
);
};

View File

@@ -61,8 +61,8 @@ export const usePrescriptionStore = () => {
const doctorSecondSign = ref(0)
const checkData = ref<any>({})
// 获取localStorage key
const getStorageKey = () => `prescriptionData-chat-${currentRegisterId.value}`
// 获取localStorage key(修改为在线复诊前缀)
const getStorageKey = () => `onlineConsultation-prescriptionData${currentRegisterId.value}`
// 计算属性
const totalProductCost = computed(() => {
@@ -579,7 +579,7 @@ export const usePrescriptionStore = () => {
const changeCategory = (categoryValue: number) => {
activeCategory.value = categoryValue
updateCurrentDrugs([])
localStorage.setItem(`activeCategory-chat-${currentRegisterId.value}`, categoryValue.toString())
localStorage.setItem(`onlineConsultation-activeCategory${currentRegisterId.value}`, categoryValue.toString())
}
// 工具函数