Skip to content

Commit

Permalink
修复上传文件bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tangtanglove committed Oct 28, 2020
1 parent 769fcde commit af33c1b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 27 deletions.
25 changes: 11 additions & 14 deletions src/pages/Quark/components/FileUploader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { Upload, message } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import { Upload, message, Button } from 'antd';
import { UploadOutlined } from '@ant-design/icons';

export interface FileUploader {
title: string;
Expand Down Expand Up @@ -33,25 +33,22 @@ const FileUploader: React.FC<FileUploader> = ({ title, action, limitType, limitS
size:null,
status:''
};
if (file.response) {
fileInfo.uid = file.response.data.id;
fileInfo.id = file.response.data.id;
fileInfo.name = file.response.data.name;
fileInfo.url = file.response.data.url;
fileInfo.size = file.response.data.size;
fileInfo.status = 'done';
}

fileInfo.uid = file.id;
fileInfo.id = file.id;
fileInfo.name = file.name;
fileInfo.url = file.url;
fileInfo.size = file.size;
fileInfo.status = 'done';

fileList[key] = fileInfo;
});
triggerChange({ ...fileList });
};

const uploadButton = (title:string) => {
return(
<div>
<PlusOutlined />
<div>{title}</div>
</div>
<Button icon={<UploadOutlined />}>{title}</Button>
)
}

Expand Down
6 changes: 3 additions & 3 deletions src/pages/Quark/components/FormItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ProFormDateRangePicker,
ProFormDateTimeRangePicker
} from '@ant-design/pro-form';
import { createFromIconfontCN,MinusCircleOutlined,PlusOutlined } from '@ant-design/icons';
import { createFromIconfontCN,PlusOutlined } from '@ant-design/icons';
import {
Tree,
Form,
Expand All @@ -26,8 +26,7 @@ import {
InputNumber,
Checkbox,
Radio,
Switch,
Divider
Switch
} from 'antd';
import locale from 'antd/es/date-picker/locale/zh_CN';

Expand Down Expand Up @@ -317,6 +316,7 @@ const FormItem: React.FC<FormItem> = (props:any) => {
component =
<Form.Item
key={item.key}
name={field ? [field.name, item.name] : item.name}
fieldKey={field ? [field.fieldKey, item.name] : item.name}
label={item.label}
tooltip={item.tooltip}
Expand Down
18 changes: 8 additions & 10 deletions src/pages/Quark/components/ImageUploader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ const ImageUploader: React.FC<ImageUploader> = ({ title, action, limitType, limi
size:null,
status:''
};
if (file.response) {
fileInfo.uid = file.response.data.id;
fileInfo.id = file.response.data.id;
fileInfo.name = file.response.data.name;
fileInfo.url = file.response.data.url;
fileInfo.size = file.response.data.size;
fileInfo.status = 'done';
}

fileInfo.uid = file.id;
fileInfo.id = file.id;
fileInfo.name = file.name;
fileInfo.url = file.url;
fileInfo.size = file.size;
fileInfo.status = 'done';

fileList[key] = fileInfo;
});
triggerChange({ ...fileList });
Expand Down Expand Up @@ -149,7 +149,6 @@ const ImageUploader: React.FC<ImageUploader> = ({ title, action, limitType, limi
return false;
}
});

// 重组数据
fileList = fileList.map((file: any,key: number) => {
if (file.response) {
Expand All @@ -160,7 +159,6 @@ const ImageUploader: React.FC<ImageUploader> = ({ title, action, limitType, limi
}
return file;
});

onFileListChange(fileList);
}}
>
Expand Down

0 comments on commit af33c1b

Please sign in to comment.