Commit 55b538f1360bb517a7c02b4f74576cbcb36b466f

Authored by boyang
1 parent ddc5a9a0

fix: 修改客户列表

src/pages/Client/Client/index.tsx
... ... @@ -9,7 +9,6 @@ import {
9 9 postAdminClientQueryClientPage,
10 10 postServiceConstClientLevels,
11 11 postServiceConstClientSource,
12   - postServiceOrderQueryCustomerInformation,
13 12 } from '@/services';
14 13 import { downloadFile } from '@/services/order';
15 14 import { enumToSelect } from '@/utils';
... ... @@ -76,33 +75,8 @@ const columns = [
76 75 {
77 76 title: '课题组',
78 77 dataIndex: 'institutionContactName',
79   - valueType: 'select',
  78 + valueType: 'text',
80 79 hideInTable: true,
81   - fieldProps: {
82   - showSearch: true,
83   - // mode: 'tags', // 允许自定义输入
84   - },
85   - request: async (value, { params }) => {
86   - const keywords = value.keyWords;
87   - const { data } = await postServiceOrderQueryCustomerInformation({
88   - data: {
89   - name: 'institutionContactName',
90   - institutionContactName: keywords,
91   - },
92   - params: params,
93   - });
94   - let options = data
95   - .filter((c: any) => {
96   - return c.orderName === 'institutionCustomerUser';
97   - })
98   - .map((item: any) => {
99   - return {
100   - label: item.orderValue,
101   - value: item.orderValue,
102   - };
103   - });
104   - return options;
105   - },
106 80 },
107 81 {
108 82 title: '关联销售',
... ... @@ -195,15 +169,15 @@ const columns = [
195 169 valueType: 'dateTime',
196 170 hideInSearch: true,
197 171 },
198   - {
199   - title: '最新更进时间',
200   - key: 'since',
201   - width: 150,
202   - ellipsis: true,
203   - dataIndex: 'updateTime',
204   - valueType: 'dateTime',
205   - hideInSearch: true,
206   - },
  172 + // {
  173 + // title: '最新更进时间',
  174 + // key: 'since',
  175 + // width: 150,
  176 + // ellipsis: true,
  177 + // dataIndex: 'updateTime',
  178 + // valueType: 'dateTime',
  179 + // hideInSearch: true,
  180 + // },
207 181 // {
208 182 // title: '最新跟进时间',
209 183 // key: 'since',
... ... @@ -435,28 +409,55 @@ export default () => {
435 409 // 获取分页参数
436 410 const { current, pageSize, ...restParams } = params;
437 411  
438   - const res = await postAdminClientQueryClientPage({
439   - data: {
440   - ...restParams,
441   - groupFilter: groupFilter,
442   - // 明确传递分页参数
443   - current: current,
444   - pageSize: pageSize,
445   - },
446   - });
  412 + try {
  413 + const res = await postAdminClientQueryClientPage({
  414 + data: {
  415 + ...restParams,
  416 + groupFilter: groupFilter,
  417 + // 明确传递分页参数
  418 + current: current,
  419 + pageSize: pageSize,
  420 + },
  421 + });
  422 +
  423 + console.log('API Response:', res); // 添加日志来查看API返回的数据结构
  424 + console.log('API Response data:', res.data); // 查看data部分的结构
  425 +
  426 + // 检查返回数据结构
  427 + if (!res.data) {
  428 + console.error('API response data is undefined');
  429 + return { data: [], success: false, total: 0 };
  430 + }
  431 +
  432 + // 根据API返回的数据结构调整处理方式
  433 + let records = [];
  434 + let total = 0;
  435 +
  436 + // 处理两种可能的数据结构
  437 + if (res.data.records) {
  438 + // 标准分页结构 {records, total, current, pages, size}
  439 + records = res.data.records;
  440 + total = res.data.total || 0;
  441 + } else if (Array.isArray(res.data)) {
  442 + // 直接返回数组的情况
  443 + records = res.data;
  444 + total = res.data.length;
  445 + }
447 446  
448   - // 处理后端返回的实际数据格式
449   - // 根据提供的JSON,格式已经是 {records, total, current, pages, size, count}
450   - const result = {
451   - data: res.data?.records || [], // 数据源是 records 数组
452   - success: true,
453   - total: res.data?.total || 0, // 总记录数
454   - // 返回服务器端的分页信息,让ProTable使用
455   - current: res.data?.current || 1,
456   - pageSize: res.data?.size || 10,
457   - };
  447 + const result = {
  448 + data: records,
  449 + success: true,
  450 + total: total,
  451 + current: res.data.current || current || 1,
  452 + pageSize: res.data.size || pageSize || 10,
  453 + };
458 454  
459   - return result;
  455 + console.log('Processed result for ProTable:', result);
  456 + return result;
  457 + } catch (error) {
  458 + console.error('Error fetching client data:', error);
  459 + return { data: [], success: false, total: 0 };
  460 + }
460 461 }}
461 462 search={{
462 463 labelWidth: 'auto',
... ...