|
@@ -35,6 +35,7 @@ export default {
|
|
carMarker: null,
|
|
carMarker: null,
|
|
pos: [],
|
|
pos: [],
|
|
posIndex: 0,
|
|
posIndex: 0,
|
|
|
|
+ carId2: null,
|
|
}
|
|
}
|
|
},
|
|
},
|
|
provide() {
|
|
provide() {
|
|
@@ -46,14 +47,15 @@ export default {
|
|
props: {
|
|
props: {
|
|
idInfo: Object,
|
|
idInfo: Object,
|
|
showRang: String,
|
|
showRang: String,
|
|
- carInfos:Object
|
|
|
|
|
|
+ carInfos: Object,
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
idInfo: {
|
|
idInfo: {
|
|
handler(val) {
|
|
handler(val) {
|
|
- this.markeList && this.markeList.forEach((element) => {
|
|
|
|
- this.map.remove(element)
|
|
|
|
- })
|
|
|
|
|
|
+ this.markeList &&
|
|
|
|
+ this.markeList.forEach((element) => {
|
|
|
|
+ this.map.remove(element)
|
|
|
|
+ })
|
|
if (this.timer) {
|
|
if (this.timer) {
|
|
clearTimeout(this.timer)
|
|
clearTimeout(this.timer)
|
|
}
|
|
}
|
|
@@ -67,20 +69,6 @@ export default {
|
|
},
|
|
},
|
|
deep: true,
|
|
deep: true,
|
|
},
|
|
},
|
|
- carInfos:{
|
|
|
|
- handler(newVal){
|
|
|
|
- this.markeList && this.markeList.forEach((element) => {
|
|
|
|
- this.map.remove(element)
|
|
|
|
- })
|
|
|
|
- if (this.timer) {
|
|
|
|
- clearTimeout(this.timer)
|
|
|
|
- }
|
|
|
|
- // console.log('----------id22',newVal.id);
|
|
|
|
- this.ids = newVal.id
|
|
|
|
- this.addCarMaker(this.AMap)
|
|
|
|
- },
|
|
|
|
- deep:true
|
|
|
|
- }
|
|
|
|
},
|
|
},
|
|
|
|
|
|
methods: {
|
|
methods: {
|
|
@@ -90,7 +78,7 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// 添加遮罩
|
|
// 添加遮罩
|
|
- addMask () {
|
|
|
|
|
|
+ addMask() {
|
|
const outer = [
|
|
const outer = [
|
|
new this.AMap.LngLat(-360, 90, true),
|
|
new this.AMap.LngLat(-360, 90, true),
|
|
new this.AMap.LngLat(-360, -90, true),
|
|
new this.AMap.LngLat(-360, -90, true),
|
|
@@ -100,10 +88,10 @@ export default {
|
|
new this.AMap.GeoJSON({
|
|
new this.AMap.GeoJSON({
|
|
geoJSON: geojson,
|
|
geoJSON: geojson,
|
|
getPolygon: (geojson, lnglats) => {
|
|
getPolygon: (geojson, lnglats) => {
|
|
- console.log('面',lnglats)
|
|
|
|
|
|
+ // console.log('面', lnglats)
|
|
const pathArray = [
|
|
const pathArray = [
|
|
// outer, //外边界
|
|
// outer, //外边界
|
|
- lnglats[0][0] //内边界需要遮罩区域
|
|
|
|
|
|
+ lnglats[0][0], //内边界需要遮罩区域
|
|
]
|
|
]
|
|
var polygon = new AMap.Polygon({
|
|
var polygon = new AMap.Polygon({
|
|
pathL: pathArray,
|
|
pathL: pathArray,
|
|
@@ -113,15 +101,14 @@ export default {
|
|
})
|
|
})
|
|
polygon.setPath(pathArray)
|
|
polygon.setPath(pathArray)
|
|
this.map.add(polygon)
|
|
this.map.add(polygon)
|
|
- }
|
|
|
|
|
|
+ },
|
|
})
|
|
})
|
|
-
|
|
|
|
},
|
|
},
|
|
async initMap() {
|
|
async initMap() {
|
|
return AMapLoader.load({
|
|
return AMapLoader.load({
|
|
key: 'a09220a9ab56352435dd123abf0c37f6', // 申请好的Web端开发者Key,首次调用 load 时必填
|
|
key: 'a09220a9ab56352435dd123abf0c37f6', // 申请好的Web端开发者Key,首次调用 load 时必填
|
|
version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
|
|
version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
|
|
- plugins: ['AMap.MoveAnimation','AMap.RangingTool', 'AMap.MouseTool', 'AMap.DistrictSearch', 'AMap.GeoJSON'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等 AMap.RangingTool(测距)
|
|
|
|
|
|
+ plugins: ['AMap.MoveAnimation', 'AMap.RangingTool', 'AMap.MouseTool', 'AMap.DistrictSearch', 'AMap.GeoJSON'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等 AMap.RangingTool(测距)
|
|
})
|
|
})
|
|
.then((AMap) => {
|
|
.then((AMap) => {
|
|
this.AMap = AMap
|
|
this.AMap = AMap
|
|
@@ -146,13 +133,13 @@ export default {
|
|
})
|
|
})
|
|
this.mouseTool.close(true)
|
|
this.mouseTool.close(true)
|
|
// 加载消防车辆信息
|
|
// 加载消防车辆信息
|
|
- this.loadFireCarInfo(AMap)
|
|
|
|
|
|
+ return this.loadFireCarInfo(AMap)
|
|
})
|
|
})
|
|
.catch((e) => {
|
|
.catch((e) => {
|
|
console.log(e)
|
|
console.log(e)
|
|
})
|
|
})
|
|
},
|
|
},
|
|
- imageIcon(isPublic,status, isOnline) {
|
|
|
|
|
|
+ imageIcon(isPublic, status, isOnline) {
|
|
if (isPublic) {
|
|
if (isPublic) {
|
|
if (status === 2) {
|
|
if (status === 2) {
|
|
return CarRepair
|
|
return CarRepair
|
|
@@ -167,7 +154,7 @@ export default {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// 加载消防车辆
|
|
// 加载消防车辆
|
|
- loadFireCarInfo(AMap) {
|
|
|
|
|
|
+ async loadFireCarInfo(AMap) {
|
|
const cache = {}
|
|
const cache = {}
|
|
const that = this
|
|
const that = this
|
|
// 刷新消防车辆
|
|
// 刷新消防车辆
|
|
@@ -175,9 +162,8 @@ export default {
|
|
const params = {
|
|
const params = {
|
|
deptId: that.depId,
|
|
deptId: that.depId,
|
|
}
|
|
}
|
|
- getCarList(params).then((res) => {
|
|
|
|
|
|
+ return getCarList(params).then((res) => {
|
|
for (const car of res.data) {
|
|
for (const car of res.data) {
|
|
-
|
|
|
|
const imageIcon = that.imageIcon(car.categoryId === 2, car.status, car.onlineStatus === 1)
|
|
const imageIcon = that.imageIcon(car.categoryId === 2, car.status, car.onlineStatus === 1)
|
|
|
|
|
|
const carImage = {
|
|
const carImage = {
|
|
@@ -201,7 +187,7 @@ export default {
|
|
<div style='width:100%;height:40px;border-bottom: 1px solid #EFEFEF;position:relative;padding:0 12px;display:flex;align-items: center;justify-content:space-between;'>
|
|
<div style='width:100%;height:40px;border-bottom: 1px solid #EFEFEF;position:relative;padding:0 12px;display:flex;align-items: center;justify-content:space-between;'>
|
|
<span style='font-size: 18px;font-weight: bold;margin-right:4px;'>${car.plateNumber}</span>
|
|
<span style='font-size: 18px;font-weight: bold;margin-right:4px;'>${car.plateNumber}</span>
|
|
<span style='display:inline-block;font-size:12px;border: 1px solid #547CD5;border-radius: 2px;color:#547CD5;padding:1px 5px;'>${
|
|
<span style='display:inline-block;font-size:12px;border: 1px solid #547CD5;border-radius: 2px;color:#547CD5;padding:1px 5px;'>${
|
|
- (car.onlineStatus === 1 ? '在线' : '离线')
|
|
|
|
|
|
+ car.onlineStatus === 1 ? '在线' : '离线'
|
|
}</span>
|
|
}</span>
|
|
</div>
|
|
</div>
|
|
<div style="width:100%;padding:4px 12px;">${car.depName}</div>
|
|
<div style="width:100%;padding:4px 12px;">${car.depName}</div>
|
|
@@ -223,7 +209,7 @@ export default {
|
|
})
|
|
})
|
|
// 点击消防车车
|
|
// 点击消防车车
|
|
marker.on('click', (e) => {
|
|
marker.on('click', (e) => {
|
|
- that.$emit('clickCarItem', car)
|
|
|
|
|
|
+ that.$emit('clickCarItem', car, 1)
|
|
})
|
|
})
|
|
|
|
|
|
if (cache[car.id] && that.map) {
|
|
if (cache[car.id] && that.map) {
|
|
@@ -238,7 +224,7 @@ export default {
|
|
}, 10 * 1000)
|
|
}, 10 * 1000)
|
|
})
|
|
})
|
|
}
|
|
}
|
|
- refreshFireCar()
|
|
|
|
|
|
+ return await refreshFireCar()
|
|
},
|
|
},
|
|
addCarMaker(AMap) {
|
|
addCarMaker(AMap) {
|
|
const cache = {}
|
|
const cache = {}
|
|
@@ -248,7 +234,7 @@ export default {
|
|
getCarInfo(that.ids).then((res) => {
|
|
getCarInfo(that.ids).then((res) => {
|
|
const car = res.data
|
|
const car = res.data
|
|
const carImage = {
|
|
const carImage = {
|
|
- image: that.imageIcon(car.categoryId === 2, car.status, car.onlineStatus === 1),
|
|
|
|
|
|
+ image: that.imageIcon(car.categoryId === 2, car.status, car.onlineStatus === 1),
|
|
size: [40, 40],
|
|
size: [40, 40],
|
|
imageSize: [40, 40],
|
|
imageSize: [40, 40],
|
|
}
|
|
}
|
|
@@ -263,11 +249,11 @@ export default {
|
|
})
|
|
})
|
|
// 基础信息模块
|
|
// 基础信息模块
|
|
const content = [
|
|
const content = [
|
|
- `<div class='info_box_contant' style="background: rgba(255, 255, 255);">
|
|
|
|
|
|
+ `<div class='info_box_contant' style="background: rgba(255, 255, 255);">
|
|
<div style='width:100%;height:40px;border-bottom: 1px solid #EFEFEF;position:relative;padding:0 12px;display:flex;align-items: center;justify-content:space-between;'>
|
|
<div style='width:100%;height:40px;border-bottom: 1px solid #EFEFEF;position:relative;padding:0 12px;display:flex;align-items: center;justify-content:space-between;'>
|
|
<span style='font-size: 18px;font-weight: bold;margin-right:4px;'>${car.plateNumber}</span>
|
|
<span style='font-size: 18px;font-weight: bold;margin-right:4px;'>${car.plateNumber}</span>
|
|
<span style='display:inline-block;font-size:12px;border: 1px solid #547CD5;border-radius: 2px;color:#547CD5;padding:1px 5px;'>${
|
|
<span style='display:inline-block;font-size:12px;border: 1px solid #547CD5;border-radius: 2px;color:#547CD5;padding:1px 5px;'>${
|
|
- (car.onlineStatus === 1 ? '在线' : '离线')
|
|
|
|
|
|
+ car.onlineStatus === 1 ? '在线' : '离线'
|
|
}</span>
|
|
}</span>
|
|
</div>
|
|
</div>
|
|
<div style="width:100%;padding:4px 12px;">${car.depName}</div>
|
|
<div style="width:100%;padding:4px 12px;">${car.depName}</div>
|
|
@@ -290,8 +276,18 @@ export default {
|
|
// 点击消防车车
|
|
// 点击消防车车
|
|
marker.on('click', (e) => {
|
|
marker.on('click', (e) => {
|
|
// basicInfo.close()
|
|
// basicInfo.close()
|
|
- console.log(e);
|
|
|
|
- // that.$emit('clickCarItem', car)
|
|
|
|
|
|
+ // console.log(e);
|
|
|
|
+ // that.$emit('clickCarBack')
|
|
|
|
+ that.markeList &&
|
|
|
|
+ that.markeList.forEach((element) => {
|
|
|
|
+ that.map.remove(element)
|
|
|
|
+ })
|
|
|
|
+ if (that.timer) {
|
|
|
|
+ clearTimeout(that.timer)
|
|
|
|
+ }
|
|
|
|
+ that.depId = 100
|
|
|
|
+ that.loadFireCarInfo(that.AMap)
|
|
|
|
+ that.$emit('clickCarBack')
|
|
})
|
|
})
|
|
|
|
|
|
if (cache[car.id] && that.map) {
|
|
if (cache[car.id] && that.map) {
|
|
@@ -309,9 +305,26 @@ export default {
|
|
},
|
|
},
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
- // 初始化完成进行地图初始化
|
|
|
|
- this.initMap()
|
|
|
|
|
|
+ this.carId2 = this.$route.query.id
|
|
|
|
+ this.initMap().then(() => {
|
|
|
|
+
|
|
|
|
+ // 初始化完成进行地图初始化
|
|
|
|
+ if (this.carId2) {
|
|
|
|
+ if (this.timer) {
|
|
|
|
+ clearTimeout(this.timer)
|
|
|
|
+ }
|
|
|
|
+ this.markeList &&
|
|
|
|
+ this.markeList.forEach((element) => {
|
|
|
|
+ this.map.remove(element)
|
|
|
|
+ })
|
|
|
|
+ this.ids = this.carId2
|
|
|
|
+ this.addCarMaker(this.AMap)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
},
|
|
},
|
|
|
|
+ // created() {
|
|
|
|
+ // this.carId2 = this.$route.query.id
|
|
|
|
+ // },
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
|
|
|