|
@@ -5,6 +5,29 @@
|
|
|
-->
|
|
|
<template>
|
|
|
<div class="u-tree__bar">
|
|
|
+ <!-- 右键可以打开菜单-->
|
|
|
+ <!-- <dg-scrollbar>-->
|
|
|
+ <!-- <dg-tree-->
|
|
|
+ <!-- ref="tree"-->
|
|
|
+ <!-- icon-class="el-icon-folder-opened"-->
|
|
|
+ <!-- icon-leaf="el-icon-document"-->
|
|
|
+ <!-- node-key="id"-->
|
|
|
+ <!-- :data="source"-->
|
|
|
+ <!-- :props="props"-->
|
|
|
+ <!-- default-expand-all-->
|
|
|
+ <!-- highlight-current-->
|
|
|
+ <!-- :filter-node-method="filterNode"-->
|
|
|
+ <!-- :expand-on-click-node="false"-->
|
|
|
+ <!-- @node-contextmenu="rightClick"-->
|
|
|
+ <!-- >-->
|
|
|
+ <!-- <div slot-scope="{ node, data }" class="u-tree-label" style="width: 100%">-->
|
|
|
+ <!-- <p @dblclick="handlerNodeDoubleClick(data)" @click="handleNodeClick(data)">-->
|
|
|
+ <!-- {{ data[props.label] }}-->
|
|
|
+ <!-- </p>-->
|
|
|
+ <!-- </div>-->
|
|
|
+ <!-- </dg-tree>-->
|
|
|
+ <!-- </dg-scrollbar>-->
|
|
|
+ <!--todo 修改成无右键菜单-->
|
|
|
<dg-scrollbar>
|
|
|
<dg-tree
|
|
|
ref="tree"
|
|
@@ -19,15 +42,19 @@
|
|
|
:expand-on-click-node="false"
|
|
|
@node-contextmenu="rightClick"
|
|
|
>
|
|
|
- <div slot-scope="{ node, data }" class="u-tree-label" style="width: 100%">
|
|
|
- <p @dblclick="handlerNodeDoubleClick(data)" @click="handleNodeClick(data)">
|
|
|
+ <div slot-scope="{ node, data }" class="u-tree-label el-tree-node__edit" style="width: 100%">
|
|
|
+ <span @dblclick="handlerNodeDoubleClick(data)" @click="handleNodeClick(data)">
|
|
|
{{ data[props.label] }}
|
|
|
- </p>
|
|
|
+ </span>
|
|
|
+ <span class="operation-icons">
|
|
|
+ <i class="el-icon-circle-plus-outline" @click="handleSelect('add', node, data)"> </i>
|
|
|
+ <i class="el-icon-delete" @click="handleSelect('delete', node, data)"> </i>
|
|
|
+ </span>
|
|
|
</div>
|
|
|
</dg-tree>
|
|
|
</dg-scrollbar>
|
|
|
<!--右键菜单-->
|
|
|
- <div v-show="menuVisible && isNeedRightMenu" id="menu" class="tree-operation-box">
|
|
|
+ <div v-show="menuVisible && isNeedRightMenu" id="menu_contain" class="tree-operation-box">
|
|
|
<el-menu id="menu" @select="handleSelect" text-color="#000">
|
|
|
<el-menu-item
|
|
|
v-for="(op, i) in treeRightOperations"
|
|
@@ -50,6 +77,7 @@
|
|
|
<script>
|
|
|
// 一次性请求数据源
|
|
|
import * as commonApi from "@/api/common";
|
|
|
+
|
|
|
let debounceTimer;
|
|
|
export default {
|
|
|
name: "menuTree",
|
|
@@ -148,7 +176,7 @@ export default {
|
|
|
this.menuVisible = true; // 显示菜单
|
|
|
this.nodedata = data; // 节点信息存下来
|
|
|
this.Node = node;
|
|
|
- let menu = document.querySelector("#menu");
|
|
|
+ let menu = document.querySelector("#menu_contain");
|
|
|
let x = event.pageX || event.clientX,
|
|
|
y = event.pageY || event.clientY;
|
|
|
// menu.style.cssText =
|
|
@@ -162,8 +190,10 @@ export default {
|
|
|
this.menuVisible = false;
|
|
|
document.removeEventListener("click", this.Listen); // 监听鼠标事件
|
|
|
},
|
|
|
- handleSelect(val) {
|
|
|
- // console.log(val);
|
|
|
+ handleSelect(val, node, data) {
|
|
|
+ console.log(val);
|
|
|
+ this.Node = node;
|
|
|
+ this.nodedata = data;
|
|
|
this.$emit("selectOperaOptions", { type: val, nodedata: this.nodedata, node: this.Node });
|
|
|
},
|
|
|
remove() {
|
|
@@ -198,8 +228,10 @@ export default {
|
|
|
width: 100px;
|
|
|
position: absolute;
|
|
|
color: #fff;
|
|
|
+
|
|
|
ul {
|
|
|
list-style: none;
|
|
|
+
|
|
|
li {
|
|
|
width: 100%;
|
|
|
cursor: pointer;
|
|
@@ -209,13 +241,30 @@ export default {
|
|
|
text-align: center;
|
|
|
font-size: 14px;
|
|
|
border-bottom: 1px solid #fff;
|
|
|
+
|
|
|
&:last-child {
|
|
|
border-bottom: none;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
.u-tree__bar {
|
|
|
height: calc(100vh - 28rem);
|
|
|
+ .el-tree-node__edit {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-between;
|
|
|
+ align-items: center;
|
|
|
+ padding-right: 10px;
|
|
|
+ i {
|
|
|
+ color: #1890ff;
|
|
|
+ }
|
|
|
+ .operation-icons {
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+ &:hover .operation-icons {
|
|
|
+ display: block;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
</style>
|