Merge pull request #67 from RickCole21/master

File添加下resetValue
This commit is contained in:
liaoxuezhi 2019-06-04 13:06:30 +08:00 committed by GitHub
commit f3bbb8e06c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 5 deletions

View File

@ -43,6 +43,7 @@ export interface FileProps extends FormControlProps {
[propName:string]: string; [propName:string]: string;
}; };
asBase64?: boolean; asBase64?: boolean;
resetValue?: string;
}; };
export interface FileX extends File { export interface FileX extends File {
@ -382,7 +383,8 @@ export default class FileControl extends React.Component<FileProps, FileState> {
joinValues, joinValues,
extractValue, extractValue,
valueField, valueField,
delimiter delimiter,
resetValue
} = this.props; } = this.props;
const files = this.state.files.filter(file => file.state == 'uploaded' || file.state == 'init'); const files = this.state.files.filter(file => file.state == 'uploaded' || file.state == 'init');
@ -394,12 +396,10 @@ export default class FileControl extends React.Component<FileProps, FileState> {
} else if (extractValue) { } else if (extractValue) {
value = Array.isArray(value) ? value.map((item: any) => item[valueField || 'value']) : value[valueField || 'value']; value = Array.isArray(value) ? value.map((item: any) => item[valueField || 'value']) : value[valueField || 'value'];
} }
} else {
value = typeof resetValue === 'undefined' ? '' : resetValue;
} }
// if (joinValues && value) {
// value = Array.isArray(value) ? value.map((item:any) => item[valueField || 'value']).join(delimiter || ',') : value[valueField || 'value']
// }
onChange(value); onChange(value);
} }