antd pro 使用心得

antd pro 使用心得

  • ProTable
    • 日期组件汉化
    • 自定义请求参数

ProTable

日期组件汉化

import locale from 'antd/es/date-picker/locale/zh_CN';
const columns = [
		...
		{
            title: '创建时间',
            dataIndex: 'created_at',
            valueType: 'dateTimeRange',
            formItemProps: { locale },
        }
	]

自定义请求参数

<ProTable
...
	request={async (params) => {
		let draft = { ...params };
		draft.page = params.current;
		draft.perPage = params.pageSize;
		draft.enterprise_user_id = enterpriseUser;
		if (draft.created_at) {
			[draft.createdAtStart, draft.createdAtEnd] = [...draft.created_at];
		}
		draft = Omit(draft, ['current', 'pageSize', 'created_at']);
		const data = await query(draft);
		return {
			data: data.data.data,
			page: params.current,
			total: data.data.total,
			success: data.code === 200,
		};
	}}
...
/>

你可能感兴趣的:(antd)