2021-01-12 20:39:59 +08:00
|
|
|
|
<template>
|
2021-09-26 18:14:47 +08:00
|
|
|
|
<el-popover :placement="placement" popper-class="nz-pop nz-pop-select-panel right-public-box-select-top right-public-box-dropdown-top nz-pop-select-panel__dropdown" ref="selectPanelPopBox" transition="slide" v-model="popBox.show" width="310" :disabled="disabled">
|
2021-01-12 20:39:59 +08:00
|
|
|
|
<div>
|
|
|
|
|
|
<div class="pop-item-wider">
|
|
|
|
|
|
|
|
|
|
|
|
<slot name="header"></slot>
|
|
|
|
|
|
|
2021-01-13 16:29:21 +08:00
|
|
|
|
<div :class="{'movable': !panelLock}" class="select-panel-tree">
|
2021-01-12 20:39:59 +08:00
|
|
|
|
<el-tree
|
|
|
|
|
|
:data="panelData"
|
|
|
|
|
|
:draggable="!panelLock"
|
|
|
|
|
|
:expand-on-click-node="false"
|
|
|
|
|
|
:filter-node-method="filterNode"
|
|
|
|
|
|
:props="{label: 'name', children: 'children'}"
|
|
|
|
|
|
@node-click="selectPanel"
|
|
|
|
|
|
@node-drop="nodeDrop"
|
|
|
|
|
|
check-on-click-node
|
|
|
|
|
|
check-strictly
|
|
|
|
|
|
default-expand-all
|
|
|
|
|
|
highlight-current
|
|
|
|
|
|
node-key="id"
|
|
|
|
|
|
ref="panelTree">
|
|
|
|
|
|
<div class="tree--node" slot-scope="{ node, data }">
|
2021-09-24 17:57:24 +08:00
|
|
|
|
<span :title="node.label + ' (' + data.chartNum +' charts)' ">{{ node.label }}</span>
|
2021-08-25 10:38:46 +08:00
|
|
|
|
<!-- <span class="tree--operation" v-if="!panelLock">-->
|
|
|
|
|
|
<!-- <span @click.stop="deletePanel(data)" class="panel-dropdown-btn panel-dropdown-btn-delete" v-has="'panel_delete'"><i class="nz-icon nz-icon-delete"></i></span>-->
|
|
|
|
|
|
<!-- <span class="panel-dropdown-btn" @click.stop="editPanel(data)"><i v-has="'panel_edit'" class="nz-icon nz-icon-edit"></i></span>-->
|
|
|
|
|
|
<!-- </span>-->
|
2021-08-25 10:59:33 +08:00
|
|
|
|
<el-row class="block-col-2" v-if="!panelLock" style="width: 35px;">
|
2021-08-25 10:38:46 +08:00
|
|
|
|
<el-col>
|
2021-09-28 14:23:51 +08:00
|
|
|
|
<el-dropdown placement="bottom-end" trigger="click">
|
2021-08-25 10:38:46 +08:00
|
|
|
|
<span class="el-dropdown-link tree--operation" @click.stop><i class="nz-icon nz-icon-more1"></i></span>
|
2021-09-28 14:23:51 +08:00
|
|
|
|
<el-dropdown-menu class="right-box-select-top" slot="dropdown" v-has="['panel_edit', 'panel_delete']">
|
2021-08-25 10:38:46 +08:00
|
|
|
|
<el-dropdown-item>
|
2021-08-25 13:56:28 +08:00
|
|
|
|
<span @click.stop="editPanel(data)"><i v-has="'panel_edit'" class="nz-icon nz-icon-edit"></i>{{$t('overall.edit')}}</span>
|
2021-08-25 10:38:46 +08:00
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
<el-dropdown-item>
|
2021-08-25 13:56:28 +08:00
|
|
|
|
<span @click.stop="deletePanel(data)" v-has="'panel_delete'"><i class="nz-icon nz-icon-delete"></i>{{$t('overall.delete')}}</span>
|
2021-08-25 10:38:46 +08:00
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
|
</el-col>
|
|
|
|
|
|
</el-row>
|
2021-01-12 20:39:59 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</el-tree>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div slot="reference">
|
|
|
|
|
|
<slot name="trigger"></slot>
|
|
|
|
|
|
</div>
|
2021-08-25 10:38:46 +08:00
|
|
|
|
<div slot="default">
|
|
|
|
|
|
<slot name="tail"></slot>
|
|
|
|
|
|
</div>
|
2021-01-12 20:39:59 +08:00
|
|
|
|
</el-popover>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
2021-03-19 18:52:19 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: 'selectPanel',
|
|
|
|
|
|
props: {
|
|
|
|
|
|
placement: { type: String },
|
|
|
|
|
|
isEdit: { type: Boolean, default: true },
|
|
|
|
|
|
panelData: { type: Array },
|
|
|
|
|
|
showPanel: { type: Object },
|
|
|
|
|
|
panelLock: { type: Boolean, default: true },
|
2021-04-08 17:49:07 +08:00
|
|
|
|
disabled: { type: Boolean, default: false },
|
2021-03-19 18:52:19 +08:00
|
|
|
|
filterPanel: { type: String }
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted () {
|
|
|
|
|
|
this.$refs.panelTree.setCurrentKey(this.panel)
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
filterPanel: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler (n) {
|
|
|
|
|
|
this.$refs.panelTree && this.$refs.panelTree.filter(n)
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
showPanel: {
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler (n) {
|
|
|
|
|
|
if (n) {
|
|
|
|
|
|
this.panel = JSON.parse(JSON.stringify(n))
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/* panel: {
|
2021-01-14 16:10:38 +08:00
|
|
|
|
immediate: true,
|
|
|
|
|
|
handler(n) {
|
|
|
|
|
|
if (this.$refs.panelTree) {
|
|
|
|
|
|
console.info(n.id, n.name)
|
|
|
|
|
|
this.$refs.panelTree.setCurrentKey(n);
|
2021-01-13 15:27:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} */
|
|
|
|
|
|
},
|
|
|
|
|
|
data () {
|
|
|
|
|
|
return {
|
|
|
|
|
|
popBox: { show: false },
|
|
|
|
|
|
panel: { id: 0, name: '' }
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
/*
|
2021-01-12 20:39:59 +08:00
|
|
|
|
* node: 被拖的节点
|
|
|
|
|
|
* relative: 发生关系的节点
|
|
|
|
|
|
* position: ['before', 'after', 'inner'] 与relative节点的关系
|
|
|
|
|
|
* */
|
2021-03-19 18:52:19 +08:00
|
|
|
|
nodeDrop (node, relative, position, event) {
|
|
|
|
|
|
if (position === 'inner') {
|
|
|
|
|
|
node.data.pid = relative.data.id
|
|
|
|
|
|
} else {
|
|
|
|
|
|
node.data.pid = relative.data.pid
|
|
|
|
|
|
}
|
|
|
|
|
|
this.updateWeight()
|
|
|
|
|
|
},
|
|
|
|
|
|
filterNode (value, data) {
|
|
|
|
|
|
if (!value) return true
|
|
|
|
|
|
return data.name.indexOf(value) !== -1
|
|
|
|
|
|
},
|
|
|
|
|
|
updateWeight () {
|
|
|
|
|
|
const toUpdate = []
|
|
|
|
|
|
let count = 0
|
|
|
|
|
|
handler(this.panelData)
|
2021-01-12 20:39:59 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
function handler (panelData) {
|
|
|
|
|
|
panelData.forEach(panel => {
|
|
|
|
|
|
panel.weight = count++
|
|
|
|
|
|
toUpdate.push({ id: panel.id, pid: panel.pid, weight: panel.weight })
|
|
|
|
|
|
if (panel.children && panel.children.length > 0) {
|
|
|
|
|
|
handler(panel.children)
|
2021-01-12 20:39:59 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
2021-01-12 20:39:59 +08:00
|
|
|
|
|
2021-04-07 11:21:12 +08:00
|
|
|
|
this.$put('visual/panel/tree', toUpdate)
|
2021-03-19 18:52:19 +08:00
|
|
|
|
},
|
|
|
|
|
|
deletePanel (data) {
|
|
|
|
|
|
this.$emit('deletePanel', data)
|
|
|
|
|
|
},
|
|
|
|
|
|
editPanel (data) {
|
|
|
|
|
|
this.$emit('editPanel', data)
|
|
|
|
|
|
},
|
|
|
|
|
|
esc () {
|
|
|
|
|
|
this.popBox.show = false
|
|
|
|
|
|
},
|
|
|
|
|
|
// 确认选择某个节点,与父组件交互
|
|
|
|
|
|
selectPanel (data, checked, child) {
|
|
|
|
|
|
this.$emit('selectPanel', data)
|
|
|
|
|
|
this.$refs.panelTree.setCurrentKey(data)
|
|
|
|
|
|
this.esc()
|
|
|
|
|
|
}
|
|
|
|
|
|
// tree设为单选
|
|
|
|
|
|
/* clearOthers(data, checked, child) {
|
2021-01-12 20:39:59 +08:00
|
|
|
|
if (checked) {
|
|
|
|
|
|
this.panel = data;
|
|
|
|
|
|
this.$refs.panelTree.setCheckedKeys([data.id]);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.panel = {id: '', name: ''};
|
|
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
} */
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-01-12 20:39:59 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
2021-01-13 16:29:21 +08:00
|
|
|
|
.movable {
|
|
|
|
|
|
.el-tree-node__content {
|
|
|
|
|
|
cursor: move;
|
|
|
|
|
|
.tree--node>span:first-of-type {
|
|
|
|
|
|
cursor: pointer;
|
2021-07-02 11:35:13 +08:00
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
word-break: break-word;
|
2021-01-13 16:29:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
.tree--node>span:last-of-type>span {
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
.tree--node>span:last-of-type>span>i {
|
|
|
|
|
|
font-weight: normal !important;
|
|
|
|
|
|
}
|
2021-01-12 20:39:59 +08:00
|
|
|
|
.select-panel-tree {
|
|
|
|
|
|
height: 350px;
|
|
|
|
|
|
overflow: auto;
|
|
|
|
|
|
}
|
|
|
|
|
|
.select-panel-tree .el-tree-node__content {
|
|
|
|
|
|
height: 34px;
|
|
|
|
|
|
line-height: 34px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.select-panel-tree .el-tree-node__content:hover {
|
|
|
|
|
|
color: $global-text-color-active;
|
|
|
|
|
|
}
|
|
|
|
|
|
.select-panel-tree .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content {
|
|
|
|
|
|
background-color: #F5F7FA;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
color: $global-text-color-active;
|
|
|
|
|
|
}
|
|
|
|
|
|
.tree--node {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
width: calc(100% - 28px);
|
|
|
|
|
|
}
|
2021-07-02 11:44:44 +08:00
|
|
|
|
.tree--node span:nth-of-type(1) {
|
2021-07-02 11:35:13 +08:00
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
word-break: break-word;
|
|
|
|
|
|
}
|
2021-01-12 20:39:59 +08:00
|
|
|
|
.tree--operation {
|
|
|
|
|
|
opacity: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
.tree--node:hover .tree--operation {
|
|
|
|
|
|
opacity: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
.panel-dropdown-btn {
|
|
|
|
|
|
color: #60BEFF;
|
|
|
|
|
|
}
|
|
|
|
|
|
.panel-dropdown-btn:hover {
|
|
|
|
|
|
color: #409EFF;
|
|
|
|
|
|
}
|
|
|
|
|
|
.panel-dropdown-btn-delete {
|
|
|
|
|
|
color: #F98D9A;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.panel-dropdown-btn-delete:hover {
|
|
|
|
|
|
color: #D96D7A;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|