修改地图

dev
夜笙歌 1 year ago
parent 4c049995a1
commit 4de7cd2eb0

@ -281,8 +281,7 @@ export default {
this.num3 = data.onlineDeviceNum this.num3 = data.onlineDeviceNum
}, },
async setAlarmInfos() { async setAlarmInfos() {
const {rows: data} = await getAlarmInfos({"sceneId": this.sceneId}) const {rows: data} = await getAlarmInfos({"sceneId": this.$store.getters.sceneId})
console.log(data)
this.table1Data = data.map((e, i) => { this.table1Data = data.map((e, i) => {
return { return {
value1: e.alarmInfoId, value1: e.alarmInfoId,

@ -46,25 +46,14 @@
<!-- </div>--> <!-- </div>-->
<!-- </el-col>--> <!-- </el-col>-->
<!-- </el-row>--> <!-- </el-row>-->
<el-table :cell-style="setStyle" :data="tableData" <el-table v-if="show" :cell-style="setStyle"
:header-cell-style="{ textAlign: 'center',backgroundColor:'#0a457d' }" v-if="show" :data="tableData" :header-cell-style="{ textAlign: 'center',backgroundColor:'#0a457d' }"
style="width: 100%;margin-top: 12px;"> style="width: 100%;margin-top: 12px;">
<el-table-column v-for="i in deviceDataColumns" :label="i.columnName" :prop="i.columnKey"> <el-table-column v-for="i in deviceDataColumns" :label="i.columnName" :prop="i.columnKey">
</el-table-column> </el-table-column>
<!-- <el-table-column label="传感器编号" prop="columnKey">-->
<!-- </el-table-column>-->
<!-- <el-table-column label="alias" prop="alias">-->
<!-- </el-table-column>-->
<!-- <el-table-column label="rssi" prop="rssi">-->
<!-- </el-table-column>-->
<!-- <el-table-column label="ts" prop="ts">-->
<!-- </el-table-column>-->
<!-- <el-table-column label="value1" prop="value1">-->
<!-- </el-table-column>-->
<!-- <el-table-column label="voltage" prop="voltage">-->
<!-- </el-table-column>-->
</el-table> </el-table>
<el-pagination :currentPage="currentPage" :pageSize="5" :total="total" background layout="prev, pager, next" @current-change="currentChange"> <el-pagination :currentPage="currentPage" :pageSize="5" :total="total" background
layout="prev, pager, next" @current-change="currentChange">
</el-pagination> </el-pagination>
</div> </div>
</div> </div>
@ -72,9 +61,8 @@
</el-collapse> </el-collapse>
</div> </div>
<!-- <el-collapse accordion>--> <div v-show="isMap" id="map" class="map"></div>
<div v-for="i in bottomData"> <div v-for="i in bottomData">
<!-- <template slot="title">-->
<div class="itemBg"> <div class="itemBg">
<div class="icon"></div> <div class="icon"></div>
<div class="icon1"></div> <div class="icon1"></div>
@ -93,9 +81,7 @@
<div class="info2">{{ i.deviceLocation }}</div> <div class="info2">{{ i.deviceLocation }}</div>
</div> </div>
</div> </div>
<!-- </template>-->
</div> </div>
<!-- </el-collapse>-->
</div> </div>
</div> </div>
</template> </template>
@ -107,9 +93,9 @@ import {
getLinkDevices getLinkDevices
} from '@/api/board/senso' } from '@/api/board/senso'
let map = null
export default { export default {
components: { components: {},
},
data() { data() {
return { return {
topData: {}, topData: {},
@ -123,10 +109,15 @@ export default {
total: 0, total: 0,
currentPage: 1, currentPage: 1,
deviceDataColumns: [], deviceDataColumns: [],
show:false show: false,
isMap:false
} }
}, },
async mounted() { async mounted() {
map = new AMap.Map('map', {
zoom: 11,
center: [113.4, 23.35],
});
if (this.$route.query.id) { if (this.$route.query.id) {
this.deviceId = this.$route.query.id this.deviceId = this.$route.query.id
this.deviceModeId = this.$route.query.deviceModeId this.deviceModeId = this.$route.query.deviceModeId
@ -134,6 +125,22 @@ export default {
await this.getData() await this.getData()
}, },
methods: { methods: {
setPolyline(e) {
let polyline = new AMap.Polyline({
path: e,
borderWeight: 2, // 线 1
});
map.add(polyline);
map.setFitView()
},
setMarker(e, i) {
let marker = new AMap.Marker({
position: e, // [116.39, 39.9]
title: i
});
map.add(marker);
map.setFitView()
},
async currentChange(e) { async currentChange(e) {
this.currentPage = e this.currentPage = e
await this.setHistoryData() await this.setHistoryData()
@ -155,15 +162,34 @@ export default {
this.topData = data || {} this.topData = data || {}
}, },
async setHistoryData() { async setHistoryData() {
this.isMap = false
map.clearMap()
this.show = false this.show = false
const {data} = await getHistoryData({ const {data} = await getHistoryData({
"sceneId": this.$store.getters.sceneId, "sceneId": this.$store.getters.sceneId,
"deviceId": this.deviceId, "deviceId": this.deviceId,
deviceModeId: this.deviceModeId, deviceModeId: this.deviceModeId,
"offset": this.currentPage - 1, "offset": this.currentPage - 1,
"limit": 1, "limit": 10,
"startTime": 0 "startTime": 0
}) })
let dataList = data.historyData.dataList
if (dataList.filter(e => (Object.keys(e).includes('longitude') || Object.keys(e).includes('longitude'))).length > 0) {
this.isMap = true
dataList.filter(e => (Object.keys(e).includes('longitude') || Object.keys(e).includes('longitude'))).forEach(e => {
this.setMarker([e.longitude, e.latitude], e.ts)
})
this.setPolyline(dataList.filter(e => (Object.keys(e).includes('longitude') || Object.keys(e).includes('longitude'))).map(e => {
return [e.longitude, e.latitude]
}))
this.tableData = data.historyData.dataList
this.total = data.historyData.count
this.currentPage = 1
this.deviceDataColumns = data.deviceDataColumns
this.$nextTick(() => {
this.show = true
})
} else {
this.tableData = data.historyData.dataList this.tableData = data.historyData.dataList
this.total = data.historyData.count this.total = data.historyData.count
this.currentPage = 1 this.currentPage = 1
@ -171,6 +197,7 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.show = true this.show = true
}) })
}
}, },
async setLinkDevices() { async setLinkDevices() {
const {data} = await getLinkDevices(this.deviceId) const {data} = await getLinkDevices(this.deviceId)
@ -314,4 +341,9 @@ export default {
} }
} }
} }
.map {
width: 100%;
height: 50vh;
}
</style> </style>

Loading…
Cancel
Save