import React from 'react'; import {Button, Form, Input, message, Modal, Radio, Upload} from 'antd'; // @ts-ignore import {useStateCB} from 'nice-hooks'; import {TableListItem} from '../data.d'; import {UploadOutlined} from '@ant-design/icons'; // 表单特殊字段 export interface FormValueType extends Partial { } export interface UpdateFormProps { onCancel: (flag?: boolean, formVals?: FormValueType) => void; onSubmit: (values: FormValueType) => void; updateModalVisible: boolean; values: Partial; } const FormItem = Form.Item; const formLayout = { labelCol: {span: 7}, wrapperCol: {span: 13}, }; const UpdateForm: React.FC = (props) => { const [formVals, setFormVals] = useStateCB(props.values); const [form] = Form.useForm(); const { onSubmit: handleUpdate, onCancel: handleUpdateModalVisible, updateModalVisible, values, } = props; const submit = async () => { const fieldsValue = await form.validateFields(); setFormVals({...formVals, ...fieldsValue},(newValue: FormValueType)=>{ handleUpdate(newValue); }); }; const modelFileProps = { action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76', // @ts-ignore onChange(info) { if (info.file.status === 'done') { setFormVals({...formVals, ...{"modelFile": info.file.response.url}}); message.success(`file uploaded successfully`); } else if (info.file.status === 'error') { message.error(`file upload failed.`); } } }; const vocabFileProps = { action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76', // @ts-ignore onChange(info) { if (info.file.status === 'done') { setFormVals({...formVals, ...{"vocabFile": info.file.response.url}}); message.success(`file uploaded successfully`); } else if (info.file.status === 'error') { message.error(`file upload failed.`); } } }; const labelFileProps = { action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76', // @ts-ignore onChange(info) { if (info.file.status === 'done') { setFormVals({...formVals, ...{"labelFile": info.file.response.url}}); message.success(`file uploaded successfully`); } else if (info.file.status === 'error') { message.error(`file upload failed.`); } } }; const renderFooter = () => { return ( <> ); }; return ( handleUpdateModalVisible()} >
aubert blstm
); }; export default UpdateForm;