From 137bf2c0666b60cfc0d98b1a9ca7ead860ee4e7c Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期三, 28 十月 2026 17:57:29 +0800
Subject: [PATCH] feat(device,supply,satisfaction): 设备计划改造、耗材采购调整与满意度照片上传

---
 src/views/CNAS/systemManagement/customerSatisfaction/components/formDialog.vue |  168 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 155 insertions(+), 13 deletions(-)

diff --git a/src/views/CNAS/systemManagement/customerSatisfaction/components/formDialog.vue b/src/views/CNAS/systemManagement/customerSatisfaction/components/formDialog.vue
index a0d404a..b128c19 100644
--- a/src/views/CNAS/systemManagement/customerSatisfaction/components/formDialog.vue
+++ b/src/views/CNAS/systemManagement/customerSatisfaction/components/formDialog.vue
@@ -22,11 +22,19 @@
         </tr>
         <tr>
           <td class="td-title">
-            <p>濮撳悕锛�</p>
+            <p>瀹㈡埛锛�</p>
           </td>
           <td class="td-info">
-            <el-input v-model="form.userName" placeholder="璇疯緭鍏ュ唴瀹�" size="small">
-            </el-input>
+            <el-select v-model="form.orderId" filterable clearable size="small" style="width: 100%"
+              popper-class="customer-select-popper" placeholder="璇烽�夋嫨瀹㈡埛锛堝凡瀹屾垚濮旀墭鍗曪級" @change="onCustomerChange">
+              <el-option v-for="opt in customerOptions" :key="opt.id" :label="opt.company" :value="opt.id">
+                <div class="customer-card">
+                  <div>瀹㈡埛锛歿{ opt.company }}</div>
+                  <div class="customer-card-sub">濮旀墭鍗曠紪鍙凤細{{ opt.entrustCode || '--' }}</div>
+                  <div class="customer-card-sub">鏍峰搧鍚嶇О锛歿{ opt.sampleName || '--' }}</div>
+                </div>
+              </el-option>
+            </el-select>
           </td>
           <td class="td-title">
             <p>閮ㄩ棬锛�</p>
@@ -128,6 +136,17 @@
             </el-input>
           </td>
         </tr>
+        <tr>
+          <td class="td-title">
+            <p>鐓х墖锛�</p>
+          </td>
+          <td class="td-info" colspan="5">
+            <lims-attachment ref="photoAttachment" inline defer-upload accept=".jpg,.jpeg,.png,.gif"
+              :main-id="form.clientSatisfactionId || ''" upload-url="/clientSatisfaction/uploadAttachment"
+              select-url="/clientSatisfaction/selectAttachments" delete-url="/clientSatisfaction/deleteAttachment"
+              id-param="clientSatisfactionId" tip="鏀寔 jpg / png / gif 鐓х墖锛屽彲棰勮锛屾彁浜ゆ椂涓�骞朵笂浼�"></lims-attachment>
+          </td>
+        </tr>
       </table>
       <template #footer><span  class="dialog-footer">
         <el-button @click="closeFormDia">鍙� 娑�</el-button>
@@ -142,10 +161,12 @@
   addClientSatisfaction,
   updateClientSatisfaction
 } from '@/api/cnas/systemManagement/customerSatisfaction.js'
