import store from "@/store"; import { getRunAlarm, getRunWarning } from "@/api/api.js"; const menuTool = { toolMenu: null, toolFlag: null, oldLeftMenuId: "f1", newLeftMenuId: null, colorAll: {}, squareOjb: [], CCpoi: [], WRpoi: [], SSpoi: [], YZZpoi: [], BJtext: "0条报警信息", YJtext: "0条预警信息", BJlist: [], YJlist: [], YJpoi: [], BJpoi: [], leftTools(res) { // this.closePoi(); // this.closeSYWG(); this.clearLeftTools({ id: this.oldLeftMenuId }); this.oldLeftMenuId = res.id; switch (res.id) { case "a2": //精准溯源 window.sgworld.Navigate.flyToPosition(115.95108, 39.7411754, 5100, { heading: -90, }); this.createJKpoi(); break; case "a3": //智能报告 break; case "b2": //超标点预测 window.sgworld.Navigate.flyToPosition(115.95108, 39.7411754, 7200, { heading: -90, }); break; case "b3": //污染物扩散趋势 window.sgworld.Core.postMessage({ TypeG1: "Loop", LG1: "1" }); window.sgworld.Navigate.flyToPosition(115.95108, 39.7411754, 7200, { heading: -90, }); break; case "c2": //预警信息 break; case "c3": //报警信息 break; case "d2": //风场模拟 window.sgworld.Navigate.flyToPosition(115.95108, 39.7411754, 7200, { heading: -90, }); this.createFC("fc"); break; case "d3": //污染物模拟 window.sgworld.Navigate.flyToPosition(115.95108, 39.7411754, 7200, { heading: -90, }); this.createWRW("wrw"); break; case "d4": //监控点位 window.sgworld.Navigate.flyToPosition(115.95108, 39.7411754, 5100, { heading: -90, }); this.createJKpoi(); break; case "d5": //排放点位 window.sgworld.Navigate.flyToPosition(115.95108, 39.7411754, 5100, { heading: -90, }); this.createPFpoi(); break; case "d6": //天气特效 break; case "e2": //阈值设置 break; case "e3": //系统说明 break; } }, clearLeftTools(res) { switch (res.id) { case "a1": //精准溯源清除 store.commit("getWGobj", null); this.closePoi(); this.closeSYWG(); this.delLine(); this.delFC(); break; case "a2": //精准溯源清除 store.commit("getWGobj", null); this.closePoi(); this.closeSYWG(); this.delLine(); this.delFC(); break; case "a3": //智能报告清除 break; case "b1": //超标点预测清除 window.sgworld.Core.postMessage({ TypeG1: "Delete" }); this.delLine(); store.commit("getWGobj", null); break; case "b2": //超标点预测清除 window.sgworld.Core.postMessage({ TypeG1: "Delete" }); this.delLine(); store.commit("getWGobj", null); break; case "b3": //污染物扩散趋势清除 window.sgworld.Core.postMessage({ TypeG1: "Delete" }); break; case "c1": //预警信息清除报警信息清除 this.closePoi(); this.delFC(); this.delLine(); this.closeSYWG(); break; case "c2": //预警信息清除 this.closePoi(); this.delFC(); this.delLine(); this.closeSYWG(); break; case "c3": //报警信息清除 this.closePoi(); this.delFC(); this.delLine(); break; case "d1": // this.closePoi(); this.delFC(); this.delWRW(); break; case "d2": //风场模拟清除 this.delFC(); break; case "d3": //污染物模拟清除 this.delWRW(); break; case "d4": //监控点位清除 this.closePoi(); break; case "d5": //排放点位清除 this.closePoi(); break; case "d6": //天气特效清除 break; case "e2": //阈值设置清除 break; case "e3": //系统说明清除 break; } }, //监控点位 createJKpoi() { var jkpoiData = JSON.parse(JSON.stringify(store.state.jkList)); var CCpoiData = JSON.parse(JSON.stringify(store.state.ccList)); CCpoiData.forEach((e) => { let ids = sgworld.Core.createRandomId(); if (!e.imgurl) { e.imgurl = "img/CJJCZ.png"; } this.createPoi(e, e.imgurl, ids, "name", "CJ", -25); this.CCpoi.push(ids); }); jkpoiData.forEach((e) => { let ids = sgworld.Core.createRandomId(); if (!e.imgurl) { e.imgurl = "img/WYW.png"; } this.createPoi(e, e.imgurl, ids, "name", "WY", -25); this.WRpoi.push(ids); }); }, //排放点位 createPFpoi() { store.state.yzList.forEach((e) => { let ids = window.sgworld.Core.createRandomId(); this.createPoi(e, "img/YZI1.png", ids, "name", "WY", -35); this.YZZpoi.push(ids); }); // getPOI("有组织排放", "YZ", "YZZpoi", "img/YZI1.png"); setTimeout(() => { // getPOI("实时排放", "SS", "SSpoi", "img/SS.png"); store.state.ssList.forEach((e) => { let ids = window.sgworld.Core.createRandomId(); this.createPoi(e, "img/SS.png", ids, "name", "CJ", -35); this.SSpoi.push(ids); }); }, 500); }, //预警点位 createYJpoi() { this.closePoi(); this.YJlist.forEach((e) => { let ids = window.sgworld.Core.createRandomId(); this.createPoi(e, "img/yjd.png", ids, "locationName", "WY", -25); this.YJpoi.push(ids); }); }, //报警点位 createBJpoi() { this.closePoi(); this.BJlist.forEach((e) => { let ids = window.sgworld.Core.createRandomId(); this.createPoi(e, "img/bjd.png", ids, "locationName", "WY", -25); this.BJpoi.push(ids); }); }, //创建poi点 createPoi(e, img, id, name, type, fontOffsetY) { var poi = window.sgworld.Creator.createBillboard({ id: id, lon: e.lon, //经度 lat: e.lat, //纬度 height: 150, //高度 text: e[name], //文本内容 textLocation: "up", //文本位置 fontSize: 16, //文本字体大小 fontColor: "#00D2FF", //字体颜色 fontOffset: { //文本自定义偏移量 x: 0, y: fontOffsetY, }, image: `${imgUrl}${img}`, //POI图标地址 distanceDisplayCondition: { near: 0, far: 5500, }, data: { name: e[name], type: type, }, scale: 0.4, clickedScale: 0.4, POIName: "", }); }, //关闭poi点 closePoi() { if (this.CCpoi.length != 0) { this.CCpoi.forEach((e) => { window.sgworld.ProjectTree.deleteItem(e); }); this.CCpoi = []; } if (this.WRpoi.length != 0) { this.WRpoi.forEach((e) => { window.sgworld.ProjectTree.deleteItem(e); }); this.WRpoi = []; } if (this.SSpoi.length != 0) { this.SSpoi.forEach((e) => { window.sgworld.ProjectTree.deleteItem(e); }); this.SSpoi = []; } if (this.YZZpoi.length != 0) { this.YZZpoi.forEach((e) => { window.sgworld.ProjectTree.deleteItem(e); }); this.YZZpoi = []; } if (this.YJpoi.length != 0) { this.YJpoi.forEach((e) => { window.sgworld.ProjectTree.deleteItem(e); }); this.YJpoi = []; } if (this.BJpoi.length != 0) { this.BJpoi.forEach((e) => { window.sgworld.ProjectTree.deleteItem(e); }); this.BJpoi = []; } }, //关闭溯源网格 closeSYWG() { sgworld.Core.postMessage({ type: "delete" }); }, //风场模拟 createFC(type, date) { if (type == "fc") { sgworld.Core.postMessage( `Type=shunxuwinds;Bool=true;Density=${FC.Density};Speed=${FC.Speed};` ); } else if (type == "sj") { let arr = date.split(/\s+/); let day = arr[0].split("-"); let Hour = arr[1]; sgworld.Core.postMessage( `Type=customewinds;Bool=true;Year=${day[0]};Mouth=${day[1]};Day=${day[2]};Hour=${Hour};Density=${FC.Density};Speed=${FC.Speed};` ); // console.log( // `Type=customewinds;Bool=true;Year=${day[0]};Mouth=${day[1]};Day=${day[2]};Hour=${Hour[0]};Density=${FC.Density};Speed=${FC.Speed};` // ); } else { } }, //风场删除 delFC() { sgworld.Core.postMessage("Type=customewinds;Bool=false;"); sgworld.Core.postMessage("Type=shunxuwinds;Bool=false;"); }, //污染物删除 delWRW() { sgworld.Core.postMessage("Type=wuranwu;Bool=false;"); sgworld.Core.postMessage("Type=wuranwu;Type2=zidingyi;Bool=false;"); }, //污染物 createWRW(type, date) { if (type == "wrw") { sgworld.Core.postMessage( "Type=wuranwu;Bool=true;Type2=zidong;Alpha=0.03;Speed=2;" ); } else if (type == "sj") { let arr = date.split(/\s+/); let day = arr[0].split("-"); let Hour = arr[1]; sgworld.Core.postMessage( `Type=wuranwu;Bool=true;Type2=zidingyi;Yearstart=${day[0]};Mouthstart=${day[1]};Daystart=${day[2]};Hourend=${Hour};Alpha=0.03;Speed=0.5;` ); } }, async bjthis(time) { this.BJlist = []; const dt = await getRunAlarm(time); var obj = {}; this.BJlist = dt.result.reduce(function (item, next) { obj[next.locationName] ? "" : (obj[next.locationName] = true && item.push(next)); return item; }, []); // this.BJtext = `${this.BJlist.length}条报警信息`; store.commit("getBJlist", this.BJlist); this.createBJpoi(); return dt.result; }, async yjthis(time) { this.YJlist = []; const dt1 = await getRunWarning(time); // this.YJlist = dt1.result; // this.YJlist = this.YJlist.filter((item, index) => { // return item.id !== this.YJlist[index + 1].id; // }); var obj = {}; this.YJlist = dt1.result.reduce(function (item, next) { obj[next.locationName] ? "" : (obj[next.locationName] = true && item.push(next)); return item; }, []); // this.YJtext = `${this.YJlist.length}条预警信息`; store.commit("getYJtext", this.YJlist); this.createYJpoi(); return dt1.result; }, //删除连线 delLine() { sgworld.Core.postMessage({ func_name: "RemoveGridLines", id: "" }); //删除边界 sgworld.Core.postMessage({ func_name: "RemoveGridSide", id: "" }); }, }; export default menuTool;