2020-04-02 20:23:52 +08:00
|
|
|
<template>
|
2020-04-08 18:50:00 +08:00
|
|
|
<el-popover @show="tempWalk.detailShow = false" v-if="popBox.show" :placement="placement" width="367" ref="selectWalkPopBox" popper-class="nz-pop nz-pop-select-walk" transition="slide">
|
|
|
|
|
<div class="pop-item-wider" @click="tempWalk.detailShow = false">
|
2020-04-08 20:27:07 +08:00
|
|
|
<div v-if="tempWalk.detailShow" class="el-popover walk-pop" :style="{left: detailPopPosition.left, top: detailPopPosition.top}">
|
2020-04-08 18:50:00 +08:00
|
|
|
<p><span class="metirc-tip-list">Name : </span><span>{{tempWalk.name}}</span></p>
|
|
|
|
|
<p><span class="metirc-tip-list">OID : </span><span>{{tempWalk.objectID}}</span></p>
|
|
|
|
|
<p><span class="metirc-tip-list">MIB : </span><span>{{mibName(tempWalk.objectID)}}</span></p>
|
|
|
|
|
</div>
|
2020-12-14 20:25:24 +08:00
|
|
|
<div class="select-walk-tree" ref="scrollbar">
|
2020-04-08 18:50:00 +08:00
|
|
|
<el-tree
|
|
|
|
|
ref="walkTree"
|
|
|
|
|
node-key="objectID"
|
|
|
|
|
:props="{label: 'name', children: 'subTree', disabled: disabledNode}"
|
|
|
|
|
:data="walkData"
|
|
|
|
|
:default-expanded-keys="expandedWalk"
|
|
|
|
|
:expand-on-click-node="false"
|
|
|
|
|
check-on-click-node
|
|
|
|
|
check-strictly
|
|
|
|
|
show-checkbox
|
|
|
|
|
@check="change"
|
2020-04-08 18:57:14 +08:00
|
|
|
@node-click="hideDetail"
|
2020-04-08 18:50:00 +08:00
|
|
|
:default-checked-keys="currentWalk"
|
|
|
|
|
>
|
|
|
|
|
<div slot-scope="{node, data}" class="walk-tree-item" :class="getClass(data.objectID)">
|
2020-09-10 17:00:32 +08:00
|
|
|
<span v-if="!data.type"><i class="nz-icon nz-icon-reading"></i></span>
|
2020-04-08 18:50:00 +08:00
|
|
|
<span v-else>
|
|
|
|
|
<i v-if="data.type.toUpperCase() == 'IDENTIFIER'" class="el-icon-folder-opened"></i>
|
|
|
|
|
<i v-if="data.type.toUpperCase() == 'OBJECT' && data.subTree.length > 0" class="el-icon-folder-opened"></i>
|
|
|
|
|
<i v-if="data.type.toUpperCase() == 'OBJECT' && data.subTree.length == 0" class="nz-icon nz-icon-leaf"></i>
|
|
|
|
|
<i v-if="data.type.toUpperCase() == 'ENTRY'" class="nz-icon nz-icon-table-edit"></i>
|
|
|
|
|
<i v-if="data.type.toUpperCase() == 'TABLE'" class="nz-icon nz-icon-table"></i>
|
|
|
|
|
<span @click.stop="showDetail(data, $event)" style="position: relative;">
|
|
|
|
|
<i class="nz-icon nz-icon-info-normal metric-tip-icon"></i>
|
2020-04-04 21:10:52 +08:00
|
|
|
</span>
|
|
|
|
|
</span>
|
2020-04-08 18:50:00 +08:00
|
|
|
{{data.name}}
|
|
|
|
|
</div>
|
|
|
|
|
</el-tree>
|
2020-12-14 20:25:24 +08:00
|
|
|
</div>
|
2020-04-02 20:23:52 +08:00
|
|
|
</div>
|
|
|
|
|
<div slot="reference">
|
|
|
|
|
<slot name="trigger">
|
|
|
|
|
</slot>
|
|
|
|
|
</div>
|
|
|
|
|
</el-popover>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
name: "selectWalk",
|
|
|
|
|
props:{
|
|
|
|
|
placement: {type: String},
|
|
|
|
|
walkData: {type: Array},
|
2020-04-04 21:10:52 +08:00
|
|
|
currentWalk: {type: Array},
|
|
|
|
|
expandedWalk: {type: Array}
|
2020-04-02 20:23:52 +08:00
|
|
|
},
|
2020-04-04 21:10:52 +08:00
|
|
|
data() {
|
2020-04-02 20:23:52 +08:00
|
|
|
return {
|
2020-09-03 18:34:19 +08:00
|
|
|
popBox: {show: true},
|
2020-04-08 18:50:00 +08:00
|
|
|
tempWalk: {detailShow: false, objectID: ''},
|
|
|
|
|
detailPopPosition: {top: "0", left: "0"}
|
2020-04-04 21:10:52 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
getClass() {
|
|
|
|
|
return (value) => {
|
|
|
|
|
return this.currentWalk.indexOf(value) == -1 ? '' : 'walk-active';
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mibName() {
|
|
|
|
|
return (value) => {
|
2020-04-08 18:50:00 +08:00
|
|
|
return value ? this.getMibName(value) : "";
|
2020-04-04 21:10:52 +08:00
|
|
|
}
|
2020-04-02 20:23:52 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods:{
|
2020-04-08 18:50:00 +08:00
|
|
|
getMibName(oid) {
|
|
|
|
|
let node = this.$refs.walkTree.getNode(oid);
|
2020-04-04 21:10:52 +08:00
|
|
|
let mibName = getMibName(node);
|
|
|
|
|
function getMibName(n) {
|
|
|
|
|
if (n.parent && n.parent.parent) {
|
|
|
|
|
return getMibName(n.parent);
|
|
|
|
|
} else if (n.parent) {
|
|
|
|
|
return n.data.name;
|
|
|
|
|
} else {
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (mibName) {
|
|
|
|
|
return mibName;
|
|
|
|
|
} else {
|
|
|
|
|
return "";
|
2020-04-02 20:23:52 +08:00
|
|
|
}
|
|
|
|
|
},
|
2020-04-04 21:10:52 +08:00
|
|
|
change(data, tree) {
|
|
|
|
|
this.$emit("selectWalk", data.objectID);
|
2020-04-02 20:23:52 +08:00
|
|
|
},
|
2020-04-04 21:10:52 +08:00
|
|
|
show() {
|
|
|
|
|
this.popBox.show = true;
|
2020-04-02 20:23:52 +08:00
|
|
|
},
|
2020-04-08 18:57:14 +08:00
|
|
|
hideDetail() {
|
|
|
|
|
this.tempWalk.detailShow = false;
|
|
|
|
|
},
|
2020-04-08 18:50:00 +08:00
|
|
|
showDetail(data, e) {
|
|
|
|
|
if (this.tempWalk.objectID != data.objectID) {
|
|
|
|
|
this.tempWalk.detailShow = false;
|
|
|
|
|
data.detailShow = !data.detailShow;
|
|
|
|
|
this.tempWalk = data;
|
|
|
|
|
} else {
|
|
|
|
|
data.detailShow = !data.detailShow;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.detailPopPosition.top = e.screenY-23 + "px";
|
|
|
|
|
this.detailPopPosition.left = e.screenX-16 + "px";
|
|
|
|
|
},
|
2020-04-04 21:10:52 +08:00
|
|
|
disabledNode(data) {
|
|
|
|
|
if (data.objectID) {
|
|
|
|
|
return false;
|
2020-04-02 20:23:52 +08:00
|
|
|
}
|
2020-04-04 21:10:52 +08:00
|
|
|
return true;
|
2020-04-02 20:23:52 +08:00
|
|
|
}
|
|
|
|
|
},
|
2020-11-20 11:19:25 +08:00
|
|
|
beforeDestroy(){
|
|
|
|
|
|
|
|
|
|
}
|
2020-04-02 20:23:52 +08:00
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
2020-04-04 21:10:52 +08:00
|
|
|
.select-walk-tree {
|
2020-04-02 20:23:52 +08:00
|
|
|
height: 350px;
|
|
|
|
|
}
|
2020-04-04 21:10:52 +08:00
|
|
|
.select-walk-tree .el-tree-node__content {
|
2020-04-02 20:23:52 +08:00
|
|
|
height: 34px;
|
|
|
|
|
line-height: 34px;
|
|
|
|
|
}
|
2020-04-04 21:10:52 +08:00
|
|
|
.select-walk-tree .el-tree--highlight-current .el-tree-node.is-current>.el-tree-node__content {
|
2020-04-02 20:23:52 +08:00
|
|
|
background-color: #F5F7FA;
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
color: $global-text-color-active;
|
|
|
|
|
}
|
2020-04-04 21:10:52 +08:00
|
|
|
.select-walk-tree .el-tree .el-checkbox {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
.nz-pop-select-walk {
|
|
|
|
|
padding: 0 !important;
|
|
|
|
|
}
|
|
|
|
|
.walk-active {
|
|
|
|
|
color: $global-text-color-active;
|
|
|
|
|
}
|
2020-04-08 18:50:00 +08:00
|
|
|
.walk-tree-item {
|
|
|
|
|
height: 34px;
|
|
|
|
|
line-height: 34px;
|
|
|
|
|
}
|
2020-04-04 21:10:52 +08:00
|
|
|
.walk-detail {
|
|
|
|
|
z-index: 10000 !important;
|
|
|
|
|
}
|
2020-04-08 18:50:00 +08:00
|
|
|
|
|
|
|
|
.walk-pop {
|
|
|
|
|
position: fixed;
|
|
|
|
|
transform: translate(-100%, -100%);
|
|
|
|
|
}
|
|
|
|
|
.walk-pop::after {
|
|
|
|
|
content: '';
|
|
|
|
|
display: block;
|
|
|
|
|
width:0;
|
|
|
|
|
height:0;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
font-size: 0;
|
|
|
|
|
line-height: 0;
|
|
|
|
|
border: 5px;
|
|
|
|
|
border-style: dashed dashed dashed solid;
|
|
|
|
|
border-color: transparent transparent transparent #fff ;
|
|
|
|
|
position: absolute;
|
|
|
|
|
right: 0;
|
|
|
|
|
top: 50%;
|
|
|
|
|
transform: translate(10px, -50%);
|
|
|
|
|
}
|
2020-04-02 20:23:52 +08:00
|
|
|
</style>
|