|  |  | 
 |  |  |                 <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="index + '-' + j + 'aaaaaa'" :label="j + '^' + n" | 
 |  |  |                   @change="handleGroupSelect(item.child[0], j)" >{{ n }}</el-checkbox> | 
 |  |  |                   @change="handleGroupSelect(item.child[0], j, item.child[0].arr.length)" >{{ n }}</el-checkbox> | 
 |  |  |                 </el-checkbox-group> | 
 |  |  |               </div> | 
 |  |  |             </td> | 
 |  |  | 
 |  |  |                 </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="index + '-' + j + 'dddddddd'" :label="j + '^' + n" | 
 |  |  |                   @change="handleGroupSelect(m, j)" >{{ n }}</el-checkbox> | 
 |  |  |                   @change="handleGroupSelect(m, j, m.arr.length)" >{{ n }}</el-checkbox> | 
 |  |  |                 </el-checkbox-group> | 
 |  |  |               </div> | 
 |  |  |             </td> | 
 |  |  | 
 |  |  |       :purchaseDialog="purchaseDialog" @resetPurchaseDialog="resetPurchaseDialog"></purchase-verification> | 
 |  |  |     <!--查看工时弹框--> | 
 |  |  |     <viewManHourDia ref="viewManHourDia" @submit="openAddVerifyDia"></viewManHourDia> | 
 |  |  |     <button @click="sss">连接串口</button> | 
 |  |  |   </div> | 
 |  |  | </template> | 
 |  |  |  | 
 |  |  | 
 |  |  | import AddUnPass from "../unpass/components/addUnPass.vue"; | 
 |  |  | import InspectionWord from "./components/InspectionWord.vue"; | 
 |  |  | import PurchaseVerification from "../unpass/components/PurchaseVerification.vue"; | 
 |  |  | import { connect,disconnect } from "@/utils/connect.js"; | 
 |  |  |  | 
 |  |  |  | 
 |  |  | import { | 
 |  |  |   doInsOrder, | 
 |  |  | 
 |  |  | 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', | 
 |  |  | 
 |  |  |         state: null, | 
 |  |  |       }, | 
 |  |  |       isSerialConnected: false, // 新增状态变量,串口连接状态 | 
 |  |  |       serialPort: null, // 存储串口对象 | 
 |  |  |       id: null, | 
 |  |  |       changeType: null, | 
 |  |  |       insOrder: {}, | 
 |  |  | 
 |  |  |   beforeDestroy() { | 
 |  |  |     // 在组件销毁前确保停止 Worker,避免内存泄漏 | 
 |  |  |     this.stopWorker(); | 
 |  |  |     disconnect() | 
 |  |  |     disconnect(); | 
 |  |  |     // 调用前先判断方法是否存在,避免报错 | 
 |  |  |     if (this.closeSerialPort) { | 
 |  |  |       this.closeSerialPort();// 组件销毁前关闭串口 | 
 |  |  |     } | 
 |  |  |   }, | 
 |  |  |   methods: { | 
 |  |  |     sss() { | 
 |  |  |       console.log(this.$store.state.weightList) //  | 
 |  |  |     }, | 
 |  |  |     // 文件管理--开始 | 
 |  |  |     getList() { | 
 |  |  |       this.tableLoading = true; | 
 |  |  | 
 |  |  |       }).catch(() => { }); | 
 |  |  |     }, | 
 |  |  |     // 文件管理--结束 | 
 |  |  |   // 处理整组勾选逻辑的方法 | 
 |  |  |     handleGroupSelect(childItem, clickedIndex) { | 
 |  |  |     // 处理整组勾选逻辑的方法 | 
 |  |  |     handleGroupSelect(childItem, clickedIndex, groupSize = 5) { | 
 |  |  |       if(groupSize == 6){ | 
 |  |  |         groupSize = 6; | 
 |  |  |       }else{ | 
 |  |  |         groupSize = 5; | 
 |  |  |       } | 
 |  |  |       // 计算所在组的起始索引 | 
 |  |  |       const groupStartIndex = Math.floor(clickedIndex / 5) * 5; | 
 |  |  |       const groupStartIndex = Math.floor(clickedIndex / groupSize) * groupSize; | 
 |  |  |       // 清空当前已选 | 
 |  |  |       childItem.getDataIndex1 = []; | 
 |  |  |       // 遍历当前组的 5 个元素,添加到选中列表 | 
 |  |  |       for (let i = groupStartIndex; i < groupStartIndex + 5 && i < childItem.arr.length; i++) { | 
 |  |  |       // 遍历当前组的 groupSize 个元素,添加到选中列表 | 
 |  |  |       for (let i = groupStartIndex; i < groupStartIndex + groupSize && i < childItem.arr.length; i++) { | 
 |  |  |         childItem.getDataIndex1.push(i + '^' + childItem.arr[i]); | 
 |  |  |       } | 
 |  |  |     }, | 
 |  |  | 
 |  |  |     }, | 
 |  |  |  | 
 |  |  |     // 数据采集 | 
 |  |  |     getDataAcquisitionDevice() { | 
 |  |  |       if (this.isSerialConnected) { | 
 |  |  |         connect(); | 
 |  |  |       } | 
 |  |  |       // return | 
 |  |  |       let itemIds = []; | 
 |  |  |       this.currentSample.insProduct.forEach((item) => { | 
 |  |  |         if (item.inspectionItemType === "1") { | 
 |  |  |           itemIds.push(item.id); | 
 |  |  |  | 
 |  |  |   getDataAcquisitionDevice() { | 
 |  |  |       (async () => { | 
 |  |  |         try { | 
 |  |  |           // 检查是否支持 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('检测串口时出错:', 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; | 
 |  |  |         }); | 
 |  |  |       }); | 
 |  |  |     }, | 
 |  |  |     // getDataAcquisitionDevice() { | 
 |  |  |     //   if (this.isSerialConnected) { | 
 |  |  |     //     connect(); | 
 |  |  |     //   } | 
 |  |  |     //   // return | 
 |  |  |     //   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; | 
 |  |  |     //   }); | 
 |  |  |     // }, | 
 |  |  |     // 假设存在一个方法用于更新串口连接状态 | 
 |  |  |     // updateSerialConnectionStatus(status) { | 
 |  |  |     //   this.isSerialConnected = status; | 
 |  |  | 
 |  |  |       return newObj; | 
 |  |  |     }, | 
 |  |  |     handleDataAcquisition(data, noDialog) { | 
 |  |  |       console.log(data); | 
 |  |  |       // 是否可以编辑数采数据 | 
 |  |  |       if (this.dataAcquisitionEidtAble) { | 
 |  |  |         this.getDataType = 1; |