From ecb306c5612f474a5911af20a567f3f4d4db33d1 Mon Sep 17 00:00:00 2001
From: zouyu <2723363702@qq.com>
Date: 星期三, 24 九月 2025 15:02:23 +0800
Subject: [PATCH] 原材料订单拆分功能v1

---
 src/views/business/inspectionTask/inspection.vue |  210 +++++++++++++++++++++++-----------------------------
 1 files changed, 93 insertions(+), 117 deletions(-)

diff --git a/src/views/business/inspectionTask/inspection.vue b/src/views/business/inspectionTask/inspection.vue
index d32723c..b425ec8 100644
--- a/src/views/business/inspectionTask/inspection.vue
+++ b/src/views/business/inspectionTask/inspection.vue
@@ -406,24 +406,24 @@
         <el-button :loading="submitLoading" type="primary" @click="submit()">纭� 瀹�</el-button>
       </span>
     </el-dialog>
-     <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false"
-    :visible.sync="dataGetDia" title="鏁版嵁閲囬泦" width="80%">
-    <div>
-      <table border="1" cellpadding="10" class="thermal-table">
-        <tr>
-          <td style="width: 120px">妫�楠岄」鍒嗙被</td>
-          <td style="width: 120px">妫�楠岄」</td>
-          <td style="width: 120px">妫�楠屽瓙椤�</td>
-          <td>鏁伴噰鏁版嵁</td>
-        </tr>
-        <template v-for="(item, index) in getData">
+    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false"
+      :visible.sync="dataGetDia" title="鏁版嵁閲囬泦" width="80%">
+      <div>
+        <table border="1" cellpadding="10" class="thermal-table">
           <tr>
-            <td :rowspan="item.child.length">{{ item.sortName }}</td>
-            <td :rowspan="item.child.length">{{ item.faName }}</td>
-            <td>{{ item.child[0].name }}</td>
-            <td style="text-align: left">
-              <!-- 娣诲姞瀹瑰櫒 div -->
-              <div class="data-collection-items">
+            <td style="width: 120px">妫�楠岄」鍒嗙被</td>
+            <td style="width: 120px">妫�楠岄」</td>
+            <td style="width: 120px">妫�楠屽瓙椤�</td>
+            <td>鏁伴噰鏁版嵁</td>
+          </tr>
+          <template v-for="(item, index) in getData">
+            <tr>
+              <td :rowspan="item.child.length">{{ item.sortName }}</td>
+              <td :rowspan="item.child.length">{{ item.faName }}</td>
+              <td>{{ item.child[0].name }}</td>
+              <td style="text-align: left">
+                <!-- 娣诲姞瀹瑰櫒 div -->
+                <div class="data-collection-items">
                 <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)">
@@ -526,7 +526,6 @@
       :purchaseDialog="purchaseDialog" @resetPurchaseDialog="resetPurchaseDialog"></purchase-verification>
     <!--鏌ョ湅宸ユ椂寮规-->
     <viewManHourDia ref="viewManHourDia" @submit="openAddVerifyDia"></viewManHourDia>
-    <button @click="sss">杩炴帴涓插彛</button>
   </div>
 </template>
 
@@ -667,18 +666,10 @@
             {
               name: "1285nm~1330nm",
               arr: [12, 13, 14, 15],
-              // 鍒濆鍖� getDataIndex1 涓烘暟缁�
-              getDataIndex1: [],
-              isShowSelect: false,
-              maxNum: 5
             },
             {
               name: "1525nm~1575nm",
               arr: [12, 13, 14, 15],
-              // 鍒濆鍖� getDataIndex1 涓烘暟缁�
-              getDataIndex1: [],
-              isShowSelect: false,
-              maxNum: 5
             },
           ],
         },
@@ -688,10 +679,6 @@
             {
               name: "鎴嚦娉㈤暱",
               arr: [12, 13, 14, 15],
-              // 鍒濆鍖� getDataIndex1 涓烘暟缁�
-              getDataIndex1: [],
-              isShowSelect: false,
-              maxNum: 5
             },
           ],
         },
@@ -762,7 +749,6 @@
         size: 10,
         current: 0,
       },
-      tableLoading: false,
       // 鏂囦欢鍒楄〃鐩稿叧--缁撴潫
       // 浠诲姟鍒囨崲鍒楄〃--寮�濮�
       tableData0: [],
