From 6f2e5c16bdefdf7129809ae303aa5e66b74cd2f7 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 24 九月 2026 09:20:22 +0800
Subject: [PATCH] feat(order): 添加检验委托单关联功能

---
 src/views/business/productOrder/components/addOrder.vue |  160 +++++++++++++++
 src/api/cnas/process/demand/demand.js                   |   28 ++
 package.json                                            |    4 
 src/views/CNAS/process/demand/index.vue                 |  350 ++++++++++++++++++++++++----------
 4 files changed, 422 insertions(+), 120 deletions(-)

diff --git a/package.json b/package.json
index 3deefe9..cda47dc 100644
--- a/package.json
+++ b/package.json
@@ -49,14 +49,16 @@
     "echarts": "5.4.0",
     "element-resize-detector": "^1.2.4",
     "element-ui": "2.15.14",
+    "fast-png": "^5.0.0",
     "file-saver": "2.0.5",
     "fuse.js": "6.4.3",
     "highlight.js": "9.18.5",
     "html2canvas": "^1.4.1",
+    "iobuffer": "^5.0.0",
     "js-beautify": "1.13.0",
     "js-cookie": "3.0.1",
     "jsencrypt": "3.0.0-rc.1",
-    "jspdf": "^3.0.0",
+    "jspdf": "^2.5.0",
     "mammoth": "^1.9.0",
     "moment": "^2.30.1",
     "nprogress": "0.2.0",
diff --git a/src/api/cnas/process/demand/demand.js b/src/api/cnas/process/demand/demand.js
index 8f59c49..6d2a6b0 100644
--- a/src/api/cnas/process/demand/demand.js
+++ b/src/api/cnas/process/demand/demand.js
@@ -13,10 +13,10 @@
     params: query
   })
 }
-// 濮旀墭鍗曟煡璇㈡垚鍝佽鍗�
-export function getInsOrderOnInspection(query) {
+// 鏌ヨ鏈粦瀹氭楠屽鎵樺崟锛堜緵鎴愬搧涓嬪崟閫夋嫨锛�
+export function pageUnboundInspectionOrder(query) {
   return request({
-    url: '/inspectionOrder/getInsOrderOnInspection',
+    url: '/inspectionOrder/pageUnboundInspectionOrder',
     method: 'get',
     params: query
   })
@@ -37,14 +37,30 @@
     data: query
   })
 }
