优化功能
Some checks failed
CI / Test (ubuntu-latest) (push) Has been cancelled
CI / Test (windows-latest) (push) Has been cancelled
CI / Lint (ubuntu-latest) (push) Has been cancelled
CI / Lint (windows-latest) (push) Has been cancelled
CI / Check (ubuntu-latest) (push) Has been cancelled
CI / Check (windows-latest) (push) Has been cancelled
CodeQL / Analyze (javascript-typescript) (push) Has been cancelled
Deploy Website on push / Deploy Push Playground Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Docs Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Antd Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Element Ftp (push) Has been cancelled
Deploy Website on push / Deploy Push Naive Ftp (push) Has been cancelled
Release Drafter / update_release_draft (push) Has been cancelled
CI / CI OK (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Issue Close Require / close-issues (push) Has been cancelled
Close stale issues / stale (push) Has been cancelled

This commit is contained in:
李琦
2026-01-22 14:53:29 +08:00
parent e33f2f1edc
commit 5ba5ec65c8
13 changed files with 2373 additions and 25 deletions

View File

@@ -16,7 +16,8 @@ import {
getProcessRuleList,
getProductListDoctorReception,
} from '#/views/doctor/doctor-reception/api';
import { getRegisterStoreInfo } from '#/views/doctor/online-consultation/api';
import { getRegisterStoreInfo as getRegisterStoreInfoPharmacy } from '#/views/doctor/online-consultation/api';
import { getRegisterStoreInfo as getRegisterStoreInfoClinic } from '#/views/doctor/online-consultation-clinic/api';
import traditionalJson from '#/views/business/chat/config/traditional.json';
export const usePrescriptionStore = defineStore('prescription', () => {
@@ -85,10 +86,13 @@ export const usePrescriptionStore = defineStore('prescription', () => {
const selectedStoreId = ref<number | null>(null); // 用户选择的诊所ID
const sendMode = ref(0); // 0=默认(使用医生当前诊所),1=自定义(使用挂号诊所)
// 存储前缀(用于区分在线复诊-药店和在线复诊-诊所)
const storagePrefix = ref('onlineConsultation-'); // 默认前缀
// 获取localStorage key(按类型分开存储)
const getStorageKey = (category?: number) => {
const cat = category ?? activeCategory.value;
return `onlineConsultation-prescriptionData_${cat}_${currentRegisterId.value}`;
return `${storagePrefix.value}prescriptionData_${cat}_${currentRegisterId.value}`;
};
// 计算属性
@@ -198,24 +202,28 @@ export const usePrescriptionStore = defineStore('prescription', () => {
// 完整初始化(包含患者信息,仅用于 PrescriptionModal)
const initializePrescription = async (
registerId: number | string,
shouldFetchPatientInfo: boolean = false
shouldFetchPatientInfo: boolean = false,
prefix: string = 'onlineConsultation-'
) => {
// 设置存储前缀
storagePrefix.value = prefix;
// 设置当前注册ID
currentRegisterId.value = registerId;
// 恢复之前保存的 activeCategory
const savedCategory = localStorage.getItem(
`onlineConsultation-activeCategory${registerId}`
`${storagePrefix.value}activeCategory${registerId}`
);
if (savedCategory) {
activeCategory.value = Number.parseInt(savedCategory);
} else {
// 检查哪个存储键有数据
const chineseData = localStorage.getItem(
`onlineConsultation-prescriptionData_1_${registerId}`
`${storagePrefix.value}prescriptionData_1_${registerId}`
);
const westData = localStorage.getItem(
`onlineConsultation-prescriptionData_2_${registerId}`
`${storagePrefix.value}prescriptionData_2_${registerId}`
);
if (chineseData && JSON.parse(chineseData).length > 0) {
activeCategory.value = 1;
@@ -245,25 +253,28 @@ export const usePrescriptionStore = defineStore('prescription', () => {
};
// 轻量级初始化(仅用于 WesternModal 等子组件)
const initializeForModal = async (registerId: number | string) => {
const initializeForModal = async (registerId: number | string, prefix: string = 'onlineConsultation-') => {
console.log('轻量级初始化,registerId:', registerId);
// 设置存储前缀
storagePrefix.value = prefix;
// 设置当前注册ID
currentRegisterId.value = registerId;
// 恢复之前保存的 activeCategory
const savedCategory = localStorage.getItem(
`onlineConsultation-activeCategory${registerId}`
`${storagePrefix.value}activeCategory${registerId}`
);
if (savedCategory) {
activeCategory.value = Number.parseInt(savedCategory);
} else {
// 检查哪个存储键有数据
const chineseData = localStorage.getItem(
`onlineConsultation-prescriptionData_1_${registerId}`
`${storagePrefix.value}prescriptionData_1_${registerId}`
);
const westData = localStorage.getItem(
`onlineConsultation-prescriptionData_2_${registerId}`
`${storagePrefix.value}prescriptionData_2_${registerId}`
);
if (chineseData && JSON.parse(chineseData).length > 0) {
activeCategory.value = 1;
@@ -348,7 +359,12 @@ export const usePrescriptionStore = defineStore('prescription', () => {
return;
}
try {
const res = await getRegisterStoreInfo(Number(currentRegisterId.value));
// 根据storagePrefix判断使用哪个API
const getRegisterStoreInfoFn = storagePrefix.value === 'onlineConsultationClinic-'
? getRegisterStoreInfoClinic
: getRegisterStoreInfoPharmacy;
const res = await getRegisterStoreInfoFn(Number(currentRegisterId.value));
registerStoreInfo.value = res;
// 默认选择挂号诊所
@@ -863,7 +879,7 @@ export const usePrescriptionStore = defineStore('prescription', () => {
// 保存 Tab 类型
localStorage.setItem(
`onlineConsultation-activeCategory${currentRegisterId.value}`,
`${storagePrefix.value}activeCategory${currentRegisterId.value}`,
categoryValue.toString(),
);
activeCategory.value = categoryValue;