MapEvent.js 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894
  1. import { getViewer } from '@/store/map/mapService'
  2. import { _locate } from '@/utils'
  3. import { addNewDatasource, setModelShow, openLayer } from '@/utils/mapUtil'
  4. import { getRTData } from '@/API/rtdata'
  5. import { getEquipmentDataList } from '@/API/equipment'
  6. import { getWXYDetail } from '@/API/custom'
  7. import {
  8. Entity,
  9. Cesium3DTileFeature,
  10. Cartesian3,
  11. Color,
  12. ScreenSpaceEventHandler,
  13. ScreenSpaceEventType,
  14. Cartographic,
  15. Math as cMath,
  16. defined as cDefined,
  17. SceneTransforms,
  18. ModelNode,
  19. } from 'cesium'
  20. import Popup from '@/utils/popup.js'
  21. import { mapGetters } from 'vuex'
  22. import { find, remove } from 'lodash-es'
  23. export default {
  24. name: 'mapEvent',
  25. data() {
  26. return {
  27. tooltipDialogArr: [],
  28. alwaysShowDialogArr: [],
  29. overlapCamera: {
  30. overlapCameras: [], //重叠摄像头的显示
  31. show: false,
  32. position: {
  33. x: '0px',
  34. y: '0px',
  35. },
  36. },
  37. overlapFire: {
  38. overlapFires: [], //重叠火灾报警器的显示
  39. show: false,
  40. position: {
  41. x: '0px',
  42. y: '0px',
  43. },
  44. },
  45. equipmentData: [], //点击模型时的设备数据,每次点击时,如果equipmentId>0时使用
  46. }
  47. },
  48. computed: {
  49. ...mapGetters(['mapPopupConfig', 'modelList', 'rtTag', 'buildInfo']),
  50. },
  51. watch: {
  52. mapPopupConfig(newVal) {
  53. if (newVal.isShow) {
  54. this.openMapPopup({
  55. type: newVal.type,
  56. position: newVal.position,
  57. dialogid: newVal.dialogid,
  58. p1: newVal.p1,
  59. p2: newVal.p2,
  60. })
  61. }
  62. },
  63. },
  64. mounted() {
  65. setTimeout(() => {
  66. this.registerLeftClickEvent()
  67. this.registerRightClickEvent()
  68. }, 5000)
  69. },
  70. methods: {
  71. /**
  72. * 注册鼠标左击事件
  73. */
  74. registerLeftClickEvent() {
  75. const viewer = getViewer()
  76. var scene = viewer.scene
  77. var handler = new ScreenSpaceEventHandler(scene.canvas)
  78. viewer.screenSpaceEventHandler.removeInputAction(ScreenSpaceEventType.LEFT_CLICK)
  79. handler.setInputAction(movement => {
  80. console.log('来自mapEvent的mixin对象')
  81. //原person.js
  82. this.handleCloseOverlapDialog()
  83. this.handleCloseBuildingPersonDialog()
  84. this.handleCloseOverlapDialog()
  85. //复位一些内容
  86. this.$store.dispatch('dialog/closeLayerDetailDialog')
  87. this.tooltipDialogArr = []
  88. var pickObj = scene.pick(movement.position)
  89. let position1 = viewer.scene.pickPosition(movement.position)
  90. let cartographicNew = Cartographic.fromCartesian(position1)
  91. let longitude = cMath.toDegrees(cartographicNew.longitude)
  92. let latitude = cMath.toDegrees(cartographicNew.latitude)
  93. let height = cartographicNew.height
  94. if (cDefined(pickObj)) {
  95. //点击实体的处理
  96. if (pickObj && pickObj.id && pickObj.id instanceof Entity) {
  97. console.log(pickObj)
  98. const type = pickObj.id.properties
  99. ? pickObj.id.properties._type
  100. ? pickObj.id.properties._type._value
  101. : ''
  102. : ''
  103. console.log(type, pickObj.id)
  104. const data = pickObj.id.properties
  105. ? pickObj.id.properties._details
  106. ? pickObj.id.properties._details._value
  107. : ''
  108. : ''
  109. let obj = {
  110. type: pickObj.id && pickObj.id.properties ? pickObj.id.properties._type._value : '',
  111. // data: pickObj.id && pickObj.id.properties
  112. // ? pickObj.id.properties._details._value
  113. // : "",
  114. position: [longitude, latitude, height],
  115. }
  116. //点击了人,打开人员信息卡片
  117. if (type === 'person') {
  118. this.openPersonDialog(pickObj.id.properties._details._value.Id)
  119. } else if (type === 'layer_station') {
  120. //打开站点模型
  121. console.log(data)
  122. this.$store.dispatch('model/setBuildInfoByBuildId', data.buildId)
  123. // this.$store.dispatch('globalConfig/setMapMode', { value: '3d' })
  124. }
  125. //点击了建筑名称,打开建筑内人员情况
  126. else if (type === 'buildingPerson') {
  127. this.openBuildingPersonDialog(pickObj.id.properties._details._value, movement.position)
  128. }
  129. //点击了围栏,打开围栏详情
  130. else if (type === 'rail') {
  131. // console.log(pickObj)
  132. // console.log(this.alarmLiveData);
  133. const id = data.id
  134. const name = data.name
  135. const tableData = this.alarmLiveData.filter(item => {
  136. return item.Category == '100001' && item.ObjectID == id
  137. })
  138. this.$store.dispatch('dialog/openLayerDetailDialog', {
  139. id,
  140. type: 'rail',
  141. detail: { id, name, tableData },
  142. })
  143. } else if (type === 'risk_rail') {
  144. console.log(pickObj)
  145. const id = data.id
  146. const name = data.name
  147. const tableData = this.alarmLiveData.filter(item => {
  148. return item.Category == '100001' && item.ObjectID == id
  149. })
  150. this.$store.dispatch('dialog/openLayerDetailDialog', {
  151. id,
  152. type: 'riskRail',
  153. detail: { id, name, tableData },
  154. })
  155. }
  156. //点击摄像头,打开追视窗口
  157. else if (type === 'camera') {
  158. this.$store.dispatch('dialog/openVideoDialog', data.id)
  159. } else if (type === 'wf') {
  160. this.getWFConfig(obj)
  161. } else if (type === 'zdwxy') {
  162. this.getWXYDetail(data.id).then(res => {
  163. this.$store.dispatch('dialog/openLayerDetailDialog', {
  164. id: data.id,
  165. type: 'zdwxy',
  166. detail: { ...res },
  167. })
  168. })
  169. } else if (type === 'fxqy') {
  170. this.$store.dispatch('dialog/openLayerDetailDialog', {
  171. id: data.id,
  172. type: 'fxqy',
  173. detail: { ...data },
  174. })
  175. } else if (type === 'fbky') {
  176. console.log("数据内容fbky:----------------", data);
  177. // this.$store.dispatch('dialog/openLayerDetailDialog', {
  178. // id: data.id,
  179. // type: 'fbky',
  180. // detail: { ...data },
  181. // })
  182. } else if (type === '集气站' || type === '汇管' || type === '井管' || type === '站间管' || type === '井') {
  183. this.$nextTick(() => {
  184. this.showEntityToolTip(pickObj, obj, type)
  185. this.runEntityActionScript(pickObj, 3)
  186. })
  187. } else if (type === 'trackPoint') {
  188. //轨迹点
  189. const trackPointDetails = pickObj.id.properties._details._value
  190. console.log(trackPointDetails)
  191. } else if (type === 'building') {
  192. this.showModelToolTip(pickObj.id.code, pickObj.id.name, pickObj, obj)
  193. } else if (type === 'layer_perimeter') {
  194. const data = pickObj.id.properties ? pickObj.id.properties.segment._value : ''
  195. if (this.mapDialogConfig.perimeter.some(item => item.dialogMsg?.data?.id == data.id)) {
  196. this.mapDialogConfig.perimeter = this.mapDialogConfig.perimeter.filter(
  197. item => item.dialogMsg?.data?.id != data.id
  198. )
  199. }
  200. this.mapDialogConfig.perimeter.push({
  201. show: false,
  202. dialogMsg: { data, position: [longitude, latitude, height] },
  203. })
  204. console.log("周界信息", this.mapDialogConfig.perimeter)
  205. for (let d of this.mapDialogConfig.perimeter) {
  206. ; (() => {
  207. setTimeout(() => {
  208. d.show = true
  209. if (d.dialogMsg.data.cameras?.length) {
  210. this.$store.dispatch('dialog/openVideoDialog', d.dialogMsg.data.cameras[0].cameraId)
  211. }
  212. this.$store.dispatch('home/setMapPopupConfig', {
  213. isShow: true,
  214. type: 'point',
  215. position: d.dialogMsg?.position,
  216. dialogid: 'perimeter_' + d.dialogMsg?.data?.id,
  217. p1: 132,
  218. p2: 236,
  219. })
  220. }, 0)
  221. })()
  222. }
  223. } else if (type === 'layer_fire') {
  224. // if (this.mapDialogConfig.fire.some(item => item.dialogMsg?.data?.id == data.id)) {
  225. // this.mapDialogConfig.fire = this.mapDialogConfig.fire.filter(
  226. // item => item.dialogMsg?.data?.id != data.id
  227. // )
  228. // }
  229. const fireInfo = pickObj.id.properties._details._value
  230. const gpsAlarmPoint = this.transPosition([{ x: fireInfo.location.x, y: fireInfo.location.y, z: fireInfo.height }])
  231. console.log('坐标点转化', gpsAlarmPoint);
  232. fireInfo.alarmType = -1
  233. this.mapDialogConfig.fire = []
  234. console.log("无报警", this.mapDialogConfig.fire);
  235. this.mapDialogConfig.fire.push({
  236. show: false,
  237. dialogMsg: { data: fireInfo, position: [gpsAlarmPoint[0][0], gpsAlarmPoint[0][1], gpsAlarmPoint[0][2]] },
  238. })
  239. for (let d of this.mapDialogConfig.fire) {
  240. ; (() => {
  241. setTimeout(() => {
  242. d.show = true
  243. if (d.dialogMsg.data.cameras?.length) {
  244. this.$store.dispatch('dialog/openVideoDialog', d.dialogMsg.data.cameras[0].cameraId)
  245. }
  246. this.$store.dispatch('home/setMapPopupConfig', {
  247. isShow: true,
  248. type: 'point',
  249. position: [gpsAlarmPoint[0][0], gpsAlarmPoint[0][1], gpsAlarmPoint[0][2]],
  250. dialogid: 'fire_' + d.dialogMsg?.data?.id,
  251. p1: 140,
  252. p2: 236,
  253. })
  254. }, 0)
  255. })()
  256. }
  257. } else if (type === 'layer_jgyt_Point') {
  258. if (this.mapDialogConfig.jgyt.some(item => item.dialogMsg?.data?.id == data.id)) {
  259. this.mapDialogConfig.jgyt = this.mapDialogConfig.jgyt.filter(
  260. item => item.dialogMsg?.data?.id != data.id
  261. )
  262. }
  263. this.mapDialogConfig.jgyt.push({
  264. show: false,
  265. dialogMsg: { data },
  266. })
  267. for (let d of this.mapDialogConfig.jgyt) {
  268. ; (() => {
  269. setTimeout(() => {
  270. d.show = true
  271. this.$store.dispatch('dialog/openVideoDialog', [d.dialogMsg?.data?.cameraId])
  272. this.$store.dispatch('home/setMapPopupConfig', {
  273. isShow: true,
  274. type: 'point',
  275. position: [
  276. +d.dialogMsg?.data?.longitude,
  277. +d.dialogMsg?.data?.latitude,
  278. +d.dialogMsg?.data?.height,
  279. ],
  280. dialogid: 'jgyt_' + d.dialogMsg?.data?.id,
  281. p1: 200,
  282. p2: 210,
  283. })
  284. }, 0)
  285. })()
  286. }
  287. // this.$store.dispatch('dialog/openVideoDialog', jgytData.cameraID)
  288. } else if (!!type) {
  289. console.log("数据内容:----------------", data);
  290. this.$store.dispatch('dialog/openLayerDetailDialog', {
  291. id: data.id,
  292. type: 'normal',
  293. name: data.name,
  294. detail: {
  295. id: data.id,
  296. name: data.name,
  297. tableData: data.dataList,
  298. },
  299. })
  300. }
  301. }
  302. //点击3dtiles建筑的处理
  303. var feature = pickObj
  304. if (feature instanceof Cesium3DTileFeature) {
  305. // console.log(feature.getProperty("name"))
  306. // console.log(feature.getProperty("id"))
  307. console.log(feature)
  308. console.log(
  309. `点击了【${feature.tileset.name}】的【${feature.getProperty('name')}】【${feature.getProperty('id')}】`
  310. )
  311. this.runModelActionScript(feature.tileset.code, feature.getProperty('id'), 3)
  312. let obj = {
  313. type: 'modelpart',
  314. // data: pickObj.id && pickObj.id.properties
  315. // ? pickObj.id.properties._details._value
  316. // : "",
  317. position: [longitude, latitude, height],
  318. }
  319. console.log('地下模式', this.underGround)
  320. if (!this.underGround) {
  321. const modelRootClickRet = this.setModelRoofVisible(feature.getProperty('name'))
  322. console.log(this.underground)
  323. if (!modelRootClickRet.hasFeature && !modelRootClickRet.insideModel) {
  324. this.showModelToolTip(feature.tileset.code, feature.getProperty('id'), pickObj, obj)
  325. setModelShow({ model: 'JBZHZ' }, true)
  326. } else if (!modelRootClickRet.hasFeature && modelRootClickRet.insideModel) {
  327. this.showModelToolTip(feature.tileset.code, feature.getProperty('id'), pickObj, obj)
  328. }
  329. } else {
  330. this.showModelToolTip(feature.tileset.code, feature.getProperty('id'), pickObj, obj)
  331. }
  332. //feature.show = false;
  333. }
  334. if (feature instanceof Cesium3DTileFeature && feature.getProperty('name') !== '000000') {
  335. // console.log(feature);
  336. // console.info("id: " + feature.getProperty("id"));
  337. // console.info("name: " + feature.getProperty("name"));
  338. // console.info("buildingId: " + feature.getProperty("buildingId"));
  339. // console.info("underFloor: " + feature.getProperty("underFloor"));
  340. // console.info("aboveFloor: " + feature.getProperty("aboveFloor"));
  341. let bid = feature.getProperty('buildingId')
  342. if (!!bid) {
  343. if (this.building.curBuildingId > 0) {
  344. this.setElementShow(this.building.curBuildingId, true)
  345. for (let i = 1; i <= this.building.curMaxFloor; i++) {
  346. this.setElementShow(this.building.curBuildingId + 'F' + i, false)
  347. }
  348. this.building.curBuildingId = 0
  349. this.building.curMaxFloor = 1
  350. }
  351. this.setElementShow(feature.getProperty('name'), false)
  352. this.building.curBuildingId = bid
  353. this.building.curMaxFloor = feature.getProperty('aboveFloor')
  354. for (let i = 1; i <= this.building.curMaxFloor; i++) {
  355. //console.log(this.building.curBuildingId + "F" + i);
  356. this.setElementShow(this.building.curBuildingId + 'F' + i, true)
  357. }
  358. this.floorHeightChanged(0)
  359. } else {
  360. if (this.building.curBuildingId > 0) {
  361. this.setElementShow(this.building.curBuildingId, true)
  362. for (let i = 1; i <= this.building.curMaxFloor; i++) {
  363. this.setElementShow(this.building.curBuildingId + 'F' + i, false)
  364. }
  365. this.building.curBuildingId = 0
  366. this.building.curMaxFloor = 1
  367. }
  368. }
  369. this.$refs.floorControl.maxFloor = this.building.curMaxFloor
  370. this.$refs.floorControl.curFloor = 1
  371. this.$refs.floorControl.floorHeight = 10
  372. this.$refs.floorControl.allFloors = true
  373. return
  374. }
  375. if (!!pickObj.node && pickObj.node instanceof ModelNode) {
  376. console.log('node code:' + pickObj.node.name)
  377. console.log('model code:' + pickObj.primitive.code)
  378. this.runModelActionScript(pickObj.primitive.code, pickObj.node.name, 3)
  379. let obj = {
  380. type: 'modelpart',
  381. // data: pickObj.id && pickObj.id.properties
  382. // ? pickObj.id.properties._details._value
  383. // : "",
  384. position: [longitude, latitude, height],
  385. }
  386. this.showModelToolTip(pickObj.primitive.code, pickObj.node.name, pickObj, obj)
  387. }
  388. }
  389. }, ScreenSpaceEventType.LEFT_CLICK)
  390. },
  391. /**
  392. * 注册鼠标右击事件
  393. */
  394. registerRightClickEvent() {
  395. const viewer = getViewer()
  396. const scene = viewer.scene
  397. const handler = new ScreenSpaceEventHandler(scene.canvas)
  398. viewer.screenSpaceEventHandler.removeInputAction(ScreenSpaceEventType.RIGHT_CLICK)
  399. //鼠标右键点击人员,列出重叠人员,只有一个时不列出
  400. handler.setInputAction(movement => {
  401. //输入一些位置信息,调试用
  402. // 从笛卡尔坐标获取经纬度
  403. let position = viewer.scene.pickPosition(movement.position)
  404. console.log(position)
  405. let cartographicNew = Cartographic.fromCartesian(position)
  406. let longitude = cMath.toDegrees(cartographicNew.longitude)
  407. let latitude = cMath.toDegrees(cartographicNew.latitude)
  408. let height = cartographicNew.height
  409. console.log(longitude, latitude, height)
  410. // 获取视角
  411. let po = viewer.camera.positionWC
  412. let heading = viewer.camera.heading
  413. let roll = viewer.camera.roll
  414. let pitch = viewer.camera.pitch
  415. let wcData = JSON.stringify({
  416. destination: po,
  417. orientation: { pitch: pitch, heading: heading, roll: roll },
  418. })
  419. console.log(wcData)
  420. //this.handleCloseOverlapDialog();
  421. //this.handleCloseBuildingPersonDialog();
  422. var pickObj = scene.pick(movement.position)
  423. if (cDefined(pickObj)) {
  424. if (pickObj.id && pickObj.id instanceof Entity) {
  425. // console.log("鼠标位置信息", pickObj)
  426. const type = pickObj.id.properties ? pickObj.id.properties._type._value : ''
  427. if (type === 'person') {
  428. this.overlapWindow.overlapPersons = [] //先清空
  429. console.log(SceneTransforms.wgs84ToWindowCoordinates(scene, pickObj.primitive._position))
  430. const multiObjs = scene.drillPick(movement.position)
  431. multiObjs.forEach((v, i, a) => {
  432. if (v.id && v.id instanceof Entity) {
  433. const vtype = v.id.properties ? v.id.properties._type._value : ''
  434. if (vtype === 'person') {
  435. //console.log(v.id);
  436. const alarm = this.getPersonAlarmStatus(v.id.id)
  437. this.overlapWindow.overlapPersons.push({
  438. id: v.id.id,
  439. name: v.id.name,
  440. alarm,
  441. })
  442. }
  443. }
  444. })
  445. console.log(this.overlapWindow.overlapPersons)
  446. if (this.overlapWindow.overlapPersons.length > 1) {
  447. //说明有人员重叠,需要打开提示窗口
  448. this.overlapWindow.show = true
  449. this.overlapWindow.position.x = movement.position.x + 'px'
  450. this.overlapWindow.position.y = movement.position.y + 'px'
  451. }
  452. }
  453. if (type === 'camera') {
  454. const multiObjs = scene.drillPick(movement.position)
  455. this.overlapCamera.overlapCameras = [] //先清空
  456. multiObjs.forEach((v, i, a) => {
  457. if (v.id && v.id instanceof Entity) {
  458. const vtype = v.id.properties ? v.id.properties._type._value : ''
  459. if (vtype === 'camera') {
  460. let { id, name } = v.id.properties.details._value
  461. this.overlapCamera.overlapCameras.push({ id, name })
  462. }
  463. }
  464. })
  465. console.log(this.overlapCamera.overlapCameras)
  466. if (this.overlapCamera.overlapCameras.length > 1) {
  467. //说明有人员重叠,需要打开提示窗口
  468. this.overlapCamera.show = true
  469. this.overlapCamera.position.x = movement.position.x + 'px'
  470. this.overlapCamera.position.y = movement.position.y + 'px'
  471. }
  472. }
  473. if (type === 'layer_fire') {
  474. //右键重叠火灾图标列表选择
  475. this.overlapFire.overlapFires = [] //先清空
  476. console.log(SceneTransforms.wgs84ToWindowCoordinates(scene, pickObj.primitive._position))
  477. const multiObjs = scene.drillPick(movement.position)
  478. console.log("鼠标位置Fire Entity信息", multiObjs)
  479. multiObjs.forEach((v, i, a) => {
  480. if (v.id && v.id instanceof Entity) {
  481. const vtype = v.id.properties ? v.id.properties._type._value : ''
  482. if (vtype === 'layer_fire') {
  483. //console.log(v.id);
  484. const fire = v.id.properties.details._value
  485. this.overlapFire.overlapFires.push({
  486. id: v.id.id,
  487. name: v.id.properties.details._value.name,
  488. fire,
  489. })
  490. }
  491. }
  492. })
  493. console.log(this.overlapFire.overlapFires)
  494. // if (this.overlapFire.overlapFires.length == 1) {
  495. // console.log(123);
  496. // const fireInfo = this.overlapFire.overlapFires[0].fire
  497. // const gpsAlarmPoint = this.transPosition([{ x: fireInfo.location.x, y: fireInfo.location.y, z: fireInfo.height }])
  498. // console.log('坐标点转化', gpsAlarmPoint);
  499. // fireInfo.alarmType = -1
  500. // // if (this.mapDialogConfig.fire.some(item => item.dialogMsg?.data?.id == data.id)) {
  501. // // this.mapDialogConfig.fire = this.mapDialogConfig.fire.filter(
  502. // // item => item.dialogMsg?.data?.id != data.id
  503. // // )
  504. // // }
  505. // this.mapDialogConfig.fire = []
  506. // console.log("无报警", this.mapDialogConfig.fire);
  507. // this.mapDialogConfig.fire.push({
  508. // show: false,
  509. // dialogMsg: { data: fireInfo, position: [gpsAlarmPoint[0][0], gpsAlarmPoint[0][1], gpsAlarmPoint[0][2]] },
  510. // })
  511. // for (let d of this.mapDialogConfig.fire) {
  512. // ; (() => {
  513. // setTimeout(() => {
  514. // d.show = true
  515. // if (d.dialogMsg.data.cameras?.length) {
  516. // this.$store.dispatch('dialog/openVideoDialog', d.dialogMsg.data.cameras[0].cameraId)
  517. // }
  518. // this.$store.dispatch('home/setMapPopupConfig', {
  519. // isShow: true,
  520. // type: 'point',
  521. // position: [gpsAlarmPoint[0][0], gpsAlarmPoint[0][1], gpsAlarmPoint[0][2]],
  522. // dialogid: 'fire_' + d.dialogMsg?.data?.id,
  523. // p1: 150,
  524. // p2: 236,
  525. // })
  526. // }, 0)
  527. // })()
  528. // }
  529. // }
  530. if (this.overlapFire.overlapFires.length > 1) {
  531. //说明有重叠,需要打开提示窗口
  532. this.overlapFire.show = true
  533. this.overlapFire.position.x = movement.position.x + 'px'
  534. this.overlapFire.position.y = movement.position.y + 'px'
  535. }
  536. }
  537. if (type === 'layer_station') {
  538. const data = pickObj.id.properties ? pickObj.id.properties.details._value : ''
  539. console.log(data)
  540. this.openStationDialog(data)
  541. }
  542. }
  543. }
  544. }, ScreenSpaceEventType.RIGHT_CLICK)
  545. },
  546. /**
  547. * 注册鼠标悬浮事件
  548. */
  549. registerMouseMoveEvent() { },
  550. //从重叠摄像头中选出一个
  551. handleSelectOverlapCamera(data) {
  552. this.$store.dispatch('dialog/openVideoDialog', data.id)
  553. },
  554. //从重叠火灾报警器中选出一个
  555. handleSelectOverlapFire(data) {
  556. // console.log("66666666666666666666666666", data);
  557. const gpsAlarmPoint = this.transPosition([{ x: data.fire.location.x, y: data.fire.location.y, z: data.fire.height }])
  558. this.mapDialogConfig.fire = []
  559. data.alarmType = -1
  560. this.mapDialogConfig.fire.push({
  561. show: false,
  562. dialogMsg: { data, position: [gpsAlarmPoint[0][0], gpsAlarmPoint[0][1], gpsAlarmPoint[0][2]] },
  563. })
  564. for (let d of this.mapDialogConfig.fire) {
  565. ; (() => {
  566. setTimeout(() => {
  567. d.show = true
  568. if (data.fire.cameras?.length) {
  569. this.$store.dispatch('dialog/openVideoDialog', data.fire.cameras[0].cameraId)//绑定摄像头弹窗
  570. }
  571. this.$store.dispatch('home/setMapPopupConfig', {
  572. isShow: true,
  573. type: 'point',
  574. position: [gpsAlarmPoint[0][0], gpsAlarmPoint[0][1], gpsAlarmPoint[0][2]],
  575. dialogid: 'fire_' + data.fire.id,
  576. p1: 150,
  577. p2: 236,
  578. })
  579. }, 0)
  580. })()
  581. }
  582. },
  583. transPosition(pointList = []) {
  584. const { longitude, latitude } = this.buildInfo.gpsCoordinate0
  585. return pointList.reduce((pre, cur) => {
  586. const { x, y } = _locate(cur.x, cur.y, { x: longitude, y: latitude })
  587. pre.push([x, y, +cur.z])
  588. return pre
  589. }, [])
  590. },
  591. //工作票的附加的区域绘制
  592. async getWFConfig(obj) {
  593. try {
  594. let { type, data, position } = obj
  595. let res = await getRTData({ tags: ['udp.wf.cnfg.lable'] })
  596. let cnfg = JSON.parse(res.data[0].value)
  597. let curCnfg = cnfg.firstOrDefault(c => {
  598. if (c.process_id == data.process_id) {
  599. return c
  600. }
  601. })
  602. //工作票
  603. let exist = this.tooltipDialogArr.firstOrDefault(t => {
  604. if (t.dialogId == data.id) {
  605. return t
  606. }
  607. })
  608. if (!!exist) return
  609. data.name = data.process_name
  610. this.tooltipDialogArr.push({
  611. show: true,
  612. dialogId: data.id,
  613. dialogMsg: { data, position, dataConfig: curCnfg },
  614. })
  615. for (const data of this.tooltipDialogArr) {
  616. ; (() => {
  617. data.show = true
  618. this.$store.dispatch('home/setMapPopupConfig', {
  619. isShow: true,
  620. type: 'point',
  621. position: data.dialogMsg.position,
  622. dialogid: 'tooltip_' + data.dialogMsg.data.id,
  623. p1: 0,
  624. p2: 50,
  625. })
  626. })()
  627. }
  628. this.$store.dispatch('dialog/openLayerDetailDialog', {
  629. id: data.task_id,
  630. type: 'tszy',
  631. detail: data,
  632. })
  633. //画出作业范围
  634. let range = JSON.parse(data['地图位置'])
  635. let points = new Array()
  636. range.points.forEach(e => {
  637. points.push(e.x)
  638. points.push(e.y)
  639. points.push(e.z)
  640. })
  641. let dataSource = addNewDatasource('wf_temp')
  642. dataSource.entities.removeAll()
  643. dataSource.entities.add(
  644. new Entity({
  645. show: true,
  646. polygon: {
  647. hierarchy: Cartesian3.fromDegreesArrayHeights(points),
  648. perPositionHeight: true,
  649. outline: true,
  650. outlineColor: Color.fromCssColorString('#ff0000').withAlpha(0.35),
  651. outlineWidth: 1,
  652. extrudedHeight: -0.01,
  653. material: Color.fromCssColorString('#ff0000').withAlpha(0.35),
  654. },
  655. })
  656. )
  657. } catch (err) {
  658. console.log(err)
  659. }
  660. },
  661. //重大危险源
  662. getWXYDetail(id) {
  663. return new Promise(async resolve => {
  664. let p = { id }
  665. let res = await getWXYDetail(p)
  666. let data = res.data
  667. resolve(data)
  668. })
  669. },
  670. //获取设备数据
  671. async getEquipmentData(id) {
  672. if (!id) return []
  673. try {
  674. let p = { id }
  675. let res = await getEquipmentDataList(p)
  676. let data = res.data.content
  677. return data
  678. } catch (err) {
  679. console.log(err)
  680. return [
  681. // { isTag: false, name: "厂家", unit: "", value: "北京" },
  682. // { isTag: true, name: "光强", unit: "", value: "GQ" },
  683. ]
  684. }
  685. },
  686. openMapPopup(obj) {
  687. console.log(obj)
  688. if (obj && obj.type == '') return
  689. let viewer = getViewer()
  690. let entityItem = new Entity({
  691. position: Cartesian3.fromDegrees(obj.position[0], obj.position[1], obj.position[2]),
  692. point: {},
  693. })
  694. let p = new Popup()
  695. p.showTrackWithEntity(entityItem, viewer, obj.dialogid, obj.p1, obj.p2)
  696. },
  697. handleAlwaysShow(layerData) {
  698. const layerId = 'layer_' + layerData.layerId
  699. const show = layerData.show
  700. if (!!this.rtTag[layerId]) {
  701. console.log(layerData)
  702. const viewer = getViewer()
  703. const dataSource = viewer.dataSources.getByName(layerId)
  704. // console.log(dataSource)
  705. if (dataSource.length) {
  706. let _this = this
  707. const entities = dataSource[0].entities.values
  708. if (show) {
  709. entities.forEach(item => {
  710. let cartographicNew = Cartographic.fromCartesian(item.position._value)
  711. let longitude = cMath.toDegrees(cartographicNew.longitude)
  712. let latitude = cMath.toDegrees(cartographicNew.latitude)
  713. let height = cartographicNew.height
  714. let obj = {
  715. type: '',
  716. data: item.properties.details._value,
  717. position: [longitude, latitude, height],
  718. }
  719. //console.log(obj);
  720. obj.data.tip = []
  721. obj.data.dataList.forEach(a => {
  722. obj.data.tip.push(a.name)
  723. obj.data[a.name] = { tag: a.tag, value: a.value }
  724. })
  725. _this.alwaysShowDialogArr.push({
  726. show: true,
  727. dialogId: obj.data.id,
  728. dialogMsg: {
  729. data: obj.data,
  730. position: obj.position,
  731. dataList: obj.data.dataList,
  732. },
  733. })
  734. })
  735. for (const data of _this.alwaysShowDialogArr) {
  736. ; (() => {
  737. data.show = true
  738. _this.openMapPopup({
  739. type: 'point',
  740. position: data.dialogMsg.position,
  741. dialogid: 'tooltip_' + data.dialogMsg.data.id,
  742. p1: 0,
  743. p2: 50,
  744. })
  745. })()
  746. }
  747. } else {
  748. // _this.alwaysShowDialogArr=[]
  749. entities.forEach(item => {
  750. let data = item.properties.details._value
  751. remove(_this.alwaysShowDialogArr, function (n) {
  752. return n.dialogId == data.id
  753. })
  754. })
  755. let __VALUE__ = JSON.parse(JSON.stringify(_this.alwaysShowDialogArr))
  756. _this.alwaysShowDialogArr = __VALUE__
  757. }
  758. }
  759. }
  760. },
  761. //运行模型事件脚本
  762. runModelActionScript(modelCode, nodeCode, eventType) {
  763. if (!!this.modelList[modelCode]) {
  764. const node = find(this.modelList[modelCode].partList, function (o) {
  765. return o.code === nodeCode
  766. })
  767. if (!!node) {
  768. const action = find(node.extraAction, function (o) {
  769. return o.eventType === eventType
  770. })
  771. if (!!action && !!action.script) {
  772. eval(action.script)
  773. }
  774. }
  775. }
  776. },
  777. //打开模型提示框
  778. async showModelToolTip(modelCode, nodeCode, pickObj, obj) {
  779. if (!!this.modelList[modelCode]) {
  780. const node = find(this.modelList[modelCode].partList, function (o) {
  781. return o.code === nodeCode
  782. })
  783. // 找到并且启用
  784. if (!!node && node.enableGeneralWindow) {
  785. console.log(node)
  786. let equipData = []
  787. if (node.equipmentId != '0') {
  788. equipData = await this.getEquipmentData(node.equipmentId)
  789. }
  790. const allDataList = [...equipData, ...node.extraWindowData].map(item => {
  791. if (item.isTag && !item.tag) {
  792. item.tag = item.value
  793. item.Tag = item.value
  794. item.value = 'loading'
  795. }
  796. return item
  797. })
  798. console.log(allDataList)
  799. //具备打开的前提条件
  800. this.tooltipDialogArr.push({
  801. show: true,
  802. dialogId: modelCode + '_' + nodeCode,
  803. dialogMsg: {
  804. data: { name: node.name, id: node.id },
  805. position: obj.position,
  806. dataList: allDataList,
  807. ops: node.extraButton,
  808. },
  809. })
  810. //console.log(this.tooltipDialogArr)
  811. for (const data of this.tooltipDialogArr) {
  812. ; (() => {
  813. data.show = true
  814. this.$store.dispatch('home/setMapPopupConfig', {
  815. isShow: true,
  816. type: 'point',
  817. position: data.dialogMsg.position,
  818. dialogid: 'tooltip_' + node.id,
  819. p1: 0,
  820. p2: 108,
  821. })
  822. })()
  823. }
  824. }
  825. }
  826. },
  827. //打开管网实体提示框
  828. showEntityToolTip(pickObj, obj, type) {
  829. if (!pickObj.id.properties.tooltipEnable || !pickObj.id.properties.tooltipEnable._value) return
  830. const dataListOrigin = pickObj.id.properties.tooltipData._value || []
  831. const dataList = dataListOrigin.map(item => {
  832. if (item.isTag && !item.tag) {
  833. item.tag = item.value
  834. item.value = 'loading'
  835. }
  836. return item
  837. })
  838. //console.log(dataList);
  839. const tooltipButtons = pickObj.id.properties.tooltipButton._value
  840. this.tooltipDialogArr.push({
  841. show: true,
  842. dialogId: pickObj.id.id,
  843. dialogMsg: {
  844. data: { name: type + ':' + pickObj.id.name, id: pickObj.id.id },
  845. position: obj.position,
  846. dataList,
  847. ops: tooltipButtons,
  848. },
  849. })
  850. //console.log(this.tooltipDialogArr)
  851. for (const data of this.tooltipDialogArr) {
  852. ; (() => {
  853. data.show = true
  854. this.$store.dispatch('home/setMapPopupConfig', {
  855. isShow: true,
  856. type: 'point',
  857. position: data.dialogMsg.position,
  858. dialogid: 'tooltip_' + data.dialogMsg.data.id,
  859. p1: 0,
  860. p2: 108,
  861. })
  862. })()
  863. }
  864. },
  865. //运行实体脚本
  866. runEntityActionScript(pickObj, eventType) {
  867. const extraActions = pickObj.id.properties.action._value
  868. //console.log(extraActions);
  869. const action = find(extraActions, function (o) {
  870. return o.eventType === eventType
  871. })
  872. if (!!action && !!action.script) {
  873. eval(action.script)
  874. }
  875. },
  876. openLayer,
  877. },
  878. }