Sfoglia il codice sorgente

添加打印功能

wanglaoye 1 anno fa
parent
commit
b2cd7e6637

+ 12 - 0
log/2023-7-10.log

@@ -0,0 +1,12 @@
+[2023-07-10 09:41:36.099] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-10 09:41:38.268] [info]  89:[object Object]
+[2023-07-10 09:41:38.285] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'
+[2023-07-10 10:28:40.316] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-10 10:28:42.256] [info]  89:[object Object]
+[2023-07-10 10:28:42.264] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'
+[2023-07-10 10:31:08.415] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-10 10:31:10.270] [info]  89:[object Object]
+[2023-07-10 10:31:10.287] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'
+[2023-07-10 10:37:08.544] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-10 10:37:10.459] [info]  89:[object Object]
+[2023-07-10 10:37:10.470] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'

+ 6 - 0
log/2023-7-11.log

@@ -0,0 +1,6 @@
+[2023-07-11 09:51:17.536] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-11 09:51:20.343] [info]  89:[object Object]
+[2023-07-11 09:51:20.362] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'
+[2023-07-11 12:43:03.023] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-11 12:43:05.194] [info]  89:[object Object]
+[2023-07-11 12:43:05.207] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'

+ 3 - 0
log/2023-7-12.log

@@ -0,0 +1,3 @@
+[2023-07-12 10:03:08.512] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-12 10:03:10.313] [info]  89:[object Object]
+[2023-07-12 10:03:10.331] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'

+ 3 - 0
log/2023-7-5.log

@@ -0,0 +1,3 @@
+[2023-07-05 17:58:15.202] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-05 17:58:17.247] [info]  89:[object Object]
+[2023-07-05 17:58:17.264] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'

+ 33 - 0
log/2023-7-6.log

@@ -0,0 +1,33 @@
+[2023-07-06 10:01:52.102] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-06 10:01:53.927] [info]  89:[object Object]
+[2023-07-06 10:01:53.938] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'
+[2023-07-06 10:19:33.233] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-06 10:19:35.320] [info]  89:[object Object]
+[2023-07-06 10:19:35.330] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'
+[2023-07-06 10:42:11.775] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-06 10:42:13.677] [info]  89:[object Object]
+[2023-07-06 10:42:13.688] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'
+[2023-07-06 10:44:11.766] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-06 10:44:13.667] [info]  89:[object Object]
+[2023-07-06 10:44:13.679] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'
+[2023-07-06 10:45:22.299] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-06 10:45:24.205] [info]  89:[object Object]
+[2023-07-06 10:45:24.214] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'
+[2023-07-06 10:49:06.348] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-06 10:49:08.127] [info]  89:[object Object]
+[2023-07-06 10:49:08.137] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'
+[2023-07-06 11:07:10.239] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-06 11:07:11.977] [info]  89:[object Object]
+[2023-07-06 11:07:11.989] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'
+[2023-07-06 11:12:13.031] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-06 11:12:14.783] [info]  89:[object Object]
+[2023-07-06 11:12:14.796] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'
+[2023-07-06 11:35:09.807] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-06 11:35:11.540] [info]  89:[object Object]
+[2023-07-06 11:35:11.550] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'
+[2023-07-06 15:59:24.412] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-06 15:59:26.605] [info]  89:[object Object]
+[2023-07-06 15:59:26.616] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'
+[2023-07-06 16:22:17.785] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-06 16:22:20.162] [info]  89:[object Object]
+[2023-07-06 16:22:20.179] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'

+ 3 - 0
log/2023-7-7.log

@@ -0,0 +1,3 @@
+[2023-07-07 12:44:39.892] [info]  38:D:\web\product\electron\patient_sign\dist\electron
+[2023-07-07 12:44:41.800] [info]  89:[object Object]
+[2023-07-07 12:44:41.810] [info]  updater-133:Error: ENOENT: no such file or directory, open 'D:\web\product\electron\patient_sign\dist\electron\dev-app-update.yml'

+ 132 - 0
public/pm.html

