fix: 修复InputFile组件的请求体中包含empty值的问题 (#2625)

This commit is contained in:
RickCole 2021-09-28 20:33:27 +08:00 committed by GitHub
parent 608b86f4c0
commit e1c9f44fa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -356,12 +356,11 @@ export default class FileControl extends React.Component<FileProps, FileState> {
if (value && value instanceof Blob) {
files = [value as any];
} else if (value) {
files = (
Array.isArray(value)
? value
: joinValues
? `${(value as any)[valueField] || value}`.split(delimiter)
: [value as any]
files = (Array.isArray(value)
? value
: joinValues
? `${(value as any)[valueField] || value}`.split(delimiter)
: [value as any]
)
.map(item => FileControl.valueToFile(item, props) as FileValue)
.filter(item => item);
@ -403,12 +402,11 @@ export default class FileControl extends React.Component<FileProps, FileState> {
let files: Array<FileValue> = [];
if (value) {
files = (
Array.isArray(value)
? value
: joinValues && typeof value === 'string'
? value.split(delimiter)
: [value as any]
files = (Array.isArray(value)
? value
: joinValues && typeof value === 'string'
? value.split(delimiter)
: [value as any]
)
.map(item => {
let obj = FileControl.valueToFile(
@ -884,6 +882,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
qsstringify({...api.data, ...params})
.split('&')
.filter(i => !!i)
.forEach(item => {
const parts = item.split('=');
fd.append(parts[0], decodeURIComponent(parts[1]));