update Cascader

This commit is contained in:
梁灏 2017-05-12 10:23:11 +08:00
parent 29264399e4
commit 952ddb518e
2 changed files with 23 additions and 2 deletions

View file

@ -29,7 +29,7 @@
:disabled="disabled" :disabled="disabled"
:change-on-select="changeOnSelect" :change-on-select="changeOnSelect"
:trigger="trigger"></Caspanel> :trigger="trigger"></Caspanel>
<div :class="[prefixCls + '-dropdown']" v-show="filterable && query !== ''"> <div :class="[prefixCls + '-dropdown']" v-show="filterable && query !== '' && querySelections.length">
<ul :class="[selectPrefixCls + '-dropdown-list']"> <ul :class="[selectPrefixCls + '-dropdown-list']">
<li <li
:class="[selectPrefixCls + '-item', { :class="[selectPrefixCls + '-item', {
@ -39,6 +39,7 @@
@click="handleSelectItem(index)" v-html="item.display"></li> @click="handleSelectItem(index)" v-html="item.display"></li>
</ul> </ul>
</div> </div>
<ul v-show="filterable && query !== '' && !querySelections.length" :class="[prefixCls + '-not-found-tip']"><li>{{ localeNotFoundText }}</li></ul>
</div> </div>
</Drop> </Drop>
</transition> </transition>
@ -113,6 +114,9 @@
filterable: { filterable: {
type: Boolean, type: Boolean,
default: false default: false
},
notFoundText: {
type: String
} }
}, },
data () { data () {
@ -135,7 +139,8 @@
[`${prefixCls}-show-clear`]: this.showCloseIcon, [`${prefixCls}-show-clear`]: this.showCloseIcon,
[`${prefixCls}-size-${this.size}`]: !!this.size, [`${prefixCls}-size-${this.size}`]: !!this.size,
[`${prefixCls}-visible`]: this.visible, [`${prefixCls}-visible`]: this.visible,
[`${prefixCls}-disabled`]: this.disabled [`${prefixCls}-disabled`]: this.disabled,
[`${prefixCls}-not-found`]: this.filterable && this.query !== '' && !this.querySelections.length
} }
]; ];
}, },
@ -163,6 +168,13 @@
inputPlaceholder () { inputPlaceholder () {
return this.filterable && this.currentValue.length ? null : this.localePlaceholder; return this.filterable && this.currentValue.length ? null : this.localePlaceholder;
}, },
localeNotFoundText () {
if (this.notFoundText === undefined) {
return this.t('i.select.noMatch');
} else {
return this.notFoundText;
}
},
querySelections () { querySelections () {
let selections = []; let selections = [];
function getSelections (arr, label, value) { function getSelections (arr, label, value) {

View file

@ -79,6 +79,15 @@
padding: 5px 0; padding: 5px 0;
} }
&-not-found-tip{
padding: 5px 0;
text-align: center;
color: @btn-disable-color;
}
&-not-found .@{select-dropdown-prefix-cls} {
width: 100%;
}
&-menu{ &-menu{
display: inline-block; display: inline-block;
min-width: 100px; min-width: 100px;