From 53b7cfd8589201ec728c68a08b4ea07d94e66258 Mon Sep 17 00:00:00 2001
From: qinxianzhangyao <11053546+qinxianzhangyao@user.noreply.gitee.com>
Date: 星期一, 08 七月 2024 17:16:48 +0800
Subject: [PATCH] qxtj

---
 src/views/system/tijian/index.vue |  259 ++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 193 insertions(+), 66 deletions(-)

diff --git a/src/views/system/tijian/index.vue b/src/views/system/tijian/index.vue
index 01a76ae..da8a012 100644
--- a/src/views/system/tijian/index.vue
+++ b/src/views/system/tijian/index.vue
@@ -1320,6 +1320,31 @@
         </el-table>
       </div>
     </el-dialog>
+    <el-dialog
+      title="鎻愮ず"
+      :visible.sync="cardreader"
+      width="30%"
+      :close-on-press-escape="false"
+      :close-on-click-modal="false"
+    >
+      <template>
+        <el-radio-group v-model="cardreaderradio" @input="changeradio">
+          <el-radio :label="3">韬唤璇�</el-radio>
+          <el-radio :label="6">鍋ュ悍鐮�</el-radio>
+        </el-radio-group>
+        <div style="margin-top: 10px" v-show="cardreaderradio == 6">
+          <el-input
+            v-model="inputSSS"
+            ref="tableHeadFilterInp"
+            placeholder="璇疯緭鍏ュ唴瀹�"
+          ></el-input>
+        </div>
+      </template>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="cardreader = false">鍙� 娑�</el-button>
+        <el-button type="primary" @click="cardreadercopes">纭� 瀹�</el-button>
+      </span>
+    </el-dialog>
     <div style="position: absolute; bottom: 100px; width: 360px; display: none">
       <div
         id="printBill"
@@ -1355,12 +1380,7 @@
       </span> -->
     <!-- </el-dialog> -->
     <historyTj :cusIdCard="form.cusIdcard" ref="historyTj"></historyTj>
-    <el-dialog
-      title="鎻愮ず"
-      :visible.sync="dialogVisiblese"
-      width="30%"
-      :before-close="handleClose"
-    >
+    <el-dialog title="鎻愮ず" :visible.sync="dialogVisiblese" width="30%">
       <span>鏄惁澶嶅埗鏈�杩戜竴娆$殑浣撴椤圭洰锛�</span>
       <span slot="footer" class="dialog-footer">
         <el-button @click="dialogVisiblese = false">鍙� 娑�</el-button>
@@ -1382,7 +1402,7 @@
 } from "@/api/hosp/customer";
 import { getPrintSetUp } from "@/api/system/examcharge";
 import axios from "axios";
