From 2f53b1ce6cd588b29d011cfa06042e0c33e3faa1 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期一, 11 七月 2022 10:56:48 +0800
Subject: [PATCH] up

---
 src/views/home/index.vue   |    8 +++++---
 src/samples/sockteStomp.ts |   21 ++++++++-------------
 src/samples/node-api.ts    |   10 ++++++++--
 electron/main/index.ts     |    9 ++++++---
 src/stores/sockteInfo.ts   |   11 +++++++++--
 5 files changed, 36 insertions(+), 23 deletions(-)

diff --git a/electron/main/index.ts b/electron/main/index.ts
index f68297a..7ac32b5 100644
--- a/electron/main/index.ts
+++ b/electron/main/index.ts
@@ -36,6 +36,7 @@
 async function createWindow() {
   win = new BrowserWindow({
     title: 'Main window',
+    fullscreen: true,
     webPreferences: {
       preload: splash,
       nodeIntegration: true,
@@ -52,9 +53,10 @@
   // Test active push message to Renderer-process
   // 测试推送消息到Renderer进程
   win.webContents.on('did-finish-load', () => {
-    win?.webContents.send('main-process-message', new Date().toLocaleString())
-    win?.webContents.send('getConfigData',store.get('clientCode'),store.get('devices'),store.path)
+    // win?.webContents.send('main-process-message', new Date().toLocaleString())
     win?.webContents.send('getScreenTimeout',store.get('screenTimeout'))
+    win?.webContents.send('getPcName',store.get('machineName'))
+    win?.webContents.send('getConfigData',store.get('clientCode'),store.get('devices'),store.path)
   })
 
   // Make all links open with the browser, not with the application
@@ -125,8 +127,9 @@
     console.log('update confing.json')
     store.set(mode2)
     // 重新建立sockte 通讯
-    win?.webContents.send('getConfigData',store.get('clientCode'),store.get('devices'),store.path)
     win?.webContents.send('getScreenTimeout',store.get('screenTimeout'))
+    win?.webContents.send('getPcName',store.get('machineName'))
+    win?.webContents.send('getConfigData',store.get('clientCode'),store.get('devices'),store.path)
   }
   
   
diff --git a/src/samples/node-api.ts b/src/samples/node-api.ts
index faf35ee..ec05ba8 100644
--- a/src/samples/node-api.ts
+++ b/src/samples/node-api.ts
@@ -45,8 +45,14 @@
   }
 })
 ipcRenderer.on("getScreenTimeout",(_event,args)=>{
-  console.log(args,'得到配置文件时间')
-  patientInfoStore().setViewNumber(args)
+  if(args!==undefined){
+    patientInfoStore().setViewNumber(args)
+  }
+})
+ipcRenderer.on("getPcName",(_event,arg)=>{
+  if(arg!==undefined){
+    sockteStore().setPcName(arg)
+  }
 })
 setInterval(function(){
   // 检查网络状态
diff --git a/src/samples/sockteStomp.ts b/src/samples/sockteStomp.ts
index 0007296..1c8cd86 100644
--- a/src/samples/sockteStomp.ts
+++ b/src/samples/sockteStomp.ts
@@ -96,15 +96,7 @@
                     sockteStore().setweightState(resultInfo.status)
                     break
                 case "血压计":
-                    sockteStore().setxyjSockte(
-                        {
-                            deviceName:resultInfo.deviceName,
-                            type:"血压计",
-                            result:resultInfo.result,
-                            resultTime:resultInfo.resultTime,
-                            state:0
-                        }
-                    )
+                    sockteStore().setXtjState(resultInfo.status)
                     break
                 default:
                     console.log('有配置类型没有匹配')
@@ -169,11 +161,14 @@
     }
 }
 const connectCallback=function(){
-    const pcName= os.hostname()
+    const pcName= sockteStore().pcName
     // 订阅患者信息服务
     if(stompClient!==null){
+        // 订阅患者信息事件
         stompClient.subscribe(`/queue/patient/info/${pcName}`,PatientCallback)
+        // 订阅配置文件事件
         stompClient.subscribe(`/queue/workstation/config/set/${clientCode}/${pcName}`,configCallback)
+        // 发送配置文件到服务端
         stompClient.send(`/app/workstation/config/set/${clientCode}/${pcName}`,{},JSON.stringify({"clientCode":clientCode,"machineName":pcName}))
         
     }
@@ -186,8 +181,7 @@
         devices.forEach(de=>{
             if(stompClient!==null){
                 stompClient.subscribe(`/queue/${clientCode}/${de.deviceName}/result`,callback)
-                // /queue/{clientCode}/{deviceName}/keepalive
-                // stompClient.subscribe(`/queue/${clientCode}/${de.deviceName}/keepalive`,callbackState)
+                stompClient.subscribe(`/queue/${clientCode}/${de.deviceName}/keepalive`,callbackState)
                 stompClient.send(`/app/device/request/${clientCode}/${de.deviceName}`, {}, JSON.stringify({"deviceNumber":de.deviceName}));
 
             } 
@@ -220,12 +214,13 @@
  * @param codeStr 
  */
 const sendPationCode=(codeStr:string)=>{
+    const pcName= sockteStore().pcName
     const mode={
         clientCode:clientCode,
         queryCode:codeStr
     }
     if(stompClient!==null){
-        stompClient.send(`/app/patient/info/get/${os.hostname()}`,{},JSON.stringify(mode))
+        stompClient.send(`/app/patient/info/get/${pcName}`,{},JSON.stringify(mode))
     }
 }
 /**
diff --git a/src/stores/sockteInfo.ts b/src/stores/sockteInfo.ts
index 1f8aeff..e6d68bf 100644
--- a/src/stores/sockteInfo.ts
+++ b/src/stores/sockteInfo.ts
@@ -34,6 +34,7 @@
 export const sockteStore =defineStore('sockteInfo',()=>{
     const isLink=ref(true) // sockte 链接状态
     const netLink=ref(true) // 网络链接状态
+    const pcName=ref('')
     const weightSockte=ref(weightInfo) // 体重秤sockte结果
     const xyjSockte=ref(xyjInfo) // 血压计sockte结果
     const dkqSockte=ref(dkqInfo) // 读卡器sockte结果
@@ -72,6 +73,9 @@
         xyjSockte.value.resultTime=info.resultTime
         weightSockte.value.state=info.state
     }
+    function setXtjState(state:any){
+        xyjSockte.value.state=state
+    }
       /**
      * 更新血压计结果
      * @param info 体重结果
@@ -81,8 +85,11 @@
         dkqSockte.value.result=info.result
         dkqSockte.value.resultTime=info.resultTime
     }
+    function setPcName(name:any){
+        pcName.value=name
+    }
 
-    return {isLink,netLink,weightSockte,xyjSockte,dkqSockte,setsockteIsLink,setnetLink,setweightSockte,
-        setweightState,
+    return {isLink,netLink,weightSockte,xyjSockte,dkqSockte,pcName,setsockteIsLink,setnetLink,setweightSockte,
+        setweightState,setPcName,setXtjState,
         setxyjSockte,setdkqSockte}
 })
\ No newline at end of file
diff --git a/src/views/home/index.vue b/src/views/home/index.vue
index e1a76c2..4c6f35a 100644
--- a/src/views/home/index.vue
+++ b/src/views/home/index.vue
@@ -2,11 +2,11 @@
 import { userInfoStore } from '@/stores/userInfo'
 import { sockteStore } from '@/stores/sockteInfo'
 import { patientInfoStore } from '@/stores/patient'
-import { ipcRenderer } from 'electron'
 import os from "os"
 import { reactive,computed, toRefs,onMounted ,ref,watch} from "vue"
 import{sendPationCode,sendPationSet} from '../../samples/sockteStomp'
 import {formatDate} from '@/utils/formatTime'
+
  export default {
         setup() {
             let  timer:any=0
@@ -183,7 +183,7 @@
                     state.Newdate=formatDate(new Date(),"YYYY-mm-dd HH:MM:SS")
                 },1000)
             })
-            return{ ...toRefs(state),isLink,netLink,weightInfo,patientInfo,inputRef,AudioRef0,AudioRef,AudioRef2,AudioRef3,inputChabge
+            return{ ...toRefs(state),isLink,netLink,weightInfo,patientInfo,xyjInfo,inputRef,AudioRef0,AudioRef,AudioRef2,AudioRef3,inputChabge
             }
         }
     }
@@ -271,7 +271,9 @@
                 <div class="conText">{{aimTSL}}</div>
             </div>
             <div class="grid-item">
-                <div class="lableText">血压:</div>
+                <div class="lableText" v-if="xyjInfo.state===2">血压:</div>
+                <div class="lableText" v-if="xyjInfo.state===1" style="color:red">血压通讯服务正常运行但未联通设备</div>
+                <div class="lableText" v-if="xyjInfo.state===0" style="color:red">血压通讯服务不正常 </div>
                 <div class="conText">{{gao_ya}}/{{di_ya}}</div>
             </div>
         </div>

--
Gitblit v1.8.0