diff --git a/apps/web-antd/.env b/apps/web-antd/.env index e3653b82..5a2bb8d7 100644 --- a/apps/web-antd/.env +++ b/apps/web-antd/.env @@ -1,3 +1,4 @@ +# 开发环境配置`n # 应用标题 VITE_APP_TITLE=萧康云医 @@ -6,3 +7,6 @@ VITE_APP_NAMESPACE=xk-admin- # 应用版本 XK_APP_VERSION=1.0.0 + +# WebSocket 连接地址 +VITE_WS_URL=ws://localhost:12080/ws diff --git a/apps/web-antd/.env.production b/apps/web-antd/.env.production index deeb8835..7a4e8f19 100644 --- a/apps/web-antd/.env.production +++ b/apps/web-antd/.env.production @@ -1,3 +1,4 @@ +# 生产环境配置 VITE_BASE=/ # 接口地址 @@ -17,3 +18,6 @@ VITE_INJECT_APP_LOADING=true # 打包后是否生成dist.zip VITE_ARCHIVER=true + +# WebSocket 连接地址 +VITE_WS_URL=wss://api.ws.g.xiaokang88.com/ws diff --git a/apps/web-antd/src/util/tool.ts b/apps/web-antd/src/util/tool.ts index 041fc2eb..6b616b91 100644 --- a/apps/web-antd/src/util/tool.ts +++ b/apps/web-antd/src/util/tool.ts @@ -5,6 +5,30 @@ import { isFunction } from '@vben/utils'; import SysAudioMp3 from '/public/audio/sys.mp3'; +/** + * 检测是否为开发环境 + * @returns boolean + */ +export const isDev = (): boolean => { + return import.meta.env.DEV; +}; + +/** + * 检测是否为生产环境 + * @returns boolean + */ +export const isProd = (): boolean => { + return import.meta.env.PROD; +}; + +/** + * 获取 WebSocket URL + * @returns string WebSocket 连接地址 + */ +export const getWebSocketUrl = (): string => { + return import.meta.env.VITE_WS_URL || 'ws://localhost:12080/ws'; +}; + export const playOnceAndDestroySys = () => { const audio = new Audio(SysAudioMp3); diff --git a/apps/web-antd/src/views/business/chat/composables/useWebSocket.ts b/apps/web-antd/src/views/business/chat/composables/useWebSocket.ts index 0227ef4b..4ab429c1 100644 --- a/apps/web-antd/src/views/business/chat/composables/useWebSocket.ts +++ b/apps/web-antd/src/views/business/chat/composables/useWebSocket.ts @@ -1,5 +1,7 @@ import { onMounted, onUnmounted, ref } from 'vue'; +import { getWebSocketUrl } from '#/util/tool'; + import { useChatStore } from '../stores/chat'; import { useUserStore } from '../stores/user'; // useVbenUserStore @@ -21,10 +23,7 @@ export function useWebSocket() { chatStore.connectionStatus = 'connecting'; try { - // const wsUrl = import.meta.env.VITE_WS_URL || "wss://g-ws.nailaoyun.cn/ws" - const wsUrl = import.meta.env.VITE_WS_URL || 'ws://localhost:12080/ws'; - // const wsUrl = 'wss://api.ws.g.xiaokang88.com/ws'; - // const wsUrl = import.meta.env.VITE_WS_URL || "wss://g-ws.nailaoyun.cn/ws" + const wsUrl = getWebSocketUrl(); socket.value = new WebSocket(wsUrl); socket.value.addEventListener('open', handleOpen); diff --git a/apps/web-antd/src/views/doctor/patient-management/components/PatientDetailModal.vue b/apps/web-antd/src/views/doctor/patient-management/components/PatientDetailModal.vue index 4e6cbe21..8c8feca1 100644 --- a/apps/web-antd/src/views/doctor/patient-management/components/PatientDetailModal.vue +++ b/apps/web-antd/src/views/doctor/patient-management/components/PatientDetailModal.vue @@ -9,7 +9,7 @@ * @author 系统 * @date 2024 */ -import { ref } from 'vue'; +import { h, ref } from 'vue'; import { Page, useVbenModal } from '@vben/common-ui'; @@ -31,10 +31,13 @@ import { } from 'ant-design-vue'; import { UserOutlined } from '@ant-design/icons-vue'; +import PrescriptionDetail from '#/views/doctor/doctor-reception/components/PrescriptionDetail.vue'; + import { getPatientDetailApi, getPatientRegisterListApi, getPatientPrescriptionListApi, + getPatientBaseInfoApi, savePatientRemarkApi, updatePatientRemarkApi, type PatientDetail, @@ -42,6 +45,27 @@ import { type PrescriptionItem, } from '../api'; +// ==================== 类型定义 ==================== + +/** + * 健康信息类型 + */ +interface UserPatientHealthInquiry { + id: number; + user_patient_id: number; + liver_function: number; + renal_function: number; + liver_index: string; + renal_index: string; + person_history: string; + allergic_history: string; + person_status: number; + allergic_status: number; + family_status: number; + family_history: string; + is_delete: number; +} + // ==================== 响应式数据 ==================== /** @@ -104,6 +128,35 @@ const remarkContent = ref(''); */ const hasRemark = ref(false); +/** + * 健康信息数据 + */ +const healthInfo = ref(null); + +// ==================== 处方详情弹窗 ==================== + +const [PrescriptionDetailModal, PrescriptionDetailModalApi] = useVbenModal({ + connectedComponent: PrescriptionDetail, +}); + +/** + * 打开处方详情 + * @param prescriptionId 处方ID + */ +function openPrescriptionDetail(prescriptionId: number) { + PrescriptionDetailModalApi.setData({ values: prescriptionId }); + PrescriptionDetailModalApi.open(); +} + +/** + * 分割字符串为数组 + * @param str 逗号分隔的字符串 + */ +function splitString(str: string): string[] { + if (!str) return []; + return str.split(',').filter((item) => item.trim()); +} + // ==================== 表格列配置 ==================== /** @@ -126,7 +179,21 @@ const registerColumns = [ * 处方记录表格列 */ const prescriptionColumns = [ - { title: '处方编号', dataIndex: 'prescription_no', key: 'prescription_no' }, + { + title: '处方编号', + dataIndex: 'prescription_no', + key: 'prescription_no', + customRender: ({ text, record }: { text: string; record: PrescriptionItem }) => { + return h( + Button, + { + type: 'link', + onClick: () => openPrescriptionDetail(record.id), + }, + () => text, + ); + }, + }, { title: '类型', dataIndex: 'prescription_type', @@ -196,6 +263,8 @@ async function loadPatientDetail() { patientDetail.value = res; remarkContent.value = res.remark || ''; hasRemark.value = !!res.remark; + // 同时加载健康信息 + loadHealthInfo(); } catch (error) { console.error('获取患者详情失败:', error); message.error('获取患者详情失败'); @@ -204,6 +273,19 @@ async function loadPatientDetail() { } } +/** + * 加载健康信息 + */ +async function loadHealthInfo() { + try { + const res = await getPatientBaseInfoApi(patientId.value); + healthInfo.value = res || null; + } catch (error) { + console.error('获取健康信息失败:', error); + healthInfo.value = null; + } +} + /** * 加载挂号记录 */ @@ -401,6 +483,96 @@ function getSexText(sex: number): string { + + + + + + {{ + healthInfo.liver_function === 0 ? '正常' : '异常' + }} +

+ + {{ item }} + +

+
+ + {{ + healthInfo.renal_function === 0 ? '正常' : '异常' + }} +

+ + {{ item }} + +

+
+ + {{ + healthInfo.person_status === 0 ? '无' : '有' + }} +

+ + {{ item }} + +

+
+ + {{ + healthInfo.allergic_status === 0 ? '无' : '有' + }} +

+ + {{ item }} + +

+
+ + {{ + healthInfo.family_status === 0 ? '无' : '有' + }} +

+ + {{ item }} + +

+
+
+ +
@@ -442,6 +614,7 @@ function getSexText(sex: number): string { +