From 049fda473cc178917a02f3a174dfd08a84b0cb8d Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 17 九月 2026 10:52:28 +0800
Subject: [PATCH] 新疆——新聚lims 1.每个检验项都要有一个选择检测时间的地方,跟温湿度放在一起,还有检测地点,设备也要单独绑定检验项,最后导出模版再总结到一起 2.产品名称改为检测依据、加一个样品名称手输 3.下单时原始记录模板可以从标准库绑定的模板进行删减

---
 src/views/business/productOrder/components/addOrder.vue |  270 ++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 194 insertions(+), 76 deletions(-)

diff --git a/src/views/business/productOrder/components/addOrder.vue b/src/views/business/productOrder/components/addOrder.vue
index 975f4ea..22f6a4c 100644
--- a/src/views/business/productOrder/components/addOrder.vue
+++ b/src/views/business/productOrder/components/addOrder.vue
@@ -1,48 +1,76 @@
 <template>
   <div class="app-container">
-    <div v-show="!cableConfigShow&&!auxiliaryShow">
-      <div style="display: flex;justify-content: space-between;align-items:center;">
-        <div>濮旀墭鍗曚俊鎭�</div>
-        <div>
-          <el-cascader
-            v-model="addObj.quarterItemId"
-            :disabled="active>1"
-            :options="quarterItemOptions"
-            size="small"
-            style="width: 380px"
-            @focus="getQuarterOnOrderList"></el-cascader>
-          <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">
-              <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">
-            <span style="color: #3A7BFA;">淇濆瓨妯℃澘</span>
-          </el-button>
-          <el-button v-if="active==1&&addObj.sampleType!=undefined&&(addObj.sampleType.indexOf('鐢电紗')>-1 ||addObj.sampleType.indexOf('缁煎悎')>-1)" size="small" type="primary" @click="openCableConfig">鐢电紗閰嶇疆</el-button>
-          <el-button v-if="active==1&&addObj.sampleType!=undefined&&addObj.sampleType.indexOf('鐢电紗')>-1" size="small" type="primary" @click="openAuxiliaryCore">杈呭姪绾胯姱閰嶇疆</el-button>
-          <el-button v-show="active==1||(tabIndex==4&&active==2)" :loading="saveLoad" size="small" type="primary" @click="save">鎻愪氦</el-button>
-          <!-- 瀹℃牳 -->
-          <el-button v-show="active==3" :disabled="saveLoad" :loading="saveLoad" size="small"
-                     @click="upInsOrderOfState(2)">涓嶉�氳繃</el-button>
-          <el-button v-show="active==3" :loading="saveLoad" size="small" type="primary"
-                     @click="upInsOrderOfState(1)">閫氳繃</el-button>
-          <el-button size="small" @click="goBack">
-            <span style="color: #3A7BFA;">杩斿洖</span>
-          </el-button>
-        </div>
+    <div v-show="!cableConfigShow&&!auxiliaryShow" class="order-header">
+      <span class="order-header__title">濮旀墭鍗曚俊鎭�</span>
+      <div class="order-header__actions">
+<!--        <el-cascader-->
+<!--          v-model="addObj.quarterItemId"-->
+<!--          :disabled="active>1"-->
+<!--          :options="quarterItemOptions"-->
+<!--          placeholder="璇烽�夋嫨瀛e害"-->
+<!--          size="small"-->
+<!--          class="order-header__quarter"-->
+<!--          @focus="getQuarterOnOrderList"></el-cascader>-->
+        <el-select v-show="active==1" v-model="template" placeholder="涓嬪崟妯℃澘" size="small"
+                   class="order-header__template"
+                   @change="selectInsOrderTemplateById">
+          <el-option v-for="(a, ai) in templates" :key="ai" :label="a.name" :value="a.id">
+            <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">淇濆瓨妯℃澘</el-button>
+        <el-button v-if="active==1&&addObj.sampleType!=undefined&&(addObj.sampleType.indexOf('鐢电紗')>-1 ||addObj.sampleType.indexOf('缁煎悎')>-1)" size="small" type="primary" plain @click="openCableConfig">鐢电紗閰嶇疆</el-button>
+        <el-button v-if="active==1&&addObj.sampleType!=undefined&&addObj.sampleType.indexOf('鐢电紗')>-1" size="small" type="primary" plain @click="openAuxiliaryCore">杈呭姪绾胯姱閰嶇疆</el-button>
+        <el-button v-show="active==1||(tabIndex==4&&active==2)" :loading="saveLoad" size="small" type="primary" @click="save">鎻愪氦</el-button>
+        <!-- 瀹℃牳 -->
+        <el-button v-show="active==3" :disabled="saveLoad" :loading="saveLoad" size="small"
+                   @click="upInsOrderOfState(2)">涓嶉�氳繃</el-button>
+        <el-button v-show="active==3" :loading="saveLoad" size="small" type="primary"
+                   @click="upInsOrderOfState(1)">閫氳繃</el-button>
+        <el-button size="small" @click="goBack">杩斿洖</el-button>
       </div>
     </div>
