2021-03-23 13:58:49 +08:00
|
|
|
<template>
|
2021-06-04 12:22:34 +08:00
|
|
|
<el-col v-loading="loading">
|
2021-05-08 00:04:24 +08:00
|
|
|
<el-row style="margin-top: 5px">
|
|
|
|
<el-row style="margin-left: 5px;margin-right: 5px">
|
2021-09-22 17:52:53 +08:00
|
|
|
<el-col :span="selectModel ? 23 : 16">
|
2021-07-06 18:34:01 +08:00
|
|
|
<el-input
|
|
|
|
v-model="templateFilterText"
|
|
|
|
:placeholder="$t('panel.filter_keywords')"
|
|
|
|
size="mini"
|
|
|
|
clearable
|
|
|
|
prefix-icon="el-icon-search"
|
|
|
|
/>
|
|
|
|
</el-col>
|
2021-09-22 17:52:53 +08:00
|
|
|
<el-col v-if="!selectModel" :span="7">
|
2021-07-06 18:34:01 +08:00
|
|
|
<el-button type="primary" size="mini" style="float: right" @click="newChart">新建 </el-button>
|
|
|
|
</el-col>
|
|
|
|
|
2021-05-08 00:04:24 +08:00
|
|
|
</el-row>
|
|
|
|
<el-row style="margin-top: 5px">
|
|
|
|
<el-tree
|
|
|
|
ref="templateTree"
|
|
|
|
:default-expanded-keys="defaultExpandedKeys"
|
2021-09-22 17:52:53 +08:00
|
|
|
:show-checkbox="selectModel"
|
2021-05-08 00:04:24 +08:00
|
|
|
:data="data"
|
|
|
|
node-key="id"
|
|
|
|
:props="defaultProps"
|
|
|
|
draggable
|
|
|
|
:allow-drop="allowDrop"
|
|
|
|
:allow-drag="allowDrag"
|
|
|
|
:expand-on-click-node="true"
|
|
|
|
:filter-node-method="filterNode"
|
|
|
|
:highlight-current="true"
|
|
|
|
@node-drag-start="handleDragStart"
|
|
|
|
@node-click="nodeClick"
|
2021-09-23 15:43:31 +08:00
|
|
|
|
2021-09-22 17:52:53 +08:00
|
|
|
@check="checkChanged"
|
2021-09-23 15:43:31 +08:00
|
|
|
|
2021-09-22 16:51:41 +08:00
|
|
|
@node-drag-end="dragEnd"
|
2021-05-08 00:04:24 +08:00
|
|
|
>
|
|
|
|
<span slot-scope="{ node, data }" class="custom-tree-node">
|
|
|
|
<span>
|
2021-06-16 17:53:02 +08:00
|
|
|
<span v-if="data.type==='scene'||data.type==='group'">
|
2021-05-08 00:04:24 +08:00
|
|
|
<el-button
|
|
|
|
icon="el-icon-folder"
|
|
|
|
type="text"
|
|
|
|
/>
|
|
|
|
</span>
|
|
|
|
<span v-else>
|
|
|
|
<svg-icon :icon-class="data.type" style="width: 14px;height: 14px" />
|
|
|
|
</span>
|
|
|
|
<span style="margin-left: 6px;font-size: 14px">{{ data.name }}</span>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</el-tree>
|
|
|
|
</el-row>
|
2021-06-04 12:22:34 +08:00
|
|
|
<!-- <el-row v-if="detailItem&&detailItem.snapshot" class="detail-class">-->
|
|
|
|
<!-- <el-card class="filter-card-class">-->
|
|
|
|
<!-- <div slot="header" class="button-div-class">-->
|
|
|
|
<!-- <span>{{ detailItem.name }}</span>-->
|
|
|
|
<!-- </div>-->
|
|
|
|
<!-- <img draggable="false" class="view-list-thumbnails" :src="detailItem.snapshot" alt="">-->
|
|
|
|
<!-- </el-card>-->
|
|
|
|
<!-- </el-row>-->
|
2021-05-08 00:04:24 +08:00
|
|
|
</el-row>
|
|
|
|
</el-col>
|
2021-03-23 13:58:49 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-05-08 00:04:24 +08:00
|
|
|
import { tree, findOne } from '@/api/panel/view'
|
2021-09-22 16:51:41 +08:00
|
|
|
import componentList from '@/components/canvas/custom-component/component-list'
|
|
|
|
import { deepCopy } from '@/components/canvas/utils/utils'
|
2021-10-09 00:02:06 +08:00
|
|
|
import eventBus from '@/components/canvas/utils/eventBus'
|
|
|
|
import { mapState } from 'vuex'
|
|
|
|
|
2021-03-23 13:58:49 +08:00
|
|
|
export default {
|
|
|
|
name: 'ViewSelect',
|
2021-09-22 17:52:53 +08:00
|
|
|
props: {
|
|
|
|
selectModel: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
}
|
|
|
|
},
|
2021-03-23 13:58:49 +08:00
|
|
|
data() {
|
|
|
|
return {
|
2021-05-08 00:04:24 +08:00
|
|
|
templateFilterText: '',
|
|
|
|
defaultExpandedKeys: [],
|
2021-03-23 13:58:49 +08:00
|
|
|
defaultProps: {
|
|
|
|
children: 'children',
|
2021-09-26 17:55:31 +08:00
|
|
|
label: 'name',
|
|
|
|
disabled: 'disabled'
|
2021-03-23 13:58:49 +08:00
|
|
|
},
|
|
|
|
data: [],
|
|
|
|
showdetail: false,
|
2021-06-04 12:22:34 +08:00
|
|
|
detailItem: null,
|
|
|
|
loading: false
|
2021-03-23 13:58:49 +08:00
|
|
|
}
|
|
|
|
},
|
2021-10-09 00:02:06 +08:00
|
|
|
computed: {
|
|
|
|
...mapState([
|
|
|
|
'canvasStyleData'
|
|
|
|
])
|
|
|
|
},
|
2021-03-23 13:58:49 +08:00
|
|
|
watch: {
|
2021-05-08 00:04:24 +08:00
|
|
|
templateFilterText(val) {
|
|
|
|
this.$refs.templateTree.filter(val)
|
2021-03-23 13:58:49 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.loadData()
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
filterNode(value, data) {
|
|
|
|
if (!value) return true
|
|
|
|
return data.name.indexOf(value) !== -1
|
|
|
|
},
|
2021-05-08 00:04:24 +08:00
|
|
|
nodeClick(data, node) {
|
|
|
|
findOne(data.id).then(res => {
|
|
|
|
this.detailItem = res.data
|
|
|
|
})
|
|
|
|
},
|
2021-03-23 13:58:49 +08:00
|
|
|
loadData() {
|
|
|
|
const param = {}
|
2021-06-04 12:22:34 +08:00
|
|
|
this.loading = true
|
2021-03-23 13:58:49 +08:00
|
|
|
tree(param).then(res => {
|
2021-09-26 17:55:31 +08:00
|
|
|
const nodeDatas = res.data
|
|
|
|
if (this.selectModel) {
|
|
|
|
this.setParentDisable(nodeDatas)
|
|
|
|
}
|
|
|
|
this.data = nodeDatas
|
2021-06-04 12:22:34 +08:00
|
|
|
this.loading = false
|
2021-03-23 13:58:49 +08:00
|
|
|
})
|
|
|
|
},
|
2021-03-25 19:16:32 +08:00
|
|
|
handleDragStart(node, ev) {
|
2021-09-22 16:51:41 +08:00
|
|
|
this.$store.commit('setDragComponentInfo', this.viewComponentInfo())
|
2021-03-25 19:16:32 +08:00
|
|
|
ev.dataTransfer.effectAllowed = 'copy'
|
|
|
|
const dataTrans = {
|
|
|
|
type: 'view',
|
|
|
|
id: node.data.id
|
|
|
|
}
|
|
|
|
ev.dataTransfer.setData('componentInfo', JSON.stringify(dataTrans))
|
2021-10-09 00:02:06 +08:00
|
|
|
eventBus.$emit('startMoveIn')
|
2021-03-25 19:16:32 +08:00
|
|
|
},
|
2021-09-22 16:51:41 +08:00
|
|
|
dragEnd() {
|
|
|
|
console.log('dragEnd')
|
|
|
|
this.$store.commit('clearDragComponentInfo')
|
|
|
|
},
|
2021-03-25 19:16:32 +08:00
|
|
|
// 判断节点能否被拖拽
|
|
|
|
allowDrag(draggingNode) {
|
2021-09-22 16:51:41 +08:00
|
|
|
if (draggingNode.data.type === 'scene' || draggingNode.data.type === 'group') {
|
2021-03-25 19:16:32 +08:00
|
|
|
return false
|
|
|
|
} else {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
allowDrop(draggingNode, dropNode, type) {
|
|
|
|
return false
|
2021-07-06 18:34:01 +08:00
|
|
|
},
|
|
|
|
newChart() {
|
|
|
|
this.$emit('newChart')
|
2021-09-22 17:52:53 +08:00
|
|
|
},
|
2021-09-23 15:43:31 +08:00
|
|
|
|
2021-09-22 17:52:53 +08:00
|
|
|
checkChanged(node, status) {
|
|
|
|
this.$refs.templateTree.setCheckedNodes([])
|
|
|
|
if (status.checkedKeys && status.checkedKeys.length > 0) {
|
|
|
|
this.$refs.templateTree.setCheckedNodes([node])
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getCurrentSelected() {
|
|
|
|
const nodes = this.$refs.templateTree.getCheckedNodes(true, false)
|
|
|
|
return nodes
|
2021-09-23 15:43:31 +08:00
|
|
|
},
|
2021-09-26 17:55:31 +08:00
|
|
|
setParentDisable(nodes) {
|
|
|
|
nodes.forEach(node => {
|
|
|
|
if (node.type === 'group') {
|
|
|
|
node.disabled = true
|
|
|
|
}
|
|
|
|
if (node.children && node.children.length > 0) {
|
|
|
|
this.setParentDisable(node.children)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
2021-09-22 16:51:41 +08:00
|
|
|
viewComponentInfo() {
|
|
|
|
let component
|
|
|
|
// 用户视图设置 复制一个模板
|
|
|
|
componentList.forEach(componentTemp => {
|
|
|
|
if (componentTemp.type === 'view') {
|
|
|
|
component = deepCopy(componentTemp)
|
|
|
|
}
|
|
|
|
})
|
2021-10-09 00:02:06 +08:00
|
|
|
component.auxiliaryMatrix = this.canvasStyleData.auxiliaryMatrix
|
2021-09-22 16:51:41 +08:00
|
|
|
return component
|
2021-03-23 13:58:49 +08:00
|
|
|
}
|
2021-03-25 19:16:32 +08:00
|
|
|
|
2021-03-23 13:58:49 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2021-03-25 19:16:32 +08:00
|
|
|
.top-div-class {
|
2021-03-23 13:58:49 +08:00
|
|
|
max-height: calc(100vh - 335px);
|
|
|
|
width: 100%;
|
|
|
|
position: fixed;
|
|
|
|
overflow-y : auto
|
2021-03-25 19:16:32 +08:00
|
|
|
}
|
|
|
|
.detail-class {
|
2021-05-20 11:18:31 +08:00
|
|
|
width: 300px;
|
2021-03-23 13:58:49 +08:00
|
|
|
position: fixed;
|
|
|
|
bottom: 0px;
|
2021-03-25 19:16:32 +08:00
|
|
|
}
|
|
|
|
.view-list-thumbnails {
|
2021-03-23 13:58:49 +08:00
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
2021-03-25 19:16:32 +08:00
|
|
|
}
|
2021-03-23 13:58:49 +08:00
|
|
|
</style>
|