Explorar el Código

♻️ refactor(contracts): 优化合同列表客户信息展示逻辑

- 移除未使用的clientClient导入和ClientItem类型定义
- 删除冗余的客户列表查询逻辑
- 直接从合同数据中获取客户公司名称,简化渲染逻辑
yourname hace 8 meses
padre
commit
56a022f287
Se han modificado 1 ficheros con 2 adiciones y 17 borrados
  1. 2 17
      src/client/admin/pages/Contracts.tsx

+ 2 - 17
src/client/admin/pages/Contracts.tsx

@@ -4,14 +4,13 @@ import ClientSelect from '@/client/admin/components/ClientSelect';
 import { App } from 'antd';
 import { PlusOutlined, EditOutlined, DeleteOutlined, SearchOutlined, FileTextOutlined } from '@ant-design/icons';
 import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
-import { hetongClient, clientClient } from '@/client/api';
+import { hetongClient } from '@/client/api';
 import type { InferResponseType } from 'hono/client';
 import dayjs from 'dayjs';
 
 // 定义类型
 type HetongItem = InferResponseType<typeof hetongClient.$get, 200>['data'][0];
 type HetongListResponse = InferResponseType<typeof hetongClient.$get, 200>;
-type ClientItem = InferResponseType<typeof clientClient.$get, 200>['data'][0];
 
 const Contracts: React.FC = () => {
   const {message} = App.useApp();
@@ -25,16 +24,6 @@ const Contracts: React.FC = () => {
   });
   const queryClient = useQueryClient();
   
-  // 获取客户列表
-  const { data: clientsData } = useQuery({
-    queryKey: ['clients'],
-    queryFn: async () => {
-      const response = await clientClient.$get({ query: { page: 1, pageSize: 1000 } });
-      if (response.status !== 200) throw new Error('Failed to fetch clients');
-      return response.json() as Promise<InferResponseType<typeof clientClient.$get, 200>>;
-    }
-  });
-  
   // 获取合同列表数据
   const fetchContracts = async ({ page, pageSize }: { page: number; pageSize: number }): Promise<HetongListResponse> => {
     const response = await hetongClient.$get({ query: { page, pageSize, keyword: searchText } });
@@ -179,12 +168,8 @@ const Contracts: React.FC = () => {
     },
     {
       title: '客户',
-      dataIndex: 'clientId',
+      dataIndex: ['client','companyName'],
       key: 'clientId',
-      render: (clientId: string) => {
-        const client = clientsData?.data.find(c => c.id.toString() === clientId);
-        return client ? client.companyName : '-';
-      },
     },
     {
       title: '合同类型',