diff --git a/src/App.vue b/src/App.vue index 078b5d2..c7d0432 100644 --- a/src/App.vue +++ b/src/App.vue @@ -6,13 +6,28 @@ import useSettingsStore from '@/store/modules/settings' import { handleThemeStyle } from '@/utils/theme' import { ref, onMounted, onUnmounted, nextTick } from 'vue'; - +import { useFingerprint } from '@/utils/useFingerprint'; +import { useCommonStore } from '@/store/modules/commonStore' +const mbStore = useCommonStore(); +// 使用自定义hook获取指纹信息 +const { + fingerprint, + loading, + error, + getFingerprint +} = useFingerprint(); onMounted(() => { nextTick(() => { // 初始化主题样式 handleThemeStyle(useSettingsStore().theme) }) + + if (!mbStore.fingerprint) { + // 重新获取指纹 + getFingerprint(); + mbStore.setFingerprint(fingerprint) + } }) diff --git a/src/api/liswork/micro/index.ts b/src/api/liswork/micro/index.ts index 0fce896..cb1ca07 100644 --- a/src/api/liswork/micro/index.ts +++ b/src/api/liswork/micro/index.ts @@ -21,11 +21,27 @@ export function wswsamplelistpage(query?: Object) { // 获取微生物样本信息 export function sampleMedInfo(query?: Object) { return request({ - url: '/lisworkgerm/sampleMedInfo', + url: '/lisworkgerm/getresultlist', method: 'get', params: query }) } +// 获取药敏数据 +export function getresultmedList(query?: Object) { + return request({ + url: '/lisworkgerm/getresultmedlist', + method: 'get', + params: query + }) +} +// 写入专家评语 +export function savetestResult(query?: Object) { + return request({ + url: '/lisworkgerm/savetestresult', + method: 'post', + data: query + }) +} // 获取操作记录 export function getComLog(query?: Object) { return request({ @@ -33,4 +49,30 @@ export function getComLog(query?: Object) { method: 'get', params: query }) +} + +//新增结果明细 +export function newresult(data?: Object) { + return request({ + url: '/lisworkgerm/newresult', + method: 'post', + data + }) +} +//修改结果明细 +export function changeresult(data?: Object) { + return request({ + url: '/lisworkgerm/changeresult', + method: 'post', + data + }) +} + +//修改结果明细 +export function saveresult(data?: Object) { + return request({ + url: '/lisworkgerm/saveresult', + method: 'post', + data + }) } \ No newline at end of file diff --git a/src/store/modules/commonStore.ts b/src/store/modules/commonStore.ts index f260ab5..b8a0787 100644 --- a/src/store/modules/commonStore.ts +++ b/src/store/modules/commonStore.ts @@ -4,10 +4,15 @@ import { defineStore } from 'pinia' export const useCommonStore = defineStore('commonStore', { state: () => ({ lxsrs: [] as string[], // 存储项目模板名称 + fingerprint: '',// 存储指纹信息 }), actions: { setLxsrList(list: any[]) { this.lxsrs = list }, + + setFingerprint(fingerprint: string) { + this.fingerprint = fingerprint + }, } }) \ No newline at end of file diff --git a/src/utils/webSocket.ts b/src/utils/webSocket.ts new file mode 100644 index 0000000..f19309b --- /dev/null +++ b/src/utils/webSocket.ts @@ -0,0 +1,103 @@ +// WebSocket连接配置 +type WebSocketOptions = { + fullUrl: string; + onMessage?: (data: string) => void; + onOpen?: () => void; + onError?: (error: Event) => void; + onClose?: () => void; + reconnectInterval?: number; +}; + +let websocket: WebSocket | null = null; +let reconnectTimer: any = null; +let isManualClose = false; + +// 初始化WebSocket连接 +export function initWebSocket(options: WebSocketOptions) { + const { + fullUrl, + onMessage, + onOpen, + onError, + onClose, + reconnectInterval = 3000 + } = options; + + // 关闭旧连接 + if (websocket) { + websocket.close(); + } + + // 检查浏览器支持性 + if (!('WebSocket' in window)) { + console.error('当前浏览器不支持WebSocket'); + return; + } + + // 创建WebSocket连接 + try { + websocket = new WebSocket(fullUrl); + + // 连接成功回调 + websocket.onopen = () => { + clearTimeout(reconnectTimer!); + isManualClose = false; + onOpen?.(); + }; + + // 接收消息回调 + websocket.onmessage = (event) => { + onMessage?.(event.data); + }; + + // 错误回调 + websocket.onerror = (error) => { + onError?.(error); + startReconnect(() => initWebSocket(options), reconnectInterval); + }; + + // 关闭回调 + websocket.onclose = () => { + onClose?.(); + if (!isManualClose) { + startReconnect(() => initWebSocket(options), reconnectInterval); + } + }; + } catch (error) { + console.error('WebSocket连接创建失败:', error); + startReconnect(() => initWebSocket(options), reconnectInterval); + } +} + +// 发送消息 +export function sendWebSocketMessage(message: any): boolean { + if (websocket && websocket.readyState === WebSocket.OPEN) { + websocket.send(JSON.stringify(message)); + return true; + } + console.error('WebSocket未连接,无法发送消息'); + return false; +} + +// 手动关闭WebSocket +export function closeWebSocket(): void { + isManualClose = true; + if (reconnectTimer) { + clearTimeout(reconnectTimer); + } + websocket?.close(); + websocket = null; +} + +// 启动重连 +function startReconnect(connectCallback: () => void, interval: number): void { + if (reconnectTimer) { + clearTimeout(reconnectTimer); + } + reconnectTimer = setTimeout(connectCallback, interval); +} + +// 获取当前连接状态 +export function getWebSocketState(): number | null { + return websocket?.readyState || null; +} \ No newline at end of file diff --git a/src/views/checkCode/report/index.vue b/src/views/checkCode/report/index.vue index ab64ebd..04ea533 100644 --- a/src/views/checkCode/report/index.vue +++ b/src/views/checkCode/report/index.vue @@ -490,13 +490,13 @@ const brlxFields = ref([ const rightTableData = ref([]) // 配置项 const rightColumns = ref([ - { prop: 'xmdh', label: '项目代号', align: 'center', visible: true, }, //0 - { prop: 'xmmc', label: '项目名称', align: 'center', visible: true, }, //1 - { prop: 'xmmc', label: '培养结果', align: 'center', visible: true, width: 150 },//2 - { prop: 'csjg', label: '检验结果', align: 'center', visible: true, },//3 - { prop: 'refs', label: '参考值', align: 'center', visible: true, },//4 - { prop: 'dw', label: '单位', align: 'center', visible: true, },//5 - { prop: 'od', label: '菌落计数', align: 'center', visible: true, },//6 + { prop: 'xmdh', label: '项目代号', align: 'center', visible: true, }, + { prop: 'xmmc', label: '项目名称', align: 'center', visible: true, }, + { prop: 'xmmc', label: '培养结果', align: 'center', visible: true, width: 150 }, + { prop: 'csjg', label: '检验结果', align: 'center', visible: true, }, + { prop: 'refs', label: '参考值', align: 'center', visible: true, }, + { prop: 'dw', label: '单位', align: 'center', visible: true, }, + { prop: 'od', label: '菌落计数', align: 'center', visible: true, }, // { prop: 'jgbz', label: '结果标志', align: 'center', visible: true, slot: 'jgbz' }, ]) diff --git a/src/views/index.vue b/src/views/index.vue index ea24300..7deb6f9 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -5,20 +5,8 @@ \ No newline at end of file diff --git a/src/views/liswork/work/charge/index.vue b/src/views/liswork/conponents/charge/index.vue similarity index 100% rename from src/views/liswork/work/charge/index.vue rename to src/views/liswork/conponents/charge/index.vue diff --git a/src/views/liswork/work/clinical/index.vue b/src/views/liswork/conponents/clinical/index.vue similarity index 100% rename from src/views/liswork/work/clinical/index.vue rename to src/views/liswork/conponents/clinical/index.vue diff --git a/src/views/liswork/work/combination/index.vue b/src/views/liswork/conponents/combination/index.vue similarity index 100% rename from src/views/liswork/work/combination/index.vue rename to src/views/liswork/conponents/combination/index.vue diff --git a/src/views/liswork/work/history/index.vue b/src/views/liswork/conponents/history/index.vue similarity index 100% rename from src/views/liswork/work/history/index.vue rename to src/views/liswork/conponents/history/index.vue diff --git a/src/views/liswork/work/others/index.vue b/src/views/liswork/conponents/others/index.vue similarity index 100% rename from src/views/liswork/work/others/index.vue rename to src/views/liswork/conponents/others/index.vue diff --git a/src/views/liswork/work/reexamination/index.vue b/src/views/liswork/conponents/reexamination/index.vue similarity index 100% rename from src/views/liswork/work/reexamination/index.vue rename to src/views/liswork/conponents/reexamination/index.vue diff --git a/src/views/liswork/work/resultGraph/index.vue b/src/views/liswork/conponents/resultGraph/index.vue similarity index 100% rename from src/views/liswork/work/resultGraph/index.vue rename to src/views/liswork/conponents/resultGraph/index.vue diff --git a/src/views/liswork/work/sample/index.vue b/src/views/liswork/conponents/sample/index.vue similarity index 100% rename from src/views/liswork/work/sample/index.vue rename to src/views/liswork/conponents/sample/index.vue diff --git a/src/views/liswork/work/sample/index2.vue b/src/views/liswork/conponents/sample/index2.vue similarity index 100% rename from src/views/liswork/work/sample/index2.vue rename to src/views/liswork/conponents/sample/index2.vue diff --git a/src/views/liswork/micro/index.vue b/src/views/liswork/micro/index.vue index 493ee21..95e6360 100644 --- a/src/views/liswork/micro/index.vue +++ b/src/views/liswork/micro/index.vue @@ -49,7 +49,9 @@ :userList="userList" @changeStatus="changeStatus" @batchShow="handleBatchScan" /> - + @@ -84,7 +86,7 @@ 近7天 此日 -> - + @@ -129,6 +131,14 @@ import iFrame from "@/components/iFrame/index.vue"; // @ts-ignore import LabResult from './labresult/index.vue'; import LabPatList from './labpatlist.vue'; +import History from '../conponents/history/index.vue' +import Others from '../conponents/others/index.vue' +import Reexamination from '../conponents/reexamination/index.vue' +import Charge from '../conponents/charge/index.vue' +import Combination from '../conponents/combination/index.vue' +import Clinical from '../conponents/clinical/index.vue' +import Sample from '../conponents/sample/index.vue' +import ResultGraph from '../conponents/resultGraph/index.vue' // @ts-ignore import { comDict } from '@/utils/dict' import { queryLabResults, loadDefault, queryLabPat, instrdconfig, delSample, getGroupInstrdList } from "@/api/liswork/work/LisWork"; @@ -144,6 +154,7 @@ import PatientQueryForm from '@/components/selectSearch/index.vue' import { listUser } from '@/api/system/user.js' import dayjs from 'dayjs' const aotuSize = classCom.useAutoSize(); +import { initWebSocket, sendWebSocketMessage, closeWebSocket, getWebSocketState } from '@/utils/webSocket'; const previewShow = ref(false); const lbFlag = ref(false); @@ -175,7 +186,14 @@ const tabList = ref([ ]) const activeTabMap = { - + ResultGraph, + History, + Others, + Reexamination, + Charge, + Combination, + Clinical, + Sample } const activeTabName = computed(() => activeTabMap[activeTab.value as keyof typeof activeTabMap] || 'LabPatList'); @@ -297,6 +315,7 @@ const yqHandleChange = (val: any) => { mbStore.setLxsrList([]); getSysList() fetchlabPatList() + sendMessage() } const instrGroupFields = ref([ { prop: 'zddh', label: '代号', width: 80, enablePinyinSearch: true }, @@ -351,7 +370,7 @@ const selectJob = (job: any) => { const labResuts = ref([]) //载入样本结果表单(中间labresult.vue组件) const fetchLabResults = async () => { - queryLabResults({ jyrq: queryParams.value.jyrq, yq: queryParams.value.yq, ybh: labInfo.value.ybh }).then((response: any) => { + sampleMedInfo({ jyrq: labInfo.value.jyrq, yq: labInfo.value.yq, ybh: labInfo.value.ybh }).then((response: any) => { labResuts.value = response.data; }) } @@ -365,6 +384,7 @@ const fetchLabPat = () => { } queryLabPat(data).then((response: any) => { labPat.value = response.data; + labInfo.value = response.data; }) } @@ -372,7 +392,7 @@ const lastRow: any = ref({}) // 批量扫码ybh同步样本编号 const ybhChangeTb = (val: string) => { - console.log('val==>', val); + // console.log('val==>', val); labInfo.value.ybh = val handleQuery(); } @@ -649,7 +669,7 @@ onMounted(async () => { userList.value = res.rows; }); // 加载病人来源字典 - const dictRefs = await comDict('PT', 'AU', 'SX', 'DP', 'BT', 'SRD', 'HOS', 'ST'); + const dictRefs = await comDict('PT', 'AU', 'SX', 'DP', 'BT', 'SRD', 'HOS', 'ST', 'germclass'); // 从 ref 中获取实际数据 dictData.value = { PT: toRaw(dictRefs.PT.value) || [], @@ -660,8 +680,48 @@ onMounted(async () => { SRD: toRaw(dictRefs.SRD.value) || [], HOS: toRaw(dictRefs.HOS.value) || [], ST: toRaw(dictRefs.ST.value) || [], + germclass: toRaw(dictRefs.germclass.value) || [], }; + // 初始化Socket + initSocket() }); + +const initSocket = () => { + initWebSocket({ + // fullUrl: `ws://47.97.125.165:8904/ws/instr/${mbStore.fingerprint}`, + fullUrl: `ws://192.168.1.151:9801/ws/instr/${mbStore.fingerprint}`, + onOpen: () => { + console.log('WebSocket连接成功'); + }, + onMessage: (data) => { + console.log(`收到消息: `, JSON.parse(data)); + }, + onError: (error) => { + console.log(`连接错误: ${error.type}`); + }, + onClose: () => { + console.log('WebSocket连接已关闭'); + }, + reconnectInterval: 3000 // 重连间隔(毫秒) + }); +} + + + +// 页面卸载时清理 +onUnmounted(() => { + closeWebSocket(); +}); + +// 发送消息 +const sendMessage = () => { + const isSuccess = sendWebSocketMessage({ yq: queryParams.value.yq }); + if (isSuccess) { + console.log(`发送消息`); + } else { + console.log('发送失败:连接未建立'); + } +}; \ No newline at end of file + \ No newline at end of file diff --git a/src/views/liswork/micro/labresult/index.vue b/src/views/liswork/micro/labresult/index.vue index 459ec30..226c3b4 100644 --- a/src/views/liswork/micro/labresult/index.vue +++ b/src/views/liswork/micro/labresult/index.vue @@ -2,10 +2,86 @@
- +
+ 审核 + 取消审核 + 新增 + 删除 +
+ + + + + + + + + + + + + + + + +
+ 更换抗生素组 + 添加抗生素组 + {{ ymTableData.length }}项 +
+
+ + + +
- + @@ -14,16 +90,28 @@
+ +
@@ -56,4 +474,27 @@ const activeName = ref('first') } } } + +.btns { + margin-top: .625rem; + + span { + color: #1f6dd3; + margin-left: 15px; + } +} + + +.el-radio { + margin-right: 10px; +} + +.btn_green { + padding: .3125rem .625rem !important; + font-size: .875rem; + height: 1.25rem !important; + margin: 5px 0; + margin-left: .625rem !important; + border-radius: 0 !important; +} \ No newline at end of file diff --git a/src/views/liswork/work/index.vue b/src/views/liswork/work/index.vue index 1b64753..bb6b72f 100644 --- a/src/views/liswork/work/index.vue +++ b/src/views/liswork/work/index.vue @@ -123,14 +123,14 @@ import { comDict } from '@/utils/dict' import { queryLabPatList, queryLabResults, loadDefault, queryLabPat, instrdconfig, delSample, getGroupInstrdList } from "@/api/liswork/work/LisWork"; import { getComDicts, queryComDictListService } from "@/api/liswork/dict/ComDict"; import { ElMessage, ElMessageBox } from "element-plus"; -import History from './history/index.vue' -import Others from './others/index.vue' -import Reexamination from './reexamination/index.vue' -import Charge from './charge/index.vue' -import Combination from './combination/index.vue' -import Clinical from './clinical/index.vue' -import Sample from './sample/index.vue' -import ResultGraph from './resultGraph/index.vue' +import History from '../conponents/history/index.vue' +import Others from '../conponents/others/index.vue' +import Reexamination from '../conponents/reexamination/index.vue' +import Charge from '../conponents/charge/index.vue' +import Combination from '../conponents/combination/index.vue' +import Clinical from '../conponents/clinical/index.vue' +import Sample from '../conponents/sample/index.vue' +import ResultGraph from '../conponents/resultGraph/index.vue' import { getNextNumber, getPreviousNumber } from "@/utils/getNextNumber"; import { useCommonStore } from '@/store/modules/commonStore'; import { classCom } from '@/utils/classCom'; @@ -140,6 +140,7 @@ import BatchCode from './components/batchCode.vue'; import { listUser } from '@/api/system/user.js' const aotuSize = classCom.useAutoSize(); +import { initWebSocket, sendWebSocketMessage, closeWebSocket, getWebSocketState } from '@/utils/webSocket'; const previewShow = ref(false); const lbFlag = ref(false); @@ -644,7 +645,46 @@ onMounted(async () => { HOS: toRaw(dictRefs.HOS.value) || [], ST: toRaw(dictRefs.ST.value) || [], }; + // 初始化Socket + initSocket() }); + +const initSocket = () => { + initWebSocket({ + // fullUrl: `ws://47.97.125.165:8904/ws/instr/${mbStore.fingerprint}`, + fullUrl: `ws://192.168.1.151:9801/ws/instr/${mbStore.fingerprint}`, + onOpen: () => { + console.log('WebSocket连接成功'); + }, + onMessage: (data) => { + console.log(`收到消息: `, JSON.parse(data)); + }, + onError: (error) => { + console.log(`连接错误: ${error.type}`); + }, + onClose: () => { + console.log('WebSocket连接已关闭'); + }, + reconnectInterval: 3000 // 重连间隔(毫秒) + }); +} + + + +// 页面卸载时清理 +onUnmounted(() => { + closeWebSocket(); +}); + +// 发送消息 +const sendMessage = () => { + const isSuccess = sendWebSocketMessage({ yq: queryParams.value.yq }); + if (isSuccess) { + console.log(`发送消息`); + } else { + console.log('发送失败:连接未建立'); + } +};