-    <div v-show="!cableConfigShow&&!auxiliaryShow" style="margin-top: 10px">
-      <div class="search">
-        <el-form ref="addObj" :inline="true" :model="addObj" :rules="addObjRules" label-width="108px" label-position="right">
+    <div v-show="!cableConfigShow&&!auxiliaryShow" class="order-body">
+      <el-card shadow="never" class="order-card">
+        <el-form ref="newJuOrder" :model="addObj" size="small" label-width="108px" label-position="right">
+          <el-row :gutter="16">
+            <el-col :span="6"><el-form-item label="妫�娴嬩緷鎹�"><el-input v-model="addObj.sample" disabled size="small"><template slot="append"><el-button :disabled="active>1" icon="el-icon-search" @click="selectStandardTree = true" /></template></el-input></el-form-item></el-col>
+            <el-col :span="18">
+              <el-form-item label="鍘熷璁板綍妯℃澘">
+                <div v-loading="templateBindingLoading" class="template-tag-list">
+                  <el-tag v-for="(item, index) in boundTemplateList" :key="item.templateId" :closable="active==1" size="small" effect="plain" @close="removeBoundTemplate(index)">{{ item.name }}</el-tag>
+                  <span v-if="!templateBindingLoading && boundTemplateList.length === 0" class="empty-template-text">鏆傛湭缁戝畾鍘熷璁板綍妯℃澘</span>
+                </div>
+              </el-form-item>
+            </el-col>
+          </el-row>
+          <el-row :gutter="16">
+            <el-col :span="6"><el-form-item label="鏍峰搧鍚嶇О"><el-input v-model="addObj.sampleView" :disabled="active>1" size="small" /></el-form-item></el-col>
+            <el-col :span="6"><el-form-item label="鐢熶骇鍗曚綅"><el-input v-model="addObj.production" :disabled="active>1" size="small" /></el-form-item></el-col>
+            <el-col :span="6"><el-form-item label="濮旀墭鍗曚綅"><el-input v-model="addObj.company" disabled size="small"><template slot="append"><el-button :disabled="active>1" icon="el-icon-search" @click="openCompanyList" /></template></el-input></el-form-item></el-col>
+            <el-col :span="6"><el-form-item label="妫�楠岀被鍒�"><el-select v-model="addObj.orderType" :disabled="active>1" size="small"><el-option v-for="item in dict.type.check_type1" :key="item.value" :label="item.label" :value="item.value" /></el-select></el-form-item></el-col>
+          </el-row>
+          <el-row :gutter="16">
+            <el-col :span="6"><el-form-item label="鏍峰搧鏁伴噺"><el-input v-model="addObj.testQuantity" :disabled="active>1" placeholder="濡傦細2妗躲��500mL" size="small" /></el-form-item></el-col>
+            <el-col :span="6"><el-form-item label="鏍峰搧缂栧彿"><el-input v-model="sampleCode" :disabled="active>1" size="small" /></el-form-item></el-col>
+            <el-col :span="6"><el-form-item label="鏍峰搧澶栬"><el-input v-model="addObj.sampleStatus" :disabled="active>1" size="small" /></el-form-item></el-col>
+            <el-col :span="6"><el-form-item label="閫佹牱浜�"><el-input v-model="addObj.prepareUser" :disabled="active>1" size="small" /></el-form-item></el-col>
+          </el-row>
+          <el-row :gutter="16">
+            <el-col :span="6"><el-form-item label="鐢熶骇鏃ユ湡"><el-date-picker v-model="addObj.productionDate" type="date" value-format="yyyy-MM-dd" :disabled="active>1" size="small" /></el-form-item></el-col>
+            <el-col :span="6"><el-form-item label="鐢熶骇鎵瑰彿"><el-input v-model="addObj.productionBatch" :disabled="active>1" size="small" /></el-form-item></el-col>
+            <el-col :span="6"><el-form-item label="閫佹牱鏃ユ湡"><el-date-picker v-model="addObj.sampleDate" type="date" value-format="yyyy-MM-dd" :disabled="active>1" size="small" /></el-form-item></el-col>
+            <el-col :span="6"><el-form-item label="鑱旂郴鏂瑰紡"><el-input v-model="addObj.phone" :disabled="active>1" size="small" /></el-form-item></el-col>
+          </el-row>
+          <el-row :gutter="16"><el-col :span="12"><el-form-item label="澶囨敞"><el-input v-model="addObj.remark" :disabled="active>1" size="small" /></el-form-item></el-col></el-row>
+        </el-form>
+        <el-form v-if="false" ref="addObj" :inline="true" :model="addObj" :rules="addObjRules" label-width="108px" label-position="right">
           <el-row>
             <el-col :span="6">
               <el-form-item label="濮旀墭缂栧彿:" prop="entrustCode">
