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 |  742 ++++++++++++++++++++++++++++++++------------------------
 1 files changed, 420 insertions(+), 322 deletions(-)

diff --git a/src/views/basicData/customerFile/index.vue b/src/views/basicData/customerFile/index.vue
index 79b1616..1b8fe52 100644
--- a/src/views/basicData/customerFile/index.vue
+++ b/src/views/basicData/customerFile/index.vue
@@ -1,6 +1,6 @@
 <template>
   <div class="app-container">
-    <div class="search_form">
+    <div class="search_form" style="margin-bottom: 20px;">
       <div>
         <span class="search_title">瀹㈡埛鍚嶇О锛�</span>
         <el-input v-model="searchForm.customerName"
@@ -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="缁存姢浜猴細"
@@ -211,7 +148,8 @@
                  :limit="1"
                  accept=".xlsx, .xls"
                  :headers="upload.headers"
-                 :action="upload.url + '?updateSupport=' + upload.updateSupport"
+                 :action="upload.url"
+                 :data="upload.data"
                  :disabled="upload.isUploading"
                  :before-upload="upload.beforeUpload"
                  :on-progress="upload.onProgress"
@@ -390,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>
@@ -406,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>
@@ -459,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>
@@ -587,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>
@@ -605,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>
 
@@ -612,21 +642,25 @@
   import { onMounted, ref, reactive, getCurrentInstance, toRefs } from "vue";
   import { Search, Paperclip, Upload } from "@element-plus/icons-vue";
   import {
-    addCustomer,
-    delCustomer,
-    getCustomer,
-    listCustomer,
-    updateCustomer,
     addCustomerFollow,
     updateCustomerFollow,
     delCustomerFollow,
     addReturnVisit,
     getReturnVisit,
   } from "@/api/basicData/customerFile.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();
 
@@ -654,7 +688,7 @@
   const negotiationFormRef = ref();
   const negotiationForm = reactive({
     customerName: "",
-    customerId: "",
+		customerId: "",
     followUpMethod: "",
     followUpLevel: "",
     followUpTime: "",
@@ -676,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);
@@ -720,25 +775,6 @@
       width: 220,
     },
     {
-      label: "绾崇◣浜鸿瘑鍒爜",
-      prop: "taxpayerIdentificationNumber",
-      width: 220,
-    },
-    {
-      label: "鍦板潃鍙婅仈绯绘柟寮�",
-      prop: "addressPhone",
-      width: 250,
-    },
-    {
-      label: "鑱旂郴浜�",
-      prop: "contactPerson",
-    },
-    {
-      label: "鑱旂郴鐢佃瘽",
-      prop: "contactPhone",
-      width: 150,
-    },
-    {
       label: "璺熻繘杩涘害",
       prop: "followUpLevel",
       width: 120,
@@ -749,23 +785,26 @@
       width: 120,
     },
     {
-      label: "閾惰鍩烘湰鎴�",
-      prop: "basicBankAccount",
-      width: 220,
-    },
-    {
-      label: "閾惰璐﹀彿",
-      prop: "bankAccount",
-      width: 220,
-    },
-    {
-      label: "寮�鎴疯鍙�",
-      prop: "bankCode",
-      width: 220,
-    },
-    {
       label: "缁存姢浜�",
       prop: "maintainer",
+    },
+    {
+      label: "瀹㈡埛鏉ユ簮",
+      prop: "type",
+      dataType: "tag",
+      width: 100,
+      formatData: value => {
+        if (value === 1 || value === "1") {
+          return "鍏捣";
+        }
+        return "绉佹捣";
+      },
+      formatType: value => {
+        if (value === 1 || value === "1") {
+          return "warning";
+        }
+        return "success";
+      },
     },
     {
       label: "缁存姢鏃堕棿",
@@ -824,50 +863,29 @@
   // 鐢ㄦ埛淇℃伅琛ㄥ崟寮规鏁版嵁
   const operationType = ref("");
   const dialogFormVisible = ref(false);
-  const formYYs = ref({
-    // 鍏朵粬瀛楁...
-    contactList: [
-      {
-        contactPerson: "",
-        contactPhone: "",
-      },
-    ],
-  });
   const data = reactive({
     searchForm: {
       customerName: "",
       customerType: "",
+      type: 0
     },
     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" }],
     },
   });
@@ -882,6 +900,9 @@
     headers: { Authorization: "Bearer " + getToken() },
     // 涓婁紶鐨勫湴鍧�
     url: import.meta.env.VITE_APP_BASE_API + "/basic/customer/importData",
