Tree add global setting, update transition component, #5592 , close #5596

This commit is contained in:
梁灏 2019-04-10 10:21:31 +08:00
parent d082f8ccc9
commit 37f4b7a879
3 changed files with 61 additions and 6 deletions

View file

@ -67,9 +67,15 @@ const Transition = {
export default { export default {
name: 'CollapseTransition', name: 'CollapseTransition',
functional: true, functional: true,
render(h, { children }) { props: {
appear: Boolean
},
render(h, { children, props }) {
const data = { const data = {
on: Transition on: Transition,
props: {
appear: props.appear
}
}; };
return h('transition', data, children); return h('transition', data, children);

View file

@ -1,10 +1,10 @@
<template> <template>
<collapse-transition> <collapse-transition :appear="appear">
<ul :class="classes"> <ul :class="classes">
<li> <li>
<span :class="arrowClasses" @click="handleExpand"> <span :class="arrowClasses" @click="handleExpand">
<Icon v-if="showArrow" type="ios-arrow-forward"></Icon> <Icon v-if="showArrow" :type="arrowType" :custom="customArrowType" :size="arrowSize" />
<Icon v-if="showLoading" type="ios-loading" class="ivu-load-loop"></Icon> <Icon v-if="showLoading" type="ios-loading" class="ivu-load-loop" />
</span> </span>
<Checkbox <Checkbox
v-if="showCheckbox" v-if="showCheckbox"
@ -17,6 +17,7 @@
<span v-else :class="titleClasses" @click="handleSelect">{{ data.title }}</span> <span v-else :class="titleClasses" @click="handleSelect">{{ data.title }}</span>
<Tree-node <Tree-node
v-if="data.expand" v-if="data.expand"
:appear="appearByClickArrow"
v-for="(item, i) in children" v-for="(item, i) in children"
:key="i" :key="i"
:data="item" :data="item"
@ -61,11 +62,16 @@
showCheckbox: { showCheckbox: {
type: Boolean, type: Boolean,
default: false default: false
},
appear: {
type: Boolean,
default: false
} }
}, },
data () { data () {
return { return {
prefixCls: prefixCls prefixCls: prefixCls,
appearByClickArrow: false
}; };
}, },
computed: { computed: {
@ -127,6 +133,41 @@
}, },
children () { children () {
return this.data[this.childrenKey]; return this.data[this.childrenKey];
},
// 3.4.0, global setting customArrow arrow
arrowType () {
let type = 'ios-arrow-forward';
if (this.$IVIEW) {
if (this.$IVIEW.tree.customArrow) {
type = '';
} else if (this.$IVIEW.tree.arrow) {
type = this.$IVIEW.tree.arrow;
}
}
return type;
},
// 3.4.0, global setting
customArrowType () {
let type = '';
if (this.$IVIEW) {
if (this.$IVIEW.tree.customArrow) {
type = this.$IVIEW.tree.customArrow;
}
}
return type;
},
// 3.4.0, global setting
arrowSize () {
let size = '';
if (this.$IVIEW) {
if (this.$IVIEW.tree.arrowSize) {
size = this.$IVIEW.tree.arrowSize;
}
}
return size;
} }
}, },
methods: { methods: {
@ -134,6 +175,9 @@
const item = this.data; const item = this.data;
if (item.disabled) return; if (item.disabled) return;
// Vue.js 2.6.9 transition appear iView appear appear false
this.appearByClickArrow = true;
// async loading // async loading
if (item[this.childrenKey].length === 0) { if (item[this.childrenKey].length === 0) {
const tree = findComponentUpward(this, 'Tree'); const tree = findComponentUpward(this, 'Tree');

View file

@ -183,6 +183,11 @@ const install = function(Vue, opts = {}) {
arrow: opts.menu ? opts.menu.arrow ? opts.menu.arrow : '' : '', arrow: opts.menu ? opts.menu.arrow ? opts.menu.arrow : '' : '',
customArrow: opts.menu ? opts.menu.customArrow ? opts.menu.customArrow : '' : '', customArrow: opts.menu ? opts.menu.customArrow ? opts.menu.customArrow : '' : '',
arrowSize: opts.menu ? opts.menu.arrowSize ? opts.menu.arrowSize : '' : '' arrowSize: opts.menu ? opts.menu.arrowSize ? opts.menu.arrowSize : '' : ''
},
tree: {
arrow: opts.tree ? opts.tree.arrow ? opts.tree.arrow : '' : '',
customArrow: opts.tree ? opts.tree.customArrow ? opts.tree.customArrow : '' : '',
arrowSize: opts.tree ? opts.tree.arrowSize ? opts.tree.arrowSize : '' : ''
} }
}; };