-import { getIp } from '@/utils/auth'
+import { getIp } from "@/utils/auth";
 import {
   deptTreeSelect,
   projectGetList,
@@ -1441,11 +1461,13 @@
       proIdList: [],
       tableDatas: [],
       dialogVisiblese: false,
+      cardreaderradio: 3,
       lishi: false,
       table: false,
       HistoryList: {},
       index: 0,
       names: "",
+      inputSSS: "",
       dictType: [
         {
           value: 0,
@@ -1551,6 +1573,7 @@
       ids: [],
       // 闈炲崟涓鐢�
       single: true,
+      cardreader: false,
       // 闈炲涓鐢�
       multiple: true,
       nodeobj: {},
@@ -1663,7 +1686,6 @@
     this.getList1();
     // this.getData();
   },
- 
 
   methods: {
     getCurrentDateTime() {
@@ -2356,64 +2378,9 @@
               this.$refs.aaa.getAllList();
               this.$refs.aaa.title = "璇佷欢瀛楀吀";
             } else if (res.msg == "S") {
-              var websocket = null;
-              var url = this.valueUrls;
-              // var url = 'ws://'+ getIp() +':6789/websocket'
-              console.log(url)
-              if ("WebSocket" in window) {
-                websocket = new WebSocket(url);
-              } else if ("MozWebSocket" in window) {
-                websocket = new MozWebSocket(url);
-              } else {
-                // console.log("SockJS");
-              }
-              if (websocket == null) {
-                alert("11111");
-              }
-              websocket.onopen = function () {
-                try {
-                websocket.send("鍙戦��");
-              } catch (err) {
-                var tryTime = 0;
-                // 閲嶈瘯10娆★紝姣忔涔嬮棿闂撮殧3绉�
-                if (tryTime < 1) {
-                  var t1 = setTimeout(function () {
-                    tryTime++;
-                  
-                websocket.send("鍙戦��");
-              
-                  }, 1 * 1000);
-                } else {
-                  console.error("閲嶈繛澶辫触.");
-                }
-              }
-              };
-              websocket.onclose = function () {
-                alert("璇诲崱鍣ㄨ繛鎺ュ叧闂�");
-              };
-              websocket.onmessage = function (event) {
-              
-                var resultObj =JSON.parse(event.data);
-               _this.form.cusName = resultObj.data.name;
-                    _this.form.cusSex =
-                    resultObj.data.sex;
-                    _this.form.cusNational =resultObj.data.mz;
-                    _this.form.cusBrithday = resultObj.data.csrq;
-                    if (_this.form.cusBrithday) {
-                      _this.form.cusBrithday = _this.form.cusBrithday.replace(
-                        /^(\d{4})(\d{2})(\d{2})$/,
-                        "$1-$2-$3"
-                      );
-                    }
-                    _this.form.cusAddr = resultObj.data.addres;
-                    _this.form.cusIdcard = resultObj.data.card;
-              };
-
-              //杩炴帴鍙戠敓閿欒鐨勫洖璋冩柟娉�
-              websocket.onerror = function () {
-                alert("璇锋鏌ヨ鍗″櫒杩炴帴鏄惁姝e父");
-              };
-            
+              this.cardreader = true;
+              _this.cardreaderradio = 3;
+              _this.inputSSS = "";
               // let url = window.location.protocol + "//" + window.location.host;
               // console.log(url);
               // axios
@@ -2445,6 +2412,166 @@
         });
       }
     },
