From 4b96a3812c141f06c767467a7f9e41940b4e8d03 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 24 六月 2026 18:42:13 +0800
Subject: [PATCH] 1.客户,销售,供应商,采购增加总合同号 2.采购的产品增加库存状态回显 3.出厂改成创建时间倒序 4.开发总合同号管理页面

---
 src/views/basicData/customerFile/index.vue |  660 ++++++++++++++++++++++++++++++++++-------------------------
 1 files changed, 383 insertions(+), 277 deletions(-)

diff --git a/src/views/basicData/customerFile/index.vue b/src/views/basicData/customerFile/index.vue
index 97ea3e6..1b8fe52 100644
--- a/src/views/basicData/customerFile/index.vue
+++ b/src/views/basicData/customerFile/index.vue
@@ -27,6 +27,9 @@
       <div>
         <el-button type="primary"
                    @click="openForm('add')">鏂板瀹㈡埛</el-button>
+        <el-button type="primary"
+                   plain
+                   @click="back">娴佸叆鍏捣</el-button>
         <el-button @click="handleOut">瀵煎嚭</el-button>
         <el-button type="info"
                    plain
@@ -34,7 +37,7 @@
                    @click="handleImport">瀵煎叆</el-button>
         <el-button type="danger"
                    plain
-                   @click="handleDelete">鍒犻櫎</el-button>
+                   @click="handleDelete" v-hasPermi="['basicData:customerFile:remove']">鍒犻櫎</el-button>
       </div>
     </div>
     <div class="table_list">
@@ -65,14 +68,6 @@
                         clearable />
             </el-form-item>
           </el-col>
-          <el-col :span="12">
-            <el-form-item label="绾崇◣浜鸿瘑鍒彿锛�"
-                          prop="taxpayerIdentificationNumber">
-              <el-input v-model="form.taxpayerIdentificationNumber"
-                        placeholder="璇疯緭鍏�"
-                        clearable />
-            </el-form-item>
-          </el-col>
         </el-row>
         <el-row :gutter="30">
           <el-col :span="12">
@@ -94,32 +89,6 @@
         </el-row>
         <el-row :gutter="30">
           <el-col :span="12">
-            <el-form-item label="閾惰鍩烘湰鎴凤細"
-                          prop="basicBankAccount">
-              <el-input v-model="form.basicBankAccount"
-                        placeholder="璇疯緭鍏�"
-                        clearable />
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="閾惰璐﹀彿锛�"
-                          prop="bankAccount">
-              <el-input v-model="form.bankAccount"
-                        placeholder="璇疯緭鍏�"
-                        clearable />
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-row :gutter="30">
-          <el-col :span="12">
-            <el-form-item label="寮�鎴疯鍙凤細"
-                          prop="bankCode">
-              <el-input v-model="form.bankCode"
-                        placeholder="璇疯緭鍏�"
-                        clearable />
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
             <el-form-item label="瀹㈡埛鍒嗙被锛�"
                           prop="customerType">
               <el-select v-model="form.customerType"
@@ -133,38 +102,6 @@
             </el-form-item>
           </el-col>
         </el-row>
-        <el-row :gutter="30"
-                v-for="(contact, index) in formYYs.contactList"
-                :key="index">
-          <el-col :span="12">
-            <el-form-item label="鑱旂郴浜猴細"
-                          prop="contactPerson">
-              <el-input v-model="contact.contactPerson"
-                        placeholder="璇疯緭鍏�"
-                        clearable />
-            </el-form-item>
-          </el-col>
-          <el-col :span="12">
-            <el-form-item label="鑱旂郴鐢佃瘽锛�"
-                          prop="contactPhone">
-              <div style="display: flex; align-items: center;width: 100%;">
-                <el-input v-model="contact.contactPhone"
-                          placeholder="璇疯緭鍏�"
-                          clearable />
-                <el-button @click="removeContact(index)"
-                           type="danger"
-                           circle
-                           style="margin-left: 5px;">
-                  <el-icon>
-                    <Close />
-                  </el-icon>
-                </el-button>
-              </div>
-            </el-form-item>
-          </el-col>
-        </el-row>
-        <el-button @click="addNewContact"
-                   style="margin-bottom: 10px;">+ 鏂板鑱旂郴浜�</el-button>
         <el-row :gutter="30">
           <el-col :span="12">
             <el-form-item label="缁存姢浜猴細"
