From ab91bbc86844f8452d27c5d0405b9011b685c10f Mon Sep 17 00:00:00 2001
From: wwl <xchao828@163.com>
Date: 星期四, 02 一月 2025 17:59:30 +0800
Subject: [PATCH] 12

---
 src/views/sampling/sampling/index.vue |  172 ++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 114 insertions(+), 58 deletions(-)

diff --git a/src/views/sampling/sampling/index.vue b/src/views/sampling/sampling/index.vue
index 8fcccea..ab8a88c 100644
--- a/src/views/sampling/sampling/index.vue
+++ b/src/views/sampling/sampling/index.vue
@@ -111,19 +111,22 @@
         <el-button type="primary" :disabled="!disabled" @click="Cancellation"
           >鎾ら攢鍚堝苟</el-button
         >
-        <el-button type="primary" @click="Confirmreceipt" :disabled="!selectList.length">閲囨牱鎵撶爜</el-button>
+        <el-button
+          type="primary"
+          @click="Confirmreceipt"
+          :disabled="!selectList.length"
+          >閲囨牱鎵撶爜</el-button
+        >
       </el-col>
       <el-col
         :span="12"
         style="margin: 10px 15px"
         v-show="samplingList.length > 0 && tjStatus == 0"
       >
-        <el-button
-          type="primary"
-          :disabled="!selectList.length"
-          @click="Collection"
+        <el-button type="primary" :disabled="!selectList.length" @click="buda"
           >琛ユ墦鏉$爜</el-button
         >
+        <!-- @click="Collection" -->
         <el-button type="primary" :disabled="!disabled" @click="Cancellation"
           >鎾ら攢鍚堝苟</el-button
         >
@@ -189,11 +192,7 @@
         </el-table>
       </div>
       <div style="width: 50%">
-        <!-- :default-sort="{ prop: 'specimenType', order: 'ascending' }"  :default-sort="{ prop: 'specimenType', order: 'ascending' }"
-          @sort-change="handleSortChange"
-          :span-method="objectSpanMethod"
-          @selection-change="handleChange" ref="tab1"
-          :row-class-name="tableRowClassName"-->
+        <!-- v-if="this.rightTabShow" -->
         <el-table
           v-loading="loading"
           :data="tableList"
@@ -325,26 +324,7 @@
       />
     </div>
 
-    <!-- 娣诲姞鎴栦慨鏀逛綋妫�閲囨牱绠$悊瀵硅瘽妗� -->
-    <!-- <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
-            <el-form ref="form" :model="form" :rules="rules" label-width="80px">
-                <el-form-item label="鐢宠鏃堕棿" prop="applicationTime">
-                    <el-date-picker clearable v-model="form.applicationTime" type="date" value-format="yyyy-MM-dd"
-                        placeholder="璇烽�夋嫨鐢宠鏃堕棿">
-                    </el-date-picker>
-                </el-form-item>
-                <el-form-item label="椤圭洰id鐖堕」" prop="proId">
-                    <el-input v-model="form.proId" placeholder="璇疯緭鍏ラ」鐩甶d鐖堕」" />
-                </el-form-item>
-                <el-form-item label="椤圭洰鍚嶇О" prop="proName">
-                    <el-input v-model="form.proName" placeholder="璇疯緭鍏ラ」鐩悕绉�" />
-                </el-form-item>
-            </el-form>
-            <div slot="footer" class="dialog-footer">
-                <el-button type="primary" @click="submitForm">纭� 瀹�</el-button>
-                <el-button @click="cancel">鍙� 娑�</el-button>
-            </div>
-        </el-dialog> -->
+
   </div>
 </template>
 
@@ -379,6 +359,8 @@
     return {
       msg: "",
       getNumbr: null,
+      valueUrl: "ws://127.0.0.1:6789/websocket",
+      webSocket: null,
       list: [],
       selectList: [],
       selectedRows: [],
@@ -390,6 +372,9 @@
       ids: [],
       // 缁戝畾鍗曢�夋寜閽�
       tjStatus: "1",
+      dayinData: [],
+      jsonObj: {},
+
       // 闈炲崟涓鐢�
       single: true,
       // 闈炲涓鐢�
@@ -458,12 +443,14 @@
       form: {},
       // 琛ㄥ崟鏍¢獙
       rules: {},
+      // rightTabShow: false
     };
   },
   created() {
     // this.getNowTime();
     getTxmmccd().then((res) => {
       this.msg = Number(res.msg);
+      console.log(res, 444);
     });
     this.getdate();
   },
@@ -598,6 +585,8 @@
             this.$nextTick(() => {
               this.$refs.tb.toggleRowSelection(this.samplingList[0], true);
               // this.fetchData(this.samplingList[0].tjNumber);
+              // ddddddddddddddd
+              // this.rightTabShow = true
             });
           }
           this.total = response.data.total;
