123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894 |
- import { getViewer } from '@/store/map/mapService'
- import { _locate } from '@/utils'
- import { addNewDatasource, setModelShow, openLayer } from '@/utils/mapUtil'
- import { getRTData } from '@/API/rtdata'
- import { getEquipmentDataList } from '@/API/equipment'
- import { getWXYDetail } from '@/API/custom'
- import {
- Entity,
- Cesium3DTileFeature,
- Cartesian3,
- Color,
- ScreenSpaceEventHandler,
- ScreenSpaceEventType,
- Cartographic,
- Math as cMath,
- defined as cDefined,
- SceneTransforms,
- ModelNode,
- } from 'cesium'
- import Popup from '@/utils/popup.js'
- import { mapGetters } from 'vuex'
- import { find, remove } from 'lodash-es'
- export default {
- name: 'mapEvent',
- data() {
- return {
- tooltipDialogArr: [],
- alwaysShowDialogArr: [],
- overlapCamera: {
- overlapCameras: [], //重叠摄像头的显示
- show: false,
- position: {
- x: '0px',
- y: '0px',
- },
- },
- overlapFire: {
- overlapFires: [], //重叠火灾报警器的显示
- show: false,
- position: {
- x: '0px',
- y: '0px',
- },
- },
- equipmentData: [], //点击模型时的设备数据,每次点击时,如果equipmentId>0时使用
- }
- },
- computed: {
- ...mapGetters(['mapPopupConfig', 'modelList', 'rtTag', 'buildInfo']),
- },
- watch: {
- mapPopupConfig(newVal) {
- if (newVal.isShow) {
- this.openMapPopup({
- type: newVal.type,
- position: newVal.position,
- dialogid: newVal.dialogid,
- p1: newVal.p1,
- p2: newVal.p2,
- })
- }
- },
- },
- mounted() {
- setTimeout(() => {
- this.registerLeftClickEvent()
- this.registerRightClickEvent()
- }, 5000)
- },
- methods: {
- /**
- * 注册鼠标左击事件
- */
- registerLeftClickEvent() {
- const viewer = getViewer()
- var scene = viewer.scene
- var handler = new ScreenSpaceEventHandler(scene.canvas)
- viewer.screenSpaceEventHandler.removeInputAction(ScreenSpaceEventType.LEFT_CLICK)
- handler.setInputAction(movement => {
- console.log('来自mapEvent的mixin对象')
- //原person.js
- this.handleCloseOverlapDialog()
- this.handleCloseBuildingPersonDialog()
- this.handleCloseOverlapDialog()
- //复位一些内容
- this.$store.dispatch('dialog/closeLayerDetailDialog')
- this.tooltipDialogArr = []
- var pickObj = scene.pick(movement.position)
- let position1 = viewer.scene.pickPosition(movement.position)
- let cartographicNew = Cartographic.fromCartesian(position1)
- let longitude = cMath.toDegrees(cartographicNew.longitude)
- let latitude = cMath.toDegrees(cartographicNew.latitude)
- let height = cartographicNew.height
- if (cDefined(pickObj)) {
- //点击实体的处理
- if (pickObj && pickObj.id && pickObj.id instanceof Entity) {
- console.log(pickObj)
- const type = pickObj.id.properties
- ? pickObj.id.properties._type
- ? pickObj.id.properties._type._value
- : ''
- : ''
- console.log(type, pickObj.id)
- const data = pickObj.id.properties
- ? pickObj.id.properties._details
- ? pickObj.id.properties._details._value
- : ''
- : ''
- let obj = {
- type: pickObj.id && pickObj.id.properties ? pickObj.id.properties._type._value : '',
- // data: pickObj.id && pickObj.id.properties
- // ? pickObj.id.properties._details._value
- // : "",
- position: [longitude, latitude, height],
- }
- //点击了人,打开人员信息卡片
- if (type === 'person') {
- this.openPersonDialog(pickObj.id.properties._details._value.Id)
- } else if (type === 'layer_station') {
- //打开站点模型
- console.log(data)
- this.$store.dispatch('model/setBuildInfoByBuildId', data.buildId)
- // this.$store.dispatch('globalConfig/setMapMode', { value: '3d' })
- }
- //点击了建筑名称,打开建筑内人员情况
- else if (type === 'buildingPerson') {
- this.openBuildingPersonDialog(pickObj.id.properties._details._value, movement.position)
- }
- //点击了围栏,打开围栏详情
- else if (type === 'rail') {
- // console.log(pickObj)
- // console.log(this.alarmLiveData);
- const id = data.id
- const name = data.name
- const tableData = this.alarmLiveData.filter(item => {
- return item.Category == '100001' && item.ObjectID == id
- })
- this.$store.dispatch('dialog/openLayerDetailDialog', {
- id,
- type: 'rail',
- detail: { id, name, tableData },
- })
- } else if (type === 'risk_rail') {
- console.log(pickObj)
- const id = data.id
- const name = data.name
- const tableData = this.alarmLiveData.filter(item => {
- return item.Category == '100001' && item.ObjectID == id
- })
- this.$store.dispatch('dialog/openLayerDetailDialog', {
- id,
- type: 'riskRail',
- detail: { id, name, tableData },
- })
- }
- //点击摄像头,打开追视窗口
- else if (type === 'camera') {
- this.$store.dispatch('dialog/openVideoDialog', data.id)
- } else if (type === 'wf') {
- this.getWFConfig(obj)
- } else if (type === 'zdwxy') {
- this.getWXYDetail(data.id).then(res => {
- this.$store.dispatch('dialog/openLayerDetailDialog', {
- id: data.id,
- type: 'zdwxy',
- detail: { ...res },
- })
- })
- } else if (type === 'fxqy') {
- this.$store.dispatch('dialog/openLayerDetailDialog', {
- id: data.id,
- type: 'fxqy',
- detail: { ...data },
- })
- } else if (type === 'fbky') {
- console.log("数据内容fbky:----------------", data);
- // this.$store.dispatch('dialog/openLayerDetailDialog', {
- // id: data.id,
- // type: 'fbky',
- // detail: { ...data },
- // })
- } else if (type === '集气站' || type === '汇管' || type === '井管' || type === '站间管' || type === '井') {
- this.$nextTick(() => {
- this.showEntityToolTip(pickObj, obj, type)
- this.runEntityActionScript(pickObj, 3)
- })
- } else if (type === 'trackPoint') {
- //轨迹点
- const trackPointDetails = pickObj.id.properties._details._value
- console.log(trackPointDetails)
- } else if (type === 'building') {
- this.showModelToolTip(pickObj.id.code, pickObj.id.name, pickObj, obj)
- } else if (type === 'layer_perimeter') {
- const data = pickObj.id.properties ? pickObj.id.properties.segment._value : ''
- if (this.mapDialogConfig.perimeter.some(item => item.dialogMsg?.data?.id == data.id)) {
- this.mapDialogConfig.perimeter = this.mapDialogConfig.perimeter.filter(
- item => item.dialogMsg?.data?.id != data.id
- )
- }
- this.mapDialogConfig.perimeter.push({
- show: false,
- dialogMsg: { data, position: [longitude, latitude, height] },
- })
- console.log("周界信息", this.mapDialogConfig.perimeter)
- for (let d of this.mapDialogConfig.perimeter) {
- ; (() => {
- setTimeout(() => {
- d.show = true
- if (d.dialogMsg.data.cameras?.length) {
- this.$store.dispatch('dialog/openVideoDialog', d.dialogMsg.data.cameras[0].cameraId)
- }
- this.$store.dispatch('home/setMapPopupConfig', {
- isShow: true,
- type: 'point',
- position: d.dialogMsg?.position,
- dialogid: 'perimeter_' + d.dialogMsg?.data?.id,
- p1: 132,
- p2: 236,
- })
- }, 0)
- })()
- }
- } else if (type === 'layer_fire') {
- // if (this.mapDialogConfig.fire.some(item => item.dialogMsg?.data?.id == data.id)) {
- // this.mapDialogConfig.fire = this.mapDialogConfig.fire.filter(
- // item => item.dialogMsg?.data?.id != data.id
- // )
- // }
- const fireInfo = pickObj.id.properties._details._value
- const gpsAlarmPoint = this.transPosition([{ x: fireInfo.location.x, y: fireInfo.location.y, z: fireInfo.height }])
- console.log('坐标点转化', gpsAlarmPoint);
- fireInfo.alarmType = -1
- this.mapDialogConfig.fire = []
- console.log("无报警", this.mapDialogConfig.fire);
- this.mapDialogConfig.fire.push({
- show: false,
- dialogMsg: { data: fireInfo, position: [gpsAlarmPoint[0][0], gpsAlarmPoint[0][1], gpsAlarmPoint[0][2]] },
- })
- for (let d of this.mapDialogConfig.fire) {
- ; (() => {
- setTimeout(() => {
- d.show = true
- if (d.dialogMsg.data.cameras?.length) {
- this.$store.dispatch('dialog/openVideoDialog', d.dialogMsg.data.cameras[0].cameraId)
- }
- this.$store.dispatch('home/setMapPopupConfig', {
- isShow: true,
- type: 'point',
- position: [gpsAlarmPoint[0][0], gpsAlarmPoint[0][1], gpsAlarmPoint[0][2]],
- dialogid: 'fire_' + d.dialogMsg?.data?.id,
- p1: 140,
- p2: 236,
- })
- }, 0)
- })()
- }
- } else if (type === 'layer_jgyt_Point') {
- if (this.mapDialogConfig.jgyt.some(item => item.dialogMsg?.data?.id == data.id)) {
- this.mapDialogConfig.jgyt = this.mapDialogConfig.jgyt.filter(
- item => item.dialogMsg?.data?.id != data.id
- )
- }
- this.mapDialogConfig.jgyt.push({
- show: false,
- dialogMsg: { data },
- })
- for (let d of this.mapDialogConfig.jgyt) {
- ; (() => {
- setTimeout(() => {
- d.show = true
- this.$store.dispatch('dialog/openVideoDialog', [d.dialogMsg?.data?.cameraId])
- this.$store.dispatch('home/setMapPopupConfig', {
- isShow: true,
- type: 'point',
- position: [
- +d.dialogMsg?.data?.longitude,
- +d.dialogMsg?.data?.latitude,
- +d.dialogMsg?.data?.height,
- ],
- dialogid: 'jgyt_' + d.dialogMsg?.data?.id,
- p1: 200,
- p2: 210,
- })
- }, 0)
- })()
- }
- // this.$store.dispatch('dialog/openVideoDialog', jgytData.cameraID)
- } else if (!!type) {
- console.log("数据内容:----------------", data);
- this.$store.dispatch('dialog/openLayerDetailDialog', {
- id: data.id,
- type: 'normal',
- name: data.name,
- detail: {
- id: data.id,
- name: data.name,
- tableData: data.dataList,
- },
- })
- }
- }
- //点击3dtiles建筑的处理
- var feature = pickObj
- if (feature instanceof Cesium3DTileFeature) {
- // console.log(feature.getProperty("name"))
- // console.log(feature.getProperty("id"))
- console.log(feature)
- console.log(
- `点击了【${feature.tileset.name}】的【${feature.getProperty('name')}】【${feature.getProperty('id')}】`
- )
- this.runModelActionScript(feature.tileset.code, feature.getProperty('id'), 3)
- let obj = {
- type: 'modelpart',
- // data: pickObj.id && pickObj.id.properties
- // ? pickObj.id.properties._details._value
- // : "",
- position: [longitude, latitude, height],
- }
- console.log('地下模式', this.underGround)
- if (!this.underGround) {
- const modelRootClickRet = this.setModelRoofVisible(feature.getProperty('name'))
- console.log(this.underground)
- if (!modelRootClickRet.hasFeature && !modelRootClickRet.insideModel) {
- this.showModelToolTip(feature.tileset.code, feature.getProperty('id'), pickObj, obj)
- setModelShow({ model: 'JBZHZ' }, true)
- } else if (!modelRootClickRet.hasFeature && modelRootClickRet.insideModel) {
- this.showModelToolTip(feature.tileset.code, feature.getProperty('id'), pickObj, obj)
- }
- } else {
- this.showModelToolTip(feature.tileset.code, feature.getProperty('id'), pickObj, obj)
- }
- //feature.show = false;
- }
- if (feature instanceof Cesium3DTileFeature && feature.getProperty('name') !== '000000') {
- // console.log(feature);
- // console.info("id: " + feature.getProperty("id"));
- // console.info("name: " + feature.getProperty("name"));
- // console.info("buildingId: " + feature.getProperty("buildingId"));
- // console.info("underFloor: " + feature.getProperty("underFloor"));
- // console.info("aboveFloor: " + feature.getProperty("aboveFloor"));
- let bid = feature.getProperty('buildingId')
- if (!!bid) {
- if (this.building.curBuildingId > 0) {
- this.setElementShow(this.building.curBuildingId, true)
- for (let i = 1; i <= this.building.curMaxFloor; i++) {
- this.setElementShow(this.building.curBuildingId + 'F' + i, false)
- }
- this.building.curBuildingId = 0
- this.building.curMaxFloor = 1
- }
- this.setElementShow(feature.getProperty('name'), false)
- this.building.curBuildingId = bid
- this.building.curMaxFloor = feature.getProperty('aboveFloor')
- for (let i = 1; i <= this.building.curMaxFloor; i++) {
- //console.log(this.building.curBuildingId + "F" + i);
- this.setElementShow(this.building.curBuildingId + 'F' + i, true)
- }
- this.floorHeightChanged(0)
- } else {
- if (this.building.curBuildingId > 0) {
- this.setElementShow(this.building.curBuildingId, true)
- for (let i = 1; i <= this.building.curMaxFloor; i++) {
- this.setElementShow(this.building.curBuildingId + 'F' + i, false)
- }
- this.building.curBuildingId = 0
- this.building.curMaxFloor = 1
- }
- }
- this.$refs.floorControl.maxFloor = this.building.curMaxFloor
- this.$refs.floorControl.curFloor = 1
- this.$refs.floorControl.floorHeight = 10
- this.$refs.floorControl.allFloors = true
- return
- }
- if (!!pickObj.node && pickObj.node instanceof ModelNode) {
- console.log('node code:' + pickObj.node.name)
- console.log('model code:' + pickObj.primitive.code)
- this.runModelActionScript(pickObj.primitive.code, pickObj.node.name, 3)
- let obj = {
- type: 'modelpart',
- // data: pickObj.id && pickObj.id.properties
- // ? pickObj.id.properties._details._value
- // : "",
- position: [longitude, latitude, height],
- }
- this.showModelToolTip(pickObj.primitive.code, pickObj.node.name, pickObj, obj)
- }
- }
- }, ScreenSpaceEventType.LEFT_CLICK)
- },
- /**
- * 注册鼠标右击事件
- */
- registerRightClickEvent() {
- const viewer = getViewer()
- const scene = viewer.scene
- const handler = new ScreenSpaceEventHandler(scene.canvas)
- viewer.screenSpaceEventHandler.removeInputAction(ScreenSpaceEventType.RIGHT_CLICK)
- //鼠标右键点击人员,列出重叠人员,只有一个时不列出
- handler.setInputAction(movement => {
- //输入一些位置信息,调试用
- // 从笛卡尔坐标获取经纬度
- let position = viewer.scene.pickPosition(movement.position)
- console.log(position)
- let cartographicNew = Cartographic.fromCartesian(position)
- let longitude = cMath.toDegrees(cartographicNew.longitude)
- let latitude = cMath.toDegrees(cartographicNew.latitude)
- let height = cartographicNew.height
- console.log(longitude, latitude, height)
- // 获取视角
- let po = viewer.camera.positionWC
- let heading = viewer.camera.heading
- let roll = viewer.camera.roll
- let pitch = viewer.camera.pitch
- let wcData = JSON.stringify({
- destination: po,
- orientation: { pitch: pitch, heading: heading, roll: roll },
- })
- console.log(wcData)
- //this.handleCloseOverlapDialog();
- //this.handleCloseBuildingPersonDialog();
- var pickObj = scene.pick(movement.position)
- if (cDefined(pickObj)) {
- if (pickObj.id && pickObj.id instanceof Entity) {
- // console.log("鼠标位置信息", pickObj)
- const type = pickObj.id.properties ? pickObj.id.properties._type._value : ''
- if (type === 'person') {
- this.overlapWindow.overlapPersons = [] //先清空
- console.log(SceneTransforms.wgs84ToWindowCoordinates(scene, pickObj.primitive._position))
- const multiObjs = scene.drillPick(movement.position)
- multiObjs.forEach((v, i, a) => {
- if (v.id && v.id instanceof Entity) {
- const vtype = v.id.properties ? v.id.properties._type._value : ''
- if (vtype === 'person') {
- //console.log(v.id);
- const alarm = this.getPersonAlarmStatus(v.id.id)
- this.overlapWindow.overlapPersons.push({
- id: v.id.id,
- name: v.id.name,
- alarm,
- })
- }
- }
- })
- console.log(this.overlapWindow.overlapPersons)
- if (this.overlapWindow.overlapPersons.length > 1) {
- //说明有人员重叠,需要打开提示窗口
- this.overlapWindow.show = true
- this.overlapWindow.position.x = movement.position.x + 'px'
- this.overlapWindow.position.y = movement.position.y + 'px'
- }
- }
- if (type === 'camera') {
- const multiObjs = scene.drillPick(movement.position)
- this.overlapCamera.overlapCameras = [] //先清空
- multiObjs.forEach((v, i, a) => {
- if (v.id && v.id instanceof Entity) {
- const vtype = v.id.properties ? v.id.properties._type._value : ''
- if (vtype === 'camera') {
- let { id, name } = v.id.properties.details._value
- this.overlapCamera.overlapCameras.push({ id, name })
- }
- }
- })
- console.log(this.overlapCamera.overlapCameras)
- if (this.overlapCamera.overlapCameras.length > 1) {
- //说明有人员重叠,需要打开提示窗口
- this.overlapCamera.show = true
- this.overlapCamera.position.x = movement.position.x + 'px'
- this.overlapCamera.position.y = movement.position.y + 'px'
- }
- }
- if (type === 'layer_fire') {
- //右键重叠火灾图标列表选择
- this.overlapFire.overlapFires = [] //先清空
- console.log(SceneTransforms.wgs84ToWindowCoordinates(scene, pickObj.primitive._position))
- const multiObjs = scene.drillPick(movement.position)
- console.log("鼠标位置Fire Entity信息", multiObjs)
- multiObjs.forEach((v, i, a) => {
- if (v.id && v.id instanceof Entity) {
- const vtype = v.id.properties ? v.id.properties._type._value : ''
- if (vtype === 'layer_fire') {
- //console.log(v.id);
- const fire = v.id.properties.details._value
- this.overlapFire.overlapFires.push({
- id: v.id.id,
- name: v.id.properties.details._value.name,
- fire,
- })
- }
- }
- })
- console.log(this.overlapFire.overlapFires)
- // if (this.overlapFire.overlapFires.length == 1) {
- // console.log(123);
- // const fireInfo = this.overlapFire.overlapFires[0].fire
- // const gpsAlarmPoint = this.transPosition([{ x: fireInfo.location.x, y: fireInfo.location.y, z: fireInfo.height }])
- // console.log('坐标点转化', gpsAlarmPoint);
- // fireInfo.alarmType = -1
- // // if (this.mapDialogConfig.fire.some(item => item.dialogMsg?.data?.id == data.id)) {
- // // this.mapDialogConfig.fire = this.mapDialogConfig.fire.filter(
- // // item => item.dialogMsg?.data?.id != data.id
- // // )
- // // }
- // this.mapDialogConfig.fire = []
- // console.log("无报警", this.mapDialogConfig.fire);
- // this.mapDialogConfig.fire.push({
- // show: false,
- // dialogMsg: { data: fireInfo, position: [gpsAlarmPoint[0][0], gpsAlarmPoint[0][1], gpsAlarmPoint[0][2]] },
- // })
- // for (let d of this.mapDialogConfig.fire) {
- // ; (() => {
- // setTimeout(() => {
- // d.show = true
- // if (d.dialogMsg.data.cameras?.length) {
- // this.$store.dispatch('dialog/openVideoDialog', d.dialogMsg.data.cameras[0].cameraId)
- // }
- // this.$store.dispatch('home/setMapPopupConfig', {
- // isShow: true,
- // type: 'point',
- // position: [gpsAlarmPoint[0][0], gpsAlarmPoint[0][1], gpsAlarmPoint[0][2]],
- // dialogid: 'fire_' + d.dialogMsg?.data?.id,
- // p1: 150,
- // p2: 236,
- // })
- // }, 0)
- // })()
- // }
- // }
- if (this.overlapFire.overlapFires.length > 1) {
- //说明有重叠,需要打开提示窗口
- this.overlapFire.show = true
- this.overlapFire.position.x = movement.position.x + 'px'
- this.overlapFire.position.y = movement.position.y + 'px'
- }
- }
- if (type === 'layer_station') {
- const data = pickObj.id.properties ? pickObj.id.properties.details._value : ''
- console.log(data)
- this.openStationDialog(data)
- }
- }
- }
- }, ScreenSpaceEventType.RIGHT_CLICK)
- },
- /**
- * 注册鼠标悬浮事件
- */
- registerMouseMoveEvent() { },
- //从重叠摄像头中选出一个
- handleSelectOverlapCamera(data) {
- this.$store.dispatch('dialog/openVideoDialog', data.id)
- },
- //从重叠火灾报警器中选出一个
- handleSelectOverlapFire(data) {
- // console.log("66666666666666666666666666", data);
- const gpsAlarmPoint = this.transPosition([{ x: data.fire.location.x, y: data.fire.location.y, z: data.fire.height }])
- this.mapDialogConfig.fire = []
- data.alarmType = -1
- this.mapDialogConfig.fire.push({
- show: false,
- dialogMsg: { data, position: [gpsAlarmPoint[0][0], gpsAlarmPoint[0][1], gpsAlarmPoint[0][2]] },
- })
- for (let d of this.mapDialogConfig.fire) {
- ; (() => {
- setTimeout(() => {
- d.show = true
- if (data.fire.cameras?.length) {
- this.$store.dispatch('dialog/openVideoDialog', data.fire.cameras[0].cameraId)//绑定摄像头弹窗
- }
- this.$store.dispatch('home/setMapPopupConfig', {
- isShow: true,
- type: 'point',
- position: [gpsAlarmPoint[0][0], gpsAlarmPoint[0][1], gpsAlarmPoint[0][2]],
- dialogid: 'fire_' + data.fire.id,
- p1: 150,
- p2: 236,
- })
- }, 0)
- })()
- }
- },
- transPosition(pointList = []) {
- const { longitude, latitude } = this.buildInfo.gpsCoordinate0
- return pointList.reduce((pre, cur) => {
- const { x, y } = _locate(cur.x, cur.y, { x: longitude, y: latitude })
- pre.push([x, y, +cur.z])
- return pre
- }, [])
- },
- //工作票的附加的区域绘制
- async getWFConfig(obj) {
- try {
- let { type, data, position } = obj
- let res = await getRTData({ tags: ['udp.wf.cnfg.lable'] })
- let cnfg = JSON.parse(res.data[0].value)
- let curCnfg = cnfg.firstOrDefault(c => {
- if (c.process_id == data.process_id) {
- return c
- }
- })
- //工作票
- let exist = this.tooltipDialogArr.firstOrDefault(t => {
- if (t.dialogId == data.id) {
- return t
- }
- })
- if (!!exist) return
- data.name = data.process_name
- this.tooltipDialogArr.push({
- show: true,
- dialogId: data.id,
- dialogMsg: { data, position, dataConfig: curCnfg },
- })
- for (const data of this.tooltipDialogArr) {
- ; (() => {
- data.show = true
- this.$store.dispatch('home/setMapPopupConfig', {
- isShow: true,
- type: 'point',
- position: data.dialogMsg.position,
- dialogid: 'tooltip_' + data.dialogMsg.data.id,
- p1: 0,
- p2: 50,
- })
- })()
- }
- this.$store.dispatch('dialog/openLayerDetailDialog', {
- id: data.task_id,
- type: 'tszy',
- detail: data,
- })
- //画出作业范围
- let range = JSON.parse(data['地图位置'])
- let points = new Array()
- range.points.forEach(e => {
- points.push(e.x)
- points.push(e.y)
- points.push(e.z)
- })
- let dataSource = addNewDatasource('wf_temp')
- dataSource.entities.removeAll()
- dataSource.entities.add(
- new Entity({
- show: true,
- polygon: {
- hierarchy: Cartesian3.fromDegreesArrayHeights(points),
- perPositionHeight: true,
- outline: true,
- outlineColor: Color.fromCssColorString('#ff0000').withAlpha(0.35),
- outlineWidth: 1,
- extrudedHeight: -0.01,
- material: Color.fromCssColorString('#ff0000').withAlpha(0.35),
- },
- })
- )
- } catch (err) {
- console.log(err)
- }
- },
- //重大危险源
- getWXYDetail(id) {
- return new Promise(async resolve => {
- let p = { id }
- let res = await getWXYDetail(p)
- let data = res.data
- resolve(data)
- })
- },
- //获取设备数据
- async getEquipmentData(id) {
- if (!id) return []
- try {
- let p = { id }
- let res = await getEquipmentDataList(p)
- let data = res.data.content
- return data
- } catch (err) {
- console.log(err)
- return [
- // { isTag: false, name: "厂家", unit: "", value: "北京" },
- // { isTag: true, name: "光强", unit: "", value: "GQ" },
- ]
- }
- },
- openMapPopup(obj) {
- console.log(obj)
- if (obj && obj.type == '') return
- let viewer = getViewer()
- let entityItem = new Entity({
- position: Cartesian3.fromDegrees(obj.position[0], obj.position[1], obj.position[2]),
- point: {},
- })
- let p = new Popup()
- p.showTrackWithEntity(entityItem, viewer, obj.dialogid, obj.p1, obj.p2)
- },
- handleAlwaysShow(layerData) {
- const layerId = 'layer_' + layerData.layerId
- const show = layerData.show
- if (!!this.rtTag[layerId]) {
- console.log(layerData)
- const viewer = getViewer()
- const dataSource = viewer.dataSources.getByName(layerId)
- // console.log(dataSource)
- if (dataSource.length) {
- let _this = this
- const entities = dataSource[0].entities.values
- if (show) {
- entities.forEach(item => {
- let cartographicNew = Cartographic.fromCartesian(item.position._value)
- let longitude = cMath.toDegrees(cartographicNew.longitude)
- let latitude = cMath.toDegrees(cartographicNew.latitude)
- let height = cartographicNew.height
- let obj = {
- type: '',
- data: item.properties.details._value,
- position: [longitude, latitude, height],
- }
- //console.log(obj);
- obj.data.tip = []
- obj.data.dataList.forEach(a => {
- obj.data.tip.push(a.name)
- obj.data[a.name] = { tag: a.tag, value: a.value }
- })
- _this.alwaysShowDialogArr.push({
- show: true,
- dialogId: obj.data.id,
- dialogMsg: {
- data: obj.data,
- position: obj.position,
- dataList: obj.data.dataList,
- },
- })
- })
- for (const data of _this.alwaysShowDialogArr) {
- ; (() => {
- data.show = true
- _this.openMapPopup({
- type: 'point',
- position: data.dialogMsg.position,
- dialogid: 'tooltip_' + data.dialogMsg.data.id,
- p1: 0,
- p2: 50,
- })
- })()
- }
- } else {
- // _this.alwaysShowDialogArr=[]
- entities.forEach(item => {
- let data = item.properties.details._value
- remove(_this.alwaysShowDialogArr, function (n) {
- return n.dialogId == data.id
- })
- })
- let __VALUE__ = JSON.parse(JSON.stringify(_this.alwaysShowDialogArr))
- _this.alwaysShowDialogArr = __VALUE__
- }
- }
- }
- },
- //运行模型事件脚本
- runModelActionScript(modelCode, nodeCode, eventType) {
- if (!!this.modelList[modelCode]) {
- const node = find(this.modelList[modelCode].partList, function (o) {
- return o.code === nodeCode
- })
- if (!!node) {
- const action = find(node.extraAction, function (o) {
- return o.eventType === eventType
- })
- if (!!action && !!action.script) {
- eval(action.script)
- }
- }
- }
- },
- //打开模型提示框
- async showModelToolTip(modelCode, nodeCode, pickObj, obj) {
- if (!!this.modelList[modelCode]) {
- const node = find(this.modelList[modelCode].partList, function (o) {
- return o.code === nodeCode
- })
- // 找到并且启用
- if (!!node && node.enableGeneralWindow) {
- console.log(node)
- let equipData = []
- if (node.equipmentId != '0') {
- equipData = await this.getEquipmentData(node.equipmentId)
- }
- const allDataList = [...equipData, ...node.extraWindowData].map(item => {
- if (item.isTag && !item.tag) {
- item.tag = item.value
- item.Tag = item.value
- item.value = 'loading'
- }
- return item
- })
- console.log(allDataList)
- //具备打开的前提条件
- this.tooltipDialogArr.push({
- show: true,
- dialogId: modelCode + '_' + nodeCode,
- dialogMsg: {
- data: { name: node.name, id: node.id },
- position: obj.position,
- dataList: allDataList,
- ops: node.extraButton,
- },
- })
- //console.log(this.tooltipDialogArr)
- for (const data of this.tooltipDialogArr) {
- ; (() => {
- data.show = true
- this.$store.dispatch('home/setMapPopupConfig', {
- isShow: true,
- type: 'point',
- position: data.dialogMsg.position,
- dialogid: 'tooltip_' + node.id,
- p1: 0,
- p2: 108,
- })
- })()
- }
- }
- }
- },
- //打开管网实体提示框
- showEntityToolTip(pickObj, obj, type) {
- if (!pickObj.id.properties.tooltipEnable || !pickObj.id.properties.tooltipEnable._value) return
- const dataListOrigin = pickObj.id.properties.tooltipData._value || []
- const dataList = dataListOrigin.map(item => {
- if (item.isTag && !item.tag) {
- item.tag = item.value
- item.value = 'loading'
- }
- return item
- })
- //console.log(dataList);
- const tooltipButtons = pickObj.id.properties.tooltipButton._value
- this.tooltipDialogArr.push({
- show: true,
- dialogId: pickObj.id.id,
- dialogMsg: {
- data: { name: type + ':' + pickObj.id.name, id: pickObj.id.id },
- position: obj.position,
- dataList,
- ops: tooltipButtons,
- },
- })
- //console.log(this.tooltipDialogArr)
- for (const data of this.tooltipDialogArr) {
- ; (() => {
- data.show = true
- this.$store.dispatch('home/setMapPopupConfig', {
- isShow: true,
- type: 'point',
- position: data.dialogMsg.position,
- dialogid: 'tooltip_' + data.dialogMsg.data.id,
- p1: 0,
- p2: 108,
- })
- })()
- }
- },
- //运行实体脚本
- runEntityActionScript(pickObj, eventType) {
- const extraActions = pickObj.id.properties.action._value
- //console.log(extraActions);
- const action = find(extraActions, function (o) {
- return o.eventType === eventType
- })
- if (!!action && !!action.script) {
- eval(action.script)
- }
- },
- openLayer,
- },
- }
|