From adacd2dc7ea6fd0c989b15f8f7beb06e69810d74 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期四, 14 八月 2025 13:22:10 +0800
Subject: [PATCH] oa标题修改

---
 src/views/business/inspectionTask/inspection.vue |  191 +++++++++++++++++++++++++++++++----------------
 1 files changed, 127 insertions(+), 64 deletions(-)

diff --git a/src/views/business/inspectionTask/inspection.vue b/src/views/business/inspectionTask/inspection.vue
index 834cf69..d750b75 100644
--- a/src/views/business/inspectionTask/inspection.vue
+++ b/src/views/business/inspectionTask/inspection.vue
@@ -141,7 +141,7 @@
           <el-button :loading="dataAcquisitionLoading" v-if="state == 1" size="small" type="primary"
             @click="getDataAcquisitionDevice">鏁版嵁閲囬泦</el-button>
           <el-button :type="dataAcquisitionEidtAble ? '' : 'primary'" v-if="state == 1" size="small"
-            @click="dataAcquisitionEidtAble = !dataAcquisitionEidtAble">{{ dataAcquisitionEidtAble ? "鍏抽棴缂栬緫" : "缂栬緫鏁伴噰"
+            @click="dataAcquisitionEidtAble = !dataAcquisitionEidtAble,disconnect()">{{ dataAcquisitionEidtAble ? "鍏抽棴缂栬緫" : "缂栬緫鏁伴噰"
             }}</el-button>
         </div>
       </div>
@@ -427,68 +427,71 @@
                 <el-select v-if="item.child[0].isShowSelect" v-model="item.child[0].getDataIndex1"
                   :multiple-limit="item.child[0].maxNum" clearable filterable multiple placeholder="璇烽�夋嫨"
                   @change="setData(item)">
-                  <el-option v-for="(item, index) in item.child[0].arr" :key="index" :filter-method="filterMethod"
-                    :label="index + 1 + '^' + item.result" :value="index + '^' + item.result">
+                  <el-option v-for="(subItem, subIndex) in item.child[0].arr" :key="index + '-' + subIndex" :filter-method="filterMethod"
+                    :label="subIndex + 1 + '^' + subItem.result" :value="subIndex + '^' + subItem.result">
                     <span>{{
                       "搴忓彿锛�" +
-                      (index + 1) +
+                      (subIndex + 1) +
                       "锛�" +
                       "缁撴灉锛�" +
-                      item.result +
+                      subItem.result +
                       "锛�" +
                       "鍘氬害锛�" +
-                      item.thickness +
+                      subItem.thickness +
                       "锛�" +
                       "鏃堕棿锛�" +
-                      item.mergedDateTime
+                      subItem.mergedDateTime
                     }}</span>
                   </el-option>
                 </el-select>
                 <el-checkbox-group v-if="!item.child[0].isShowSelect" v-model="item.child[0].getDataIndex1"
                   :max="item.child[0].maxNum">
-                  <el-checkbox v-for="(n, j) in item.child[0].arr" :key="j" :label="j + '^' + n">{{ n }}</el-checkbox>
+                  <el-checkbox v-for="(n, j) in item.child[0].arr" :key="index + '-' + j + 'aaaaaa'" :label="j + '^' + n"
+                  @change="handleGroupSelect(item.child[0], j, item.child[0].arr.length)" >{{ n }}</el-checkbox>
                 </el-checkbox-group>
-                </div>
-              </td>
-            </tr>
-            <tr v-for="(m, i) in item.child" v-show="i > 0" :key="i + 'bbbbbbbbbbbbbb'">
-              <td>{{ m.name }}</td>
-              <td style="text-align: left">
-                 <!-- 娣诲姞瀹瑰櫒 div -->
-                 <div class="data-collection-items">
+              </div>
+            </td>
+          </tr>
+          <tr v-for="(m, i) in item.child" v-show="i > 0" :key="index + '-' + i + 'bbbbbbbbbbbbbb'">
+            <td>{{ m.name }}</td>
+            <td style="text-align: left">
+              <!-- 娣诲姞瀹瑰櫒 div -->
+              <div class="data-collection-items">
                 <el-select v-if="m.isShowSelect" v-model="m.getDataIndex1" :multiple-limit="m.maxNum" clearable
                   filterable multiple placeholder="璇烽�夋嫨">
-                  <el-option v-for="(item, index1) in m.arr" :key="index1" :label="index + 1 + '^' + item.result"
-                    :value="index1 + '^' + item.result">
+                  <el-option v-for="(subItem, index1) in m.arr" :key="index + '-' + index1 + 'cccccccc'"
+                    :label="index1 + 1 + '^' + subItem.result" :value="index1 + '^' + subItem.result">
                     <span>{{
                       "搴忓彿锛�" +
                       (index1 + 1) +
                       "锛�" +
                       "缁撴灉锛�" +
-                      item.result +
+                      subItem.result +
                       "锛�" +
                       "鍘氬害锛�" +
-                      item.thickness +
+                      subItem.thickness +
                       "锛�" +
                       "鏃堕棿锛�" +
-                      item.mergedDateTime
+                      subItem.mergedDateTime
                     }}</span>
                   </el-option>
                 </el-select>
                 <el-checkbox-group v-if="!m.isShowSelect" v-model="m.getDataIndex1" :max="m.maxNum">
-                  <el-checkbox v-for="(n, j) in m.arr" :key="j" :label="j + '^' + n">{{ n }}</el-checkbox>
+                  <el-checkbox v-for="(n, j) in m.arr" :key="index + '-' + j + 'dddddddd'" :label="j + '^' + n"
+                  @change="handleGroupSelect(m, j, m.arr.length)" >{{ n }}</el-checkbox>
                 </el-checkbox-group>
               </div>
-              </td>
-            </tr>
-          </template>
-        </table>
-      </div>
-      <span slot="footer" class="dialog-footer">
-        <el-button @click="dataGetDia = false">鍙� 娑�</el-button>
-        <el-button :loading="getDataIndexLoading" type="primary" @click="submitDataGet()">纭� 瀹�</el-button>
-      </span>
-    </el-dialog>
+            </td>
+          </tr>
+        </template>
+      </table>
+    </div>
+    <span slot="footer" class="dialog-footer">
+      <el-button @click="dataGetDia = false">鍙� 娑�</el-button>
+      <el-button :loading="getDataIndexLoading" type="primary" @click="submitDataGet()">纭� 瀹�</el-button>
+    </span>
+  </el-dialog>
+
     <el-dialog :close-on-click-modal="false" :visible.sync="addCheck" title="鎸囧畾鎶ュ憡瀹℃牳浜哄憳" width="400px"
       @close="closeAddVerifyDia">
       <div class="body" style="display: flex; padding: 10px; align-items: center">
@@ -533,6 +536,8 @@
 import AddUnPass from "../unpass/components/addUnPass.vue";
 import InspectionWord from "./components/InspectionWord.vue";
 import PurchaseVerification from "../unpass/components/PurchaseVerification.vue";
+
+
 import {
   doInsOrder,
   getCableTag,
@@ -556,6 +561,7 @@
 import DataWorker from '@/workers/DataWorker.worker.js';
 import html2canvas from "html2canvas";
 import { mapGetters } from "vuex";
+import { connect,disconnect,weightList } from "@/utils/connect.js";
 import viewManHourDia from "@/views/business/inspectionTask/components/viewManHourDia.vue";
 export default {
   name: 'Inspection',
@@ -593,6 +599,8 @@
         sampleName: null,
         state: null,
       },
+      isSerialConnected: false, // 鏂板鐘舵�佸彉閲忥紝涓插彛杩炴帴鐘舵��
+      serialPort: null, // 瀛樺偍涓插彛瀵硅薄
       id: null,
       changeType: null,
       insOrder: {},
@@ -882,8 +890,16 @@
   beforeDestroy() {
     // 鍦ㄧ粍浠堕攢姣佸墠纭繚鍋滄 Worker锛岄伩鍏嶅唴瀛樻硠婕�
     this.stopWorker();
+    disconnect();
+    // 璋冪敤鍓嶅厛鍒ゆ柇鏂规硶鏄惁瀛樺湪锛岄伩鍏嶆姤閿�
+    if (this.closeSerialPort) {
+      this.closeSerialPort();// 缁勪欢閿�姣佸墠鍏抽棴涓插彛
+    }
   },
   methods: {
+    sss() {
+      console.log(this.$store.state.weightList) //
+    },
     // 鏂囦欢绠$悊--寮�濮�
     getList() {
       this.tableLoading = true;
@@ -919,6 +935,22 @@
       }).catch(() => { });
     },
     // 鏂囦欢绠$悊--缁撴潫
+    // 澶勭悊鏁寸粍鍕鹃�夐�昏緫鐨勬柟娉�
+    handleGroupSelect(childItem, clickedIndex, groupSize = 5) {
+      if(groupSize == 6){
+        groupSize = 6;
+      }else{
+        groupSize = 5;
+      }
+      // 璁$畻鎵�鍦ㄧ粍鐨勮捣濮嬬储寮�
+      const groupStartIndex = Math.floor(clickedIndex / groupSize) * groupSize;
+      // 娓呯┖褰撳墠宸查��
+      childItem.getDataIndex1 = [];
+      // 閬嶅巻褰撳墠缁勭殑 groupSize 涓厓绱狅紝娣诲姞鍒伴�変腑鍒楄〃
+      for (let i = groupStartIndex; i < groupStartIndex + groupSize && i < childItem.arr.length; i++) {
+        childItem.getDataIndex1.push(i + '^' + childItem.arr[i]);
+      }
+    },
 
     // 浠诲姟鍒囨崲--寮�濮�
     getList0() {
@@ -1100,31 +1132,59 @@
       this.$refs.purchaseDialog.$refs["purchaseForm"].resetFields();
       this.purchaseDialog = false;
     },
+
     // 鏁版嵁閲囬泦
-    getDataAcquisitionDevice() {
-      let itemIds = [];
-      this.currentSample.insProduct.forEach((item) => {
-        if (item.inspectionItemType === "1") {
-          itemIds.push(item.id);
+
+  getDataAcquisitionDevice() {
+      (async () => {
+        try {
+          // 妫�鏌ラ〉闈腑妫�娴嬮」鏄惁鍖呭惈瀵嗗害
+          const hasDensityItem = this.currentSample.insProduct.some(item => {
+            // 鍋囪瀵嗗害鐩稿叧鐨勬娴嬮」鍚嶇О鍖呭惈 "瀵嗗害" 鍏抽敭瀛楋紝鍙寜闇�淇敼
+            return item.inspectionItem && item.inspectionItem.includes('瀵嗗害');
+          });
+          if (hasDensityItem) {
+            // 妫�鏌ユ槸鍚︽敮鎸� Web Serial API
+            if ('serial' in navigator) {
+              // 璇锋眰鍙敤涓插彛
+              const ports = await navigator.serial.getPorts();
+              if (ports.length > 0) {
+                await connect();
+              } else {
+                console.log('娌℃湁鍙敤鐨勪覆鍙�');
+              }
+            } else {
+              console.log('褰撳墠娴忚鍣ㄤ笉鏀寔 Web Serial API');
+            }
+          }
+        } catch (error) {
+          console.error('妫�娴嬩覆鍙f椂鍑洪敊:', error);
         }
-      });
-      const params = {
-        entrustCode: this.insOrder.entrustCode,
-        sampleCode: this.currentSample.sampleCode,
-        id: this.currentSample.id,
-        itemIds: itemIds,
-      };
-      this.dataAcquisitionLoading = true;
-      dataCollection(params).then((res) => {
-        this.dataAcquisitionLoading = false;
-        if (res.code != 200) {
-          return;
-        }
-        this.dataAcquisitionInfoNew = this.HaveJson(res.data);
-        // 瀵规暟閲囧洖鏉ョ殑鍊艰繘琛屽鐞�
-        this.handleDataAcquisition(res.data);
-      }).catch(err => {
-        this.dataAcquisitionLoading = false;
+      })().then(() => {
+        let itemIds = [];
+        this.currentSample.insProduct.forEach((item) => {
+          if (item.inspectionItemType === "1") {
+            itemIds.push(item.id);
+          }
+        });
+        const params = {
+          entrustCode: this.insOrder.entrustCode,
+          sampleCode: this.currentSample.sampleCode,
+          id: this.currentSample.id,
+          itemIds: itemIds,
+        };
+        this.dataAcquisitionLoading = true;
+        dataCollection(params).then((res) => {
+          this.dataAcquisitionLoading = false;
+          if (res.code != 200) {
+            return;
+          }
+          this.dataAcquisitionInfoNew = this.HaveJson(res.data);
+          // 瀵规暟閲囧洖鏉ョ殑鍊艰繘琛屽鐞�
+          this.handleDataAcquisition(res.data);
+        }).catch(err => {
+          this.dataAcquisitionLoading = false;
+        });
       });
     },
     objectOrder(obj) {
@@ -1253,7 +1313,7 @@
               } else {
                 str0 = i + "," + j;
               }
-            }
+            };
             let list = this.tableList[0].arr;
             let maxNum = 0;
             list.forEach((item, index) => {
@@ -1286,6 +1346,7 @@
                   }
                   let num = 0;
                   list[index].forEach((n) => {
+                    // console.log(n.v.ps.value);
                     if (
                       n.v.ps &&
                       n.v.ps.value &&
@@ -2082,12 +2143,10 @@
         }
       });
       // 鏈寰幆涓昏鏄椤甸潰鍙婂悗绔紶鍙傝繘琛屽垵濮嬪寲璧嬪��
-      console.log(this.currentSample.insProduct)
       this.currentSample.insProduct.forEach(async (a) => {
         try {
           // 璁$畻鍊艰祴鍊�
           let comValue = JSON.parse(a.insProductResult.comValue);
-          
           for (var i = 0; i < comValue.length; i++) {
             if (
               this.param[a.id].comValue.find(
@@ -2887,9 +2946,12 @@
       this.$router.go(-1)
     }
   },
+  destroyed() {
+    disconnect()
+  },
 };
 </script>
-<styl scoped>
+<style scoped>
 .custom-table .el-table__header-wrapper th {
   background-color: #87ceeb;
   /* 鍙甯︽湁my-custom-table绫荤殑琛ㄦ牸鐢熸晥 */
@@ -3091,7 +3153,7 @@
   display: inline-flex;
   align-items: center;
 }
-</styl>
+</style>
 <style scoped>
 /* .inspection .el-form-item__label {
   color: #000;
@@ -3159,15 +3221,16 @@
   max-width: 1000px;
   /* 璁剧疆鏈�澶у搴� */
 }
+
+
 .data-collection-items {
   display: flex;
-  flex-wrap: wrap; 
+  flex-wrap: wrap;
 }
 .data-collection-items .el-select,
 .data-collection-items .el-checkbox {
-  flex-basis: 20% ; 
+  flex-basis: 20% ;
   box-sizing: border-box;
-  padding: 5px 15px;
+  padding: 5px 2%;
 }
 </style>
- 
\ No newline at end of file

--
Gitblit v1.9.3