|
@@ -1,12 +1,10 @@
|
|
|
-import React, {useEffect, useState} from 'react';
|
|
|
-import {Button, Form, Input, message, Modal, Radio, Upload} from 'antd';
|
|
|
-import {TableListItem} from '../data.d';
|
|
|
-import {UploadOutlined} from '@ant-design/icons';
|
|
|
+import React, { useState } from 'react';
|
|
|
+import { Button, Form, Input, message, Modal, Radio, Upload } from 'antd';
|
|
|
+import { TableListItem } from '../data.d';
|
|
|
+import { UploadOutlined } from '@ant-design/icons';
|
|
|
|
|
|
// 表单特殊字段
|
|
|
-export interface FormValueType extends Partial<TableListItem> {
|
|
|
-
|
|
|
-}
|
|
|
+export interface FormValueType extends Partial<TableListItem> {}
|
|
|
|
|
|
export interface UpdateFormProps {
|
|
|
onCancel: (flag?: boolean, formVals?: FormValueType) => void;
|
|
@@ -18,8 +16,8 @@ export interface UpdateFormProps {
|
|
|
const FormItem = Form.Item;
|
|
|
|
|
|
const formLayout = {
|
|
|
- labelCol: {span: 7},
|
|
|
- wrapperCol: {span: 13},
|
|
|
+ labelCol: { span: 7 },
|
|
|
+ wrapperCol: { span: 13 },
|
|
|
};
|
|
|
|
|
|
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
@@ -36,7 +34,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
|
|
|
const submit = async () => {
|
|
|
const fieldsValue = await form.validateFields();
|
|
|
- const newValue = {...formVals, ...fieldsValue};
|
|
|
+ const newValue = { ...formVals, ...fieldsValue };
|
|
|
setFormVals(newValue);
|
|
|
handleUpdate(newValue);
|
|
|
};
|
|
@@ -46,36 +44,36 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
// @ts-ignore
|
|
|
onChange(info) {
|
|
|
if (info.file.status === 'done') {
|
|
|
- setFormVals({...formVals, ...{"modelFile": info.file.response.url}});
|
|
|
+ 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}});
|
|
|
+ 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}});
|
|
|
+ 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 = () => {
|
|
@@ -92,61 +90,50 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
return (
|
|
|
<Modal
|
|
|
width={640}
|
|
|
- bodyStyle={{padding: '32px 40px 48px'}}
|
|
|
+ bodyStyle={{ padding: '32px 40px 48px' }}
|
|
|
destroyOnClose
|
|
|
title="配置模型"
|
|
|
visible={updateModalVisible}
|
|
|
footer={renderFooter()}
|
|
|
onCancel={() => handleUpdateModalVisible()}
|
|
|
>
|
|
|
- <Form
|
|
|
- {...formLayout}
|
|
|
- form={form}
|
|
|
- initialValues={formVals}
|
|
|
- >
|
|
|
+ <Form {...formLayout} form={form} initialValues={formVals}>
|
|
|
<FormItem
|
|
|
name="modelName"
|
|
|
label="模型名称"
|
|
|
- rules={[{required: true, message: '请输入规则名称!'}]}
|
|
|
+ rules={[{ required: true, message: '请输入规则名称!' }]}
|
|
|
>
|
|
|
- <Input placeholder="请输入"/>
|
|
|
+ <Input placeholder="请输入" />
|
|
|
</FormItem>
|
|
|
|
|
|
-
|
|
|
<FormItem
|
|
|
name="modelType"
|
|
|
label="模型类型"
|
|
|
- rules={[{required: true, message: '请选择模型类型!'}]}
|
|
|
+ rules={[{ required: true, message: '请选择模型类型!' }]}
|
|
|
>
|
|
|
<Radio.Group>
|
|
|
<Radio.Button value="0">aubert</Radio.Button>
|
|
|
<Radio.Button value="1">blstm</Radio.Button>
|
|
|
</Radio.Group>
|
|
|
</FormItem>
|
|
|
- <FormItem
|
|
|
- label="模型文件"
|
|
|
- >
|
|
|
+ <FormItem label="模型文件">
|
|
|
<Upload {...modelFileProps}>
|
|
|
<Button>
|
|
|
- <UploadOutlined/> Upload
|
|
|
+ <UploadOutlined /> Upload
|
|
|
</Button>
|
|
|
</Upload>
|
|
|
</FormItem>
|
|
|
- <FormItem
|
|
|
- label="词向量文件"
|
|
|
- >
|
|
|
+ <FormItem label="词向量文件">
|
|
|
<Upload {...vocabFileProps}>
|
|
|
<Button>
|
|
|
- <UploadOutlined/> Upload
|
|
|
+ <UploadOutlined /> Upload
|
|
|
</Button>
|
|
|
</Upload>
|
|
|
</FormItem>
|
|
|
- <FormItem
|
|
|
- label="标签文件"
|
|
|
- >
|
|
|
+ <FormItem label="标签文件">
|
|
|
<Upload {...labelFileProps}>
|
|
|
<Button>
|
|
|
- <UploadOutlined/> Upload
|
|
|
+ <UploadOutlined /> Upload
|
|
|
</Button>
|
|
|
</Upload>
|
|
|
</FormItem>
|
|
@@ -155,5 +142,4 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
|
|
|
);
|
|
|
};
|
|
|
|
|
|
-
|
|
|
export default UpdateForm;
|