shadow-sm transition-all duration-300 hover:shadow-mdborder: noneborder-radius: 6pxhover:shadow-lg transition-all duration-200focus:border-primary focus:ring-1 focus:ring-primaryDatePicker 组件,时间选择使用 TimePicker 组件size="middle"YYYY-MM-DD,时间格式为 HH:mm:ssRangePicker 组件,格式为 [YYYY-MM-DD, YYYY-MM-DD]allowClearplaceholder="请选择日期"disabledDate={(current) => current && current > dayjs().endOf('day')}(根据业务需求调整)日期对象规范:始终使用dayjs对象而非原生Date对象,避免出现"isValid is not a function"错误
// 错误示例 - 使用原生Date对象
form.setFieldsValue({
noteDate: new Date(record.noteDate) // 导致验证失败
});
// 正确示例 - 使用dayjs对象
form.setFieldsValue({
noteDate: dayjs(record.noteDate) // 正常支持验证方法
});
日期时间转换规范:
// 日期对象转字符串(提交给后端)
const formatDate = (date: Dayjs | null) => {
return date ? date.format('YYYY-MM-DD') : '';
};
// 字符串转日期对象(从后端接收)
const parseDate = (str: string) => {
return str ? dayjs(str) : null;
};
// 日期时间对象转字符串
const formatDateTime = (date: Dayjs | null) => {
return date ? date.format('YYYY-MM-DD HH:mm:ss') : '';
};
// 日期范围转换
const formatDateRange = (range: [Dayjs | null, Dayjs | null]) => {
return range && range[0] && range[1]
? [range[0].format('YYYY-MM-DD'), range[1].format('YYYY-MM-DD')]
: [];
};
borderedrowClassName={(record, index) => index % 2 === 0 ? 'bg-white' : 'bg-gray-50'}scroll={{ x: 'max-content' }}flex items-center justify-between 布局Title level={2} 组件mb-6 flex justify-between items-center 样式bg-gradient-to-br from-blue-50 to-indigo-100shadow-lgStatistic 组件展示loading 属性hover:shadow-md transition-all duration-300hover:shadow-lg transition-all duration-200destroyOnClose 属性确保每次打开都是新实例centeredmaskClosable={false}message 组件提供反馈loading 属性显示加载指示器Popconfirm 组件二次确认统一使用App.useApp()获取message实例
import { App } from 'antd';
const { message } = App.useApp();
消息提示使用明确的类型区分:
message.success('操作成功');
message.error('操作失败');
message.warning('警告信息');
message.info('提示信息');
消息显示时长统一使用默认值,重要操作可适当延长:message.success('操作成功', 3);
Button type="link" 样式