@@ -391,12 +328,6 @@
           <el-row :gutter="20">
             <el-col :span="12">
               <div class="info-item">
-                <span class="info-label">绾崇◣浜鸿瘑鍒彿锛�</span>
-                <span class="info-value">{{ detailForm.taxpayerIdentificationNumber }}</span>
-              </div>
-            </el-col>
-            <el-col :span="12">
-              <div class="info-item">
                 <span class="info-label">鍏徃鐢佃瘽锛�</span>
                 <span class="info-value">{{ detailForm.companyPhone }}</span>
               </div>
@@ -407,40 +338,6 @@
               <div class="info-item">
                 <span class="info-label">鍏徃鍦板潃锛�</span>
                 <span class="info-value">{{ detailForm.companyAddress }}</span>
-              </div>
-            </el-col>
-            <el-col :span="12">
-              <div class="info-item">
-                <span class="info-label">閾惰鍩烘湰鎴凤細</span>
-                <span class="info-value">{{ detailForm.basicBankAccount }}</span>
-              </div>
-            </el-col>
-          </el-row>
-          <el-row :gutter="20">
-            <el-col :span="12">
-              <div class="info-item">
-                <span class="info-label">閾惰璐﹀彿锛�</span>
-                <span class="info-value">{{ detailForm.bankAccount }}</span>
-              </div>
-            </el-col>
-            <el-col :span="12">
-              <div class="info-item">
-                <span class="info-label">寮�鎴疯鍙凤細</span>
-                <span class="info-value">{{ detailForm.bankCode }}</span>
-              </div>
-            </el-col>
-          </el-row>
-          <el-row :gutter="20">
-            <el-col :span="12">
-              <div class="info-item">
-                <span class="info-label">鑱旂郴浜猴細</span>
-                <span class="info-value">{{ detailForm.contactPerson }}</span>
-              </div>
-            </el-col>
-            <el-col :span="12">
-              <div class="info-item">
-                <span class="info-label">鑱旂郴鐢佃瘽锛�</span>
-                <span class="info-value">{{ detailForm.contactPhone }}</span>
               </div>
             </el-col>
           </el-row>
@@ -460,70 +357,129 @@
           </el-row>
         </div>
       </div>
