From ea7c19b7bfd7a5260fa321579e6941f28ef2eb46 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 27 八月 2026 11:36:30 +0800
Subject: [PATCH] fix(order): 解决实验室字段必填验证和数据源问题

---
 src/views/business/productOrder/components/addOrder.vue |  167 ++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 121 insertions(+), 46 deletions(-)

diff --git a/src/views/business/productOrder/components/addOrder.vue b/src/views/business/productOrder/components/addOrder.vue
index 6e69cbb..67b582d 100644
--- a/src/views/business/productOrder/components/addOrder.vue
+++ b/src/views/business/productOrder/components/addOrder.vue
@@ -14,9 +14,13 @@
           <el-select v-show="active==1" v-model="template" placeholder="涓嬪崟妯℃澘" size="small"
                      @change="selectInsOrderTemplateById">
             <el-option v-for="(a, ai) in templates" :key="ai" :label="a.name" :value="a.id">
-              <span style="float: left">{{ a.name }}</span>
-              <i class="el-icon-delete" style="float: right; color: #66b1ff; font-size: 16px"
-                 @click.stop="handleDelete(a)"></i>
+              <div style="display: flex; align-items: center; justify-content: space-between;">
+                <span>{{ a.name }}</span>
+                <i class="el-icon-delete"
+                   style="color: #66b1ff; font-size: 16px; cursor: pointer;"
+                   @click.stop="handleDelete(a)">
+                </i>
+              </div>
             </el-option>
           </el-select>
           <el-button v-show="active==1" size="small" @click="templateDia=true">
@@ -459,10 +463,10 @@
             </div>
           </el-col>
           <el-col v-if="distributeData.userId" :span="22" class="search_thing">
-            <div class="search_label"><span class="required-span">* </span>璇曢獙瀹わ細</div>
+            <div class="search_label">璇曢獙瀹わ細</div>
             <div class="search_input">
               <el-select v-model="distributeData.sonLaboratory" filterable placeholder="璇烽�夋嫨" size="small" style="width: 100%;">
-                <el-option v-for="item in sonLaboratoryList" :key="item.value" :label="item.label" :value="item.value">
+                <el-option v-for="item in newJuLaboratoryList" :key="item.value" :label="item.label" :value="item.value">
                 </el-option>
               </el-select>
             </div>
