chenyc
2025-04-22 1051ab47ac671486801296ccf0ad7c0ed527d7e6
src/views/home/index.vue
@@ -9,7 +9,7 @@
                        <img class="image_1"  style="margin-left: 20px;display: inline-block;"  referrerpolicy="no-referrer" src="@/assets/logo.png" />
                    
                    </div>
                      <div class="titlecss">自助签到系统</div>
                      <div @click="yanzhengTUpian" class="titlecss">自助签到系统</div>
                </div> 
            </el-col>
            <el-col v-if="dialogVisible" :span="12" style="text-align: right;padding-top: 10px;">
@@ -53,8 +53,8 @@
                    <div style="height: 77%;">
                        <div style="display: grid;grid-template-columns: minmax(250px, 40%) 1fr; height: 100%; padding-left: 20px;padding-top: 20px;">
                            <!-- 头像 -->
                            <div  :style="{backgroundImage:`url(${patientInfo.patientAvatarIcon})`}" style="background-size:100% 100%;height: 100%;" >
                              <div style="width:140px; height: 50px; line-height: 50px; font-size: 25px; background: #DFB144;color: #FFFFFF; font-weight: 500; text-align: center; border-radius: 0px 8px 0px 30px; float: right;">
                            <div  :style="{backgroundImage:`url(${patientInfo.patientAvatarIcon.replace(/\\/g, '/').replace(/%EF%BF%BD/g, '')})`}" style="background-size:100% 100%;height: 100%;" >
                              <div style="width:140px; height: 50px; line-height: 50px; font-size: 25px; background: #9F61DC;color: #FFFFFF; font-weight: 500; text-align: center; border-radius: 0px 8px 0px 30px; float: right;">
                                {{patientInfo.name}}
                              </div>
                            </div>
@@ -75,23 +75,23 @@
                <div style="height: 31%; margin-top: 20px;border-radius: 12px;" >
                    <el-row style="height: 100%;background:rgba(246, 244, 244, 0.3);border-radius: 12px;opacity: 0.9;">
                        <el-col :span="8">
                            <div class="textwenben" style="height: 28%; font-size: 25px;background-color: #DFB144; border-radius: 12px 0 0 0;">
                            <div class="textwenben" style="height: 28%; font-size: 25px;background-color: #9F61DC; border-radius: 12px 0 0 0;">
                              <template v-if="configData.deviceType==='体重秤'">
                                <template v-if="patientInfo.isAfterMed===0&&!configData.gantiziShow">
                                  机号/床位号
                                </template>
                                <template v-else>干体重(kg)</template>
                                <template v-else>理想体重(kg)</template>
                                  
                              </template>
                              <template v-else>
                                <template v-if="!configData.gantiziShow">
                                  机号/床位号
                                </template>
                                <template v-else>干体重(kg)</template>
                                <template v-else>理想体重(kg)</template>
                                
                              </template>
                            </div>
                            <div class="textwenben" style="height: 70%; font-size: 80px; color: #DFB144;">
                            <div class="textwenben" style="height: 70%; font-size: 80px; color: #9F61DC;font-weight: 1000;">
                              <template v-if="configData.deviceType==='体重秤'">
                                  <template v-if="patientInfo.isAfterMed===0&&!configData.gantiziShow">
                                    {{ patientInfo.deviceNo }}
@@ -129,7 +129,7 @@
                                
                              </template>
                            </div>
                            <div class="textwenben" style="height: 70%; font-size: 80px; color: #41B593;
                            <div class="textwenben" style="height: 70%; font-size: 80px; color: #41B593; font-weight: 1000;
                              border-left: #FFFFFF solid 2px;border-right: #FFFFFF solid 2px;">
                                <template v-if="configData.deviceType==='体重秤'">
                                  <template v-if="patientInfo.isAfterMed===0">
@@ -218,9 +218,10 @@
    <div  style="height: 18%;">
        <el-row>
            <el-col :span="6" style="padding-left: 40px; font-size: 34px; color: #FFFFFF;">
                {{formatDate(new Date(),'HH:MM')}}
              {{date.substring(11,16)}}
                <br>
                {{formatDate(new Date(),'YYYY-mm-dd')}}
                <!-- {{formatDate(new Date(),'YYYY-mm-dd')}} -->
                {{date.substring(0,11)}}
            </el-col>
            <el-col :span="12" style="font-size: 40px;color: #FFFFFF;text-align: center; padding-top: 20px;">
                请将脸部对准摄像头
