This commit is contained in:
梁灏 2017-07-14 13:58:34 +08:00
parent da17044c8d
commit 98bf25b3ce
4 changed files with 9555 additions and 13399 deletions

View file

@ -53,6 +53,7 @@
type: [String, Number, Array],
default: ''
},
// 使 value
label: {
type: [String, Number, Array],
default: ''
@ -586,27 +587,31 @@
} else {
this.broadcast('iOption', 'on-query-change', val);
}
},
// remote
updateLabel () {
if (this.remote) {
if (!this.multiple && this.model !== '') {
this.selectToChangeQuery = true;
if (this.currentLabel === '') this.currentLabel = this.model;
this.lastQuery = this.currentLabel;
this.query = this.currentLabel;
} else if (this.multiple && this.model.length) {
if (this.currentLabel.length !== this.model.length) this.currentLabel = this.model;
this.selectedMultiple = this.model.map((item, index) => {
return {
value: item,
label: this.currentLabel[index]
};
});
}
}
}
},
mounted () {
this.modelToQuery();
// remote
if (this.remote) {
if (!this.multiple && this.model !== '') {
this.selectToChangeQuery = true;
if (this.currentLabel === '') this.currentLabel = this.model;
this.lastQuery = this.currentLabel;
this.query = this.currentLabel;
} else if (this.multiple && this.model.length) {
if (this.currentLabel.length !== this.model.length) this.currentLabel = this.model;
this.selectedMultiple = this.model.map((item, index) => {
return {
value: item,
label: this.currentLabel[index]
};
});
}
}
this.updateLabel();
this.$nextTick(() => {
this.broadcastQuery('');
});
@ -685,6 +690,10 @@
this.model = val;
if (val === '') this.query = '';
},
label (val) {
this.currentLabel = val;
this.updateLabel();
},
model () {
this.$emit('input', this.model);
this.modelToQuery();