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/CNAS/process/demand/index.vue |  999 +++++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 847 insertions(+), 152 deletions(-)

diff --git a/src/views/CNAS/process/demand/index.vue b/src/views/CNAS/process/demand/index.vue
index 137aba5..3d17223 100644
--- a/src/views/CNAS/process/demand/index.vue
+++ b/src/views/CNAS/process/demand/index.vue
@@ -1,163 +1,858 @@
-<style lang="scss" scoped>
-.standard_method {
-    padding: 20px;
-}
-.search {
-  background-color: #fff;
-  height: 80px;
-  display: flex;
-  align-items: center;
-}
-
-.search_thing {
-//   width: 350px;
-  display: flex;
-  align-items: center;
-}
-
-.search_label {
-  width: 110px;
-  font-size: 14px;
-  text-align: right;
-}
-
-.search_input {
-  width: calc(100% - 110px);
-}
-
-.table {
-  margin-top: 10px;
-  background-color: #fff;
-  width: calc(100% - 40px);
-  height: calc(100% - 60px - 80px - 10px - 40px);
-  padding: 20px;
-}
-</style>
-
 <template>
-    <div class="standard_method">
-        <el-form :model="model" :inline="true" label-width="auto">
-            <el-form-item label="璇曟牱鍚嶇О锛�">
-                <el-input size="small"
-                    placeholder="璇疯緭鍏�" 
-                    clearable 
-                    @change="refreshTable()"
-                />
-            </el-form-item>
-            <el-form-item label="濮旀墭鍗曚綅锛�">
-                <el-input size="small"
-                    placeholder="璇疯緭鍏�" 
-                    clearable 
-                    @change="refreshTable()"
-                />
-            </el-form-item>
-            <el-form-item label="鐢熶骇鍗曚綅锛�">
-                <el-input size="small"
-                    placeholder="璇疯緭鍏�" 
-                    clearable 
-                    @change="refreshTable()"
-                />
-            </el-form-item>
-            <el-form-item label="濮旀墭浜猴細">
-                <el-input size="small"
-                    placeholder="璇疯緭鍏�" 
-                    clearable 
-                    @change="refreshTable()"
-                />
-            </el-form-item>
-            <el-form-item>
-                <el-button size="small">
-                    閲� 缃�
-                </el-button>
-                <el-button size="small" type="primary">
-                    鏌� 璇�
-                </el-button>
-            </el-form-item>
-        </el-form>
-        <div style="margin-bottom: 10px">
-            <el-button size="small" type="primary" icon="el-icon-plus" @click="openDialog('add')">
-                鏂� 澧�
-            </el-button>
-        </div>
-        <lims-table
-            :column="column"
-            :tableData="tableData"
-            :height="'calc(100vh - 250px)'"
-            :page="page"
-        />
-        <Edit ref="editRef" />
+  <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>
+        </el-form-item>
+        <el-form-item label="濮旀墭鍗曚綅" prop="commissionUnit">
+          <el-input v-model="entitySearch.commissionUnit" clearable placeholder="璇疯緭鍏�" size="small"
+            @keyup.enter.native="refreshTable()"></el-input>
+        </el-form-item>
+        <el-form-item label="鐢熶骇鍗曚綅" prop="production">
+          <el-input v-model="entitySearch.production" clearable placeholder="璇疯緭鍏�" size="small"
+            @keyup.enter.native="refreshTable()"></el-input>
+        </el-form-item>
+        <el-form-item label="濮旀墭浜�" prop="commissionUser">
+          <el-input v-model="entitySearch.commissionUser" clearable placeholder="璇疯緭鍏�" size="small"
+            @keyup.enter.native="refreshTable()"></el-input>
+        </el-form-item>
+        <el-form-item>
+          <el-button type="primary" size="mini" @click="refreshTable">鏌ヨ</el-button>
+          <el-button size="mini" @click="refresh">閲嶇疆</el-button>
+        </el-form-item>
+      </el-form>
     </div>
