Skip to content

Commit af33c1b

Browse files
author
tangtanglove
committed
修复上传文件bug
1 parent 769fcde commit af33c1b

File tree

3 files changed

+22
-27
lines changed

3 files changed

+22
-27
lines changed

src/pages/Quark/components/FileUploader.tsx

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { useState } from 'react';
2-
import { Upload, message } from 'antd';
3-
import { PlusOutlined } from '@ant-design/icons';
2+
import { Upload, message, Button } from 'antd';
3+
import { UploadOutlined } from '@ant-design/icons';
44

55
export interface FileUploader {
66
title: string;
@@ -33,25 +33,22 @@ const FileUploader: React.FC<FileUploader> = ({ title, action, limitType, limitS
3333
size:null,
3434
status:''
3535
};
36-
if (file.response) {
37-
fileInfo.uid = file.response.data.id;
38-
fileInfo.id = file.response.data.id;
39-
fileInfo.name = file.response.data.name;
40-
fileInfo.url = file.response.data.url;
41-
fileInfo.size = file.response.data.size;
42-
fileInfo.status = 'done';
43-
}
36+
37+
fileInfo.uid = file.id;
38+
fileInfo.id = file.id;
39+
fileInfo.name = file.name;
40+
fileInfo.url = file.url;
41+
fileInfo.size = file.size;
42+
fileInfo.status = 'done';
43+
4444
fileList[key] = fileInfo;
4545
});
4646
triggerChange({ ...fileList });
4747
};
4848

4949
const uploadButton = (title:string) => {
5050
return(
51-
<div>
52-
<PlusOutlined />
53-
<div>{title}</div>
54-
</div>
51+
<Button icon={<UploadOutlined />}>{title}</Button>
5552
)
5653
}
5754

src/pages/Quark/components/FormItem.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
ProFormDateRangePicker,
1414
ProFormDateTimeRangePicker
1515
} from '@ant-design/pro-form';
16-
import { createFromIconfontCN,MinusCircleOutlined,PlusOutlined } from '@ant-design/icons';
16+
import { createFromIconfontCN,PlusOutlined } from '@ant-design/icons';
1717
import {
1818
Tree,
1919
Form,
@@ -26,8 +26,7 @@ import {
2626
InputNumber,
2727
Checkbox,
2828
Radio,
29-
Switch,
30-
Divider
29+
Switch
3130
} from 'antd';
3231
import locale from 'antd/es/date-picker/locale/zh_CN';
3332

@@ -317,6 +316,7 @@ const FormItem: React.FC<FormItem> = (props:any) => {
317316
component =
318317
<Form.Item
319318
key={item.key}
319+
name={field ? [field.name, item.name] : item.name}
320320
fieldKey={field ? [field.fieldKey, item.name] : item.name}
321321
label={item.label}
322322
tooltip={item.tooltip}

src/pages/Quark/components/ImageUploader.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ const ImageUploader: React.FC<ImageUploader> = ({ title, action, limitType, limi
3636
size:null,
3737
status:''
3838
};
39-
if (file.response) {
40-
fileInfo.uid = file.response.data.id;
41-
fileInfo.id = file.response.data.id;
42-
fileInfo.name = file.response.data.name;
43-
fileInfo.url = file.response.data.url;
44-
fileInfo.size = file.response.data.size;
45-
fileInfo.status = 'done';
46-
}
39+
40+
fileInfo.uid = file.id;
41+
fileInfo.id = file.id;
42+
fileInfo.name = file.name;
43+
fileInfo.url = file.url;
44+
fileInfo.size = file.size;
45+
fileInfo.status = 'done';
46+
4747
fileList[key] = fileInfo;
4848
});
4949
triggerChange({ ...fileList });
@@ -149,7 +149,6 @@ const ImageUploader: React.FC<ImageUploader> = ({ title, action, limitType, limi
149149
return false;
150150
}
151151
});
152-
153152
// 重组数据
154153
fileList = fileList.map((file: any,key: number) => {
155154
if (file.response) {
@@ -160,7 +159,6 @@ const ImageUploader: React.FC<ImageUploader> = ({ title, action, limitType, limi
160159
}
161160
return file;
162161
});
163-
164162
onFileListChange(fileList);
165163
}}
166164
>

0 commit comments

Comments
 (0)