From bad2bc143be3f8ddb93a1c9f984127b3ccf43e8f Mon Sep 17 00:00:00 2001
From: lkk <364857242@qq.com>
Date: 星期一, 31 三月 2025 17:47:14 +0800
Subject: [PATCH] 11

---
 src/views/sampling/sampling/index.vue |  121 +++++++++++++++++++++++----------------
 1 files changed, 71 insertions(+), 50 deletions(-)

diff --git a/src/views/sampling/sampling/index.vue b/src/views/sampling/sampling/index.vue
index 4fc83f2..2c7a66a 100644
--- a/src/views/sampling/sampling/index.vue
+++ b/src/views/sampling/sampling/index.vue
@@ -14,17 +14,17 @@
           format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" type="daterange" range-separator="-"
           start-placeholder="寮�濮嬫棩鏈�" end-placeholder="缁撴潫鏃ユ湡" :picker-options="pickerOptions"></el-date-picker>
       </el-form-item>
-      <el-form-item label="鍗曚綅鍚嶇О" prop="tjCompName" style="margin-left: 20px; margin-right: 500px">
+      <el-form-item label="鍗曚綅鍚嶇О" prop="compName" style="margin-left: 20px; margin-right: 500px">
         <el-select :remote-method="getRemoteData" v-model="queryParams.tjCompName" value-key="drugManufacturerId"
           style="width: 200px" remote filterable placeholder="璇烽�夋嫨鍗曚綅鍚嶇О" clearable @change="searchSelect">
           <el-option v-for="dict in CompanyList" :key="dict.drugManufacturerId" :label="dict.cnName" :value="dict" />
         </el-select>
       </el-form-item>
       <!-- <el-form-item label="鏄惁閲囨牱" prop="isSignFor">
-                    <el-select style="width:100px" v-model="queryParams.isSignFor" placeholder="鏄惁閲囨牱">
+                    <el-select1 style="width:100px" v-model="queryParams.isSignFor" placeholder="鏄惁閲囨牱">
                             <el-option v-for="dict in dict.type.sampling_type" :key="dict.value" :label="dict.label"
                                 :value="dict.value"></el-option>
-                        </el-select>
+                        </el-select1>
             </el-form-item> -->
       <!-- <el-form-item label="浣撴鏃堕棿" prop="tjTime">
                 <el-date-picker clearable v-model="queryParams.tjTime" type="date" value-format="yyyy-MM-dd"
@@ -95,7 +95,7 @@
             </template>
           </el-table-column>
           <el-table-column label="鎵嬫満鍙�" align="center" prop="cusPhone" width="120px" />
-          <el-table-column label="鍗曚綅鍚嶇О" align="center" prop="firmName" width="120px" />
+          <el-table-column label="鍗曚綅鍚嶇О" align="center" prop="compName" width="120px" />
           <el-table-column label="鐢宠鏃堕棿" align="center" prop="applicationTime" width="210">
             <template slot-scope="scope">
               <span>{{ parseTime(scope.row.applicationTime) }}</span>
@@ -104,9 +104,9 @@
         </el-table>
       </div>
       <div style="width: 50%">
-        <!-- v-if="this.rightTabShow" -->
-        <el-table v-loading="loading" :data="tableList" @selection-change="handleChange" :span-method="objectSpanMethod"
-          ref="tab1" :row-class-name="tableRowClassName" border height="520px">
+        <!-- v-if="this.rightTabShow"  v-if="tableList.length > 0"-->
+        <el-table  v-loading="loading" :data="tableList" @selection-change="handleChange" :span-method="objectSpanMethod"
+          ref="elTable" :row-class-name="tableRowClassName" border height="520px">
           <el-table-column type="selection" width="40" align="center" />
           <!--  :selectable="selectEnable" -->
           <!-- <el-table-column label="鏄惁绛炬敹" align="center" prop="isSignFor" /> -->
