up
chenyc
2022-07-04 359a3d84ba7d9378cb183710db221580d7ba845a
up
8个文件已修改
1个文件已添加
313 ■■■■ 已修改文件
.vscode/tasks.json 78 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
electron/main/index.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
index.html 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
logipc.png 补丁 | 查看 | 原始文档 | blame | 历史
package.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/samples/node-api.ts 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/samples/sockteStomp.ts 89 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stores/sockteInfo.ts 58 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/home/index.vue 79 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.vscode/tasks.json
@@ -1,14 +1,78 @@
{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "label": "start .debug.script.mjs",
      "label": "haas-studio: Config",
      "type": "shell",
      "command": "node .vscode/.debug.script.mjs",
      "isBackground": true,
      "problemMatcher": []
      "command": "aos",
      "args": [
        "make",
        "@haaseduk1",
        "-c",
        "config"
      ],
      "presentation": {
        "focus": true
    }
  ]
    },
    {
      "label": "haas-studio: Make",
      "type": "shell",
      "command": "aos",
      "args": [
        "make"
      ],
      "presentation": {
        "focus": true
      }
    },
    {
      "label": "haas-studio: Burn",
      "type": "shell",
      "command": "aos",
      "args": [
        "burn"
      ],
      "presentation": {
        "focus": true
      }
    },
    {
      "label": "haas-studio: Serial Monitor",
      "type": "shell",
      "command": "aos",
      "args": [
        "monitor",
        "",
        "1500000"
      ],
      "presentation": {
        "focus": true,
        "panel": "dedicated"
      }
    },
    {
      "label": "haas-studio: Clean",
      "type": "shell",
      "command": "aos",
      "args": [
        "make",
        "clean"
      ],
      "presentation": {
        "focus": true
      }
    },
    {
      "label": "dummy_aos3.3.0",
      "command": "pwd"
    }
  ],
  "windows": {
    "options": {
      "env": {
        "PATH": "C:\\ProgramData\\aos\\miniconda3;C:\\ProgramData\\aos\\miniconda3\\Scripts;C:\\ProgramData\\aos\\miniconda3\\Library\\bin;${env:PATH}"
      }
    }
  }
}
electron/main/index.ts
@@ -52,7 +52,7 @@
  // 测试推送消息到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('deviceList'))
    win?.webContents.send('getConfigData',store.get('clientCode'),store.get('deviceList'),store.path)
  })
  // Make all links open with the browser, not with the application
index.html
@@ -2,7 +2,7 @@
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" href="/favicon.ico" />
    <link rel="icon" href="/logipc.png" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="Content-Security-Policy" content="script-src 'self' 'unsafe-inline';" />
    <title>自助签到</title>
logipc.png
package.json
@@ -1,5 +1,5 @@
{
  "name": "electron-vue-vite",
  "name": "Device-Communication-UI",
  "version": "2.0.0",
  "main": "dist/electron/main/index.js",
  "author": "",
src/samples/node-api.ts
@@ -3,7 +3,8 @@
import { ipcRenderer } from 'electron'
import {creatorClient} from './sockteStomp'
import {sockteStore} from '@/stores/sockteInfo'
import internetAvailable  from "internet-available"
// import internetAvailable  from "internet-available"
var internetAvailable = require("internet-available")
let deviceList=[]
let clientCode=''
// 主进程发送消息到渲染进程
src/samples/sockteStomp.ts
@@ -1,4 +1,5 @@
import Stomp from 'stompjs'
import os from 'os'
var stompClient: Stomp.Client | null=null
import { userInfoStore } from '@/stores/userInfo'
@@ -14,7 +15,10 @@
let devices:Array<device>=[]
let clientCode:string=''
/**
 * 保存结果到vuex
 * @param resultInfo 结果写入
 */
const writeResult=(resultInfo:any)=>{
    if(devices.length>0){
        const deviceInfo=devices.find(de=>{de.deviceName===resultInfo.deviceName})
@@ -27,7 +31,7 @@
                            type:"读卡器",
                            result:resultInfo.result,
                            resultTime:resultInfo.resultTime,
                            state:true
                            state:0
                        }
                    )
                    break
@@ -38,7 +42,7 @@
                            type:"体重秤",
                            result:resultInfo.result,
                            resultTime:resultInfo.resultTime,
                            state:true
                            state:0
                        }
                    )
                    break
