123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363 |
- <template>
- <view v-if="node.visible" class="ly-tree-node" name="LyTreeNode" ref="node">
- <view class="ly-tree-node__content" :class="{
- 'ly-tree-node__content-current': node.isCurrent && highlightCurrent
- }" :style="{
- 'padding-left': '2px'
- }">
- <text v-if="node.isLeaf" class="ly-tree-node__expand-icon-holder">
- </text>
- <text v-else class="ly-tree-node__expand-icon" @click.stop="handleExpandIconClick">
- {{node.expanded ? iconExpand : iconCollapse}}
- </text>
- <ly-checkbox v-if="checkboxVisible || radioVisible" :type="checkboxVisible ? 'checkbox' : 'radio'"
- :checked="node.checked" :indeterminate="node.indeterminate" :disabled="!!node.disabled"
- @check="handleCheckChange(!node.checked)" />
- <image v-if="node.loading" class="ly-tree-node__loading-icon" mode="widthFix"
- src="data:image/gif;base64,R0lGODlhgACAAKIAAP///93d3bu7u5mZmQAA/wAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFBQAEACwCAAIAfAB8AAAD/0i63P4wygYqmDjrzbtflvWNZGliYXiubKuloivPLlzReD7al+7/Eh5wSFQIi8hHYBkwHUmD6CD5YTJLz49USuVYraRsZ7vtar7XnQ1Kjpoz6LRHvGlz35O4nEPP2O94EnpNc2sef1OBGIOFMId/inB6jSmPdpGScR19EoiYmZobnBCIiZ95k6KGGp6ni4wvqxilrqBfqo6skLW2YBmjDa28r6Eosp27w8Rov8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mzy9/T5+tvUzdN3Zp+GBAAh+QQJBQAEACwCAAIAfAB8AAAD/0i63P4wykmrvTjrzbv/YCiOZGmeaKqubOu+cCzPdArcQK2TOL7/nl4PSMwIfcUk5YhUOh3M5nNKiOaoWCuWqt1Ou16l9RpOgsvEMdocXbOZ7nQ7DjzTaeq7zq6P5fszfIASAYUBIYKDDoaGIImKC4ySH3OQEJKYHZWWi5iZG0ecEZ6eHEOio6SfqCaqpaytrpOwJLKztCO2jLi1uoW8Ir6/wCHCxMG2x7muysukzb230M6H09bX2Nna29zd3t/g4cAC5OXm5+jn3Ons7eba7vHt2fL16tj2+QL0+vXw/e7WAUwnrqDBgwgTKlzIsKHDh2gGSBwAccHEixAvaqTYcFCjRoYeNyoM6REhyZIHT4o0qPIjy5YTTcKUmHImx5cwE85cmJPnSYckK66sSAAj0aNIkypdyrSp06dQo0qdSrWq1atYs2rdyrWr169gwxZJAAA7">
- </image>
- <template v-if="node.icon && node.icon.length > 0">
- <image v-if="node.icon.indexOf('/') !== -1" class="ly-tree-node__icon" :src="node.icon" mode="widthFix"
- @error="handleImageError">
- </image>
- <text v-else class="ly-tree-node__icon" :class="node.icon">
- </text>
- </template>
- <text class="ly-tree-node__label" @click.stop="handleClick"
- :class="{active:node.label == '全县' || node.label == '部门' || node.label == '乡镇' || node.label == '街道'}">
- {{node.label}}
- </text>
- </view>
- <view v-if="(!renderAfterExpand || childNodeRendered)" class="ly-tree-node__children"
- :class="{'ly-tree-node__children-hide': !expanded}" role="group">
- <ly-tree-node v-for="cNodeId in node.childNodesId" :nodeId="cNodeId"
- :render-after-expand="renderAfterExpand" :show-checkbox="showCheckbox" :show-radio="showRadio"
- :check-only-leaf="checkOnlyLeaf" :key="getNodeKey(cNodeId)" :indent="indent" :icon-class="iconClass">
- </ly-tree-node>
- </view>
- </view>
- </template>
- <script>
- import {
- getNodeKey
- } from './tool/util.js';
- import lyCheckbox from './components/ly-checkbox.vue';
- // #ifdef APP-NVUE
- var domModule = weex.requireModule('d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AHQAZQBsAGwAbwAgAHAAcgBvAGoAZQBjAHQALgBoAHQAdABwADoALwAvAGYAbwBuAHQAZQBsAGwAbwAuAGMAbwBtAAAAAAIAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwECAQMBBAAKY2FyZXQtZG93bgtjYXJldC1yaWdodAAAAAA=')"
- });
- // #endif
- export default {
- name: 'LyTreeNode',
- componentName: 'LyTreeNode',
- components: {
- lyCheckbox
- },
- props: {
- nodeId: [Number, String],
- renderAfterExpand: {
- type: Boolean,
- default: true
- },
- checkOnlyLeaf: {
- type: Boolean,
- default: false
- },
- showCheckbox: {
- type: Boolean,
- default: false
- },
- showRadio: {
- type: Boolean,
- default: false
- },
- indent: Number,
- iconClass: String
- },
- data() {
- return {
- node: {
- indeterminate: false,
- checked: false,
- expanded: false
- },
- expanded: false,
- childNodeRendered: false,
- oldChecked: null,
- oldIndeterminate: null,
- highlightCurrent: false,
- iconExpand: '\ue8ec',
- iconCollapse: '\ue8ed'
- };
- },
- inject: ['tree'],
- computed: {
- checkboxVisible() {
- if (this.checkOnlyLeaf) {
- return this.showCheckbox && this.node.isLeaf;
- }
- return this.showCheckbox;
- },
- radioVisible() {
- if (this.checkOnlyLeaf) {
- return this.showRadio && this.node.isLeaf;
- }
- return this.showRadio;
- }
- },
- watch: {
- 'node.indeterminate'(val) {
- this.handleSelectChange(this.node.checked, val);
- },
- 'node.checked'(val) {
- this.handleSelectChange(val, this.node.indeterminate);
- },
- 'node.expanded'(val) {
- this.$nextTick(() => this.expanded = val);
- if (val) {
- this.childNodeRendered = true;
- }
- }
- },
- methods: {
- getNodeKey(nodeId) {
- let node = this.tree.store.root.getChildNodes([nodeId])[0];
- return getNodeKey(this.tree.nodeKey, node.data);
- },
- handleSelectChange(checked, indeterminate) {
- if (this.oldChecked !== checked && this.oldIndeterminate !== indeterminate) {
- if (this.checkOnlyLeaf && !this.node.isLeaf) return;
- if (this.checkboxVisible) {
- const allNodes = this.tree.store._getAllNodes();
- this.tree.$emit('check-change', {
- checked,
- indeterminate,
- node: this.node,
- data: this.node.data,
- checkedall: allNodes.every(item => item.checked)
- });
- } else {
- this.tree.$emit('radio-change', {
- checked,
- node: this.node,
- data: this.node.data,
- checkedall: false
- });
- }
- }
- if (!this.expanded && this.tree.expandOnCheckNode && checked) {
- this.handleExpandIconClick();
- }
- this.oldChecked = checked;
- this.indeterminate = indeterminate;
- },
- handleClick(e) {
- this.tree.store.setCurrentNode(this.node);
- this.tree.$emit('current-change', {
- node: this.node,
- data: this.tree.store.currentNode ? this.tree.store.currentNode.data : null,
- currentNode: this.tree.store.currentNode
- });
- this.tree.currentNode = this.node;
- if (this.tree.expandOnClickNode) {
- this.handleExpandIconClick();
- }
- if (this.tree.checkOnClickNode && !this.node.disabled) {
- (this.checkboxVisible || this.radioVisible) && this.handleCheckChange(!this.node.checked);
- }
- this.tree.$emit('node-click', this.node);
- // #ifdef APP-NVUE
- e.stopPropagation()
- // #endif
- },
- handleExpandIconClick() {
- if (this.node.isLeaf) return;
- if (this.expanded) {
- this.tree.$emit('node-collapse', this.node);
- this.node.collapse();
- } else {
- this.node.expand();
- this.tree.$emit('node-expand', this.node);
- if (this.tree.accordion) {
- uni.$emit(`${this.tree.elId}-tree-node-expand`, this.node);
- }
- }
- },
- handleCheckChange(checked) {
- if (this.node.disabled) return;
- if (this.checkboxVisible) {
- this.node.setChecked(checked, !(this.tree.checkStrictly || this.checkOnlyLeaf));
- } else {
- this.node.setRadioChecked(checked);
- }
- this.$nextTick(() => {
- this.tree.$emit('check', {
- node: this.node,
- data: this.node.data,
- checkedNodes: this.tree.store.getCheckedNodes(),
- checkedKeys: this.tree.store.getCheckedKeys(),
- halfCheckedNodes: this.tree.store.getHalfCheckedNodes(),
- halfCheckedKeys: this.tree.store.getHalfCheckedKeys()
- });
- });
- },
- handleImageError() {
- this.node.icon = this.tree.defaultNodeIcon;
- }
- },
- created() {
- if (!this.tree) {
- throw new Error('Can not find node\'s tree.');
- }
- const props = this.tree.props || {};
- const childrenKey = props['children'] || 'children';
- this.node = this.tree.store.nodesMap[this.nodeId];
- this.highlightCurrent = this.tree.highlightCurrent;
- if (this.node.expanded) {
- this.expanded = true;
- this.childNodeRendered = true;
- }
- this.$watch(`node.data.${childrenKey}`, () => {
- this.node.updateChildren();
- });
- if (this.tree.accordion) {
- uni.$on(`${this.tree.elId}-tree-node-expand`, node => {
- if (this.node.id !== node.id && this.node.level === node.level) {
- this.node.collapse();
- }
- });
- }
- },
- beforeDestroy() {
- this.$parent = null;
- }
- };
- </script>
- <style lang="scss" scoped>
- .ly-tree-node__content {
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- flex-direction: row;
- align-items: center;
- height: 90rpx;
- }
- .ly-tree-node__expand-icon-holder {
- width: 20rpx;
- }
- .ly-tree-node__icon {
- width: 20rpx;
- height: 20rpx;
- overflow: hidden;
- margin-right: 14rpx;
- }
- .ly-tree-node__loading-icon {
- margin-right: 16rpx;
- width: 20rpx;
- height: 20rpx;
- }
- .ly-tree-node__label {
- width: 100%;
- font-size: 42rpx;
- white-space: nowrap;
- /*超出的空白区域不换行*/
- overflow: hidden;
- /*超出隐藏*/
- text-overflow: ellipsis;
- /*文本超出显示省略号*/
- color: #fff;
- }
- .active {
- font-size: 44rpx;
- font-weight: 700;
- }
- .ly-tree-node__children {
- overflow: hidden;
- background-color: transparent
- }
- .ly-tree-node__children-hide {
- height: 0px;
- line-height: 0px;
- }
- .ly-tree-node__content-current {
- border-top: 1px solid;
- border-bottom: 1px solid;
- border-image: linear-gradient(to right, #3c94d4, #fff, #064279) 1;
- background: linear-gradient(to right, #3c94d4, #064279);
- }
- /* icon-start */
- /* #ifndef APP-NVUE */
- @font-face {
- font-family: "lyExpandIcons";
- src: url('data:font/truetype;charset=utf-8;base64,AAEAAAALAIAAAwAwR1NVQrD+s+0AAAE4AAAAQk9TLzI/YkrfAAABfAAAAFZjbWFwjN/tlQAAAeAAAAF+Z2x5ZvmkuOMAAANoAAAAcGhlYWQZ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A=') format('truetype');
- }
- /* #endif */
- .ly-tree-node__expand-icon {
- font-family: lyExpandIcons;
- font-size: 40rpx;
- font-style: normal;
- text-decoration: none;
- text-align: center;
- color: #DCDFE6;
- font-weight: 500;
- padding-right: 16rpx
- }
- /* icon-end */
- </style>
|