wvp-GB28181-pro/web_src/src/components/common/RegionTree.vue

163 lines
4.0 KiB
Vue
Raw Normal View History

2024-07-23 18:00:47 +08:00
<template>
2024-07-24 17:54:19 +08:00
<div id="DeviceTree">
<div class="page-header" style="margin-bottom: 1rem">
<div class="page-title">行政区划</div>
<div class="page-header-btn">
<div style="display: inline;">
<el-input @input="search" style="margin-right: 1rem; width: auto;" size="mini" placeholder="关键字"
prefix-icon="el-icon-search" v-model="searchSrt" clearable></el-input>
2024-07-23 18:00:47 +08:00
</div>
2024-07-24 17:54:19 +08:00
</div>
</div>
<vue-easy-tree
ref="veTree"
node-key="id"
height="72vh"
style="height: 78vh"
:loadNode="loadNode"
:data="treeData"
:props="props"
></vue-easy-tree>
2024-07-23 18:00:47 +08:00
</div>
</template>
<script>
2024-07-24 17:54:19 +08:00
import VueEasyTree from "@wchbrad/vue-easy-tree";
let treeData = []
2024-07-23 18:00:47 +08:00
export default {
2024-07-24 17:54:19 +08:00
name: 'DeviceTree',
components: {
VueEasyTree
},
data() {
return {
props: {
label: "name",
},
treeData: [],
}
},
props: ['edit', 'clickEvent', 'contextMenuEvent'],
created() {
this.$axios({
method: 'get',
url: `/api/region/tree/list`,
}).then((res)=> {
if (res.data.code === 0) {
this.treeData.push(res.data.data)
2024-07-23 18:00:47 +08:00
}
2024-07-24 17:54:19 +08:00
}).catch(function (error) {
console.log(error);
});
},
methods: {
onClick(evt, treeId, treeNode) {
2024-07-23 18:00:47 +08:00
2024-07-24 17:54:19 +08:00
},
onCheck(evt, treeId, treeNode) {
2024-07-23 18:00:47 +08:00
2024-07-24 17:54:19 +08:00
},
handleCreated(ztreeObj) {
2024-07-23 18:00:47 +08:00
2024-07-24 17:54:19 +08:00
},
handleNodeClick(data, node, element) {
let deviceNode = this.$refs.gdTree.getNode(data.userData.deviceId)
if (typeof (this.clickEvent) == "function") {
this.clickEvent(deviceNode.data.userData, data.userData, data.type === 2)
}
},
handleContextMenu(event, data, node, element) {
console.log("右键点击事件")
let deviceNode = this.$refs.gdTree.getNode(data.userData.deviceId)
if (typeof (this.contextMenuEvent) == "function") {
this.contextMenuEvent(deviceNode.data.userData, event, data.userData, data.type === 2)
}
},
loadNode: function (node, resolve) {
console.log(node)
if (node.level === 0) {
2024-07-23 18:00:47 +08:00
2024-07-24 17:54:19 +08:00
} else {
2024-07-23 18:00:47 +08:00
2024-07-24 17:54:19 +08:00
}
2024-07-23 18:00:47 +08:00
2024-07-24 17:54:19 +08:00
},
channelDataHandler: function (data, resolve) {
if (data.length > 0) {
let nodeList = []
for (let i = 0; i < data.length; i++) {
let item = data[i];
let type = 3;
if (item.id.length <= 10) {
type = 2;
} else {
if (item.id.length > 14) {
let channelType = item.id.substring(10, 13)
console.log("channelType: " + channelType)
if (channelType === '215' || channelType === '216') {
type = 2;
}
console.log(type)
if (item.basicData.ptzType === 1) { // 1-球机;2-半球;3-固定枪机;4-遥控枪机
type = 4;
} else if (item.basicData.ptzType === 2) {
type = 5;
} else if (item.basicData.ptzType === 3 || item.basicData.ptzType === 4) {
type = 6;
}
} else {
if (item.basicData.subCount > 0 || item.basicData.parental === 1) {
type = 2;
2024-07-23 18:00:47 +08:00
}
}
}
2024-07-24 17:54:19 +08:00
let node = {
name: item.name || item.basicData.channelId,
isLeaf: type !== 2,
id: item.id,
deviceId: item.deviceId,
type: type,
online: item.basicData.status === 1,
hasGPS: item.basicData.longitude * item.basicData.latitude !== 0,
userData: item.basicData
}
nodeList.push(node);
2024-07-23 18:00:47 +08:00
}
2024-07-24 17:54:19 +08:00
resolve(nodeList)
} else {
resolve([])
2024-07-23 18:00:47 +08:00
}
},
2024-07-24 17:54:19 +08:00
reset: function () {
this.$forceUpdate();
}
},
destroyed() {
// if (this.jessibuca) {
// this.jessibuca.destroy();
// }
// this.playing = false;
// this.loaded = false;
// this.performance = "";
},
2024-07-23 18:00:47 +08:00
}
</script>
<style>
2024-07-24 17:54:19 +08:00
.device-tree-main-box {
2024-07-23 18:00:47 +08:00
text-align: left;
}
2024-07-24 17:54:19 +08:00
.device-online {
2024-07-23 18:00:47 +08:00
color: #252525;
}
2024-07-24 17:54:19 +08:00
.device-offline {
2024-07-23 18:00:47 +08:00
color: #727272;
}
</style>