-      <!-- 娲借皥杩涘害璁板綍 -->
-      <div class="detail-section">
-        <div class="section-header">
-          <h3 class="section-title">娲借皥杩涘害璁板綍</h3>
-          <el-button type="primary"
-                     size="small"
-                     @click="openNegotiationDialog(detailForm)">
-            娣诲姞杩涘害
-          </el-button>
-        </div>
-        <el-table :data="negotiationRecords"
-                  border
-                  style="width: 100%">
-          <el-table-column prop="followUpTime"
-                           label="璺熻繘鏃堕棿"
-                           width="160" />
-          <el-table-column prop="followUpMethod"
-                           label="璺熻繘鏂瑰紡"
-                           width="100" />
-          <el-table-column prop="followUpLevel"
-                           label="璺熻繘绋嬪害" />
-          <el-table-column prop="followerUserName"
-                           label="璺熻繘浜�"
-                           width="100" />
-          <el-table-column prop="content"
-                           label="鍐呭"
-                           show-overflow-tooltip />
-          <el-table-column label="闄勪欢"
-                           width="100"
-                           align="center">
-            <template #default="{ row }">
-              <el-button type="info"
-                         link
-                         @click="openAttachmentDialog(row)">
-                <el-icon>
-                  <Paperclip />
-                </el-icon>
-                闄勪欢
-                <!-- {{ row.fileList && row.fileList.length > 0 ? row.fileList.length : '涓婁紶' }} -->
-              </el-button>
-            </template>
-          </el-table-column>
-          <el-table-column label="鎿嶄綔"
-                           width="150"
-                           align="center">
-            <template #default="{ row, $index }">
-              <el-button type="primary"
-                         link
-                         @click="editNegotiationRecord(row, $index)">
-                淇敼
-              </el-button>
-              <el-button type="danger"
-                         link
-                         @click="deleteNegotiationRecord(row, $index)">
-                鍒犻櫎
-              </el-button>
-            </template>
-          </el-table-column>
-        </el-table>
-        <div v-if="negotiationRecords.length === 0"
-             class="no-records">
-          鏆傛棤娲借皥杩涘害璁板綍
-        </div>
-      </div>
+      <!-- Tab鍒囨崲鍖哄煙 -->
+      <el-tabs v-model="detailActiveTab" class="detail-tabs">
+        <!-- 娲借皥杩涘害璁板綍 -->
+        <el-tab-pane label="娲借皥杩涘害璁板綍" name="negotiation">
+          <div class="section-header">
+            <el-button type="primary"
+                       size="small"
+                       @click="openNegotiationDialog(detailForm)">
+              娣诲姞杩涘害
+            </el-button>
+          </div>
+          <el-table :data="negotiationRecords"
+                    border
+                    style="width: 100%">
+            <el-table-column prop="followUpTime"
+                             label="璺熻繘鏃堕棿"
+                             width="160" />
+            <el-table-column prop="followUpMethod"
+                             label="璺熻繘鏂瑰紡"
+                             width="100" />
+            <el-table-column prop="followUpLevel"
+                             label="璺熻繘绋嬪害" />
+            <el-table-column prop="followerUserName"
+                             label="璺熻繘浜�"
+                             width="100" />
+            <el-table-column prop="content"
+                             label="鍐呭"
+                             show-overflow-tooltip />
+            <el-table-column label="闄勪欢"
+                             width="100"
+                             align="center">
+              <template #default="{ row }">
+                <el-button type="info"
+                           link
+                           @click="openAttachmentDialog(row)">
+                  <el-icon>
+                    <Paperclip />
+                  </el-icon>
+                  闄勪欢
+                </el-button>
+              </template>
+            </el-table-column>
+            <el-table-column label="鎿嶄綔"
+                             width="150"
+                             align="center">
+              <template #default="{ row, $index }">
+                <el-button type="primary"
+                           link
+                           @click="editNegotiationRecord(row, $index)">
+                  淇敼
+                </el-button>
+                <el-button type="danger"
+                           link
+                           @click="deleteNegotiationRecord(row, $index)" v-hasPermi="['basicData:customerFile:remove']">
+                  鍒犻櫎
+                </el-button>
+              </template>
+            </el-table-column>
+          </el-table>
+          <div v-if="negotiationRecords.length === 0"
+               class="no-records">
+            鏆傛棤娲借皥杩涘害璁板綍
+          </div>
+        </el-tab-pane>
+        <!-- 鍚堝悓璁板綍 -->
+        <el-tab-pane label="鍚堝悓璁板綍" name="contract">
+          <div class="section-header">
+            <el-button type="primary"
+                       size="small"
+                       @click="handleAddContract">
+              鏂板鍚堝悓璁板綍
+            </el-button>
+          </div>
+          <el-table :data="contractList"
+                    border
+                    style="width: 100%">
+            <el-table-column prop="masterContractNo"
+                             label="鎬诲悎鍚屽彿"
+                             show-overflow-tooltip />
+            <el-table-column prop="entryDate"
+                             label="褰曞叆鏃ユ湡"
+                             width="180" />
+            <el-table-column prop="entryPerson"
+                             label="褰曞叆浜�"
+                             width="120" />
+            <el-table-column prop="remark"
+                             label="澶囨敞"
+                             show-overflow-tooltip />
+            <el-table-column label="闄勪欢"
+                             width="100"
+                             align="center">
+              <template #default="{ row }">
+                <el-link type="primary"
+                         v-if="row.fileList && row.fileList.length"
+                         @click="handleViewContractFiles(row)">
+                  鏌ョ湅({{ row.fileList.length }})
+                </el-link>
+                <span v-else>-</span>
+              </template>
+            </el-table-column>
+            <el-table-column label="鎿嶄綔"
+                             width="150"
+                             align="center">
+              <template #default="{ row }">
+                <el-button type="primary"
+                           link
+                           @click="handleEditContract(row)">
+                  缂栬緫
+                </el-button>
+                <el-button type="danger"
+                           link
+                           @click="handleDeleteContract(row)" v-hasPermi="['basicData:customerFile:remove']">
+                  鍒犻櫎
+                </el-button>
+              </template>
+            </el-table-column>
+          </el-table>
+          <div v-if="contractList.length === 0"
+               class="no-records">
+            鏆傛棤鍚堝悓璁板綍
+          </div>
+        </el-tab-pane>
+      </el-tabs>
       <template #footer>
         <div class="dialog-footer">
           <el-button @click="closeDetailDialog">鍏抽棴</el-button>