-// 鏂板鏃舵牴鎹垚鍝佽鍗曟煡璇㈠鎵樺崟璇︽儏
-export function getInspectionOrderByInsOderId(query) {
+// 鏍规嵁妫�楠屽鎵樺崟鑾峰彇鎴愬搧涓嬪崟鍒濆鍖栦俊鎭�
+export function getInspectionOrderForPlaceOrder(query) {
   return request({
-    url: '/inspectionOrder/getInspectionOrderByInsOderId',
+    url: '/inspectionOrder/getInspectionOrderForPlaceOrder',
     method: 'get',
     params: query
   })
 }
+// 鏂板鎴愬搧涓嬪崟骞剁粦瀹氭楠屽鎵樺崟
+export function addInsOrderWithInspectionOrder(query) {
+  return request({
+    url: '/inspectionOrder/addInsOrderWithInspectionOrder',
+    method: 'post',
+    data: query
+  })
+}
+// 鍙樻洿妫�楠屽鎵樺崟鍏宠仈
+export function changeInspectionOrderBinding(query) {
+  return request({
+    url: '/inspectionOrder/changeBinding',
+    method: 'post',
+    params: query
+  })
+}
 // 濮旀墭鍗曟楠屾煡鐪嬭鎯�
 export function getInspectionOrderOne(query) {
   return request({
diff --git a/src/views/CNAS/process/demand/index.vue b/src/views/CNAS/process/demand/index.vue
index e77260c..3d17223 100644
--- a/src/views/CNAS/process/demand/index.vue
+++ b/src/views/CNAS/process/demand/index.vue
@@ -2,6 +2,10 @@
   <div class="app-container">
     <div style="display: flex;justify-content: space-between;">
       <el-form :model="entitySearch" ref="entitySearch" size="small" :inline="true">
+        <el-form-item label="濮旀墭鍗曞彿" prop="inspectionOrderCode">
+          <el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="entitySearch.inspectionOrderCode"
+            @keyup.enter.native="refreshTable"></el-input>
+        </el-form-item>
         <el-form-item label="璇曟牱鍚嶇О" prop="sampleName">
           <el-input size="small" placeholder="璇疯緭鍏�" clearable v-model="entitySearch.sampleName"
             @keyup.enter.native="refreshTable"></el-input>
@@ -31,8 +35,26 @@
       <el-table v-loading="tableListLoading" :data="tableList"
                 height="630" border :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }">
         <el-table-column align="center" label="搴忓彿" type="index"></el-table-column>
+        <el-table-column label="濮旀墭鍗曞彿" prop="inspectionOrderCode" min-width="160" show-overflow-tooltip></el-table-column>
         <el-table-column label="璇曟牱鍚嶇О" prop="sampleName" show-overflow-tooltip></el-table-column>
-        <el-table-column label="濮旀墭缂栧彿" prop="entrustCode" show-overflow-tooltip></el-table-column>
+        <el-table-column label="濮旀墭缂栧彿" prop="entrustCode" show-overflow-tooltip>
+          <template slot-scope="scope">{{ scope.row.entrustCode || '寰呯敓鎴�' }}</template>
+        </el-table-column>
+        <el-table-column label="鍏宠仈鐘舵��" min-width="90">
+          <template slot-scope="scope">{{ scope.row.bindingStatus === 1 ? '宸茬粦瀹�' : '鏈粦瀹�' }}</template>
+        </el-table-column>
+        <el-table-column label="涓嬪崟鐘舵��" min-width="90">
+          <template slot-scope="scope">{{ orderStateText(scope.row.orderState) }}</template>
+        </el-table-column>
+        <el-table-column label="妫�楠岃繘搴�" prop="insProgress" min-width="90">
+          <template slot-scope="scope">{{ scope.row.insProgress || '--' }}</template>
+        </el-table-column>
+        <el-table-column label="妫�楠岀粨鏋�" min-width="90">
+          <template slot-scope="scope">{{ insResultText(scope.row.insResult) }}</template>
+        </el-table-column>
+        <el-table-column label="鎶ュ憡鐘舵��" min-width="90">
+          <template slot-scope="scope">{{ reportStatusText(scope.row.reportStatus) }}</template>
+        </el-table-column>
         <el-table-column label="濮旀墭鏃堕棿" prop="commissionDate" show-overflow-tooltip></el-table-column>
         <el-table-column label="鍨嬪彿" prop="modelNo" show-overflow-tooltip></el-table-column>
         <el-table-column label="濮旀墭鍗曚綅" prop="commissionUnit" show-overflow-tooltip></el-table-column>
@@ -52,12 +74,13 @@
             <span v-if="scope.row.processing === 0">濮旀墭鍗曚綅鍙栧洖</span>
           </template>
         </el-table-column>
-        <el-table-column align="center" label="鎿嶄綔" width="240">
+        <el-table-column align="center" label="鎿嶄綔" width="320">
           <template slot-scope="scope">
             <el-button size="mini" type="text" @click="goUpdate(scope.row)">缂栬緫</el-button>
             <el-button size="mini" type="text" @click="handleLook(scope.row)">鏌ョ湅</el-button>
             <el-button size="mini" style="color:#F56C6C" type="text" @click="deleteOrder(scope.row)">鍒犻櫎</el-button>
-            <el-button size="mini" type="text" @click="openDownloadDia(scope.row)">涓嬭浇</el-button>
+            <el-button :disabled="!scope.row.fileUrl" size="mini" type="text" @click="openDownloadDia(scope.row)">涓嬭浇</el-button>
+            <el-button v-if="canChangeBinding(scope.row)" size="mini" type="text" @click="openChangeBinding(scope.row)">鍙樻洿鍏宠仈</el-button>
             <el-upload ref='upload' :action="action" :data="{ inspectionOrderId: scope.row.inspectionOrderId }"
               :headers="uploadHeader" :on-error="onError" :on-success="handleSuccessUp" :show-file-list="false"
               accept='image/jpg,image/jpeg,image/png,application/pdf,.doc,.docx,.xlsx' name="file"
@@ -72,32 +95,6 @@
         @current-change="handleCurrentChange1">
       </el-pagination>
     </div>
-    <el-dialog :close-on-click-modal="false" :close-on-press-escape="false" :visible.sync="orderRowsVisible"
-      title="鏂板妫�楠屼换鍔″崟" width="1000px">
-      <div style="display: flex; align-items: center;margin-bottom: 10px">
-        <span style="width: 80px">濮旀墭缂栧彿锛�</span>
-        <el-input v-model="entity.entrustCode" clearable size="small"
-          style="width: 300px;margin-right: 10px"></el-input>
-        <el-button size="small" type="primary" @click="searchTableData">鏌ヨ</el-button>
-        <el-button size="small" @click="refreshTableData">閲� 缃�</el-button>
-      </div>
-      <el-table v-loading="tableLoading" :data="tableData"
-                :header-cell-style="{ background: '#f8f8f9', color: '#515a6e' }" border
-                height="550" style="width: 100%">
-        <el-table-column align="center" label="搴忓彿" type="index" width="60"></el-table-column>
-        <el-table-column label="濮旀墭缂栧彿" prop="entrustCode"></el-table-column>
-        <el-table-column label="鏍峰搧鍚嶇О" prop="sample"></el-table-column>
-        <el-table-column align="center" label="鎿嶄綔">
-          <template slot-scope="scope">
-            <el-button align="center" size="mini" type="text" @click="goAddOrder(scope.row)">鏂板濮旀墭鍗�</el-button>
-          </template>
-        </el-table-column>
-      </el-table>
-      <el-pagination :current-page="1" :page-size="tableSearch.size" :page-sizes="[10, 20, 30, 50, 100]" :total="total"
-        layout="->,total, sizes, prev, pager, next" style="margin-top: 10px" background @size-change="handleSizeChange"
-        @current-change="handleCurrentChange">
-      </el-pagination>
-    </el-dialog>
     <el-dialog :class="{ downPdf: title == '涓嬭浇' }" :close-on-click-modal="false" :close-on-press-escape="false"
       :modal="title != '涓嬭浇'" :title="title" :visible.sync="detailDialogVisible" top="20px" width="1200px">
       <div style="max-height: 75vh;overflow-y: auto;">
@@ -119,19 +116,19 @@
                 <p>璁板綍缂栧彿锛� ZTT/QR-16-04-a</p>
               </td>
               <td>
-                <p>褰掓。閮ㄩ棬锛氱患鍚堝</p>
+                <p>褰掓。閮ㄩ棬锛氳川閲忛儴</p>
               </td>
             </tr>
           </table>
           <h4 style="display: flex;align-items: center;flex-direction: column;justify-content: center;">
             <span style="font-size: 28px;">妫� 楠� 濮� 鎵� 鍗�</span>
           </h4>
-          <p v-if="operationType !== 'view'" style="margin-left: 560px;display: flex;align-items: center">
-            <span style="width: 100px">濮旀墭缂栧彿锛�</span>
-            <el-input v-model="currentInfo.entrustCode" clearable size="small"></el-input>
+          <p style="margin-left: 560px;display: flex;align-items: center">
+            <span style="width: 100px">濮旀墭鍗曞彿锛�</span>
+            <el-input v-model="currentInfo.inspectionOrderCode" disabled placeholder="淇濆瓨鍚庣郴缁熺敓鎴�" size="small"></el-input>
           </p>
-          <p v-if="operationType === 'view'" style="margin-top: 16px;margin-left: 600px;">濮旀墭缂栧彿锛歿{
-            currentInfo.entrustCode }}
+          <p style="margin-top: 16px;margin-left: 600px;">濮旀墭缂栧彿锛歿{
+            currentInfo.entrustCode || '寰呯敓鎴�' }}
           </p>
           <table border="1" cellpadding="10" class="tables" style="width: 100%">
             <tr>
@@ -162,8 +159,10 @@
               <td>
                 <p>濮旀墭鍗曚綅</p>
               </td>
-              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.commissionUnit" clearable
-                  size="small"></el-input></td>
+              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.commissionUnit" disabled
+                  placeholder="璇烽�夋嫨濮旀墭鍗曚綅" size="small">
+                  <template slot="append"><el-button icon="el-icon-search" @click="openCommissionUnitDialog"></el-button></template>
+                </el-input></td>
               <td v-if="operationType === 'view'">{{ currentInfo.commissionUnit }}</td>
             </tr>
             <tr>
@@ -176,8 +175,10 @@
               <td>
                 <p>濮旀墭浜�</p>
               </td>
-              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.commissionUser" clearable
-                  size="small"></el-input></td>
+              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.commissionUser" disabled
+                  placeholder="璇烽�夋嫨濮旀墭浜�" size="small">
+                  <template slot="append"><el-button icon="el-icon-search" @click="openCommissionUserDialog"></el-button></template>
+                </el-input></td>
               <td v-if="operationType === 'view'">{{ currentInfo.commissionUser }}</td>
             </tr>
             <tr>
@@ -325,8 +326,8 @@
               <td colspan="2">
                 <p>濮旀墭浜鸿仈绯荤數璇�</p>
               </td>
-              <td v-if="operationType !== 'view'" colspan="3"><el-input v-model="currentInfo.commissionPhone" clearable
-                  size="small"></el-input></td>
+              <td v-if="operationType !== 'view'" colspan="3"><el-input v-model="currentInfo.commissionPhone" disabled
+                  placeholder="閫夋嫨濮旀墭浜哄悗鑷姩甯﹀嚭" size="small"></el-input></td>
               <td v-if="operationType === 'view'" colspan="3">{{ currentInfo.commissionPhone }}</td>
             </tr>
             <tr>
@@ -350,8 +351,8 @@
               <td colspan="2">
                 <p>棰嗘牱鍛樼鍚�</p>
               </td>
-              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.sampleTakerUser" clearable
-                  size="small"></el-input></td>
+              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.sampleTakerUser" disabled
+                  placeholder="涓嬪崟鍏宠仈鍚庤嚜鍔ㄨ褰曞綋鍓嶇櫥褰曚汉" size="small"></el-input></td>
               <td v-if="operationType === 'view'">{{ currentInfo.sampleTakerUser }}</td>
               <td>
                 <p>棰嗘牱鏃ユ湡</p>
@@ -368,17 +369,17 @@
                 <p>妫�娴嬫満鏋勪俊鎭�</p>
               </td>
               <td colspan="3">
-                <p>姹熻嫃涓ぉ绉戞妧鑲′唤鏈夐檺鍏徃妫�娴嬩腑蹇�</p>
+                <p>姹熻嫃涓ぉ绉戞妧鑲′唤鏈夐檺鍏徃锛堣蒋鐢电紗妫�娴嬪锛�</p>
               </td>
             </tr>
             <tr>
               <td colspan="3">
-                <p>鍦板潃锛氭睙鑻忕渷鍗楅�氬競缁忔祹鎶�鏈紑鍙戝尯鏂板紑鍗楄矾 19 鍙�</p>
+                <p>鍦板潃锛氭睙鑻忕渷鍗楅�氬競濡備笢鍘挎渤鍙i晣涓ぉ鏉戜簲缁�168鍙�</p>
               </td>
             </tr>
             <tr>
               <td colspan="3">
-                <p>鐢佃瘽锛�0513-89059043</p>
+                <p>鐢佃瘽锛�0513-84882686</p>
               </td>
             </tr>
           </table>
@@ -402,18 +403,53 @@
         <el-button @click="downloadDialog = false">鍙� 娑�</el-button>
       </span>
     </el-dialog>
+    <el-dialog :visible.sync="changeBindingVisible" title="鍙樻洿鍏宠仈濮旀墭鍗�" width="500px" append-to-body>
+      <el-form ref="bindingForm" :model="bindingForm" :rules="bindingRules" label-width="100px">
+        <el-form-item label="鏂扮殑濮旀墭鍗�" prop="inspectionOrderId">
+          <el-select v-model="bindingForm.inspectionOrderId" filterable remote reserve-keyword
+            :remote-method="searchUnboundInspectionOrders" :loading="bindingLoading" placeholder="璇烽�夋嫨鏈粦瀹氬鎵樺崟"
+            style="width: 100%" @focus="loadUnboundInspectionOrders">
+            <el-option v-for="item in unboundInspectionOrders" :key="item.inspectionOrderId"
+              :label="`${item.inspectionOrderCode} / ${item.sampleName || ''}`" :value="item.inspectionOrderId" />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="鍙樻洿鍘熷洜" prop="reason">
+          <el-input v-model="bindingForm.reason" type="textarea" :rows="3" maxlength="200" show-word-limit />
+        </el-form-item>
+      </el-form>
+      <span slot="footer">
+        <el-button @click="changeBindingVisible = false">鍙� 娑�</el-button>
+        <el-button type="primary" :loading="bindingSubmitting" @click="submitChangeBinding">纭� 瀹�</el-button>
+      </span>
+    </el-dialog>
+    <el-dialog :visible.sync="commissionUnitDialogVisible" title="閫夋嫨濮旀墭鍗曚綅" width="70%" append-to-body>
+      <lims-table :tableData="commissionUnitList" :column="commissionUnitColumns" :isSelection="true"
+        :handleSelectionChange="selectCommissionUnit" @pagination="changeCommissionUnitPage" :height="400"
+        :page="commissionUnitPage" :tableLoading="commissionUnitLoading" />
+      <span slot="footer"><el-button @click="commissionUnitDialogVisible = false">鍙� 娑�</el-button>
+        <el-button type="primary" @click="confirmCommissionUnit">纭� 瀹�</el-button></span>
+    </el-dialog>
+    <el-dialog :visible.sync="commissionUserDialogVisible" title="閫夋嫨濮旀墭浜�" width="70%" append-to-body>
+      <lims-table :tableData="commissionUserList" :column="commissionUserColumns" :isSelection="true"
+        :handleSelectionChange="selectCommissionUser" :height="400" :page="{ total: commissionUserList.length, size: 100, current: 1 }" />
+      <span slot="footer"><el-button @click="commissionUserDialogVisible = false">鍙� 娑�</el-button>
+        <el-button type="primary" @click="confirmCommissionUser">纭� 瀹�</el-button></span>
+    </el-dialog>
   </div>
 </template>
 
 <script>
 import {
   addInspectionOrder, delInspectionOrder, exportInspectionOrder,
-  getInsOrderOnInspection, getInspectionOrderByInsOderId, getInspectionOrderOne,
+  changeInspectionOrderBinding,
+  getInspectionOrderOne,
+  pageUnboundInspectionOrder,
   pageInspectionOrder,
   updateInspectionOrder
 } from "@/api/cnas/process/demand/demand";
 import limsTable from "@/components/Table/lims-table.vue";
 import { selectUserCondition } from "@/api/business/inspectionTask";
+import { selectCustomPageList } from "@/api/system/customer";
 
 export default {
   name: "Demand",
@@ -450,25 +486,15 @@
         },
       ],
       operationType: '',
