优化国标树型展示

This commit is contained in:
648540858
2022-07-03 07:40:54 +08:00
parent 0da452293f
commit f5fcc79a2c
29 changed files with 1341 additions and 537 deletions

View File

@@ -56,11 +56,11 @@
@mouseover="getTooltipContent(scope.row.deviceId)">刷新
</el-button>
<el-divider direction="vertical"></el-divider>
<el-button type="text" size="medium" icon="el-icon-video-camera" v-bind:disabled="scope.row.online==0"
<el-button type="text" size="medium" icon="el-icon-video-camera"
@click="showChannelList(scope.row)">通道
</el-button>
<el-divider direction="vertical"></el-divider>
<el-button size="medium" icon="el-icon-location" v-bind:disabled="scope.row.online==0" type="text"
<el-button size="medium" icon="el-icon-location" type="text"
@click="showDevicePosition(scope.row)">定位
</el-button>
<el-divider direction="vertical"></el-divider>
@@ -192,7 +192,7 @@ export default {
},
showChannelList: function (row) {
this.$router.push(`/channelList/${row.deviceId}/0/15/1`);
this.$router.push(`/channelList/${row.deviceId}/0`);
},
showDevicePosition: function (row) {
this.$router.push(`/map?deviceId=${row.deviceId}`);

View File

@@ -7,104 +7,116 @@
通道列表
</div>
<div class="page-header-btn">
搜索:
<el-input @input="search" style="margin-right: 1rem; width: auto;" size="mini" placeholder="关键字"
prefix-icon="el-icon-search" v-model="searchSrt" clearable></el-input>
<div v-if="!showTree" 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>
通道类型:
<el-select size="mini" @change="search" style="margin-right: 1rem;" v-model="channelType" placeholder="请选择"
default-first-option>
<el-option label="全部" value=""></el-option>
<el-option label="设备" value="false"></el-option>
<el-option label="子目录" value="true"></el-option>
</el-select>
在线状态:
<el-select size="mini" style="margin-right: 1rem;" @change="search" v-model="online" placeholder="请选择"
default-first-option>
<el-option label="全部" value=""></el-option>
<el-option label="在线" value="true"></el-option>
<el-option label="离线" value="false"></el-option>
</el-select>
通道类型:
<el-select size="mini" @change="search" style="margin-right: 1rem;" v-model="channelType" placeholder="请选择"
default-first-option>
<el-option label="全部" value=""></el-option>
<el-option label="设备" value="false"></el-option>
<el-option label="子目录" value="true"></el-option>
</el-select>
在线状态:
<el-select size="mini" style="margin-right: 1rem;" @change="search" v-model="online" placeholder="请选择"
default-first-option>
<el-option label="全部" value=""></el-option>
<el-option label="在线" value="true"></el-option>
<el-option label="离线" value="false"></el-option>
</el-select>
</div>
<el-button icon="el-icon-refresh-right" circle size="mini" @click="refresh()"></el-button>
<el-button v-if="showTree" icon="iconfont icon-list" circle size="mini" @click="switchList()"></el-button>
<el-button v-if="!showTree" icon="iconfont icon-tree" circle size="mini" @click="switchTree()"></el-button>
</div>
</div>
<devicePlayer ref="devicePlayer" v-loading="isLoging"></devicePlayer>
<el-container v-loading="isLoging" style="height: 82vh;">
<el-aside width="auto" style="height: 82vh; background-color: #ffffff; overflow: auto" v-if="showTree" >
<DeviceTree ref="deviceTree" :device="device" :onlyCatalog="true" :clickEvent="treeNodeClickEvent" ></DeviceTree>
</el-aside>
<el-main style="padding: 5px;">
<el-table ref="channelListTable" :data="deviceChannelList" :height="winHeight" style="width: 100%" header-row-class-name="table-header">
<el-table-column prop="channelId" label="通道编号" min-width="200">
</el-table-column>
<el-table-column prop="deviceId" label="设备编号" min-width="200">
</el-table-column>
<el-table-column prop="name" label="通道名称" min-width="200">
</el-table-column>
<el-table-column label="快照" min-width="120">
<template v-slot:default="scope">
<el-image
:src="getSnap(scope.row)"
:preview-src-list="getBigSnap(scope.row)"
@error="getSnapErrorEvent(scope.row.deviceId, scope.row.channelId)"
:fit="'contain'"
style="width: 60px">
<div slot="error" class="image-slot">
<i class="el-icon-picture-outline"></i>
</div>
</el-image>
</template>
</el-table-column>
<el-table-column prop="subCount" label="子节点数" min-width="120">
</el-table-column>
<el-table-column prop="manufacture" label="厂家" min-width="120">
</el-table-column>
<el-table-column label="位置信息" min-width="200">
<template slot-scope="scope">
<span v-if="scope.row.longitude*scope.row.latitude > 0">{{ scope.row.longitude }},<br>{{ scope.row.latitude }}</span>
<span v-if="scope.row.longitude*scope.row.latitude === 0"></span>
</template>
</el-table-column>
<el-table-column prop="ptztypeText" label="云台类型" min-width="120"/>
<el-table-column label="开启音频" min-width="120">
<template slot-scope="scope">
<el-switch @change="updateChannel(scope.row)" v-model="scope.row.hasAudio" active-color="#409EFF">
</el-switch>
</template>
</el-table-column>
<el-table-column label="状态" min-width="120">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag size="medium" v-if="scope.row.status === 1">在线</el-tag>
<el-tag size="medium" type="info" v-if="scope.row.status === 0">离线</el-tag>
</div>
</template>
</el-table-column>
<el-table-column label="操作" min-width="280" fixed="right">
<template slot-scope="scope">
<el-button size="medium" v-bind:disabled="device == null || device.online === 0" icon="el-icon-video-play" type="text" @click="sendDevicePush(scope.row)">播放</el-button>
<el-button size="medium" v-bind:disabled="device == null || device.online === 0" icon="el-icon-switch-button" type="text" style="color: #f56c6c" v-if="!!scope.row.streamId"
@click="stopDevicePush(scope.row)">停止
</el-button>
<el-divider direction="vertical"></el-divider>
<el-button size="medium" icon="el-icon-s-open" type="text" v-if="scope.row.subCount > 0 || scope.row.parental === 1"
@click="changeSubchannel(scope.row)">查看
</el-button>
<el-divider v-if="scope.row.subCount > 0 || scope.row.parental === 1" direction="vertical"></el-divider>
<el-button size="medium" v-bind:disabled="device == null || device.online === 0" icon="el-icon-video-camera" type="text" @click="queryRecords(scope.row)">设备录像
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
style="float: right"
@size-change="handleSizeChange"
@current-change="currentChange"
:current-page="currentPage"
:page-size="count"
:page-sizes="[15, 25, 35, 50]"
layout="total, sizes, prev, pager, next"
:total="total">
</el-pagination>
</el-main>
</el-container>
<!--设备列表-->
<el-table ref="channelListTable" :data="deviceChannelList" :height="winHeight" style="width: 100%" header-row-class-name="table-header">
<el-table-column prop="channelId" label="通道编号" min-width="200">
</el-table-column>
<el-table-column prop="deviceId" label="设备编号" min-width="200">
</el-table-column>
<el-table-column prop="name" label="通道名称" min-width="200">
</el-table-column>
<el-table-column label="快照" min-width="120">
<template v-slot:default="scope">
<el-image
:src="getSnap(scope.row)"
:preview-src-list="getBigSnap(scope.row)"
@error="getSnapErrorEvent(scope.row.deviceId, scope.row.channelId)"
:fit="'contain'"
style="width: 60px">
<div slot="error" class="image-slot">
<i class="el-icon-picture-outline"></i>
</div>
</el-image>
</template>
</el-table-column>
<el-table-column prop="subCount" label="子节点数" min-width="120">
</el-table-column>
<el-table-column prop="manufacture" label="厂家" min-width="120">
</el-table-column>
<el-table-column label="位置信息" min-width="200">
<template slot-scope="scope">
<span v-if="scope.row.longitude*scope.row.latitude > 0">{{ scope.row.longitude }},<br>{{ scope.row.latitude }}</span>
<span v-if="scope.row.longitude*scope.row.latitude === 0"></span>
</template>
</el-table-column>
<el-table-column prop="ptztypeText" label="云台类型" min-width="120"/>
<el-table-column label="开启音频" min-width="120">
<template slot-scope="scope">
<el-switch @change="updateChannel(scope.row)" v-model="scope.row.hasAudio" active-color="#409EFF">
</el-switch>
</template>
</el-table-column>
<el-table-column label="状态" min-width="120">
<template slot-scope="scope">
<div slot="reference" class="name-wrapper">
<el-tag size="medium" v-if="scope.row.status === 1">在线</el-tag>
<el-tag size="medium" type="info" v-if="scope.row.status === 0">离线</el-tag>
</div>
</template>
</el-table-column>
<el-table-column label="操作" min-width="280" fixed="right">
<template slot-scope="scope">
<!-- <el-button size="mini" icon="el-icon-video-play" v-if="scope.row.parental == 0" @click="sendDevicePush(scope.row)">播放</el-button> -->
<el-button size="medium" icon="el-icon-video-play" type="text" @click="sendDevicePush(scope.row)">播放</el-button>
<el-button size="medium" icon="el-icon-switch-button" type="text" style="color: #f56c6c" v-if="!!scope.row.streamId"
@click="stopDevicePush(scope.row)">停止
</el-button>
<el-divider direction="vertical"></el-divider>
<el-button size="medium" icon="el-icon-s-open" type="text" v-if="scope.row.subCount > 0 || scope.row.parental === 1"
@click="changeSubchannel(scope.row)">查看
</el-button>
<el-divider v-if="scope.row.subCount > 0 || scope.row.parental === 1" direction="vertical"></el-divider>
<el-button size="medium" icon="el-icon-video-camera" type="text" @click="queryRecords(scope.row)">设备录像
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
style="float: right"
@size-change="handleSizeChange"
@current-change="currentChange"
:current-page="currentPage"
:page-size="count"
:page-sizes="[15, 25, 35, 50]"
layout="total, sizes, prev, pager, next"
:total="total">
</el-pagination>
</div>
</template>
@@ -114,12 +126,14 @@ import uiHeader from '../layout/UiHeader.vue'
import moment from "moment";
import DviceService from "./service/DeviceService";
import DeviceService from "./service/DeviceService";
import DeviceTree from "./common/DeviceTree";
export default {
name: 'channelList',
components: {
devicePlayer,
uiHeader
uiHeader,
DeviceTree
},
data() {
return {
@@ -134,12 +148,13 @@ export default {
searchSrt: "",
channelType: "",
online: "",
winHeight: window.innerHeight - 250,
currentPage: parseInt(this.$route.params.page),
count: parseInt(this.$route.params.count),
winHeight: window.innerHeight - 200,
currentPage: 1,
count: 15,
total: 0,
beforeUrl: "/deviceList",
isLoging: false,
showTree: false,
loadSnap: {}
};
},
@@ -172,19 +187,16 @@ export default {
initParam: function () {
this.deviceId = this.$route.params.deviceId;
this.parentChannelId = this.$route.params.parentChannelId;
this.currentPage = parseInt(this.$route.params.page);
this.count = parseInt(this.$route.params.count);
this.currentPage = 1;
this.count = 15;
if (this.parentChannelId == "" || this.parentChannelId == 0) {
this.beforeUrl = "/deviceList"
}
},
currentChange: function (val) {
var url = `/${this.$router.currentRoute.name}/${this.deviceId}/${this.parentChannelId}/${this.count}/${val}`
this.$router.push(url).then(() => {
this.initParam();
this.initData();
})
this.currentPage = val;
this.initData();
},
handleSizeChange: function (val) {
this.count = val;
@@ -316,28 +328,48 @@ export default {
})
},
showSubchannels: function (channelId) {
let that = this;
if (!this.showTree) {
this.$axios({
method: 'get',
url: `/api/device/query/sub_channels/${this.deviceId}/${this.parentChannelId}/channels`,
params: {
page: this.currentPage,
count: this.count,
query: this.searchSrt,
online: this.online,
channelType: this.channelType
}
}).then( (res) =>{
this.total = res.data.total;
this.deviceChannelList = res.data.list;
// 防止出现表格错位
this.$nextTick(() => {
this.$refs.channelListTable.doLayout();
})
}).catch(function (error) {
console.log(error);
});
}else {
this.$axios({
method: 'get',
url: `/api/device/query/tree/channel/${this.deviceId}`,
params: {
parentId: this.parentChannelId,
page: this.currentPage,
count: this.count,
}
}).then((res)=> {
this.total = res.data.total;
this.deviceChannelList = res.data.list;
// 防止出现表格错位
this.$nextTick(() => {
this.$refs.channelListTable.doLayout();
})
}).catch(function (error) {
console.log(error);
});
}
this.$axios({
method: 'get',
url: `/api/device/query/sub_channels/${this.deviceId}/${this.parentChannelId}/channels`,
params: {
page: that.currentPage,
count: that.count,
query: that.searchSrt,
online: that.online,
channelType: that.channelType
}
}).then(function (res) {
that.total = res.data.total;
that.deviceChannelList = res.data.list;
// 防止出现表格错位
that.$nextTick(() => {
that.$refs.channelListTable.doLayout();
})
}).catch(function (error) {
console.log(error);
});
},
search: function () {
this.currentPage = 1;
@@ -355,6 +387,29 @@ export default {
},
refresh: function () {
this.initData();
},
switchTree: function (){
this.showTree = true;
this.deviceChannelList = [];
this.parentChannelId = 0;
this.currentPage = 1;
},
switchList: function (){
this.showTree = false;
this.deviceChannelList = [];
this.parentChannelId = 0;
this.currentPage = 1;
this.initData();
},
treeNodeClickEvent: function (device, data, isCatalog) {
console.log(device)
if (!!!data.channelId) {
this.parentChannelId = device.deviceId;
}else {
this.parentChannelId = data.channelId;
}
this.initData();
}
}

View File

@@ -4,7 +4,7 @@
<el-header>设备列表</el-header>
<el-main style="background-color: #ffffff;">
<div class="device-tree-main-box">
<el-tree :props="defaultProps" :load="loadNode" lazy @node-click="handleNodeClick"@node-contextmenu="handleContextMenu" style="min-width: 100%; display:inline-block !important;">
<el-tree ref="gdTree" :props="defaultProps" :load="loadNode" lazy @node-click="handleNodeClick"@node-contextmenu="handleContextMenu" node-key="id" style="min-width: 100%; display:inline-block !important;">
<span class="custom-tree-node" slot-scope="{ node, data }" style="width: 100%">
<span v-if="node.data.type === 0 && node.data.online" title="在线设备" class="device-online iconfont icon-jiedianleizhukongzhongxin2"></span>
<span v-if="node.data.type === 0 && !node.data.online " title="离线设备" class="device-offline iconfont icon-jiedianleizhukongzhongxin2"></span>
@@ -47,98 +47,112 @@ export default {
}
};
},
props: ['clickEvent', 'contextMenuEvent'],
props: ['device', 'onlyCatalog', 'clickEvent', 'contextMenuEvent'],
methods: {
handleNodeClick(data,node,element) {
console.log("点击事件")
console.log(data)
let deviceNode = this.$refs.gdTree.getNode(data.userData.deviceId)
if(typeof (this.clickEvent) == "function") {
this.clickEvent(data.userData)
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(event, data.userData)
this.contextMenuEvent(deviceNode.data.userData, event, data.userData, data.type === 2)
}
},
loadNode: function(node, resolve){
console.log(this.device)
if (node.level === 0) {
this.deviceService.getAllDeviceList((data)=>{
console.log(data)
if (data.length > 0) {
let nodeList = []
for (let i = 0; i < data.length; i++) {
console.log(data[i].name)
let node = {
name: data[i].name || data[i].deviceId,
isLeaf: false,
id: data[i].deviceId,
type: data[i].online,
online: data[i].online === 1,
userData: data[i]
}
nodeList.push(node);
}
resolve(nodeList)
}else {
resolve([])
if (this.device) {
let node = {
name: this.device.name || this.device.deviceId,
isLeaf: false,
id: this.device.deviceId,
type: this.device.online,
online: this.device.online === 1,
userData: this.device
}
}, (list)=>{
resolve([node])
}else {
this.deviceService.getAllDeviceList((data)=>{
console.log(data)
if (data.length > 0) {
let nodeList = []
for (let i = 0; i < data.length; i++) {
console.log(data[i].name)
let node = {
name: data[i].name || data[i].deviceId,
isLeaf: false,
id: data[i].deviceId,
type: data[i].online,
online: data[i].online === 1,
userData: data[i]
}
nodeList.push(node);
}
resolve(nodeList)
}else {
resolve([])
}
}, (list)=>{
console.log("设备加载完成")
}, (error)=>{
}, (error)=>{
})
}
if (node.level === 1) {
})
}
}else {
let channelArray = []
this.deviceService.getAllChannel(true, true, node.data.id, catalogData =>{
this.deviceService.getTree(node.data.userData.deviceId, node.data.id, this.onlyCatalog, catalogData =>{
console.log(catalogData)
channelArray = channelArray.concat(catalogData)
this.channelDataHandler(channelArray, resolve)
},(endCatalogData) => {
this.deviceService.getAllChannel(false, true, node.data.id, channelData => {
channelArray = channelArray.concat(channelData)
this.channelDataHandler(channelArray, resolve)
}, endChannelList => {
})
})
}else if (node.level > 1){
let channelArray = []
this.deviceService.getAllSubChannel(true, node.data.deviceId, node.data.id, (catalogData)=>{
channelArray = channelArray.concat(catalogData)
this.channelDataHandler(channelArray, resolve)
}, (endCatalogData)=>{
this.deviceService.getAllSubChannel(false, node.data.deviceId, node.data.id, (channelData)=>{
channelArray = channelArray.concat(channelData)
this.channelDataHandler(channelArray, resolve)
})
})
}
},
channelDataHandler: function (data, resolve) {
if (data.length > 0) {
let nodeList = []
for (let i = 0; i < data.length; i++) {
for (let i = 0; i <data.length; i++) {
let item = data[i];
let type = 3;
if (data[i].subCount > 0 || data[i].parental === 1) {
if (item.id.length <= 10) {
type = 2;
}else if (data[i].ptztype === 1 ) { // 1-球机;2-半球;3-固定枪机;4-遥控枪机
type = 4;
}else if (data[i].ptztype === 2) {
type = 5;
}else if (data[i].ptztype === 3 || data[i].ptztype === 4) {
type = 6;
}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;
}
}
}
let node = {
name: data[i].name || data[i].channelId,
isLeaf: data[i].subCount === 0,
id: data[i].channelId,
deviceId: data[i].deviceId,
name: item.name || item.basicData.channelId,
isLeaf: type !== 2,
id: item.id,
deviceId: item.deviceId,
type: type,
online: data[i].status === 1,
hasGPS: data[i].longitude*data[i].latitude !== 0,
userData: data[i]
online: item.basicData.status === 1,
hasGPS: item.basicData.longitude*item.basicData.latitude !== 0,
userData: item.basicData
}
nodeList.push(node);
}
@@ -146,6 +160,9 @@ export default {
}else {
resolve([])
}
},
reset: function (){
this.$forceUpdate();
}
},
destroyed() {

View File

@@ -0,0 +1,112 @@
<template>
<div id="DeviceTree" style="width: 100%;height: 100%; background-color: #FFFFFF; overflow: auto">
<el-container>
<el-header>设备列表</el-header>
<el-main style="background-color: #ffffff;">
<div class="device-tree-main-box">
<tree
:nodes="nodes"
@onClick="onClick"
@onCheck="onCheck"
@onExpand="onExpand"
@onCreated="handleCreated"
/>
</div>
</el-main>
</el-container>
</div>
</template>
<script>
import DeviceService from "../service/DeviceService.js";
import tree from "vue-giant-tree";
export default {
name: 'DeviceTreeForZtree',
components: {
tree
},
data() {
return {
deviceService: new DeviceService(),
device: null,
nodes:[],
setting: {
callback: {
beforeExpand: this.beforeExpand
},
// async: {
// enable: true,
// type: "get",
// url: `/api/device/query/tree`,
// contentType: "application/json",
// // autoParam: ["pid=parentId"],
// },
check: {
enable: false,
},
edit: {
enable: false,
}
},
defaultProps: {
children: 'children',
label: 'name',
isLeaf: 'isLeaf'
}
};
},
props: ['clickEvent', 'contextMenuEvent'],
mounted() {
this.deviceService.getAllDeviceList((data)=>{
console.log(data)
for (let i = 0; i < data.length; i++) {
console.log(data[i].name)
let node = {
name: data[i].name || data[i].deviceId,
id: data[i].deviceId,
isParent: true,
}
this.nodes.push(node)
}
}, (list)=>{
console.log("设备加载完成")
})
},
methods: {
onClick(evt, treeId, treeNode) {
console.log(evt)
console.log(treeId)
console.log(treeNode)
},
onCheck(evt, treeId, treeNode) {
console.log(evt)
},
beforeExpand(treeId, treeNode) {
console.log(treeId)
console.log(treeNode)
return true;
},
onExpand(evt, treeId, treeNode) {
// console.log(evt)
// console.log(treeId)
// console.log(treeNodes)
},
handleCreated(ztreeObj) {
console.log(ztreeObj)
}
}
}
</script>
<style>
.device-tree-main-box{
text-align: left;
}
.device-online{
color: #252525;
}
.device-offline{
color: #727272;
}
</style>

View File

@@ -42,6 +42,12 @@
<el-option key="GCJ02" label="GCJ02" value="GCJ02"></el-option>
</el-select>
</el-form-item>
<el-form-item label="目录结构" prop="treeType" >
<el-select v-model="form.treeType" style="float: left; width: 100%" >
<el-option key="WGS84" label="行政区划" value="CivilCode"></el-option>
<el-option key="GCJ02" label="业务分组" value="BusinessGroup"></el-option>
</el-select>
</el-form-item>
<el-form-item label="目录订阅" title="0为取消订阅" prop="subscribeCycleForCatalog" >
<el-input v-model="form.subscribeCycleForCatalog" clearable ></el-input>
</el-form-item>

View File

@@ -107,20 +107,24 @@ export default {
console.log(idx);
this.clear(idx.substring(idx.length - 1))
},
clickEvent: function (data) {
if (data.channelId && data.subCount == 0) {
this.sendDevicePush(data)
clickEvent: function (device, data, isCatalog) {
if (data.channelId && !isCatalog) {
if (device.online === 0) {
this.$message.error('设备离线!不允许点播');
}else {
this.sendDevicePush(data)
}
}
},
contextMenuEvent: function (data) {
contextMenuEvent: function (device, event, data, isCatalog) {
},
//通知设备上传媒体流
sendDevicePush: function (itemData) {
if (itemData.status === 0) {
this.$message.error('设备离线!');
return
}
// if (itemData.status === 0) {
// this.$message.error('设备离线!');
// return
// }
this.save(itemData)
let deviceId = itemData.deviceId;
// this.isLoging = true;

View File

@@ -16,7 +16,8 @@
<el-descriptions class="margin-top" :title="channel.name" :column="1" :colon="true" size="mini" :labelStyle="labelStyle" >
<el-descriptions-item label="编号" >{{channel.channelId}}</el-descriptions-item>
<el-descriptions-item label="型号">{{channel.model}}</el-descriptions-item>
<el-descriptions-item label="经度" >{{channel.longitude}},{{channel.latitude}}</el-descriptions-item>
<el-descriptions-item label="经度" >{{channel[longitudeStr]}}</el-descriptions-item>
<el-descriptions-item label="纬度" >{{channel[latitudeStr]}}</el-descriptions-item>
<el-descriptions-item label="生产厂商">{{channel.manufacture}}</el-descriptions-item>
<el-descriptions-item label="行政区域" >{{channel.civilCode}}</el-descriptions-item>
<el-descriptions-item label="设备归属" >{{channel.owner}}</el-descriptions-item>
@@ -28,7 +29,7 @@
</el-descriptions-item>
</el-descriptions>
<div style="padding-top: 10px">
<el-button type="primary" size="small" title="播放" icon="el-icon-video-play" @click="play(channel)"></el-button>
<el-button v-bind:disabled="device == null || device.online === 0" type="primary" size="small" title="播放" icon="el-icon-video-play" @click="play(channel)"></el-button>
<el-button type="primary" size="small" title="编辑位置" icon="el-icon-edit" @click="edit(channel)"></el-button>
<el-button type="primary" size="small" title="轨迹查询" icon="el-icon-map-location" @click="getTrace(channel)"></el-button>
</div>
@@ -64,11 +65,14 @@ export default {
layer: null,
lineLayer: null,
channel: null,
device: null,
infoBoxId: null,
labelStyle: {
width: "56px"
},
isLoging: false,
longitudeStr: "longitude",
latitudeStr: "latitude",
};
},
created() {
@@ -78,17 +82,27 @@ export default {
setTimeout(()=>{ // 延迟以等待地图加载完成 TODO 后续修改为通过是实际这;状态加回调完成
this.deviceService.getAllChannel(false, false, this.$route.query.deviceId, this.channelsHandler)
}, 1000)
}
if (window.mapParam.coordinateSystem == "GCJ-02") {
this.longitudeStr = "longitudeGcj02";
this.latitudeStr = "latitudeGcj02";
}else if (window.mapParam.coordinateSystem == "WGS84") {
this.longitudeStr = "longitudeWgs84";
this.latitudeStr = "latitudeWgs84";
}else {
this.longitudeStr = "longitude";
this.latitudeStr = "latitude";
}
},
destroyed() {
},
methods: {
clickEvent: function (data) {
if (data.channelId && data.subCount == 0) {
clickEvent: function (device, data, isCatalog) {
this.device = device;
if (data.channelId && !isCatalog) {
// 点击通道
if (data.longitude * data.latitude === 0) {
if (data[this.longitudeStr] * data[this.latitudeStr] === 0) {
this.$message.error('未获取到位置信息');
} else {
if (this.layer != null) {
@@ -96,26 +110,29 @@ export default {
}
this.closeInfoBox()
this.layer = this.$refs.map.addLayer([{
position: [data.longitude, data.latitude],
position: [data[this.longitudeStr], data[this.latitudeStr]],
image: {
src: this.getImageByChannel(data),
anchor: [0.5, 1]
},
data: data
}], this.featureClickEvent)
this.$refs.map.panTo([data.longitude, data.latitude], mapParam.maxZoom)
this.$refs.map.panTo([data[this.longitudeStr], data[this.latitudeStr]], mapParam.maxZoom)
}
}
},
contextmenuEventHandler: function (event, data) {
if (data.channelId && data.subCount == 0) {
contextmenuEventHandler: function (device, event, data, isCatalog) {
console.log(device)
console.log(device.online)
this.device = device;
if (data.channelId && !isCatalog) {
// 点击通道
this.$contextmenu({
items: [
{
label: "播放",
icon: "el-icon-video-play",
disabled: false,
disabled: device.online === 0,
onClick: () => {
this.play(data);
}
@@ -183,22 +200,11 @@ export default {
this.clean()
this.closeInfoBox()
let params = [];
let longitudeStr;
let latitudeStr;
if (window.mapParam.coordinateSystem == "GCJ-02") {
longitudeStr = "longitudeGcj02";
latitudeStr = "latitudeGcj02";
}else if (window.mapParam.coordinateSystem == "WGS84") {
longitudeStr = "longitudeWgs84";
latitudeStr = "latitudeWgs84";
}else {
longitudeStr = "longitude";
latitudeStr = "latitude";
}
for (let i = 0; i < channels.length; i++) {
let longitude = channels[i][longitudeStr];
let latitude = channels[i][latitudeStr];
let longitude = channels[i][this.longitudeStr];
let latitude = channels[i][this.latitudeStr];
if (longitude * latitude === 0) {
continue;
}
@@ -217,7 +223,7 @@ export default {
this.layer = this.$refs.map.addLayer(params, this.featureClickEvent)
console.log(4)
if (params.length === 1) {
this.$refs.map.panTo([channels[0][longitudeStr], channels[0][latitudeStr]], mapParam.maxZoom)
this.$refs.map.panTo([channels[0][this.longitudeStr], channels[0][this.latitudeStr]], mapParam.maxZoom)
} else if (params.length > 1) {
this.$refs.map.fit(this.layer)
} else {
@@ -266,19 +272,7 @@ export default {
this.channel = channels[0]
}
this.$nextTick(() => {
let longitudeStr;
let latitudeStr;
if (window.mapParam.coordinateSystem == "GCJ-02") {
longitudeStr = "longitudeGcj02";
latitudeStr = "latitudeGcj02";
}else if (window.mapParam.coordinateSystem == "WGS84") {
longitudeStr = "longitudeWgs84";
latitudeStr = "latitudeWgs84";
}else {
longitudeStr = "longitude";
latitudeStr = "latitude";
}
let position = [this.channel[longitudeStr], this.channel[latitudeStr]];
let position = [this.channel[this.longitudeStr], this.channel[this.latitudeStr]];
this.infoBoxId = this.$refs.map.openInfoBox(position, this.$refs.infobox, [0, -50])
})
},

View File

@@ -133,6 +133,49 @@ class DeviceService{
if (typeof (callback) == "function") callback(res.data)
}).catch(errorCallback);
}
getTree(deviceId, id, param3, param4) {
}
getTree(deviceId, parentId, onlyCatalog, callback, endCallback, errorCallback) {
let currentPage = 1;
let count = 100;
let catalogList = []
this.getTreeIteration(deviceId, parentId, onlyCatalog, catalogList, currentPage, count, callback, endCallback, errorCallback)
}
getTreeIteration(deviceId, parentId, onlyCatalog, catalogList, currentPage, count, callback, endCallback, errorCallback) {
this.getTreeInfo(deviceId, parentId, onlyCatalog, currentPage, count, (data) => {
if (data.list) {
if (typeof (callback) == "function") callback(data.list)
catalogList = catalogList.concat(data.list);
if (catalogList.length < data.total) {
currentPage ++
this.getTreeIteration(deviceId, parentId, onlyCatalog, catalogList, currentPage, count, callback, endCallback, errorCallback)
}else {
if (typeof (endCallback) == "function") endCallback(catalogList)
}
}
}, errorCallback)
}
getTreeInfo(deviceId, parentId, onlyCatalog, currentPage, count, callback, errorCallback) {
if (onlyCatalog == null || typeof onlyCatalog === "undefined") {
onlyCatalog = false;
}
this.$axios({
method: 'get',
url: `/api/device/query/tree/${deviceId}`,
params:{
page: currentPage,
count: count,
parentId: parentId,
onlyCatalog: onlyCatalog
}
}).then((res) =>{
if (typeof (callback) == "function") callback(res.data)
}).catch(errorCallback);
}
}
export default DeviceService;