mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 10:59:42 +08:00
fix: 修复InputFile组件的请求体中包含empty值的问题 (#2625)
This commit is contained in:
parent
608b86f4c0
commit
e1c9f44fa5
@ -356,12 +356,11 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|||||||
if (value && value instanceof Blob) {
|
if (value && value instanceof Blob) {
|
||||||
files = [value as any];
|
files = [value as any];
|
||||||
} else if (value) {
|
} else if (value) {
|
||||||
files = (
|
files = (Array.isArray(value)
|
||||||
Array.isArray(value)
|
? value
|
||||||
? value
|
: joinValues
|
||||||
: joinValues
|
? `${(value as any)[valueField] || value}`.split(delimiter)
|
||||||
? `${(value as any)[valueField] || value}`.split(delimiter)
|
: [value as any]
|
||||||
: [value as any]
|
|
||||||
)
|
)
|
||||||
.map(item => FileControl.valueToFile(item, props) as FileValue)
|
.map(item => FileControl.valueToFile(item, props) as FileValue)
|
||||||
.filter(item => item);
|
.filter(item => item);
|
||||||
@ -403,12 +402,11 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|||||||
let files: Array<FileValue> = [];
|
let files: Array<FileValue> = [];
|
||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
files = (
|
files = (Array.isArray(value)
|
||||||
Array.isArray(value)
|
? value
|
||||||
? value
|
: joinValues && typeof value === 'string'
|
||||||
: joinValues && typeof value === 'string'
|
? value.split(delimiter)
|
||||||
? value.split(delimiter)
|
: [value as any]
|
||||||
: [value as any]
|
|
||||||
)
|
)
|
||||||
.map(item => {
|
.map(item => {
|
||||||
let obj = FileControl.valueToFile(
|
let obj = FileControl.valueToFile(
|
||||||
@ -884,6 +882,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|||||||
|
|
||||||
qsstringify({...api.data, ...params})
|
qsstringify({...api.data, ...params})
|
||||||
.split('&')
|
.split('&')
|
||||||
|
.filter(i => !!i)
|
||||||
.forEach(item => {
|
.forEach(item => {
|
||||||
const parts = item.split('=');
|
const parts = item.split('=');
|
||||||
fd.append(parts[0], decodeURIComponent(parts[1]));
|
fd.append(parts[0], decodeURIComponent(parts[1]));
|
||||||
|
Loading…
Reference in New Issue
Block a user