-      orderRowsVisible: false,
       tableList: [],
       tableListLoading: false,
       pages: {
         current: 1,
         size: 20,
       },
-      tableData: [],
-      tableLoading: false,
-      tableSearch: {
-        current: 1,
-        size: 20,
-      },
-      total: 0,
       total1: 0,
-      entity: {
-        entrustCode: ''
-      },
       entitySearch: {
+        inspectionOrderCode: '',
         sampleName: '',
         commissionUnit: '',
         production: '',
@@ -477,6 +503,38 @@
       buttonLoading: false,
       downloadDialog: false,
       download: {},
+      changeBindingVisible: false,
+      bindingLoading: false,
+      bindingSubmitting: false,
+      unboundInspectionOrders: [],
+      bindingForm: {
+        insOrderId: null,
+        inspectionOrderId: null,
+        reason: ''
+      },
+      bindingRules: {
+        inspectionOrderId: [{ required: true, message: '璇烽�夋嫨鏂扮殑濮旀墭鍗�', trigger: 'change' }],
+        reason: [{ required: true, message: '璇疯緭鍏ュ彉鏇村師鍥�', trigger: 'blur' }]
+      },
+      commissionUnitDialogVisible: false,
+      commissionUnitLoading: false,
+      commissionUnitList: [],
+      commissionUnitSelection: [],
+      commissionUnitPage: { total: 0, size: 10, current: 1 },
+      commissionUnitColumns: [
+        { label: '瀹㈡埛鍚嶇О', prop: 'company' },
+        { label: '瀹㈡埛鍗曚綅EN', prop: 'companyEn' },
+        { label: '鍗曚綅鍦板潃', prop: 'address' },
+        { label: '鍗曚綅鐢佃瘽', prop: 'phone' }
+      ],
+      commissionUserDialogVisible: false,
+      commissionUserList: [],
+      commissionUserSelection: [],
+      commissionUserColumns: [
+        { label: '濮撳悕', prop: 'name' },
+        { label: '璐﹀彿', prop: 'account' },
+        { label: '鑱旂郴鐢佃瘽', prop: 'phone' }
+      ],
     };
   },
   mounted() {
@@ -489,6 +547,122 @@
     }
   },
   methods: {
+    openCommissionUnitDialog() {
+      this.commissionUnitSelection = []
+      this.commissionUnitDialogVisible = true
+      this.loadCommissionUnitList()
+    },
+    loadCommissionUnitList() {
+      this.commissionUnitLoading = true
+      selectCustomPageList({ ...this.commissionUnitPage }).then(res => {
+        this.commissionUnitList = res.data.records || []
+        this.commissionUnitPage.total = res.data.total || 0
+      }).finally(() => { this.commissionUnitLoading = false })
+    },
+    changeCommissionUnitPage({ page, limit }) {
+      this.commissionUnitPage.current = page
+      this.commissionUnitPage.size = limit
+      this.loadCommissionUnitList()
+    },
+    selectCommissionUnit(rows) { this.commissionUnitSelection = rows },
+    confirmCommissionUnit() {
+      if (this.commissionUnitSelection.length !== 1) {
+        this.$message.error('璇烽�夋嫨涓�鏉″鎵樺崟浣�')
+        return
+      }
+      const custom = this.commissionUnitSelection[0]
+      this.currentInfo.commissionUnitId = custom.id
+      this.currentInfo.commissionUnit = custom.company
+      this.commissionUnitDialogVisible = false
+    },
+    openCommissionUserDialog() {
+      this.commissionUserSelection = []
+      this.commissionUserDialogVisible = true
+      selectUserCondition().then(res => { this.commissionUserList = res.data || [] })
+    },
+    selectCommissionUser(rows) { this.commissionUserSelection = rows },
+    confirmCommissionUser() {
+      if (this.commissionUserSelection.length !== 1) {
+        this.$message.error('璇烽�夋嫨涓�浣嶅鎵樹汉')
+        return
+      }
+      const user = this.commissionUserSelection[0]
+      this.currentInfo.commissionUserId = user.id
+      this.currentInfo.commissionUser = user.name
+      this.currentInfo.commissionPhone = user.phone || ''
+      this.commissionUserDialogVisible = false
+    },
+    loadDefaultCommissionUnit() {
+      selectCustomPageList({ current: 1, size: 10, company: '涓ぉ绉戞妧瑁呭鐢电紗鏈夐檺鍏徃' }).then(res => {
+        const custom = (res.data.records || []).find(item => item.company === '涓ぉ绉戞妧瑁呭鐢电紗鏈夐檺鍏徃')
+        if (custom) {
+          this.currentInfo.commissionUnitId = custom.id
+          this.currentInfo.commissionUnit = custom.company
+        } else {
+          this.$message.warning('鏈壘鍒伴粯璁ゅ鎵樺崟浣嶏紝璇锋墜鍔ㄩ�夋嫨')
+        }
+      })
+    },
+    orderStateText(state) {
+      const states = {
+        0: '寰呭鏍�',
+        1: '妫�楠屼腑',
+        2: '閫�鍥�',
+        3: '鎾ら攢',
+        4: '宸叉楠�'
+      }
+      return state === null || state === undefined ? '鏈笅鍗�' : (states[state] || '--')
+    },
+    insResultText(result) {
+      const results = {
+        0: '涓嶅悎鏍�',
+        1: '鍚堟牸',
+        3: '涓嶅垽瀹�'
+      }
+      return result === null || result === undefined ? '寰呮楠�' : (results[result] || '--')
+    },
+    reportStatusText(status) {
+      const statuses = {
+        0: '鏈敓鎴�',
+        1: '寰呭悓姝�',
+        2: '鍙笅杞�'
+      }
+      return statuses[status] || '鏈敓鎴�'
+    },
+    canChangeBinding(row) {
+      return row.insOrderId && (row.orderState === 0 || row.orderState === 2) && !row.entrustCode
+    },
+    openChangeBinding(row) {
+      this.bindingForm = { insOrderId: row.insOrderId, inspectionOrderId: null, reason: '' }
+      this.unboundInspectionOrders = []
+      this.changeBindingVisible = true
+      this.loadUnboundInspectionOrders()
+      this.$nextTick(() => this.$refs.bindingForm && this.$refs.bindingForm.clearValidate())
+    },
+    loadUnboundInspectionOrders() {
+      this.searchUnboundInspectionOrders('')
+    },
+    searchUnboundInspectionOrders(keyword) {
+      this.bindingLoading = true
+      pageUnboundInspectionOrder({ current: 1, size: 20, inspectionOrderCode: keyword }).then(res => {
+        this.unboundInspectionOrders = res.data.records || []
+      }).finally(() => {
+        this.bindingLoading = false
+      })
+    },
+    submitChangeBinding() {
+      this.$refs.bindingForm.validate(valid => {
+        if (!valid) return
+        this.bindingSubmitting = true
+        changeInspectionOrderBinding(this.bindingForm).then(() => {
+          this.$message.success('鍏宠仈宸插彉鏇�')
+          this.changeBindingVisible = false
+          this.refreshTable()
+        }).finally(() => {
+          this.bindingSubmitting = false
+        })
+      })
+    },
     addOrderDetailList() {
       if (this.currentInfo.orderDetailList == null) {
         this.currentInfo.orderDetailList = []
@@ -518,6 +692,7 @@
     // 閲嶇疆
     refresh() {
       this.entitySearch = {
+        inspectionOrderCode: '',
         sampleName: '',
         commissionUnit: '',
         production: '',
@@ -533,42 +708,15 @@
     goAdd() {
       this.operationType = 'add'
       this.title = '鏂板妫�楠屽鎵樺崟';
-      this.orderRowsVisible = true
-      this.searchTableData()
-    },
-    // 鏌ヨ鍙柊澧炵殑妫�楠屽崟
-    searchTableData() {
-      this.tableLoading = true
-      getInsOrderOnInspection({
-        ...this.tableSearch,
-        ...this.entity
-      }).then(res => {
-        this.tableLoading = false
-        this.tableData = res.data.records
-        this.total = res.data.total
-      }).catch(err => {
-        this.tableLoading = false
-      })
-    },
-    // 閲嶇疆妫�楠屽崟鍒楄〃
-    refreshTableData() {
-      this.entity = {
-        entrustCode: ''
+      this.currentInfo = {
+        isLeave: 1,
+        processing: 0,
+        send: 1,
+        criterionRule: 0,
+        orderDetailList: []
       }
-      this.tableSearch = {
-        current: 1,
-        size: 20,
-      }
-      this.searchTableData()
-    },
-    // 妫�楠屽崟鍒楄〃鍒嗛〉
-    handleSizeChange(val) {
-      this.tableSearch.size = val
-      this.searchTableData();
-    },
-    handleCurrentChange(val) {
-      this.tableSearch.current = val
-      this.searchTableData();
+      this.detailDialogVisible = true
+      this.loadDefaultCommissionUnit()
     },
     // 鍒楄〃鍒嗛〉
     handleSizeChange1(val) {
@@ -584,9 +732,8 @@
       this.buttonLoading = true
       addInspectionOrder(this.currentInfo).then(res => {
         this.buttonLoading = false
-        this.$message.success('鏂板鎴愬姛')
+        this.$message.success(`鏂板鎴愬姛锛屽鎵樺崟鍙凤細${res.data.inspectionOrderCode}`)
         this.detailDialogVisible = false
-        this.orderRowsVisible = false
         this.refreshTable()
       }).catch(err => {
         this.buttonLoading = false
@@ -597,22 +744,11 @@
       this.buttonLoading = true
       updateInspectionOrder(this.currentInfo).then(res => {
         this.buttonLoading = false
-        this.$message.success('鏂板鎴愬姛')
+        this.$message.success('淇敼鎴愬姛')
         this.detailDialogVisible = false
-        this.orderRowsVisible = false
         this.refreshTable()
       }).catch(err => {
         this.buttonLoading = false
-      })
-    },
-    // 鏌ヨ闇�瑕佹柊澧炵殑濮旀墭鍗曡鎯�
-    goAddOrder(row) {
-      getInspectionOrderByInsOderId({ insOrderId: row.id }).then(res => {
-        this.currentInfo = res.data
-        this.title = '鏂板妫�楠屽鎵樺崟';
-        this.detailDialogVisible = true
-      }).catch(err => {
-        console.log('err----', err)
       })
     },
     // 鎵撳紑缂栬緫寮规
diff --git a/src/views/business/productOrder/components/addOrder.vue b/src/views/business/productOrder/components/addOrder.vue
index 27ee756..8ca6aee 100644
--- a/src/views/business/productOrder/components/addOrder.vue
+++ b/src/views/business/productOrder/components/addOrder.vue
@@ -49,6 +49,15 @@
                 <el-input v-model="addObj.entrustCode" clearable disabled placeholder="绯荤粺鐢熸垚" size="small"></el-input>
               </el-form-item>
             </el-col>
+            <el-col v-if="active == 1" :span="6">
+              <el-form-item label="妫�楠屽鎵樺崟:" prop="inspectionOrderId">
+                <el-input v-model="addObj.inspectionOrderCode" disabled placeholder="璇烽�夋嫨妫�楠屽鎵樺崟" size="small" style="width: 208px">
+                  <template slot="append">
+                    <el-button slot="append" icon="el-icon-search" @click="openInspectionOrderList"></el-button>
+                  </template>
+                </el-input>
+              </el-form-item>
+            </el-col>
             <el-col :span="6">
               <el-form-item label="妫�楠岀被鍒�:" prop="orderType">
                 <el-select v-model="addObj.orderType" :disabled="active>1&&tabIndex!=4" clearable size="small" style="width: 100%;">
@@ -61,6 +70,8 @@
                 <el-input v-model="addObj.custom" disabled size="small" clearable></el-input>
               </el-form-item>
             </el-col>
+          </el-row>
+          <el-row>
             <el-col :span="6">
               <el-form-item label="濮旀墭鍗曚綅:" prop="company">
                 <el-input v-model="addObj.company" disabled placeholder="閫夋嫨濮旀墭鍗曚綅" size="small" style="width: 208px">
@@ -71,8 +82,6 @@
                 </el-input>
               </el-form-item>
             </el-col>
-          </el-row>
-          <el-row>
             <el-col :span="6">
               <el-form-item label="IFS鍩�:" prop="contract">
                 <el-select v-model="addObj.contract" clearable placeholder="璇烽�夋嫨" size="small">
@@ -93,14 +102,14 @@
                 </el-input>
               </el-form-item>
             </el-col>
+          </el-row>
+          <el-row>
             <el-col :span="6">
               <el-form-item label="闆朵欢鎻忚堪:" prop="partDesc">
                 <el-input v-model="addObj.partDesc" clearable placeholder="璇疯緭鍏ラ浂浠舵弿杩�" size="small">
                 </el-input>
               </el-form-item>
             </el-col>
-          </el-row>
-          <el-row>
             <el-col :span="6">
               <el-form-item label="鑱旂郴鏂瑰紡:" prop="phone">
                 <el-input v-model="addObj.phone" :disabled="active>1&&tabIndex!=4" clearable placeholder="閫夋嫨濮旀墭瀹㈡埛" size="small"></el-input>
@@ -431,6 +440,28 @@
         <el-button type="primary" @click="selectUser">纭� 瀹�</el-button>
       </span>
     </el-dialog>
+    <el-dialog :visible.sync="inspectionOrderDialogVisible" title="閫夋嫨妫�楠屽鎵樺崟" width="70%">
+      <div v-if="inspectionOrderDialogVisible" class="body">
+        <el-form :inline="true" :model="inspectionOrderQuery" size="small">
+          <el-form-item label="濮旀墭鍗曞彿">
+            <el-input v-model="inspectionOrderQuery.inspectionOrderCode" clearable placeholder="璇疯緭鍏ュ鎵樺崟鍙�"
+              @keyup.enter.native="queryInspectionOrders"></el-input>
+          </el-form-item>
+          <el-form-item>
+            <el-button type="primary" @click="queryInspectionOrders">鏌ヨ</el-button>
+            <el-button @click="resetInspectionOrderQuery">閲嶇疆</el-button>
+          </el-form-item>
+        </el-form>
+        <lims-table :tableData="inspectionOrderTableData" :column="inspectionOrderColumns"
+                    :isSelection="true" :handleSelectionChange="selectInspectionOrderRows"
+                    @pagination="inspectionOrderPagination" :height="450" key="inspectionOrderTableData"
+                    :page="inspectionOrderPage" :tableLoading="inspectionOrderLoading"></lims-table>
+      </div>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="inspectionOrderDialogVisible = false">鍙� 娑�</el-button>
+        <el-button type="primary" @click="confirmInspectionOrder">纭� 瀹�</el-button>
+      </span>
+    </el-dialog>
     <el-dialog :visible.sync="selectStandardTree" title="閫夋嫨鏍峰搧" width="500px">
       <div v-if="selectStandardTree" v-loading="selectStandardTreeLoading" class="body"  style="height: 60vh;overflow-y: auto;user-select: none;">
         <el-row>
@@ -633,6 +664,11 @@
 import { bigEval } from "@/utils/bigEval";
 import {mapGetters} from "vuex";
 import {addQuarter, updateQuarterOnOrder} from "@/api/business/finishedProductSampling";
+import {
+  addInsOrderWithInspectionOrder,
+  getInspectionOrderForPlaceOrder,
+  pageUnboundInspectionOrder
+} from "@/api/cnas/process/demand/demand";
 
 export default {
   name: 'AddOrder',
@@ -663,6 +699,8 @@
       templates: [],
       addObj: {
         entrustCode: null,
+        inspectionOrderId: null,
+        inspectionOrderCode: null,
         contract:null,
         updateBatchNo: null,
         partDesc: null,
@@ -765,6 +803,26 @@
         unit: null
       },
       type: [],
+      inspectionOrderLoading: false,
+      inspectionOrderDialogVisible: false,
+      inspectionOrderTableData: [],
+      inspectionOrderSelection: [],
+      inspectionOrderQuery: {
+        inspectionOrderCode: ''
+      },
+      inspectionOrderPage: {
+        total: 0,
+        size: 10,
+        current: 1
+      },
+      inspectionOrderColumns: [
+        {label: '濮旀墭鍗曞彿', prop: 'inspectionOrderCode'},
+        {label: '璇曟牱鍚嶇О', prop: 'sampleName'},
+        {label: '濮旀墭鍗曚綅', prop: 'commissionUnit'},
+        {label: '鐢熶骇鍗曚綅', prop: 'production'},
+        {label: '濮旀墭浜�', prop: 'commissionUser'},
+        {label: '濮旀墭鏃堕棿', prop: 'commissionDate'}
+      ],
       selectUserDia: false,
       tableData1: [],
       tableLoading1: false,
@@ -917,6 +975,85 @@
     this.getInfo();
   },
   methods: {
+    openInspectionOrderList() {
+      this.inspectionOrderSelection = []
+      this.inspectionOrderQuery.inspectionOrderCode = ''
+      this.inspectionOrderPage.current = 1
+      this.inspectionOrderDialogVisible = true
+      this.getInspectionOrderList()
+    },
+    getInspectionOrderList() {
+      this.inspectionOrderLoading = true
+      pageUnboundInspectionOrder({
+        ...this.inspectionOrderPage,
+        ...this.inspectionOrderQuery
+      }).then(res => {
+        this.inspectionOrderTableData = res.data.records || []
+        this.inspectionOrderPage.total = res.data.total || 0
+      }).finally(() => {
+        this.inspectionOrderLoading = false
+      })
+    },
+    queryInspectionOrders() {
+      this.inspectionOrderPage.current = 1
+      this.getInspectionOrderList()
+    },
+    resetInspectionOrderQuery() {
+      this.inspectionOrderQuery.inspectionOrderCode = ''
+      this.queryInspectionOrders()
+    },
+    inspectionOrderPagination({ page, limit }) {
+      this.inspectionOrderPage.current = page
+      this.inspectionOrderPage.size = limit
+      this.getInspectionOrderList()
+    },
+    selectInspectionOrderRows(rows) {
+      this.inspectionOrderSelection = rows
+    },
+    confirmInspectionOrder() {
+      if (this.inspectionOrderSelection.length !== 1) {
+        this.$message.error(this.inspectionOrderSelection.length === 0 ? '璇烽�夋嫨涓�鏉℃楠屽鎵樺崟' : '鍙兘閫夋嫨涓�鏉℃楠屽鎵樺崟')
+        return
+      }
+      const inspectionOrder = this.inspectionOrderSelection[0]
+      this.addObj.inspectionOrderId = inspectionOrder.inspectionOrderId
+      this.addObj.inspectionOrderCode = inspectionOrder.inspectionOrderCode
+      this.inspectionOrderDialogVisible = false
+      this.handleInspectionOrderChange(inspectionOrder.inspectionOrderId)
+    },
+    handleInspectionOrderChange(inspectionOrderId) {
+      if (!inspectionOrderId) {
+        this.addObj.inspectionOrderCode = null
+        return
+      }
+      getInspectionOrderForPlaceOrder({ inspectionOrderId }).then(res => {
+        const inspectionOrder = res.data
+        this.addObj.inspectionOrderCode = inspectionOrder.inspectionOrderCode
+        this.addObj.sample = inspectionOrder.sampleName || this.addObj.sample
+        this.addObj.company = inspectionOrder.commissionUnit || this.addObj.company
+        this.addObj.companyId = inspectionOrder.commissionUnitId || this.addObj.companyId
+        this.addObj.production = inspectionOrder.production || this.addObj.production
+        this.addObj.prepareUser = inspectionOrder.commissionUser || this.addObj.prepareUser
+        this.addObj.phone = inspectionOrder.commissionPhone || this.addObj.phone
+        this.addObj.sampleStatus = inspectionOrder.sampleStatus || this.addObj.sampleStatus
+        this.addObj.isLeave = inspectionOrder.isLeave === null || inspectionOrder.isLeave === undefined
+          ? this.addObj.isLeave : inspectionOrder.isLeave
+        this.addObj.processing = inspectionOrder.processing === null || inspectionOrder.processing === undefined
+          ? this.addObj.processing : inspectionOrder.processing
+        this.addObj.appointed = inspectionOrder.appointed || this.addObj.appointed
+        this.addObj.send = inspectionOrder.send === null || inspectionOrder.send === undefined
+          ? this.addObj.send : inspectionOrder.send
+        if (/^\d+$/.test(inspectionOrder.quantity || '')) {
+          this.addObj.sampleNum = Number(inspectionOrder.quantity)
+        }
+        this.sample.sample = inspectionOrder.sampleName || this.sample.sample
+        this.sample.model = inspectionOrder.modelNo || this.sample.model
+        this.$message.success('宸插甫鍏ユ楠屽鎵樺崟淇℃伅')
+      }).catch(() => {
+        this.addObj.inspectionOrderId = null
+        this.addObj.inspectionOrderCode = null
+      })
+    },
     getInfo() {
       this.selectStandardTreeList()
       this.getAuthorizedPerson();
@@ -1413,7 +1550,18 @@
         })
       }else{
         // 甯歌鎻愪氦
-        addInsOrder({insOrder: {...this.addObj,typeSource:-1}, sampleList: sampleList}).then(res => {
+        const { inspectionOrderId, inspectionOrderCode, ...insOrder } = this.addObj
+        const submitRequest = inspectionOrderId
+          ? addInsOrderWithInspectionOrder({
+            inspectionOrderId,
+            insOrder: {...insOrder, typeSource: -1},
+            sampleList: sampleList
+          })
+          : addInsOrder({
+            insOrder: {...insOrder, typeSource: -1},
+            sampleList: sampleList
+          })
+        submitRequest.then(res => {
           this.saveLoad = false
           this.$message.success('宸叉彁浜�')
           this.bsm3Dia = false;
@@ -1494,7 +1642,7 @@
           this.addObj.phone = selects.phone
           this.addObj.companyId = selects.departId
           this.addObj.production = '涓ぉ鑰愪笣鏈夐檺鍏徃'
-          this.addObj.productionEn = 'Zhongtian Naisi Co., Ltd.'
+          this.addObj.productionEn = 'Zhongtian intelligent cable Co.,Ltd.'
           if(this.active==1){
             this.selectInsOrderTemplate()
           }

--
Gitblit v1.9.3