From 44305d0d559f6b8e1e171c1c5ade4efd5aec2ed3 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期四, 22 十月 2026 22:18:08 +0800
Subject: [PATCH] feat(customer): 优化客户档案开放海域功能中的领用人显示逻辑

---
 src/views/basicData/customerFileOpenSea/index.vue |   63 ++++++++++++++++++++++++++-----
 1 files changed, 52 insertions(+), 11 deletions(-)

diff --git a/src/views/basicData/customerFileOpenSea/index.vue b/src/views/basicData/customerFileOpenSea/index.vue
index 31e5795..0a9305c 100644
--- a/src/views/basicData/customerFileOpenSea/index.vue
+++ b/src/views/basicData/customerFileOpenSea/index.vue
@@ -280,7 +280,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"
@@ -681,7 +682,6 @@
   import { onMounted, ref, reactive, getCurrentInstance, toRefs } from "vue";
   import { Search, Paperclip, Upload } from "@element-plus/icons-vue";
   import {
-    shareCustomer,
     addCustomerFollow,
     updateCustomerFollow,
     delCustomerFollow,
@@ -695,7 +695,8 @@
     updateCustomer,
     getCustomer,
     assignCustomer,
-    recycleCustomer
+    recycleCustomer,
+    shareCustomer,
   } from "@/api/basicData/customer.js";
 
   import { ElMessageBox } from "element-plus";
@@ -916,8 +917,13 @@
         {
           name: "鍥炴敹",
           type: "text",
+          disabled: row => isCustomerRecoveryLocked(row),
           showHide: row => row.usageStatus == 1,
           clickFun: row => {
+            if (isCustomerRecoveryLocked(row)) {
+              proxy.$modal.msgWarning("宸查鐢ㄥ苟涓旇閿�鍞ā鍧楀紩鐢ㄧ殑鍏捣瀹㈡埛涓嶈兘鍥炴敹");
+              return;
+            }
             recycle(row);
           },
         },
@@ -932,7 +938,12 @@
 				{
 					name: "缂栬緫",
 					type: "text",
-					clickFun: row => {
+          disabled: row => isCustomerEditLocked(row),
+          clickFun: row => {
+            if (isCustomerEditLocked(row)) {
+              proxy.$modal.msgWarning("宸查鐢ㄥ苟涓旇閿�鍞ā鍧楀紩鐢ㄧ殑鍏捣瀹㈡埛涓嶈兘缂栬緫");
+              return;
+            }
 						openForm("edit", row);
 					},
 				},
@@ -1020,6 +1031,9 @@
     headers: { Authorization: "Bearer " + getToken() },
     // 涓婁紶鐨勫湴鍧�
     url: import.meta.env.VITE_APP_BASE_API + "/basic/customer/importData",
+    data: {
+      type: 1
+    },
     // 鏂囦欢涓婁紶鍓嶇殑鍥炶皟
     beforeUpload: file => {
       console.log("鏂囦欢鍗冲皢涓婁紶", file);
@@ -1088,12 +1102,25 @@
     page.size = obj.limit;
     getList();
   };
+  // 棰嗙敤浜烘樉绀烘樀绉帮細浼樺厛鎸夌敤鎴稩D鏄犲皠锛屽洖閫�鍒扮櫥褰曞悕鍖归厤
+  const resolveUsageUserName = row => {
+    const user =
+      row.usageUser != null
+        ? userList.value.find(
+            item => Number(item.userId) === Number(row.usageUser)
+          )
+        : userList.value.find(item => item.userName === row.usageUserName);
+    return user?.nickName || row.usageUserName || "";
+  };
   const getList = () => {
     tableLoading.value = true;
     const { total, ...queryPage } = page;
     listCustomer({ ...searchForm.value, ...queryPage }).then(res => {
       tableLoading.value = false;
-      tableData.value = res.data.records;
+      tableData.value = (res.data.records || []).map(row => ({
+        ...row,
+        usageUserName: resolveUsageUserName(row),
+      }));
       page.total = res.data.total;
     });
   };
@@ -1117,6 +1144,10 @@
   }
   // 鎵撳紑寮规
   const openForm = (type, row) => {
+    if (type === "edit" && isCustomerEditLocked(row)) {
+      proxy.$modal.msgWarning("宸查鐢ㄥ苟涓旇閿�鍞ā鍧楀紩鐢ㄧ殑鍏捣瀹㈡埛涓嶈兘缂栬緫");
+      return;
+    }
     operationType.value = type;
     form.value = {};
     form.value.maintainer = userStore.nickName;
@@ -1146,6 +1177,11 @@
     }
     dialogFormVisible.value = true;
   };
+  const isCustomerSalesReferenced = row => Number(row?.salesReferenceFlag || 0) === 1;
+  const isCustomerRecoveryLocked = row => Number(row?.usageStatus || 0) === 1 && isCustomerSalesReferenced(row);
+  const isCustomerEditLocked = row => isCustomerSalesReferenced(row) && (
+    Number(row?.type) === 0 || (Number(row?.type) === 1 && Number(row?.usageStatus || 0) === 1)
+  );
   // 鎻愪氦琛ㄥ崟
   const submitForm = () => {
     proxy.$refs["formRef"].validate(valid => {
@@ -1220,7 +1256,7 @@
   const openShareDialog = row => {
     shareForm.id = row.id;
     shareForm.customerName = row.customerName;
-    shareForm.boundIds = [];
+    shareForm.boundIds = row.userIds || [];
     ensureUserList().then(() => {
       shareDialogVisible.value = true;
     });
@@ -1253,8 +1289,8 @@
         return;
       }
       shareCustomer({
-        customerId: shareForm.id,
-        boundIds: shareForm.boundIds,
+        id: shareForm.id,
+        userIds: shareForm.boundIds,
       }).then(() => {
         proxy.$modal.msgSuccess("鍏变韩鎴愬姛");
         closeShareDialog();
@@ -1288,7 +1324,7 @@
       type: "warning",
     })
       .then(() => {
-        proxy.download("/basic/customer/export", {}, "瀹㈡埛妗f.xlsx");
+        proxy.download("/basic/customer/export", {type: 1}, "瀹㈡埛妗f.xlsx");
       })
       .catch(() => {
         proxy.$modal.msg("宸插彇娑�");
@@ -1647,7 +1683,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("涓嬭浇閾炬帴涓嶅瓨鍦�");
     }
@@ -1708,7 +1744,12 @@
     return `${year}-${month}-${day}`;
   }
 
-  onMounted(() => {
+  onMounted(async () => {
+    try {
+      await ensureUserList();
+    } catch (error) {
+      // 鐢ㄦ埛鍒楄〃鍔犺浇澶辫触鏃朵粛灞曠ず鏁版嵁锛岄鐢ㄤ汉鍥為��涓烘帴鍙h繑鍥炲��
+    }
     getList();
   });
 </script>

--
Gitblit v1.9.3