mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-30 10:59:42 +08:00
fix: 文件上传自动填充问题修复 (#4688)
Co-authored-by: wutong25 <wutong25@baidu.com>
This commit is contained in:
parent
6c1eed74da
commit
0896ed77ed
@ -316,6 +316,7 @@ order: 21
|
||||
| concurrency | `number` | | 分块上传时并行个数 |
|
||||
| documentation | `string` | | 文档内容 |
|
||||
| documentLink | `string` | | 文档链接 |
|
||||
| initAutoFill | `boolean` | `true` | 初始化时是否自动填充 |
|
||||
|
||||
## 事件表
|
||||
|
||||
|
@ -318,6 +318,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
||||
multiple: false,
|
||||
autoUpload: true,
|
||||
hideUploadButton: false,
|
||||
initAutoFill: true,
|
||||
stateTextMap: {
|
||||
init: '',
|
||||
pending: '等待上传',
|
||||
@ -428,7 +429,12 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.syncAutoFill();
|
||||
if (this.initAutoFill) {
|
||||
const {formInited, addHook} = this.props;
|
||||
formInited || !addHook
|
||||
? this.syncAutoFill()
|
||||
: addHook(this.syncAutoFill, 'init');
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: FileProps) {
|
||||
@ -473,16 +479,14 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
||||
return obj;
|
||||
})
|
||||
.filter(item => item);
|
||||
this.setState(
|
||||
{
|
||||
files: files
|
||||
},
|
||||
this.syncAutoFill
|
||||
);
|
||||
} else if (prevProps.value !== props.value && !this.initAutoFill) {
|
||||
this.initAutoFill = true;
|
||||
this.syncAutoFill();
|
||||
}
|
||||
|
||||
this.setState(
|
||||
{
|
||||
files: files
|
||||
},
|
||||
this.syncAutoFill
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -940,7 +944,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
||||
// 排除自身的字段,否则会无限更新state
|
||||
const excludeSelfAutoFill = omit(autoFill, name || '');
|
||||
|
||||
if (!isEmpty(excludeSelfAutoFill) && onBulkChange && this.initAutoFill) {
|
||||
if (!isEmpty(excludeSelfAutoFill) && onBulkChange) {
|
||||
const files = this.state.files.filter(
|
||||
file => ~['uploaded', 'init', 'ready'].indexOf(file.state as string)
|
||||
);
|
||||
|
@ -448,7 +448,12 @@ export default class ImageControl extends React.Component<
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.syncAutoFill();
|
||||
if (this.initAutoFill) {
|
||||
const {formInited, addHook} = this.props;
|
||||
formInited || !addHook
|
||||
? this.syncAutoFill()
|
||||
: addHook(this.syncAutoFill, 'init');
|
||||
}
|
||||
}
|
||||
|
||||
componentDidUpdate(prevProps: ImageProps) {
|
||||
|
Loading…
Reference in New Issue
Block a user