Skip to content

Commit

Permalink
fixbug, see: #333
Browse files Browse the repository at this point in the history
  • Loading branch information
ZianeCui committed Mar 27, 2018
1 parent f2bd687 commit f04e257
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
9 changes: 4 additions & 5 deletions src/js/components/form/KLForm/KLFormItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ const KLFormItem = Validation.extend({
},
init() {
const parentValidator = this._parentValidator;
this.$watch('this.controls.length', (newValue, oldValue) => {
/* 处理kl-form-item下面kl-select数量变化的情况,当从没有变为有时,需要赋值 */
if (oldValue === undefined) {
return;
}
this.$watch('this.controls.length', () => {
if (parentValidator && parentValidator.initSelectorSource) {
parentValidator.initSelectorSource();
}
if (parentValidator && parentValidator.initFormItem) {
parentValidator.initFormItem();
}
});

this.$watch('required', function () {
Expand Down
5 changes: 3 additions & 2 deletions src/js/components/form/KLForm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ const KLForm = Validation.extend({
this.initSelectorSource();
this.initFormItem();
});

this.__reqSourceOnce = _.debounce(this.__reqSource.bind(this), 200, false);
},
initFormItem() {
const controls = this.controls;
Expand Down Expand Up @@ -85,8 +87,7 @@ const KLForm = Validation.extend({
if (!this.data.service || !this.selectors.length) {
return;
}

this.__reqSource();
this.__reqSourceOnce();
},
__getSourceKeys() {
return this.selectors.map($formitem => $formitem.data.sourceKey);
Expand Down
2 changes: 1 addition & 1 deletion src/js/util/validationMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ module.exports = function (Component) {
this.$on('destroy', function () {
const index = $outer.controls.indexOf(this);
if (index !== -1) {
$outer.controls = $outer.controls.splice(index, 1);
$outer.controls.splice(index, 1);
}
});
}
Expand Down

0 comments on commit f04e257

Please sign in to comment.