From fcadf16afa65a8a5ca53a33c4b8f4bf2efe2ea03 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期三, 16 九月 2026 09:21:44 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_新疆_新聚' into dev_新疆_新聚

---
 src/views/business/inspectionTask/inspection.vue |  144 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 99 insertions(+), 45 deletions(-)

diff --git a/src/views/business/inspectionTask/inspection.vue b/src/views/business/inspectionTask/inspection.vue
index 94318dc..68b3a9a 100644
--- a/src/views/business/inspectionTask/inspection.vue
+++ b/src/views/business/inspectionTask/inspection.vue
@@ -92,7 +92,6 @@
           <el-descriptions-item label="闆朵欢鍙�">{{insOrder.partNo}}</el-descriptions-item>
           <el-descriptions-item label="闆朵欢鍚嶇О">{{insOrder.partDetail}}</el-descriptions-item>
           <el-descriptions-item label="鎵规鍙�">{{ insOrder.lotBatchNo }}</el-descriptions-item>
-          <el-descriptions-item label="鏍峰搧鍨嬪彿" >{{currentSample.model}}</el-descriptions-item>
           <el-descriptions-item label="鎶芥鏁伴噺">{{insOrder.testQuantity}}</el-descriptions-item>
           <el-descriptions-item label="鍘傚瀵嗗害">{{supplierDensity}}</el-descriptions-item>
           <template v-if="insOrder.ifsOrderType && insOrder.ifsOrderType==='02wg'">
@@ -109,8 +108,7 @@
           <el-descriptions-item label="濮旀墭缂栧彿">{{ insOrder.entrustCode }}</el-descriptions-item>
           <el-descriptions-item label="鏍峰搧缂栧彿">{{ currentSample.sampleCode }}</el-descriptions-item>
           <el-descriptions-item label="鏍峰搧鍚嶇О">{{ currentSample.sample }}</el-descriptions-item>
-          <el-descriptions-item label="鏍峰搧鏁伴噺">{{ sampleProduct.length }}</el-descriptions-item>
-          <el-descriptions-item label="鏍峰搧鍨嬪彿">{{ currentSample.model }}</el-descriptions-item>
+          <el-descriptions-item label="鏍峰搧鏁伴噺">{{ insOrder.testQuantity }}</el-descriptions-item>
           <el-descriptions-item label="涓嬪彂鏃堕棿">{{ insOrder.sendTime }}</el-descriptions-item>
           <el-descriptions-item label="绱ф�ョ▼搴�">{{ insOrder.typeName }}</el-descriptions-item>
           <el-descriptions-item label="绾﹀畾鏃堕棿">{{ insOrder.appointed }}</el-descriptions-item>
@@ -119,6 +117,18 @@
         <el-descriptions-item label="澶囨敞">
           <el-input v-model="insOrder.remark" :disabled="state != 1" clearable placeholder="璇疯緭鍏�" size="small"
                     @blur="subOtherForm(insOrder.remark, 'remark')"></el-input>
+        </el-descriptions-item>
+        <el-descriptions-item v-if="isDirectTemplateOrder()" label="璁惧" :span="2">
+          <el-select v-model="selectedDeviceIds" multiple filterable clearable size="small" placeholder="璇烽�夋嫨璁惧"
+            :disabled="state != 1" @change="saveOverviewDevices">
+            <el-option v-for="device in orderDeviceOptions" :key="device.id" :label="device.label" :value="device.id" />
+          </el-select>
+        </el-descriptions-item>
+        <el-descriptions-item label="妫�楠岀粨璁�">
+          <el-radio-group v-model="reviewInsResult" :disabled="state != 2">
+            <el-radio :label="1">鍚堟牸</el-radio>
+            <el-radio :label="0">涓嶅悎鏍�</el-radio>
+          </el-radio-group>
         </el-descriptions-item>
       </el-descriptions>
     </div>
@@ -385,17 +395,6 @@
           </el-select>
         </div>
       </div>
