From 9428791901927bb014bd14ee50937948acfcd781 Mon Sep 17 00:00:00 2001 From: DIAMOND <276397553@qq.com> Date: Fri, 5 Jan 2024 15:53:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0useMessage=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 抽离guid方法 --- .../earthMap/KeyControlAreaList.vue | 12 +- src/components/earthMap/RoamPathList.vue | 6 +- src/components/earthMap/Toolbar.vue | 14 +- src/components/earthMap/ToolbarShow.vue | 14 +- src/components/earthMap/VideoControl.vue | 10 +- src/components/earthMap/WarnInfoList.vue | 6 +- .../earthMap/toolbar/AddKeyControlArea.vue | 21 +- .../earthMap/toolbar/AddModelWin.vue | 40 +- .../earthMap/toolbar/AddRoamPath.vue | 23 +- .../earthMap/toolbar/AddroamVideo.vue | 29 +- .../earthMap/toolbar/CreateModel.vue | 27 +- .../earthMap/toolbar/NotificationModel.vue | 4 +- src/components/earthMap/toolbar/WarnList.vue | 5 +- src/utils/earthMap/guid.ts | 8 + src/utils/earthMap/handleNodeType.ts | 62 + src/utils/earthMap/keyControlInit.ts | 2 - src/utils/earthMap/websocket.ts | 437 +++ src/views/earthMap/edit/EarthComp copy.vue | 2608 ----------------- src/views/earthMap/edit/EarthComp.vue | 207 +- src/views/military/modules/duty/DutySet.vue | 2 +- .../modules/dutyManage/duty/DutySet.vue | 2 +- .../modules/equipment/camera/CameraSet.vue | 2 - .../components/MsEmergencyPlanForm.vue | 2 - 23 files changed, 648 insertions(+), 2895 deletions(-) create mode 100644 src/utils/earthMap/guid.ts create mode 100644 src/utils/earthMap/handleNodeType.ts create mode 100644 src/utils/earthMap/websocket.ts delete mode 100644 src/views/earthMap/edit/EarthComp copy.vue diff --git a/src/components/earthMap/KeyControlAreaList.vue b/src/components/earthMap/KeyControlAreaList.vue index c5c75d7..a0d9c44 100644 --- a/src/components/earthMap/KeyControlAreaList.vue +++ b/src/components/earthMap/KeyControlAreaList.vue @@ -55,6 +55,7 @@ import BTable from '@/components/earthMap/components/B-table.vue'; import { addArrow, addCustomPrimitive, addRoamPath } from '@/utils/earthMap/earthObj'; import AddKeyControlArea from '@/components/earthMap/toolbar/AddKeyControlArea.vue'; + import { useMessage } from "/@/hooks/web/useMessage"; export default defineComponent({ name: 'KeyControlAreaList', props: { @@ -70,6 +71,7 @@ }, setup(props, ctx) { const { proxy }: any = getCurrentInstance(); + const { createMessage } = useMessage(); const userStore = useUserStore(); const store = useEarthMapStore(); let winVisible = ref(true); // 窗口显示或隐藏 @@ -184,7 +186,7 @@ (err) => {} ) .catch((res) => { - proxy.$message.error('获取列表失败!'); + createMessage.error('获取列表失败!'); console.error('获取列表失败!', res); }); } @@ -250,8 +252,7 @@ if (model) { viewer.flyTo(model); } else { - // Msg.error('该区域不存在, 请刷新页面重试'); - proxy.$message.error('该区域不存在, 请刷新页面重试'); + createMessage.error('该区域不存在, 请刷新页面重试'); } } @@ -275,8 +276,7 @@ if (model) { viewer.entities.remove(model); } else { - // Msg.error('该区域不存在, 请刷新页面重试'); - proxy.$message.error('该区域不存在, 请刷新页面重试'); + createMessage.error('该区域不存在, 请刷新页面重试'); } // 删除会话中的数据 @@ -287,7 +287,7 @@ getKeyControlAreaList(); }) .catch((res) => { - proxy.$message.error('删除失败!'); + createMessage.error('删除失败!'); console.error('删除失败!', res); }); } diff --git a/src/components/earthMap/RoamPathList.vue b/src/components/earthMap/RoamPathList.vue index 09129d3..2ac68d1 100644 --- a/src/components/earthMap/RoamPathList.vue +++ b/src/components/earthMap/RoamPathList.vue @@ -67,6 +67,7 @@ import BTable from '@/components/earthMap/components/B-table.vue'; import AddRoamPathSet from '@/components/earthMap/toolbar/AddRoamPath.vue'; import { addArrow, addCustomPrimitive, addRoamPath } from '@/utils/earthMap/earthObj'; + import { useMessage } from "/@/hooks/web/useMessage"; export default defineComponent({ name: 'RoamPathList', props: { @@ -82,6 +83,7 @@ }, setup(props, ctx) { const { proxy }: any = getCurrentInstance(); + const { createMessage } = useMessage(); const userStore = useUserStore(); const store = useEarthMapStore(); let heightCoefficient = ref(0.5); // 高 @@ -391,7 +393,7 @@ (err) => {} ) .catch((res) => { - proxy.$message.error('删除失败!'); + createMessage.error('删除失败!') console.error('删除失败!', res); }); }); @@ -424,7 +426,7 @@ (err) => {} ) .catch((res) => { - proxy.$message.error('获取路径列表失败!'); + createMessage.error('获取路径列表失败!') console.error('获取路径列表失败!', res); }); } diff --git a/src/components/earthMap/Toolbar.vue b/src/components/earthMap/Toolbar.vue index f56f6a1..bf6e818 100644 --- a/src/components/earthMap/Toolbar.vue +++ b/src/components/earthMap/Toolbar.vue @@ -211,8 +211,6 @@ onMounted(() => { // console.log("asdsdfsdfsdfsdfsdf"); - - // proxy.$message.info('请先创建路径!') getEventData(); window.getEventData = getEventData; { @@ -404,23 +402,19 @@ // this.mapObj_ = window.$earth.sceneTree.$refs.tdtwxsj; break; case 'bdha': - // $mitt.emit('openNotification', '暂未开放该地图!', 2, 'warning') - $mitt.emit('openNotification', { msg: '暂未开放该地图!', dt: 2, type: 'warning' }); + createMessage.warning('暂未开放该地图!', 2); // this.mapObj_ = window.$earth.sceneTree.$refs.bdha; break; case 'gdsl': - // $mitt.emit('openNotification', '暂未开放该地图!', 2, 'warning') - $mitt.emit('openNotification', { msg: '暂未开放该地图!', dt: 2, type: 'warning' }); + createMessage.warning('暂未开放该地图!', 2); // this.mapObj_ = window.$earth.sceneTree.$refs.gdsl; break; case 'gdwx': - // $mitt.emit('openNotification', '暂未开放该地图!', 2, 'warning') - $mitt.emit('openNotification', { msg: '暂未开放该地图!', dt: 2, type: 'warning' }); + createMessage.warning('暂未开放该地图!', 2); // this.mapObj_ = window.$earth.sceneTree.$refs.gdwx; break; case 'sjgkdt': - // $mitt.emit('openNotification', '暂未开放该地图!', 2, 'warning') - $mitt.emit('openNotification', { msg: '暂未开放该地图!', dt: 2, type: 'warning' }); + createMessage.warning('暂未开放该地图!', 2); // this.mapObj_ = window.$earth.sceneTree.$refs.sjgkdt; break; default: diff --git a/src/components/earthMap/ToolbarShow.vue b/src/components/earthMap/ToolbarShow.vue index 91d0c27..fdefa64 100644 --- a/src/components/earthMap/ToolbarShow.vue +++ b/src/components/earthMap/ToolbarShow.vue @@ -203,9 +203,7 @@ }); onMounted(() => { - // console.log("asdsdfsdfsdfsdfsdf"); - // proxy.$message.info('请先创建路径!') getEventData(); window.getEventData = getEventData; { @@ -392,23 +390,19 @@ // this.mapObj_ = window.$earth.sceneTree.$refs.tdtwxsj; break; case 'bdha': - // $mitt.emit('openNotification', '暂未开放该地图!', 2, 'warning') - $mitt.emit('openNotification', { msg: '暂未开放该地图!', dt: 2, type: 'warning' }); + createMessage.warning('暂未开放该地图!', 2); // this.mapObj_ = window.$earth.sceneTree.$refs.bdha; break; case 'gdsl': - // $mitt.emit('openNotification', '暂未开放该地图!', 2, 'warning') - $mitt.emit('openNotification', { msg: '暂未开放该地图!', dt: 2, type: 'warning' }); + createMessage.warning('暂未开放该地图!', 2); // this.mapObj_ = window.$earth.sceneTree.$refs.gdsl; break; case 'gdwx': - // $mitt.emit('openNotification', '暂未开放该地图!', 2, 'warning') - $mitt.emit('openNotification', { msg: '暂未开放该地图!', dt: 2, type: 'warning' }); + createMessage.warning('暂未开放该地图!', 2); // this.mapObj_ = window.$earth.sceneTree.$refs.gdwx; break; case 'sjgkdt': - // $mitt.emit('openNotification', '暂未开放该地图!', 2, 'warning') - $mitt.emit('openNotification', { msg: '暂未开放该地图!', dt: 2, type: 'warning' }); + createMessage.warning('暂未开放该地图!', 2); // this.mapObj_ = window.$earth.sceneTree.$refs.sjgkdt; break; default: diff --git a/src/components/earthMap/VideoControl.vue b/src/components/earthMap/VideoControl.vue index f9f7153..65c6d80 100644 --- a/src/components/earthMap/VideoControl.vue +++ b/src/components/earthMap/VideoControl.vue @@ -98,6 +98,7 @@ import * as ysApi from '@/api/yushiApi'; import $mitt from '@/utils/earthMap/mitt'; import { defHttp } from '/@/utils/http/axios'; + import { useMessage } from '/@/hooks/web/useMessage'; export default defineComponent({ name: 'VideoControl', props: ['cameraCode', 'visibleChild', 'user', 'password'], @@ -105,6 +106,7 @@ // ImgListDialog }, setup(props) { + const { createMessage } = useMessage(); const { proxy }: any = getCurrentInstance(); // const $mitt = mitt(); let currentStep = ref(5); @@ -182,14 +184,10 @@ ) // postAction(this.url.screenSnap, newInfo) .then(() => { - // $mitt.emit('openNotification', '抓拍图片保存成功!', 2, 'success', '50px') - // $mitt.emit('openNotification',{msg: '抓拍图片保存成功!', dt: 2, type:'success', top: '50px'} ) - proxy.$message.success('抓拍图片保存成功!'); + createMessage.success('抓拍图片保存成功', 2); }) .catch(() => { - // $mitt.emit('openNotification', '抓拍图片保存失败!', 2, 'error', '50px') - // $mitt.emit('openNotification',{msg: '抓拍图片保存失败!', dt: 2, type:'error', top: '50px'} ) - proxy.$message.error('抓拍图片保存失败!'); + createMessage.error('抓拍图片保存失败!', 2); }); }); } diff --git a/src/components/earthMap/WarnInfoList.vue b/src/components/earthMap/WarnInfoList.vue index 54ab8ad..2d6d98b 100644 --- a/src/components/earthMap/WarnInfoList.vue +++ b/src/components/earthMap/WarnInfoList.vue @@ -140,6 +140,7 @@ import _ from 'lodash'; import ScrollBoardTable from '@/components/earthMap/components/Scroll-board-table.vue'; import MsWarnModal from '@/views/military/modules/alarmManage/cautionManage/components/MsPreWarnModal.vue'; + import { useMessage } from "/@/hooks/web/useMessage"; export default defineComponent({ name: 'infoList', props: {}, @@ -148,6 +149,7 @@ MsWarnModal, }, setup(props, ctx) { + const { createMessage } = useMessage(); const { proxy }: any = getCurrentInstance(); let store = useMonitorStore(); //ref @@ -517,9 +519,7 @@ function showPhotos(url) { if (objectIsNull(url)) { - // $mitt.emit('openNotification', '暂无数据', 2, 'warning') - // $mitt.emit('openNotification', { msg: '暂无数据', dt: 2, type: 'warning' }) - proxy.$message.warning('暂无数据'); + createMessage.warning('暂无数据', 2); return; } images.value = handleImageList(url); diff --git a/src/components/earthMap/toolbar/AddKeyControlArea.vue b/src/components/earthMap/toolbar/AddKeyControlArea.vue index a2fbc4b..df00fbd 100644 --- a/src/components/earthMap/toolbar/AddKeyControlArea.vue +++ b/src/components/earthMap/toolbar/AddKeyControlArea.vue @@ -81,6 +81,7 @@ import { useEarthMapStore } from '/@/store/modules/earthMap'; import _ from 'lodash'; import { getDictItems } from '/@/api/common/api'; + import { useMessage } from "/@/hooks/web/useMessage"; export default defineComponent({ name: 'AddKeyControlArea', @@ -100,6 +101,7 @@ }, }, setup(props, ctx) { + const { createMessage } = useMessage(); const { proxy }: any = getCurrentInstance(); const userStore = useUserStore(); const store = useEarthMapStore(); @@ -325,12 +327,10 @@ //提交方法 function confirmBtn() { if (!areaObj.value) { - // return $mitt.emit('openNotification', { msg: '请先完成创建', dt: 2, type: 'warning', top: '50px' }) - return proxy.$message.warning('请先完成创建'); + return createMessage.warning('请先完成创建', 2); } if (!area.value.name) { - // return $mitt.emit('openNotification', { msg: '请输入名称', dt: 2, type: 'warning', top: '50px' }) - return proxy.$message.warning('请输入名称'); + return createMessage.warning('请输入名称', 2); } //整理数据 @@ -359,8 +359,7 @@ ) .then((res) => { if (res.success) { - // $mitt.emit('openNotification', { msg: '编辑成功', dt: 2, type: 'success', top: '50px' }) - proxy.$message.success('编辑成功'); + createMessage.success('编辑成功'); // 销毁旧模型 window?.$earth.czm.viewer.entities.remove(oldAreaFence.value); // 修改到 sessionStorage @@ -386,8 +385,7 @@ } }) .catch((res) => { - // $mitt.emit('openNotification', { msg: '编辑失败!', dt: 2, type: 'error', top: '50px' }) - proxy.$message.error('编辑失败!'); + createMessage.error('编辑失败!'); console.error('编辑失败!', res); }); } @@ -404,9 +402,7 @@ ) .then((res) => { if (res.success) { - // Msg.success("创建成功"); - // $mitt.emit('openNotification', { msg: '创建成功', dt: 2, type: 'success', top: '50px' }) - proxy.$message.success('创建成功'); + createMessage.success('创建成功'); // 保存到 sessionStorage let keyControlAreaListStr = sessionStorage.getItem('keyControlAreaList'); let keyControlAreaList: any = JSON.parse(keyControlAreaListStr ? keyControlAreaListStr : 'null'); @@ -424,8 +420,7 @@ } }) .catch((res) => { - // $mitt.emit('openNotification', { msg: '创建失败!', dt: 2, type: 'error', top: '50px' }) - proxy.$message.error('创建失败!'); + createMessage.error('创建失败!'); console.error('创建失败!', res); }); } diff --git a/src/components/earthMap/toolbar/AddModelWin.vue b/src/components/earthMap/toolbar/AddModelWin.vue index c658121..54c10f2 100644 --- a/src/components/earthMap/toolbar/AddModelWin.vue +++ b/src/components/earthMap/toolbar/AddModelWin.vue @@ -482,8 +482,7 @@ export default defineComponent({ }) .catch((e) => { // 提示用户加载数据出现了问题 - // $mitt.emit('openNotification', '加载区域数据出错', 2, 'error', '50px') - $mitt.emit('openNotification', { msg: '加载区域数据出错', dt: 2, type: 'error', top: '50px' }); + createMessage.error('加载区域数据出错', 2); }); }); @@ -601,29 +600,23 @@ export default defineComponent({ return; } else if (name.value == null || name.value.length <= 0) { // 名称效验 - // $mitt.emit('openNotification', '需要先填写名称', 2, 'warning') - $mitt.emit('openNotification', { msg: '需要先填写名称', dt: 2, type: 'warning' }); - + createMessage.warning('需要先填写名称', 2); return; } else if (currentModel.value.xbsjType == 'Pin' && currentModel.value.imageUrl.length <= 0) { // pin类型图片效验 - // $mitt.emit('openNotification', '需要先上传图片', 2, 'warning') - $mitt.emit('openNotification', { msg: '需要先上传图片', dt: 2, type: 'warning' }); + createMessage.warning('需要先上传图片', 2); return; } else if (currentModel.value.xbsjType == 'Pin' && !selectHostDevice.value) { - // $mitt.emit('openNotification', '主机设备不能为空', 2, 'warning') - $mitt.emit('openNotification', { msg: '主机设备不能为空', dt: 2, type: 'warning' }); + createMessage.warning('主机设备不能为空', 2); return; } else if (currentModel.value.xbsjType == 'Pin' && !selectDeviceNum.value) { - // $mitt.emit('openNotification', '设备编码不能为空', 2, 'warning') - $mitt.emit('openNotification', { msg: '设备编码不能为空', dt: 2, type: 'warning' }); + createMessage.warning('设备编码不能为空', 2); return; } //*************************************************** else if (currentModel.value.xbsjType !== 'Polyline' && (selectArea.value == null || selectArea.value.id <= 0)) { // 非区域类型,区域效验 - // $mitt.emit('openNotification', '需要先选择区域', 2, 'warning') - $mitt.emit('openNotification', { msg: '需要先选择区域', dt: 2, type: 'warning' }); + createMessage.warning('需要先选择区域', 2); return; } currentModel.value.editing = false; @@ -792,8 +785,7 @@ export default defineComponent({ // 路径为空,无法提交 const poistions = currentModel.positions; if (poistions.length <= 0) { - // $mitt.emit('openNotification', '路径为空,无法创建', 2, 'warning') - $mitt.emit('openNotification', { msg: '路径为空,无法创建', dt: 2, type: 'warning' }); + createMessage.warning('路径为空,无法创建', 2); return; } @@ -932,8 +924,7 @@ export default defineComponent({ } }) .catch((e) => { - // $mitt.emit('openNotification', '新增区域数据出错', 2, 'error', '50px') - $mitt.emit('openNotification', { msg: '新增区域数据出错', dt: 2, type: 'error', top: '50px' }); + createMessage.error('新增区域数据出错', 2); }); }; // 取消按钮 @@ -1117,8 +1108,7 @@ export default defineComponent({ // 树中加入并显示该节点 parent.children.push(shamNode); // 提示用户 - // $mitt.emit('openNotification', '添加成功!', 2, 'info') - $mitt.emit('openNotification', { msg: '添加成功!', dt: 2, type: 'info' }); + createMessage.success('添加成功!', 2); } else { //当前处于更新状态 // 获取更新的虚假节点 @@ -1129,8 +1119,7 @@ export default defineComponent({ currentModel.value.name = name.value; moveNode('Model'); // 提示用户 - // $mitt.emit('openNotification',{msg: '修改成功!', dt: 2, type:'info'} ) - $mitt.emit('openNotification', { msg: '修改成功!', dt: 2, type: 'info' }); + createMessage.success('修改成功!', 2); } } }) @@ -1239,8 +1228,7 @@ export default defineComponent({ wbParent.children.push(node); } // 提示用户 - // $mitt.emit('openNotification', '添加成功!', 2, 'info') - $mitt.emit('openNotification', { msg: '添加成功!', dt: 2, type: 'info' }); + createMessage.success('添加成功!', 2); }); } else { const node = window.$earth.sceneTree.$refs[eidtId]; @@ -1255,8 +1243,7 @@ export default defineComponent({ } }); // 提示用户 - // $mitt.emit('openNotification', '编辑成功!', 2, 'info') - $mitt.emit('openNotification', { msg: '编辑成功!', dt: 2, type: 'info' }); + createMessage.success('编辑成功!', 2); //----------------------- } //是否为雷达 @@ -1294,8 +1281,7 @@ export default defineComponent({ } } } else { - // $mitt.emit('openNotification', response.message, 2, 'error') - $mitt.emit('openNotification', { msg: response.message, dt: 2, type: 'error' }); + createMessage.error(response.message, 2); currentModel.value.destroy(); } }) diff --git a/src/components/earthMap/toolbar/AddRoamPath.vue b/src/components/earthMap/toolbar/AddRoamPath.vue index 1e30500..289cb75 100644 --- a/src/components/earthMap/toolbar/AddRoamPath.vue +++ b/src/components/earthMap/toolbar/AddRoamPath.vue @@ -80,6 +80,7 @@ import { defHttp } from '/@/utils/http/axios'; // import mitt from '/@/utils/mitt'; import $mitt from '@/utils/earthMap/mitt'; + import { useMessage } from "/@/hooks/web/useMessage"; export default defineComponent({ name: 'AddRoamPath', @@ -97,6 +98,7 @@ setup(props, ctx) { const { proxy }: any = getCurrentInstance(); + const { createMessage } = useMessage(); // const $mitt = mitt(); const userStore = useUserStore(); let heightCoefficient = ref(0.5); @@ -221,7 +223,7 @@ // 编辑姿态 function editing() { if (!pathObj.value) { - proxy.$message.info('请先创建路径!'); + createMessage.warning('请先创建路径!'); return; } const model = window.$earth.getObject(pathObj.value); @@ -231,14 +233,14 @@ //确定按钮 function confirmBtn() { if (!pathObj.value) { - proxy.$message.info('请先创建路径!'); + createMessage.warning('请先创建路径!'); return; } const model = window.$earth.getObject(pathObj.value); path.value.positions = JSON.stringify(model.positions); path.value.rotations = JSON.stringify(model.rotations); if (path.value.pathname.length == 0) { - proxy.$message.warning('路径名称不能为空'); + createMessage.warning('路径名称不能为空'); return; } if (props.cdata) { @@ -254,15 +256,14 @@ ) .then((res) => { if (res.success) { - proxy.$message.success('修改成功!'); + createMessage.success('修改成功!'); cancel(); } else { - proxy.$message.error('修改失败,请检查参数!'); + createMessage.error('修改失败,请检查参数!'); } }) .catch((res) => { - proxy.$message.error('修改失败,请检查参数!', res); - proxy.$message.error('修改失败,请检查参数!'); + createMessage.error('修改失败,请检查参数!'+res); }); } else { // 添加路径 @@ -284,15 +285,15 @@ ) .then((res) => { if (res.success) { - proxy.$message.success('创建成功!'); + createMessage.success('创建成功!'); cancel(); } else { - proxy.$message.error('创建失败,请检查参数!'); + createMessage.error('修改失败,请检查参数!'+res); } }) .catch((res) => { - proxy.$message.error('创建失败,请检查参数!', res); - proxy.$message.error('创建失败,请检查参数!'); + createMessage.error('修改失败,请检查参数!'+res); + createMessage.error('修改失败,请检查参数!'); }); } } diff --git a/src/components/earthMap/toolbar/AddroamVideo.vue b/src/components/earthMap/toolbar/AddroamVideo.vue index 837d4e2..e23e0cc 100644 --- a/src/components/earthMap/toolbar/AddroamVideo.vue +++ b/src/components/earthMap/toolbar/AddroamVideo.vue @@ -109,6 +109,7 @@ import { useEarthMapStore } from '/@/store/modules/earthMap'; import { defHttp } from '/@/utils/http/axios'; import $mitt from '@/utils/earthMap/mitt'; + import { useMessage } from "/@/hooks/web/useMessage"; export default defineComponent({ name: 'AddRoamVideo', @@ -132,6 +133,7 @@ }, setup(props, ctx) { const { proxy }: any = getCurrentInstance(); + const { createMessage } = useMessage(); // const $mitt = mitt(); const userStore = useUserStore(); const store = useEarthMapStore(); @@ -319,18 +321,17 @@ //flag判断是否摧毁对象 return new Promise((resolve, reject) => { if (!ButtonState.value) { - proxy.$message.error('请先创建巡检视频'); + createMessage.error('请先创建巡检视频'); return; } const pathId = modelData.value.pathId; if (!pathId || pathId.length < 0) { - proxy.$message.error('请选择巡检路径'); + createMessage.error('请选择巡检路径'); return; } const deviceUid = modelData.value.deviceUid; if (!deviceUid || deviceUid.length < 0) { - // console.log(deviceUid) - proxy.$message.error('请选择相机设备'); + createMessage.error('请选择相机设备'); return; } const position = modelData.value.lngLatHeight; @@ -369,16 +370,16 @@ }) .then((res) => { if (!res.success) { - proxy.$message.error(`编辑失败,${res.message}`); + createMessage.error('编辑失败'+ res.message); return; } - proxy.$message.success(`编辑成功`); + createMessage.success('编辑成功'); resolve(res); windowClose(flag); destroyVideoLise(); }) .catch((res) => { - proxy.$message.error('编辑失败'); + createMessage.error('编辑失败'); console.error('编辑失败', res); }); } else { @@ -392,16 +393,16 @@ ) .then((response) => { if (!response.success) { - proxy.$message.error(`保存失败,${response.message}`); + createMessage.error('保存失败'+ response.message); return; } - proxy.$message.success(`保存成功`); + createMessage.success('保存成功'); resolve(response); windowClose(flag); destroyVideoLise(); }) .catch((res) => { - proxy.$message.error('保存失败'); + createMessage.error('保存失败'); console.error('保存失败', res); }); } @@ -422,7 +423,7 @@ ) .then((response) => { if (!response.success) { - proxy.$message.error('没有查询到相机设备信息'); + createMessage.error('没有查询到相机设备信息'); return; } const records = response.result[0].msCameraSiteList; @@ -442,7 +443,7 @@ } }) .catch((res) => { - proxy.$message.error('没有查询到相机设备信息'); + createMessage.error('没有查询到相机设备信息'); console.error('没有查询到相机设备信息', res); }); } @@ -471,7 +472,7 @@ ) .then((response) => { if (!response.success) { - proxy.$message.error('没有查询到区域信息'); + createMessage.error('没有查询到区域信息'); return; } const records = response.result; @@ -486,7 +487,7 @@ // console.log('this.areaList', this.areaList) }) .catch((res) => { - proxy.$message.error('没有查询到区域信息'); + createMessage.error('没有查询到区域信息'); console.error('没有查询到区域信息', res); }); }); diff --git a/src/components/earthMap/toolbar/CreateModel.vue b/src/components/earthMap/toolbar/CreateModel.vue index 7fdbc2b..f9986de 100644 --- a/src/components/earthMap/toolbar/CreateModel.vue +++ b/src/components/earthMap/toolbar/CreateModel.vue @@ -235,7 +235,7 @@ import { onBeforeUnmount, defineComponent, ref, getCurrentInstance, computed, watch } from 'vue'; import { Col, Row } from 'ant-design-vue'; import { addModel, addPin } from '@/utils/earthMap/earthObj'; - + import { useMessage } from "/@/hooks/web/useMessage"; import { defHttp } from '/@/utils/http/axios'; // import mitt from '/@/utils/mitt'; import $mitt from '@/utils/earthMap/mitt'; @@ -257,6 +257,7 @@ }, }, setup(props, _ctx) { + const { createMessage } = useMessage(); const { proxy }: any = getCurrentInstance(); // const $mitt = mitt(); //computed @@ -493,8 +494,7 @@ if (_modelEntity.value) { _modelEntity.value.creating = !_modelEntity.value.creating; } else { - // $mitt.emit('openNotification', '没有找到模型!', 2, 'error', '50px') - $mitt.emit('openNotification', { msg: '没有找到模型!', dt: 2, type: 'error', top: '50px' }); + createMessage.error('没有找到模型!', 2); } } function handleEditLocation(_e) { @@ -505,8 +505,7 @@ _modelEntity.value.editing = !_modelEntity.value.editing; } } else { - // $mitt.emit('openNotification', '没有找到模型!', 2, 'error', '50px') - $mitt.emit('openNotification', { msg: '没有找到模型!', dt: 2, type: 'error', top: '50px' }); + createMessage.error('没有找到模型!', 2); } } function handleFlyToLocation(_e) { @@ -518,8 +517,7 @@ if (_modelEntity.value) { _modelEntity.value.rotationEditing = !_modelEntity.value.rotationEditing; } else { - // $mitt.emit('openNotification', '没有找到模型!', 2, 'error', '50px') - $mitt.emit('openNotification', { msg: '没有找到模型!', dt: 2, type: 'error', top: '50px' }); + createMessage.error('没有找到模型!', 2); } } function handleResetRotation(_e) { @@ -532,8 +530,7 @@ if (_modelEntity.value) { // 空值判断 if (model.value.name === '') { - // $mitt.emit('openNotification', '模型名称不能为空!', 2, 'error', '50px') - $mitt.emit('openNotification', { msg: '模型名称不能为空!', dt: 2, type: 'error', top: '50px' }); + createMessage.error('模型名称不能为空!', 2); return false; } // 新建一个场景结构树叶子节点存放模型 @@ -549,8 +546,7 @@ if (selectModel.value.id === 'ironTower') { // 判断是否已经选择路线 if (selectLine.value.value === '') { - // $mitt.emit('openNotification', '请选择线路!', 2, 'error', '50px') - $mitt.emit('openNotification', { msg: '请选择线路!', dt: 2, type: 'error', top: '50px' }); + createMessage.error('请选择线路!', 2); return false; } let saveCameraSiteModelParameter = { @@ -581,8 +577,7 @@ .catch((_err) => { // 销毁模型 node.destroy(); - // $mitt.emit('openNotification', '保存失败!', 2, 'error', '50px') - $mitt.emit('openNotification', { msg: '保存失败!', dt: 2, type: 'error', top: '50px' }); + createMessage.error('保存失败!', 2); }); } // 传感器 @@ -610,8 +605,7 @@ .catch((_err) => { // 销毁模型 node.destroy(); - // $mitt.emit('openNotification', "保存失败!", 2, 'error', '50px') - $mitt.emit('openNotification', { msg: '保存失败!', dt: 2, type: 'error', top: '50px' }); + createMessage.error('保存失败!', 2); }); } break; @@ -642,8 +636,7 @@ .catch((_err) => { // 销毁模型 node.destroy(); - // $mitt.emit('openNotification', "保存失败!", 2, 'error', '50px') - $mitt.emit('openNotification', { msg: '保存失败!', dt: 2, type: 'error', top: '50px' }); + createMessage.error('保存失败!', 2); }); break; default: diff --git a/src/components/earthMap/toolbar/NotificationModel.vue b/src/components/earthMap/toolbar/NotificationModel.vue index 12cbacf..c89a73f 100644 --- a/src/components/earthMap/toolbar/NotificationModel.vue +++ b/src/components/earthMap/toolbar/NotificationModel.vue @@ -32,6 +32,7 @@ import NotificationChild from '/@/components/earthMap/toolbar/NotificationChild.vue'; import Window from '@/components/earthMap/components/Window.vue'; import BTable from '@/components/earthMap/components/B-table.vue'; + import { useMessage } from "/@/hooks/web/useMessage"; export default defineComponent({ name: 'NotificationModel', components: { @@ -48,6 +49,7 @@ setup(props, ctx) { // const $mitt = mitt(); const { proxy }: any = getCurrentInstance(); + const { createMessage } = useMessage(); let heightCoefficient = ref(0.5); let widthCoefficient = ref(0.3); let currentModel: any = ref(null); @@ -147,7 +149,7 @@ //一键已读 defHttp.put({ url: url.value.readAll }, { isTransformResponse: false }).then((res) => { if (res.code == 200) { - proxy.$message.success(res.message); + createMessage.success(res.message) window.getEventData().then((res) => { eventListAll.value = res; let pageNo = pagination.value.pageNo; diff --git a/src/components/earthMap/toolbar/WarnList.vue b/src/components/earthMap/toolbar/WarnList.vue index 6d3988b..509f60d 100644 --- a/src/components/earthMap/toolbar/WarnList.vue +++ b/src/components/earthMap/toolbar/WarnList.vue @@ -144,6 +144,7 @@ MsWarnDetail, }, setup(props, ctx) { + const { createMessage } = useMessage(); const { proxy }: any = getCurrentInstance(); let store = useMonitorStore(); const userStore = useUserStore(); @@ -410,9 +411,7 @@ } function showPhotos(url) { if (objectIsNull(url)) { - // $mitt.emit('openNotification', '暂无数据', 2, 'warning') - // $mitt.emit('openNotification', { msg: '暂无数据', dt: 2, type: 'warning' }) - proxy.$message.warning('暂无数据'); + createMessage.warning('暂无数据', 2); return; } images.value = handleImageList(url); diff --git a/src/utils/earthMap/guid.ts b/src/utils/earthMap/guid.ts new file mode 100644 index 0000000..4d344a3 --- /dev/null +++ b/src/utils/earthMap/guid.ts @@ -0,0 +1,8 @@ +// 随机数 +export function guid() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r = (Math.random() * 16) | 0, + v = c == 'x' ? r : (r & 0x3) | 0x8; + return v.toString(16); + }); +} \ No newline at end of file diff --git a/src/utils/earthMap/handleNodeType.ts b/src/utils/earthMap/handleNodeType.ts new file mode 100644 index 0000000..85c372e --- /dev/null +++ b/src/utils/earthMap/handleNodeType.ts @@ -0,0 +1,62 @@ +export default class HandleNodeType { + #sn; + #sensorCallback; + #modelCallback; + #markerPositionCallback; + #polylineCallBack; + #default; + + constructor(sn) { + this.#sn = sn; + } + + sensor(callback) { + this.#sensorCallback = callback; + return this; + } + + // 模型回调 + modelCallback(callback) { + this.#modelCallback = callback; + return this; + } + + // 微波雷达回调 + markerPosition(callback) { + this.#markerPositionCallback = callback; + return this; + } + + // 区域回调 + polylineCallBack(callback) { + this.#polylineCallBack = callback; + return this; + } + + default(callback) { + this.#default = callback; + return this; + } + + run() { + // 判断节点的类型 + if (!this.#sn.czmObject) { + return null; + } + // 模型类型 + let tempCondition = this.#sn.czmObject.xbsjType; + switch (tempCondition) { + case 'Model': + this.#modelCallback ? this.#modelCallback() : this.#default(); + break; + case 'Pin': + this.#markerPositionCallback ? this.#markerPositionCallback() : this.#default(); + break; + case 'Polyline': + this.#polylineCallBack ? this.#polylineCallBack() : this.#default(); + break; + default: + this.#default ? this.#default() : null; + } + } +} \ No newline at end of file diff --git a/src/utils/earthMap/keyControlInit.ts b/src/utils/earthMap/keyControlInit.ts index 4b90671..e13a791 100644 --- a/src/utils/earthMap/keyControlInit.ts +++ b/src/utils/earthMap/keyControlInit.ts @@ -69,11 +69,9 @@ export async function keyControlInit() { }, (err) => { - // proxy.$message.error('重点监控区域初始化失败!') console.error('重点监控区域初始化失败!', err) }) .catch((res) => { - // proxy.$message.error('重点监控区域初始化失败!') console.error('重点监控区域初始化失败!', res) }) diff --git a/src/utils/earthMap/websocket.ts b/src/utils/earthMap/websocket.ts new file mode 100644 index 0000000..07d4276 --- /dev/null +++ b/src/utils/earthMap/websocket.ts @@ -0,0 +1,437 @@ + +import _ from 'lodash'; +import { useUserStore } from '/@/store/modules/user'; +import { defHttp } from '/@/utils/http/axios'; +import $mitt from '@/utils/earthMap/mitt'; +import { useMessage } from "/@/hooks/web/useMessage"; +import earthUtils from '@/utils/earthMap/earth'; +import alarmImg from '@/assets/earthMap/alarm.gif'; +const { createMessage } = useMessage(); + +let userStore = useUserStore(); +let websock: any = []; +function initWebSocket(configName) { + if ('WebSocket' in window) { + let url = ''; + switch (configName) { + case 'domianURL': //接收后台模型数据 + // WebSocket与普通的请求所用协议有所不同,ws等同于http,wss等同于https + // const userStore = useUserStore() + // const orgCode = userStore.userInfo?.orgCode; + // let userId = store.getters.userInfo.id; + let userId = userStore.userInfo?.id; + url = window._CONFIG[configName].replace('https://', 'wss://').replace('http://', 'ws://') + '/websocket/' + userId; + // url = 'ws://127.0.0.1:5004' + websock[configName] = new WebSocket(url); + websock[configName].onopen = websocketonopen; + websock[configName].onerror = websocketonerror; + websock[configName].onmessage = websocketonmessage; + websock[configName].onclose = websocketclose; + break; + case 'clientURL': //调用客户端监控视频窗口 + url = window._CONFIG['clientURL']; + websock[configName] = new WebSocket(url); + websock[configName].onopen = websocketonopen; + websock[configName].onerror = websocketonerror; + websock[configName].onclose = websocketclose; + break; + default: + console.log('websocket初始化失败'); + } + // console.log('url', url) + } else { + console.log('当前浏览器不支持websocket,请更换浏览器!'); + } +} +function websocketonopen(e) { + console.log('WebSocket连接成功'); +} +function websocketonerror(e) { + console.log('WebSocket连接发生错误'); +} +const loreadAlarmInfo = _.debounce( + (url, eventSerialNum) => { + defHttp + .get( + { + url: url, + params: eventSerialNum, + }, + { isTransformResponse: false } + ) + // getAction(url, {eventSerialNum: eventSerialNum}) + .then((res) => { + if (!res.success) { + console.log('重新发送websocket报警数据失败!'); + } else { + console.log('重新发送websocket报警数据成功!'); + } + }); + }, + 2000, + { maxWait: 3000, trailing: true } +); + +// +async function websocketonmessage(e) { + //接收后端数据 + var data = eval('(' + e.data + ')'); + const cesium = window.Cesium; + // Cesium Math + const math = cesium.Math; + // earth + const earth = window.$earth; + //处理订阅信息 + if (data.cmd == 'new_warn_info') { + //有新增的预警信息 + //1.调起客户端窗体 + // chrome.call("formactive"); + //2.若警示界面打开着,则刷新列表 + if ($('.infoList').css('visibility') == 'visible') { + $mitt.emit('getWarnData'); + } + //3.弹出监控窗口或围栏信息 + if (data.msgTxt != undefined && data.dealStatus == 1) { + $mitt.emit('listenerVideoNum', data.msgTxt); + //显示报警位置 + window.$earth.sceneTree.$refs[data.labelCode].czmObject.color = [1, 0.09803921568627451, 0, 1]; + } else if (data.msgTxt != undefined && data.dealStatus == 3) { + this.$notification.open({ + key: 'fenceInfo', + message: '围栏信息通知', + description: data.msgTxt + '!', + duration: 0, + }); + } else if (data.dealStatus == 2) { + //消除单个报警位置 + window.$earth.sceneTree.$refs[data.labelCode].czmObject.color = [0.08235294117647059, 1, 0, 1]; + } else if (data.dealStatus == 0) { + //消除所有报警位置 + window.$earth.sceneTree.$refs.sensor.children.forEach((data, index) => { + data.czmObject.color = [0.08235294117647059, 1, 0, 1]; + }); + } + + //4.提示音 + if (data.dealStatus !== 2 && data.dealStatus !== 0) { + await this.$refs.audio.play(); + setTimeout(() => { + this.$refs.audio.pause(); //N秒后暂停播放 + }, data.alarmNum * 1000); + } + } else if (data.cmd == 'new_microwave_warn_info' || data.cmd == 'new_radar_warn_info' || data.cmd == 'new_video_warn_info') { + if (this.alarmInfoMap.has(data.serialNum)) { + return; + } + const evalString = ` + if(p._div){ + return + } + let left=p.winPos[0]; + let bottom=p.winPos[3]; + const div = document.createElement('div'); + div.style="position: absolute;left:"+left+"px;bottom:"+bottom+"px " + const img = document.createElement('img'); + img.src="${alarmImg}"; + img.style="width:60px;height:60px" + div.appendChild(img); + div.onclick=()=>{ + p.flyTo() + } + p._div = div; + const root=document.getElementById('earthContainer'); + root.appendChild(div); + XE.MVVM.watch(p.winPos,() => { + left=p.winPos[0]-30; + bottom=p.winPos[3]; + div.style="position: absolute;left:"+left+"px;bottom:"+bottom+"px " + }) + `; + const pinConfig: any = { + name: 'Pin1', + xbsjType: 'Pin', + position: [math.toRadians(data.lon), math.toRadians(data.lat), 0], + evalString: evalString, + // imageUrl: alarmImg, + isDivImage: true, + show: false, + far: 3000, + }; + // scanline + const scanlineConfig: any = { + name: 'AlarmScanline', + xbsjType: 'Scanline', + position: [math.toRadians(data.lon), math.toRadians(data.lat), 0], + playing: true, + radius: 30, + timeDuration: 0.5, + color: [1, 0, 0, 1], + show: false, + }; + const pin = new window.XE.Obj.Pin(window.$earth); + const scanline = new window.XE.Obj.Scanline(window.$earth); + //1、获取到世界坐标 + let start = cesium.Cartesian3.fromDegrees(data.lon, data.lat, 0); + let height = await window.$earth.czm.viewer.scene.clampToHeightMostDetailed([start]).then(function (clampedCartesians) { + //2、获取到经纬高度 + let ellipsoid = window.$earth.czm.viewer.scene.globe.ellipsoid; + let cartographic = ellipsoid.cartesianToCartographic(clampedCartesians[0]); + return cartographic.height; + }); + if (height > 0) { + pinConfig.position[2] = height; + } else if (window.$earth.sceneTree.$refs.terrain.czmObject.show) { + height = await cesium.sampleTerrainMostDetailed(earth._viewer.terrainProvider, [start]).then((updatedPositions) => { + return updatedPositions[0].height ? updatedPositions[0].height : 0; + }); + pinConfig.position[2] = height; + } else { + pinConfig.position[2] = 0; + } + + // 保存报警类型到对象上 + let customProp: any = {}; + customProp.alarmType = data.cmd; + pinConfig.customProp = JSON.stringify(customProp); + scanlineConfig.customProp = JSON.stringify(customProp); + pin.xbsjFromJSON(pinConfig); + scanline.xbsjFromJSON(scanlineConfig); + // 判断现在相机的高度来显示报警相关模型 + if (this._earth.camera.position[2] < 100) { + // 隐藏 pin, 显示 scanline + pin._div.hidden = true; + scanline.show = true; + } else { + // 隐藏 scanline, 显示 pin + pin._div.hidden = false; + scanline.show = false; + } + scanline.flyTo(); + this.alarmInfoMap.set(data.serialNum, { pin: pin, scanline: scanline, timestamp: Date.now() }); + //报警弹窗 + this.videoWindowProps.title = `实时报警窗口(${data.cameraName})`; + this.videoWindowProps.videoUrl = data.cameraCode; //相机编码 + this.videoWindowProps.isAlarm = true; + this.videoWindowProps.visible = true; + this.videoWindowProps.playRecord = false; + + this.videoWindowProps.warnEvent.happenTime = data.happenTime; + this.videoWindowProps.warnEvent.happenLoc = `${Number(data.lon).toFixed(6)},${Number(data.lat).toFixed(6)}`; + this.videoWindowProps.warnEvent.warnNum = 1; + this.videoWindowProps.warnEvent.warnLevel = filterDictTextByCache('ms_warn_level', data.warnLevel); + this.videoWindowProps.warnEvent.warnType = filterDictTextByCache('ms_warn_type', data.warnType); + this.videoWindowProps.warnEvent.warnContent = data.warnContent; + + //若警示界面打开着,则刷新列表 + if ($('.infoList').css('visibility') == 'visible') { + $mitt.emit('getWarnData'); + } + + //提示音 + await this.$refs.audio.play(); + setTimeout(() => { + this.$refs.audio.pause(); //N秒后暂停播放 + }, 3 * 1000); + } else if (data.cmd == 'earthMap_model_realtime_info') { + console.log(data); + console.log(this.radarAlarmDataMap); + // 雷达轨迹报警数据 + const alarmContent = data.content; + + if (this.radarAlarmDataMap.has(data.eventSerialNum)) { + // 存在雷达报警数据 + let radarAlarmData = this.radarAlarmDataMap.get(data.eventSerialNum); + let targetMap = radarAlarmData.target; + if (targetMap.has(data.modelId)) { + // 存在目标数据 + let targetData = targetMap.get(data.modelId); + let pathModel = targetData.path; + let groundImageModel = targetData.groundImage; + //更新目标数据 + // 更新报警数据 + let positionRadian = earthUtils.degreeToRadianInLngLatHeight(alarmContent.lon, alarmContent.lat, 0); + // 更新路径 + pathModel.positions.push(positionRadian); + groundImageModel.position = positionRadian; + if (pathModel.positions.length > 1) { + pathModel.show = true; + groundImageModel.show = true; + } + } else { + // 不存在目标数据 + // 创建目标数据 + let positionRadian = earthUtils.degreeToRadianInLngLatHeight(alarmContent.lon, alarmContent.lat, 0); + // 路径 + let pathModel = new window.XE.Obj.Path(window.$earth); + let pathConfig = { + name: 'path', + xbsjType: 'Path', + positions: [positionRadian], + loop: false, + playing: true, + width: 2, + color: [1, 0, 0, 1], + show: false, + showDirection: false, + currentSpeed: 30, + alwaysAlongThePath: true, + material: { + type: 'Color', + color: [1, 0, 0, 1], + }, + }; + pathModel.xbsjFromJSON(pathConfig); + // 地面图片 + let groundImageModel = new window.XE.Obj.GroundImage(window.$earth); + let imageUrls: any = []; + if (data.mainTarget) { + imageUrls.push(window._CONFIG['staticDomainURL'] + '/keyi_point1.png'); + imageUrls.push(window._CONFIG['staticDomainURL'] + '/keyi_point2.png'); + } else { + imageUrls.push(window._CONFIG['staticDomainURL'] + '/keyi_point3.png'); + imageUrls.push(window._CONFIG['staticDomainURL'] + '/keyi_point4.png'); + } + let groundImageConfig = { + name: 'groundImage', + xbsjType: 'GroundImage', + position: positionRadian, + width: 3, + height: 3, + playing: true, + imageUrls: imageUrls, + show: false, + }; + groundImageModel.xbsjFromJSON(groundImageConfig); + // 保存目标数据 + let targetData = { + path: pathModel, + groundImage: groundImageModel, + }; + targetMap.set(data.modelId, targetData); + } + // 更新时间 + const updateTime = Date.now(); + radarAlarmData.timestamp = updateTime; + // 更新 pin 的时间 + let alarm = this.alarmInfoMap.get(data.eventSerialNum); + if (alarm) { + alarm.timestamp = updateTime; + } + } else { + // 不存在报警数据 + // 路径 + let pathModel = new window.XE.Obj.Path(window.$earth); + let pathConfig = { + name: 'path', + xbsjType: 'Path', + positions: [earthUtils.degreeToRadianInLngLatHeight(alarmContent.lon, alarmContent.lat, 0)], + loop: false, + playing: true, + width: 2, + color: [1, 0, 0, 1], + show: false, + showDirection: false, + currentSpeed: 30, + alwaysAlongThePath: true, + material: { + type: 'Color', + color: [1, 0, 0, 1], + }, + }; + // 地面图片 + let groundImage = new window.XE.Obj.GroundImage(window.$earth); + let imageUrls: any = []; + if (data.mainTarget) { + imageUrls.push(window._CONFIG['staticDomainURL'] + '/keyi_point1.png'); + imageUrls.push(window._CONFIG['staticDomainURL'] + '/keyi_point2.png'); + } else { + imageUrls.push(window._CONFIG['staticDomainURL'] + '/keyi_point3.png'); + imageUrls.push(window._CONFIG['staticDomainURL'] + '/keyi_point4.png'); + } + let groundImageConfig = { + name: 'groundImage', + xbsjType: 'GroundImage', + playing: true, + width: 3, + height: 3, + position: earthUtils.degreeToRadianInLngLatHeight(alarmContent.lon, alarmContent.lat, 0), + imageUrls: imageUrls, + show: false, + }; + // 创建路径 + groundImage.xbsjFromJSON(groundImageConfig); + // 创建地面图片 + pathModel.xbsjFromJSON(pathConfig); + + // 保存数据到map中 + let target = { + path: pathModel, + groundImage: groundImage, + mainTarget: alarmContent.mainTarget, + }; + let targetMap = new Map(); + targetMap.set(data.modelId, target); + this.radarAlarmDataMap.set(data.eventSerialNum, { + target: targetMap, + timestamp: Date.now(), + }); + + if (!this.alarmInfoMap.has(data.eventSerialNum)) { + // 不存在告警信息(小灯或扫描线)时发送 + // 事件编号到后台使其重新发送websocket报警数据 + await new Promise((r) => setTimeout(r, 500)); + if (!this.alarmInfoMap.has(data.eventSerialNum)) { + console.log('发送websocket报警数据'); + this.loreadAlarmInfo(this.url.sendRadarAlarmByWebSocket, data.eventSerialNum); + } + } + } + if (this.videoWindowProps.visible) { + this.videoWindowProps.warnEvent.warnNum = this.radarAlarmDataMap.get(data.eventSerialNum).target.size; + } + // console.debug('雷达轨迹报警数据', this.radarAlarmDataMap); + } else if (data.cmd == '') { + earth.sceneTree.$refs[data.eventSerialNum].destroy(); + } else if (data.cmd == 'eventPublish') { + window.getEventData(); + } +} +function websocketclose(e) { + console.log('connection closed (' + e.code + ')'); + createMessage.warn('websocket连接已断开', 3); +} +function websocketdosend(configName) { + //发送数据 + this.spinning = !this.spinning; //加载状态 + console.log('this.websock[configName]', websock[configName]); + let message = { + topic: 'Show_Single_Video', + msg: '192.168.1.65', + }; + //readyState:0:正在连接中,1:已建立连接,2:连接正在关闭,3:连接已关闭或连接失败 + if (websock[configName].readyState == 1) { + websock[configName].send(JSON.stringify(message)); + that.spinning = !that.spinning; //加载状态 + console.log('已发送'); + } else { + //重新连接websocket + initWebSocket('clientURL'); + setTimeout(function () { + if (websock[configName].readyState == 1) { + websock[configName].send(JSON.stringify(message)); + } + that.spinning = !that.spinning; //加载状态 + }, 3000); + } +} + +export { + initWebSocket, + websocketonopen, + websocketonerror, + loreadAlarmInfo, + websocketclose, + websocketonmessage, + websocketdosend, + websock, +} \ No newline at end of file diff --git a/src/views/earthMap/edit/EarthComp copy.vue b/src/views/earthMap/edit/EarthComp copy.vue deleted file mode 100644 index 7987a30..0000000 --- a/src/views/earthMap/edit/EarthComp copy.vue +++ /dev/null @@ -1,2608 +0,0 @@ - - - - - - diff --git a/src/views/earthMap/edit/EarthComp.vue b/src/views/earthMap/edit/EarthComp.vue index 1ecb62f..9368563 100644 --- a/src/views/earthMap/edit/EarthComp.vue +++ b/src/views/earthMap/edit/EarthComp.vue @@ -104,6 +104,8 @@ import { getRealTime } from '@/utils/date'; import $mitt from '@/utils/earthMap/mitt'; import { drawInit } from '@/utils/earthMap/earthDraw'; + import { guid } from '@/utils/earthMap/guid'; + import HandleNodeType from '@/utils/earthMap/handleNodeType'; import { keyControlInit } from '@/utils/earthMap/keyControlInit'; import redFlag from '@/assets/earthMap/redFlag.png'; import { addModel, addPin, addViewShedRadar, addShipGroundImg, addShipTrack } from '@/utils/earthMap/earthObj'; @@ -111,76 +113,14 @@ import hidePng from '@/assets/earthMap/hide.png'; import alarmImg from '@/assets/earthMap/alarm.gif'; import VideoFusionWin from './components/VideoFusionWin.vue'; + import { useMessage } from "/@/hooks/web/useMessage"; import circleDot2 from '@/assets/earthMap/circleDot2.png'; import circleDot1 from '@/assets/earthMap/circleDot1.png'; import circleDot3 from '@/assets/earthMap/circleDot3.png'; - import ship from '@/assets/images/ship.png'; - import { onBeforeUnmount } from 'vue'; - - class HandleNodeType { - #sn; - #sensorCallback; - #modelCallback; - #markerPositionCallback; - #polylineCallBack; - #default; - - constructor(sn) { - this.#sn = sn; - } - - sensor(callback) { - this.#sensorCallback = callback; - return this; - } - - // 模型回调 - modelCallback(callback) { - this.#modelCallback = callback; - return this; - } - - // 微波雷达回调 - markerPosition(callback) { - this.#markerPositionCallback = callback; - return this; - } - - // 区域回调 - polylineCallBack(callback) { - this.#polylineCallBack = callback; - return this; - } - - default(callback) { - this.#default = callback; - return this; - } - - run() { - // 判断节点的类型 - if (!this.#sn.czmObject) { - return null; - } - // 模型类型 - let tempCondition = this.#sn.czmObject.xbsjType; - switch (tempCondition) { - case 'Model': - this.#modelCallback ? this.#modelCallback() : this.#default(); - break; - case 'Pin': - this.#markerPositionCallback ? this.#markerPositionCallback() : this.#default(); - break; - case 'Polyline': - this.#polylineCallBack ? this.#polylineCallBack() : this.#default(); - break; - default: - this.#default ? this.#default() : null; - } - } - } + + const { createMessage } = useMessage(); function setClassEl(setClassEl1, setClassEl2, checked) { if (checked) { setClassChecked(setClassEl1, setClassEl2); @@ -407,7 +347,7 @@ mounted() { let that = this; //随机数 - window.guid = this.guid; + window.guid = guid; //创建地球资源 this.createEarth(); //获取实时日期时间 @@ -452,14 +392,7 @@ }); } } - // 随机数 - guid() { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { - var r = (Math.random() * 16) | 0, - v = c == 'x' ? r : (r & 0x3) | 0x8; - return v.toString(16); - }); - } + // 打开视频融合 roamPathSet() { // 打开视频融合 @@ -2187,8 +2120,7 @@ // notification.close("RoamVideoSet"); // sessionStorage.setItem("RoamVideoSet", "false"); } else { - // Msg.error('删除失败'); - $mitt.emit('openNotification', { msg: '删除失败', dt: 2, type: 'error', top: '50px' }); + createMessage.error('修改失败', 2); console.error('删除失败', response); } }) @@ -2280,12 +2212,10 @@ { isTransformResponse: false } ) .then((response) => { - $mitt.emit('openNotification', { msg: '编辑成功', dt: 2, type: 'success', top: '50px' }); - // console.error('编辑成功', response); + createMessage.success('编辑成功', 2); }) .catch((response) => { - $mitt.emit('openNotification', { msg: '编辑失败', dt: 2, type: 'error', top: '50px' }); - // console.error('删除失败', response); + createMessage.error('编辑失败', 2); }); }; }); @@ -2315,7 +2245,7 @@ }); this.store.shapeList = shapeList; } else { - $mitt.emit('openNotification', { msg: '删除失败', dt: 2, type: 'error', top: '50px' }); + createMessage.error('删除失败', 2); console.error('删除失败', response); } }) @@ -2353,10 +2283,6 @@ that.VideoFusionWinShow = e; }); //其他页面调用本页面的methods方法 - $mitt.on('openNotification', (res: any) => { - // that.openNotification(msg, dt, type, top) - that.openNotification(res.msg, res.dt, res.type, res.top); - }); $mitt.on('listenMouseHandler', function () { that.listenMouseHandler(); }); @@ -2394,8 +2320,7 @@ } else { // 失败 console.log('失败'); - - this.$message.error(res.message); + createMessage.error(res.message); } }); } else { @@ -2833,7 +2758,7 @@ } websocketclose(e) { console.log('connection closed (' + e.code + ')'); - this.openNotification('websocket连接已断开', 3, 'warning'); + createMessage.warn('websocket连接已断开', 3); } websocketdosend(configName) { //发送数据 @@ -2861,32 +2786,6 @@ } } /* websocket-end */ - openNotification(msg, dt = 2, type = 'info', top = '300px') { - // console.log("openNotification收到"); - // console.log("proxy",this); - // console.log("window",window); - // debugger - this.$message.config({ - top: top, - duration: dt, - maxCount: 3, - }); - switch (type) { - case 'info': - this.$message.info(msg); - break; - case 'success': - this.$message.success(msg); - break; - case 'error': - this.$message.error(msg); - break; - case 'warning': - this.$message.warning(msg); - break; - default: - } - } getRandomArr(arr, count) { //从数组随机抽取元素 var shuffled = arr.slice(0), @@ -3233,10 +3132,10 @@ // postAction(this.url.SaveSensorModel, saveSensorModelParameter) .then((res) => { if (res.success) { - that.$message.success('克隆成功'); + createMessage.success('克隆成功'); } else { newSn.parent.children.splice(index, 1); - that.$message.error('克隆失败: ', res.message ? res.message : ''); + createMessage.error('克隆成功:'+ res.message); } }); }) @@ -3284,15 +3183,15 @@ jsonObj.labelCode = ''; newSn.czmObject.customProp = JSON.stringify(jsonObj); // 保存成功 - that.$message.success('克隆成功'); + createMessage.success('克隆成功'); } else { newSn.parent.children.splice(index, 1); - that.$message.error('克隆失败: ', res.message ? res.message : ''); + createMessage.error('克隆失败'+ res.message); } }) .catch((err) => { newSn.parent.children.splice(index, 1); - that.$message.error('克隆失败'); + createMessage.error('克隆失败'); }); }) //区域回调 @@ -3398,13 +3297,12 @@ }) .catch((e) => { currentModel.destroy(); - // $mitt.emit('openNotification', '克隆区域数据出错', 2, 'error', '50px') - $mitt.emit('openNotification', { msg: '克隆区域数据出错', dt: 2, type: 'error', top: '50px' }); + createMessage.error('克隆区域数据出错', 3); }); }) //监控点 .modelCallback(() => { - this.$message.warning('监控点不支持克隆'); + createMessage.warning('监控点不支持克隆'); }) .run(); } @@ -3474,7 +3372,7 @@ for (const child of childList) { if (child.children.length > 0) { - this.$message.warning('存在下级数据无法删除'); + createMessage.warning('存在下级数据无法删除'); throw '存在下级数据无法删除'; } } @@ -3525,7 +3423,7 @@ that.setIconByRef(ref, el); }); } else { - that.$message.error('设备不在线'); + createMessage.error('设备不在线'); } } } else if (device.deviceType_dictText.indexOf('雷达') > -1) { @@ -3804,7 +3702,7 @@ // 感应器 .sensor(() => { // 不支持修改名称 - this.$message.warning('不支持修改感应器的名称'); + createMessage.warning('不支持修改感应器的名称'); }) // 传感器标志线 .modelCallback(() => { @@ -3824,13 +3722,13 @@ // putAction(this.url.updateSite, editCameraSiteModelParameter) .then((res) => { if (res.success) { - this.$message.success('修改成功'); + createMessage.success('修改成功'); } else { - this.$message.error('修改失败'); + createMessage.error('修改失败'); } }) .catch((error) => { - this.$message.error('修改失败'); + createMessage.error('修改失败'); }); }) .markerPosition(() => { @@ -3852,13 +3750,13 @@ if (res.success) { // 修改扩展文本 sn.czmObject.pinBuilder.extText = newTitle; - this.$message.success('修改成功'); + createMessage.success('修改成功'); } else { - this.$message.error('修改失败'); + createMessage.error('修改失败'); } }) .catch((error) => { - this.$message.error('修改失败'); + createMessage.error('修改失败'); }); }) .run(); @@ -3866,7 +3764,6 @@ // 右键菜单删除按钮的删除方法 handlerModelDelete(url, params) { - // return deleteAction(url, params).then((res) => { return defHttp .delete( { @@ -3877,9 +3774,9 @@ ) .then((res) => { if (res.success) { - this.$message.success('删除成功'); + createMessage.success('删除成功'); } else { - this.$message.error('删除失败'); + createMessage.error('删除失败'); console.log('asdasdasd'); } }); @@ -3926,12 +3823,11 @@ }, { isTransformResponse: false } ) - // putAction(this.url.updateSensor, editSensorParams) .then((res) => { if (res.success) { - this.$message.success('修改成功'); + createMessage.success('修改成功'); } else { - this.$message.error('修改失败: ', res.message); + createMessage.error('修改失败: ' + res.message); } }); }) @@ -3966,9 +3862,9 @@ .then((res) => { if (res.success) { modelData.pinBuilder.extText = modelData.name; - this.$message.success('修改成功'); + createMessage.success('修改成功'); } else { - this.$message.error('修改失败'); + createMessage.error('修改失败'); } }); }) @@ -3998,13 +3894,13 @@ .then((res) => { if (res.success) { modelData.pinBuilder.extText = modelData.name; - this.$message.success('修改成功'); + createMessage.success('修改成功'); } else { - this.$message.error('修改失败'); + createMessage.error('修改失败'); } }) .catch((error) => { - this.$message.error('修改失败'); + createMessage.error('修改失败'); }); }) .polylineCallBack(() => { @@ -4076,21 +3972,17 @@ }, { isTransformResponse: false } ) - // putAction(this.url.updateMapLine, submitData) .then((res) => { if (res.success) { - // $mitt.emit('openNotification', '修改成功', 2, 'info') - $mitt.emit('openNotification', { msg: '修改成功!', dt: 2, type: 'info', top: '50px' }); + createMessage.success('修改成功!', 2); sn.title = submitData.name; window.$earth.sceneTree.$refs['node_' + sn.ref].title = submitData.name; } else { - // $mitt.emit('openNotification', '修改失败', 2, 'error', '50px') - $mitt.emit('openNotification', { msg: '修改失败', dt: 2, type: 'error', top: '50px' }); + createMessage.error('修改失败', 2); } }) .catch((error) => { - // $mitt.emit('openNotification', '修改失败', 2, 'error', '50px') - $mitt.emit('openNotification', { msg: '修改失败', dt: 2, type: 'error', top: '50px' }); + createMessage.error('修改失败', 2); }); }) .run(); @@ -4123,25 +4015,23 @@ this.sceneTreeOldRefValue = ''; // 更新模型的名称 model.title = newRef; - this.$message.success('修改成功'); + createMessage.success('修改成功'); } else { - this.$message.error('修改失败: ' + res.message); + createMessage.error('修改失败: ' + res.message); } }) .catch((err) => { - this.$message.error('修改失败: ', err); + createMessage.error('修改失败: ' + err); }); }) .modelCallback(() => { // 传感器标志线不能修改ref,因为 ref 是后台数据库的ID; - this.$message.warning('无法修改传感器标志线的ref'); + createMessage.warning('无法修改传感器标志线的ref'); }) .run(); } }, 150); - handleNodeType(sn) { - return new HandleNodeType(sn); - } + radarAlarmTimeOutCheck() { const now = Date.now(); const timeout = 5 * 60 * 1000; @@ -4182,6 +4072,11 @@ } this.clearRadarAlarmModel(radarAlarmDataMap, eventNum); } + + //调用方法 + handleNodeType(sn) { + return new HandleNodeType(sn); + } // 获取当前实时时间 getRealTime() { this.timer2 = setInterval(() => { diff --git a/src/views/military/modules/duty/DutySet.vue b/src/views/military/modules/duty/DutySet.vue index 22887b8..ec0b7d2 100644 --- a/src/views/military/modules/duty/DutySet.vue +++ b/src/views/military/modules/duty/DutySet.vue @@ -120,7 +120,7 @@ // httpAction(this.addUrl, this.addData, 'post') .then((res) => { if (res.success) { - $message.success(res.message); + $message.createMessage.success(res.message); } else { // that.$message.warning(res.message); } diff --git a/src/views/military/modules/dutyManage/duty/DutySet.vue b/src/views/military/modules/dutyManage/duty/DutySet.vue index 1a3d0a0..00bc2ef 100644 --- a/src/views/military/modules/dutyManage/duty/DutySet.vue +++ b/src/views/military/modules/dutyManage/duty/DutySet.vue @@ -120,7 +120,7 @@ // httpAction(this.addUrl, this.addData, 'post') .then((res) => { if (res.success) { - $message.success(res.message); + $message.createMessage.success(res.message); } else { // that.$message.warning(res.message); } diff --git a/src/views/military/modules/equipment/camera/CameraSet.vue b/src/views/military/modules/equipment/camera/CameraSet.vue index c0dbb7b..a86455f 100644 --- a/src/views/military/modules/equipment/camera/CameraSet.vue +++ b/src/views/military/modules/equipment/camera/CameraSet.vue @@ -450,7 +450,6 @@ } if (cameraForm.value.id == '') { - // this.$message.info("请先选择需要修改的数据!"); createMessage.info('请先选择需要修改的数据!'); return false; } @@ -577,7 +576,6 @@ return; } // else if (!pattern.test(this.cameraForm.cloudCtrlIp)){ - // this.$message.warning("请正确填写云台IP!"); // return // } cameraForm.value.channel = channel ? channel : '0'; diff --git a/src/views/military/modules/eventManage/emergencyPlan/components/MsEmergencyPlanForm.vue b/src/views/military/modules/eventManage/emergencyPlan/components/MsEmergencyPlanForm.vue index c07c0d0..16050f6 100644 --- a/src/views/military/modules/eventManage/emergencyPlan/components/MsEmergencyPlanForm.vue +++ b/src/views/military/modules/eventManage/emergencyPlan/components/MsEmergencyPlanForm.vue @@ -153,7 +153,6 @@ function addStep() { stepList.value.push(""); stepText.value.focus(); } else { - // this.$message.error("最多只能添加5个步骤") createMessage.error("最多只能添加5个步骤") } } @@ -164,7 +163,6 @@ function removeStep() { stepCurrent.value = stepCurrent.value == 0 ? 0 : stepCurrent.value - 1; stepText.value.focus(); } else { - // this.$message.error("至少要有一个步骤") createMessage.error("至少要有一个步骤") } }