Merge pull request #30 from catchonme/master

修复combo提交验证唯一值失败,修改单一item时只验证当前item的问题
This commit is contained in:
liaoxuezhi 2019-05-14 10:37:03 +08:00 committed by GitHub
commit 40710a6d2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 6 deletions

View File

@ -9,7 +9,8 @@ import {
} from '../../factory';
import {
ComboStore,
IComboStore
IComboStore,
IUniqueGroup
} from '../../store/combo';
import {
anyChanged,
@ -302,11 +303,15 @@ export default class FormControl extends React.Component<FormControlProps, any>
} = this.props;
if (this.model) {
this.model.validate(this.hook);
// 可能出现同名的表单项
form.getItemsByName(this.model.name)
.forEach(item => item !== this.model && item.validate())
if (form.parentStore && form.parentStore.storeType === 'ComboStore') {
const combo = form.parentStore as IComboStore;
const group = combo.uniques.get(this.model.name) as IUniqueGroup;
group && group.items.forEach(item => item.validate());
} else {
this.model.validate(this.hook);
form.getItemsByName(this.model.name)
.forEach(item => item !== this.model && item.validate())
}
}
}