uploadModel.tsx
1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { PlusOutlined, VerticalAlignBottomOutlined } from '@ant-design/icons';
import {
ModalForm,
ProForm,
ProFormDateRangePicker,
ProFormSelect,
ProFormText,
} from '@ant-design/pro-components';
import { Button, Form, message } from 'antd';
import App from './uploadApp'
import { useState } from 'react';
import { postOrderErpOrderStagesImport } from '@/services/request';
import { RcFile } from 'antd/es/upload';
const waitTime = (time: number = 100) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, time);
});
};
export default ({toReload}) => {
const [form] = Form.useForm<{ name: string; company: string }>();
const [uploadFile, setUploadFile] = useState({})
function setUploadFileWay(value) {
console.log(value);
setUploadFile(value)
}
return (
<ModalForm<{
name: string;
company: string;
}>
title="新建表单"
trigger={
<Button type="primary">
<VerticalAlignBottomOutlined />
导入
</Button>
}
form={form}
autoFocusFirstInput
modalProps={{
destroyOnClose: true,
onCancel: () => console.log('run'),
}}
submitTimeout={2000}
onFinish={async (values) => {
const formData = new FormData();
formData.append('file', uploadFile as RcFile);
const res = await postOrderErpOrderStagesImport({
data: formData,
headers: {
'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundarynl6gT1BKdPWIejNq',
}
});
if (res) {
message.success('提交成功');
toReload()
return true;
}
}}
>
<App uploadFile={setUploadFile}></App>
</ModalForm>
);
};