+    data: {
+      type: 0
+    },
     // 鏂囦欢涓婁紶鍓嶇殑鍥炶皟
     beforeUpload: file => {
       console.log("鏂囦欢鍗冲皢涓婁紶", file);
@@ -927,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 = () => {
@@ -954,8 +963,8 @@
     tableLoading.value = true;
     listCustomer({ ...searchForm.value, ...page }).then(res => {
       tableLoading.value = false;
-      tableData.value = res.records;
-      page.total = res.total;
+      tableData.value = res.data.records;
+      page.total = res.data.total;
     });
   };
   // 琛ㄦ牸閫夋嫨鏁版嵁
@@ -981,12 +990,7 @@
     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 => {
       userList.value = res.data;
@@ -994,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;
@@ -1020,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();
@@ -1037,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();
@@ -1062,7 +1043,7 @@
       type: "warning",
     })
       .then(() => {
-        proxy.download("/basic/customer/export", {}, "瀹㈡埛妗f.xlsx");
+        proxy.download("/basic/customer/export", {type: 0}, "瀹㈡埛妗f.xlsx");
       })
       .catch(() => {
         proxy.$modal.msg("宸插彇娑�");
@@ -1072,12 +1053,11 @@
   const handleDelete = () => {
     let ids = [];
     if (selectedRows.value.length > 0) {
-      // 妫�鏌ユ槸鍚︽湁浠栦汉缁存姢鐨勬暟鎹�
       const unauthorizedData = selectedRows.value.filter(
-        item => item.maintainer !== userStore.nickName
+        item => item.type === 1 || item.type === "1"
       );
       if (unauthorizedData.length > 0) {
-        proxy.$modal.msgWarning("涓嶅彲鍒犻櫎浠栦汉缁存姢鐨勬暟鎹�");
+        proxy.$modal.msgWarning("鍏捣鍒嗛厤鐨勫鎴蜂笉鑳藉垹闄�");
         return;
       }
       ids = selectedRows.value.map(item => item.id);
@@ -1093,7 +1073,7 @@
       .then(() => {
         tableLoading.value = true;
         delCustomer(ids)
-          .then(res => {
+          .then(() => {
             proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
             getList();
           })
@@ -1103,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("宸插彇娑�");
+        }
       });
   };
 
@@ -1146,7 +1156,7 @@
         if (reminderForm.id) {
           submitvalue.value = {
             id: reminderForm.id,
-            customerId: currentCustomerId.value,
+						customerId: currentCustomerId.value,
             isEnabled: reminderForm.reminderSwitch ? 1 : 0,
             content: reminderForm.reminderContent,
             reminderTime: reminderForm.reminderTime,
@@ -1161,8 +1171,6 @@
             remindUserId: userStore.id,
           };
         }
-
-        console.log("鎻愪氦鍥炶鎻愰啋鏁版嵁:", submitvalue.value);
 
         // 璋冪敤鎺ュ彛
         addReturnVisit(submitvalue.value)
@@ -1191,14 +1199,6 @@
     negotiationForm.followUpTime = "";
     negotiationForm.followerUserName = userStore.nickName; // 榛樿褰撳墠鐧诲綍浜�
     negotiationForm.content = "";
-    // {
-    // 	"customerId": 152,
-    // 	"followUpMethod": "鐢佃瘽娌熼��",
-    // 	"followUpLevel": "娌℃湁鎰忓悜",
-    // 	"followUpTime": "2026-03-04T15:30:00",
-    // 	"followerUserName": "绠$悊鍛樿处鍙�",
-    // 	"content": "111"
-    // }
     negotiationDialogVisible.value = true;
   };
 
@@ -1220,23 +1220,6 @@
 
         if (isEdit) {
           // 淇敼鎿嶄綔
-          console.log("淇敼娲借皥杩涘害鏁版嵁:", negotiationForm);
-          // 杩欓噷鍙互璋冪敤鏇存柊鎺ュ彛
-          // 瀹為檯椤圭洰涓渶瑕佹牴鎹悗绔帴鍙h繘琛岃皟鏁�
-          // 绀轰緥锛歶pdateCustomerFollow(negotiationForm).then(res => {
-          //   // 鏇存柊鏈湴鏁版嵁
-          //   const index = negotiationForm.editIndex;
-          //   negotiationRecords.value[index] = {
-          //     followUpTime: negotiationForm.followUpTime,
-          //     followUpMethod: negotiationForm.followUpMethod,
-          //     followUpLevel: negotiationForm.followUpLevel,
-          //     followerUserName: negotiationForm.followerUserName,
-          //     content: negotiationForm.content,
-          //     id: negotiationForm.id,
-          //   };
-          //   proxy.$modal.msgSuccess("淇敼鎴愬姛");
-          //   closeNegotiationDialog();
-          // });
           updateCustomerFollow(negotiationForm).then(res => {
             // 鏇存柊鏈湴鏁版嵁
             getCustomer(negotiationForm.customerId).then(res => {
@@ -1271,21 +1254,132 @@
 
   // 鎵撳紑璇︽儏寮圭獥
   const openDetailDialog = row => {
-    // 璋冪敤getCustomer鎺ュ彛鑾峰彇瀹㈡埛璇︽儏
+    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 = [];
   };
 
   // 淇敼娲借皥璁板綍
@@ -1293,7 +1387,7 @@
     // 灏嗗綋鍓嶈褰曟暟鎹~鍏呭埌琛ㄥ崟
     Object.assign(negotiationForm, {
       customerName: row.customerName,
-      customerId: row.customerId,
+			customerId: row.customerId,
       followUpMethod: row.followUpMethod,
       followUpLevel: row.followUpLevel,
       followUpTime: row.followUpTime,
@@ -1421,7 +1515,7 @@
   const downloadAttachment = row => {
     if (row.url) {
       // proxy.download(row.url, {}, row.name);
-      proxy.$download.name(row.url);
+			proxy.$download.byUrl(row.url, row.originalFilename);
     } else {
       proxy.$modal.msgError("涓嬭浇閾炬帴涓嶅瓨鍦�");
     }
@@ -1541,6 +1635,10 @@
     font-size: 14px;
   }
 
+  .detail-tabs {
+    margin-top: 20px;
+  }
+
   .attachment-section {
     .upload-area {
       margin-bottom: 20px;

--
Gitblit v1.9.3