@@ -588,7 +544,7 @@
                 </el-button>
                 <el-button type="danger"
                            link
-                           @click="deleteAttachment(row, $index)">
+                           @click="deleteAttachment(row, $index)" v-hasPermi="['basicData:customerFile:remove']">
                   鍒犻櫎
                 </el-button>
               </template>
@@ -606,6 +562,79 @@
         </div>
       </template>
     </el-dialog>
+    <!-- 鍚堝悓璁板綍鏂板/缂栬緫寮圭獥 -->
+    <el-dialog :title="contractDialogTitle"
+               v-model="contractDialogVisible"
+               width="600px"
+               @close="closeContractDialog">
+      <el-form :model="contractForm"
+               :rules="contractRules"
+               ref="contractFormRef"
+               label-width="100px">
+        <el-form-item label="鎬诲悎鍚屽彿" prop="masterContractNo">
+          <el-input v-model="contractForm.masterContractNo"
+                    placeholder="璇疯緭鍏ユ�诲悎鍚屽彿" />
+        </el-form-item>
+        <el-form-item label="褰曞叆鏃ユ湡" prop="entryDate">
+          <el-date-picker v-model="contractForm.entryDate"
+                          type="datetime"
+                          placeholder="閫夋嫨鏃ユ湡鏃堕棿"
+                          value-format="YYYY-MM-DD HH:mm:ss"
+                          style="width: 100%" />
+        </el-form-item>
+        <el-form-item label="褰曞叆浜�" prop="entryPerson">
+          <el-input v-model="contractForm.entryPerson"
+                    placeholder="璇疯緭鍏ュ綍鍏ヤ汉" />
+        </el-form-item>
+        <el-form-item label="闄勪欢">
+          <FileUpload v-model:file-list="contractForm.storageBlobDTOs" />
+        </el-form-item>
+        <el-form-item label="澶囨敞">
+          <el-input v-model="contractForm.remark"
+                    type="textarea"
+                    :rows="3"
+                    placeholder="璇疯緭鍏ュ娉�" />
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="contractDialogVisible = false">鍙栨秷</el-button>
+          <el-button type="primary" @click="submitContractForm">纭畾</el-button>
+        </div>
+      </template>
+    </el-dialog>
+    <!-- 鍚堝悓闄勪欢鏌ョ湅寮圭獥 -->
+    <el-dialog title="闄勪欢鍒楄〃"
+               v-model="contractFileDialogVisible"
+               width="600px">
+      <el-table :data="currentContractFiles"
+                border
+                style="width: 100%">
+        <el-table-column prop="name"
+                         label="鏂囦欢鍚�"
+                         show-overflow-tooltip />
+        <el-table-column label="鎿嶄綔"
+                         width="120"
+                         align="center">
+          <template #default="{ row }">
+            <el-button type="primary"
+                       link
+                       @click="downloadContractFile(row)">
+              涓嬭浇
+            </el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      <div v-if="!currentContractFiles || currentContractFiles.length === 0"
+           class="no-records">
+        鏆傛棤闄勪欢
+      </div>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button @click="contractFileDialogVisible = false">鍏抽棴</el-button>
+        </div>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
@@ -619,11 +648,19 @@
     addReturnVisit,
     getReturnVisit,
   } from "@/api/basicData/customerFile.js";
-  import {listCustomer, getCustomer, addCustomer, updateCustomer, delCustomer} from "@/api/basicData/customer.js";
+  import {
+    getCustomerContractList,
+    getCustomerContractById,
+    addCustomerContract,
+    updateCustomerContract,
+    delCustomerContract,
+  } from "@/api/basicData/customerContract.js";
+  import {listCustomer, getCustomer, addCustomer, updateCustomer, delCustomer, backCustomer} from "@/api/basicData/customer.js";
   import { ElMessageBox } from "element-plus";
   import { userListNoPage } from "@/api/system/user.js";
   import useUserStore from "@/store/modules/user";
   import { getToken } from "@/utils/auth.js";
+  import FileUpload from "@/components/AttachmentUpload/file/index.vue";
   const { proxy } = getCurrentInstance();
   const userStore = useUserStore();
 
@@ -673,21 +710,42 @@
 
   // 璇︽儏鐩稿叧
   const detailDialogVisible = ref(false);
