AttachmentModal.tsx
2.03 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
69
70
71
72
73
74
75
76
77
78
79
import { getAliYunOSSFileNameFromUrl } from '@/utils';
import { ModalForm, ProFormUploadDragger } from '@ant-design/pro-components';
import { Button, Form } from 'antd';
import { cloneDeep } from 'lodash';
import { useEffect, useState } from 'react';
export default ({ data, onClose }) => {
let newData = cloneDeep(data);
const [fileList, setFileList] = useState<[]>([]);
const [form] = Form.useForm<{
subOrderId: '';
listAnnex: [];
}>();
let newListAnnex = newData.listAnnex?.map((path) => {
let i = 0;
return {
uid: i++,
name: getAliYunOSSFileNameFromUrl(path),
status: 'uploaded',
url: path,
response: { data: [path] },
};
});
newData.listAnnex = newListAnnex;
useEffect(() => {
setFileList(newData.listAnnex);
}, []);
return (
<ModalForm
width={500}
open
title="查看附件"
initialValues={newData}
form={form}
modalProps={{
onCancel: onClose,
}}
submitter={{
render: () => {
return [
<Button
key="back"
onClick={() => {
onClose();
}}
>
返回
</Button>,
];
},
}}
>
<ProFormUploadDragger
name="listAnnex"
action="/api/service/order/fileProcess"
disabled
fieldProps={{
headers: { Authorization: localStorage.getItem('token') },
// onRemove: (file) => {
// const index = fileList[listMeta.index].indexOf(file);
// console.log(index);
// const newFileList = fileList.slice();
// newFileList.splice(index, 1);
// setFileList(newFileList);
// },
// beforeUpload: (file) => {
// fileList[listMeta.index] = [...fileList[listMeta.index], file as RcFile];
// setFileList(fileList);
// return true;
// },
fileList,
// defaultFileList: itemFileList
}}
/>
</ModalForm>
);
};