-      <div class="body" style="display: flex; padding: 10px; align-items: center">
-        <div class="search_label" style="width: 150px">
-          <span class="required-span">*</span>鎶ュ憡绫诲瀷
-        </div>
-        <div class="search_input" style="width: 100%">
-          <el-select v-model="reportType" clearable placeholder="璇烽�夋嫨" size="small" style="width: 100%">
-            <el-option label="妫�娴嬫姤鍛�" :value="0"></el-option>
-            <el-option label="妫�楠屾姤鍛�" :value="1"></el-option>
-          </el-select>
-        </div>
-      </div>
       <span slot="footer" class="dialog-footer">
         <el-button @click="addVerifyDia = false">鍙� 娑�</el-button>
         <el-button :loading="submitLoading" type="primary" @click="submit()">纭� 瀹�</el-button>
@@ -579,6 +578,9 @@
   checkSubmitPlan,
   submitPlan,
   saveInsContext,
+  saveTemplateContext,
+  getOrderDevices,
+  saveOrderDevices,
   selectUserCondition,
   downFile,
   getFileList,
@@ -661,16 +663,18 @@
       comparisonList: [],
       excelMethodList: [],
       equipOptions: [],
+      orderDeviceOptions: [],
+      selectedDeviceIds: [],
       reviewLoading: false,
       reviewDia: false,
       noReason: "",
+      reviewInsResult: null,
       tableWidth: 1000,
       currentTable: null,
       tableLists: [],
       widthList: [],
       addVerifyDia: false,
       verifyUser: null,
-      reportType: null,
       personList: [],
       enumList: [],
       tableLoading: false,
@@ -696,6 +700,8 @@
       worker0: null,
       // 妫�楠屽�兼寜瑙﹀彂椤哄簭涓茶淇濆瓨锛岄伩鍏嶅悓涓�妫�楠岄」鐨勬棫璇锋眰瑕嗙洊鏂拌姹傘��
       saveQueue: null,
+      calculationRevision: 0,
+      completedCalculationRevision: 0,
       wareLength: [],
       dataAcquisitionInfo: {},
       dataAcquisitionInfoNew: {},
@@ -827,7 +833,6 @@
       },
       tableLoading0: false,
       // 浠诲姟鍒囨崲鍒楄〃--缁撴潫
-      isSplit: 0, // 鏄惁鏄媶鍗曡繃鏉ョ殑
     };
   },
   // 鐢ㄤ簬涓婁紶鏂囦欢鐨勪俊鎭�
@@ -839,7 +844,7 @@
   },
   created() {
     this.saveQueue = Promise.resolve();
-    let { sonLaboratory, orderId, state, inspectorList, typeSource,isSplit } =
+    let { sonLaboratory, orderId, state, inspectorList, typeSource } =
       this.$route.query;
     this.sonLaboratory = sonLaboratory;
     this.orderId = orderId;
@@ -847,7 +852,6 @@
     this.state = state;
     this.inspectorList = inspectorList;
     this.typeSource = typeSource;
-    this.isSplit = isSplit;
   },
   mounted() {
     this.getTypeDicts(); // 鑾峰彇绱ф�ョ▼搴︿笅鎷夋閫夐」
@@ -1077,6 +1081,7 @@
         laboratory: this.sonLaboratory,
       }).then(async (res) => {
         this.insOrder = res.data.insOrder;
+        this.reviewInsResult = this.insOrder.insResult;
         if(res.data.insOrder.ifsOrderType==='02wg'){
           //鏌ヨ闆朵欢灞炴��
           this.getPartProps(res.data.insOrder.ifsInventoryId)
@@ -1109,6 +1114,9 @@
           this.rawMaterialTag = "1";
         }
         this.getEquipOptions(1);
+        if (this.sonLaboratory === "鏂拌仛") {
+          this.loadOverviewDevices();
+        }
         // 鑾峰彇褰撳墠鏍峰搧鐨勬楠岄」
         let list = await this.getCurrentProduct(this.currentSample.id, 0);
         this.currentSample.insProduct = this.HaveJson(list);
@@ -2003,6 +2011,7 @@
         }
       }
       try {
+        const revision = ++this.calculationRevision;
         // 鍚� Worker 鍙戦�佹秷鎭紝寮�濮嬪鐞嗛�昏緫
         this.worker.postMessage(
           JSON.stringify({
@@ -2017,6 +2026,7 @@
             getDataTypeId: this.getDataTypeId,
             modelType: this.sampleProduct[0].model,
             currentInsItem: n,
+            revision: revision,
           })
         );
         // 鍏堜繚瀛樹富绾跨▼涓凡缁忚緭鍏ョ殑鍘熷鍊笺�俉orker 瀹屾垚璁$畻鍚庝細鍐嶆鍏ラ槦淇濆瓨璁$畻缁撴灉銆�
@@ -2031,6 +2041,9 @@
       // 鐩戝惉 Worker 杩斿洖鐨勭粨鏋�
       this.worker.onmessage = (event) => {
         const workerResult = JSON.parse(event.data);
+        if (workerResult.revision != null && workerResult.revision < this.calculationRevision) {
+          return;
+        }
         this.result = workerResult;
         switch (workerResult.method) {
           case "saveInsContext":
@@ -2043,6 +2056,10 @@
               );
               this.param = resultValue.param;
               this.saveInsContext();
+              this.completedCalculationRevision = Math.max(
+                this.completedCalculationRevision,
+                workerResult.revision || 0
+              );
             });
             break;
           case "tableList":
