2021-03-18 18:30:10 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
|
2021-03-19 10:00:41 +08:00
|
|
|
<el-tree :data="datas" :props="defaultProps" @node-click="handleNodeClick">
|
|
|
|
<span slot-scope="{ data }" class="custom-tree-node">
|
|
|
|
<span>
|
|
|
|
<span v-if="!!data.id">
|
|
|
|
<el-button
|
|
|
|
icon="el-icon-picture-outline"
|
|
|
|
type="text"
|
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
<span style="margin-left: 6px">{{ data.name }}</span>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</el-tree>
|
2021-03-18 18:30:10 +08:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { loadTree } from '@/api/panel/share'
|
2021-04-20 14:19:10 +08:00
|
|
|
import { uuid } from 'vue-uuid'
|
|
|
|
import { get } from '@/api/panel/panel'
|
2021-03-18 18:30:10 +08:00
|
|
|
export default {
|
|
|
|
name: 'ShareTree',
|
|
|
|
data() {
|
|
|
|
return {
|
2021-03-19 10:00:41 +08:00
|
|
|
datas: [],
|
2021-03-18 18:30:10 +08:00
|
|
|
defaultProps: {
|
|
|
|
children: 'children',
|
|
|
|
label: 'name'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.initData()
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
initData() {
|
|
|
|
const param = {}
|
|
|
|
loadTree(param).then(res => {
|
2021-03-19 10:00:41 +08:00
|
|
|
this.datas = res.data
|
2021-03-18 18:30:10 +08:00
|
|
|
})
|
|
|
|
},
|
|
|
|
handleNodeClick(data) {
|
2021-04-20 14:19:10 +08:00
|
|
|
get('panel/group/findOne/' + data.id).then(response => {
|
|
|
|
this.$store.commit('setComponentData', this.resetID(JSON.parse(response.data.panelData)))
|
|
|
|
this.$store.commit('setCanvasStyle', JSON.parse(response.data.panelStyle))
|
|
|
|
|
|
|
|
this.$store.dispatch('panel/setPanelInfo', data)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
resetID(data) {
|
2021-05-05 22:14:23 +08:00
|
|
|
if( data ) {
|
|
|
|
data.forEach(item => {
|
|
|
|
item.id = uuid.v1()
|
|
|
|
})
|
|
|
|
}
|
2021-04-20 14:19:10 +08:00
|
|
|
|
|
|
|
return data
|
2021-03-18 18:30:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|