update Select

This commit is contained in:
梁灏 2019-09-09 14:41:42 +08:00
parent 255b69abd6
commit 74fb7cb03d
3 changed files with 14 additions and 8 deletions

View file

@ -51,9 +51,9 @@
<Select v-model="model13" filterable allow-create @on-create="handleCreate" style="width:260px">
<Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select>
<!-- <Select v-model="model12" multiple filterable allow-create @on-create="handleCreate" style="width:260px">-->
<!-- <Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>-->
<!-- </Select>-->
<Select v-model="model12" multiple filterable allow-create @on-create="handleCreate" style="width:260px">
<Option v-for="item in cityList" :value="item.value" :key="item.value">{{ item.label }}</Option>
</Select>
</div>
</template>
@ -68,7 +68,7 @@
},
{
value: 'London',
label: 'London2'
label: 'London'
},
{
value: 'Sydney',

View file

@ -225,7 +225,7 @@
this.$emit('on-input-focus');
},
onInputBlur () {
if (this.allowCreate && this.showNotFoundLabel && this.query !== '') return;
if (this.allowCreate && this.query !== '') return;
if (!this.values.length) this.query = ''; // #5155
this.$emit('on-input-blur');
},

View file

@ -85,7 +85,7 @@
import Drop from './dropdown.vue';
import {directive as clickOutside} from 'v-click-outside-x';
import TransferDom from '../../directives/transfer-dom';
import { oneOf } from '../../utils/assist';
import { oneOf, findComponentsDownward } from '../../utils/assist';
import Emitter from '../../mixins/emitter';
import Locale from '../../mixins/locale';
import SelectHead from './select-head.vue';
@ -341,7 +341,13 @@
},
showCreateItem () {
let state = false;
if (this.allowCreate && this.query !== '') state = true;
if (this.allowCreate && this.query !== '') {
state = true;
const $options = findComponentsDownward(this, 'iOption');
if ($options && $options.length) {
if ($options.find(item => item.showLabel === this.query)) state = false;
}
}
return state;
},
transitionName () {
@ -715,7 +721,7 @@
},
// 4.0.0 create new item
handleCreateItem () {
if (this.allowCreate && this.showNotFoundLabel) {
if (this.allowCreate && this.query !== '') {
const query = this.query;
this.$emit('on-create', query);
this.query = '';