From f5fcc79a2c7e6379a73b14ba4e366ad1654e9475 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期日, 03 七月 2022 07:40:54 +0800 Subject: [PATCH] 优化国标树型展示 --- web_src/src/components/map.vue | 72 ++++++++++++++++------------------- 1 files changed, 33 insertions(+), 39 deletions(-) diff --git a/web_src/src/components/map.vue b/web_src/src/components/map.vue index e9e8628..d4a36cf 100644 --- a/web_src/src/components/map.vue +++ b/web_src/src/components/map.vue @@ -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 @@ layer: null, lineLayer: null, channel: null, + device: null, infoBoxId: null, labelStyle: { width: "56px" }, isLoging: false, + longitudeStr: "longitude", + latitudeStr: "latitude", }; }, created() { @@ -78,17 +82,27 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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]) }) }, -- Gitblit v1.8.0