@@ -204,8 +232,8 @@
             </el-col>
           </el-row>
         </el-form>
-      </div>
-      <div>
+      </el-card>
+      <div v-if="false">
         <div style="display: flex;justify-content: space-between;background-color: #F5F7FB;margin-bottom: 6px">
           <div v-if="active==1">
             <el-form :inline="true" :model="addObj1" label-width="90px">
@@ -427,7 +455,7 @@
               <el-col :span="24">
                 <span><i
                     :class="`node_i ${data.children != undefined ? (data.code==='[1]'?'el-icon-folder-opened':'el-icon-folder') : 'el-icon-tickets'}`"></i>
-                  {{ data.code }} {{ data.label }}</span>
+                  {{ data.label }}</span>
               </el-col>
             </el-row>
           </div>
@@ -606,7 +634,7 @@
   upInsOrderOfState
 } from "@/api/business/add";
 import {selectUserCondition} from "@/api/performance/class";
-import {selectsStandardMethodByFLSSM} from "@/api/standard/standardLibrary";
+import {selectTemplateBindings, selectsStandardMethodByFLSSM} from "@/api/standard/standardLibrary";
 import limsTable from "@/components/Table/lims-table.vue";
 import {selectCustomPageList} from "@/api/system/customer";
 import {mapGetters} from "vuex";
@@ -615,7 +643,6 @@
 import {
   isLeafPath,
   buildSelectTree,
-  deriveTreeFields,
   dropLastLabel,
 } from "@/utils/standardTree";
 
@@ -644,6 +671,9 @@
       active: '',
       tabIndex: '',
       currentId: '',
+      sampleCode: '',
+      boundTemplateList: [],
+      templateBindingLoading: false,
       sampleSelectionList: [],//鏍峰搧琛ㄦ牸閫変腑鏁版嵁
       editTable:[],
       template: null,
@@ -672,7 +702,7 @@
         orderType: null,
         send: 1,
         formType: '閫佹', //  鏉ユ牱鏂瑰紡
-        sampleStatus: 'In good condition', // 鏍峰搧鐘舵��
+        sampleStatus: '', // 鏍峰搧鐘舵��
         testQuantity: '', // 鏍峰搧鐘舵��
         production: null,
         productionEn: null,
@@ -698,7 +728,7 @@
           { required: true, message: '璇烽�夋嫨绱ф�ョ▼搴�', trigger: 'change' }
         ],
         sample: [
-          { required: true, message: '璇烽�夋嫨鏍峰搧鍚嶇О', trigger: 'change' }
+          { required: true, message: '璇烽�夋嫨妫�娴嬩緷鎹�', trigger: 'change' }
         ],
         sampleNum: [
           { required: true, message: '璇峰~鍐欐牱鍝佹暟閲�', trigger: 'blur' }
@@ -927,6 +957,8 @@
           };
           this.addObj.type = String(this.addObj.type)
           const samples = this.HaveJson(res.data.sampleProduct)
