6 changed files with 97 additions and 13 deletions
-
2.env
-
2package.json
-
13src/index.tsx
-
2src/pages/measure/components/MeasureDetail.tsx
-
62src/pages/rail/Upload.tsx
-
29src/pages/rail/railConfig.tsx
@ -1 +1 @@ |
|||||
REACT_APP_WS_URL=192.168.1.201:8080/ws |
|
||||
|
REACT_APP_WS_URL=192.168.1.200:8080/ws |
@ -0,0 +1,62 @@ |
|||||
|
import { Button, message, Upload, type UploadProps, Input, Form } from 'antd'; |
||||
|
import { UploadOutlined } from '@ant-design/icons'; |
||||
|
type ChildProps = { |
||||
|
cancel: () => void; |
||||
|
}; |
||||
|
|
||||
|
export default function UploadFile(props:ChildProps) { |
||||
|
|
||||
|
const uploadProps: UploadProps = { |
||||
|
name: 'file', |
||||
|
action: 'https://660d2bd96ddfa2943b33731c.mockapi.io/api/upload', |
||||
|
headers: { |
||||
|
authorization: 'authorization-text', |
||||
|
}, |
||||
|
onChange(info) { |
||||
|
if (info.file.status !== 'uploading') { |
||||
|
console.log(info.file, info.fileList); |
||||
|
} |
||||
|
if (info.file.status === 'done') { |
||||
|
message.success(`${info.file.name} file uploaded successfully`); |
||||
|
} else if (info.file.status === 'error') { |
||||
|
message.error(`${info.file.name} file upload failed.`); |
||||
|
} |
||||
|
}, |
||||
|
}; |
||||
|
|
||||
|
const layout = { |
||||
|
labelCol: { span: 8 }, |
||||
|
wrapperCol: { span: 16 }, |
||||
|
}; |
||||
|
const [form] = Form.useForm(); |
||||
|
const onFinish = (values: any) => { |
||||
|
console.log(values); |
||||
|
}; |
||||
|
|
||||
|
const onCancel = () => { |
||||
|
form.resetFields() |
||||
|
props.cancel(); |
||||
|
} |
||||
|
return (<div className='p-[3rem]'> |
||||
|
<Form |
||||
|
{...layout} |
||||
|
form={form} |
||||
|
name="control-hooks" |
||||
|
onFinish={onFinish} |
||||
|
style={{ maxWidth: 600 }} |
||||
|
> |
||||
|
<Form.Item name="name" label="轨形名称" rules={[{ required: true }]}> |
||||
|
<Input className="w-[200px]" placeholder="轨形名称"></Input> |
||||
|
</Form.Item> |
||||
|
<Form.Item name="fileData" label="选择文件" rules={[{ required: true , message:'请选择文件'}]}> |
||||
|
<Upload {...uploadProps}> |
||||
|
<Button icon={<UploadOutlined />}>选择轨形数据文件</Button> |
||||
|
</Upload> |
||||
|
</Form.Item> |
||||
|
<div className="pt-[1rem]" style={{ position: 'absolute', right: 20, textAlign: 'right' }}> |
||||
|
<Button onClick={onCancel}>取消</Button> |
||||
|
<Button type="primary" htmlType="submit" className="ml-[1rem]">确定</Button> |
||||
|
</div> |
||||
|
</Form> |
||||
|
</div>) |
||||
|
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue