2021-03-23 13:58:49 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div class="my-top">
|
|
|
|
<el-input
|
|
|
|
v-model="filterText"
|
|
|
|
placeholder="按名称搜索"
|
|
|
|
/>
|
|
|
|
<el-tree
|
|
|
|
ref="tree"
|
|
|
|
class="filter-tree"
|
|
|
|
:data="data"
|
|
|
|
:props="defaultProps"
|
|
|
|
:render-content="renderNode"
|
|
|
|
default-expand-all
|
|
|
|
:filter-node-method="filterNode"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div v-if="showdetail" class="detail-class">
|
|
|
|
<el-card class="filter-card-class">
|
|
|
|
<div slot="header" class="button-div-class">
|
|
|
|
<span>{{ detailItem.name }}</span>
|
|
|
|
<div style="float: right; padding: 1px 5px; cursor:pointer; " @click="closeDetail">
|
|
|
|
<i class="el-icon-close" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<img class="view-list-thumbnails" :src="'/common-files/images/'+detailItem.id+'/VIEW_DEFAULT_IMAGE'" alt="">
|
|
|
|
</el-card>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { tree } from '@/api/panel/view'
|
|
|
|
import { addClass, removeClass } from '@/utils'
|
|
|
|
export default {
|
|
|
|
name: 'ViewSelect',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
filterText: null,
|
|
|
|
defaultProps: {
|
|
|
|
children: 'children',
|
|
|
|
label: 'name'
|
|
|
|
},
|
|
|
|
data: [],
|
|
|
|
showdetail: false,
|
|
|
|
detailItem: null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
watch: {
|
|
|
|
filterText(val) {
|
|
|
|
this.$refs.tree.filter(val)
|
|
|
|
},
|
|
|
|
showdetail(val) {
|
|
|
|
const dom = document.querySelector('.my-top')
|
|
|
|
if (val) {
|
|
|
|
addClass(dom, 'top-div-class')
|
|
|
|
} else {
|
|
|
|
removeClass(dom, 'top-div-class')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.loadData()
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
filterNode(value, data) {
|
|
|
|
if (!value) return true
|
|
|
|
return data.name.indexOf(value) !== -1
|
|
|
|
},
|
|
|
|
loadData() {
|
|
|
|
const param = {}
|
|
|
|
tree(param).then(res => {
|
2021-03-23 14:05:32 +08:00
|
|
|
// let arr = []
|
|
|
|
// for (let index = 0; index < 10; index++) {
|
|
|
|
// arr = arr.concat(res.data)
|
|
|
|
// }
|
|
|
|
// this.data = arr
|
|
|
|
this.data = res.data
|
2021-03-23 13:58:49 +08:00
|
|
|
})
|
|
|
|
},
|
|
|
|
renderNode(h, { node, data, store }) {
|
|
|
|
return (
|
|
|
|
<div class='custom-tree-node' on-click={() => this.detail(data)} >
|
|
|
|
<span class='label-span'>{node.label}</span>
|
|
|
|
{data.type !== 'group' && data.type !== 'scene' ? (
|
|
|
|
|
|
|
|
<svg-icon icon-class={data.type} class='chart-icon' />
|
|
|
|
) : (
|
|
|
|
''
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
},
|
|
|
|
detail(data) {
|
|
|
|
this.showdetail = true
|
|
|
|
this.detailItem = data
|
|
|
|
},
|
|
|
|
closeDetail() {
|
|
|
|
this.showdetail = false
|
|
|
|
this.detailItem = null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.top-div-class {
|
|
|
|
max-height: calc(100vh - 335px);
|
|
|
|
width: 100%;
|
|
|
|
position: fixed;
|
|
|
|
overflow-y : auto
|
|
|
|
}
|
|
|
|
.detail-class {
|
|
|
|
width: 100%;
|
|
|
|
position: fixed;
|
|
|
|
bottom: 0px;
|
|
|
|
}
|
|
|
|
.view-list-thumbnails {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
</style>
|