|
@@ -7,7 +7,7 @@ import {
|
|
|
watch,
|
|
|
computed,
|
|
|
} from 'vue';
|
|
|
-import { useRouter } from 'vue-router';
|
|
|
+import { useRoute, useRouter } from 'vue-router';
|
|
|
import isString from 'lodash/isString';
|
|
|
import useMarkerStore, { MarkerType } from '@/store/useMarkerStore';
|
|
|
import MapView from '../MapView';
|
|
@@ -38,6 +38,8 @@ import {
|
|
|
GET_WAREHOUSE_DIALOG_HTML,
|
|
|
renderElement,
|
|
|
} from './dialog';
|
|
|
+import { IncidentItemDetail } from '@/api/incident';
|
|
|
+import { useIncidentStore } from '@/store';
|
|
|
|
|
|
const MARKER_MAP_TYPES = [
|
|
|
// '待派发事件',
|
|
@@ -80,6 +82,7 @@ export default defineComponent({
|
|
|
type: Array as PropType<string[]>,
|
|
|
default: MARKER_MAP_TYPES,
|
|
|
},
|
|
|
+ marker: Object as PropType<IncidentItemDetail | undefined | null>,
|
|
|
readonly: Boolean,
|
|
|
},
|
|
|
setup(props, ctx) {
|
|
@@ -95,7 +98,9 @@ export default defineComponent({
|
|
|
});
|
|
|
|
|
|
const store = useMarkerStore();
|
|
|
+ const incidentStore = useIncidentStore();
|
|
|
const router = useRouter();
|
|
|
+ const route = useRoute();
|
|
|
|
|
|
const actionTypes = computed<ActionType[]>(() => [
|
|
|
{
|
|
@@ -142,7 +147,7 @@ export default defineComponent({
|
|
|
},
|
|
|
]);
|
|
|
|
|
|
- const getMarkerPopupHTML = (type: MarkerMapType) => {
|
|
|
+ const getMarkerPopupHTML = (type: MarkerMapType, marker?: MarkerType) => {
|
|
|
switch (type) {
|
|
|
case '应急事件':
|
|
|
// case '待派发事件':
|
|
@@ -153,7 +158,16 @@ export default defineComponent({
|
|
|
name: '事件名称',
|
|
|
addr: 'su qian',
|
|
|
},
|
|
|
- () => router.push('/incidentDetail'),
|
|
|
+ () => {
|
|
|
+ router.push(`/incidentDetail?id=${marker?.id}`);
|
|
|
+ handleRemoveAllMarkers();
|
|
|
+ handleAddMarkers(
|
|
|
+ '应急事件',
|
|
|
+ [{ location: marker?.location, name: '中心庄' }],
|
|
|
+ icon_map_dpf,
|
|
|
+ );
|
|
|
+ state.markers[0].marker.togglePopup();
|
|
|
+ },
|
|
|
);
|
|
|
case '应急仓库':
|
|
|
return GET_WAREHOUSE_DIALOG_HTML({
|
|
@@ -240,7 +254,7 @@ export default defineComponent({
|
|
|
offset: [10, 25],
|
|
|
maxWidth: 'max-content',
|
|
|
// autoPan: true,
|
|
|
- }).setDOMContent(getMarkerPopupHTML(type));
|
|
|
+ }).setDOMContent(getMarkerPopupHTML(type, i));
|
|
|
return {
|
|
|
location: i.location,
|
|
|
popup,
|
|
@@ -278,13 +292,13 @@ export default defineComponent({
|
|
|
}, []);
|
|
|
|
|
|
const leftTopBounds: number[][] = new window.minemap.LngLat(...leftTop)
|
|
|
- .toBounds(10000)
|
|
|
+ .toBounds(5000)
|
|
|
.toArray();
|
|
|
|
|
|
const rightBottomBounds: number[][] = new window.minemap.LngLat(
|
|
|
...rightBottom,
|
|
|
)
|
|
|
- .toBounds(10000)
|
|
|
+ .toBounds(5000)
|
|
|
.toArray();
|
|
|
|
|
|
state.map.fitBounds([
|
|
@@ -318,6 +332,14 @@ export default defineComponent({
|
|
|
|
|
|
handleFitBounds();
|
|
|
};
|
|
|
+ const handleRemoveAllMarkers = () => {
|
|
|
+ state.markers.forEach((m) => {
|
|
|
+ m.marker.remove();
|
|
|
+ m.popup.remove();
|
|
|
+ });
|
|
|
+ state.markers = [];
|
|
|
+ state.positions = [];
|
|
|
+ };
|
|
|
onMounted(() => {
|
|
|
window.minemap.util.getJSON(
|
|
|
'https://minedata.cn/service/solu/style/id/12878',
|
|
@@ -373,7 +395,60 @@ export default defineComponent({
|
|
|
state.trafficStatus = false;
|
|
|
updateTrafficLayerVisibility('none');
|
|
|
});
|
|
|
+
|
|
|
+ if (!route.query.id) return;
|
|
|
+ // 如果存在id
|
|
|
+ handleAddMarkers(
|
|
|
+ '应急事件',
|
|
|
+ [{ location: '118.752399,34.118339', name: '中心庄' }],
|
|
|
+ icon_map_dpf,
|
|
|
+ );
|
|
|
+
|
|
|
+ state.markers[0].marker.togglePopup();
|
|
|
});
|
|
|
+
|
|
|
+ watch(
|
|
|
+ () => route.query.id,
|
|
|
+ (next) => {
|
|
|
+ if (!next) {
|
|
|
+ handleRemoveAllMarkers();
|
|
|
+ if (state.types.includes('应急事件')) {
|
|
|
+ state.types.forEach((next) => {
|
|
|
+ actionTypes.value.forEach((item) => {
|
|
|
+ if (next === item.type) {
|
|
|
+ state.hasTypes.push(item.type);
|
|
|
+ item.action();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ state.map?.flyTo({
|
|
|
+ center: [118.29564, 33.97441],
|
|
|
+ zoom: 14,
|
|
|
+ bearing: 10,
|
|
|
+ pitch: 30,
|
|
|
+ duration: 2000,
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ );
|
|
|
+
|
|
|
+ watch(
|
|
|
+ () => props.marker?.baseInfo?.locations,
|
|
|
+ (next) => {
|
|
|
+ if (next && !state.positions.includes(next)) {
|
|
|
+ handleRemoveAllMarkers();
|
|
|
+ handleAddMarkers(
|
|
|
+ '应急事件',
|
|
|
+ [{ location: '118.288721,33.951047', name: '中心庄' }],
|
|
|
+ icon_map_dpf,
|
|
|
+ );
|
|
|
+ state.markers[0].marker.togglePopup();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ );
|
|
|
+
|
|
|
watch(
|
|
|
() => state.types,
|
|
|
(next) => {
|