|
@@ -163,17 +163,24 @@ export default {
|
|
|
},
|
|
|
//change事件处理
|
|
|
changeHandler(val) {
|
|
|
- this.$nextTick(() => {
|
|
|
- let selText = this.getSelectedText();
|
|
|
- this.$emit('input', val, selText) //v-model实现,需要触发input
|
|
|
- this.$emit('change', val, selText) //将原change事件暴露
|
|
|
- });
|
|
|
+ let selText = this.getSelectedText(val);
|
|
|
+ this.$emit('input', val, selText); //v-model实现,需要触发input
|
|
|
+ this.$emit('change', val, selText); //将原change事件暴露
|
|
|
},
|
|
|
/**
|
|
|
* 获取当前选中项的文本值
|
|
|
+ * @param {array} arrVal 多选的数组值对象
|
|
|
*/
|
|
|
- getSelectedText() {
|
|
|
- return this.$refs.cpsSelect.selected.label;
|
|
|
+ getSelectedText(arrVal) {
|
|
|
+ if (this.multiple) {
|
|
|
+ //多选
|
|
|
+ let isFlag = (arrVal instanceof Array);//多选必须传入数组对象
|
|
|
+ return isFlag ? this.optionList.filter((option) => arrVal.includes(option.value))
|
|
|
+ .map((option) => option.label).join(",") : "";
|
|
|
+ } else {
|
|
|
+ //单选
|
|
|
+ return this.$refs.cpsSelect.hoverOption.label;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|