| | |
| | | @dragleave.stop.prevent="isDragEnter = false" |
| | | @drop.stop.prevent="handleItemDrop($event, _self, _self.model)" |
| | | > |
| | | <div role="presentation" :class="wholeRowClasses" v-if="isWholeRow"> </div> |
| | | <i class="tree-icon tree-ocl" role="presentation" @click="handleItemToggle"></i> |
| | | <div role="presentation" :class="wholeRowClasses" v-if="isWholeRow">
|
| | |
|
| | | </div>
|
| | | <i
|
| | | class="tree-icon tree-ocl"
|
| | | role="presentation"
|
| | | @click="handleItemToggle"
|
| | | ></i>
|
| | | <div :class="anchorClasses" v-on="events"> |
| | | <i |
| | | class="tree-icon tree-checkbox" |
| | |
| | | @click.stop="handleCheckbox($event)" |
| | | ></i> |
| | | <slot :vm="this" :model="model"> |
| | | <i :class="themeIconClasses" role="presentation" v-if="!model.loading"></i> |
| | | <i
|
| | | :class="themeIconClasses"
|
| | | role="presentation"
|
| | | v-if="!model.loading"
|
| | | ></i>
|
| | | <span v-html="model[textFieldName]"></span> |
| | | </slot> |
| | | </div> |
| | | <ul role="group" ref="group" class="tree-children" v-if="isFolder" :style="groupStyle"> |
| | | <ul
|
| | | role="group"
|
| | | ref="group"
|
| | | class="tree-children"
|
| | | v-if="isFolder"
|
| | | :style="groupStyle"
|
| | | >
|
| | | <tree-item |
| | | v-for="(child, index) in model[childrenFieldName]" |
| | | :key="index" |
| | |
| | | > |
| | | <template slot-scope="_"> |
| | | <slot :vm="_.vm" :model="_.model"> |
| | | <i :class="_.vm.themeIconClasses" role="presentation" v-if="!model.loading"></i> |
| | | <i
|
| | | :class="_.vm.themeIconClasses"
|
| | | role="presentation"
|
| | | v-if="!model.loading"
|
| | | ></i>
|
| | | <span v-html="_.model[textFieldName]"></span> |
| | | </slot> |
| | | </template> |
| | |
| | | dragOverBackgroundColor: { type: String }, |
| | | onItemClick: { |
| | | type: Function, |
| | | default: () => false |
| | | default: () => false,
|
| | | }, |
| | | onItemToggle: { |
| | | type: Function, |
| | | default: () => false |
| | | default: () => false,
|
| | | }, |
| | | onItemDragStart: { |
| | | type: Function, |
| | | default: () => false |
| | | default: () => false,
|
| | | }, |
| | | onItemDragEnd: { |
| | | type: Function, |
| | | default: () => false |
| | | default: () => false,
|
| | | }, |
| | | onItemDrop: { |
| | | type: Function, |
| | | default: () => false |
| | | default: () => false,
|
| | | }, |
| | | onCheckboxClick: { |
| | | type: Function, |
| | | default: () => false |
| | | default: () => false,
|
| | | }, |
| | | klass: String |
| | | klass: String,
|
| | | }, |
| | | data() { |
| | | return { |
| | |
| | | isDragEnter: false, |
| | | model: this.data, |
| | | maxHeight: 0, |
| | | events: {} |
| | | events: {},
|
| | | }; |
| | | }, |
| | | watch: { |
| | |
| | | this.onItemToggle(this, this.model); |
| | | this.handleGroupMaxHeight(); |
| | | }, |
| | | deep: true |
| | | } |
| | | deep: true,
|
| | | },
|
| | | }, |
| | | computed: { |
| | | isShowCheckBox() { |
| | |
| | | { "tree-leaf": !this.isFolder }, |
| | | { "tree-loading": !!this.model.loading }, |
| | | { "tree-drag-enter": this.isDragEnter }, |
| | | { [this.klass]: !!this.klass } |
| | | { [this.klass]: !!this.klass },
|
| | | ]; |
| | | }, |
| | | anchorClasses() { |
| | |
| | | { "tree-anchor": true }, |
| | | { "tree-disabled": this.model.disabled }, |
| | | { "tree-selected": this.model.selected }, |
| | | { "tree-hovered": this.isHover } |
| | | { "tree-hovered": this.isHover },
|
| | | ]; |
| | | }, |
| | | wholeRowClasses() { |
| | | return [ |
| | | { "tree-wholerow": true }, |
| | | { "tree-wholerow-clicked": this.model.selected }, |
| | | { "tree-wholerow-hovered": this.isHover } |
| | | { "tree-wholerow-hovered": this.isHover },
|
| | | ]; |
| | | }, |
| | | themeIconClasses() { |
| | |
| | | { "tree-icon": true }, |
| | | { "tree-themeicon": true }, |
| | | { [this.model.icon]: !!this.model.icon }, |
| | | { "tree-themeicon-custom": !!this.model.icon } |
| | | { "tree-themeicon-custom": !!this.model.icon },
|
| | | ]; |
| | | }, |
| | | isWholeRow() { |
| | |
| | | ? "block" |
| | | : this.model.opened |
| | | ? "block" |
| | | : "none" |
| | | : "none",
|
| | | }; |
| | | } |
| | | },
|
| | | }, |
| | | methods: { |
| | | handleItemToggle(e) { |
| | |
| | | if (this.model.disabled) return; |
| | | this.model.selected = !this.model.selected; |
| | | this.onCheckboxClick(this, this.model, e); |
| | | } |
| | | },
|
| | | }, |
| | | created() { |
| | | const self = this; |
| | | const events = { |
| | | click: this.handleItemClick, |
| | | mouseover: this.handleItemMouseOver, |
| | | mouseout: this.handleItemMouseOut |
| | | mouseout: this.handleItemMouseOut,
|
| | | }; |
| | | for (let itemEvent in this.itemEvents) { |
| | | let itemEventCallback = this.itemEvents[itemEvent]; |
| | |
| | | }, |
| | | mounted() { |
| | | this.handleGroupMaxHeight(); |
| | | } |
| | | },
|
| | | }; |
| | | </script> |