diff --git a/apps/web-antd/src/views/_core/authentication/login.vue b/apps/web-antd/src/views/_core/authentication/login.vue index bd895417..553f695f 100644 --- a/apps/web-antd/src/views/_core/authentication/login.vue +++ b/apps/web-antd/src/views/_core/authentication/login.vue @@ -27,9 +27,9 @@ const formSchema = computed((): VbenFormSchema[] => { const schema: VbenFormSchema[] = [ // 1. Radio选择组(最上面) { - component: 'RadioGroup', + component: 'VbenSelect', componentProps: { - optionType: 'button', + // optionType: 'button', options: [ { label: '手机号登录', value: 'phone' }, { label: '登录账号登录', value: 'login_account' }, diff --git a/apps/web-antd/src/views/business/chat/components/MessageInput.vue b/apps/web-antd/src/views/business/chat/components/MessageInput.vue index 0622418d..7bc84ef2 100644 --- a/apps/web-antd/src/views/business/chat/components/MessageInput.vue +++ b/apps/web-antd/src/views/business/chat/components/MessageInput.vue @@ -12,7 +12,6 @@ import { useThemeStore } from '../stores/theme.ts'; import { useUserStore } from '../stores/user.ts'; import { sendMessage } from '../utils/request.ts'; import { usePrescriptionStore } from '#/store/prescription'; -import { getProductListDoctorReception } from '#/views/doctor/doctor-reception/api'; // 根据路由判断是在线复诊-药店还是在线复诊-诊所 const route = useRoute(); @@ -21,8 +20,8 @@ const isClinicModule = computed(() => { }); // 动态导入对应的API和组件 -import { endConsultation as endConsultationPharmacy } from '#/views/doctor/online-consultation/api/index'; -import { endConsultation as endConsultationClinic } from '#/views/doctor/online-consultation-clinic/api/index'; +import { endConsultation as endConsultationPharmacy, getDrugsByRegisterId as getDrugsByRegisterIdPharmacy } from '#/views/doctor/online-consultation/api/index'; +import { endConsultation as endConsultationClinic, getDrugsByRegisterId as getDrugsByRegisterIdClinic } from '#/views/doctor/online-consultation-clinic/api/index'; import QuickReplyBubblesPharmacy from '#/views/doctor/online-consultation/components/QuickReplyBubbles.vue'; import QuickReplyBubblesClinic from '#/views/doctor/online-consultation-clinic/components/QuickReplyBubbles.vue'; @@ -31,6 +30,10 @@ const endConsultation = computed(() => { return isClinicModule.value ? endConsultationClinic : endConsultationPharmacy; }); +const getDrugsByRegisterId = computed(() => { + return isClinicModule.value ? getDrugsByRegisterIdClinic : getDrugsByRegisterIdPharmacy; +}); + const QuickReplyBubbles = computed(() => { return isClinicModule.value ? QuickReplyBubblesClinic : QuickReplyBubblesPharmacy; }); @@ -349,6 +352,7 @@ const handleQuickReplySelect = (content) => { // 判断是否显示在线复诊相关按钮 const showOnlineConsultationButtons = computed(() => { + console.log('检查是否显示在线复诊相关按钮:', chatStore.currentFriend); // 检查是否有 register_id,如果有则说明是在线复诊场景 return !!chatStore.currentFriend?.register_id; }); @@ -368,16 +372,6 @@ const handleAddPatientProductsToPrescription = async () => { } } - // 从聊天记录中筛选出所有 message_type=11 的消息(患者就诊经历) - const experienceMessages = chatStore.messages.filter( - (msg) => msg.message_type === 11 - ); - - if (experienceMessages.length === 0) { - message.warning('当前聊天没有可添加的药品'); - return; - } - // 获取诊所ID let storeId = prescriptionStore.myStoreId; if (!storeId || storeId === 0) { @@ -389,64 +383,34 @@ const handleAddPatientProductsToPrescription = async () => { } } - // 按时间排序,取最新的就诊经历 - const sortedMessages = [...experienceMessages].sort((a, b) => { - const timeA = a.created_at ? new Date(a.created_at).getTime() : (a.timestamp || 0); - const timeB = b.created_at ? new Date(b.created_at).getTime() : (b.timestamp || 0); - return timeB - timeA; // 降序排列,最新的在前 - }); - - const latestMessage = sortedMessages[0]; try { - // 解析最新消息的内容 - let experienceData; - try { - experienceData = typeof latestMessage.message_content === 'string' - ? JSON.parse(latestMessage.message_content) - : latestMessage.message_content; - } catch (e) { - console.error('解析就诊经历消息失败:', e); - message.warning('当前聊天没有可添加的药品'); - return; - } - - // 获取药品名称 - const drugName = experienceData.drug_name; - if (!drugName) { - message.warning('当前聊天没有可添加的药品'); - return; - } - - // 通过药品名称搜索药品 - const res = await getProductListDoctorReception({ - store_id: storeId, - type: 2, // 中成(西)药 - name: drugName, - }); - - if (!res || res.length === 0) { - message.warning('当前聊天没有可添加的药品'); - return; - } - - // 使用第一个匹配的药品 - const drugData = res[0]; - - // 检查药品是否已在处方中 - const existItem = prescriptionStore.currentDrugs.find( - (item) => item.index_id === drugData.id, + // 根据 register_id 获取药品信息 + const res = await getDrugsByRegisterId.value( + prescriptionStore.currentRegisterId || chatStore.currentFriend?.register_id, + storeId ); - if (existItem) { - message.warning('该药品已在处方中'); + const drugList = res?.result || res?.data || res || []; + + if (!drugList || drugList.length === 0) { + message.warning('未找到药品信息'); return; } - // 添加药品到处方单 - const success = prescriptionStore.addProducts(drugData); - if (success) { - message.success(`已将${drugData.drug.drug_name}添加到处方单`); + // 遍历药品列表,添加到处方单 + let addedCount = 0; + for (const drugData of drugList) { + const success = prescriptionStore.addProducts(drugData); + if (success) { + addedCount++; + } + } + + if (addedCount > 0) { + message.success(`已成功添加 ${addedCount} 个药品到处方单`); // 触发打开处方模态框事件 emit('openPrescription', prescriptionStore.currentRegisterId || chatStore.currentFriend?.register_id); + } else { + message.warning('所有药品已在处方中'); } } catch (error) { console.error('添加药品失败:', error); @@ -522,13 +486,13 @@ const handleEndConsultation = () => { > - + + + + + + + - + + + + + + + + + + + +