|
|
@@ -14,16 +14,16 @@
|
|
|
v-if="isShowAlarm"
|
|
|
:alarm="alarm"
|
|
|
class="c-alarm cv"
|
|
|
- @close="isShowAlarm=false"
|
|
|
+ @close="onMidAlarmClose"
|
|
|
/>
|
|
|
<AlarmInfo
|
|
|
- v-for="(item, index) in alarmList.slice(0,4)"
|
|
|
+ v-for="(item, index) in alarmList.slice(0, 4)"
|
|
|
v-show="subAlarmShow"
|
|
|
:key="item.id"
|
|
|
:alarm="item"
|
|
|
:style="alarmStyleMap[index]"
|
|
|
class="c-alarm--sub"
|
|
|
- @close="onAlarmClose(index)"
|
|
|
+ @close="onListAlarmClose(index)"
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -85,8 +85,8 @@ export default {
|
|
|
marks: [],
|
|
|
alarmPosition: [],
|
|
|
isShowAlarm: false,
|
|
|
- alarm: {},
|
|
|
- alarmList: [],
|
|
|
+ alarm: {}, // 中间的
|
|
|
+ alarmList: [], // 四角的
|
|
|
subAlarmShow: false
|
|
|
}
|
|
|
},
|
|
|
@@ -170,7 +170,10 @@ export default {
|
|
|
const markObj = new AMap.Marker({
|
|
|
position: [Number(longitude), Number(latitude)],
|
|
|
title: name,
|
|
|
- icon: onlineStatus === 1 ? this.$onlineIcon : this.$offlineIcon
|
|
|
+ content: this.getMarkerContent(
|
|
|
+ onlineStatus,
|
|
|
+ this.getMarkActive(id)
|
|
|
+ )
|
|
|
})
|
|
|
this.marks.push(markObj)
|
|
|
this.$deviceMap[id] = {
|
|
|
@@ -223,34 +226,72 @@ export default {
|
|
|
}
|
|
|
this.polylines = polylines
|
|
|
this.resetView()
|
|
|
+ map.on('click', () => {
|
|
|
+ map.zoomIn()
|
|
|
+ })
|
|
|
+ polygon.on('click', () => {
|
|
|
+ map.zoomIn()
|
|
|
+ })
|
|
|
})
|
|
|
},
|
|
|
- onAlarmClose (index) {
|
|
|
- this.alarmList.splice(index, 1)
|
|
|
+ /* 关闭警告后的回调 */
|
|
|
+ handleAlarmClose (alarm) {
|
|
|
+ /* 重置地图缩放 */
|
|
|
+ if (!this.alarmList.length && !this.isShowAlarm) {
|
|
|
+ this.resetView()
|
|
|
+ }
|
|
|
+ /* 关闭标记点活跃 */
|
|
|
+ this.$alldeviceMap[alarm.deviceId]?.markObj?.setContent(
|
|
|
+ this.getMarkerContent(
|
|
|
+ this.$alldeviceMap[alarm.deviceId].onlineStatus,
|
|
|
+ this.getMarkActive(alarm.deviceId)
|
|
|
+ )
|
|
|
+ )
|
|
|
+ /* 联动警告列表关闭 */
|
|
|
+ this.$emit('closeAlarm', alarm)
|
|
|
},
|
|
|
+ /* 处理关闭逻辑 */
|
|
|
+ onMidAlarmClose () {
|
|
|
+ this.handleAlarmClose(this.alarm)
|
|
|
+ this.isShowAlarm = false
|
|
|
+ this.alarm = {}
|
|
|
+ },
|
|
|
+ onListAlarmClose (index) {
|
|
|
+ const alarm = this.alarmList.splice(index, 1)[0]
|
|
|
+ this.handleAlarmClose(alarm)
|
|
|
+ },
|
|
|
+ /* * * * * * * * */
|
|
|
closeOfflineAlarm (alarm, offlineMap) {
|
|
|
- if (offlineMap.includes(this.alarm.deviceErrorId) && this.alarm.deviceId === alarm.deviceId) {
|
|
|
- this.isShowAlarm = false
|
|
|
+ if (
|
|
|
+ offlineMap.includes(this.alarm.deviceErrorId)
|
|
|
+ && this.alarm.deviceId === alarm.deviceId
|
|
|
+ ) {
|
|
|
+ this.onMidAlarmClose()
|
|
|
return
|
|
|
}
|
|
|
- const index = this.alarmList.findIndex(i => offlineMap.includes(i.deviceErrorId) && i.deviceId === alarm.deviceId)
|
|
|
+ const index = this.alarmList.findIndex(
|
|
|
+ i => offlineMap.includes(i.deviceErrorId) && i.deviceId === alarm.deviceId
|
|
|
+ )
|
|
|
if (index > -1) {
|
|
|
- this.alarmList.splice(index, 1)
|
|
|
+ this.onListAlarmClose(index)
|
|
|
}
|
|
|
},
|
|
|
setNewAlarm (alarm) {
|
|
|
const {
|
|
|
markObj: marker,
|
|
|
mac,
|
|
|
- address
|
|
|
+ address,
|
|
|
+ onlineStatus
|
|
|
} = this.$alldeviceMap?.[alarm.deviceId] || {}
|
|
|
alarm = { ...alarm, mac, address, status: alarm.status.label }
|
|
|
- if (!marker) { // 没有经纬度 周围展示不移动
|
|
|
+ if (!marker) {
|
|
|
+ // 没有经纬度 周围展示不移动
|
|
|
this.alarmList.unshift(alarm)
|
|
|
this.subAlarmShow = true
|
|
|
return
|
|
|
}
|
|
|
- if (this.isShowAlarm || this.isMoving) { // 有中间占位警告 将当前中间的四周展示 或者是正在移动的警告
|
|
|
+ if (this.isShowAlarm || this.isMoving) {
|
|
|
+ // 有中间占位警告 将当前中间的四周展示 或者是正在移动的警告
|
|
|
this.alarmList.unshift(this.alarm)
|
|
|
}
|
|
|
// 中间展示
|
|
|
@@ -261,15 +302,17 @@ export default {
|
|
|
this.isShowAlarm = false
|
|
|
this.subAlarmShow = false
|
|
|
this.isMoving = true // 防止间隔过短的警告
|
|
|
- this.$mapMoveTimer = setTimeout(() => { // 还是当前地点没有动地图
|
|
|
+ this.$mapMoveTimer = setTimeout(() => {
|
|
|
+ // 还是当前地点没有动地图
|
|
|
this.onSetNewAlarmFitView()
|
|
|
}, 1000)
|
|
|
this.map.setFitView(marker, false, [60, 60, 60, 60], 20)
|
|
|
this.curMarker = marker
|
|
|
+ // 标记点激活
|
|
|
+ marker.setContent(this.getMarkerContent(onlineStatus, true))
|
|
|
},
|
|
|
resetView () {
|
|
|
this.map.setFitView(this.polylines)
|
|
|
- this.isShowAlarm = false
|
|
|
},
|
|
|
onSetNewAlarmFitView () {
|
|
|
clearTimeout(this.$mapMoveTimer)
|
|
|
@@ -312,6 +355,16 @@ export default {
|
|
|
this.subAlarmShow = true
|
|
|
this.isMoving = false
|
|
|
},
|
|
|
+ getMarkerContent (onlineStatus, active) {
|
|
|
+ return `<div class="c-marker ${active ? 'active' : ''} ${
|
|
|
+ onlineStatus === 1 ? 'online' : 'offline'
|
|
|
+ }"></div>`
|
|
|
+ },
|
|
|
+ getMarkActive (deviceId) {
|
|
|
+ return this.alarmList
|
|
|
+ .concat(this.alarm)
|
|
|
+ .some(i => i.deviceId === deviceId)
|
|
|
+ },
|
|
|
refreshMarkers () {
|
|
|
const map = {}
|
|
|
const arr = []
|
|
|
@@ -322,8 +375,8 @@ export default {
|
|
|
if (device) {
|
|
|
device.onlineStatus = onlineStatus
|
|
|
device.markObj.setPosition([Number(longitude), Number(latitude)])
|
|
|
- device.markObj.setIcon(
|
|
|
- onlineStatus === 1 ? this.$onlineIcon : this.$offlineIcon
|
|
|
+ device.markObj.setContent(
|
|
|
+ this.getMarkerContent(onlineStatus, this.getMarkActive(id))
|
|
|
)
|
|
|
map[id] = device
|
|
|
delete this.$deviceMap[id]
|
|
|
@@ -331,7 +384,10 @@ export default {
|
|
|
const markObj = new this.$AMap.Marker({
|
|
|
position: [Number(longitude), Number(latitude)],
|
|
|
title: name,
|
|
|
- icon: onlineStatus === 1 ? this.$onlineIcon : this.$offlineIcon
|
|
|
+ content: this.getMarkerContent(
|
|
|
+ onlineStatus,
|
|
|
+ this.getMarkActive(id)
|
|
|
+ )
|
|
|
})
|
|
|
map[id] = {
|
|
|
onlineStatus,
|
|
|
@@ -377,6 +433,67 @@ export default {
|
|
|
.amap-container {
|
|
|
background: none !important;
|
|
|
}
|
|
|
+ ::v-deep {
|
|
|
+ .c-marker {
|
|
|
+ width: 14px;
|
|
|
+ height: 19px;
|
|
|
+ transform: translate(-50%, -50%);
|
|
|
+ background-repeat: no-repeat;
|
|
|
+ background-size: 100% 100%;
|
|
|
+ background-position: center;
|
|
|
+ position: relative;
|
|
|
+ &.online {
|
|
|
+ background-image: url("~@/assets/v1/icon_position1.svg");
|
|
|
+ }
|
|
|
+ &.offline {
|
|
|
+ background-image: url("~@/assets/v1/icon_position2.svg");
|
|
|
+ }
|
|
|
+ &.active::before {
|
|
|
+ // 阴影
|
|
|
+ content: "";
|
|
|
+ position: absolute;
|
|
|
+ top: 3px;
|
|
|
+ left: 0;
|
|
|
+ right: 0;
|
|
|
+ bottom: 3px;
|
|
|
+ border-radius: 50%;
|
|
|
+ background-color: rgba(241, 34, 30, 0.9);
|
|
|
+ animation: scale 2s infinite;
|
|
|
+ }
|
|
|
+ &.active::after {
|
|
|
+ // 阴影
|
|
|
+ content: "";
|
|
|
+ position: absolute;
|
|
|
+ top: 3px;
|
|
|
+ left: 0;
|
|
|
+ right: 0;
|
|
|
+ bottom: 3px;
|
|
|
+ border-radius: 50%;
|
|
|
+ background-color: rgba(241, 34, 30, 0.9);
|
|
|
+ animation: scale2 2s infinite;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @keyframes scale {
|
|
|
+ 0% {
|
|
|
+ transform: scale(1);
|
|
|
+ opacity: 0.9;
|
|
|
+ }
|
|
|
+ 100% {
|
|
|
+ transform: scale(6);
|
|
|
+ opacity: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ @keyframes scale2 {
|
|
|
+ 0% {
|
|
|
+ transform: scale(1);
|
|
|
+ opacity: 0.9;
|
|
|
+ }
|
|
|
+ 100% {
|
|
|
+ transform: scale(12);
|
|
|
+ opacity: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
.c-alarm {
|
|
|
position: absolute;
|
|
|
z-index: 99;
|