import React from 'react'; import { message } from 'antd'; import { FormItem, Radio, combinePage, InputNumber, TextArea } from 'common'; import { PageForm, useInfo, UploadInput, SelectMenu } from 'components'; import { options } from './config'; import { info } from 'apis'; type TParams = { id?: string }; export default combinePage(({ history, match }) => { const { id } = match.params; const { setData, setLoading, pageFormProps } = useInfo({ defaultData: { hot: 0, priority: 0, status: 1 }, getData: async () => { if (!id) return; setLoading('请求数据'); const res = await info.details(id); res.ok && setData(res.data); setLoading(false); }, onFinish: async (values: any) => { setLoading('正在保存'); if (id) values.id = id; // 编辑时需要带入 ID const res = await info[id ? 'edit' : 'add'](values); if (!res.ok) return setLoading(false); message.success(`${id ? '保存' : '新建'}成功`); history.goBack(); }, }); return (