@@ -0,0 +1,132 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+  <meta charset="UTF-8" />
+  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
+  <title>Document</title>
+  <style>
+    body,
+    html {
+      padding: 0;
+      margin: 0;
+      font-size: 14px;
+      
+    }
+
+    @page {
+      margin: 0px;
+    }
+
+    .text-center {
+      text-align: center;
+    }
+
+    .mt {
+      margin-top: 5px;
+    }
+
+    .mt-1 {
+      margin-top: 10px;
+    }
+
+    .mt-2 {
+      margin-top: 20px;
+    }
+
+    .mt-3 {
+      margin-top: 30px;
+    }
+
+    .ml-1 {
+      margin-left: 10px;
+    }
+
+    .p-1 {
+      padding: 10px;
+    }
+
+    .font-bold {
+      font-weight: bold;
+    }
+
+    .w-50 {
+      width: 50%;
+    }
+    .itemtitle{
+      width: 25%;
+      padding:4px 5px;
+      border-right:1px solid #000;
+    }
+    .itemstyle{
+      width: 75%;
+      padding:4px 5px;
+    }
+  </style>
+</head>
+
+<body id="bd" style="padding:15px 5px;box-sizing: border-box;">
+  <!-- <div style="box-sizing: border-box;padding-top:40px;">
+    <div class="text-center font-bold" style="font-size: 18px;">随访单</div>
+    <div class="text-center" style="font-size: 16px;">社区卫生服务中心</div>
+    <div class="mt-2" style="display: flex;">
+      <div>姓名:<span class="font-bold">王长策</span></div>
+      <div style="margin: auto;">性别:<span class="font-bold"> 女</span></div>
+      <div>年龄:<span class="font-bold">62岁</span></div>
+    </div>
+    <div class="mt" style="display: flex;">
+      <div>慢病类型:<span class="font-bold">高血压</span></div>
+      <div style="margin-left: auto;">手机:<span class="font-bold">18812312312</span></div>
+    </div>
+    <div class="mt" style="display: flex;font-size: 10px;">
+      <div style="margin-left: auto;"><span class="font-bold">公费医保</span></div>
+    </div>
+    <div class="" style="font-size: 14px;border: 1px solid #000;border-radius: 4px;">
+      <div class="font-bold" style="display: flex;border: 1px solid #000;">
+        <div class="itemtitle">项目</div>
+        <div class="itemstyle">状态</div>
+      </div>
+      <div style="display: flex;border:1px solid #000 ;">
+        <div class="itemtitle">随访情况</div>
+        <div class="itemstyle"><span>×</span> 您需要随访!</div>
+      </div>
+      <div style="display: flex;border: 1px solid #000;">
+        <div class="itemtitle">体检检查</div>
+        <div class="itemstyle">
+          <div><span>√</span> 已完成体检</div>
+          <div>体检时间:2023-07-10</div>
+        </div>
+      </div>
+      <div style="display: flex;border: 1px solid #000;">
+        <div class="itemtitle">患者签约</div>
+        <div class="itemstyle">
+          <div><span>√</span> 已签约</div>
+          <div>医生: 王姥爷</div>
+          <div>医院: 慈溪市桥头医院慈溪市桥头医院</div>
+        </div>
+      </div>
+    </div>
+    <div id="date" class="mt" style="font-size: 12px;text-align: right;">
+    </div>
+    <div style="padding-top:140px;text-align: center;">
+      ------ 访单 -------
+    </div>
+  </div> -->
+</body>
+
+<script>
+  const { ipcRenderer } = require('electron')
+  ipcRenderer.on('webview-print-render', (event, info) => {
+    // 执行渲染
+    console.log(info);
+    document.getElementById('bd').innerHTML = info.html
+    ipcRenderer.sendToHost('webview-print-do',{a:1}).then(()=>{console.log(1)})
+  })
+ 
+</script>
+<style>
+  #bd {}
+</style>
+
+</html>

+ 1 - 0
src/main/main.js

@@ -55,6 +55,7 @@ async function createWindow() {
       enableRemoteModule: true,
       devTools: isdev,
       contextIsolation: false,
+      webviewTag: true,
       //   preload: path.join(__dirname, '../preload/index.js'),
       // sandbox: false
     }

+ 7 - 10
src/main/windows/mainWin.js