@@ -816,17 +805,12 @@
 
     /** 鐐瑰嚮琛ユ墦鏉$爜鎸夐挳 **/
     async Collection() {
-      // console.log("selectList:", this.selectList);
       const jyxh = this.selectList.map((item) => item.jyxh);
       console.log("jyxh:", jyxh);
       try {
         // 璇锋眰鎺ュ彛骞惰幏鍙栧搴﹀��
         const widthResponse = await getTxmkd();
         const barcodeWidth = `${Number(widthResponse.msg)}%` || "70%"; // 鑾峰彇瀹藉害鍊硷紝榛樿浣跨敤 70%
-
-        // const jyxh = this.selectList.map((item) => item.jyxh);
-
-        // await this.$nextTick(); // 纭繚 DOM 鏇存柊
 
         jyxh.forEach((number, index) => {
           const barcodeContent = number; // 纭繚 jyxh 鏄湁鏁堢殑
@@ -861,7 +845,7 @@
         const newWindow = window.open("", "_blank", "width=800,height=600");
         const printContents = document.getElementById("printSection").innerHTML;
 
-        // console.log(printContents);
+        console.log(printContents);
         newWindow.document.write(`
       <html>
         <head>
@@ -917,11 +901,11 @@
               }
               .last p {
               // font-weight: bold;
-                margin-left: 10px; 
+                margin-left: 1px; 
                 // font-family: "Arial Black", sans-serif !important; 
               }
                 p {
-                margin-left: 10px; 
+                margin-left: 1px; 
                 // font-weight: bold;
                 // font-family: "Arial Black", sans-serif !important;  
               }
@@ -934,7 +918,7 @@
                  font-family: "Arial Black", sans-serif !important; 
               }
               .tj span {
-                margin-left: 10px;
+                margin-left: 1px;
               }
             }
           </style>
@@ -963,28 +947,55 @@
       // console.log(selection);
 
       this.selectList = selection;
-      console.log(this.selectList, 5555);
+      console.log(this.selectList, 9977);
+      var array = selection;
 
-      this.ids = selection.map((item) => item.id);
+      this.ids = array.map((item) => item.id);
     },
+    buda() {
+      var websocket = null;
+      var url = this.valueUrl;
+      if ("WebSocket" in window) {
+        websocket = new WebSocket(url);
+      } else if ("MozWebSocket" in window) {
+        websocket = new MozWebSocket(url);
+      }
+      if (websocket == null) {
+        alert("鍒涘缓WebSocket瀵硅薄澶辫触");
+      }
+      websocket.onerror = function () {
+        alert("璇锋鏌ヨ鍗″櫒杩炴帴鏄惁姝e父");
+      };
+      websocket.onopen = () => {
+        this.websocket = websocket;
+        this.dayinData = this.selectList.map((item) => ({
+          jyxh: item.jyxh,
+          proName: item.proName,
+          cusName: item.cusName,
+          cusSex: item.customer.cusSex,
+          age: item.customer.age,
+          cardId: item.cardId,
+          tjTime: item.createTime,
+        }));
+        console.log(this.dayinData, 2222);
 
-    // 绂侀��
-    // selectEnable(row, rowIndex) {
-    //     if(row.isSignFor === "0"){
-    //         return false
-    //     }else{
-    //         return true
-    //     }
-    // },
-
-    // 纭畾鎸夐挳
-    submitForm() {},
+        // 杩炴帴璁惧
+        this.jsonObj = {
+          type: "3",
+          array: {
+            data: this.dayinData,
+          },
+        };
+        var jStr = JSON.stringify(this.jsonObj);
+        this.websocket.send(jStr);
+        this.jsonObj = {};
+        // this.dialogVisible = false;
+      };
+      // this.getList();
+    },
 
     // 纭閲囨牱
     Confirmreceipt() {
-      let data = this.ids;
-      console.log(this.ids, 999);
-
       const loadingInstance = this.$loading({
         lock: true, // 閿佸畾灞忓箷
         text: "鍔犺浇涓�...", // 鍔犺浇鏂囨湰
@@ -993,10 +1004,55 @@
       });
       confirmSampling(this.ids)
         .then((res) => {
-          if (res.code === 200) {
-            // this.$modal.msgSuccess("閲囨牱鎴愬姛");
+          console.log(this.selectList, 2222);
 
-            this.Collection();
+          if (res.code === 200) {
+            // var websocket = null;
+            this.buda();
+
+            /* var url = this.valueUrl;
+            if ("WebSocket" in window) {
+              websocket = new WebSocket(url);
+            } else if ("MozWebSocket" in window) {
+              websocket = new MozWebSocket(url);
+            }
+            if (websocket == null) {
+              alert("鍒涘缓WebSocket瀵硅薄澶辫触");
+            }
+            websocket.onerror = function () {
+              alert("璇锋鏌ヨ鍗″櫒杩炴帴鏄惁姝e父");
+            };
+            websocket.onopen = () => {
+              this.websocket = websocket;
+              var list = this.selectList;
+              var data = list.map((item) => ({
+                jyxh: item.jyxh,
+                proName: item.proName,
+                cusName: item.cusName,
+                cusSex: item.customer.cusSex,
+                age: item.customer.age,
+                cardId: item.cardId,
+                tjTime: item.createTime,
+              }));
+
+              // 杩炴帴璁惧
+              var jsonObj = {
+                type: "3",
+                array: {
+                  data: data,
+                },
+              };
+              var jStr = JSON.stringify(jsonObj);
+              this.websocket.send(jStr);
+              var jsonObj = {};
+              this.dialogVisible = false;
+            };
+            websocket.onmessage = (event) => {
+              var resultObj = eval("(" + event.data + ")");
+              console.log(resultObj, 9988);
+            }; */
+
+            // this.Collection();
             this.getList();
           } else {
             this.$message.error(res.msg);

--
Gitblit v1.8.0