Commit 37f4b7a8795d2b4cda4cce746b62cc8dd40b4cb0
1 parent
d082f8cc
Tree add global setting, update transition component, #5592 , close #5596
Showing
3 changed files
with
61 additions
and
6 deletions
Show diff stats
src/components/base/collapse-transition.js
| @@ -67,9 +67,15 @@ const Transition = { | @@ -67,9 +67,15 @@ const Transition = { | ||
| 67 | export default { | 67 | export default { |
| 68 | name: 'CollapseTransition', | 68 | name: 'CollapseTransition', |
| 69 | functional: true, | 69 | functional: true, |
| 70 | - render(h, { children }) { | 70 | + props: { |
| 71 | + appear: Boolean | ||
| 72 | + }, | ||
| 73 | + render(h, { children, props }) { | ||
| 71 | const data = { | 74 | const data = { |
| 72 | - on: Transition | 75 | + on: Transition, |
| 76 | + props: { | ||
| 77 | + appear: props.appear | ||
| 78 | + } | ||
| 73 | }; | 79 | }; |
| 74 | 80 | ||
| 75 | return h('transition', data, children); | 81 | return h('transition', data, children); |
src/components/tree/node.vue
| 1 | <template> | 1 | <template> |
| 2 | - <collapse-transition> | 2 | + <collapse-transition :appear="appear"> |
| 3 | <ul :class="classes"> | 3 | <ul :class="classes"> |
| 4 | <li> | 4 | <li> |
| 5 | <span :class="arrowClasses" @click="handleExpand"> | 5 | <span :class="arrowClasses" @click="handleExpand"> |
| 6 | - <Icon v-if="showArrow" type="ios-arrow-forward"></Icon> | ||
| 7 | - <Icon v-if="showLoading" type="ios-loading" class="ivu-load-loop"></Icon> | 6 | + <Icon v-if="showArrow" :type="arrowType" :custom="customArrowType" :size="arrowSize" /> |
| 7 | + <Icon v-if="showLoading" type="ios-loading" class="ivu-load-loop" /> | ||
| 8 | </span> | 8 | </span> |
| 9 | <Checkbox | 9 | <Checkbox |
| 10 | v-if="showCheckbox" | 10 | v-if="showCheckbox" |
| @@ -17,6 +17,7 @@ | @@ -17,6 +17,7 @@ | ||
| 17 | <span v-else :class="titleClasses" @click="handleSelect">{{ data.title }}</span> | 17 | <span v-else :class="titleClasses" @click="handleSelect">{{ data.title }}</span> |
| 18 | <Tree-node | 18 | <Tree-node |
| 19 | v-if="data.expand" | 19 | v-if="data.expand" |
| 20 | + :appear="appearByClickArrow" | ||
| 20 | v-for="(item, i) in children" | 21 | v-for="(item, i) in children" |
| 21 | :key="i" | 22 | :key="i" |
| 22 | :data="item" | 23 | :data="item" |
| @@ -61,11 +62,16 @@ | @@ -61,11 +62,16 @@ | ||
| 61 | showCheckbox: { | 62 | showCheckbox: { |
| 62 | type: Boolean, | 63 | type: Boolean, |
| 63 | default: false | 64 | default: false |
| 65 | + }, | ||
| 66 | + appear: { | ||
| 67 | + type: Boolean, | ||
| 68 | + default: false | ||
| 64 | } | 69 | } |
| 65 | }, | 70 | }, |
| 66 | data () { | 71 | data () { |
| 67 | return { | 72 | return { |
| 68 | - prefixCls: prefixCls | 73 | + prefixCls: prefixCls, |
| 74 | + appearByClickArrow: false | ||
| 69 | }; | 75 | }; |
| 70 | }, | 76 | }, |
| 71 | computed: { | 77 | computed: { |
| @@ -127,6 +133,41 @@ | @@ -127,6 +133,41 @@ | ||
| 127 | }, | 133 | }, |
| 128 | children () { | 134 | children () { |
| 129 | return this.data[this.childrenKey]; | 135 | return this.data[this.childrenKey]; |
| 136 | + }, | ||
| 137 | + // 3.4.0, global setting customArrow 有值时,arrow 赋值空 | ||
| 138 | + arrowType () { | ||
| 139 | + let type = 'ios-arrow-forward'; | ||
| 140 | + | ||
| 141 | + if (this.$IVIEW) { | ||
| 142 | + if (this.$IVIEW.tree.customArrow) { | ||
| 143 | + type = ''; | ||
| 144 | + } else if (this.$IVIEW.tree.arrow) { | ||
| 145 | + type = this.$IVIEW.tree.arrow; | ||
| 146 | + } | ||
| 147 | + } | ||
| 148 | + return type; | ||
| 149 | + }, | ||
| 150 | + // 3.4.0, global setting | ||
| 151 | + customArrowType () { | ||
| 152 | + let type = ''; | ||
| 153 | + | ||
| 154 | + if (this.$IVIEW) { | ||
| 155 | + if (this.$IVIEW.tree.customArrow) { | ||
| 156 | + type = this.$IVIEW.tree.customArrow; | ||
| 157 | + } | ||
| 158 | + } | ||
| 159 | + return type; | ||
| 160 | + }, | ||
| 161 | + // 3.4.0, global setting | ||
| 162 | + arrowSize () { | ||
| 163 | + let size = ''; | ||
| 164 | + | ||
| 165 | + if (this.$IVIEW) { | ||
| 166 | + if (this.$IVIEW.tree.arrowSize) { | ||
| 167 | + size = this.$IVIEW.tree.arrowSize; | ||
| 168 | + } | ||
| 169 | + } | ||
| 170 | + return size; | ||
| 130 | } | 171 | } |
| 131 | }, | 172 | }, |
| 132 | methods: { | 173 | methods: { |
| @@ -134,6 +175,9 @@ | @@ -134,6 +175,9 @@ | ||
| 134 | const item = this.data; | 175 | const item = this.data; |
| 135 | if (item.disabled) return; | 176 | if (item.disabled) return; |
| 136 | 177 | ||
| 178 | + // Vue.js 2.6.9 对 transition 的 appear 进行了调整,导致 iView 初始化时无动画,加此方法来判断通过点击箭头展开时,加 appear,否则初始渲染时 appear 为 false | ||
| 179 | + this.appearByClickArrow = true; | ||
| 180 | + | ||
| 137 | // async loading | 181 | // async loading |
| 138 | if (item[this.childrenKey].length === 0) { | 182 | if (item[this.childrenKey].length === 0) { |
| 139 | const tree = findComponentUpward(this, 'Tree'); | 183 | const tree = findComponentUpward(this, 'Tree'); |
src/index.js
| @@ -183,6 +183,11 @@ const install = function(Vue, opts = {}) { | @@ -183,6 +183,11 @@ const install = function(Vue, opts = {}) { | ||
| 183 | arrow: opts.menu ? opts.menu.arrow ? opts.menu.arrow : '' : '', | 183 | arrow: opts.menu ? opts.menu.arrow ? opts.menu.arrow : '' : '', |
| 184 | customArrow: opts.menu ? opts.menu.customArrow ? opts.menu.customArrow : '' : '', | 184 | customArrow: opts.menu ? opts.menu.customArrow ? opts.menu.customArrow : '' : '', |
| 185 | arrowSize: opts.menu ? opts.menu.arrowSize ? opts.menu.arrowSize : '' : '' | 185 | arrowSize: opts.menu ? opts.menu.arrowSize ? opts.menu.arrowSize : '' : '' |
| 186 | + }, | ||
| 187 | + tree: { | ||
| 188 | + arrow: opts.tree ? opts.tree.arrow ? opts.tree.arrow : '' : '', | ||
| 189 | + customArrow: opts.tree ? opts.tree.customArrow ? opts.tree.customArrow : '' : '', | ||
| 190 | + arrowSize: opts.tree ? opts.tree.arrowSize ? opts.tree.arrowSize : '' : '' | ||
| 186 | } | 191 | } |
| 187 | }; | 192 | }; |
| 188 | 193 |