+  const detailActiveTab = ref("negotiation");
   const detailForm = reactive({
     customerName: "",
     customerType: "",
-    taxpayerIdentificationNumber: "",
     companyPhone: "",
     companyAddress: "",
-    basicBankAccount: "",
-    bankAccount: "",
-    bankCode: "",
-    contactPerson: "",
-    contactPhone: "",
     maintainer: "",
     maintenanceTime: "",
   });
   const negotiationRecords = ref([]);
+
+  // 鍚堝悓璁板綍鐩稿叧
+  const contractList = ref([]);
+  const contractDialogVisible = ref(false);
+  const contractDialogTitle = ref("");
+  const contractFormRef = ref();
+  const contractForm = reactive({
+    id: null,
+    customerId: null,
+    masterContractNo: "",
+    entryDate: "",
+    entryPerson: "",
+    entryPersonId: null,
+    remark: "",
+    storageBlobDTOs: [],
+  });
+  const contractRules = {
+    masterContractNo: [
+      { required: true, message: "璇疯緭鍏ユ�诲悎鍚屽彿", trigger: "blur" },
+    ],
+    entryDate: [
+      { required: true, message: "璇烽�夋嫨褰曞叆鏃ユ湡", trigger: "change" },
+    ],
+  };
+  const contractFileDialogVisible = ref(false);
+  const currentContractFiles = ref([]);
 
   // 闄勪欢鐩稿叧
   const attachmentDialogVisible = ref(false);
@@ -717,25 +775,6 @@
       width: 220,
     },
     {
-      label: "绾崇◣浜鸿瘑鍒爜",
-      prop: "taxpayerIdentificationNumber",
-      width: 220,
-    },
-    {
-      label: "鍦板潃鍙婅仈绯绘柟寮�",
-      prop: "companyAddress",
-      width: 250,
-    },
-    {
-      label: "鑱旂郴浜�",
-      prop: "contactPerson",
-    },
-    {
-      label: "鑱旂郴鐢佃瘽",
-      prop: "contactPhone",
-      width: 150,
-    },
-    {
       label: "璺熻繘杩涘害",
       prop: "followUpLevel",
       width: 120,
@@ -744,21 +783,6 @@
       label: "璺熻繘鏃堕棿",
       prop: "followUpTime",
       width: 120,
-    },
-    {
-      label: "閾惰鍩烘湰鎴�",
-      prop: "basicBankAccount",
-      width: 220,
-    },
-    {
-      label: "閾惰璐﹀彿",
-      prop: "bankAccount",
-      width: 220,
-    },
-    {
-      label: "寮�鎴疯鍙�",
-      prop: "bankCode",
-      width: 220,
     },
     {
       label: "缁存姢浜�",
@@ -839,15 +863,6 @@
   // 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
   const operationType = ref("");
   const dialogFormVisible = ref(false);
-  const formYYs = ref({
-    // 鍏朵粬瀛楁...
-    contactList: [
-      {
-        contactPerson: "",
-        contactPhone: "",
-      },
-    ],
-  });
   const data = reactive({
     searchForm: {
       customerName: "",
@@ -856,35 +871,21 @@
     },
     form: {
       customerName: "",
-      taxpayerIdentificationNumber: "",
       companyAddress: "",
       companyPhone: "",
-      contactPerson: "",
-      contactPhone: "",
       maintainer: "",
       maintenanceTime: "",
-      basicBankAccount: "",
-      bankAccount: "",
-      bankCode: "",
       customerType: "",
       type: 0
     },
     rules: {
       customerName: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-      taxpayerIdentificationNumber: [
-        { required: true, message: "璇疯緭鍏�", trigger: "blur" },
-      ],
       companyAddress: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
       companyPhone: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-      // contactPerson: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-      // contactPhone: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
       maintainer: [{ required: false, message: "璇烽�夋嫨", trigger: "change" }],
       maintenanceTime: [
         { required: false, message: "璇烽�夋嫨", trigger: "change" },
       ],
-      basicBankAccount: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-      bankAccount: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
-      bankCode: [{ required: true, message: "璇疯緭鍏�", trigger: "blur" }],
       customerType: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
     },
   });
@@ -947,18 +948,6 @@
     },
   });
   const { searchForm, form, rules } = toRefs(data);