@@ -239,6 +240,20 @@
           返回
          </div>
        </div>
        <el-dialog
            v-model="centerDialogVisible"
            title=""
            width="40%"
            align-center
        >
            <span>
              <div>
                  找到该程序根目录下imgs/1708401593426.png下路径 把图片名改成一致 就可以测试了,
              </div>
                <el-button @click="yanzhengTUpianClick">验证</el-button>
            </span>
        </el-dialog>
    
   
  </div>
@@ -259,24 +274,37 @@
import { sendPationCodeApi } from '../../samples/httpApi'
import { formatDate,jgTime,isworkTime } from '@/utils/formatTime'
import { confingInfoStore } from '@/stores/StoresConfing'
import {base64toFile} from '@/samples/faceApi'
import {base64toFile,yanzhengimg} from '@/samples/faceApi'
import{initPort} from '@/samples/portApi'
import{initPort as oumulongHbp9030 } from '@/samples/deviceApi/oumulong-HBP-9030'
import{initPort as  TM2655VP} from '@/samples/deviceApi/TM2655VP'
import{initPort as zhiRongT605 } from '@/samples/deviceApi/zhiRongT605'
import{initPort as zhiRongHehui } from '@/samples/deviceApi/zhiRongHehui'
import{initPort as zhiRongShantou } from '@/samples/deviceApi/zhiRongShantou'
import{initPort as taiHengM523 } from '@/samples/deviceApi/taiHengM523'
import{initPort as XK3190A12 } from '@/samples/deviceApi/XK3190A12'
import {initPort as mbp7000} from '@/samples/deviceApi/mbp7000'
import {initPort as mbp7000qy} from '@/samples/deviceApi/mbp7000qy'
import {initPort as omlhbp9020} from '@/samples/deviceApi/oml-HBP-9020'
import {initPort as mbp9020} from '@/samples/deviceApi/mbp-9020'
import {initPort as rbp9000c} from '@/samples/deviceApi/RBP-9000c'
import {initPort as yuyueDevice} from '@/samples/deviceApi/yuyue'
import {initPort as M503} from '@/samples/deviceApi/M503'
import {initPort as seca102} from '@/samples/deviceApi/seca102'
import {initPort as seca101Banger} from '@/samples/deviceApi/seca101Banger'
import {initPort as liangjiang} from '@/samples/deviceApi/liangjiang'
import {initPort as xinanguojiTZC} from '@/samples/deviceApi/xinanguojiTZC'
// 引入模块
import config from '../../../package.json'
import { Delete, Download, Plus, ZoomIn } from '@element-plus/icons-vue'
// 读取体重文件
import{todatatzs } from '@/samples/deviceApi/seca101'
import {ElMessage } from 'element-plus'
import {ElMessage, ElNotification, UploadFile, UploadInstance, UploadProps } from 'element-plus'
const { proxy } = getCurrentInstance() as any;
// 人脸检测对象
const options = new SsdMobilenetv1Options({
@@ -290,7 +318,6 @@
const stream = ref(null) // 当前流
const getUserMediaFail = ref(false) // 获取用户媒体失败
let lsDateTime:any=new Date()
let imgSrc:'';
const msg = ref<string>("没识别到人脸...");
const datetext=computed(()=>{
  return  formatDate(new Date(),'YYYY-mm-dd  WWW')
@@ -319,7 +346,17 @@
const gao_ya=ref("")//高压
const di_ya=ref("")//低压
const  mai_bu=ref("")//脉搏,
const centerDialogVisible=ref(false)
// 打开图片验证
const yanzhengTUpian=()=>{
  centerDialogVisible.value=true
}
//验证图片
const yanzhengTUpianClick=()=>{
  const path = './imgs/1708401593426.png'
  yanzhengimg(path)
}
const tzjs=computed(()=>{
  if(weightInfo.value.result!=='0'&&weightInfo.value.result!==undefined&&weightInfo.value.result!==null){
    return (patientInfo.value.preWeight-Number(weightInfo.value.result)).toFixed(1)
@@ -328,7 +365,6 @@
  }
 
})
const configData=computed(()=>{
  return confingInfoStore().confingInfo
})
@@ -350,7 +386,13 @@
  if(!netLink.value){
    ElMessage.success('网络已经连接')
  }else{
    ElMessage.warning('网络已断开,等待重连')
    // ElNotification({
    //   title: '异常',
    //   message: '网络已断开,等待重连',
    //   type: 'warning',
    //   duration:10000
    // })
    // ElMessage.warning('网络已断开,等待重连')
  }
})
@@ -431,10 +473,11 @@
  }
  if (isUseFaceRecogService.value) {
    console.log('开启人脸识别')
    lsDateTime=new Date()
    dialogVisible.value = true
  }else{
    console.log('关闭人脸识别')
    dialogVisible.value = true
    dialogVisible.value = false
  }
}
@@ -667,6 +710,7 @@
    }
    // 没有找到患者
    else if (patientInfo.value.name === '') {
      timer=new Date()
      ipcRenderer.invoke('logger', '接收到的患者为空')
      console.log('接收到的患者为空')
      if (isUseFaceRecogService.value) {
@@ -743,14 +787,36 @@
        }else if(Number(patientInfo.value.pureWeight) !== 0&&patientInfo.value.isAfterMed===1 && patientInfo.value.preWeight>10){
          aimTSL.value = (Number(patientInfo.value.preWeight)- Number(patientInfo.value.pureWeight) - Number(patientInfo.value.clothesWeight)).toFixed(2)
        }
    }// 要过4秒才能重复播报这个消息
    else if(patientInfo.value.code===''&&weightInfo.value.result !== "0"&&X>configData.value.BobaoJg){
      timer=new Date()
      speech.value?.speak({ text: "没有识别的患者,请先验证患者" }).then(() => {
      })
    }// 要过设置的10秒才能重复播报这个消息
    else if(patientInfo.value.code===''&&weightInfo.value.result !== "0"){
      //10后才执行
      if(播报是否完成.value){
        播报是否完成.value=false
        setTimeout(bobaoyuy, configData.value.BobaoJg*1000);
      }else{
        console.log('上一次播报还没完成,放弃这次播报',播报是否完成.value)
      }
    }
  }
);
// 默认播报完成
const 播报是否完成=ref(true)
const bobaoyuy=()=>{
  if(patientInfo.value.name===''){
    speech.value?.speak({ text: "没有识别的患者,请先验证患者",onend:()=>{
      console.log('播报完成')
      播报是否完成.value=true
      console.log('播报完成111111',播报是否完成.value)
      }
    })
    播报是否完成.value=true
  }
}
// 血压发送了变化
watch(
  () => xyjInfo.value.resultTime,
@@ -808,6 +874,12 @@
  updatePatient(mode).then(re=>{
    ElMessage.success('结果发送成功')
    ipcRenderer.invoke('logger', '结果上传成功')
    // 测量结果发送成功后就一定要体重秤归零才行  关闭体重秤归零状态为false
    // 只增对M503
    if(configData.value.tzc_type==='M503'||configData.value.tzc_type==='seca101Banger'){
      console.log('发送清理体重归零')
      sockteStore().setis测量准备(false)
    }
    clockNum.value = Number(configData.value.timeJg/1000)
    return false
  }).catch(re=>{
@@ -840,16 +912,17 @@
    ipcRenderer.invoke('logger', '结果上传成功')
    // 倒计时结果显示
    clockNum.value = Number(configData.value.timeJg/1000)
    return false
  }).catch(re=>{
    ElMessage('结果发送失败')
    console.log('结果发送失败')
    ipcRenderer.invoke('logger', `结果发送失败:第${fasongNum.value}次,3秒后重新发送`)
    ipcRenderer.invoke('logger', `结果发送失败:第${fasongNum.value}次,2秒后重新发送`)
    if(fasongNum.value<3){
      setTimeout(sundModeXyj,5000);
      setTimeout(sundModeXyj,2000);
    }
    else{
      ipcRenderer.invoke('logger', '3次结果上传都失败放弃本次请求')
      ipcRenderer.invoke('logger', '2次结果上传都失败放弃本次请求')
      return false
    }
  })
@@ -910,8 +983,13 @@
  }
}
const updateChengxu=()=>{
  console.log('检查更新')
  ipcRenderer.invoke("check-update");
  console.log('检查更新',)
  if(configData.value.isLanFace===true||sockteStore().isLink){
    console.log('是内网不能检查更新')
  }else{
    ipcRenderer.invoke("check-update");
  }
}
onMounted(() => {
  console.log('页面初始化', os.hostname())
@@ -933,6 +1011,18 @@
        TM2655VP(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
      }else if(configData.value.xyj_type==='mbp7000'){
        mbp7000(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
      }else if(configData.value.xyj_type==='mbp7000qy'){
        mbp7000qy(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
      }else if(configData.value.xyj_type==='mbp9020'){
        mbp9020(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
      }
      else if(configData.value.xyj_type==='RBP-9000c'){
        rbp9000c(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
        // 鱼跃血压计
      }else if(configData.value.xyj_type==='yuyue'){
        yuyueDevice(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
      }else if(configData.value.xyj_type==='oml-HBP-9020'){
        omlhbp9020(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
      }
      else{
        oumulongHbp9030(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
@@ -948,16 +1038,24 @@
        M503(configData.value.tzcPortPath,configData.value.tzcBaudRate)
      }else if(configData.value.tzc_type==='seca102'){
        seca102(configData.value.tzcPortPath,configData.value.tzcBaudRate)
      }
      // seca101读取文件
      else if(configData.value.tzc_type==='seca101'){
        console.log('体重是读取文件')
      else if(configData.value.tzc_type==='seca101Banger'){
        seca101Banger(configData.value.tzcPortPath,configData.value.tzcBaudRate)
      }// 耀华XK3190-A12 
      else if(configData.value.tzc_type==='XK3190-A12'){
        XK3190A12(configData.value.tzcPortPath,configData.value.tzcBaudRate)
      }else if(configData.value.tzc_type==='zhiRongHehui'){
        zhiRongHehui(configData.value.tzcPortPath,configData.value.tzcBaudRate)
        // 福州连江 就是1200 南京圣洁 9600
      }else if(configData.value.tzc_type==='lianjiang'){
        liangjiang(configData.value.tzcPortPath,configData.value.tzcBaudRate)
      }else if(configData.value.tzc_type==='xinanguojiTZC'){
        xinanguojiTZC(configData.value.tzcPortPath,9600)
      }
      // 志荣粤康  2400
      else if(configData.value.tzc_type==='zhiRongShantou'){
        zhiRongShantou(configData.value.tzcPortPath,configData.value.tzcBaudRate)
      }
      else{
        zhiRongT605(configData.value.tzcPortPath,configData.value.tzcBaudRate)
@@ -1025,7 +1123,7 @@
    speech.value = new Speech();
    speech.value?.setLanguage('zh-CN')
    speech.value?.init().then(() => {
      console.log('语音初始化成功')
      console.log('加载人脸采集模型成功')
    })
  },8000)
})
@@ -1046,7 +1144,10 @@
  const resizedResult = resizeResults(result, dims)
  const box = resizedResult.box
  // 不要小头像
  if(box._height<120) return detectFace()
  // console.log('000')
  const h=configData.value.imgHeight===undefined?140:configData.value.imgHeight
  // console.log('000',h)
  if(box._height<h) return detectFace()
  //检测框是否在取景框内
  // if (!checkInViewFinder(box)) return detectFace()
  // drawViewFinder()
@@ -1054,7 +1155,6 @@
  draw.drawDetections(canvas.value, resizedResult.box);
  drawBox(box, '')
  // video.value.pause()
  // //截取人脸图片
  const image = await cameraShoot(
    video.value,
@@ -1064,15 +1164,17 @@
  )
  if (!image) {
    drawBox(box, '识别失败')
    // 开启识别
    video.value.play()
    return detectFace()
  }
  const X= jgTime(lsDateTime,new Date())
  console.log('----',X,dialogVisible.value)
  // console.log(image)
  if(dialogVisible.value&&X>configData.value.face_push&&isworkTime(new Date())){
  //人脸上传到阿里云
  // 只有是结果归零状态才能进行识别
  console.log(`检查人脸是否要上传到阿里云识别:${sockteStore().is测量准备}`)
  if(dialogVisible.value&&X>configData.value.face_push&&isworkTime(new Date())&&sockteStore().is测量准备){
    lsDateTime=new Date()
    console.log(X,'上传阿里识别间隔')
    // console.log(X,'上传图片间隔')
    base64toFile(image)
  }
  return detectFace()
@@ -1109,8 +1211,11 @@
  const canvas = document.createElement('canvas')
  canvas.width = video.videoWidth
  canvas.height = video.videoHeight
  canvas.getContext('2d')?.drawImage(video, 0, 0, canvas.width, canvas.height)
  // 参数:图片,裁剪开始x坐标,裁剪开始y坐标,裁剪宽度,裁剪高度,目标x坐标,目标y坐标,目标宽度,目标高度
  // context.drawImage(image, 100, 100, 200, 200, 0, 0, 200, 200);
  canvas.getContext('2d')?.drawImage(video, startPoint.x-10,startPoint.y-10,width+20,height+20,0,0,width+10,height+10)
  const imgSrc = canvas?.toDataURL('image/png');
  return imgSrc
}
// 画盒子