@@ -49,7 +53,47 @@
                            type:"血压计",
                            result:resultInfo.result,
                            resultTime:resultInfo.resultTime,
                            state:true
                            state:0
                        }
                    )
                    break
                default:
                    console.log('有配置类型没有匹配')
            }
        }
    }
}
const writeStatu=(resultInfo:any)=>{
    if(devices.length>0){
        const deviceInfo=devices.find(de=>{
            console.log(de.deviceName,resultInfo.deviceName)
            return de.deviceName===resultInfo.deviceName
        })
        if(deviceInfo!==undefined){
            switch(deviceInfo.deviceType){
                case '读卡器':
                    sockteStore().setdkqSockte(
                        {
                            deviceName:resultInfo.deviceName,
                            type:"读卡器",
                            result:resultInfo.result,
                            resultTime:resultInfo.resultTime,
                            state:0
                        }
                    )
                    break
                case "体重秤":
                    sockteStore().setweightState(resultInfo.status)
                    break
                case "血压计":
                    sockteStore().setxyjSockte(
                        {
                            deviceName:resultInfo.deviceName,
                            type:"血压计",
                            result:resultInfo.result,
                            resultTime:resultInfo.resultTime,
                            state:0
                        }
                    )
                    break
@@ -75,26 +119,38 @@
const callbackState=function(message:any){
    if (message.body) {
        const data=JSON.parse(message.body)
    if(data.deviceName)
        console.log(data,'设备心跳包数据')
        writeResult(data)
    } else {
        alert("接收数据异常");
        if(data){
            writeStatu(data)
    }
        console.log(data,'设备心跳包数据')
    }
}
const PatientCallback=function(message:any){
    if (message.body) {
        const data=JSON.parse(message.body)
        console.log(data,'患者信息读取')
    }
}
const connectCallback=function(){
    console.log("链接成功",stompClient)
    const pcName= os.hostname()
    // 订阅患者信息服务
    stompClient.subscribe(`/queue/patient/info/${pcName}`,PatientCallback)
    console.log("链接成功",stompClient,pcName)
    // 更新sockte链接状态
    sockteStore().setsockteIsLink(true)
    console.log(sockteStore().isLink)
    if(stompClient!==null){
    console.log(devices)
        if(devices.length>0){
            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.send(`/app/device/request/${clientCode}/${de.deviceName}`, {}, JSON.stringify({"deviceNumber":de.deviceName}));
            })
        }
        
            }
        })
    }
}
const error_callback=function(error:any){
@@ -118,4 +174,9 @@
    stompClient.connect({}, connectCallback,error_callback)
}
export {creatorClient}
const sendPationCode=(codeStr:string)=>{
    if(stompClient!==null){
        stompClient.send(`/app/patient/info/get/${os.hostname()}`,{},codeStr)
    }
}
export {creatorClient,sendPationCode}
src/stores/sockteInfo.ts
@@ -7,74 +7,80 @@
    deviceName:string;
    result:string;
    resultTime:string;
    state:boolean;
    state:0;
}
let weightInfo:info={
    type:"体重秤",
    state:false,
    state:0,
    deviceName:"",
    result:"",
    result:"0",
    resultTime:""
let xyjInfo:info={
    type:"血压计",
    state:false,
    state:0,
    deviceName:"",
    result:"",
    resultTime:""
let dkqInfo:info={
    type:"读卡器",
    state:false,
    state:0,
    deviceName:"",
    result:"",
    resultTime:""
}
export const sockteStore =defineStore('sockteInfo',()=>{
    const isLink=ref(false) // sockte 链接状态
    const netLink=ref(false) // 网络链接状态
    const weightSockte=weightInfo // 体重秤sockte结果
    const xyjSockte=xyjInfo // 血压计sockte结果
    const dkqSockte=dkqInfo // 读卡器sockte结果
    const netLink=ref(true) // 网络链接状态
    const weightSockte=ref(weightInfo) // 体重秤sockte结果
    const xyjSockte=ref(xyjInfo) // 血压计sockte结果
    const dkqSockte=ref(dkqInfo) // 读卡器sockte结果
    // 更新连接状态
    function setsockteIsLink(Link:boolean){
        isLink.value=Link
    }
    // 更新连接状态
    // 更新网络连接状态
    function setnetLink(Link:boolean){
        netLink.value=Link
    }
    /**
     * 更新体重秤结果
     * @param roleText 体重结果
     * @param info 体重结果
     */
    function setweightSockte(info:info){
        weightSockte.deviceName=info.deviceName
        weightSockte.result=info.result
        weightSockte.resultTime=info.resultTime
        weightSockte.state=info.state
        weightSockte.value.deviceName=info.deviceName
        weightSockte.value.result=info.result
        weightSockte.value.resultTime=info.resultTime
    }
     /**
     * 更新体重秤工作状态
     * @param state 体重秤运行状态
     */
      function setweightState(state:any){
        weightSockte.value.state=state
    }
      /**
     * 更新血压计结果
     * @param roleText 体重结果
     * @param info 体重结果
     */
    function setxyjSockte(info:info){
        xyjSockte.deviceName=info.deviceName
        xyjSockte.result=info.result
        xyjSockte.resultTime=info.resultTime
        xyjSockte.state=info.state
        xyjSockte.value.deviceName=info.deviceName
        xyjSockte.value.result=info.result
        xyjSockte.value.resultTime=info.resultTime
    }
      /**
     * 更新血压计结果
     * @param roleText 体重结果
     * @param info 体重结果
     */
    function setdkqSockte(info:info){
        dkqSockte.deviceName=info.deviceName
        dkqSockte.result=info.result
        dkqSockte.resultTime=info.resultTime
        dkqSockte.state=info.state
        dkqSockte.value.deviceName=info.deviceName
        dkqSockte.value.result=info.result
        dkqSockte.value.resultTime=info.resultTime
    }
    return {isLink,netLink,weightSockte,xyjSockte,dkqSockte,setsockteIsLink,setnetLink,setweightSockte,setxyjSockte,setdkqSockte}
    return {isLink,netLink,weightSockte,xyjSockte,dkqSockte,setsockteIsLink,setnetLink,setweightSockte,
        setweightState,
        setxyjSockte,setdkqSockte}
})
src/views/home/index.vue
@@ -2,36 +2,66 @@
import { userInfoStore } from '@/stores/userInfo'
import { sockteStore } from '@/stores/sockteInfo'
import { ipcRenderer } from 'electron'
import { reactive,computed, toRefs } from "vue"
import { reactive,computed, toRefs,onMounted ,ref} from "vue"
import{sendPationCode} from '../../samples/sockteStomp'
import {formatDate} from '@/utils/formatTime'
import { popper } from '@popperjs/core'
 export default {
        setup() {
            const user = userInfoStore()
            const sockte= sockteStore()
            const inputRef=ref()
            const isLink= computed(()=>{
                return sockte.isLink
                return !sockte.isLink
            }) 
            const netLink= computed(()=>{
                return sockte.netLink
                return !sockte.netLink
            })
            const weightInfo= computed(()=>{
                return sockte.weightSockte
            })
            const state=reactive({
                dialogVisible:false,
                isActive:false,
                inputCode:"",
                Newdate:""
            })
            const ubtCilert=()=>{
                console.log('ss')
                // console.log(user.userInfo)
                // console.log(sockteStore().isLink)
                // ipcRenderer.send('main-process-message2', { 'param1': "hello" });
                // console.log(window.myApi.fun('陈银城'))
            const inputChabge=()=>{
                sendPationCode(state.inputCode)
            }
            return{ ...toRefs(state), ubtCilert,isLink,netLink
            onMounted(() => {
                console.log('Component is mounted!')
                inputRef.value.focus();
                console.log(inputRef)
                setTimeout(function(){
                    // state.inputCode="3434"
                    console.log('-----------sdsds')
                    inputRef.value.focus();
                },10000)
                setInterval(function(){
                    state.Newdate=formatDate(new Date(),"YYYY-mm-dd HH:MM:SS")
                    console.log(state.Newdate,'----ss')
                },1000)
            })
            return{ ...toRefs(state),isLink,netLink,weightInfo,inputRef,inputChabge
            }
        }
    }
</script>
<template>
    <div class="home">
        <!-- <el-button @click="ubtCilert">
            test
        </el-button> -->
        <el-dialog
            title="提示"
            v-model="netLink"
            width="30%">
            <span>无法链接到网络!</span>
        </el-dialog>
        <el-dialog
            title="提示"
            v-model="isLink"
            width="30%">
            <span>sockte连接失败正在重连。。。。。。</span>
        </el-dialog>
        <el-row>
            <el-col :span="12">
                <div class="tale">
@@ -39,8 +69,9 @@
                </div>
            </el-col>
            <el-col :span="12">
                <div> sockte连接状态{{isLink}}</div>
                <div> 网络连接状态{{netLink}}</div>
                <!-- <div> sockte连接状态{{isLink}}</div>
                <div> 网络连接状态{{netLink}}</div> -->
                <el-input id="inputCode" @change="inputChabge" v-model="inputCode" ref="inputRef" placeholder="" />
            </el-col>
        </el-row>
        <div class="grid-container">
@@ -55,11 +86,11 @@
            </div>
            <div class="grid-item">
                <div class="lableText">当前时间:</div>
                <div class="conText">2022-06-21 14:10</div>
                <div class="conText">{{Newdate}}</div>
            </div>
            <div class="grid-item">
                <div class="lableText">当前时间:</div>
                <div class="conText">2022-06-21 14:10</div>
                <div class="lableText">透析号:</div>
                <div class="conText">123456</div>
            </div>
            <div class="grid-item">
                <div class="lableText">机号:</div>
@@ -74,8 +105,12 @@
                <div class="conText">88</div>
            </div>
            <div class="grid-item">
                <div class="lableText">透前称重(kg):</div>
                <div class="conText">90</div>
                <div>
                    <div class="lableText" v-if="weightInfo.state===2">透前称重(kg):</div>
                    <div class="lableText" v-if="weightInfo.state===1" style="color:red">体重秤通讯服务正常运行但未联通设备</div>
                    <div class="lableText" v-if="weightInfo.state===0" style="color:red">体重秤通讯服务不正常 </div>
                    <div class="conText">{{weightInfo.result}}</div>
                </div>
            </div>
            <div class="grid-item">
                <div class="lableText">目标脱水量:</div>
@@ -137,4 +172,8 @@
    margin-top: 15pt;
    color: #769aff;
}
.active{
    background: #c1c2c6;
    color: black;
}
</style>