+    <div style="text-align: right; margin-bottom: 10px">
+      <el-button size="small" type="primary" @click="goAdd">鏂板</el-button>
+    </div>
+    <div class="table">
+      <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>
+          <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>
+        <el-table-column label="鐢熶骇鍗曚綅" prop="production" show-overflow-tooltip></el-table-column>
+        <el-table-column label="濮旀墭浜�" prop="commissionUser"></el-table-column>
+        <el-table-column label="鏍峰搧鏁伴噺" prop="quantity"></el-table-column>
+        <el-table-column label="鏍峰搧鐘舵��" prop="sampleStatus"></el-table-column>
+        <el-table-column label="鏄惁鐣欐牱" prop="isLeave">
+          <template slot-scope="scope">
+            <span v-if="scope.row.isLeave === 1">鏄�</span>
+            <span v-if="scope.row.isLeave === 0">鍚�</span>
+          </template>
+        </el-table-column>
+        <el-table-column label="鏍峰搧澶勭悊鏂瑰紡" prop="processing" width="150">
+          <template slot-scope="scope">
+            <span v-if="scope.row.processing === 1">瀹為獙瀹ゅ鐞�</span>
+            <span v-if="scope.row.processing === 0">濮旀墭鍗曚綅鍙栧洖</span>
+          </template>
+        </el-table-column>
+        <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 :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"
+              style="background: transparent;display: inline;margin-left: 4px">
+              <span style="color: #409EFF">涓婁紶</span>
+            </el-upload>
+          </template>
+        </el-table-column>
+      </el-table>
+      <el-pagination :current-page="1" :page-size="pages.size" :page-sizes="[10, 20, 30, 50, 100]" :total="total1"
+        layout="->,total, sizes, prev, pager, next" style="margin-top: 10px" background @size-change="handleSizeChange1"
+        @current-change="handleCurrentChange1">
+      </el-pagination>
+    </div>
+    <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;">
+        <div id="dialogBody">
+          <table border="1" cellpadding="10" class="tables heads" style="border: 1px dashed black;width: 100%">
+            <tr>
+              <td rowspan="2">
+                <img alt="" src="@/assets/logo/ZTTlogo.png" style="width: 80%;">
+              </td>
+              <td>
+                <p>璁板綍鍚嶇О锛氭楠屽鎵樺崟</p>
+              </td>
+              <td>
+                <p>淇濆瓨鏈熼檺锛�6骞�</p>
+              </td>
+            </tr>
+            <tr>
+              <td>
+                <p>璁板綍缂栧彿锛� ZTT/QR-16-04-a</p>
+              </td>
+              <td>
+                <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 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 style="margin-top: 16px;margin-left: 600px;">濮旀墭缂栧彿锛歿{
+            currentInfo.entrustCode || '寰呯敓鎴�' }}
+          </p>
+          <table border="1" cellpadding="10" class="tables" style="width: 100%">
+            <tr>
+              <td colspan="2">
+                <p>璇曟牱鍚嶇О</p>
+              </td>
+              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.sampleName" clearable
+                  size="small"></el-input></td>
+              <td v-if="operationType === 'view'">{{ currentInfo.sampleName }}</td>
+              <td>
+                <p>濮旀墭鏃堕棿</p>
+              </td>
+              <td v-if="operationType !== 'view'">
+                <el-date-picker v-model="currentInfo.commissionDate" clearable format="yyyy-MM-dd" placeholder="閫夋嫨鏃ユ湡"
+                  size="small" style="width: 100%" type="date" value-format="yyyy-MM-dd">
+                </el-date-picker>
+              </td>
+              <td v-if="operationType === 'view'">{{ currentInfo.commissionDate }}</td>
+            </tr>
+            <tr>
+              <td colspan="2">
+                <p>鍨� 鍙�</p>
+              </td>
+              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.modelNo" clearable
+                  size="small"></el-input>
+              </td>
+              <td v-if="operationType === 'view'">{{ currentInfo.modelNo }}</td>
+              <td>
+                <p>濮旀墭鍗曚綅</p>
+              </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>
+              <td colspan="2">
+                <p>鐢熶骇鍗曚綅</p>
+              </td>
+              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.production" clearable
+                  size="small"></el-input></td>
+              <td v-if="operationType === 'view'">{{ currentInfo.production }}</td>
+              <td>
+                <p>濮旀墭浜�</p>
+              </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>
+              <td colspan="2">
+                <p>鏍峰搧鏁伴噺</p>
+              </td>
+              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.quantity" clearable
+                  size="small"></el-input></td>
+              <td v-if="operationType === 'view'">{{ currentInfo.quantity }}</td>
+              <td>
+                <p>鏍峰搧鐘舵��</p>
+              </td>
+              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.sampleStatus" clearable
+                  size="small"></el-input></td>
+              <td v-if="operationType === 'view'">{{
+                insStateList.find(m => m.value == currentInfo.sampleStatus) ? insStateList.find(m => m.value == currentInfo.sampleStatus).label:'/'
+                }}</td>
+            </tr>
+            <tr>
+              <td colspan="2">
+                <p>鏄惁鐣欐牱</p>
+              </td>
+              <td v-if="operationType !== 'view'">
+                <el-radio-group v-model="currentInfo.isLeave" v-removeAriaHidden>
+                  <el-radio :label="1">鏄�</el-radio>
+                  <el-radio :label="0">鍚�</el-radio>
+                </el-radio-group>
+              </td>
+              <td v-if="operationType === 'view'">
+                <span v-if="currentInfo.isLeave == 1">鏄�</span>
+                <span v-else>鍚�</span>
+              </td>
+              <td>
+                <p>鏍峰搧澶勭悊鏂瑰紡</p>
+              </td>
+              <td v-if="operationType !== 'view'">
+                <el-radio-group v-model="currentInfo.processing" v-removeAriaHidden>
+                  <el-radio :label="0">濮旀墭鍗曚綅鍙栧洖</el-radio>
+                  <el-radio :label="1">瀹為獙瀹ゅ鐞�</el-radio>
+                </el-radio-group>
+              </td>
+              <td v-if="operationType === 'view'">
+                <span v-if="currentInfo.processing == 0">濮旀墭鍗曚綅鍙栧洖</span>
+                <span v-else>瀹為獙瀹ゅ鐞�</span>
+              </td>
+            </tr>
+            <tr>
+              <td colspan="2">
+                <p>绾﹀畾瀹屾垚鏃堕棿(鎶ュ憡鏃ユ湡)</p>
+              </td>
+              <td v-if="operationType !== 'view'">
+                <el-date-picker v-model="currentInfo.appointed" clearable format="yyyy-MM-dd" placeholder="閫夋嫨鏃ユ湡"
+                  size="small" style="width: 100%" type="date" value-format="yyyy-MM-dd">
+                </el-date-picker>
+              </td>
+              <td v-if="operationType === 'view'">{{ currentInfo.appointed }}</td>
+              <td>
+                <p>鎶ュ憡鍙戦�佹柟寮�</p>
+              </td>
+              <td v-if="operationType !== 'view'">
+                <el-radio-group v-model="currentInfo.send" v-removeAriaHidden>
+                  <el-radio :label="1">鑷彇</el-radio>
+                  <el-radio :label="0">鍏朵粬</el-radio>
+                </el-radio-group>
+              </td>
+              <td v-if="operationType === 'view'">
+                <span v-if="currentInfo.send == 1">鑷彇</span>
+                <span v-else>鍏朵粬</span>
+              </td>
+            </tr>
+            <el-button size="small" type="primary" @click="addOrderDetailList"
+              v-if="operationType !== 'view'">娣诲姞</el-button>
+            <tr>
+              <td>
+                <p>搴忓彿</p>
+              </td>
+              <td>
+                <p>鏍峰搧缂栧彿</p>
+              </td>
+              <td>
+                <p>璇曢獙椤圭洰</p>
+              </td>
+              <td>
+                <p>妫�楠屼緷鎹�</p>
+              </td>
+              <td>
+                <p>澶囨敞</p>
+              </td>
+            </tr>
+            <tr v-for="(item, index) in currentInfo.orderDetailList" :key="index">
+              <td>{{ index + 1 }}</td>
+              <td v-if="operationType !== 'view'"><el-input v-model="item.sampleNumber" clearable
+                  size="small"></el-input>
+              </td>
+              <td v-if="operationType === 'view'">{{ item.sampleNumber }}</td>
+              <td v-if="operationType !== 'view'"><el-input v-model="item.testItem" clearable size="small"></el-input>
+              </td>
+              <td v-if="operationType === 'view'">{{ item.testItem }}</td>
+              <td v-if="operationType !== 'view'"><el-input v-model="item.testStandard" clearable
+                  size="small"></el-input>
+              </td>
+              <td v-if="operationType === 'view'">{{ item.testStandard }}</td>
+              <td v-if="operationType !== 'view'"><el-input v-model="item.remark" clearable size="small"></el-input>
+              </td>
+              <td v-if="operationType === 'view'">{{ item.remark }}</td>
+            </tr>
+            <tr>
+              <td colspan="2">
+                <p>鍒ゅ畾瑙勫垯</p>
+              </td>
+              <td v-if="operationType !== 'view'" colspan="3">
+                <el-radio-group v-model="currentInfo.criterionRule" v-removeAriaHidden>
+                  <el-radio :label="0">涓嶈�冭檻涓嶇‘瀹氬害</el-radio>
+                  <el-radio :label="1">鑰冭檻涓嶇‘瀹氬害</el-radio>
+                </el-radio-group>
+                <span v-if="currentInfo.criterionRule === 1"><el-input v-model="currentInfo.criterionRuleRemark"
+                    clearable size="small" style="width: 60px"></el-input>%</span>
+              </td>
+              <td v-if="operationType === 'view'" colspan="3">
+                <span v-if="currentInfo.criterionRule === 0">涓嶈�冭檻涓嶇‘瀹氬害</span>
+                <span v-if="currentInfo.criterionRule === 1">鑰冭檻涓嶇‘瀹氬害</span>
+                <span v-if="currentInfo.criterionRule === 1">{{ currentInfo.criterionRuleRemark + '%' }}</span>
+              </td>
+            </tr>
+            <tr>
+              <td colspan="2">
+                <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'">
+                {{ currentInfo.commissionUser }}
+              </td>
+              <td>
+                <p>濮旀墭鏃ユ湡</p>
+              </td>
+              <td v-if="operationType !== 'view'">
+                <el-date-picker v-model="currentInfo.commissionDate" clearable format="yyyy-MM-dd" placeholder="閫夋嫨鏃ユ湡"
+                  size="small" style="width: 100%" type="date" value-format="yyyy-MM-dd">
+                </el-date-picker>
+              </td>
+              <td v-if="operationType === 'view'">{{ currentInfo.commissionDate }}</td>
+            </tr>
+            <tr>
+              <td colspan="2">
+                <p>濮旀墭浜鸿仈绯荤數璇�</p>
+              </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>
+              <td colspan="2">
+                <p>缁煎悎瀹ょ鍚�</p>
+              </td>
+              <td v-if="operationType !== 'view'"><el-input v-model="currentInfo.generalOfficeUser" clearable
+                  size="small"></el-input></td>
+              <td v-if="operationType === 'view'">{{ currentInfo.generalOfficeUser }}</td>
+              <td>
+                <p>鎺ユ敹鏃ユ湡</p>
+              </td>
+              <td v-if="operationType !== 'view'">
+                <el-date-picker v-model="currentInfo.receiptData" clearable format="yyyy-MM-dd" placeholder="閫夋嫨鏃ユ湡"
+                  size="small" style="width: 100%" type="date" value-format="yyyy-MM-dd">
+                </el-date-picker>
+              </td>
+              <td v-if="operationType === 'view'">{{ currentInfo.receiptData }}</td>
+            </tr>
+            <tr>
+              <td colspan="2">
+                <p>棰嗘牱鍛樼鍚�</p>
+              </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>
+              </td>
+              <td v-if="operationType !== 'view'">
+                <el-date-picker v-model="currentInfo.sampleData" clearable format="yyyy-MM-dd" placeholder="閫夋嫨鏃ユ湡"
+                  size="small" style="width: 100%" type="date" value-format="yyyy-MM-dd">
+                </el-date-picker>
+              </td>
+              <td v-if="operationType === 'view'">{{ currentInfo.sampleData }}</td>
+            </tr>
+            <tr>
+              <td colspan="2" rowspan="3">
+                <p>妫�娴嬫満鏋勪俊鎭�</p>
+              </td>
+              <td colspan="3">
+                <p>姹熻嫃涓ぉ绉戞妧鑲′唤鏈夐檺鍏徃锛堣蒋鐢电紗妫�娴嬪锛�</p>
+              </td>
+            </tr>
+            <tr>
+              <td colspan="3">
+                <p>鍦板潃锛氭睙鑻忕渷鍗楅�氬競濡備笢鍘挎渤鍙i晣涓ぉ鏉戜簲缁�168鍙�</p>
+              </td>
+            </tr>
+            <tr>
+              <td colspan="3">
+                <p>鐢佃瘽锛�0513-84882686</p>
+              </td>
+            </tr>
+          </table>
+          <p style="margin-top: 10px;margin-left: 20px;">娉細鏈楠屽鎵樺崟涓�寮忎簩浠斤紝涓�浠界患鍚堝褰掓。锛屼竴浠藉鎵樺崟浣嶇暀瀛樸��</p>
+        </div>
+      </div>
+      <span v-if="operationType !== 'view'" slot="footer" class="dialog-footer">
+        <el-button @click="detailDialogVisible = false">鍙� 娑�</el-button>
+        <el-button v-if="operationType === 'add'" :loading="buttonLoading" type="primary" @click="handleAdd">纭�
+          瀹�</el-button>
+        <el-button v-if="operationType === 'edit'" :loading="buttonLoading" type="primary" @click="handleEdit">纭�
+          瀹�</el-button>
+      </span>
+    </el-dialog>
+    <el-dialog :visible.sync="downloadDialog" title="涓嬭浇" width="600px">
+      <span>
+        <el-button :loading="outLoading" plain type="primary" @click="orderReportDown">涓嬭浇濮旀墭鍗�</el-button>
+        <el-button :loading="outLoading" plain type="primary" @click="orderFormDown">涓嬭浇濮旀墭鎶ュ憡</el-button>
+      </span>
+      <span slot="footer" class="dialog-footer">
+        <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,
+  changeInspectionOrderBinding,
+  getInspectionOrderOne,
+  pageUnboundInspectionOrder,
+  pageInspectionOrder,
+  updateInspectionOrder
+} from "@/api/cnas/process/demand/demand";
 import limsTable from "@/components/Table/lims-table.vue";