@@ -797,6 +783,7 @@
       },
       tableLoading0: false,
       // 浠诲姟鍒囨崲鍒楄〃--缁撴潫
+      isSplit: 0, // 鏄惁鏄媶鍗曡繃鏉ョ殑
     };
   },
   // 鐢ㄤ簬涓婁紶鏂囦欢鐨勪俊鎭�
@@ -807,7 +794,7 @@
     },
   },
   created() {
-    let { sonLaboratory, orderId, state, inspectorList, typeSource } =
+    let { sonLaboratory, orderId, state, inspectorList, typeSource,isSplit } =
       this.$route.query;
     this.sonLaboratory = sonLaboratory;
     this.orderId = orderId;
@@ -815,6 +802,7 @@
     this.state = state;
     this.inspectorList = inspectorList;
     this.typeSource = typeSource;
+    this.isSplit = isSplit;
   },
   mounted() {
     this.getTypeDicts(); // 鑾峰彇绱ф�ョ▼搴︿笅鎷夋閫夐」
@@ -824,7 +812,6 @@
     this.startWorker();
     // this.getList0() // 浠诲姟鍒囨崲
     this.scrollInit();
-    disconnect()
   },
   activated() {
     this.getTypeDicts(); // 鑾峰彇绱ф�ョ▼搴︿笅鎷夋閫夐」
@@ -912,7 +899,7 @@
   },
   methods: {
     sss() {
-      console.log(this.$store.state.weightList) // 
+      console.log(this.$store.state.weightList) //
     },
     // 鏂囦欢绠$悊--寮�濮�
     getList() {
@@ -1152,17 +1139,24 @@
   getDataAcquisitionDevice() {
       (async () => {
         try {
-          // 妫�鏌ユ槸鍚︽敮鎸� Web Serial API
-          if ('serial' in navigator) {
-            // 璇锋眰鍙敤涓插彛
-            const ports = await navigator.serial.getPorts();
-            if (ports.length > 0) {
-              await connect();
+          // 妫�鏌ラ〉闈腑妫�娴嬮」鏄惁鍖呭惈瀵嗗害
+          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('娌℃湁鍙敤鐨勪覆鍙�');
+              console.log('褰撳墠娴忚鍣ㄤ笉鏀寔 Web Serial API');
             }
-          } else {
-            console.log('褰撳墠娴忚鍣ㄤ笉鏀寔 Web Serial API');
           }
         } catch (error) {
           console.error('妫�娴嬩覆鍙f椂鍑洪敊:', error);
@@ -1194,41 +1188,6 @@
         });
       });
     },
-    // 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;
-    //   });
-    // },
-    // 鍋囪瀛樺湪涓�涓柟娉曠敤浜庢洿鏂颁覆鍙h繛鎺ョ姸鎬�
-    // updateSerialConnectionStatus(status) {
-    //   this.isSerialConnected = status;
-    // },
-
     objectOrder(obj) {
       let newkey = Object.keys(obj).sort();
       let newObj = {};
@@ -1238,7 +1197,6 @@
       return newObj;
     },
     handleDataAcquisition(data, noDialog) {
-      console.log(data);
       // 鏄惁鍙互缂栬緫鏁伴噰鏁版嵁
       if (this.dataAcquisitionEidtAble) {
         this.getDataType = 1;
@@ -1291,7 +1249,6 @@
               };
             }
             let list = this.tableList[0].arr;
-            console.log(this.tableList[0]);
             // 寰幆椤甸潰鍒楄〃淇℃伅锛屽垽鏂暟閲囨暟鎹搴旈〉闈㈠垪琛ㄤ俊鎭殑妫�楠岄」鏄摢涓紝骞剁粰褰撳墠妫�楠岄」缁戝畾璁惧淇℃伅
             list.forEach((item, index) => {
               let num0 = 0;
@@ -1359,7 +1316,6 @@
               }
             };
             let list = this.tableList[0].arr;
-            console.log(this.tableList[0]);
             let maxNum = 0;
             list.forEach((item, index) => {
               let num0 = 0;
@@ -1464,7 +1420,6 @@
       } else {
         // 濡傛灉閮戒笉瀛樺湪锛屽垯锛岃繘鍏ュ鐞嗘暟閲囩嚎绋嬮噷鍘诲鐞嗘暟鎹�
         try {
-          console.log(this.dataAcquisitionInfo);
           // 鍚� Worker 鍙戦�佹秷鎭紝寮�濮嬪鐞嗛�昏緫
           this.getDataIndexLoading = false;
           this.dataGetDia = false;
@@ -2666,6 +2621,26 @@
     openAddVerifyDia() {
       this.addVerifyDia = true;
     },
+    confirmSubmit(registerInsResults){
+      submitPlan({
+        orderId: this.orderId,
+        laboratory: this.sonLaboratory,
+        verifyUser: this.verifyUser,
+        entrustCode: this.insOrder.entrustCode,
+        registerInsResults: registerInsResults
+      }).then((res) => {
+        if (res.code === 200) {
+          this.$message.success("鎿嶄綔鎴愬姛");
+          this.goback();
+          this.submitLoading = false;
+          this.addVerifyDia = false;
+        }
+      })
+        .catch((error) => {
+          console.error(error);
+          this.submitLoading = false;
+        });
+    },
     submit() {
       if (this.verifyUser === null || this.verifyUser === "") {
         this.$message.error("璇锋寚瀹氬鏍镐汉鍛�");
@@ -2684,26 +2659,26 @@
         orderId: this.orderId,
         laboratory: this.sonLaboratory,
       }).then((res) => {
+        console.log(res)
         if (res.code === 200) {
-          if (!res.data || res.data.length == 0) {
+          if (!res.data || res.data.errorMsg.length == 0) {
             this.submitLoading = true;
-            submitPlan({
-              orderId: this.orderId,
-              laboratory: this.sonLaboratory,
-              verifyUser: this.verifyUser,
-              entrustCode: this.insOrder.entrustCode,
-            }).then((res) => {
-              if (res.code === 200) {
-                this.$message.success("鎿嶄綔鎴愬姛");
-                this.goback();
-                this.submitLoading = false;
-                this.addVerifyDia = false;
-              }
-            })
-              .catch((error) => {
-                console.error(error);
-                this.submitLoading = false;
+            //妫�楠岀被鍨嬩负鍘熸潗鏂�
+            if(this.typeSource==1 && res.data.unInsOrderCount==0 && this.isSplit==1){
+              const htmlStr = "鏄惁鐧昏IFS閲囪喘妫�楠岀粨鏋滃苟绉诲簱锛熻鎿嶄綔浼氱櫥璁�<span style='color:#ff4949'>鍚屼竴闆朵欢鍚屼竴璁㈠崟鐨勬墍鏈夋媶鍒嗘壒娆�</span>锛岃璋ㄦ厧閫夋嫨銆�"
+              this.$confirm(htmlStr, '鎻愮ず', {
+                confirmButtonText: '鏄�',
+                cancelButtonText: '鍚�',
+                type: 'warning',
+                dangerouslyUseHTMLString: true
+              }).then(() => {
+                this.confirmSubmit(true)
+              }).catch(() => {
+                this.confirmSubmit(false)
               });
+            }else{
+              this.confirmSubmit(false)
+            }
           } else {
             let newData = [];
             const h = this.$createElement;
@@ -2739,22 +2714,23 @@
             })
               .then(() => {
                 this.submitLoading = true;
-                submitPlan({
-                  orderId: this.orderId,
-                  laboratory: this.sonLaboratory,
-                  verifyUser: this.verifyUser,
-                }).then((res) => {
-                  if (res.code === 200) {
-                    this.$message.success("鎿嶄綔鎴愬姛");
-                    this.addVerifyDia = false;
-                    this.goback();
-                  }
-                  this.submitLoading = false;
-                })
-                  .catch((error) => {
-                    console.error(error);
-                    this.submitLoading = false;
-                  });
+                this.confirmSubmit(false)
+                // submitPlan({
+                //   orderId: this.orderId,
+                //   laboratory: this.sonLaboratory,
+                //   verifyUser: this.verifyUser,
+                // }).then((res) => {
+                //   if (res.code === 200) {
+                //     this.$message.success("鎿嶄綔鎴愬姛");
+                //     this.addVerifyDia = false;
+                //     this.goback();
+                //   }
+                //   this.submitLoading = false;
+                // })
+                //   .catch((error) => {
+                //     console.error(error);
+                //     this.submitLoading = false;
+                //   });
               })
               .catch(() => { });
           }
@@ -3271,11 +3247,11 @@
 
 .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 2%;
 }

--
Gitblit v1.9.3