+    changeradio() {
+      if (this.cardreaderradio != 3) {
+        this.$nextTick(() => {
+          this.$refs.tableHeadFilterInp.focus();
+        });
+      }
+    },
+    cardreadercopes() {
+      let _this = this;
+
+      if (this.cardreaderradio == 3) {
+        var websocket = null;
+        var url = this.valueUrls;
+        // var url = 'ws://'+ getIp() +':6789/websocket'
+        if ("WebSocket" in window) {
+          websocket = new WebSocket(url);
+        } else if ("MozWebSocket" in window) {
+          websocket = new MozWebSocket(url);
+        } else {
+          // console.log("SockJS");
+        }
+        if (websocket == null) {
+          alert("11111");
+        }
+        websocket.onopen = function () {
+          try {
+            // 杩炴帴璁惧
+            var jsonObjs = {
+              type: 1,
+              data: {},
+            };
+            var jStrs = JSON.stringify(jsonObjs);
+            websocket.send(jStrs);
+          } catch (err) {
+            var tryTime = 0;
+            // 閲嶈瘯10娆★紝姣忔涔嬮棿闂撮殧3绉�
+            if (tryTime < 1) {
+              var t1 = setTimeout(function () {
+                tryTime++;
+                var jsonObjs = {
+                  type: 1,
+                  data: {},
+                };
+                var jStrs = JSON.stringify(jsonObjs);
+                websocket.send(jStrs);
+              }, 1 * 1000);
+            } else {
+              console.error("閲嶈繛澶辫触.");
+            }
+          }
+        };
+        websocket.onclose = function () {
+          alert("璇诲崱鍣ㄨ繛鎺ュ叧闂�");
+        };
+        websocket.onmessage = function (event) {
+          var resultObj = JSON.parse(event.data);
+          _this.form.cusName = resultObj.data.name;
+          _this.form.cusSex = resultObj.data.sex;
+          _this.form.cusNational = resultObj.data.mz;
+          _this.form.cusBrithday = resultObj.data.csrq;
+          if (_this.form.cusBrithday) {
+            _this.form.cusBrithday = _this.form.cusBrithday.replace(
+              /^(\d{4})(\d{2})(\d{2})$/,
+              "$1-$2-$3"
+            );
+          }
+          _this.form.cusAddr = resultObj.data.addres;
+          _this.form.cusIdcard = resultObj.data.card;
+          _this.cardreader = false;
+        };
+
+        //杩炴帴鍙戠敓閿欒鐨勫洖璋冩柟娉�
+        websocket.onerror = function () {
+          alert("璇锋鏌ヨ鍗″櫒杩炴帴鏄惁姝e父");
+        };
+      } else {
+        // if (_this.inputSSS.indexOf(":1") != -1) {
+          
+        //   var str1 = _this.inputSSS.indexOf(":1");
+        //   var result1 = _this.inputSSS.substring(0, str1);
+
+        //   var str2 = _this.inputSSS.indexOf(":1");
+        //   var result2 = _this.inputSSS.substring(
+        //     str2 + 2,
+        //     _this.inputSSS.length
+        //   );
+
+        //   _this.inputSSS = result1 + result2;
+        // }
+        _this.inputSSS = _this.inputSSS.replace(":1","");
+        var websocket = null;
+        var url = this.valueUrls;
+        // var url = 'ws://'+ getIp() +':6789/websocket'
+        if ("WebSocket" in window) {
+          websocket = new WebSocket(url);
+        } else if ("MozWebSocket" in window) {
+          websocket = new MozWebSocket(url);
+        } else {
+          // console.log("SockJS");
+        }
+        if (websocket == null) {
+          alert("11111");
+        }
+        websocket.onopen = function () {
+          try {
+            // 杩炴帴璁惧
+            var jsonObjs = {
+              type: 2,
+              data: {
+                qrcode: _this.inputSSS,
+              },
+            };
+            var jStrs = JSON.stringify(jsonObjs);
+            websocket.send(jStrs);
+          } catch (err) {
+            var tryTime = 0;
+            // 閲嶈瘯10娆★紝姣忔涔嬮棿闂撮殧3绉�
+            if (tryTime < 1) {
+              var t1 = setTimeout(function () {
+                tryTime++;
+                var jsonObjs = {
+                  type: 2,
+                  data: {
+                    qrcode: _this.inputSSS,
+                  },
+                };
+                var jStrs = JSON.stringify(jsonObjs);
+                websocket.send(jStrs);
+              }, 1 * 1000);
+            } else {
+              console.error("閲嶈繛澶辫触.");
+            }
+          }
+        };
+        websocket.onclose = function () {
+          alert("璇诲崱鍣ㄨ繛鎺ュ叧闂�");
+        };
+        websocket.onmessage = function (event) {
+          var resultObj = JSON.parse(event.data);
+          _this.form.cusName = resultObj.data.name;
+          _this.form.cusSex = resultObj.data.gender;
+          _this.form.cusNational = resultObj.data.nation;
+          // _this.form.cusBrithday = resultObj.data.csrq;
+          // if (_this.form.cusBrithday) {
+          //   _this.form.cusBrithday = _this.form.cusBrithday.replace(
+          //     /^(\d{4})(\d{2})(\d{2})$/,
+          //     "$1-$2-$3"
+          //   );
+          // }
+          _this.form.cusPhone = resultObj.data.phone;
+          _this.form.cusIdcard = resultObj.data.idenno;
+          _this.cardreader = false;
+        };
+
+        //杩炴帴鍙戠敓閿欒鐨勫洖璋冩柟娉�
+        websocket.onerror = function () {
+          alert("璇锋鏌ヨ鍗″櫒杩炴帴鏄惁姝e父");
+        };
+      }
+    },
 
     handleChanges(param1) {
       if (this.form.pacCode == "涓嶈") {

--
Gitblit v1.8.0