You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.3 KiB

9 months ago
<template>
<view>
<ly-trees v-if="isReady" :props="props" :node-key="props.value" :load="loadNode" lazy :tree-data="treeData"
show-node-icon :defaultNodeIcon="defaultNodeIcon" />
</view>
</template>
<script>
import LyTrees from '@/components/ly-tree/ly-tree-s.vue'
import {
getSubordinate
} from '@/api/common.js'
let _self;
export default {
components: {
LyTrees
},
data() {
return {
isReady: false,
props: {
label: 'userName',
isLeaf: 'isLeaf',
value: "id",
icon: 'avatar'
},
defaultNodeIcon: '../../../static/image/5.png',
treeData: []
}
},
onLoad() {
_self = this
this.isReady = true;
},
computed: {
baseURL() {
return this.define.baseURL
}
},
methods: {
loadNode(node, resolve) {
if (node.level === 0) {
getSubordinate(node.level).then(res => {
let data = JSON.parse(JSON.stringify(res.data))
data.map((o) => {
o.avatar = _self.baseURL + o.avatar
return data
})
resolve(data)
})
} else {
getSubordinate(node.key).then(res => {
let data = JSON.parse(JSON.stringify(res.data))
data.map((o) => {
o.avatar = _self.baseURL + o.avatar
return data
})
resolve(data)
})
}
}
}
}
</script>
<style>
</style>