|
|
@@ -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: '合同类型',
|