-import Edit from './Edit.vue'
-import { getInspectionOrder } from "@/api/cnas/process/demand/demand.js"
+import { selectUserCondition } from "@/api/business/inspectionTask";
+import { selectCustomPageList } from "@/api/system/customer";
 
 export default {
-    name: 'Demand',
-    components: {
-        limsTable,
-        Edit
-    },
-    data() {
-        return {
-            queryParams: {
-                code: ''
-            },
-            model: {},
-            column: [
-                { label: '搴忓彿', minWidth: '100px' },
-                { label: '璇曟牱鍚嶇О', minWidth: '100px' },
-                { label: '濮旀墭缂栧彿' },
-                { label: '濮旀墭鏃堕棿' },
-                { label: '鍨嬪彿' },
-                { label: '濮旀墭鍗曚綅' },
-                { label: '鐢熶骇鍗曚綅' },
-                { label: '濮旀墭浜�' },
-                { label: '鏍峰搧鏁伴噺' },
-                { label: '鏍峰搧鐘舵��' },
-                { label: '鏄惁鐣欐牱' },
-                { label: '鏍峰搧澶勭悊鏂瑰紡' },
-                {
-                    dataType: "action",
-                    fixed: "right",
-                    label: "鎿嶄綔",
-                    operation: [
-                        {
-                            name: "缂� 杈�",
-                            type: "text",
-                            clickFun: (row) => {
-                                this.$refs.editRef.openAddContracts(row)
-                            }
-                        }
-                    ],
-                },
-            ],
-            tableData: [], // 琛ㄦ牸鏁版嵁
-            page: {
-                total: 0,
-                size: 10,
-                current: 1,
-            },
-        }
-    },
-    mounted() {
-        this.refreshTable()
-    },
-    methods: {
-        /**
-         * @desc 鍒锋柊琛ㄦ牸
-         */
-        async refreshTable() {
-            await getInspectionOrder({ ...this.page })
+  name: "Demand",
+  components: { limsTable },
+  data() {
+    return {
+      title: '妫�楠屽鎵樺崟',
+      detailDialogVisible: false,
+      addLoading: false,
+      outLoading: false,
+      currentInfo: {
+        orderDetailList: []
+      },
+      personList: [],
+      insStateList: [
+        {
+          label: '寰呭鏍�',
+          value: 0
+        }, {
+          label: '寰呮楠�',
+          value: 1
         },
-        /**
-         * @desc 鎵撳紑妯℃�佹
-         */
-        openDialog(type) {
-            this.$refs.editRef.open(type)
-        }
+        {
+          label: '宸叉楠�',
+          value: 4
+        },
+        {
+          label: '閫�鍥�',
+          value: 2
+        },
+        {
+          label: '鎾ら攢',
+          value: 3
+        },
+      ],
+      operationType: '',
+      tableList: [],
+      tableListLoading: false,
+      pages: {
+        current: 1,
+        size: 20,
+      },
+      total1: 0,
+      entitySearch: {
+        inspectionOrderCode: '',
+        sampleName: '',
+        commissionUnit: '',
+        production: '',
+        commissionUser: '',
+      },
+      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() {
+    this.getAuthorizedPerson()
+    this.refreshTable()
+  },
+  computed: {
+    action() {
+      return this.javaApi + '/inspectionOrder/uploadInspectionOrderFile'
     }
+  },
+  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 = []
+      }
+      this.currentInfo.orderDetailList.push({
+        sampleNumber: '',
+        testItem: '',
+        testStandard: '',
+        standardMethodList: '',
+        remark: '',
+      })
+    },
+    // 鏌ヨ鍒楄〃
+    refreshTable() {
+      this.tableListLoading = true
+      pageInspectionOrder({
+        ...this.pages,
+        ...this.entitySearch
+      }).then(res => {
+        this.tableListLoading = false
+        this.tableList = res.data.records
+        this.total1 = res.data.total
+      }).catch(err => {
+        this.tableListLoading = false
+      })
+    },
+    // 閲嶇疆
+    refresh() {
+      this.entitySearch = {
+        inspectionOrderCode: '',
+        sampleName: '',
+        commissionUnit: '',
+        production: '',
+        commissionUser: '',
+      }
+      this.pages = {
+        current: 1,
+        size: 20,
+      }
+      this.refreshTable()
+    },
+    // 鎵撳紑鏂板寮规
+    goAdd() {
+      this.operationType = 'add'
+      this.title = '鏂板妫�楠屽鎵樺崟';
+      this.currentInfo = {
+        isLeave: 1,
+        processing: 0,
+        send: 1,
+        criterionRule: 0,
+        orderDetailList: []
+      }
+      this.detailDialogVisible = true
+      this.loadDefaultCommissionUnit()
+    },
+    // 鍒楄〃鍒嗛〉
+    handleSizeChange1(val) {
+      this.pages.size = val
+      this.refreshTable();
+    },
+    handleCurrentChange1(val) {
+      this.pages.current = val
+      this.refreshTable();
+    },
+    // 鎻愪氦鏂板
+    handleAdd() {
+      this.buttonLoading = true
+      addInspectionOrder(this.currentInfo).then(res => {
+        this.buttonLoading = false
+        this.$message.success(`鏂板鎴愬姛锛屽鎵樺崟鍙凤細${res.data.inspectionOrderCode}`)
+        this.detailDialogVisible = false
+        this.refreshTable()
+      }).catch(err => {
+        this.buttonLoading = false
+      })
+    },
+    // 鎻愪氦淇敼
+    handleEdit() {
+      this.buttonLoading = true
+      updateInspectionOrder(this.currentInfo).then(res => {
+        this.buttonLoading = false
+        this.$message.success('淇敼鎴愬姛')
+        this.detailDialogVisible = false
+        this.refreshTable()
+      }).catch(err => {
+        this.buttonLoading = false
+      })
+    },
+    // 鎵撳紑缂栬緫寮规
+    goUpdate(row) {
+      this.operationType = 'edit'
+      getInspectionOrderOne({ inspectionOrderId: row.inspectionOrderId }).then(res => {
+        this.currentInfo = res.data
+        this.title = '缂栬緫妫�楠屽鎵樺崟';
+        this.detailDialogVisible = true
+      }).catch(err => {
+        console.log('err----', err)
+      })
+    },
+    // 鏌ョ湅
+    handleLook(row) {
+      this.operationType = 'view'
+      getInspectionOrderOne({ inspectionOrderId: row.inspectionOrderId }).then(res => {
+        this.currentInfo = res.data
+        this.title = '鏌ョ湅妫�楠屽鎵樺崟';
+        this.detailDialogVisible = true
+      }).catch(err => {
+        console.log('err----', err)
+      })
+    },
+    // 鍒犻櫎
+    deleteOrder(row) {
+      this.$confirm('姝ゆ搷浣滃皢姘镐箙鍒犻櫎璇ユ暟鎹�, 鏄惁缁х画?', '鎻愮ず', {
+        confirmButtonText: '纭畾',
+        cancelButtonText: '鍙栨秷',
+        type: 'warning'
+      }).then(() => {
+        delInspectionOrder({ inspectionOrderId: row.inspectionOrderId }).then(res => {
+          this.$message.success('鍒犻櫎鎴愬姛锛�');
+          this.refreshTable();
+        });
+      }).catch(() => {
+        this.$message({
+          type: 'info',
+          message: '宸插彇娑堝垹闄�'
+        });
+      });
+    },
+    // 鎵撳紑涓嬭浇寮规
+    openDownloadDia(row) {
+      this.downloadDialog = true
+      this.download = row
+    },
+    // 濮旀墭鍗曚笅杞�
+    orderFormDown() {
+      let url = this.download.fileUrl;
+      const link = document.createElement('a');
+      link.href = this.javaApi + url;
+      link.target = '_blank';
+      document.body.appendChild(link);
+      link.click();
+    },
+    // 濮旀墭鎶ュ憡涓嬭浇
+    orderReportDown() {
+      this.outLoading = true;
+      exportInspectionOrder({ inspectionOrderId: this.download.inspectionOrderId }).then(res => {
+        this.outLoading = false;
+        const blob = new Blob([res], { type: 'application/octet-stream' });
+        this.$download.saveAs(blob, '妫�楠屽鎵樺崟.docx')
+
+      }).catch(err => {
+        this.outLoading = false;
+      })
+    },
+    // 涓婁紶
+    handleSuccessUp(response,) {
+      if (response.code == 200) {
+        this.$message.success('涓婁紶鎴愬姛');
+        this.refreshTable()
+      }
+    },
+    beforeUpload(file) {
+      if (file.size > 1024 * 1024 * 10) {
+        this.$message.error('涓婁紶鏂囦欢涓嶈秴杩�10M');
+        this.$refs.upload.clearFiles()
+        return false;
+      } else {
+        return true;
+      }
+    },
+    onError(err, file, fileList) {
+      this.$message.error('涓婁紶澶辫触')
+      this.$refs.upload.clearFiles()
+    },
+    // 浜哄憳鍒楄〃
+    getAuthorizedPerson() {
+      selectUserCondition().then(res => {
+        let data = []
+        res.data.forEach(a => {
+          data.push({
+            label: a.name,
+            value: a.id
+          })
+        })
+        this.personList = data
+      })
+    },
+
+  },
 }
-</script>
\ No newline at end of file
+</script>
+
+<style scoped></style>

--
Gitblit v1.9.3