@@ -587,7 +591,7 @@
 } from "@/api/business/rawMaterialOrder";
 import {
   addInsOrder, addInsOrderTemplate, delInsOrderTemplate,
-  getQuarterOnOrder, selectInsOrderTemplateById,
+  getQuarterOnOrder, judgeNotSpotCheckOrder, selectInsOrderTemplateById,
   selectOrderManDay,
   updateInsOrder,
   upInsOrder,
@@ -598,6 +602,8 @@
 import limsTable from "@/components/Table/lims-table.vue";
 import {selectCustomPageList} from "@/api/system/customer";
 import {mapGetters} from "vuex";
+import { bigEval } from "@/utils/bigEval";
+import {addQuarter, updateQuarterOnOrder} from "@/api/business/finishedProductSampling";
 
 export default {
   name: 'AddOrder',
@@ -608,8 +614,11 @@
   },
   computed:{
     ...mapGetters(["nickName", 'nameEn', 'userName']),
+    newJuLaboratoryList() {
+      return (this.dict.type.sys_sub_lab || []).filter(item => item.label === '鏂拌仛')
+    },
   },
-  dicts: ['check_type1', 'urgency_level', 'form_type', 'sample_status_list'],
+  dicts: ['check_type1', 'urgency_level', 'form_type', 'sample_status_list', 'sys_sub_lab'],
   data() {
     return {
       active: '',
@@ -793,10 +802,10 @@
     }
   },
   watch: {
-    sampleList() {
-      this.addObj.method = null
-      this.productList = []
-    },
+    // sampleList() {
+    //   this.addObj.method = null
+    //   this.productList = []
+    // },
     productList: {
       deep: true,
       handler(val) {
@@ -855,6 +864,37 @@
     this.getInfo();
   },
   methods: {
+    /**
+     * 鑾峰彇灏忔暟鐨勬渶澶т綅鏁�
+     * @param number  鍨嬪彿鍙傛暟
+     * @param ask     瑕佹眰鍊�
+     * @param calcNum 璁$畻鍊�
+     */
+    getDecimalPlaces(number, ask, calcNum) {
+      console.log("璁$畻灏忔暟鐐�-->", number, ask, calcNum);
+      let count1 = 0;
+      let count2 = 0;
+      const reg = /(\d+\.)(\d+)/g;
+      let matches = [];
+      if (ask) {
+        matches = ask.match(reg);
+      }
+      if (
+        matches &&
+        matches.length > 0 &&
+        matches[0].toString().indexOf(".") > -1
+      ) {
+        count1 = matches[0].toString().split(".")[1].length;
+      }
+      if (number.toString().indexOf(".") > -1) {
+        count2 = number.toString().split(".")[1].length;
+      }
+      if (calcNum.toString().indexOf(".") > -1) {
+        const pointLength2 = calcNum.toString().split(".")[1].length;
+        count2 = count2 > pointLength2 ? count2 : pointLength2;
+      }
+      return count1 > count2 ? count1 : count2;
+    },
     getInfo() {
       this.selectStandardTreeList()
       this.getAuthorizedPerson();
@@ -1040,7 +1080,13 @@
               let index = code.findIndex(b => m.includes(b))
               if (index > -1) {
                 let arr = m.split(code[index]).filter(b => !!b)
-                let num = eval(this.replaceAll(arr[0], symbolItem, value))
+                let calcNum = this.$Big(
+                  bigEval(this.replaceAll(arr[0], symbolItem, value))
+                );
+                let num = calcNum.toFixed(
+                  this.getDecimalPlaces(value, ask, calcNum)
+                );
+                // let num = eval(this.replaceAll(arr[0], symbolItem, value))
                 m = code[index] + '' + num
                 arr1.push(m)
               }
@@ -1069,7 +1115,13 @@
             let index = code.findIndex(b => ask.includes(b))
             if (index > -1) {
               let arr = ask.split(code[index]).filter(b => !!b)
-              let num = eval(this.replaceAll(arr[0], symbolItem, value))
+              let calcNum = this.$Big(
+                bigEval(this.replaceAll(arr[0], symbolItem, value))
+              );
+              let num = calcNum.toFixed(
+                this.getDecimalPlaces(value, ask, calcNum)
+              );
+              // let num = eval(this.replaceAll(arr[0], symbolItem, value))
               return code[index] + '' + num
             }
           }
@@ -1255,36 +1307,62 @@
         }
       },
       saveMethod(sampleList){
-        this.saveLoad = true
         if (this.addObj.quarterItemId) {
           this.addObj.quarterItemId = this.addObj.quarterItemId[1]
         }
-        if(this.tabIndex==4&&this.active==2){
-          if (this.addObj.createTime) {
-            delete this.addObj.createTime
-          }
-          // 閫�鍥炲悗鎻愪氦
-          updateInsOrder({insOrder: this.addObj, sampleProduct: sampleList}).then(res => {
-            this.saveLoad = false
-            this.$message.success('宸叉彁浜�')
-            this.bsm3Dia = false;
-            this.closeOpenPage()
-          }).catch(e=>{
-            this.saveLoad = false
-          })
-        }else{
-          // 甯歌鎻愪氦
-          addInsOrder({insOrder: this.addObj, sampleList: sampleList}).then(res => {
-            this.saveLoad = false
-            this.$message.success('宸叉彁浜�')
-            this.bsm3Dia = false;
-            this.closeOpenPage()
-          }).catch(e=>{
-            this.saveLoad = false
-          })
+        if (this.addObj.createTime) {
+          delete this.addObj.createTime
         }
-
+        if (this.addObj.orderType === '鎶芥') {
+          judgeNotSpotCheckOrder({ insOrder: this.addObj, sampleList: sampleList }).then(res => {
+            if (res.data === true) {
+              this.saveData(sampleList);
+            } else {
+              // const message = res.message.replace(/\n/g, '<br>');
+              this.$confirm(res.message, '鎻愮ず', {
+                confirmButtonText: '纭畾',
+                cancelButtonText: '鍙栨秷',
+                type: 'warning',
+                dangerouslyUseHTMLString: true, // 馃憟 鍏抽敭鐐癸細鍏佽 HTML
+                message: res.message // 杩欓噷涔熷彲浠ョ渷鐣ワ紝鍥犱负绗簩涓弬鏁版槸 title锛岀涓変釜鏄� options
+              }).then(() => {
+                this.saveData(sampleList);
+              }).catch(() => {
+                this.$message({
+                  type: 'info',
+                  message: '宸插彇娑�'
+                });
+              });
+            }
+          });
+        } else {
+          this.saveData(sampleList)
+        }
       },
+    saveData(sampleList) {
+      this.saveLoad = true
+      if(this.tabIndex==4&&this.active==2){
+        // 閫�鍥炲悗鎻愪氦
+        updateInsOrder({insOrder: this.addObj, sampleProduct: sampleList}).then(res => {
+          this.saveLoad = false
+          this.$message.success('宸叉彁浜�')
+          this.bsm3Dia = false;
+          this.closeOpenPage()
+        }).catch(e=>{
+          this.saveLoad = false
+        })
+      }else{
+        // 甯歌鎻愪氦
+        addInsOrder({insOrder: {...this.addObj,typeSource:-1}, sampleList: sampleList}).then(res => {
+          this.saveLoad = false
+          this.$message.success('宸叉彁浜�')
+          this.bsm3Dia = false;
+          this.closeOpenPage()
+        }).catch(e=>{
+          this.saveLoad = false
+        })
+      }
+    },
       upInsOrderOfState(state) {
         if (state == 1) {
           this.saveLoad = true
@@ -1304,6 +1382,7 @@
               this.distributeData.appointed = ress.data
             })
             setTimeout(() => {
+              this.distributeData.sonLaboratory = this.newJuLaboratoryList.length > 0 ? this.newJuLaboratoryList[0].value : ''
               this.issuedDialogVisible = true;
             }, 1000)
           })
@@ -1320,10 +1399,6 @@
         }
         if (this.distributeData.userId == null || this.distributeData.userId == '') {
           this.$message.error('鎸囨淳浜哄憳鏈~鍐�')
-          return
-        }
-        if (this.distributeData.userId&&(this.distributeData.sonLaboratory== null ||this.distributeData.sonLaboratory== '')) {
-          this.$message.error('璇曢獙瀹ゆ湭濉啓')
           return
         }
         this.upLoad = true;
@@ -1355,8 +1430,8 @@
           this.addObj.code = selects.code
           this.addObj.phone = selects.phone
           this.addObj.companyId = selects.departId
-          this.addObj.production = '涓ぉ绉戞妧瑁呭鐢电紗鏈夐檺鍏徃'
-          this.addObj.productionEn = 'Zhongtian Technology Industrial Wire&Cable System CO.,LTD'
+          this.addObj.production = ''
+          this.addObj.productionEn = ''
           if(this.active==1){
             this.selectInsOrderTemplate()
           }
@@ -2149,8 +2224,8 @@
         })
       },
       changeUser(){
-        if(this.sonLaboratoryList.length>0){
-          this.distributeData.sonLaboratory = this.sonLaboratoryList[0].value
+        if(this.newJuLaboratoryList.length>0){
+          this.distributeData.sonLaboratory = this.newJuLaboratoryList[0].value
         }
       },
       addProductList(productList,row,index){

--
Gitblit v1.9.3