2021-03-18 18:30:10 +08:00
|
|
|
<template>
|
2021-11-09 18:23:45 +08:00
|
|
|
<el-col style="padding: 0 5px 0 5px;">
|
|
|
|
<el-row>
|
|
|
|
<span class="header-title">分享给我</span>
|
|
|
|
<div class="block" style="margin-top:8px;">
|
|
|
|
<el-tree :data="datas" :props="defaultProps" node-key="name" :default-expanded-keys="expandNodes" @node-click="handleNodeClick">
|
|
|
|
<span slot-scope="{ data }" class="custom-tree-node">
|
|
|
|
<span :class="!!data.msgNode ? 'msg-node-class': ''">
|
|
|
|
<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>
|
|
|
|
</div>
|
|
|
|
</el-row>
|
2021-03-18 18:30:10 +08:00
|
|
|
|
2021-11-09 18:23:45 +08:00
|
|
|
<el-row>
|
|
|
|
<span class="header-title">我分享的</span>
|
|
|
|
<div class="block" style="margin-top:8px;">
|
|
|
|
<el-tree :data="outDatas" :props="defaultProps" node-key="name" :default-expand-all="true" @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>
|
2021-03-19 10:00:41 +08:00
|
|
|
</span>
|
2021-11-09 18:23:45 +08:00
|
|
|
</el-tree>
|
|
|
|
</div>
|
|
|
|
</el-row>
|
|
|
|
</el-col>
|
2021-03-18 18:30:10 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-11-09 18:23:45 +08:00
|
|
|
import { loadTree, loadShareOutTree } from '@/api/panel/share'
|
2021-04-20 14:19:10 +08:00
|
|
|
import { uuid } from 'vue-uuid'
|
|
|
|
import { get } from '@/api/panel/panel'
|
2021-10-13 12:18:25 +08:00
|
|
|
import bus from '@/utils/bus'
|
2021-03-18 18:30:10 +08:00
|
|
|
export default {
|
|
|
|
name: 'ShareTree',
|
2021-07-03 18:01:30 +08:00
|
|
|
props: {
|
|
|
|
msgPanelIds: {
|
|
|
|
type: Array,
|
|
|
|
default: null
|
|
|
|
}
|
|
|
|
},
|
2021-03-18 18:30:10 +08:00
|
|
|
data() {
|
|
|
|
return {
|
2021-03-19 10:00:41 +08:00
|
|
|
datas: [],
|
2021-03-18 18:30:10 +08:00
|
|
|
defaultProps: {
|
|
|
|
children: 'children',
|
|
|
|
label: 'name'
|
2021-07-03 18:01:30 +08:00
|
|
|
},
|
2021-11-09 18:23:45 +08:00
|
|
|
expandNodes: [],
|
|
|
|
outDatas: []
|
2021-03-18 18:30:10 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
2021-07-03 18:01:30 +08:00
|
|
|
this.initData().then(res => {
|
|
|
|
this.datas = res.data
|
|
|
|
if (this.msgPanelIds && this.msgPanelIds.length > 0) {
|
|
|
|
this.expandMsgNode(this.msgPanelIds)
|
|
|
|
}
|
|
|
|
})
|
2021-11-09 18:23:45 +08:00
|
|
|
this.initOutData().then(res => {
|
|
|
|
this.outDatas = res.data
|
|
|
|
})
|
2021-03-18 18:30:10 +08:00
|
|
|
},
|
2021-07-03 18:01:30 +08:00
|
|
|
|
2021-03-18 18:30:10 +08:00
|
|
|
methods: {
|
|
|
|
initData() {
|
|
|
|
const param = {}
|
2021-07-03 18:01:30 +08:00
|
|
|
return loadTree(param)
|
2021-03-18 18:30:10 +08:00
|
|
|
},
|
2021-11-09 18:23:45 +08:00
|
|
|
initOutData() {
|
|
|
|
return loadShareOutTree()
|
|
|
|
},
|
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)
|
2021-10-13 12:18:25 +08:00
|
|
|
bus.$emit('set-panel-is-share')
|
2021-04-20 14:19:10 +08:00
|
|
|
})
|
|
|
|
},
|
|
|
|
resetID(data) {
|
2021-05-20 16:45:27 +08:00
|
|
|
if (data) {
|
2021-05-05 22:14:23 +08:00
|
|
|
data.forEach(item => {
|
2021-05-20 16:45:27 +08:00
|
|
|
item.type !== 'custom' && (item.id = uuid.v1())
|
2021-05-05 22:14:23 +08:00
|
|
|
})
|
|
|
|
}
|
2021-04-20 14:19:10 +08:00
|
|
|
|
|
|
|
return data
|
2021-07-03 18:01:30 +08:00
|
|
|
},
|
|
|
|
expandMsgNode(panelIds) {
|
2021-07-06 15:24:34 +08:00
|
|
|
// console.log(panelIds)
|
2021-07-03 18:01:30 +08:00
|
|
|
this.$nextTick(() => {
|
|
|
|
this.getMsgNodes(panelIds)
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getMsgNodes(panelIds) {
|
|
|
|
this.datas.forEach(item => {
|
|
|
|
if (item.children && item.children.length > 0) {
|
|
|
|
item.children.forEach(node => {
|
|
|
|
if (panelIds.includes(node.id)) {
|
|
|
|
node.msgNode = true
|
|
|
|
this.expandNodes.push(item.name)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
2021-03-18 18:30:10 +08:00
|
|
|
}
|
2021-07-03 18:01:30 +08:00
|
|
|
|
2021-03-18 18:30:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
2021-07-03 18:01:30 +08:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-11-09 18:23:45 +08:00
|
|
|
.header-title {
|
|
|
|
font-size: 14px;
|
|
|
|
flex: 1;
|
|
|
|
color: var(--TextPrimary, #606266);
|
|
|
|
font-weight: bold;
|
|
|
|
display: block;
|
|
|
|
height: 100%;
|
|
|
|
/*line-height: 36px;*/
|
|
|
|
}
|
2021-07-03 18:01:30 +08:00
|
|
|
.msg-node-class {
|
|
|
|
color: red;
|
|
|
|
>>> i{
|
|
|
|
color: red;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|