1.添加急救路线
This commit is contained in:
2025-07-09 19:38:59 +08:00
parent b52d46cd76
commit b61ca7f567
6 changed files with 115 additions and 44 deletions
+41
View File
@@ -9,6 +9,7 @@ import { defaultOption, getZoom, mapKey, mapPlugin } from '/@/assets/mapUtils/ma
let AMap = null; let AMap = null;
export const Map = { export const Map = {
aMap: null,
map: null, map: null,
overlayGroup: null, // 地图中marker overlayGroup: null, // 地图中marker
circleGroup: null, //直升机背景圆 circleGroup: null, //直升机背景圆
@@ -19,6 +20,9 @@ export const Map = {
infoWindow: null, //地图弹窗 infoWindow: null, //地图弹窗
driveLine: null, // 导航轨迹线 driveLine: null, // 导航轨迹线
emergencyMarker: null, // 应急人员marker emergencyMarker: null, // 应急人员marker
startMarker: null,
endMarker: null,
clearSOrE: null,
/** /**
* @desc 地图舒适化 * @desc 地图舒适化
* @param el dom元素 id选择器 * @param el dom元素 id选择器
@@ -34,6 +38,7 @@ export const Map = {
plugins: mapPlugin, // 需要使用的的插件列表,如比例尺'AMap.Scale'等 plugins: mapPlugin, // 需要使用的的插件列表,如比例尺'AMap.Scale'等
}).then((res) => { }).then((res) => {
AMap = res; AMap = res;
this.aMap = res;
const { zoom, center, mapStyle } = { ...defaultOption, ...option }; const { zoom, center, mapStyle } = { ...defaultOption, ...option };
//基本地图加载 //基本地图加载
this.map = new AMap.Map(el, { this.map = new AMap.Map(el, {
@@ -476,4 +481,40 @@ export const Map = {
this.clearNaviLine(); this.clearNaviLine();
this.clearEmergencyMarker(); this.clearEmergencyMarker();
}, },
createSMarker(position: any) {
if (this.startMarker) {
this.startMarker?.setMap(null);
this.startMarker = null;
}
this.startMarker = new AMap.Marker({
position: position,
offset: new AMap.Pixel(0, 0),
});
this.map.add(this.startMarker);
this.setZoomCenter(position);
},
createEMarker(position: any) {
if (this.endMarker) {
this.endMarker?.setMap(null);
this.endMarker = null;
}
this.endMarker = new AMap.Marker({
position: position,
offset: new AMap.Pixel(0, 0),
});
this.map.add(this.endMarker);
this.setZoomCenter(position);
},
clearSOrE() {
if (this.startMarker) {
this.startMarker?.setMap(null);
this.startMarker = null;
}
if (this.endMarker) {
this.endMarker?.setMap(null);
this.endMarker = null;
}
},
}; };
+10 -1
View File
@@ -23,7 +23,16 @@ export const innerLineLight = {
// 地图key // 地图key
export const mapKey = '4bbcb216b889f2d612cbed05ae6979c8'; export const mapKey = '4bbcb216b889f2d612cbed05ae6979c8';
// 地图插件 // 地图插件
export const mapPlugin = ['AMap.ToolBar', 'AMap.Driving', 'AMap.GeoJSON', 'AMap.MarkerCluster', 'AMap.PlaceSearch', 'AMap.Driving', 'AMap.Geocoder']; export const mapPlugin = [
'AMap.ToolBar',
'AMap.Driving',
'AMap.GeoJSON',
'AMap.MarkerCluster',
'AMap.PlaceSearch',
'AMap.Driving',
'AMap.Geocoder',
'AMap.AutoComplete',
];
//根据数据量设置地图层级 //根据数据量设置地图层级
export function getZoom(list = []) { export function getZoom(list = []) {
+3 -1
View File
@@ -105,7 +105,7 @@
import { handleSocketUrl, startTime } from '/@/utils/utils.ts'; import { handleSocketUrl, startTime } from '/@/utils/utils.ts';
import { useUserStore } from '/@/store/modules/user.ts'; import { useUserStore } from '/@/store/modules/user.ts';
const { getCenterInfo } = useUserStore(); const { getCenterInfo, setCount } = useUserStore();
import { import {
oneLApi, oneLApi,
roomDetailApi, roomDetailApi,
@@ -273,6 +273,7 @@
watch(socketData, (nVal) => { watch(socketData, (nVal) => {
if (nVal) { if (nVal) {
nextTick(() => { nextTick(() => {
setCount();
setSocketData(nVal); setSocketData(nVal);
employeeDialogRef.value.openDialog(); employeeDialogRef.value.openDialog();
}); });
@@ -285,6 +286,7 @@
const emergencyDialogRef = ref(); //紧急求助 const emergencyDialogRef = ref(); //紧急求助
watch(socketData1, (nVal) => { watch(socketData1, (nVal) => {
if (nVal) { if (nVal) {
setCount();
setSocketData1(nVal); setSocketData1(nVal);
emergencyDialogRef.value.openDialog(); emergencyDialogRef.value.openDialog();
} }
+54 -35
View File
@@ -2,17 +2,17 @@
<div class="sun-center-map"> <div class="sun-center-map">
<div class="map-box"> <div class="map-box">
<div class="tab-list"> <div class="tab-list">
<div v-for="(item, i) in list" :class="[currentIndex == i ? 'active' : '']" class="tab" @click="changeTab(item, i)"> <div v-for="(item, i) in list" :class="[currentIndex == i ? 'active' : '']" class="tab" @click="changeTab(item, i)" :key="`tab-${i}`">
{{ item.name }} {{ item.name }}
</div> </div>
</div> </div>
<div v-show="currentIndex == list.length - 1" class="route-navigation"> <div v-show="currentIndex == list.length - 1" class="route-navigation">
<a-form :model="formState" layout="inline"> <a-form :model="formState" layout="inline">
<a-form-item class="form-item-self" label="起点"> <a-form-item class="form-item-self" label="起点">
<a-input v-model:value="formState.start" placeholder="请输入起点"></a-input> <a-input v-model:value="formState.start" placeholder="请输入起点" id="startInput" />
</a-form-item> </a-form-item>
<a-form-item class="form-item-self" label="终点"> <a-form-item class="form-item-self" label="终点">
<a-input v-model:value="formState.end" placeholder="请输入终点"></a-input> <a-input v-model:value="formState.end" placeholder="请输入终点" id="endInput" />
</a-form-item> </a-form-item>
<a-form-item> <a-form-item>
<a-button class="reset-btn" @click="removeInput">清空</a-button> <a-button class="reset-btn" @click="removeInput">清空</a-button>
@@ -20,7 +20,7 @@
</a-form-item> </a-form-item>
</a-form> </a-form>
</div> </div>
<div v-show="showHospitalList || showRestB" class="reset-map" :class="[themeType]" @click="resetMap"> <div class="reset-map" :class="[themeType]" @click="resetMap">
<RedoOutlined title="重置地图" /> <RedoOutlined title="重置地图" />
</div> </div>
<div v-show="showRoutePanel" v-click-outside="outClick" class="line-container"> <div v-show="showRoutePanel" v-click-outside="outClick" class="line-container">
@@ -65,9 +65,9 @@
<div class="hospital-list" :class="[themeType]" v-if="showHospitalList"> <div class="hospital-list" :class="[themeType]" v-if="showHospitalList">
<div class="hospital-item" v-for="(item, index) in hospitalList" :key="index" @click.stop="showDrivingLine(item)"> <div class="hospital-item" v-for="(item, index) in hospitalList" :key="index" @click.stop="showDrivingLine(item)">
<div>{{ item.name }}</div> <div>{{ item?.name }}</div>
<div>相距{{ item.distance }}</div> <div>相距{{ item?.distance }}</div>
<div>驾车大约{{ item.driveTime }}</div> <div>驾车大约{{ item?.driveTime }}</div>
</div> </div>
</div> </div>
</div> </div>
@@ -123,7 +123,8 @@
const level = ref(0); const level = ref(0);
const routeList = ref([]); const routeList = ref([]);
const emits = defineEmits(['clearHospitalList', 'showRestB', 'handleDetail']); const emits = defineEmits(['clearHospitalList', 'showRestB', 'handleDetail']);
let placeSearch = null;
let driving = null;
watch( watch(
() => props.showHospitalList, () => props.showHospitalList,
(v) => { (v) => {
@@ -143,6 +144,17 @@
getMapData(tabList[0].type); getMapData(tabList[0].type);
Map.map && Map.map.on('zoomend', setLevel); Map.map && Map.map.on('zoomend', setLevel);
Map.map && Map.map.on('zoomend', setLevel); Map.map && Map.map.on('zoomend', setLevel);
placeSearch = new Map.aMap.PlaceSearch({
extensions: 'all',
pageIndex: 1,
pageSize: 10,
showMarker: false,
});
// 确保 AutoComplete 加载完成后再使用
const startAuto = new Map.aMap.AutoComplete({ input: 'startInput' });
const endAuto = new Map.aMap.AutoComplete({ input: 'endInput' });
startAuto.on('select', startSelect);
endAuto.on('select', endSelect);
}); });
$bus.on(earlyWarning, (params) => { $bus.on(earlyWarning, (params) => {
drawMarker(params); drawMarker(params);
@@ -157,6 +169,27 @@
}); });
}); });
function startSelect(e: any) {
placeSearch.search(e.poi.name, function (status, result) {
if (status === 'complete' && result.poiList.pois.length > 0) {
const poi = result.poiList.pois[0]; // 取第一个结果
const { lat, lng } = poi.location;
formState.value.start = poi.name;
Map.createSMarker([lng, lat]);
}
});
}
function endSelect(e: any) {
placeSearch.search(e.poi.name, function (status, result) {
if (status === 'complete' && result.poiList.pois.length > 0) {
const poi = result.poiList.pois[0]; // 取第一个结果
const { lat, lng } = poi.location;
formState.value.end = poi.name;
Map.createEMarker([lng, lat]);
}
});
}
function showDrivingLine(item) { function showDrivingLine(item) {
nextTick(() => { nextTick(() => {
panelTitle.value = '全程' + item.driveTime + item.distance; panelTitle.value = '全程' + item.driveTime + item.distance;
@@ -183,29 +216,13 @@
function changeTab(item: any, i: number) { function changeTab(item: any, i: number) {
closeDrivingElement(); closeDrivingElement();
currentIndex.value = i; currentIndex.value = i;
if (item.type) {
tab(item); tab(item);
} }
}
function tab(item: any) { function tab(item: any) {
Map.clearActiveHospital(); Map.clearActiveHospital();
Map.map.off('moveend', logMapinfo); Map.map.off('moveend', logMapinfo);
if (TabType.diFangYiYuan == item.type) { getMapData(item.type, { type: item.type });
let { lng, lat } = Map.getMapCenter();
Map.getAddressByPoint([lng, lat]).then((text, data) => {
// console.log('data', data, data.citycode);
});
Map.removeOverlayGroup();
Map.map.on('moveend', logMapinfo);
return;
}
// if (TabType.zhiShengJi == item.type) {
// Map.createAircraft(aircraft);
// return;
// } else {
// getMapData(item.type, { type: item.type });
// }
} }
function watchInfoChangeTab(item: any) { function watchInfoChangeTab(item: any) {
@@ -223,13 +240,13 @@
return message.warn('请输入终点'); return message.warn('请输入终点');
} }
searchFlag.value = true; searchFlag.value = true;
let map = new AMap.Map('container', { // let map = new Map.aMap.Map('container', {
resizeEnable: true, // resizeEnable: true,
center: [116.397428, 39.90923], //地图中心点 // center: [116.397428, 39.90923], //地图中心点
zoom: 13, //地图显示的缩放级别 // zoom: 13, //地图显示的缩放级别
}); // });
let driving = new AMap.Driving({ driving = new Map.aMap.Driving({
map: map, map: Map.map,
panel: 'panel', panel: 'panel',
}); });
driving.search([{ keyword: formState.value.start }, { keyword: formState.value.end }], function (status, result) { driving.search([{ keyword: formState.value.start }, { keyword: formState.value.end }], function (status, result) {
@@ -241,7 +258,7 @@
searchFlag.value = false; searchFlag.value = false;
} }
}); });
AMap.Event.addListener(driving, 'complete', (res) => { Map.aMap.Event.addListener(driving, 'complete', (res) => {
const data = JSON.parse(JSON.stringify(res)); const data = JSON.parse(JSON.stringify(res));
searchFlag.value = false; searchFlag.value = false;
if (data.info == 'OK') { if (data.info == 'OK') {
@@ -301,6 +318,7 @@
} }
function closeDrivingElement() { function closeDrivingElement() {
if (driving) driving.clear();
Map.clearNavigationElements(); Map.clearNavigationElements();
formState.value.start = ''; formState.value.start = '';
formState.value.end = ''; formState.value.end = '';
@@ -345,6 +363,7 @@
} }
function resetMap() { function resetMap() {
Map.clearSOrE();
closeDrivingElement(); closeDrivingElement();
changeTab(list.value[currentIndex.value], currentIndex.value); changeTab(list.value[currentIndex.value], currentIndex.value);
emits('showRestB'); emits('showRestB');
@@ -404,7 +423,7 @@
border-radius: 6px; border-radius: 6px;
position: absolute; position: absolute;
top: 36px; top: 36px;
z-index: 999; z-index: 100;
transition: all 0.3s; transition: all 0.3s;
:deep(.form-item-self) { :deep(.form-item-self) {
@@ -679,7 +698,7 @@
position: absolute; position: absolute;
left: 0; left: 0;
top: 50px; top: 50px;
z-index: 99; z-index: 101;
font-size: 20px; font-size: 20px;
cursor: pointer; cursor: pointer;
padding: 0px 6px; padding: 0px 6px;
+4 -5
View File
@@ -7,10 +7,9 @@ export const legend1 = new URL('/@/assets/img/legend1.png', import.meta.url).hre
export const legend2 = new URL('/@/assets/img/legend5.png', import.meta.url).href; export const legend2 = new URL('/@/assets/img/legend5.png', import.meta.url).href;
export const legend3 = new URL('/@/assets/img/legend3.png', import.meta.url).href; export const legend3 = new URL('/@/assets/img/legend3.png', import.meta.url).href;
async function getDict(code) { export const checkData = await (async () => {
return await getDictByCode2({ dictCode: code }); return await getDictByCode2({ dictCode: 'xj_check_type' });
} })();
export const checkData = await getDict('xj_check_type');
export function getClassCharts(dx, dy, m) { export function getClassCharts(dx, dy, m) {
return { return {
@@ -159,7 +158,7 @@ export function infoContent1(res) {
</div> </div>
<div class="modal-item"> <div class="modal-item">
<span class="item-one">地点:</span> <span class="item-one">地点:</span>
<span class="item-two">${res.name ? res.name : '--'}</span> <span class="item-two">${res.orgName ? res.orgName : '--'}</span>
</div> </div>
</div> `; </div> `;
} }
+2 -1
View File
@@ -56,12 +56,13 @@ export default defineConfig({
}, },
optimizeDeps: { optimizeDeps: {
esbuildOptions: { esbuildOptions: {
target: 'es2020', target: 'esnext',
}, },
// @iconify/iconify: The dependency is dynamically and virtually loaded by @purge-icons/generated, so it needs to be specified explicitly // @iconify/iconify: The dependency is dynamically and virtually loaded by @purge-icons/generated, so it needs to be specified explicitly
include: ['lodash-es', 'ant-design-vue/es/locale/zh_CN', 'ant-design-vue/es/locale/en_US'], include: ['lodash-es', 'ant-design-vue/es/locale/zh_CN', 'ant-design-vue/es/locale/en_US'],
}, },
build: { build: {
target: 'esnext',
sourcemap: false, sourcemap: false,
// rollupOptions: { // rollupOptions: {
// output: { // output: {