+          this.sampleCode = samples.length ? samples[0].sampleCode || '' : ''
+          this.boundTemplateList = this.sortTemplateList(res.data.templateList)
           const loadSamples = this.canSelectProduct
             ? Promise.all(samples.map(sample => this.loadSelectableProducts(sample)))
             : Promise.resolve(samples)
@@ -1157,6 +1189,14 @@
         return str.replaceAll(find, value);
       },
       save() {
+        if (this.addObj.standardTreeId) {
+          if (!this.addObj.sample || !this.addObj.company || !this.addObj.orderType || !this.addObj.testQuantity) {
+            this.$message.error('璇峰~鍐欐娴嬩緷鎹�佸鎵樺崟浣嶃�佹楠岀被鍒拰鏍峰搧鏁伴噺');
+            return;
+          }
+          this.saveData([]);
+          return;
+        }
         this.$refs['addObj'].validate((valid) => {
           if (valid) {
             this.sampleList.forEach(item => {
@@ -1337,6 +1377,10 @@
         }
       },
       saveMethod(sampleList){
+        if (this.addObj.standardTreeId) {
+          this.saveData([]);
+          return;
+        }
         if (this.addObj.quarterItemId) {
           this.addObj.quarterItemId = this.addObj.quarterItemId[1]
         }
@@ -1383,7 +1427,18 @@
         })
       }else{
         // 甯歌鎻愪氦
-        addInsOrder({insOrder: {...this.addObj,typeSource:-1}, sampleList: sampleList}).then(res => {
+        const newJuOrder = {...this.addObj,typeSource:-1}
+        delete newJuOrder.temperature
+        delete newJuOrder.humidity
+        const payload = this.addObj.standardTreeId
+          ? {
+              insOrder: newJuOrder,
+              standardTreeId: this.addObj.standardTreeId,
+              sampleCode: this.sampleCode,
+              templateList: this.boundTemplateList.map((item, index) => ({ templateId: item.templateId, sort: index }))
+            }
+          : { insOrder: {...this.addObj,typeSource:-1}, sampleList: sampleList }
+        addInsOrder(payload).then(res => {
           this.saveLoad = false
           this.$message.success('宸叉彁浜�')
           this.bsm3Dia = false;
@@ -1512,38 +1567,34 @@
         return data.label.indexOf(value) !== -1;
       },
       activeStandardTree() {
-        const fields = deriveTreeFields(this.selectTreeNode)
-        if (fields.labels.length < 2) {
-          this.$message.error('鏈�夋嫨瀵硅薄')
+        if (!this.selectTreeNode || this.selectTreeNode.data.code !== '[2]') {
+          this.$message.error('璇烽�夋嫨浜岀骇浜у搧')
           return
         }
-        this.addObj.factory = fields.factory
-        this.addObj.laboratory = fields.laboratory
-        this.addObj.sampleType = fields.sampleType
-        this.addObj.sample = fields.sample || fields.sampleType
-        this.addObj.sampleView = this.addObj.sample
-        this.addObj.sampleViewEn = this.sampleViewEn
-        this.addObj.model = fields.model
+        const productName = this.selectTreeNode.data.label
+        this.addObj.sample = productName
+        this.addObj.standardTreeId = this.selectTreeNode.data.id
+        this.loadTemplateBindings(this.addObj.standardTreeId)
         this.selectStandardTree = false
         this.sampleList = []
-        for (var i = 0; i < this.addObj.sampleNum; i++) {
-          this.sample.joinName = null
-          this.sample.joinModel = null
-          this.sample.joinNum = 1
-          this.sample.sample = this.addObj.sample
-          this.sample.model = this.addObj.model
-          this.sample.unit = this.addObj.unit
-          this.sample.standardMethodListId = null
-          this.sample.insProduct = []
-          this.sample.id = this.count
-          this.sample.childSampleList = []
-          this.sample.insulating = null
-          this.sample.sheath = null
-          this.sampleList.push(this.HaveJson(this.sample))
-          this.count++
+      },
+      sortTemplateList(list) {
+        return (list || []).slice().sort((a, b) => (a.sort || 0) - (b.sort || 0))
+      },
+      // 涓嬪崟鏃朵粠鏍囧噯搴撶粦瀹氱殑妯℃澘閲屽垹鍑忥紝鎻愪氦鏃堕殢 templateList 涓�璧蜂笅鍙�
+      removeBoundTemplate(index) {
+        this.boundTemplateList.splice(index, 1)
+      },
+      async loadTemplateBindings(standardTreeId) {
+        this.boundTemplateList = []
+        if (!standardTreeId) return
+        this.templateBindingLoading = true
+        try {
+          const res = await selectTemplateBindings({standardTreeId})
+          this.boundTemplateList = this.sortTemplateList(res.data)
+        } finally {
+          this.templateBindingLoading = false
         }
-        this.$refs.sampleTable.doLayout()
-        // this.selectsStandardMethodByFLSSM()
       },
       // 鐢ㄦ寚瀹氬瀷鍙锋浛鎹㈡爲璺緞鏈锛堟湯娈靛嵆鏍囧噯/鍨嬪彿锛�
       buildFactoryPath(model) {
@@ -2334,4 +2385,71 @@
   color: orange;
   font-size: 18px;
 }
+.template-tag-list {
+  min-height: 32px;
+  display: flex;
+  align-items: center;
+  flex-wrap: wrap;
+  gap: 8px;
+}
+.empty-template-text {
+  color: #909399;
+}
+/* 濮旀墭鍗曚俊鎭細椤堕儴鎿嶄綔鏍� */
+.order-header {
+  display: flex;
+  align-items: center;
+  justify-content: space-between;
+  flex-wrap: wrap;
+  gap: 8px;
+  padding-bottom: 12px;
+  border-bottom: 1px solid #ebeef5;
+}
+.order-header__title {
+  font-size: 16px;
+  font-weight: bold;
+  color: #303133;
+}
+.order-header__actions {
+  display: flex;
+  align-items: center;
+  flex-wrap: wrap;
+  gap: 8px;
+}
+/* 闂磋窛缁熶竴浜ょ粰 gap锛屽幓鎺夌浉閭绘寜閽嚜甯︾殑 margin-left */
+.order-header__actions>>>.el-button+.el-button {
+  margin-left: 0;
+}
+.order-header__quarter {
+  width: 220px;
+}
+.order-header__template {
+  width: 160px;
+}
+/* 濮旀墭鍗曚俊鎭細琛ㄥ崟鍗$墖 */
+.order-body {
+  margin-top: 12px;
+}
+.order-card>>>.el-card__body {
+  padding: 20px 20px 6px;
+}
+.order-card>>>.el-form-item {
+  margin-bottom: 16px;
+}
+/* 鎺т欢缁熶竴鍗犳弧鏍囩涔嬪鐨勬暣鍒楀搴︼細el-date-editor 榛樿鍐欐 220px銆�
+   el-select 瀹藉害鏀剁缉鎴愬浐鏈夊搴︼紝涓嶆寚瀹氬氨浼氬拰鍏朵粬杈撳叆妗嗗乏鍙宠竟缂樺涓嶉綈 */
+.order-card>>>.el-input,
+.order-card>>>.el-select {
+  width: 100%;
+}
+/* append 鍗曞厓鏍肩殑 20px 鍐呰竟璺� + 鎸夐挳 -10px 璐熻竟璺濇槸鎸夐粯璁� 40px 鎸夐挳鏍囧畾鐨勶紝
+   small 杈撳叆涓嬫寜閽細姣旇緭鍏ユ楂樸�佷笂涓嬫孩鍑猴紱鏀规垚鎸夐挳鐩存帴鎾戞弧鍗曞厓鏍� */
+.order-card>>>.el-input-group__append {
+  padding: 0;
+}
+.order-card>>>.el-input-group__append .el-button {
+  margin: 0;
+  padding: 9px 15px;
+  font-size: 12px;
+}
 </style>

--
Gitblit v1.9.3