@@ -2,16 +2,6 @@ import { shell, screen, ipcMain } from 'electron'
 import tray from './tray'
 export default function mainWin(mw) {
 
-  //设置悬浮球位置
-  // const { left, top } = { left: screen.getPrimaryDisplay().workAreaSize.width - 400, top: 160 }
-  // mw.setPosition(left, top)
-  //改变窗口大小
-  // ipcMain.handle('setsize', async (event, option) => {  //大小
-  //   mw.setMaximumSize(option.width, option.height);
-  //   mw.setMinimumSize(option.width, option.height);
-  //   mw.setSize(option.width, option.height, true)
-  //   return true
-  // })
   // 移动窗口----start
   ipcMain.on("win-start", (e) => {
     const winPosition = mw.getPosition();
@@ -63,4 +53,11 @@ export default function mainWin(mw) {
   ipcMain.on('window-close', function () {
     mw.close();
   })
+  //获取打印机
+  ipcMain.on('getPrinterList', (event) => {
+    //主线程获取打印机列表
+    const list = mw.webContents.getPrinters();
+    //通过webContents发送事件到渲染线程,同时将打印机列表也传过去
+    mw.webContents.send('getPrinterList', list);
+  });
 }

+ 3 - 6
src/renderer/components/nav/index.vue

@@ -6,13 +6,13 @@
     @mousemove.self="winMove"
     @mouseleave.self="winUp"
     @mouseup.self="winUp" -->
-      <div class="centerY">
+      <div class="centerY fs-16">
         <div class="ml-1 py-1" style="width: 1.5rem ;">
           <div class="picbox">
             <img src="../../assets/logo.png" alt="" class="picimg" />
           </div>
         </div>
-        <span class="ml-1 text-dark fs-16">星空路人</span>
+        <span class="ml-1 text-dark ">星空路人</span>
         <div class="ml-auto centerY my-n1 mr-n1 btn-click" style="-webkit-app-region: no-drag;">
           <div class="px-3 py-1" @click="full">
             <span class="iconfont quanping1 fs-16"></span>
@@ -24,7 +24,7 @@
             <span :class="['iconfont fs-16', ismax ? 'zuidahua-3' : 'zuidahua']"></span>
           </div>
           <div class="px-3 py-1 btn-click-close" @click="closeclick">
-            <span class="iconfont CloseDefault fs-16"></span>
+            <span class="iconfont fs-16 CloseDefault"></span>
           </div>
         </div>
       </div>
@@ -32,7 +32,6 @@
   </div>
 </template>
 <script>
-import { throttle } from 'lodash';
 import { ipcRenderer } from "electron";
 import { mapActions, mapGetters } from 'vuex'
 export default {
@@ -47,8 +46,6 @@ export default {
     }
   },
   mounted() {
-
-    // throttle(renewToken, 300000, { 'trailing': false })
     this.$nextTick(() => {
     })
   },

+ 238 - 0
src/renderer/components/print/index.vue

@@ -0,0 +1,238 @@
+<template>
+  <div class="containerPinter">
+    <webview style="height: 100%;" id="printWebview" ref="printWebview" :src="fullPath" nodeintegration
+      webpreferences="contextIsolation=no" />
+  </div>
+</template>
+<script>
+// import config from "@/utils/config";
+let fullPath = '', ipc;
+// if (config.type != "loc") {
+//   const { ipcRenderer } = require("electron");
+//   ipc = ipcRenderer;
+//   fullPath = './index.html';
+//   // fullPath = path.join(__static, 'print.html');
+// } else {
+//   fullPath = "./index.html";
+// }
+import { timeTrans } from '@/utils/common'
+import { ipcRenderer } from 'electron'
+ipc = ipcRenderer;
+fullPath = "./pm.html";
+export default {
+  name: 'Pinter',
+  props: {
+    printerObj: {
+      type: Object,
+      default() {
+        return {}
+      }
+    },
+    printerData: {
+      type: Object,
+      default() {
+        return {}
+      }
+    },
+  },
+  data() {
+    return {
+      fullPath: fullPath,
+    }
+  },
+  watch: {
+    printerObj(newValue, oldValue) {
+      this.sethtml(this.printerData)
+    },
+  },
+  mounted() {
+    let t = this
+    const webview = this.$refs.printWebview;
+    // webview.addEventListener('console-message', e => {
+    //可以打印出webview中所需要打印的内容
+    // console.log('webview: ' + JSON.stringify(e.message));
+    // });
+    webview.addEventListener('ipc-message', (event) => {
+      console.log(event)
+      if (event.channel === 'webview-print-do') {
+        webview.print({
+          silent: true,
+          printBackground: true,
+          deviceName: t.printerObj.displayName
+        }).then((res,r) => {
+          console.log(res,r)
+        }).catch((err) => {
+          console.log(err)
+        }).finally(() => {
+          t.$notify({
+            title: '打印完成',
+            message: '请取走你的小票',
+            type: 'success',
+            offset: 80,
+          });
+          this.$emit('loadingclick')
+        });
+      }
+    })
+  },
+  created() {
+
+  },
+  methods: {
+    sethtml(obj) {
+      let codemsg = {
+        0: '您近期需要随访',
+        1: '您近期需要随访,系统中未登记',
+        2: '已完成随访,下次随访时间',
+        3: '您近期需要随访,电子健康档案未建档',
+        4: '已完成随访,下次随访时间,电子健康档案未建档',
+        5: '系统中未登记,电子健康档案未建档',
+        6: '已完成随访,系统中未登记,下次随访时间',
+        7: '您在电子健康档案中不是两慢病',
+        8: '您在本系统中不是两慢病',
+        9: '查询出错'
+      }
+      let d = obj.patientvisit.msg.split('[')
+        ? obj.patientvisit.msg.split('[')[1]
+        : ''
+      d = d && d.split(']') ? d.split(']')[0] : ''
+      let time = d || ''
+      console.log(obj)
+      let html = `<div style="box-sizing: border-box;padding-top:40px;">
+          <div class="text-center font-bold" style="font-size: 18px;">随访单</div>
+          <div class="text-center" style="font-size: 16px;">${obj.hospitalname}</div>
+          <div class="mt-2" style="display: flex;">
+            <div>姓名:<span class="font-bold">${obj.username}</span></div>
+            <div style="margin: auto;">性别:<span class="font-bold"> ${obj.sex}</span></div>
+            <div>年龄:<span class="font-bold">${obj.age}</span></div>
+          </div>
+          <div class="mt" style="display: flex;">
+            <div>慢病类型:<span class="font-bold">${obj.chronicDiseaseType}</span></div>
+            <div style="margin-left: auto;">手机:<span class="font-bold">${obj.phone}</span></div>
+          </div>
+          <div class="mt" style="display: flex;font-size: 10px;">
+            <div style="margin-left: auto;"><span class="font-bold">${obj.medicalInsuranceType}</span></div>
+          </div>
+          <div class="" style="font-size: 14px;border: 1px solid #000;border-radius: 4px;">
+            <div class="font-bold" style="display: flex;border: 1px solid #000;">
+              <div class="itemtitle">项目</div>
+              <div class="itemstyle">状态</div>
+            </div>
+            <div style="display: flex;border:1px solid #000 ;">
+              <div class="itemtitle">随访情况</div>
+              <div class="itemstyle" style="display: flex;">
+                ${obj.patientvisit.code >= 0 || obj.patientvisit.code <= 8 ? `
+                  <div class="" style="width:11%;font-size:18px;line-height:1.1">${obj.patientvisit.code == 2 || obj.patientvisit.code == 4 || obj.patientvisit.code == 6 ? '☑' : '🗷'}</div>
+                <div style="width:89%">
+                  <div>${codemsg[obj.patientvisit.code]} ${time ? `<div>(${time})</div>` : ''}</div>
+                </div>
+                  `: `
+                  <div class="" style="width:11%;font-size:18px;line-height:1.1">🗷</div>
+                <div style="width:89%">
+                  <div>${codemsg[9]}</div>
+                </div>`
+        }
+              </div>
+            </div>
+            <div style="display: flex;border: 1px solid #000;">
+              <div class="itemtitle">体检检查</div>
+              <div class="itemstyle" style="display: flex;">
+              ${Number(obj.patientother.istj) ? ` 
+                <div class="" style="width:11%;font-size:18px;line-height:1.1">☑</div>
+                <div style="width:89%">
+                  <div>本年度已完成体检</div>
+                </div>`:
+          `
+                <div class="" style="width:11%;font-size:18px;line-height:1.1">🗷</div>
+                <div style="width:89%">
+                  <div>本年度未完成体检</div>
+                </div>
+              `}
+            </div>
+            </div>
+            <div style="display: flex;border: 1px solid #000;">
+              <div class="itemtitle">患者签约</div>
+              <div class="itemstyle" style="display: flex;">
+                ${obj.patientother.tlSign && obj.patientother.tlSign.qyysxm.length ? ` <div class="" style="width:11%;font-size:18px;line-height:1.1">☑</div>
+                      <div style="width:89%">
+                        <div>已签约(${obj.patientother.tlSign.qyrq})</div>
+                        <div>${obj.patientother.tlSign.qyysxm}</div>
+                        <div>${obj.patientother.tlSign.jgmc}</div>
+                      </div>`:
+          ` <div class="" style="width:11%;font-size:18px;line-height:1.1">🗷</div>
+                  <div style="width:89%">
+                    <div>未签约</div>
+                  </div>`
+        }
+                
+              </div>
+            </div>
+          </div>
+          <div id="date" class="mt" style="font-size: 12px;text-align: right;">
+            ${timeTrans({ format: 'Y年M月D日 h:m:s' })}
+          </div>
+          <div style="padding-top:150px;text-align: center;">
+            ------ 访单 -------
+          </div>
+        </div>`
+      this.printRender(html);
+    },
+    printRender(html) {
+      let t = this
+      // 获取<webview>节点
+      const webview = this.$refs.printWebview
+      // 发送信息到<webview>里的页面
+      webview.send('webview-print-render', {
+        printName: t.printerObj.displayName,
+        html: 1
+      })
+
+    }
+  }
+}
+</script>
+<style lang="less">
+.containerPinter {
+  width: 280px;
+  height: 600px;
+  position: fixed;
+  // left: -10000px;
+  background-color: #fff;
+  z-index: 999;
+
+}
+
+.el-notification {
+  width: 15rem;
+  padding: 0.8rem 1.5rem 0.8rem 0.8rem;
+  border-radius: 0.5rem;
+
+  .el-notification__icon {
+    height: 1.8rem;
+    width: 1.8rem;
+    font-size: 1.8rem;
+  }
+
+  .el-notification__group {
+    margin-left: 0.8rem;
+    margin-right: 0.5rem;
+  }
+
+  .el-notification__title {
+    font-size: 1.1rem;
+    line-height: 1.8rem;
+  }
+
+  .el-notification__content {
+    font-size: 0.9rem;
+    line-height: 1.5rem;
+    margin-top: 0.3rem;
+  }
+
+  .el-notification__closeBtn {
+    top: 0.8rem;
+    right: 0.8rem;
+    font-size: 1.2rem;
+  }
+}
+</style>

+ 70 - 27
src/renderer/components/userinfo/index.vue

@@ -3,37 +3,36 @@
     <el-dialog title="" :append-to-body="true" custom-class="selfDialog" center
       style="max-height: 100vh;overflow: hidden;" :close-on-click-modal="false" :visible.sync="dialogshow"
       :show-close="false" :before-close="close">
-      <div class="bg-white centerY py-3" style="overflow: hidden;background-color: #409EFF;">
+      <div class="bg-white centerY py-3" style="overflow: hidden;background-color: #409EFF;" v-loading="loading"
+        element-loading-text="正在打印中..." element-loading-spinner="el-icon-loading"
+        element-loading-background="rgba(0, 0, 0, 0.8)">
         <div class="w-30">
           <div class="text-center" style="z-index: 999;">
             <span
-              :class="['iconfont fs-40 d-inline-block bg-white p-1 text-primary', getIDCardInfo(patientInfo.idCard).sex == 1 ? 'touxiangnan' : 'touxiangnv']"
+              :class="['iconfont fs-40 d-inline-block bg-white p-1 text-primary', getIDCardInfo(patientInfo.idCard)?.sex == 1 ? 'touxiangnan' : 'touxiangnv']"
               style="border-radius: 50%;"></span>
           </div>
           <!-- 个人信息 -->
           <div class="text-center text-white fs-16 mt-3 px-2">
             <div>
               <span class="fs-18 "> {{ patientInfo.username }}</span>
-             
             </div>
             <div class="mt-1">
-              <span class="ml-1" v-if="getIDCardInfo(patientInfo.idCard).age">
+              <span class="ml-1" v-if="getIDCardInfo(patientInfo.idCard)?.age">
                 {{ getIDCardInfo(patientInfo.idCard).age }}岁
               </span>
               <span class="ml-1" v-else>暂无年龄</span>
-              <span class="">{{ getIDCardInfo(patientInfo.idCard).sex == 1 ? '男' : '女' }}</span>
-              
+              <span class="">{{ getIDCardInfo(patientInfo.idCard)?.sex == 1 ? '男' : '女' }}</span>
             </div>
-            
             <div class="mt-1">
               <span>{{ patientInfo.phone }}</span>
             </div>
             <div class="mt-1">
-              <span class="ml-1"> {{ MEDICAL_INSURANCE_TYPE[patientInfo.medicalInsuranceType - 1].label }}</span>
+              <span class="ml-1"> {{ MEDICAL_INSURANCE_TYPE[patientInfo.medicalInsuranceType - 1]?.label }}</span>
             </div>
             <div class="mt-3">
               <span class="el-tag1 fs-12 py-1">
-                {{ CHRONIC_DISEASE_TYPE[patientInfo.chronicDiseaseType - 1].label }}
+                {{ CHRONIC_DISEASE_TYPE[patientInfo.chronicDiseaseType - 1]?.label }}
               </span>
             </div>
             <!-- <div>
@@ -60,7 +59,7 @@
           style="height: 100%;box-sizing: border-box; border-top-left-radius: .9rem;border-bottom-left-radius: .9rem; box-shadow: inset 1px 1px 0 rgba(255, 255, 255, 1), inset 0 0 0.4rem #fff,  -1px -1px 0.4rem rgba(0, 0, 0, 0.3);background: rgb(247,252,252);">
           <div class="userbox px-2" style="max-height:80vh;overflow: auto;">
             <div class="fs-16 pt-2 text-right">
-              <el-button class="fs-12 py-2 px-4" type="primary">
+              <el-button class="fs-12 py-2 px-4" type="primary" @click="getPrinterList">
                 打印
               </el-button>
               <el-button class="fs-12 py-2 px-4" type="danger" @click="close()">关闭({{ closeCount }}s)</el-button>
@@ -175,6 +174,7 @@
             </div>
           </div>
         </div>
+        <Pinter :printerObj="printerObj" :printerData="printerData" @loadingclick="loadingclick()" />
       </div>
     </el-dialog>
   </div>
@@ -184,8 +184,12 @@
 import { getIDCardInfo, getAge } from '@/utils/common'
 import { CHRONIC_DISEASE_TYPE, MEDICAL_INSURANCE_TYPE } from '@/utils/const'
 import moment from 'moment'
+import { mapGetters } from 'vuex'
+import { ipcRenderer } from 'electron'
+import Pinter from '@/components/print'
 export default {
   name: 'Index',
+  components: { Pinter },
   props: {
     dialogshow: {
       type: Boolean,
@@ -212,16 +216,35 @@ export default {
       },
     },
   },
+  computed: {
+    ...mapGetters({
+      hospitalInfo: 'hospital/hospitalInfo'
+    }),
+  },
   watch: {
     dialogshow(newValue, oldValue) {
-      console.log(1)
       this.closeCount = 30
       clearInterval(this.timer)
       this.setCount()
     },
     patientInfo(newValue, oldValue) {
-      
-      console.log(newValue, oldValue)
+      let t = this
+      let obj = {
+        info:newValue,
+        hospitalInfo: t.hospitalInfo&&t.hospitalInfo.hospitalname?t.hospitalInfo:{ hospitalname: '测试医院' },
+        patientother:t.patientother,
+        patientvisit:t.patientvisit,
+        hospitalname:t.hospitalInfo?.hospitalname||'测试医院',
+        username: newValue.username,
+        sex: t.getIDCardInfo(newValue.idCard)?.sex == 1 ? '男' : '女',
+        age: t.getIDCardInfo(newValue.idCard)?.age+'岁' || '暂无年龄',
+        chronicDiseaseType: CHRONIC_DISEASE_TYPE[newValue.chronicDiseaseType - 1]?.label,
+        phone: newValue.phone,
+        medicalInsuranceType: t.MEDICAL_INSURANCE_TYPE[newValue.medicalInsuranceType - 1]?.label,
+      }
+      // console.log(obj)
+      t.printerData = obj
+      // console.log(newValue, oldValue)
     }
   },
   data() {
@@ -232,32 +255,52 @@ export default {
       CHRONIC_DISEASE_TYPE,
       MEDICAL_INSURANCE_TYPE,
       closeCount: 30,
-      timer:null
+      timer: null,
+      printerObj: {},
+      printerData:{},
+      loading: false,
+      i: 0
     }
   },
-  computed: {
-
-  },
   created() {
-
+    let t = this
+    ipcRenderer.on('getPrinterList', (event, data) => {
+      data.map((item) => {
+        if (item.isDefault) {
+          t.printerObj = item
+        }
+      })
+    })
   },
   methods: {
+    // 获取打印机
+    getPrinterList() {
+      this.loading = true;
+      clearInterval(this.timer)
+      ipcRenderer.send('getPrinterList')
+    },
+    loadingclick() {
+      this.loading = false
+    },
     close() {
       clearInterval(this.timer)
       this.$emit('close')
     },
-    setCount(){
-      let t=this
-      this.timer=setInterval(()=>{
-        if(t.closeCount<=0){
+    setCount() {
+      let t = this
+      if (process.env.NODE_ENV === "development") {
+        return false
+      }
+      this.timer = setInterval(() => {
+        if (t.closeCount <= 1) {
           clearInterval(t.timer)
-          setTimeout(()=>{
+          setTimeout(() => {
             this.$emit('close')
-          },500)
-        }else{
-          t.closeCount = t.closeCount-1
+          }, 500)
+        } else {
+          t.closeCount = t.closeCount - 1
         }
-      },1000)
+      }, 1000)
     }
   }
 }

+ 26 - 7
src/renderer/pages/home/index.vue

@@ -16,6 +16,7 @@ import Nav from '@/components/nav'
 import Box from '@/components/box'
 import Title from '@/components/title'
 import { mapGetters, mapActions } from 'vuex'
+import { Message } from 'element-ui';
 export default {
   name: 'Home',
   components: { Box, Nav, Title },
@@ -36,21 +37,39 @@ export default {
     }
   },
   created() {
-    this.hospitalInfo()
+  },
+  mounted() {
+    this.gethospitalId()
   },
   methods: {
     ...mapActions({
       hospitalInfoApi: 'hospital/hospitalInfoApi'
     }),
-    hospitalInfo() {
-      // if()
+    gethospitalId() {
+      let t = this, timer = null, id = null
+      id = localStorage.getItem('locationpath') && JSON.parse(localStorage.getItem('locationpath')).hospitalId
+      if (id) {
+        this.hospitalInfo(id)
+      } else {
+        clearInterval(timer)
+        Message({
+          message: '请先设置医院ID',
+          type: 'warning',
+          offset: 80,
+          center: true
+        })
+        timer = setTimeout(() => {
+          t.gethospitalId()
+        }, 1000 * 10)
+        return false
+      }
+    },
+    hospitalInfo(id) {
       let t = this
-
-      this.$api.getHospitalInfo({ "hospitalId": 103 }).then((res) => {
-        console.log(res)
+      this.$api.getHospitalInfo({ "hospitalId": id }).then((res) => {
+        // console.log(res)
         if (res.code == 0) t.hospitalInfoApi(res.data);
       })
-
     }
   }
 }

File diff suppressed because it is too large
+ 49 - 24
src/renderer/pages/search/index.vue


+ 1 - 1
src/renderer/pages/update/index.vue

@@ -42,7 +42,7 @@ export default {
       getlocationpath: 'user/getlocationpath',
     }),
     sendurl(){
-      console.log(111,this.webURL)
+      // console.log(111,this.webURL)
       ipcRenderer.send('sendurl',{url:this.webURL})
     },
     get1() {

+ 1 - 0
src/renderer/utils/common.js

@@ -84,6 +84,7 @@ export function timeTrans({
   }
 }
 export function getIDCardInfo(idCard) {
+  idCard= idCard||0
   if (idCard.length === 18) {
     //获取计算后出生日期
     let birthDateStr = getBirthDate(idCard);