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