12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115 |
- import {
- defineComponent,
- reactive,
- PropType,
- onMounted,
- watchEffect,
- watch,
- computed,
- onUnmounted,
- } from 'vue';
- import {
- ResourceItemDetail,
- getResourceItem,
- ResourceItemDetailResponse,
- } from '@/api/resource';
- import { useRoute, useRouter } from 'vue-router';
- import isString from 'lodash/isString';
- import useMarkerStore, { MarkerType } from '@/store/useMarkerStore';
- import MapView from '../MapView';
- import { useDaHuaStore,useMainStore } from '@/store';
- import emitter from '@/utils/mitt';
- /** @ts-ignore */
- import icon_map_yjcl from '@/assets/icons/home/yjcl.svg';
- /** @ts-ignore */
- import icon_map_yjsj from '@/assets/icons/home/yjsj.svg';
- /** @ts-ignore */
- import icon_map_yjdw from '@/assets/icons/home/yjdw.svg';
- /** @ts-ignore */
- import icon_map_yjdw_w from '@/assets/icons/home/icon_map_yjdw_w.svg';
- /** @ts-ignore */
- import icon_map_yjck from '@/assets/icons/home/yjck.svg';
- /** @ts-ignore */
- import icon_map_yjck_w from '@/assets/icons/home/icon_map_yjck_w.svg';
- /** @ts-ignore */
- import icon_map_spjk from '@/assets/icons/home/spjk.svg';
- /** @ts-ignore */
- import icon_map_spjk_offline from '@/assets/icons/home/spjkoffline.svg';
- /** @ts-ignore */
- import icon_map_dcz from '@/assets/icons/home/icon_map_dcz.svg';
- /** @ts-ignore */
- import icon_map_dpf from '@/assets/icons/home/dpf.svg';
- /** @ts-ignore */
- import icon_map_dbsb from '@/assets/icons/home/dbsb.svg';
- // @ts-ignore
- import icon_map_traffic from '@/assets/icons/detail/source2@2x.png';
- import './index.scss';
- import {
- GET_INCIDENT_DIALOG_HTML,
- GET_TEAM_DIALOG_HTML,
- GET_VEHICLES_DIALOG_HTML,
- GET_VIDEO_DIALOG_HTML,
- GET_WAREHOUSE_DIALOG_HTML,
- GET_SINGLE_DEVICE_DIALOG_HTML,
- renderElement,
- } from './dialog';
- import { IncidentItemDetail } from '@/api/incident';
- import { useIncidentStore } from '@/store';
- import Popup from '../Popup';
- import { ElMessage } from 'element-plus';
- import { isEmpty, xor } from 'lodash';
- import clsx from 'clsx';
- import { SingleDeviceItem } from '@/api/resource';
- const MARKER_MAP_TYPES = [
- // '待派发事件',
- // '待处置事件',
- '路况信息',
- '视频监控',
- '应急车辆',
- '应急队伍',
- '应急仓库',
- '应急事件',
- '单兵',
- ] as const;
- export type MarkerMapType = typeof MARKER_MAP_TYPES[number];
- interface State {
- map: any;
- types: MarkerMapType[];
- trafficLayerIds: any[];
- timer?: NodeJS.Timer | null;
- trafficStatus: boolean;
- markers: MarkerType[];
- positions: string[];
- hasTypes: string[];
- // theSocket: null;
- }
- interface ActionType {
- type: MarkerMapType;
- hasActioned: boolean;
- action: Function;
- remove: Function;
- }
- // locationType + resourceType
- const RESOURCE_ICON_MAP = {
- '11': icon_map_yjck_w, // 水上 仓库
- '21': icon_map_yjck, // 陆上 仓库
- '12': icon_map_yjdw_w, // 水上 队伍
- '22': icon_map_yjdw, // 陆上 队伍
- '13': icon_map_yjcl, // 水上 车辆
- '23': icon_map_yjcl, // 陆上 车辆
- };
- const getResourceIcon = (locationType: string, resourceType: string) => {
- // @ts-ignore
- return RESOURCE_ICON_MAP[locationType + resourceType] || '';
- };
- // 路况信息刷新间隔
- const REFRESH_TRAFFIC_TIME = 60000;
- // let theSocket = null;
- // let vPlayArea =null;
- const getIncidentImage = (status: MarkerType['status']) =>
- status?.toString() === '1'
- ? icon_map_yjsj
- : status?.toString() === '2'
- ? icon_map_dpf
- : status?.toString() === '3'
- ? icon_map_dcz
- : icon_map_yjsj;
- export default defineComponent({
- name: 'MarkerMap',
- props: {
- adrsMapTypes: {
- type: Array as PropType<string[]>,
- default: MARKER_MAP_TYPES,
- },
- marker: Object as PropType<IncidentItemDetail | undefined | null>,
- readonly: Boolean,
- },
- setup(props, ctx) {
- const state = reactive<State>({
- map: null,
- types: [],
- trafficLayerIds: [],
- timer: undefined,
- trafficStatus: false,
- markers: [],
- positions: [],
- hasTypes: [],
- // theSocket:null
- });
- const store = useMarkerStore();
- const mainstore = useMainStore();
- const incidentStore = useIncidentStore();
- const daHuaStore = useDaHuaStore();
- const router = useRouter();
- const route = useRoute();
- // const theSocket = null;
- const adrsMapTypes = computed(() =>
- props.adrsMapTypes.map((i) => ({
- name: i,
- icon: ((name) => {
- switch(name)
- {
- case "路况信息": return icon_map_traffic;
- case "应急事件": return icon_map_dpf;
- case "视频监控": return icon_map_spjk;
- case "应急车辆": return icon_map_yjcl;
- case "应急队伍": return icon_map_yjdw;
- case "应急仓库": return icon_map_yjck;
- case "单兵": return icon_map_dbsb;
-
- }
- })(i),
- disabled: route.query.id && i === '应急事件',
- })),
- );
- const actionTypes = computed<ActionType[]>(() => [
- {
- type: '路况信息',
- hasActioned: state.trafficStatus,
- action: toggleControlTraffic,
- remove: toggleControlTraffic,
- },
- {
- type: '应急事件',
- hasActioned: state.hasTypes.includes('应急事件'),
- action: () =>
- handleAddMarkers('应急事件', store.incident, icon_map_dpf),
- remove: () => handleRemoveMarkers('应急事件', store.incident),
- },
- {
- type: '视频监控',
- hasActioned: state.hasTypes.includes('视频监控'),
- action: () =>
- // console.log(store.videoSurveillance);
- handleAddMarkers('视频监控', store.videoSurveillance, icon_map_spjk),
- remove: () => handleRemoveMarkers('视频监控', store.videoSurveillance),
- },
- {
- type: '应急车辆',
- hasActioned: state.hasTypes.includes('应急车辆'),
- action: () =>
- handleAddMarkers('应急车辆', store.emergencyVehicles, icon_map_yjcl),
- remove: () => handleRemoveMarkers('应急车辆', store.emergencyVehicles),
- },
- {
- type: '应急队伍',
- hasActioned: state.hasTypes.includes('应急队伍'),
- action: () =>
- handleAddMarkers('应急队伍', store.emergencyTeam, icon_map_yjdw),
- remove: () => handleRemoveMarkers('应急队伍', store.emergencyTeam),
- },
- {
- type: '应急仓库',
- hasActioned: state.hasTypes.includes('应急仓库'),
- action: () =>
- handleAddMarkers('应急仓库', store.emergencyWarehouse, icon_map_yjck),
- remove: () => handleRemoveMarkers('应急仓库', store.emergencyWarehouse),
- },
- {
- type: '单兵',
- hasActioned: state.hasTypes.includes('单兵'),
- action: () =>
- handleAddMarkers('单兵', store.singleDevice, icon_map_dbsb),
- remove: () => handleRemoveMarkers('单兵', store.singleDevice),
- },
- ]);
- const getMarkerPopupHTML = (type: MarkerMapType, marker: MarkerType) => {
- switch (type) {
- case '应急事件':
- // case '待派发事件':
- // case '预警事件':
- default:
- return GET_INCIDENT_DIALOG_HTML(marker, async () => {
- marker.id && (await incidentStore.getIncidentItem(marker.id));
- await router.push(`/incidentDetail?id=${marker?.id}`);
- handleSetDetailMarker(marker);
- store.currentIncident = marker;
- });
- case '单兵': {
- var callback = () => {
- // console.log(marker['deviceCode']);
- // console.log(marker['userId']);
- // daHuaStore.DAHUAUserObj(marker["userId"]).then(deviceUser=>{
- // console.log(deviceUser);
- // let memberObj = {
- // userName:deviceUser.userName,
- // userId:deviceUser.userCode,
- // region:deviceUser.paasId,
- // type:'single',
- // // speak:'true',
- // number:deviceUser.userPhone,
- // deviceId:marker["deviceCode"],
- // channelId:marker["channelId"],
- // }
- // let meetObj = JSON.parse(localStorage.getItem('meeting'));
- // let memberList = [];
- // memberList.push(meetObj.member==null||meetObj.member==undefined?"":meetObj.member[0]);
- // memberList.push(memberObj);
- // meetObj.member = memberList
- // console.log(meetObj);
- // daHuaStore.DAHUAMeetingMember(meetObj).then(data=>{
- // // console.log(11111111)
- // daHuaStore.DAHUAMeetingUser(meetObj.meetId);
- // daHuaStore.DAHUAUserInfo().then(u => {
- // console.log(u,'+++++++');
- // initSocket(u.userCode,memberObj);
- // })
- // })
-
- // console.log(memberObj);
- // meetObj.mebmber.push(memberObj);
- // mainstore.videoisshow = true;
-
- mainstore.videoisshow = true;
- // // try {
- // daHuaStore.DAHUAUserObj(marker["userId"]).then(deviceUser=>{
- mainstore.videotitle = marker["userName"] + "";
- // });
- const userid = marker['userId'];
- const dievicecode = marker['deviceCode']+"";
- const channelid = marker['channelId']+"";
- async function cremetting(){
- await window.metting.getLocalUserInfo();
- const res = await window.metting.queryUser(userid);
-
- window.metting.localUserInfo.name = "danbing_Meeting";
-
- await window.metting.creatMeeting();
- await window.metting.startInvite({
- userName: res.userName,
- userId: res.userCode,
- region: res.paasId,
- type: "single",
- // speak:'true',
- number: res.userPhone,
- deviceId: dievicecode,
- channelId: channelid,
- });
- }
-
- if(window.metting){
- const meeting = window.metting;
- meeting.settargetId("vPlayArea");
- meeting.playVideo({
- type: 'single',
- deviceId: marker['deviceCode'],
- channelId: channelid,
- });
- cremetting();
-
- setTimeout(() => {
- try{
- if(window.vPlayArea){
- window.vPlayArea.resize();
- window.vPlayArea.dragResize(0,0,0,0)
- }
- }catch(E){
- }
-
- }, 500);
-
-
- }else{
- const meeting = new Meeting();
- if(window.theSocket){
- meeting.settargetId("vPlayArea");
- meeting.playVideo({
- type: 'single',
- deviceId: marker['deviceCode'],
- channelId: channelid,
- });
- window.metting = meeting;
- setTimeout(() => {
- try{
- if(window.vPlayArea){
- window.vPlayArea.resize();
- window.vPlayArea.dragResize(0,0,0,0)
- }
- }catch(E){
- }
-
- }, 500);
-
- }else{
- meeting.openClient(() => {
-
- meeting.settargetId("vPlayArea");
- meeting.playVideo({
- type: 'single',
- deviceId: marker['deviceCode'],
- channelId: channelid,
- });
- window.metting = meeting;
- cremetting();
-
- setTimeout(() => {
- try{
- if(window.vPlayArea){
- window.vPlayArea.resize();
- window.vPlayArea.dragResize(0,0,0,0)
- }
- }catch(E){
- }
-
- }, 1000);
-
-
- });
-
- }
-
- }
-
-
-
- // mainstore.videohandle = meeting;
- // });
- // const DAHUA = document.getElementById('DAHUA') as HTMLIFrameElement;
- // DAHUA?.contentWindow?.postMessage(
- // {
- // key: 'danbing',
- // value: marker['userId'],
- // deviceId: marker['deviceCode'],
- // channelId: marker['channelId'],
- // },
- // '*',
- // );
- // daHuaStore.dahuaUserVisible = true;
- // console.log(daHuaStore.deviceUser);
- };
- return GET_SINGLE_DEVICE_DIALOG_HTML(
- marker as SingleDeviceItem,
- callback,
- );
- }
- case '应急仓库':
- return GET_WAREHOUSE_DIALOG_HTML(marker);
- case '应急车辆':
- return GET_VEHICLES_DIALOG_HTML(marker);
- case '应急队伍':
- return GET_TEAM_DIALOG_HTML(marker);
- case '视频监控':
- return GET_VIDEO_DIALOG_HTML(marker, (type=1) => {
- if (marker['status'] == 1) {
- // mainstore.videourl =
- // (import.meta.env.VITE_DH_SERVER as string) +
- // '/videoplay.html?channelId=' +
- // marker['deviceCode'];
- const channelid = marker['channelId']+"";
- if(type==1){
- mainstore.videoisshow = true;
- mainstore.videotitle = marker['name'] + "";
-
-
-
- if(window.metting){
- const meeting = window.metting;
- meeting.settargetId("vPlayArea");
- meeting.playVideo({
- type: 'single',
- deviceId: marker['deviceCode'],
- channelId: channelid,
- });
- setTimeout(() => {
- try{
- if(window.vPlayArea){
- window.vPlayArea.resize();
- window.vPlayArea.dragResize(0,0,0,0)
- }
- }catch(E){
- }
-
- }, 500);
-
- }else{
- const meeting = new Meeting();
- if(window.theSocket){
- meeting.settargetId("vPlayArea");
- meeting.playVideo({
- type: 'single',
- deviceId: marker['deviceCode'],
- channelId: channelid,
- });
- window.metting = meeting;
- setTimeout(() => {
- try{
- if(window.vPlayArea){
- window.vPlayArea.resize();
- window.vPlayArea.dragResize(0,0,0,0)
- }
- }catch(E){
- }
-
- }, 500);
- }else{
- meeting.openClient(() => {
-
- meeting.settargetId("vPlayArea");
- meeting.playVideo({
- type: 'single',
- deviceId: marker['deviceCode'],
- channelId: channelid,
- });
- window.metting = meeting;
- setTimeout(() => {
- try{
- if(window.vPlayArea){
- window.vPlayArea.resize();
- window.vPlayArea.dragResize(0,0,0,0)
- }
- }catch(E){
- }
-
- }, 1000);
-
-
- });
- }
- }
- }
- if(type==2){
- window.indexp = (window.indexp == 1?2:1);
- const meeting = new Meeting();
- if(window.theSocket){
- meeting.settargetId("relvideo"+window.indexp);
- meeting.playVideo({
- type: 'single',
- deviceId: marker['deviceCode'],
- channelId: channelid,
- });
- }else{
- meeting.openClient(() => {
- meeting.settargetId("relvideo"+window.indexp);
- meeting.playVideo({
- type: 'single',
- deviceId: marker['deviceCode'],
- channelId: channelid,
- });
- });
- }
- }
-
- // // try {
- // const meeting = new Meeting();
-
- // meeting.closeVideo();
- // meeting.openClient(() => {
- // meeting.settargetId("");
- // meeting.playVideo({
- // type: 'single',
- // deviceId: marker['deviceCode'],
- // channelId: channelid,
- // });
- // });
- // mainstore.videohandle = meeting;
- // } catch (E) { }
-
- // const DAHUA = document.getElementById('DAHUA') as HTMLIFrameElement;
- // DAHUA?.contentWindow?.postMessage(
- // {
- // key: 'video',
- // value: marker['userId'],
- // deviceId: marker['deviceCode'],
- // channelId: marker['channelId'],
- // },
- // '*',
- // );
- // daHuaStore.dahuaUserVisible = true;
- }else{
- ElMessage.warning('设备离线,请联系大华相关人员');
- }
- });
- }
- };
- const videoplay = (item: { type: string; userId: any; channelId: any }) => {
- // console.log('播放视频');
- // console.log(item);
- if (!window.theSocket.websocket) {
- ElMessage.warning('请先打开视频插件');
- return;
- }
- if (item.type == 'client') {
- window.slectOptionmini(item.userId).then((arr: any) => {
- if (arr) {
- window.vPlayArea.openAppVideo(arr);
- }
- });
- } else if (item.type == 'single') {
- //播放单兵视频
- pullFlow(item.channelId);
- } else if (item.type == 'vehicle') {
- //播放车载视频
- pullFlow(item.channelId);
- } else if (item.type == 'uav_dev') {
- //播放无人机视频
- pullFlow(item.channelId);
- }
- };
- const pullFlow = (channelId: any) => {
- channelId &&
- window.vPlayArea &&
- window.vPlayArea.realTimeVideo([{ channelId }]);
- };
- const initSocket = (
- userCode: string,
- memberObj: {
- userName?: any;
- userId: any;
- region?: any;
- type: string;
- number?: any;
- deviceId?: any;
- channelId: any;
- },
- ) => {
- const self = this;
- // console.log(userCode);
- localStorage.setItem('userId', userCode);
- //初始websocket实例,保存在window中方便调用。一个浏览器tab页面只能初始化一次。所有的控件窗口,通过该websocket实例去生成不同的窗口实例,不同的控件窗口通过自己的窗口实例去调用初始化、关闭、隐藏等
- window.theSocket = new window.InitWebSocketClass(
- userCode,
- localStorage.getItem('DAHUA_token'),
- {
- //客户端登陆成功通知;
- loginSuccess: (v: any) => {
- // console.log(2222222222222222);
- console.log('loginSuccess-->', v);
- initWnd();
- },
- //客户端窗口被拉起通知
- onCreateVideoSuccess: (v: any) => {
- console.log('客户端onCreateVideoSuccess-----', v);
- },
- //重点:统一分发客户端ws消息;vue 可以统一用$bus分发.第三方消息分发自定
- onSocketBackInfos: (data: {
- method: string;
- params: { result: number; handleName: string };
- }) => {
- //视频窗口创建成功通知
- if (
- data &&
- data.method === 'createVideoDialogReuslt' &&
- data.params.result === 0
- ) {
- if (data.params.handleName === '#vPlayArea') {
- //客户端窗口创建好后,界面显示窗口;
- window.vPlayArea.resize();
- ElMessage.warning('视频窗口创建成功!');
- videoplay(memberObj);
- }
- }
- },
- },
- );
- // console.log(theSocket);
- //socket实例初始化websocket回调方法;
- window.theSocket
- .initWebSocket()
- .then((v: any) => {
- if (v) {
- ElMessage.warning('视频插件登陆完成!');
- }
- })
- .catch(() => {
- ElMessage.warning('若要观看实时视频,请先安装视频插件');
- });
- };
- const initWnd = () => {
- // console.log(1111);
- //左边窗口类型参数 分割 2行2列
- const typeObj = {
- rows: 2,
- cols: 2,
- wndSpaceing: 10,
- embedVideoMode: true,
- playerCtrlBarEnable: false,
- displayMode: 0,
- playMode: 0,
- playParams: {},
- };
- //左边窗口实例
- window.vPlayArea = new window.VideoPlay(
- '#vPlayArea',
- window.theSocket.websocket, //一个浏览器tab页面公用一个
- window.theSocket.socketCode, //一个浏览器tab页面公用一个
- typeObj,
- );
- //左边窗口初始化
- window.vPlayArea.init();
- };
- const updateTrafficSource = () => {
- if (state.map.getSource('Traffic')) {
- state.map.removeSource('Traffic');
- }
- state.map.addSource('Traffic', {
- type: 'vector',
- traffic: true,
- tiles: [
- 'mineserver://data/dynamic-traffic/ertic?servicetype=0&z={z}&x={x}&y={y}',
- ],
- });
- };
- const updateTrafficLayerVisibility = (v: 'none' | 'visible') => {
- state.trafficLayerIds.forEach(function (id) {
- if (state.map?.getLayer(id)) {
- state.map?.setLayoutProperty(id, 'visibility', v);
- }
- });
- };
- const toggleControlTraffic = () => {
- if (state.trafficStatus) {
- state.trafficStatus = false;
- if (state.timer) {
- clearInterval(state.timer);
- state.timer = null;
- }
- updateTrafficLayerVisibility('none');
- } else {
- state.trafficStatus = true;
- if (state.timer) {
- clearInterval(state.timer);
- state.timer = null;
- }
- updateTrafficSource();
- state.timer = setInterval(function () {
- updateTrafficSource();
- }, REFRESH_TRAFFIC_TIME);
- updateTrafficLayerVisibility('visible');
- }
- };
- const handleAddMarkers = (
- type: MarkerMapType,
- markers: State['markers'],
- image: any,
- ) => {
- // console.log(state.markers);
- state.markers.push(
- ...markers.map((i) => {
-
- var nextImage1 =
- type === '应急事件'
- ? getIncidentImage(i?.status)
- : i.locationType && i.resourceType
- ? getResourceIcon(
- i.locationType.toString(),
- i.resourceType.toString(),
- )
- : image;
-
-
- if (type == "视频监控") {
- if (i.isOnline == false) {
- nextImage1 = icon_map_spjk_offline;
- }
- }
- const nextImage = nextImage1;
- const popup = new window.minemap.Popup({
- anchor: 'left',
- closeOnClick: true,
- closeButton: false,
- offset: [10, 25],
- maxWidth: 'max-content',
- // autoPan: true,
- }).setDOMContent(getMarkerPopupHTML(type, i));
- popup.on('open', function () {
- getResourceItem(i.id ?? 0).then(
- (res: ResourceItemDetailResponse) => {
- var element = document.getElementById('tbl-' + i.id);
- var header = [
- '序号',
- '名称',
- '型号',
- '规格',
- '仓储数量',
- '可用数量',
- '单位',
- ];
- try {
- element.innerHTML = ` <tr>
- ${header.map((i) => '<th>' + i + '</th>').join('')}
- </tr>${res.data.resourceDetailList?.map((itemc,index) => {
- return `<tr><td>${index + 1}</td><td>${itemc.name ?? '-'}</td><td>${
- itemc.model ?? '-'
- }</td><td>${itemc.size ?? '-'}</td><td>${itemc.num ?? '-'}</td><td>${
- itemc.availableNum ?? '-'
- }</td><td>${itemc.unit ?? '-'}</td></tr>`;
- }).join("")}`;
- } catch (error) {}
- },
- );
- });
- return {
- locations: i.locations,
- popup,
- marker:
- i.locations &&
- new window.minemap.Marker(renderElement(nextImage), {
- offset: [-25, -25],
- })
- .setLngLat({
- lng: ((i) => { var ii = parseFloat(i.locations?.split(',')[0] ?? "0"); return ii; })(i),
- lat: ((i) => { var ii = parseFloat(i.locations?.split(',')[1] ?? "0"); return ii>90?89:ii<-90?-89:ii; })(i) ,
- })
- .setPopup(popup)
- .addTo(state.map),
- };
- }),
- );
- state.positions.push(...markers.map((i) => i.locations).filter(isString));
- handleFitBounds();
- };
- const handleFitBounds = () => {
- if (state.positions.length === 0) {
- return;
- }
- const locations = state.positions.map((i) => i.split(',').map(Number));
- const leftTop = locations.reduce((carry, next) => {
- if (carry.length === 0) return next;
- var x = Math.min(carry[0], next[0]);
- var y = Math.max(carry[1], next[1]);
- return [x<118?118:x, y>35?35:y<30?30:y];
- }, []);
- console.log(leftTop)
- const rightBottom = locations.reduce((carry, next) => {
- if (carry.length === 0) return next;
- return [Math.max(carry[0], next[0]), Math.min(carry[1], next[1])];
- }, []);
- const leftTopBounds: number[][] = new window.minemap.LngLat(...leftTop)
- .toBounds(5000)
- .toArray();
- const rightBottomBounds: number[][] = new window.minemap.LngLat(
- ...rightBottom,
- )
- .toBounds(5000)
- .toArray();
- state.map.fitBounds([
- rightBottomBounds.reduce((carry, next) => {
- if (carry.length === 0) return next;
- return [Math.max(carry[0], next[0]), Math.min(carry[1], next[1])];
- }, []),
- leftTopBounds.reduce((carry, next) => {
- if (carry.length === 0) return next;
- return [Math.min(carry[0], next[0]), Math.max(carry[1], next[1])];
- }, []),
- ]);
- };
- const handleRemoveMarkers = (
- type: MarkerMapType,
- markers: State['markers'],
- ) => {
- state.hasTypes = state.hasTypes.filter((t) => t !== type);
- const locations = markers.map((i) => i.locations);
- state.markers.forEach((m) => {
- if (locations.includes(m.locations)) {
- m.marker?.remove();
- m.popup?.remove();
- m.popup = null;
- m.marker = null;
- }
- });
- state.markers = state.markers.filter(
- (m) => !locations.includes(m.locations),
- );
- state.positions = state.positions.filter((p) => !locations.includes(p));
- handleFitBounds();
- };
- const handleRemoveAllMarkers = () => {
- state.markers.forEach((m) => {
- m.marker?.remove();
- m.popup?.remove();
- });
- state.markers = [];
- state.positions = [];
- };
- const handleSetDetailMarker = (marker: MarkerType) => {
- handleRemoveAllMarkers();
- const locations = marker.locations?.split(',').map(Number);
- if (!locations) {
- ElMessage.error({ message: '该点位无地址经纬度' });
- return;
- }
- // 获取事件周围的 5km 内的 监控点
- const bounds: number[][] = new window.minemap.LngLat(...locations)
- .toBounds(10000)
- .toArray();
- const videos = store.videoSurveillance.reduce((carry, next) => {
- const [lng, lat] = next.locations?.split(',') ?? [];
- // bounds [right-bottom[lng, lat],left-top[lng, lat], ]
- if (
- Number(lng) > bounds[0][0] &&
- Number(lng) < bounds[1][0] &&
- Number(lat) > bounds[0][1] &&
- Number(lat) < bounds[1][1]
- ) {
- carry.push(next);
- }
- return carry;
- }, [] as MarkerType[]);
- // 开启路况信息
- if (!state.types.includes('路况信息')) {
- state.types.push('路况信息');
- state.hasTypes.push('路况信息');
- toggleControlTraffic();
- }
- handleAddMarkers('应急事件', [marker], icon_map_dpf);
- handleAddMarkers('视频监控', videos, icon_map_spjk);
- // state.markers[0].marker.togglePopup();
- };
- onMounted(async () => {
- window.minemap.util.getJSON(
- (import.meta.env.VITE_MAP_SERVER as string) +
- '/service/solu/style/id/12878',
- function (error, data) {
- data.layers.forEach(function (layer: any) {
- //判断是否道路线图层
- if (
- layer.type == 'line' &&
- layer.source == 'Traffic' &&
- layer['source-layer'] == 'Trafficrtic'
- ) {
- state.trafficLayerIds.push(layer.id);
- }
- });
- },
- );
- try {
- const html = document.createElement("div");
- actionTypes.value.forEach(atypes => {
- if (atypes?.action == null) return;
- const name = atypes.type;
- const c = (atypes?.action?.toString().split("handleAddMarkers"));
- if (c.length <= 1) return;
- const args1 = c[1].replaceAll("(","").replaceAll(")","");
- // debugger
- const args = args1.split(",");
-
- if (eval(args[2]) == undefined) return;
- const div = document.createElement("div");
- div.className = "tipitem"
- const imagee = renderElement((eval(args[2])));
- div.append(imagee);
- const c1 = document.createElement("span"); c1.innerHTML = (name);
- div.append(c1);
- html.append(div);
-
- });
- state.map["tipcontentRef"].append(html);
- } catch (ee) {
- }
- state.map.on('load', function () {
- updateTrafficSource();
- //如果底图没有配置路况图层,需要自己手动增加
- state.map.addLayer({
- id: 'trafficlines',
- type: 'line',
- source: 'Traffic',
- 'source-layer': 'Trafficrtic',
- layout: {
- 'line-join': 'round',
- 'line-cap': 'round',
- },
- paint: {
- 'line-color': {
- property: 'status',
- stops: [
- [0, '#999999'],
- [1, '#66cc00'],
- [2, '#ff9900'],
- [3, '#cc0000'],
- [4, '#9d0404'],
- ],
- },
- 'line-width': {
- stops: [
- [5, 1],
- [18, 3],
- ],
- base: 1.2,
- },
- },
- });
- state.trafficLayerIds.push('trafficlines');
- state.trafficStatus = false;
- updateTrafficLayerVisibility('none');
- store.getAllResources();
- store.getAllsingleDevice();
- store.getAllvideoDevice();
- store.getHDIncidentList();
- });
- if (!route.query.id) return;
- // 如果存在id
- await incidentStore.getIncidentItem(route.query.id as string);
- // @ts-ignore
- handleSetDetailMarker(incidentStore.incidentDetail.baseInfo ?? {});
- // const vPlayAreaEl = document.getElementById('vPlayArea');
- // vPlayAreaEl &&
- // (vPlayAreaEl.style.height = window.innerHeight - 20 + 'px');
- // window.theSocket && window.theSocket.resize();
- });
- emitter.on('dosearchstart', () => { handleRemoveMarkers('应急仓库', store.emergencyWarehouse);
- });
- emitter.on('dosearchend', () => {
- handleAddMarkers('应急仓库', store.emergencyWarehouse, icon_map_yjck);
- });
- onUnmounted(() => {
- emitter.off('dosearchstart', () => { });
- emitter.off('dosearchend', () => {});
- })
- watch(
- () => store?.currentIncident,
- (next) => {
- if (!isEmpty(next)) {
- handleSetDetailMarker({
- ...next,
- });
- } else {
- 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(
- () => state.types,
- (next) => {
- actionTypes.value.forEach((item) => {
- if (next.includes(item.type) && !item.hasActioned) {
- state.hasTypes.push(item.type);
- item.action();
- }
- if (!next.includes(item.type) && item.hasActioned) {
- item.remove();
- }
- });
- },
- );
- return () => (
- <div class="task-map-container">
- <MapView v-model:map={state.map} />
- {/* <div style="width:35%;height:20%;background-color:blue"> */}
- {/*<div id='vPlayArea' style="width:30%;"/>*/}
- {/* </div> */}
- <div
- class={clsx('address-type-card-container', {
- ['in-detail']: props.readonly,
- })}>
- <Popup
- class={clsx('address-type-card', {
- ['in-detail']: props.readonly,
- })}>
- <el-checkbox-group v-model={state.types}>
- {adrsMapTypes.value &&
- adrsMapTypes.value?.map((t) => (
- <>
- {!t.disabled && (
- <el-checkbox key={t} class="card-item" label={t.name}>
- <span>
- <img class="tipicon" v-show={t.icon!=null} src={t.icon} />
- {t.name}
- </span>
- </el-checkbox>
- )}
- </>
- ))}
- </el-checkbox-group>
- <i class="card-border-bottom-left"></i>
- <i class="card-border-bottom-right"></i>
- </Popup>
- </div>
- </div>
- );
- },
- });
|