+import { selectCompletedOrders } from '@/api/business/productOrder'
+import limsAttachment from '@/components/Attachment/lims-attachment.vue'
 export default {
   name: 'formDialog',
   // import 寮曞叆鐨勭粍浠堕渶瑕佹敞鍏ュ埌瀵硅薄涓墠鑳戒娇鐢�
-  components: {},
+  components: { limsAttachment },
   data() {
     // 杩欓噷瀛樻斁鏁版嵁
     return {
@@ -157,6 +178,7 @@
         department: '',
         contactNumber: '',
         serviceAttitude: '',
+        serviceAttitudeSuggestion: '',
         technicalCompetence: '',
         technicalCompetenceSuggestion: '',
         inspectionWork: '',
@@ -165,7 +187,12 @@
         reasonableFeesSuggestion: '',
         remark: '',
         clientSatisfactionId: '',
+        orderId: '',
+        entrustCode: '',
+        sampleName: ''
       },
+      // 瀹㈡埛涓嬫媺閫夐」锛氬彧鍖呭惈"宸蹭笅杩囧鎵樺崟涓斿凡瀹屾垚"鐨勬暟鎹�
+      customerOptions: [],
       operationType: '',
       editLoad: false,
 
@@ -173,14 +200,89 @@
   },
   // 鏂规硶闆嗗悎
   methods: {
-    openDia(type, row) {
+    async openDia(type, row) {
       this.formDia = true;
       this.operationType = type
+      await this.loadCustomerOptions()
       if (this.operationType === 'edit') {
         this.form = { ...row }
+        // 鑰佹暟鎹病鏈夊叧鑱斿鎵樺崟锛氬悎鎴愪竴涓�夐」鎶婂師鏉ョ殑鍊煎洖鏄惧嚭鏉ワ紝涓嶅己鍒堕噸閫�
+        if (row.orderId == null && row.userName) {
+          this.customerOptions.unshift({
+            id: 0,
+            company: row.userName,
+            entrustCode: row.entrustCode || '--',
+            sampleName: row.sampleName || '--'
+          })
+          this.form.orderId = 0
+        } else if (row.orderId && !this.customerOptions.some(o => o.id === row.orderId)) {
+          // 鍏宠仈鐨勫鎵樺崟宸蹭笉鏄�"宸插畬鎴�"鐘舵�侊紝鐢ㄨ褰曢噷鐨勪俊鎭厹搴曞洖鏄�
+          this.customerOptions.unshift({
+            id: row.orderId,
+            company: row.userName || '鏈煡瀹㈡埛',
+            entrustCode: row.entrustCode || '--',
+            sampleName: row.sampleName || '--'
+          })
+        }
+      } else {
+        this.resetForm()
       }
     },
+    resetForm() {
+      this.form = {
+        unitName: '',
+        fillDate: '',
+        userName: '',
+        department: '',
+        contactNumber: '',
+        serviceAttitude: '',
+        serviceAttitudeSuggestion: '',
+        technicalCompetence: '',
+        technicalCompetenceSuggestion: '',
+        inspectionWork: '',
+        inspectionWorkSuggestion: '',
+        reasonableFees: '',
+        reasonableFeesSuggestion: '',
+        remark: '',
+        clientSatisfactionId: '',
+        orderId: '',
+        entrustCode: '',
+        sampleName: ''
+      }
+    },
+    // 涓嬫媺鏁版嵁锛氬悗绔彧杩斿洖"宸叉楠�"鐨勫鎵樺崟锛坰tate=4锛�
+    loadCustomerOptions() {
+      this.customerOptions = []
+      return selectCompletedOrders().then(res => {
+        if (res.code === 200 && res.data) {
+          this.customerOptions = res.data.map(o => ({
+            id: o.id,
+            company: o.company,
+            entrustCode: o.entrustCode,
+            sampleName: o.sampleView
+          }))
+        }
+      }).catch(err => {
+        console.log('err---', err)
+      })
+    },
+    // 閫変腑瀹㈡埛鍚庯細鍥炲~瀹㈡埛鍚嶅苟鑷姩甯﹀嚭鍗曚綅鍚嶇О銆佸鎵樺崟缂栧彿銆佹牱鍝佸悕绉�
+    onCustomerChange(val) {
+      const opt = this.customerOptions.find(o => o.id === val)
+      if (!opt || opt.id === 0) {
+        return
+      }
+      this.form.userName = opt.company
+      this.form.entrustCode = opt.entrustCode
+      this.form.sampleName = opt.sampleName
+      this.form.unitName = opt.company
+    },
     handleEdit() {
+      const orderIdEmpty = this.form.orderId === '' || this.form.orderId === null || this.form.orderId === undefined
+      if (orderIdEmpty) {
+        this.$message.warning('璇烽�夋嫨瀹㈡埛')
+        return
+      }
       if (!this.form.unitName) {
         this.$message.warning('璇峰~鍐欏崟浣嶅悕绉�')
         return
@@ -190,25 +292,51 @@
         return
       }
       this.editLoad = true
+      const payload = { ...this.form }
+      // 鑰佹暟鎹悎鎴愮殑鍥炴樉閫夐」锛坕d=0锛変笉绠楃湡瀹炲叧鑱旓紝淇濆瓨鏃朵粛淇濇寔鏈叧鑱�
+      if (payload.orderId === 0) {
+        payload.orderId = null
+      }
       if (this.operationType === 'add') {
-        addClientSatisfaction(this.form).then(res => {
-          this.editLoad = false
-          this.$message.success('鎻愪氦鎴愬姛')
-          this.closeFormDia()
+        addClientSatisfaction(payload).then(res => {
+          // 鍚庣杩斿洖淇濆瓨鍚庣殑璁板綍锛堝惈鑷id锛夛紝鐢ㄤ簬鎶婃柊澧炴椂鏆傚瓨鐨勭収鐗囦紶涓婂幓
+          const savedId = res.data && res.data.clientSatisfactionId
+          this.finishSave(savedId)
         }).catch(err => {
           console.log('err---', err);
           this.editLoad = false
         })
       } else {
-        updateClientSatisfaction(this.form).then(res => {
-          this.editLoad = false
-          this.$message.success('鎻愪氦鎴愬姛')
-          this.closeFormDia()
+        updateClientSatisfaction(payload).then(() => {
+          this.finishSave(this.form.clientSatisfactionId)
         }).catch(err => {
           console.log('err---', err);
           this.editLoad = false
         })
       }
+    },
+    // 璁板綍淇濆瓨鎴愬姛鍚庝笂浼犳殏瀛樼収鐗囷紱鐓х墖涓婁紶澶辫触涓嶅奖鍝嶈褰曟湰韬�
+    finishSave(clientSatisfactionId) {
+      this.uploadPendingPhotos(clientSatisfactionId).then(() => {
+        this.editLoad = false
+        this.$message.success('鎻愪氦鎴愬姛')
+        this.closeFormDia()
+      }).catch(err => {
+        console.log('鐓х墖涓婁紶澶辫触', err)
+        this.editLoad = false
+        this.$message.warning('璁板綍宸蹭繚瀛橈紝浣嗙収鐗囦笂浼犲け璐ワ紝璇峰洖鍒板垪琛ㄧ敤鈥滈檮浠垛�濊ˉ鍏呬笂浼�')
+        this.closeFormDia()
+      })
+    },
+    uploadPendingPhotos(clientSatisfactionId) {
+      const attachment = this.$refs.photoAttachment
+      if (!attachment || !attachment.pendingFiles.length) {
+        return Promise.resolve()
+      }
+      if (!clientSatisfactionId) {
+        return Promise.reject(new Error('鏈幏鍙栧埌璁板綍id锛屾棤娉曚笂浼犵収鐗�'))
+      }
+      return attachment.flushPending(clientSatisfactionId)
     },
     closeFormDia() {
       this.formDia = false;
@@ -251,4 +379,18 @@
   word-wrap: break-word;
   white-space: normal;
 }
+
+.customer-card-sub {
+  color: #909399;
+  font-size: 12px;
+}
+</style>
+
+<style>
+/* 涓嬫媺鍗$墖涓夎闇�瑕佽嚜閫傚簲楂樺害锛屽脊灞� teleport 鍒� body锛岀敤鑷畾涔� popper-class 鍛戒腑 */
+.customer-select-popper .el-select-dropdown__item {
+  height: auto;
+  line-height: 1.7;
+  padding: 6px 12px;
+}
 </style>

--
Gitblit v1.9.3