-  const addNewContact = () => {
-    formYYs.value.contactList.push({
-      contactPerson: "",
-      contactPhone: "",
-    });
-  };
-
-  const removeContact = index => {
-    if (formYYs.value.contactList.length > 1) {
-      formYYs.value.contactList.splice(index, 1);
-    }
-  };
   // 鏌ヨ鍒楄〃
   /** 鎼滅储鎸夐挳鎿嶄綔 */
   const handleQuery = () => {
@@ -1001,12 +990,6 @@
     operationType.value = type;
     form.value = {};
     form.value.maintainer = userStore.nickName;
-    formYYs.value.contactList = [
-      {
-        contactPerson: "",
-        contactPhone: "",
-      },
-    ];
     form.value.type = 0;
     form.value.maintenanceTime = getCurrentDate();
     userListNoPage().then(res => {
@@ -1015,14 +998,6 @@
     if (type === "edit") {
       getCustomer(row.id).then(res => {
         form.value = { ...res.data };
-        formYYs.value.contactList = res.data.contactPerson
-          .split(",")
-          .map((item, index) => {
-            return {
-              contactPerson: item,
-              contactPhone: res.data.contactPhone.split(",")[index],
-            };
-          });
       });
     }
     dialogFormVisible.value = true;
@@ -1041,15 +1016,6 @@
   };
   // 鎻愪氦鏂板
   const submitAdd = () => {
-    if (formYYs.value.contactList.length < 1) {
-      return proxy.$modal.msgWarning("璇疯嚦灏戞坊鍔犱竴涓仈绯讳汉");
-    }
-    form.value.contactPerson = formYYs.value.contactList
-      .map(item => item.contactPerson)
-      .join(",");
-    form.value.contactPhone = formYYs.value.contactList
-      .map(item => item.contactPhone)
-      .join(",");
     addCustomer(form.value).then(res => {
       proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
       closeDia();
@@ -1058,12 +1024,6 @@
   };
   // 鎻愪氦淇敼
   const submitEdit = () => {
-    form.value.contactPerson = formYYs.value.contactList
-      .map(item => item.contactPerson)
-      .join(",");
-    form.value.contactPhone = formYYs.value.contactList
-      .map(item => item.contactPhone)
-      .join(",");
     updateCustomer(form.value).then(res => {
       proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
       closeDia();
@@ -1123,6 +1083,36 @@
       })
       .catch(() => {
         proxy.$modal.msg("宸插彇娑�");
+      });
+  };
+
+  const back = () => {
+    if (selectedRows.value.length === 0) {
+      proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+      return;
+    }
+    const ids = selectedRows.value.map(item => item.id);
+    ElMessageBox.confirm("閫変腑鐨勫鎴峰皢娴佸叆鍏捣锛屾槸鍚︾‘璁わ紵", "娴佸叆鍏捣鎻愮ず", {
+      confirmButtonText: "纭",
+      cancelButtonText: "鍙栨秷",
+      type: "warning",
+    })
+      .then(() => {
+        tableLoading.value = true;
+        return Promise.all(ids.map(id => backCustomer(id)))
+          .then(() => {
+            proxy.$modal.msgSuccess("娴佸叆鍏捣鎴愬姛");
+            selectedRows.value = [];
+            getList();
+          })
+          .finally(() => {
+            tableLoading.value = false;
+          });
+      })
+      .catch(error => {
+        if (error === "cancel" || error === "close") {
+          proxy.$modal.msg("宸插彇娑�");
+        }
       });
   };
 
@@ -1264,20 +1254,132 @@
 
   // 鎵撳紑璇︽儏寮圭獥
   const openDetailDialog = row => {
+    detailActiveTab.value = "negotiation";
     getCustomer(row.id).then(res => {
       // 濉厖瀹㈡埛鍩烘湰淇℃伅
       Object.assign(detailForm, res.data);
+      detailForm.id = row.id; // 淇濆瓨瀹㈡埛ID
 
       // 鑾峰彇娲借皥杩涘害璁板綍
       negotiationRecords.value = res.data.followUpList || [];
 
       detailDialogVisible.value = true;
     });
+
+    // 鑾峰彇鍚堝悓璁板綍鍒楄〃
+    getContractList(row.id);
+  };
+
+  // 鑾峰彇鍚堝悓璁板綍鍒楄〃
+  const getContractList = customerId => {
+    getCustomerContractList(customerId).then(res => {
+      if (res.code === 200) {
+        contractList.value = res.data || [];
+      }
+    });
+  };
+
+  // 鏂板鍚堝悓璁板綍
+  const handleAddContract = () => {
+    contractDialogTitle.value = "鏂板鍚堝悓璁板綍";
+    contractForm.id = null;
+    contractForm.customerId = detailForm.id;
+    contractForm.masterContractNo = "";
+    contractForm.entryDate = "";
+    contractForm.entryPerson = userStore.nickName;
+    contractForm.entryPersonId = userStore.id;
+    contractForm.remark = "";
+    contractForm.storageBlobDTOs = [];
+    contractDialogVisible.value = true;
+  };
+
+  // 缂栬緫鍚堝悓璁板綍
+  const handleEditContract = row => {
+    contractDialogTitle.value = "缂栬緫鍚堝悓璁板綍";
+    getCustomerContractById(row.id).then(res => {
+      if (res.code === 200) {
+        contractForm.id = res.data.id;
+        contractForm.customerId = res.data.customerId;
+        contractForm.masterContractNo = res.data.masterContractNo;
+        contractForm.entryDate = res.data.entryDate;
+        contractForm.entryPerson = res.data.entryPerson;
+        contractForm.entryPersonId = res.data.entryPersonId;
+        contractForm.remark = res.data.remark;
+        contractForm.storageBlobDTOs = res.data.fileList || [];
+        contractDialogVisible.value = true;
+      }
+    });
+  };
+
+  // 鍒犻櫎鍚堝悓璁板綍
+  const handleDeleteContract = row => {
+    ElMessageBox.confirm("纭畾鍒犻櫎璇ュ悎鍚岃褰曞悧锛�", "鎻愮ず", {
+      type: "warning",
+    }).then(() => {
+      delCustomerContract(row.id).then(res => {
+        if (res.code === 200) {
+          proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+          getContractList(detailForm.id);
+        }
+      });
+    }).catch(() => {
+      proxy.$modal.msg("宸插彇娑�");
+    });
+  };
+
+  // 鎻愪氦鍚堝悓璁板綍琛ㄥ崟
+  const submitContractForm = () => {
+    proxy.$refs.contractFormRef.validate(valid => {
+      if (valid) {
+        const submitData = {
+          id: contractForm.id,
+          customerId: contractForm.customerId,
+          masterContractNo: contractForm.masterContractNo,
+          entryDate: contractForm.entryDate,
+          entryPerson: contractForm.entryPerson,
+          entryPersonId: contractForm.entryPersonId,
+          remark: contractForm.remark,
+          storageBlobDTOs: contractForm.storageBlobDTOs.map(f => ({ id: f.id })),
+        };
+
+        const request = contractForm.id ? updateCustomerContract : addCustomerContract;
+        request(submitData).then(res => {
+          if (res.code === 200) {
+            proxy.$modal.msgSuccess("鎿嶄綔鎴愬姛");
+            contractDialogVisible.value = false;
+            getContractList(detailForm.id);
+          }
+        });
+      }
+    });
+  };
+
+  // 鍏抽棴鍚堝悓璁板綍寮圭獥
+  const closeContractDialog = () => {
+    proxy.resetForm("contractFormRef");
+    contractDialogVisible.value = false;
+  };
+
+  // 鏌ョ湅鍚堝悓闄勪欢
+  const handleViewContractFiles = row => {
+    currentContractFiles.value = row.fileList || [];
+    contractFileDialogVisible.value = true;
+  };
+
+  // 涓嬭浇鍚堝悓闄勪欢
+  const downloadContractFile = row => {
+    if (row.downloadURL || row.url) {
+      proxy.$download.byUrl(row.downloadURL || row.url, row.name || row.originalFilename);
+    } else {
+      proxy.$modal.msgError("涓嬭浇閾炬帴涓嶅瓨鍦�");
+    }
   };
 
   // 鍏抽棴璇︽儏寮圭獥
   const closeDetailDialog = () => {
     detailDialogVisible.value = false;
+    detailActiveTab.value = "negotiation";
+    contractList.value = [];
   };
 
   // 淇敼娲借皥璁板綍
@@ -1533,6 +1635,10 @@
     font-size: 14px;
   }
 
+  .detail-tabs {
+    margin-top: 20px;
+  }
+
   .attachment-section {
     .upload-area {
       margin-bottom: 20px;

--
Gitblit v1.9.3