@@ -211,12 +211,7 @@
 
 <script>
 import {
-  listSampling,
-  getSampling,
   getList,
-  delSampling,
-  addSampling,
-  updateSampling,
   confirmSampling,
   getCusCyList,
   mergeCaiYang,
@@ -227,10 +222,8 @@
 import { getNewDateList } from "@/api/hosp/order";
 import moment from "moment";
 import {
-  SubmitCompany,
   getCompany,
   queryCompany,
-  addbatch,
 } from "@/api/team/tuanti";
 export default {
   dicts: [
@@ -244,12 +237,11 @@
   data() {
     return {
       CheckBox: {},
-
       CompanyList: [],
       piliangList: [],
       msg: "",
       getNumbr: null,
-      valueUrl: "ws://192.168.1.138:6789/websocket",
+      valueUrl: "ws://127.0.0.1:6789/websocket",
       webSocket: null,
       list: [],
       selectList: [],
@@ -264,7 +256,6 @@
       tjStatus: "1",
       dayinData: [],
       jsonObj: {},
-
       // 闈炲崟涓鐢�
       single: true,
       // 闈炲涓鐢�
@@ -333,20 +324,17 @@
       form: {},
       // 琛ㄥ崟鏍¢獙
       rules: {},
-      // rightTabShow: false
       allSelected: false,
       disableSelections: false, // 鎺у埗閫夋嫨绂佺敤鐘舵��
     };
   },
   created() {
-    // this.getNowTime();
     getTxmmccd().then((res) => {
       this.msg = Number(res.msg);
       console.log(res, 444);
     });
     getCompany(this.queryParams).then((response) => {
       this.CompanyList = response.data;
-
       this.loading = false;
     });
     this.getdate();
@@ -378,7 +366,7 @@
     // 閫夋鏁版嵁
     searchSelect(val) {
       this.CheckBox = val;
-      this.queryParams.dw = this.CheckBox.cnName;
+      this.queryParams.dw = this.CheckBox.drugManufacturerId;
       console.log(this.CheckBox, 9999);
     },
     getRemoteData(query) {
@@ -393,27 +381,60 @@
       }
     },
     async piliangPrint() {
-      for (const item of this.piliangList) {
-        try {
-          // 鑾峰彇鏁版嵁锛屽苟绛夊緟鏁版嵁鏇存柊瀹屾垚
-          const tableList = await this.fetchData(item.tjNumber);
+      // 妫�鏌ユ槸鍚︽湁閫変腑鐨勬暟鎹�
+      if (this.piliangList.length === 0) {
+        this.$message.warning('璇峰厛閫夋嫨瑕佹墦鍗扮殑鏁版嵁');
+        return;
+      }
 
-          // 鍙繚鐣欐渶鏂颁袱涓厓绱�
-          if (tableList.length > 0) {
-            this.selectList = tableList.slice(0, 2);
-          } else {
-            this.selectList = []; // 濡傛灉娌℃湁鏁版嵁锛屾竻绌簊electList
+      const loadingInstance = this.$loading({
+        lock: true,
+        text: '鎵撳嵃涓�...',
+        spinner: 'el-icon-loading',
+        background: 'rgba(255, 255, 255, 0.7)'
+      });
+
+      try {
+        for (const item of this.piliangList) {
+          try {
+            // 鑾峰彇鏁版嵁锛屽苟绛夊緟鏁版嵁鏇存柊瀹屾垚
+            const tableList = await this.fetchData(item.tjNumber);
+
+            // 妫�鏌� tableList 鏄惁鏈夋暟鎹�
+            if (!tableList || tableList.length === 0) {
+              console.error(`浣撴鍙� ${item.tjNumber} 鏃犵浉鍏虫暟鎹甡);
+              continue;
+            }
+
+            // 鐩存帴浣跨敤鎵�鏈夋暟鎹�
+            this.selectList = tableList;
+
+            // 妫�鏌� selectList 鏄惁鏈夋暟鎹�
+            if (this.selectList.length === 0) {
+              console.error(`浣撴鍙� ${item.tjNumber} 鐨� selectList 涓虹┖锛岃烦杩� WebSocket 鎿嶄綔`);
+              continue;
+            }
+
+            // 浣跨敤鏇存柊鍚庣殑 tableList 鑾峰彇 ids
+            let ids = this.selectList.map(row => row.id);
+            if (ids.length === 0) {
+              console.error(`浣撴鍙� ${item.tjNumber} 鏃犳湁鏁� ID`);
+              continue;
+            }
+
+            // 纭閲囨牱
+            await this.Confirmreceipt1(ids);
+
+            // 绛夊緟涓�娈垫椂闂�
+            await new Promise(resolve => setTimeout(resolve, 5000));
+          } catch (error) {
+            console.error(`澶勭悊浣撴鍙� ${item.tjNumber} 鏃跺嚭閿�:`, error);
           }
-
-          // 浣跨敤鏇存柊鍚庣殑tableList鑾峰彇ids
-          let ids = this.selectList.map(row => row.id);
-          await this.Confirmreceipt1(ids);
-
-          // 绛夊緟涓�娈垫椂闂�
-          await new Promise(resolve => setTimeout(resolve, 5000));
-        } catch (error) {
-          console.error(`澶勭悊浣撴鍙� ${item.tjNumber} 鏃跺嚭閿�:`, error);
         }
+      } finally {
+        this.ids = []; // 娓呯┖ ids
+        this.selectList = []; // 娓呯┖ selectList
+        loadingInstance.close();
       }
     },
     getTruncatedName(proName) {
@@ -615,11 +636,14 @@
       const selectedCount = selection.length;
       const totalCount = this.samplingList.length;
 
-      // 濡傛灉鍙湁涓�鏉℃暟鎹紝涓嶈绂佺敤閫夋嫨
-      if (selectedCount === 1 && totalCount === 1) {
+      // 濡傛灉鍙湁涓�鏉℃暟鎹紝涓嶈绂佺敤閫夋嫨锛屽苟灞曠ず鍙充晶鍒楄〃
+      if (selectedCount === 1) {
         this.disableSelections = false;
-
-      } else if (selectedCount === totalCount && selectedCount > 0) {
+        const selectedPerson = selection[0];
+        const tjNumber = selectedPerson.tjNumber;
+        console.log(`閫変腑鐨勪綋妫�鍙�: ${tjNumber}`);
+        this.fetchData(tjNumber);
+      } else if (selectedCount === totalCount && selectedCount > 1) {
         // 鍏ㄩ�夋椂绂佺敤閫夋嫨鏂拌
         this.disableSelections = true;
         this.tableList = [];
@@ -627,13 +651,7 @@
       } else {
         // 闈炲叏閫夋椂鍚敤閫夋嫨
         this.disableSelections = false;
-
-        if (selectedCount === 1) {
-          const selectedPerson = selection[0];
-          const tjNumber = selectedPerson.tjNumber;
-          console.log(`閫変腑鐨勪綋妫�鍙�: ${tjNumber}`);
-          this.fetchData(tjNumber);
-        } else if (selectedCount > 1) {
+        if (selectedCount > 1) {
           // 淇濈暀鍗曢�夊姛鑳斤紝鍙栨秷澶氶��
           let del_row = selection.shift();
           this.$refs.tb.toggleRowSelection(del_row, false);
@@ -663,6 +681,9 @@
           .then((response) => {
             if (response.data) {
               this.tableList = response.data;
+              this.$nextTick(() => {
+      this.$refs.elTable.doLayout(); // 閫氳繃 ref 璋冪敤琛ㄦ牸鏂规硶
+    });
               resolve(this.tableList);
             } else {
               this.tableList = [];

--
Gitblit v1.8.0