From c069a398226e8c6489b9c5c0036bf0553cc66495 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 16 十月 2026 10:28:21 +0800
Subject: [PATCH] feat(crm): 添加业务模块客户选择功能

---
 src/views/mes/pro/mps/data.ts                 |    2 +
 src/views/mes/qc/oqc/index.vue                |    4 +-
 src/components/crm-customer-select.vue        |   18 +++++++-
 src/components/crm-customer-select-dialog.vue |   23 ++++++-----
 src/api/crm/customer/index.ts                 |   15 +++++++
 src/views/wls/productsales/data.ts            |    2 +
 src/views/wls/returnsales/data.ts             |    2 +
 src/views/mes/qc/oqc/data.ts                  |    3 +
 8 files changed, 54 insertions(+), 15 deletions(-)

diff --git a/src/api/crm/customer/index.ts b/src/api/crm/customer/index.ts
index 874fbc3..2259fae 100644
--- a/src/api/crm/customer/index.ts
+++ b/src/api/crm/customer/index.ts
@@ -63,6 +63,21 @@
   );
 }
 
+/** 鏌ヨ涓氬姟妯″潡瀹㈡埛鍒楄〃锛堜笉鍙� CRM 璐熻矗浜烘潈闄愯繃婊わ級 */
+export function getBusinessCustomerPage(params: PageParam) {
+  return requestClient.get<PageResult<CrmCustomerApi.Customer>>(
+    '/crm/customer/business-page',
+    { params },
+  );
+}
+
+/** 鏌ヨ涓氬姟妯″潡鍏宠仈瀹㈡埛璇︽儏锛堜笉鍙� CRM 璐熻矗浜烘潈闄愯繃婊わ級 */
+export function getBusinessCustomer(id: number) {
+  return requestClient.get<CrmCustomerApi.Customer>(
+    `/crm/customer/business-get?id=${id}`,
+  );
+}
+
 /** 鏌ヨ瀹㈡埛璇︽儏 */
 export function getCustomer(id: number) {
   return requestClient.get<CrmCustomerApi.Customer>(
diff --git a/src/components/crm-customer-select-dialog.vue b/src/components/crm-customer-select-dialog.vue
index a514f9c..0c5561b 100644
--- a/src/components/crm-customer-select-dialog.vue
+++ b/src/components/crm-customer-select-dialog.vue
@@ -7,19 +7,25 @@
 import { message, Modal, Tabs } from 'ant-design-vue';
 
 import { useVbenVxeGrid } from '#/adapter/vxe-table';
-import { getCustomerPage } from '#/api/crm/customer';
+import { getBusinessCustomerPage, getCustomerPage } from '#/api/crm/customer';
 
 defineOptions({ name: 'CrmCustomerSelectDialog' });
 
 const emit = defineEmits<{
   selected: [rows: CrmCustomerApi.Customer[]];
 }>();
+const props = defineProps<{ allCustomers: boolean }>();
 
 const open = ref(false);
 const multiple = ref(true);
 const selectedRows = ref<CrmCustomerApi.Customer[]>([]);
 const preSelectedIds = ref<number[]>([]);
 const sceneType = ref('1');
+
+function handleSceneTypeChange(key: number | string) {
+  sceneType.value = key.toString();
+  gridApi.query();
+}
 
 function getTableRows() {
   return gridApi.grid.getTableData().fullData as CrmCustomerApi.Customer[];
@@ -94,11 +100,6 @@
   }
 }
 
-function handleSceneTypeChange(key: number | string) {
-  sceneType.value = key.toString();
-  gridApi.query();
-}
-
 const gridColumns = [
   { field: 'name', title: '瀹㈡埛鍚嶇О', minWidth: 180 },
   { field: 'mobile', title: '鎵嬫満鍙�', width: 140 },
@@ -137,12 +138,14 @@
     proxyConfig: {
       ajax: {
         query: async ({ page }, formValues) => {
-          return await getCustomerPage({
+          const query = {
             pageNo: page.currentPage,
             pageSize: page.pageSize,
-            sceneType: sceneType.value,
             ...formValues,
-          });
+          };
+          return props.allCustomers
+            ? await getBusinessCustomerPage(query)
+            : await getCustomerPage({ ...query, sceneType: sceneType.value });
         },
       },
     },
@@ -226,7 +229,7 @@
     @ok="handleConfirm"
     @cancel="closeModal"
   >
-    <Tabs class="mb-2" @change="handleSceneTypeChange">
+    <Tabs v-if="!allCustomers" class="mb-2" @change="handleSceneTypeChange">
       <Tabs.TabPane key="1" tab="鎴戣礋璐g殑" />
       <Tabs.TabPane key="2" tab="鎴戝弬涓庣殑" />
       <Tabs.TabPane key="3" tab="涓嬪睘璐熻矗鐨�" />
diff --git a/src/components/crm-customer-select.vue b/src/components/crm-customer-select.vue
index 64dcc12..b55e90e 100644
--- a/src/components/crm-customer-select.vue
+++ b/src/components/crm-customer-select.vue
@@ -2,12 +2,13 @@
 import type { CrmCustomerApi } from '#/api/crm/customer';
 
 import { computed, ref, useAttrs, watch } from 'vue';
+import { useRoute } from 'vue-router';
 
 import { IconifyIcon } from '@vben/icons';
 
 import { Input, Tooltip } from 'ant-design-vue';
 
-import { getCustomer } from '#/api/crm/customer';
+import { getBusinessCustomer, getCustomer } from '#/api/crm/customer';
 
 import CrmCustomerSelectDialog from './crm-customer-select-dialog.vue';
 
@@ -16,6 +17,7 @@
 const props = withDefaults(
   defineProps<{
     allowClear?: boolean;
+    allCustomers?: boolean;
     disabled?: boolean;
     modelValue?: number;
     placeholder?: string;
@@ -26,6 +28,10 @@
     modelValue: undefined,
     placeholder: '璇烽�夋嫨瀹㈡埛',
   },
+);
+const route = useRoute();
+const useAllCustomers = computed(
+  () => props.allCustomers ?? !String(route.path).startsWith('/crm/'),
 );
 const emit = defineEmits<{
   change: [item: CrmCustomerApi.Customer | undefined];
@@ -53,7 +59,9 @@
   if (selectedItem.value?.id === id) {
     return;
   }
-  selectedItem.value = await getCustomer(id);
+  selectedItem.value = useAllCustomers.value
+    ? await getBusinessCustomer(id)
+    : await getCustomer(id);
 }
 
 watch(
@@ -129,5 +137,9 @@
       </Input>
     </Tooltip>
   </div>
-  <CrmCustomerSelectDialog ref="dialogRef" @selected="handleSelected" />
+  <CrmCustomerSelectDialog
+    ref="dialogRef"
+    :all-customers="useAllCustomers"
+    @selected="handleSelected"
+  />
 </template>
diff --git a/src/views/mes/pro/mps/data.ts b/src/views/mes/pro/mps/data.ts
index ba79f62..0ef3742 100644
--- a/src/views/mes/pro/mps/data.ts
+++ b/src/views/mes/pro/mps/data.ts
@@ -96,6 +96,7 @@
       label: '瀹㈡埛',
       component: markRaw(CrmCustomerSelect),
       componentProps: {
+        allCustomers: true,
         placeholder: '璇烽�夋嫨瀹㈡埛',
         disabled: !isCreate && !isEdit,
       },
@@ -161,6 +162,7 @@
       label: '瀹㈡埛',
       component: markRaw(CrmCustomerSelect),
       componentProps: {
+        allCustomers: true,
         placeholder: '璇烽�夋嫨瀹㈡埛',
       },
     },
diff --git a/src/views/mes/qc/oqc/data.ts b/src/views/mes/qc/oqc/data.ts
index e3c4a4c..bc0eb75 100644
--- a/src/views/mes/qc/oqc/data.ts
+++ b/src/views/mes/qc/oqc/data.ts
@@ -129,6 +129,7 @@
       dependencies: {
         triggerFields: ['sourceDocId'],
         componentProps: (values) => ({
+          allCustomers: true,
           disabled: !!values.sourceDocId,
           placeholder: '璇烽�夋嫨浜у搧鐗╂枡',
         }),
@@ -166,6 +167,7 @@
       label: '瀹㈡埛',
       component: markRaw(CrmCustomerSelect),
       componentProps: {
+        allCustomers: true,
         allowClear: true,
         placeholder: '璇烽�夋嫨瀹㈡埛锛堝彲涓嶅~锛�',
       },
@@ -340,6 +342,7 @@
       label: '瀹㈡埛',
       component: markRaw(CrmCustomerSelect),
       componentProps: {
+        allCustomers: true,
         placeholder: '璇烽�夋嫨瀹㈡埛',
       },
     },
diff --git a/src/views/mes/qc/oqc/index.vue b/src/views/mes/qc/oqc/index.vue
index 3782c48..63cbd99 100644
--- a/src/views/mes/qc/oqc/index.vue
+++ b/src/views/mes/qc/oqc/index.vue
@@ -55,8 +55,8 @@
       importApi: importOqc,
       fileName: '鍑鸿揣妫�楠屽崟瀵煎叆妯℃澘.xls',
       hints: [
-        '浠呭厑璁稿鍏� xls銆亁lsx 鏍煎紡鏂囦欢锛涘繀濉垪锛氭楠屽崟鍚嶇О銆佷骇鍝佺墿鏂欑紪鐮併�佸鎴峰悕绉般�佹湰娆″嚭璐ф暟閲忋�佸悎鏍煎搧鏁伴噺銆佷笉鍚堟牸鍝佹暟閲忋�佹娴嬫棩鏈熴�佸嚭璐ф棩鏈熴��',
-        '銆屼骇鍝佺墿鏂欑紪鐮併�嶉渶涓庛�岀墿鏂欑鐞嗐�嶄腑鐨勭紪鐮佸畬鍏ㄤ竴鑷达紱銆屽鎴峰悕绉般�嶉渶涓庛�孋RM 瀹㈡埛绠$悊銆嶄腑鐨勫悕绉颁竴鑷达紝涓斿繀椤诲湪褰撳墠鐧诲綍鐢ㄦ埛鐨勫鎴锋暟鎹潈闄愯寖鍥村唴銆�',
+        '浠呭厑璁稿鍏� xls銆亁lsx 鏍煎紡鏂囦欢锛涘繀濉垪锛氭楠屽崟鍚嶇О銆佷骇鍝佺墿鏂欑紪鐮併�佹湰娆″嚭璐ф暟閲忋�佸悎鏍煎搧鏁伴噺銆佷笉鍚堟牸鍝佹暟閲忋�佹娴嬫棩鏈熴�佸嚭璐ф棩鏈熴�傚鎴峰悕绉板彲閫夈��',
+        '銆屼骇鍝佺墿鏂欑紪鐮併�嶉渶涓庛�岀墿鏂欑鐞嗐�嶄腑鐨勭紪鐮佸畬鍏ㄤ竴鑷达紱濉啓瀹㈡埛鍚嶇О鏃讹紝闇�涓庛�孋RM 瀹㈡埛绠$悊銆嶄腑鐨勫鎴峰悕绉颁竴鑷淬��',
         '鍚堟牸鍝佹暟閲� + 涓嶅悎鏍煎搧鏁伴噺 蹇呴』绛変簬銆屾娴嬫暟閲忋�嶏紙鐣欑┖鏃惰嚜鍔ㄥ彇涓よ�呬箣鍜岋級锛涖�屾娴嬬粨鏋溿�嶆寜瀛楀吀鍚嶇О濉啓锛堟牎楠岄�氳繃 / 鏍¢獙涓嶉�氳繃锛夈��',
         '銆岃川妫�鏂规銆嶅~鏂规鍚嶇О锛岀暀绌哄垯鎸夌墿鏂欒嚜鍔ㄥ尮閰� OQC 鏂规锛涖�屾娴嬩汉鍛樸�嶇暀绌哄彇褰撳墠鐧诲綍鐢ㄦ埛锛涙棩鏈熸敮鎸� 2026-01-01 10:00:00 鎴� 2026-01-01銆�',
         '閫愯瀵煎叆锛屽け璐ヨ涓嶅奖鍝嶆垚鍔熻锛涘鍏ュ悗鐨勬楠屽崟涓恒�屽緟妫�楠屻�嶇姸鎬侊紝鍙湪鍒楄〃涓户缁紪杈戙�佸綍鍏ユ娴嬬粨鏋溿��',
diff --git a/src/views/wls/productsales/data.ts b/src/views/wls/productsales/data.ts
index ddfc5a3..923946c 100644
--- a/src/views/wls/productsales/data.ts
+++ b/src/views/wls/productsales/data.ts
@@ -191,6 +191,7 @@
       label: '瀹㈡埛',
       component: markRaw(CrmCustomerSelect),
       componentProps: {
+        allCustomers: true,
         disabled: isHeaderReadonly(formType),
         placeholder: '璇烽�夋嫨瀹㈡埛',
       },
@@ -298,6 +299,7 @@
       label: '瀹㈡埛',
       component: markRaw(CrmCustomerSelect),
       componentProps: {
+        allCustomers: true,
         placeholder: '璇烽�夋嫨瀹㈡埛',
       },
     },
diff --git a/src/views/wls/returnsales/data.ts b/src/views/wls/returnsales/data.ts
index 25abc11..8b96bbd 100644
--- a/src/views/wls/returnsales/data.ts
+++ b/src/views/wls/returnsales/data.ts
@@ -121,6 +121,7 @@
       label: '瀹㈡埛',
       component: markRaw(CrmCustomerSelect),
       componentProps: {
+        allCustomers: true,
         placeholder: '璇烽�夋嫨瀹㈡埛',
       },
       rules: 'selectRequired',
@@ -196,6 +197,7 @@
       label: '瀹㈡埛',
       component: markRaw(CrmCustomerSelect),
       componentProps: {
+        allCustomers: true,
         placeholder: '璇烽�夋嫨瀹㈡埛',
       },
     },

--
Gitblit v1.9.3