cascader Click icon to expand
This commit is contained in:
parent
5bc98a52cf
commit
b2c3442f20
2 changed files with 28 additions and 9 deletions
|
@ -44,6 +44,7 @@
|
|||
[selectPrefixCls + '-item-disabled']: item.disabled
|
||||
}]"
|
||||
v-for="(item, index) in querySelections"
|
||||
:key="index"
|
||||
@click="handleSelectItem(index)" v-html="item.display"></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
|
@ -7,9 +7,18 @@
|
|||
:prefix-cls="prefixCls"
|
||||
:data="item"
|
||||
:tmp-item="tmpItem"
|
||||
@click.native.stop="handleClickItem(item)"
|
||||
@mouseenter.native.stop="handleHoverItem(item)"></Casitem>
|
||||
</ul><Caspanel v-if="sublist && sublist.length" :prefix-cls="prefixCls" :data="sublist" :disabled="disabled" :trigger="trigger" :change-on-select="changeOnSelect"></Caspanel>
|
||||
@click.native.stop="handleClickItem(item, $event)"
|
||||
@mouseenter.native.stop="handleHoverItem(item)"
|
||||
></Casitem>
|
||||
</ul>
|
||||
<Caspanel
|
||||
v-if="sublist && sublist.length"
|
||||
:prefix-cls="prefixCls"
|
||||
:data="sublist"
|
||||
:disabled="disabled"
|
||||
:trigger="trigger"
|
||||
:change-on-select="changeOnSelect">
|
||||
</Caspanel>
|
||||
</span>
|
||||
</template>
|
||||
<script>
|
||||
|
@ -48,16 +57,25 @@
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
handleClickItem (item) {
|
||||
isIcon(node){
|
||||
let nodeName = (node.nodeName || "").toLocaleUpperCase();
|
||||
let isIvu = node.classList.contains("ivu-icon");
|
||||
if(nodeName == "I" && isIvu){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
},
|
||||
handleClickItem (item, ev) {
|
||||
let isIcon = this.isIcon(ev.target);
|
||||
if (this.trigger !== 'click' && item.children && item.children.length) return; // #1922
|
||||
this.handleTriggerItem(item, false, true);
|
||||
this.handleTriggerItem(item, false, true,isIcon);
|
||||
},
|
||||
handleHoverItem (item) {
|
||||
if (this.trigger !== 'hover' || !item.children || !item.children.length) return; // #1922
|
||||
this.handleTriggerItem(item, false, true);
|
||||
this.handleTriggerItem(item, false, true,false);
|
||||
},
|
||||
//#6158 -- default fromInit = false to fromInit = true;
|
||||
handleTriggerItem (item, fromInit = true, fromUser = false) {
|
||||
handleTriggerItem (item, fromInit = true, fromUser = false,isIcon=false) {
|
||||
if (item.disabled) return;
|
||||
|
||||
const cascader = findComponentUpward(this, 'Cascader');
|
||||
|
@ -90,7 +108,7 @@
|
|||
|
||||
if (item.children && item.children.length){
|
||||
this.sublist = item.children;
|
||||
this.dispatch('Cascader', 'on-result-change', {
|
||||
!isIcon && this.dispatch('Cascader', 'on-result-change', {
|
||||
lastValue: false,
|
||||
changeOnSelect: this.changeOnSelect,
|
||||
fromInit: fromInit
|
||||
|
@ -105,7 +123,7 @@
|
|||
}
|
||||
} else {
|
||||
this.sublist = [];
|
||||
this.dispatch('Cascader', 'on-result-change', {
|
||||
!isIcon && this.dispatch('Cascader', 'on-result-change', {
|
||||
lastValue: true,
|
||||
changeOnSelect: this.changeOnSelect,
|
||||
fromInit: fromInit
|
||||
|
|
Loading…
Reference in a new issue