@@ -2162,6 +2179,10 @@
     upInsReview(e) {
       if (e == 1) {
         // 閫氳繃
+        if (this.reviewInsResult !== 0 && this.reviewInsResult !== 1) {
+          this.$message.error("璇烽�夋嫨妫�楠岀粨璁�");
+          return;
+        }
         this.reviewLoading = true;
         verifyPlan({
           orderId: this.orderId,
@@ -2169,6 +2190,7 @@
           laboratory: this.sonLaboratory,
           tell: null,
           userId: this.checkUser,
+          insResult: this.reviewInsResult,
         }).then((res) => {
           if (res.code === 200) {
             this.$message.success("鎿嶄綔鎴愬姛");
@@ -2214,17 +2236,15 @@
       this.$refs.viewManHourDia.showDialog(this.id, 99);
     },
     openAddVerifyDia() {
-      this.reportType = null;
       this.addVerifyDia = true;
     },
-    confirmSubmit(registerInsResults){
+    confirmSubmit(){
       submitPlan({
         orderId: this.orderId,
         laboratory: this.sonLaboratory,
         verifyUser: this.verifyUser,
         entrustCode: this.insOrder.entrustCode,
-        registerInsResults: this.reportType === 1 && registerInsResults,
-        reportType: this.reportType
+        registerInsResults: false,
       }).then((res) => {
         if (res.code === 200) {
           this.$message.success("鎿嶄綔鎴愬姛");
@@ -2243,8 +2263,8 @@
         this.$message.error("璇锋寚瀹氬鏍镐汉鍛�");
         return;
       }
-      if (this.reportType === null || this.reportType === "") {
-        this.$message.error("璇烽�夋嫨鎶ュ憡绫诲瀷");
+      if (this.isDirectTemplateOrder() && (!this.selectedDeviceIds || this.selectedDeviceIds.length === 0)) {
+        this.$message.error("璇烽�夋嫨璁惧");
         return;
       }
       if (!this.otherForm.humidity && this.insOrder.ifsOrderType!=='02wg') {
@@ -2264,27 +2284,11 @@
       checkSubmitPlan({
         orderId: this.orderId,
         laboratory: this.sonLaboratory,
-        reportType: this.reportType,
       }).then((res) => {
         if (res.code === 200) {
           if (!res.data || res.data.errorMsg.length == 0) {
             this.submitLoading = true;
-            //妫�楠岀被鍨嬩负鍘熸潗鏂�
-            if(this.reportType === 1 && 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(true)
-            }
+            this.confirmSubmit();
           } else {
             let newData = [];
             const h = this.$createElement;
@@ -2320,7 +2324,7 @@
             })
               .then(() => {
                 this.submitLoading = true;
-                this.confirmSubmit(false)
+                this.confirmSubmit()
                 // submitPlan({
                 //   orderId: this.orderId,
                 //   laboratory: this.sonLaboratory,
@@ -2353,7 +2357,17 @@
       const param = {};
       this.tableList.forEach((a) => {
         param[a.templateId] = {};
-        a.template.forEach((cell) => {
+        // Worker 鍥炰紶鍚� arr 鏄〉闈笂鐨勬渶鏂板璞★紝template 浠嶅彲鑳戒繚鐣欒绠楀墠鐨勬棫鍊笺��
+        const cells = a.arr && a.arr.length
+          ? a.arr.reduce((all, row) => all.concat(row), [])
+          : a.template;
+        const resultHeader = cells.find((cell) =>
+          cell.v && String(cell.v.v || "").trim() === "妫�楠岀粨鏋�"
+        );
+        const exportRows = new Set(cells.filter((cell) =>
+          cell.v && cell.v.ps && cell.v.ps.value === "瀵煎嚭鍊�"
+        ).map((cell) => cell.r));
+        cells.forEach((cell) => {
           const isEditable =
             cell.v.ps != undefined &&
             typeof cell.v.ps.value === "string" &&
@@ -2361,10 +2375,12 @@
               cell.v.ps.value === "璁$畻鍊�" ||
               cell.v.ps.value === "鏈�缁堝��" ||
               cell.v.ps.value === "璁惧鍚嶇О");
-          if (!isEditable) {
+          const isExportResult = resultHeader && exportRows.has(cell.r) && cell.c === resultHeader.c;
+          if (!isEditable && !isExportResult) {
             return;
           }
           if (
+            isEditable &&
             cell.v.ps.value.includes("妫�楠屽��") &&
             (cell.v.v === "" || cell.v.v === null || cell.v.v === undefined)
           ) {
@@ -2410,7 +2426,14 @@
         const previousSave = this.saveQueue || Promise.resolve();
         this.saveQueue = previousSave
           .catch(() => undefined)
-          .then(() => saveInsContext(payload))
+          .then(() => this.isDirectTemplateOrder()
+            ? saveTemplateContext({
+                orderId: this.orderId,
+                sampleId: this.currentSample.id,
+                templateId: this.currentTable,
+                values: param[this.currentTable] || {},
+              })
+            : saveInsContext(payload))
           .then(() => {
             this.$message.success("宸蹭繚瀛�");
           })
@@ -2433,6 +2456,20 @@
       }
     },
     async waitForPendingSaves() {
+      const targetRevision = this.calculationRevision;
+      if (this.completedCalculationRevision < targetRevision) {
+        await new Promise((resolve) => {
+          const startedAt = Date.now();
+          const waitWorker = () => {
+            if (this.completedCalculationRevision >= targetRevision || Date.now() - startedAt > 5000) {
+              resolve();
+              return;
+            }
+            setTimeout(waitWorker, 20);
+          };
+          waitWorker();
+        });
+      }
       if (this.saveQueue) {
         await this.saveQueue;
       }
@@ -2458,6 +2495,23 @@
       // 閫夋嫨銆佺Щ闄ゃ�佹竻绌哄潎鐢� change 浜嬩欢瑙﹀彂锛岀珛鍗充繚瀛樸��
       this.saveInsContext();
     },
+    isDirectTemplateOrder() {
+      return this.sonLaboratory === "鏂拌仛" && this.currentSample &&
+        (this.currentSample.insProduct || []).some((product) => product.templateRowIndex != null);
+    },
+    loadOverviewDevices() {
+      Promise.all([search({ status: 0 }), getOrderDevices({ orderId: this.orderId })]).then(([devices, selected]) => {
+        this.orderDeviceOptions = (devices.data || []).map((device) => ({
+          id: device.id,
+          label: `${device.deviceName}--${device.managementNumber}`,
+        }));
+        this.selectedDeviceIds = selected.data || [];
+      });
+    },
+    saveOverviewDevices() {
+      return saveOrderDevices({ orderId: this.orderId, deviceIds: this.selectedDeviceIds })
+        .then(() => this.$message.success("璁惧宸蹭繚瀛�"));
+    },
     getAuthorizedPerson() {
       selectUserCondition({ type: 1 }).then((res) => {
         let data = [];

--
Gitblit v1.9.3