Browse Source

将EarthComp组件中,添加模型选项中的四种类型(区域、监控点、微波、雷达)单独抽离出来

master
Fuyuu 12 months ago
parent
commit
a4acaeed2f
  1. 285
      src/components/earthMap/Toolbar.vue
  2. 144
      src/components/earthMap/toolbar/AddModelWin.vue
  3. 521
      src/components/earthMap/toolbar/AddMonitorPointCom.vue
  4. 638
      src/components/earthMap/toolbar/AddRadarCom.vue
  5. 542
      src/components/earthMap/toolbar/AddWaveCom.vue
  6. 1
      src/utils/earthMap/earthObj.ts
  7. 7
      src/views/earthMap/edit/EarthComp.vue

285
src/components/earthMap/Toolbar.vue

@ -44,7 +44,6 @@
<p title="态势工具" class="tb-img-p alarm" @click="drawShapeMilitary">
<img :src="drawShapeMilitaryIMG" />
</p>
</div>
</Window>
<div id="measurePopModal" class="popModal">
@ -74,6 +73,10 @@
<p @click="openCreateModel('addModelWin')">添加模型</p>
<p @click="openCreateModel('roamPathList')">路径巡检</p>
<p @click="openCreateModel('keyControlAreaList')">管控区域</p>
<p @click="addArea()">添加区域</p>
<p @click="addMonitorPoint()">添加监控点</p>
<p @click="addWave()">添加微波探测</p>
<p @click="addRadar()">添加雷达</p>
</ul>
</div>
<div class="mapBox">
@ -86,6 +89,12 @@
</li>
</ul>
</div>
<!-- 添加监控点 -->
<AddMonitorPointCom v-if="addMonitorPointComShow"></AddMonitorPointCom>
<!-- 添加微波 -->
<AddWaveCom v-if="addWaveComShow" :setLabelStatus="setLabelStatus"></AddWaveCom>
<!-- 添加雷达 -->
<AddRadarCom v-if="addRadarComShow" :setLabelStatus="setLabelStatus"></AddRadarCom>
<AddModelWin v-if="addModelWinShow" :setLabelStatus="setLabelStatus"></AddModelWin>
<RoamPathList v-if="roamPathListShow"></RoamPathList>
@ -123,6 +132,9 @@
import drawShapeIMG from '@/assets/earthMap/toolbar/drawShapeIMG.png';
import drawShapeMilitaryIMG from '@/assets/earthMap/toolbar/drawShapeMilitaryIMG.png';
import AddMonitorPointCom from '@/components/earthMap/toolbar/AddMonitorPointCom.vue';
import AddWaveCom from '@/components/earthMap/toolbar/AddWaveCom.vue';
import AddRadarCom from '@/components/earthMap/toolbar/AddRadarCom.vue';
// import mitt from '/@/utils/mitt';
import $mitt from '@/utils/earthMap/mitt';
import { defHttp } from '/@/utils/http/axios';
@ -146,6 +158,9 @@
DrawShape,
DrawShapeMilitary,
KeyControlAreaList,
AddMonitorPointCom,
AddWaveCom,
AddRadarCom,
},
setup(props) {
const { proxy }: any = getCurrentInstance();
@ -181,6 +196,12 @@
const drawShapePackage: any = ref(null);
const drawShapeMilitaryShow = ref(false);
//
const addMonitorPointComShow = ref(false);
//
const addWaveComShow = ref(false);
//
const addRadarComShow = ref(false);
//
const title = computed(() => {
return '';
@ -236,7 +257,7 @@
//res.show,res
$mitt.on('drawShapeShow', function (res: any) {
drawShapeShow.value = res.show;
drawShapePackage.value = res
drawShapePackage.value = res;
});
}
//
@ -946,17 +967,19 @@
//
function drawShape() {
//使
if(drawShapeMilitaryShow.value && store.shapeUsing == false)
{drawShapeMilitaryShow.value = false}
if (drawShapeMilitaryShow.value && store.shapeUsing == false) {
drawShapeMilitaryShow.value = false;
}
//
drawShapePackage.value = null
drawShapePackage.value = null;
drawShapeShow.value = !drawShapeShow.value;
}
//-
function drawShapeMilitary() {
//使
if(drawShapeShow.value && store.shapeUsing == false)
{drawShapeShow.value = false}
if (drawShapeShow.value && store.shapeUsing == false) {
drawShapeShow.value = false;
}
drawShapeMilitaryShow.value = !drawShapeMilitaryShow.value;
}
@ -1051,6 +1074,246 @@
// )
}
//
function addMonitorPoint() {
addMonitorPointComShow.value = true;
}
//
function addWave() {
addWaveComShow.value = true;
}
//
function addRadar() {
addRadarComShow.value = true;
}
//
function addArea() {
$mitt.emit('drawShapeShow', { show: true, title: '区域创建工具', from: 'addArea' });
$mitt.on('addAreaFinished', (t: any) => {
console.log('addAreaFinished', t);
//t drawShape
t.creating = true;
// t
window.XE.MVVM.watch(t, 'creating', (n: any) => {
console.log('creating', n);
if (n == false) {
//
let positions: any = [];
if (t._polygon) {
positions = t._polygon._polyline.positions;
}
//线
else if (t._polyline) {
positions = t._polyline.positions;
} else {
positions = t.positions;
}
//
t.destroy();
/**
* 控制时序处理完数据再调用方法 addPolyline
* 否则会出现在数据滞后在图形创建时导致数据错误
*
*/
nextTick(() => {
addPolyline(positions);
});
}
});
});
}
/**
* @params 需要调用 addArea 方法进行绘图获取坐标点position
*/
function addPolyline(positions: any = null) {
//
// cancel();
//
const currentModel = new window.XE.Obj.Polyline(window.$earth);
//
const objConfig = {
positions: positions,
};
//
currentModel.xbsjFromJSON(objConfig);
console.log('currentModel', currentModel);
// ui
const earthUI = window.$uia;
// ui
earthUI.showPropertyWindow(currentModel);
nextTick(() => {
// ui
const mainUI = earthUI._vm.$refs.mainUI;
// uiRef
const windowsAttrList = Object.keys(mainUI.$refs);
//
const modelToolKey = windowsAttrList.filter((f) => f.indexOf(currentModel.guid) > -1)[0];
const modelTool = mainUI.$refs[modelToolKey][0];
//
const el = modelTool.$el;
//
el.children[2].style.padding = '0px';
el.children[2].style.transition = 'none';
//
const cancelBtn = el.children[3].children[0];
//
const okBtn = el.children[3].children[1];
//
okBtn.onclick = function () {
$mitt.emit('windowCancel');
//
const submitData: any = {};
//
const poistions = currentModel.positions;
if (poistions.length <= 0) {
createMessage.warning('路径为空,无法创建', 2);
return;
}
//
submitData.name = currentModel.name;
// 线
submitData.lineCode = currentModel.guid;
//
submitData.isLoop = Number(currentModel.loop);
//
submitData.isDepthCheck = Number(currentModel.depthTest);
//
submitData.width = currentModel.width;
//
submitData.interpolation = currentModel.arcType;
//
submitData.positions = JSON.stringify(poistions);
//
switch (currentModel.material.type) {
// 线
case 'XbsjColorMaterial':
// 线0
submitData.materialType = 0;
// 线
submitData.color = JSON.stringify(currentModel.material.XbsjColorMaterial.color);
//
submitData.intervalColor = null;
submitData.dashLength = 0;
submitData.dashStyle = 0;
break;
// 线
case 'XbsjPolylineDashMaterial':
// 线1
submitData.materialType = 1;
// 线
submitData.color = JSON.stringify(currentModel.material.XbsjPolylineDashMaterial.color);
//
submitData.intervalColor = JSON.stringify(currentModel.material.XbsjPolylineDashMaterial.gapColor);
// 线
submitData.dashLength = currentModel.material.XbsjPolylineDashMaterial.dashLength;
// 线
submitData.dashStyle = currentModel.material.XbsjPolylineDashMaterial.dashPattern;
break;
// 线
case 'XbsjPolylineArrowMaterial':
// 线2
submitData.materialType = 2;
// 线
submitData.color = JSON.stringify(currentModel.material.XbsjPolylineArrowMaterial.color);
//
submitData.intervalColor = null;
submitData.dashLength = 0;
submitData.dashStyle = 0;
break;
// 线
case 'XbsjODLineMaterial':
// 线
submitData.materialType = 3;
// 线
submitData.color = JSON.stringify(currentModel.material.XbsjODLineMaterial.color);
//
submitData.intervalColor = null;
submitData.dashLength = 0;
submitData.dashStyle = 0;
//
submitData.cycleFrame = currentModel.material.XbsjODLineMaterial.totoalFrameCount;
break;
}
//
defHttp
.post({ url: '/military/msMapLine/add', params: submitData }, { isTransformResponse: false })
.then((response) => {
//
if (response.success) {
//
const leaf = new window.XE.SceneTree.Leaf(currentModel);
//
leaf.ref = response.result;
//
window.$earth.sceneTree.root.children.push(leaf);
// dom
nextTick(() => {
$('#earthContainer>div>div>div:nth-child(5)')
.children('div')
.eq(1)
.children()
.eq(0)
.children()
.eq(0)
.children()
.each((index, element) => {
if (index <= 1) {
return;
}
const paddingLeft = $(element).children().eq(0).css('padding-left');
if (paddingLeft === '10px') {
$(element).css('display', 'none');
}
});
});
// ref node_ref ref
const node = {
ref: 'node_' + response.result,
title: currentModel.name,
expand: false,
children: [
{
expand: false,
title: '监控点位',
ref: 'monitor_' + window.guid(),
children: [],
},
{
expand: false,
title: '雷达点位',
ref: 'ldList_' + window.guid(),
children: [],
},
{
expand: false,
title: '微波点位',
ref: 'wbList_' + window.guid(),
children: [],
},
],
};
//
window.$earth.sceneTree.$refs.areas.children.push(node);
} else {
throw '新增区域数据出错';
}
})
.catch((e) => {
createMessage.error('新增区域数据出错', 2);
});
};
//
cancelBtn.onclick = function () {
$mitt.off('windowCancel');
// dom
el.remove();
//
currentModel.destroy();
};
});
return currentModel;
}
onBeforeUnmount(() => {
// vue
proxy._disposers.forEach((d) => d());
@ -1061,7 +1324,6 @@
$mitt.off('warnInfoMan');
});
return {
show,
title,
@ -1121,7 +1383,14 @@
openCreateModel,
drawShape,
drawShapeMilitary,
addMonitorPoint,
addWave,
addRadar,
addArea,
addModelWinShow,
addMonitorPointComShow,
addWaveComShow,
addRadarComShow,
roamPathListShow,
keyControlAreaListShow,
notificationModelShow,

144
src/components/earthMap/toolbar/AddModelWin.vue

@ -1,7 +1,19 @@
<template>
<div class="create-model-modal" v-if="winVisible">
<Window :title="title" @cancel="cancel" @ok="ok" :width="width" :minWidth="600" :height="height" :left="left"
:top="top" :floatright="false" :footervisible="true" v-show="!creating" :expand="expand">
<Window
:title="title"
@cancel="cancel"
@ok="ok"
:width="width"
:minWidth="600"
:height="height"
:left="left"
:top="top"
:floatright="false"
:footervisible="true"
v-show="!creating"
:expand="expand"
>
<div style="display: flex" class="custom-item" v-if="!isUpdateModel">
<label class="custom-label">模型类型:</label>
<div class="custom-item-box">
@ -12,8 +24,7 @@
<div style="display: flex" class="custom-item">
<label class="custom-label">名称:</label>
<div class="custom-item-box">
<input v-model="name" class="name-input" style="height: 90%; width: 100%"
@change="nameChange(currentModel)" />
<input v-model="name" class="name-input" style="height: 90%; width: 100%" @change="nameChange(currentModel)" />
</div>
</div>
<div style="display: flex" class="custom-item">
@ -28,8 +39,14 @@
<!-- <XbsjSlider style="margin-top: 16px" :min="0" :max="256" :step="1" showTip="always"
v-model="minimumPixelSize">
</XbsjSlider> -->
<a-slider v-model:value="minimumPixelSize" :min="0" :max="256" :step="1" :tooltipVisible="true"
v-if="currentModel && currentModel.xbsjType == 'Model'" />
<a-slider
v-model:value="minimumPixelSize"
:min="0"
:max="256"
:step="1"
:tooltipVisible="true"
v-if="currentModel && currentModel.xbsjType == 'Model'"
/>
</div>
</div>
<div style="display: flex" class="custom-item">
@ -55,19 +72,28 @@
</div>
</div>
<div style="display: flex; align-items: center; justify-content: center" class="custom-item">
<button @click="modelState('creating')"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" :disabled="creating"
style="width: 20%">
<button
@click="modelState('creating')"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']"
:disabled="creating"
style="width: 20%"
>
拾取
</button>
<button @click="currentModel.positionEditing = true"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" :disabled="creating"
style="width: 20%">
<button
@click="currentModel.positionEditing = true"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']"
:disabled="creating"
style="width: 20%"
>
移动
</button>
<button @click="modelState('rotationEditing')"
<button
@click="modelState('rotationEditing')"
:class="['xbsj-button', 'edit-model-btn', !currentModel || rotationEditing ? 'edit-model-btn-disable' : '']"
:disabled="rotationEditing" style="width: 20%">
:disabled="rotationEditing"
style="width: 20%"
>
旋转
</button>
</div>
@ -76,8 +102,7 @@
<div style="display: flex" class="custom-item">
<label class="custom-label">名称:</label>
<div class="custom-item-box">
<input v-model="name" class="name-input" style="height: 90%; width: 100%"
@change="nameChange(currentModel)" />
<input v-model="name" class="name-input" style="height: 90%; width: 100%" @change="nameChange(currentModel)" />
</div>
</div>
<div style="display: flex" class="custom-item">
@ -102,8 +127,7 @@
<label class="custom-label">上传图标:</label>
<div class="custom-item-box">
<div class="upload-box">
<upload v-model:file="uploadFile" :pre-view-url="previewImgUrl" :isUpdateModel="isUpdateModel"
ref="pinIconUpload" />
<upload v-model:file="uploadFile" :pre-view-url="previewImgUrl" :isUpdateModel="isUpdateModel" ref="pinIconUpload" />
</div>
</div>
</div>
@ -141,14 +165,20 @@
</div>
</div>
<div style="display: flex; justify-content: center" class="custom-item">
<button @click="modelState('creating')"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" :disabled="creating"
style="width: 20%; display: flex; align-items: center; justify-content: center">
<button
@click="modelState('creating')"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']"
:disabled="creating"
style="width: 20%; display: flex; align-items: center; justify-content: center"
>
拾取
</button>
<button @click="currentModel.editing = true"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" :disabled="creating"
style="width: 20%; display: flex; align-items: center; justify-content: center">
<button
@click="currentModel.editing = true"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']"
:disabled="creating"
style="width: 20%; display: flex; align-items: center; justify-content: center"
>
移动
</button>
</div>
@ -157,8 +187,7 @@
<div style="display: flex" class="custom-item">
<label class="custom-label">名称:</label>
<div class="custom-item-box">
<input v-model="name" class="name-input" style="height: 90%; width: 100%"
@change="nameChange(currentModel)" />
<input v-model="name" class="name-input" style="height: 90%; width: 100%" @change="nameChange(currentModel)" />
</div>
</div>
<div style="display: flex" class="custom-item">
@ -183,8 +212,7 @@
<label class="custom-label">上传图标:</label>
<div class="custom-item-box">
<div class="upload-box">
<upload v-model:file="uploadFile" :pre-view-url="previewImgUrl" :isUpdateModel="isUpdateModel"
ref="pinIconUpload" />
<upload v-model:file="uploadFile" :pre-view-url="previewImgUrl" :isUpdateModel="isUpdateModel" ref="pinIconUpload" />
</div>
</div>
</div>
@ -198,14 +226,20 @@
</div>
</div>
<div style="display: flex; justify-content: center" class="custom-item">
<button @click="modelState('creating')"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" :disabled="creating"
style="width: 20%; display: flex; align-items: center; justify-content: center">
<button
@click="modelState('creating')"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']"
:disabled="creating"
style="width: 20%; display: flex; align-items: center; justify-content: center"
>
拾取
</button>
<button @click="currentModel.editing = true"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']" :disabled="creating"
style="width: 20%; display: flex; align-items: center; justify-content: center">
<button
@click="currentModel.editing = true"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']"
:disabled="creating"
style="width: 20%; display: flex; align-items: center; justify-content: center"
>
移动
</button>
</div>
@ -430,7 +464,7 @@ export default defineComponent({
/**
* 防止重复打开drawShape组件所以每次变更选项时都进行关闭操作
*/
$mitt.emit('drawShapeShow', { show: false })
$mitt.emit('drawShapeShow', { show: false });
//
if (isUpdateModel.value) {
return;
@ -527,10 +561,9 @@ export default defineComponent({
onBeforeUnmount(() => {
// mitt
$mitt.emit('drawShapeShow', { show: false })
$mitt.emit('drawShapeShow', { show: false });
$mitt.off('windowCancel');
$mitt.off('addAreaFinished');
});
//
function cancel() {
@ -551,6 +584,8 @@ export default defineComponent({
//
if (currentModel.value) {
if (currentModel.value.addViewShedReturn) {
console.log('window.$earth.czm.viewer.entities', window.$earth.czm.viewer.entities);
window.$earth.czm.viewer.entities.remove(currentModel.value.addViewShedReturn);
}
currentModel.value.editing = false;
@ -702,41 +737,40 @@ export default defineComponent({
* $mitt.emit('addAreaFinished') 接受传回来的临时图形
*/
function addArea() {
$mitt.emit('drawShapeShow', { show: true, title: '创建区域工具', from: 'addArea' })
$mitt.on("addAreaFinished", (t: any) => {
console.log("addAreaFinished", t);
$mitt.emit('drawShapeShow', { show: true, title: '创建区域工具', from: 'addArea' });
$mitt.on('addAreaFinished', (t: any) => {
console.log('addAreaFinished', t);
//t drawShape
t.creating = true;
// t
window.XE.MVVM.watch(t, 'creating', (n: any) => {
console.log("creating", n);
console.log('creating', n);
if (n == false) {
//
let positions: any = []
let positions: any = [];
if (t._polygon) {
positions = t._polygon._polyline.positions
positions = t._polygon._polyline.positions;
}
//线
else if (t._polyline) {
positions = t._polyline.positions
}
else {
positions = t.positions
positions = t._polyline.positions;
} else {
positions = t.positions;
// console.error("");
}
//
t.destroy()
t.destroy();
/**
* 控制时序处理完数据再调用方法 addPolyline
* 否则会出现在数据滞后在图形创建时导致数据错误
*
*/
nextTick(() => { addPolyline(positions); })
nextTick(() => {
addPolyline(positions);
});
}
})
})
});
});
}
/**
* @params 需要调用 addArea 方法进行绘图获取坐标点position
@ -749,10 +783,10 @@ export default defineComponent({
//
const objConfig = {
positions: positions,
}
};
//
currentModel.xbsjFromJSON(objConfig);
console.log("currentModel", currentModel);
console.log('currentModel', currentModel);
// ui
const earthUI = window.$uia;
// ui

521
src/components/earthMap/toolbar/AddMonitorPointCom.vue

@ -0,0 +1,521 @@
<template>
<div class="create-model-modal" v-if="winVisible">
<Window
:title="title"
@cancel="cancel"
@ok="ok"
:width="width"
:minWidth="600"
:height="height"
:left="left"
:top="top"
:floatright="false"
:footervisible="true"
v-show="!creating"
:expand="expand"
>
<div class="object-box">
<div style="display: flex" class="custom-item">
<label class="custom-label">监控点名称:</label>
<div class="custom-item-box">
<input v-model="name" class="name-input" style="height: 90%; width: 100%" />
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">所属区域:</label>
<div class="custom-item-box">
<XbsjSelect id="area-select" title="name" :list="areaList" v-model:value="selectArea" />
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">像素大小:</label>
<div class="custom-item-box">
<a-slider v-model:value="minimumPixelSize" :min="0" :max="256" :step="1" />
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">经纬度:</label>
<div class="custom-item-box">
<input v-model="LngLatHeight[0]" type="number" class="xyz-input" />
<input v-model="LngLatHeight[1]" type="number" class="xyz-input y-margin" />
<input v-model="LngLatHeight[2]" type="number" class="xyz-input" />
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">旋转:</label>
<div class="custom-item-box">
<input v-model="rotation[0]" class="xyz-input" type="number" />
<input v-model="rotation[1]" class="xyz-input y-margin" type="number" />
<input v-model="rotation[2]" class="xyz-input" type="number" />
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">缩放:</label>
<div class="custom-item-box">
<xbsjScale v-model:scale="scale" style="height: 90%; width: 100%"></xbsjScale>
</div>
</div>
<div style="display: flex; align-items: center; justify-content: center" class="custom-item">
<button
@click="modelState('creating')"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']"
:disabled="creating"
style="width: 20%"
>
拾取
</button>
<button
@click="currentModel.positionEditing = true"
:class="['xbsj-button', 'edit-model-btn', !currentModel || positionEditing ? 'edit-model-btn-disable' : '']"
:disabled="creating"
style="width: 20%"
>
移动
</button>
<button
@click="modelState('rotationEditing')"
:class="['xbsj-button', 'edit-model-btn', !currentModel || rotationEditing ? 'edit-model-btn-disable' : '']"
:disabled="rotationEditing"
style="width: 20%"
>
旋转
</button>
</div>
</div>
<div class="Mask"></div>
</Window>
</div>
</template>
<script lang="ts">
import { onMounted, nextTick, defineComponent, ref, getCurrentInstance, computed } from 'vue';
import xbsjScale from '/@/components/earthMap/components/xbsjScale.vue';
import XbsjSelect from '/@/components/earthMap/components/XbsjSelect.vue';
import XbsjColorButton from '/@/components/earthMap/components/XbsjColorButton.vue';
import upload from '/@/components/earthMap/components/upload.vue';
import Window from '@/components/earthMap/components/Window.vue';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import $ from 'jquery';
export default defineComponent({
name: 'AddMonitorPointCom',
components: {
xbsjScale,
XbsjSelect,
upload,
XbsjColorButton,
Window,
},
props: {
title: {
type: String,
default: '添加监控点',
},
},
setup() {
const { proxy }: any = getCurrentInstance();
const { createMessage } = useMessage();
//
let widthCoefficient = ref(0.3);
let heightCoefficient = ref(0.5);
//
const width = computed(() => {
return window.outerWidth * widthCoefficient.value;
});
const height = computed(() => {
return window.outerHeight * heightCoefficient.value;
});
const top = computed(() => {
return window.outerHeight * ((1.0 - heightCoefficient.value - 0.15) / 2);
});
const left = computed(() => {
return (window.outerWidth * (1.0 - widthCoefficient.value)) / 2;
});
//
let winVisible = ref(true);
//
let currentModel: any = ref(null);
//
let isUpdateModel = ref(false);
//
let revert = ref(null);
//
let name = ref('');
//
let areaList = ref([]);
//
let selectArea: any = ref(null);
//
let minimumPixelSize = ref(80);
//
let LngLatHeight = ref([0, 0, 0]);
//
let rotation = ref([0, 0, 0]);
//
let rotationEditing = ref(false);
//
let positionEditing = ref(false);
//
let scale = ref([1, 1, 1]);
//
let creating = ref(false);
//
let expand = ref(true);
//
let submitObject: any = ref({});
//
function getAreas() {
const submitData: any = {
pageNo: 1,
pageSize: 999,
};
return defHttp
.get(
{
url: '/military/msMapLine/list',
params: submitData,
},
{ isTransformResponse: false }
)
.then((res) => {
if (res.success) {
areaList.value = res.result.records;
}
});
}
//
function cancel() {
if (isUpdateModel.value) {
//
updateClose();
} else {
//
close();
}
//v-if
proxy.$parent.addMonitorPointComShow = false;
}
//
function updateClose() {
//
if (currentModel.value) {
currentModel.value.xbsjFromJSON(revert.value);
currentModel.value.editing = false;
currentModel.value.positionEditing = false;
currentModel.value.rotationEditing = false;
}
}
//
function close() {
//
if (currentModel.value) {
if (currentModel.value.addViewShedReturn) {
window.$earth.czm.viewer.entities.remove(currentModel.value.addViewShedReturn);
}
currentModel.value.editing = false;
currentModel.value.destroy();
}
}
//
function ok() {
//
if (name.value == null || name.value.length <= 0) {
createMessage.warning('请填写监控点名称', 2);
return;
} else if (selectArea.value == null || selectArea.value.id <= 0) {
//
createMessage.warning('请选择所属区域', 2);
return;
}
//
currentModel.value.editing = false;
//
submitData();
}
//
function submitData() {
// /
let startNum = currentModel.value.url.lastIndexOf('/') + 1;
//
let modelName = '';
if (startNum > -1) {
modelName = currentModel.value.url.substring(startNum, currentModel.value.url.length);
}
submitObject.value = {
id: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
sitecode: null,
sitename: name.value, //
longitude: LngLatHeight.value[0], // x
latitude: LngLatHeight.value[1], // y
height: LngLatHeight.value[2], // z
yaw: rotation.value[0], // x
pitch: rotation.value[1], // y
roll: rotation.value[2], // z
lineId: selectArea.value.id ? selectArea.value.id : null, // id
state: 1, //
modelUrl: modelName, // url
scale: currentModel.value.scale ? currentModel.value.scale : 1, // 1
xyzScale: scale.value.toString(), // xyz
minimumPixelSize: minimumPixelSize.value, //
};
let request: any = null;
//
let url = '';
if (isUpdateModel.value) {
// urlput id
url = '/military/camera/site/edit';
submitObject.value.id = currentModel.value.customProp;
request = defHttp.put({ url: url, params: submitObject.value }, { isTransformResponse: false });
} else {
// urlpost
url = '/military/camera/site/add';
request = defHttp.post({ url: url, params: submitObject.value }, { isTransformResponse: false });
}
//
request
.then(function (response) {
//
if (response.success) {
// ref node_ref
const lineId = 'node_' + selectArea.value.id;
//
if (!isUpdateModel.value) {
//
const parent = window.$earth.sceneTree.$refs[lineId].children[0];
//
let node = new window.XE.SceneTree.Leaf(currentModel.value);
// ref
node.ref = response.result;
// idcustomProp
currentModel.value.customProp = response.result;
//
node.title = name.value;
// name,idname
node.name = selectArea.value.id;
//
window.$earth.sceneTree.root.children.push(node);
// dom
nextTick(() => {
$('#earthContainer>div>div>div:nth-child(5)')
.children('div')
.eq(1)
.children()
.eq(0)
.children()
.eq(0)
.children()
.each((index, element) => {
if (index <= 1) {
return;
}
const paddingLeft = $(element).children().eq(0).css('padding-left');
if (paddingLeft === '10px') {
$(element).css('display', 'none');
}
});
});
//
const shamNode = {
ref: 'node_' + response.result, // ref
title: name.value, //
expand: false,
children: [],
};
//
parent.children.push(shamNode);
//
createMessage.success('添加成功!', 2);
} else {
//
//
const shamNode = window.$earth.sceneTree.$refs['node_' + submitObject.value.id];
//
shamNode.title = name.value;
// name
currentModel.value.name = name.value;
moveNode('Model');
//
createMessage.success('修改成功!', 2);
}
}
})
.then(function () {
finish();
});
}
//
function finish() {
if (currentModel.value) {
//
currentModel.value.rotationEditing = false;
currentModel.value.positionEditing = false;
currentModel.value = null;
}
//v-if
proxy.$parent.addMonitorPointComShow = false;
}
// ,
function modelState(propName) {
proxy[propName] = !proxy[propName];
}
//
function addModel() {
//
const model = new window.XE.Obj.Model(window.$earth);
//
model.distanceDisplayCondition = [1, 30000];
//
model.url = window._CONFIG['domianURL'] + '/sys/common/static/dxgG.gltf';
//
model.scale = 0.03;
//
bindModelProps(model);
//
minimumPixelSize.value = 80;
return model;
}
//
function bindModelProps(model) {
//
model.disposers.push(window.XE.MVVM.bindPosition(proxy, 'LngLatHeight', model, 'xbsjPosition'));
//
model.disposers.push(window.XE.MVVM.bindRotation(proxy, 'rotation', model, 'xbsjRotation'));
//
model.disposers.push(window.XE.MVVM.bind(proxy, 'scale', model, 'xbsjScale'));
//
model.disposers.push(window.XE.MVVM.bind(proxy, 'creating', model, 'creating'));
//
model.disposers.push(window.XE.MVVM.bind(proxy, 'rotationEditing', model, 'rotationEditing'));
//
model.disposers.push(window.XE.MVVM.bind(proxy, 'minimumPixelSize', model, 'minimumPixelSize'));
}
//
function moveNode(type) {
if (!isUpdateModel.value) {
return false;
}
const newNodel = 'node_' + selectArea.value.id;
const moveAreaNode = window.$earth.sceneTree.$refs[newNodel] || window.$earth.sceneTree.$refs['nodeSecondary_' + selectArea.value.id];
if (moveAreaNode) {
let moveNode = null;
if (type == 'Model') {
moveNode = moveAreaNode.children[0];
} else if (type == 'ld') {
moveNode = moveAreaNode;
} else {
moveNode = moveAreaNode.children[2];
}
}
return true;
}
onMounted(() => {
//
isUpdateModel.value = false;
//
getAreas().then(() => {
//
expand.value = true;
//
currentModel.value = addModel();
});
});
return {
widthCoefficient,
heightCoefficient,
width,
height,
top,
left,
winVisible,
currentModel,
name,
areaList,
selectArea,
minimumPixelSize,
LngLatHeight,
rotation,
rotationEditing,
positionEditing,
scale,
creating,
expand,
getAreas,
bindModelProps,
modelState,
cancel,
ok,
};
},
});
</script>
<style scoped>
.object-box {
width: 100%;
height: 86%;
label {
color: #ffffff;
}
}
:deep(.custom-item-box > div > input) {
width: 45% !important;
margin-right: 0% !important;
}
:deep(.custom-label) {
width: 15% !important;
display: flex;
align-items: center;
justify-content: flex-end;
color: #ffffff;
}
:deep(.object-box .custom-item) {
height: 10%;
margin-top: 2%;
}
:deep(.custom-item-box) {
padding-left: 5% !important;
width: 80% !important;
}
.name-input {
height: 90%;
width: 100%;
background: rgba(0, 0, 0, 0.5);
border-radius: 3px;
border: none;
color: #ddd;
padding: 5px;
outline: none;
}
.xyz-input {
height: 90%;
width: 30%;
background: rgba(0, 0, 0, 0.5);
border-radius: 3px;
border: none;
color: #ddd;
padding: 5px;
outline: none;
}
.y-margin {
margin-left: 5%;
margin-right: 5%;
}
.edit-model-btn {
cursor: pointer;
line-height: 5%;
}
.edit-model-btn-disable {
cursor: not-allowed;
}
</style>

638
src/components/earthMap/toolbar/AddRadarCom.vue

@ -0,0 +1,638 @@
<!--
* @Author: Fuyuu 1805498209@qq.com
* @Date: 2024-01-10 15:19:50
* @LastEditors: Fuyuu 1805498209@qq.com
* @LastEditTime: 2024-01-11 15:50:45
* @FilePath: \dt-admin-pc-v2\src\components\earthMap\toolbar\AddWaveCom.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="create-model-modal" v-if="winVisible">
<Window
:title="title"
@cancel="cancel"
@ok="ok"
:width="width"
:minWidth="600"
:height="height"
:left="left"
:top="top"
:floatright="false"
:footervisible="true"
v-show="!creating"
:expand="expand"
>
<div class="object-box">
<div style="display: flex" class="custom-item">
<label class="custom-label">雷达名称:</label>
<div class="custom-item-box">
<input v-model="name" class="name-input" style="height: 90%; width: 100%" @change="nameChange(currentModel)" />
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">所属区域:</label>
<div class="custom-item-box">
<XbsjSelect id="area-select" title="name" :list="areaList" v-model:value="selectArea" />
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">主机设备:</label>
<div class="custom-item-box">
<XbsjSelect title="deviceName" :list="hostDeviceList" v-model:value="selectHostDevice" />
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">设备编码:</label>
<div class="custom-item-box">
<input v-model="selectDeviceNum" class="name-input" style="height: 90%; width: 100%" />
</div>
</div>
<div style="display: flex; height: 20%" class="custom-item">
<label class="custom-label">上传图标:</label>
<div class="custom-item-box">
<div class="upload-box">
<upload v-model:file="uploadFile" :pre-view-url="previewImgUrl" :isUpdateModel="isUpdateModel" />
</div>
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">经纬度:</label>
<div class="custom-item-box">
<!-- <XbsjLngLatHeight v-model="LngLatHeight" style="height: 90%; width: 100%"></XbsjLngLatHeight> -->
<input v-model="LngLatHeight[0]" type="number" class="xyz-input" />
<input v-model="LngLatHeight[1]" type="number" class="xyz-input y-margin" />
<input v-model="LngLatHeight[2]" type="number" class="xyz-input" />
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">扫描颜色:</label>
<div class="custom-item-box">
<XbsjColorButton style="height: 30px" v-model:color="radarColor"> </XbsjColorButton>
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">法线偏移角度:</label>
<div class="custom-item-box">
<input v-model="radarShifting" type="number" class="xyz-input" />
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">扫描范围:</label>
<div class="custom-item-box">
<input v-model="radarRange" type="number" class="xyz-input" />
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">扫描半径:</label>
<div class="custom-item-box">
<input v-model="radarRadius" type="number" class="xyz-input" />
</div>
</div>
<div style="display: flex; justify-content: center" class="custom-item">
<button
@click="modelState('creating')"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']"
:disabled="creating"
style="width: 20%; display: flex; align-items: center; justify-content: center"
>
拾取
</button>
<button
@click="currentModel.editing = true"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']"
:disabled="creating"
style="width: 20%; display: flex; align-items: center; justify-content: center"
>
移动
</button>
</div>
</div>
</Window>
</div>
</template>
<script lang="ts">
import { onMounted, defineComponent, ref, getCurrentInstance, computed, watch } from 'vue';
import xbsjScale from '/@/components/earthMap/components/xbsjScale.vue';
import XbsjSelect from '/@/components/earthMap/components/XbsjSelect.vue';
import XbsjColorButton from '/@/components/earthMap/components/XbsjColorButton.vue';
import upload from '/@/components/earthMap/components/upload.vue';
import Window from '@/components/earthMap/components/Window.vue';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import { addViewShedRadar } from '@/utils/earthMap/earthObj';
export default defineComponent({
name: 'AddWaveCom',
components: {
xbsjScale,
XbsjSelect,
upload,
XbsjColorButton,
Window,
},
props: {
title: {
type: String,
default: '添加雷达',
},
setLabelStatus: {
type: Function,
default: null,
},
setIconByRef: {
type: Function,
default: null,
},
el: {
type: Object,
default: null,
},
},
setup(props) {
const { proxy }: any = getCurrentInstance();
const { createMessage } = useMessage();
//
let widthCoefficient = ref(0.3);
let heightCoefficient = ref(0.5);
//
const width = computed(() => {
return window.outerWidth * widthCoefficient.value;
});
const height = computed(() => {
return window.outerHeight * heightCoefficient.value;
});
const top = computed(() => {
return window.outerHeight * ((1.0 - heightCoefficient.value - 0.15) / 2);
});
const left = computed(() => {
return (window.outerWidth * (1.0 - widthCoefficient.value)) / 2;
});
//
let name = ref('');
//
let areaList = ref([]);
//
let selectArea: any = ref(null);
//
let hostDeviceList = ref([]);
//
let selectHostDevice: any = ref(null);
//
let selectDeviceNum = ref(null);
//
let uploadFile:any = ref(null);
//
let previewImgUrl = ref('');
//
let uploadFileCount = ref(1);
//
let timer: any = ref(null);
//
let isUpdateModel = ref(false);
//
let revert = ref(null);
//
let currentModel: any = ref(null);
//
let LngLatHeight = ref([0, 0, 0]);
//
let radarColor = ref({ rgba: { r: 0, g: 255, b: 0, a: 0.5 } });
// 线
let radarShifting = ref(1);
//
let radarRange = ref(100);
//
let radarRadius = ref(500);
// 使
let radarOldObj: any = ref({});
//
let submitObject: any = ref({});
//
let winVisible = ref(true);
//
let creating = ref(false);
//
let show = ref(false);
//
let expand = ref(true);
//
watch(uploadFile, (newVal, _oldVal) => {
//
let formData = new FormData();
// temp
formData.append('biz', 'temp');
//
formData.append('file', newVal);
//
defHttp.post({ url: '/sys/common/upload', params: formData }, { isTransformResponse: false }).then((response) => {
//
if (response.success) {
//
let imageUrl = '/dt/sys/common/static/' + response.message;
// img domsrc
previewImgUrl.value = imageUrl;
// pin
currentModel.value.imageUrl = imageUrl;
if (!isUpdateModel.value && uploadFileCount.value == 1) {
// pin
show.value = true;
//
creating.value = true;
// 2
uploadFileCount.value++;
}
}
});
});
//
function getAreas() {
const submitData: any = {
pageNo: 1,
pageSize: 999,
};
return defHttp
.get(
{
url: '/military/msMapLine/list',
params: submitData,
},
{ isTransformResponse: false }
)
.then((res) => {
if (res.success) {
areaList.value = res.result.records;
}
});
}
//
function getHostDeviceList() {
const url = '/military/dtDeviceInfo/list';
const args = { pageNo: 1, pageSize: 999 };
return defHttp
.get({ url, params: args }, { isTransformResponse: false })
.then((reponse) => {
if (reponse.success) {
hostDeviceList.value = reponse.result.records;
}
})
.catch(() => {
throw '获取主机信息错误';
});
}
//
function nameChange(model) {
// pin
model.pinBuilder.extText = name.value;
}
// ,
function modelState(propName) {
proxy[propName] = !proxy[propName];
}
// pin
function addPin() {
// pin
const pin = new window.XE.Obj.Pin(window.$earth);
//
pin.scale = 0.8;
// url
pin.imageUrl = '';
//
pin.far = 1073741824;
//
pin.pinBuilder.extTextFont = '30px 楷体';
pin.pinBuilder.extTextPixelOffset = [30, -20];
pin.pinBuilder.fillColor = [1, 1, 1, 0.9];
pin.pinBuilder.outlineColor = [0, 0, 0, 0.9];
//
pin.onmouseover = () => {
window.$earth.czm.viewer._container.style.cursor = 'pointer';
};
pin.onmouseout = () => {
window.$earth.czm.viewer._container.style.cursor = 'default';
};
//
bindPinProps(pin);
//
show.value = false;
//
modelState('creating');
return pin;
}
//
function bindPinProps(pin) {
pin.disposers.push(window.XE.MVVM.bindPosition(proxy, 'LngLatHeight', pin, 'position'));
pin.disposers.push(window.XE.MVVM.bind(proxy, 'creating', pin, 'creating'));
pin.disposers.push(window.XE.MVVM.bind(proxy, 'show', pin, 'show'));
}
//
function cancel() {
if (isUpdateModel.value) {
//
updateClose();
} else {
//
close();
}
//v-if
proxy.$parent.addRadarComShow = false;
}
//
function updateClose() {
//
if (currentModel.value) {
currentModel.value.xbsjFromJSON(revert.value);
if (Object.keys(radarOldObj.value).length > 0) {
radarColor.value.rgba = radarOldObj.value.color;
radarRadius.value = radarOldObj.value.radarRadius;
radarRange.value = radarOldObj.value.radarRange;
radarShifting.value = radarOldObj.value.radarShifting;
}
currentModel.value.editing = false;
currentModel.value.positionEditing = false;
currentModel.value.rotationEditing = false;
}
}
//
function close() {
//
if (currentModel.value) {
if (currentModel.value.addViewShedReturn) {
console.log('window.$earth.czm.viewer.entities', window.$earth.czm.viewer.entities);
window.$earth.czm.viewer.entities.remove(currentModel.value.addViewShedReturn);
}
currentModel.value.addViewShedReturn = undefined;
currentModel.value.editing = false;
currentModel.value.destroy();
}
}
//
function ok() {
// pin
if (currentModel.value.imageUrl.length <= 0) {
createMessage.warning('需要先上传图片', 2);
return;
} else if (!selectHostDevice.value) {
createMessage.warning('主机设备不能为空', 2);
return;
} else if (!selectDeviceNum.value) {
createMessage.warning('设备编码不能为空', 2);
return;
} else if (selectArea.value == null || selectArea.value.id <= 0) {
//
createMessage.warning('请选择所属区域', 2);
return;
}
//
currentModel.value.editing = false;
//
submitData();
}
//
function submitData() {
const lastIndex = currentModel.value.imageUrl.lastIndexOf('/temp');
const ImgUrl = currentModel.value.imageUrl.substring(lastIndex + 1);
// Pin
//
const labelAttr = 4; // 4 10
submitObject.value = {
mapLabel: {
id: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
sysOrgCode: null,
labelAttr: labelAttr, //
labelName: name.value, //
lineId: selectArea.value?.id ? selectArea.value.id : null, //
labelLon: LngLatHeight.value[0], // x
labelLat: LngLatHeight.value[1], // y
labelHeight: LngLatHeight.value[2], // z
labelImgUrl: ImgUrl, // url
labelStatus: 1, // :1 0
labelCode: selectDeviceNum.value,
cameraId: null,
cameraName: null,
pan: 0,
tile: 0,
zoom: 0,
placements: null,
},
deviceId: selectHostDevice.value.id,
};
let request: any = null;
//
let url = '';
if (isUpdateModel.value) {
// urlput id
url = '/military/msMapLabel/editMapLabel';
// submitObject.value.mapLabel.id = props.eidtId;
request = defHttp.put({ url: url, params: submitObject.value }, { isTransformResponse: false });
} else {
// urlpost
url = '/military/msMapLabel/addMapLabel';
request = defHttp.post({ url: url, params: submitObject.value }, { isTransformResponse: false });
}
const { setLabelStatus } = props;
//
request
.then(function (response) {
//
if (response.success) {
// ref node_ref
const lineId = 'node_' + selectArea.value.id;
// const ldLineId = 'nodeSecondary_' + selectArea.value.id;
//
const wbParent = window.$earth.sceneTree.$refs[lineId] && window.$earth.sceneTree.$refs[lineId].children[2];
//
const ldParent = window.$earth.sceneTree.$refs[lineId] && window.$earth.sceneTree.$refs[lineId].children[1];
//
let node = new window.XE.SceneTree.Leaf(currentModel.value);
//
node.title = name.value;
// ref
node.ref = response.result;
// nameid
node.name = submitObject.value.lineId;
//
currentModel.value.customProp =
'{"labelAttr":' + labelAttr + ',"labelCode":"' + selectDeviceNum.value + '","deviceId":"' + selectHostDevice.value.id + '"}';
setLabelStatus(selectHostDevice.value, selectDeviceNum.value, node.ref, 2).finally(() => {
if (labelAttr == 4) {
//
ldParent.children.push(node);
} else {
//
wbParent.children.push(node);
}
//
createMessage.success('添加成功!', 2);
});
//
if (labelAttr == 4) {
let radarObj = {
radarCode: selectDeviceNum.value,
elevation: Number(radarRange.value),
workingRadius: Number(radarRadius.value),
angularRadian: Number(radarShifting.value),
customProp: JSON.stringify({ color: radarColor.value.rgba }),
};
defHttp.post({ url: '/military/RadarConfig/add', params: radarObj }, { isTransformResponse: false });
}
}
})
.then(function () {
finish();
});
}
//
function finish() {
if (currentModel.value) {
//
currentModel.value.rotationEditing = false;
currentModel.value.positionEditing = false;
currentModel.value = null;
}
//v-if
proxy.$parent.addRadarComShow = false;
}
//
function getRadarScan() {
if (timer.value) clearTimeout(timer.value);
timer.value = setTimeout(() => {
let rgb = radarColor.value.rgba;
if (currentModel.value.addViewShedReturn) {
console.log('window.$earth.czm.viewer.entities', window.$earth.czm.viewer.entities);
window.$earth.czm.viewer.entities.remove(currentModel.value.addViewShedReturn);
}
//
let left = Number(radarShifting.value) - Number(radarRange.value) / 2;
currentModel.value.addViewShedReturn = addViewShedRadar(
currentModel.value.position,
radarRadius.value,
left,
Number(radarRange.value) / 2 + Number(radarShifting.value),
[rgb.r / 255, rgb.g / 255, rgb.b / 255, rgb.a]
);
}, 300);
}
onMounted(() => {
//
isUpdateModel.value = false;
//
getHostDeviceList().then(() => {
//
getAreas().then(() => {
//
expand.value = true;
//
currentModel.value = addPin();
});
});
});
return {
width,
height,
top,
left,
name,
areaList,
selectArea,
hostDeviceList,
selectHostDevice,
selectDeviceNum,
uploadFile,
previewImgUrl,
isUpdateModel,
LngLatHeight,
radarShifting,
radarColor,
radarRange,
radarRadius,
radarOldObj,
currentModel,
winVisible,
creating,
expand,
modelState,
getRadarScan,
nameChange,
cancel,
ok,
};
},
});
</script>
<style scoped>
.object-box {
width: 100%;
height: 86%;
label {
color: #ffffff;
}
}
:deep(.custom-item-box > div > input) {
width: 45% !important;
margin-right: 0% !important;
}
:deep(.custom-label) {
width: 16% !important;
display: flex;
align-items: center;
justify-content: flex-end;
color: #ffffff;
}
:deep(.object-box .custom-item) {
height: 10%;
margin-top: 2%;
}
:deep(.custom-item-box) {
padding-left: 5% !important;
width: 80% !important;
}
.name-input {
height: 90%;
width: 100%;
background: rgba(0, 0, 0, 0.5);
border-radius: 3px;
border: none;
color: #ddd;
padding: 5px;
outline: none;
}
.xyz-input {
height: 90%;
width: 30%;
background: rgba(0, 0, 0, 0.5);
border-radius: 3px;
border: none;
color: #ddd;
padding: 5px;
outline: none;
}
.y-margin {
margin-left: 5%;
margin-right: 5%;
}
.edit-model-btn {
cursor: pointer;
line-height: 5%;
}
.edit-model-btn-disable {
cursor: not-allowed;
}
.upload-box {
height: 100%;
width: 20%;
}
</style>

542
src/components/earthMap/toolbar/AddWaveCom.vue

@ -0,0 +1,542 @@
<!--
* @Author: Fuyuu 1805498209@qq.com
* @Date: 2024-01-10 15:19:50
* @LastEditors: Fuyuu 1805498209@qq.com
* @LastEditTime: 2024-01-11 15:49:37
* @FilePath: \dt-admin-pc-v2\src\components\earthMap\toolbar\AddWaveCom.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="create-model-modal" v-if="winVisible">
<Window
:title="title"
@cancel="cancel"
@ok="ok"
:width="width"
:minWidth="600"
:height="height"
:left="left"
:top="top"
:floatright="false"
:footervisible="true"
v-show="!creating"
:expand="expand"
>
<div class="object-box">
<div style="display: flex" class="custom-item">
<label class="custom-label">微波名称:</label>
<div class="custom-item-box">
<input v-model="name" class="name-input" style="height: 90%; width: 100%" @change="nameChange(currentModel)" />
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">所属区域:</label>
<div class="custom-item-box">
<XbsjSelect id="area-select" title="name" :list="areaList" v-model:value="selectArea" />
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">主机设备:</label>
<div class="custom-item-box">
<XbsjSelect title="deviceName" :list="hostDeviceList" v-model:value="selectHostDevice" />
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">设备编码:</label>
<div class="custom-item-box">
<input v-model="selectDeviceNum" class="name-input" style="height: 90%; width: 100%" />
</div>
</div>
<div style="display: flex; height: 20%" class="custom-item">
<label class="custom-label">上传图标:</label>
<div class="custom-item-box">
<div class="upload-box">
<upload v-model:file="uploadFile" :pre-view-url="previewImgUrl" :isUpdateModel="isUpdateModel" />
</div>
</div>
</div>
<div style="display: flex" class="custom-item">
<label class="custom-label">经纬度:</label>
<div class="custom-item-box">
<!-- <XbsjLngLatHeight v-model="LngLatHeight" style="height: 90%; width: 100%"></XbsjLngLatHeight> -->
<input v-model="LngLatHeight[0]" type="number" class="xyz-input" />
<input v-model="LngLatHeight[1]" type="number" class="xyz-input y-margin" />
<input v-model="LngLatHeight[2]" type="number" class="xyz-input" />
</div>
</div>
<div style="display: flex; justify-content: center" class="custom-item">
<button
@click="modelState('creating')"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']"
:disabled="creating"
style="width: 20%; display: flex; align-items: center; justify-content: center"
>
拾取
</button>
<button
@click="currentModel.editing = true"
:class="['xbsj-button', 'edit-model-btn', creating ? 'edit-model-btn-disable' : '']"
:disabled="creating"
style="width: 20%; display: flex; align-items: center; justify-content: center"
>
移动
</button>
</div>
</div>
</Window>
</div>
</template>
<script lang="ts">
import { onMounted, defineComponent, ref, getCurrentInstance, computed, watch } from 'vue';
import xbsjScale from '/@/components/earthMap/components/xbsjScale.vue';
import XbsjSelect from '/@/components/earthMap/components/XbsjSelect.vue';
import XbsjColorButton from '/@/components/earthMap/components/XbsjColorButton.vue';
import upload from '/@/components/earthMap/components/upload.vue';
import Window from '@/components/earthMap/components/Window.vue';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
export default defineComponent({
name: 'AddWaveCom',
components: {
xbsjScale,
XbsjSelect,
upload,
XbsjColorButton,
Window,
},
props: {
title: {
type: String,
default: '添加微波探测器',
},
setLabelStatus: {
type: Function,
default: null,
},
setIconByRef: {
type: Function,
default: null,
},
el: {
type: Object,
default: null,
},
},
setup(props) {
const { proxy }: any = getCurrentInstance();
const { createMessage } = useMessage();
//
let widthCoefficient = ref(0.3);
let heightCoefficient = ref(0.5);
//
const width = computed(() => {
return window.outerWidth * widthCoefficient.value;
});
const height = computed(() => {
return window.outerHeight * heightCoefficient.value;
});
const top = computed(() => {
return window.outerHeight * ((1.0 - heightCoefficient.value - 0.15) / 2);
});
const left = computed(() => {
return (window.outerWidth * (1.0 - widthCoefficient.value)) / 2;
});
//
let name = ref('');
//
let areaList = ref([]);
//
let selectArea: any = ref(null);
//
let hostDeviceList = ref([]);
//
let selectHostDevice: any = ref(null);
//
let selectDeviceNum = ref(null);
//
let uploadFile: any = ref(null);
//
let previewImgUrl = ref('');
//
let uploadFileCount = ref(1);
//
let isUpdateModel = ref(false);
//
let revert = ref(null);
//
let currentModel: any = ref(null);
//
let LngLatHeight = ref([0, 0, 0]);
//
let submitObject: any = ref({});
//
let winVisible = ref(true);
//
let creating = ref(false);
//
let show = ref(false);
//
let expand = ref(true);
watch(uploadFile, (newVal, _oldVal) => {
//
let formData = new FormData();
// temp
formData.append('biz', 'temp');
//
formData.append('file', newVal);
//
defHttp.post({ url: '/sys/common/upload', params: formData }, { isTransformResponse: false }).then((response) => {
//
if (response.success) {
//
let imageUrl = '/dt/sys/common/static/' + response.message;
// img domsrc
previewImgUrl.value = imageUrl;
// pin
currentModel.value.imageUrl = imageUrl;
if (!isUpdateModel.value && uploadFileCount.value == 1) {
// pin
show.value = true;
//
creating.value = true;
// 2
uploadFileCount.value++;
}
}
});
});
//
function getAreas() {
const submitData: any = {
pageNo: 1,
pageSize: 999,
};
return defHttp
.get(
{
url: '/military/msMapLine/list',
params: submitData,
},
{ isTransformResponse: false }
)
.then((res) => {
if (res.success) {
areaList.value = res.result.records;
}
});
}
//
function getHostDeviceList() {
const url = '/military/dtDeviceInfo/list';
const args = { pageNo: 1, pageSize: 999 };
return defHttp
.get({ url, params: args }, { isTransformResponse: false })
.then((reponse) => {
if (reponse.success) {
hostDeviceList.value = reponse.result.records;
}
})
.catch(() => {
throw '获取主机信息错误';
});
}
//
function nameChange(model) {
// pin
model.pinBuilder.extText = name.value;
}
// ,
function modelState(propName) {
proxy[propName] = !proxy[propName];
}
// pin
function addPin() {
// pin
const pin = new window.XE.Obj.Pin(window.$earth);
//
pin.scale = 0.8;
// url
pin.imageUrl = '';
//
pin.far = 1073741824;
//
pin.pinBuilder.extTextFont = '30px 楷体';
pin.pinBuilder.extTextPixelOffset = [30, -20];
pin.pinBuilder.fillColor = [1, 1, 1, 0.9];
pin.pinBuilder.outlineColor = [0, 0, 0, 0.9];
//
bindPinProps(pin);
//
show.value = false;
//
modelState('creating');
modelState('creating');
return pin;
}
//
function bindPinProps(pin) {
pin.disposers.push(window.XE.MVVM.bindPosition(proxy, 'LngLatHeight', pin, 'position'));
pin.disposers.push(window.XE.MVVM.bind(proxy, 'creating', pin, 'creating'));
pin.disposers.push(window.XE.MVVM.bind(proxy, 'show', pin, 'show'));
}
//
function cancel() {
if (isUpdateModel.value) {
//
updateClose();
} else {
//
close();
}
//v-if
proxy.$parent.addWaveComShow = false;
}
//
function updateClose() {
//
if (currentModel.value) {
currentModel.value.xbsjFromJSON(revert.value);
currentModel.value.editing = false;
currentModel.value.positionEditing = false;
currentModel.value.rotationEditing = false;
}
}
//
function close() {
//
if (currentModel.value) {
if (currentModel.value.addViewShedReturn) {
window.$earth.czm.viewer.entities.remove(currentModel.value.addViewShedReturn);
}
currentModel.value.editing = false;
currentModel.value.destroy();
}
}
//
function ok() {
// pin
if (currentModel.value.imageUrl.length <= 0) {
createMessage.warning('需要先上传图片', 2);
return;
} else if (!selectHostDevice.value) {
createMessage.warning('主机设备不能为空', 2);
return;
} else if (!selectDeviceNum.value) {
createMessage.warning('设备编码不能为空', 2);
return;
} else if (selectArea.value == null || selectArea.value.id <= 0) {
//
createMessage.warning('请选择所属区域', 2);
return;
}
//
currentModel.value.editing = false;
//
submitData();
}
//
function submitData() {
const lastIndex = currentModel.value.imageUrl.lastIndexOf('/temp');
const ImgUrl = currentModel.value.imageUrl.substring(lastIndex + 1);
// Pin
//
const labelAttr = 10; // 4 10
submitObject.value = {
mapLabel: {
id: null,
createBy: null,
createTime: null,
updateBy: null,
updateTime: null,
sysOrgCode: null,
labelAttr: labelAttr, //
labelName: name.value, //
lineId: selectArea.value?.id ? selectArea.value.id : null, //
labelLon: LngLatHeight.value[0], // x
labelLat: LngLatHeight.value[1], // y
labelHeight: LngLatHeight.value[2], // z
labelImgUrl: ImgUrl, // url
labelStatus: 1, // :1 0
labelCode: selectDeviceNum.value,
cameraId: null,
cameraName: null,
pan: 0,
tile: 0,
zoom: 0,
placements: null,
},
deviceId: selectHostDevice.value.id,
};
let request: any = null;
//
let url = '';
if (isUpdateModel.value) {
// urlput id
url = '/military/msMapLabel/editMapLabel';
// submitObject.value.mapLabel.id = props.eidtId;
request = defHttp.put({ url: url, params: submitObject.value }, { isTransformResponse: false });
} else {
// urlpost
url = '/military/msMapLabel/addMapLabel';
request = defHttp.post({ url: url, params: submitObject.value }, { isTransformResponse: false });
}
const { setLabelStatus } = props;
//
request
.then(function (response) {
//
if (response.success) {
// ref node_ref
const lineId = 'node_' + selectArea.value.id;
// const ldLineId = 'nodeSecondary_' + selectArea.value.id;
//
const wbParent = window.$earth.sceneTree.$refs[lineId] && window.$earth.sceneTree.$refs[lineId].children[2];
//
// const ldParent = window.$earth.sceneTree.$refs[ldLineId];
//
let node = new window.XE.SceneTree.Leaf(currentModel.value);
//
node.title = name.value;
// ref
node.ref = response.result;
// nameid
node.name = submitObject.value.lineId;
//
currentModel.value.customProp =
'{"labelAttr":' + labelAttr + ',"labelCode":"' + selectDeviceNum.value + '","deviceId":"' + selectHostDevice.value.id + '"}';
setLabelStatus(selectHostDevice.value, selectDeviceNum.value, node.ref, 2).finally(() => {
//
wbParent.children.push(node);
//
createMessage.success('添加成功!', 2);
});
}
})
.then(function () {
finish();
});
}
//
function finish() {
if (currentModel.value) {
//
currentModel.value.rotationEditing = false;
currentModel.value.positionEditing = false;
currentModel.value = null;
}
//v-if
proxy.$parent.addWaveComShow = false;
}
onMounted(() => {
//
isUpdateModel.value = false;
//
getHostDeviceList().then(() => {
//
getAreas().then(() => {
//
expand.value = true;
//
currentModel.value = addPin();
});
});
});
return {
width,
height,
top,
left,
name,
areaList,
selectArea,
hostDeviceList,
selectHostDevice,
selectDeviceNum,
uploadFile,
previewImgUrl,
isUpdateModel,
LngLatHeight,
currentModel,
winVisible,
creating,
expand,
modelState,
nameChange,
cancel,
ok,
};
},
});
</script>
<style scoped>
.object-box {
width: 100%;
height: 86%;
label {
color: #ffffff;
}
}
:deep(.custom-item-box > div > input) {
width: 45% !important;
margin-right: 0% !important;
}
:deep(.custom-label) {
width: 15% !important;
display: flex;
align-items: center;
justify-content: flex-end;
color: #ffffff;
}
:deep(.object-box .custom-item) {
height: 10%;
margin-top: 2%;
}
:deep(.custom-item-box) {
padding-left: 5% !important;
width: 80% !important;
}
.name-input {
height: 90%;
width: 100%;
background: rgba(0, 0, 0, 0.5);
border-radius: 3px;
border: none;
color: #ddd;
padding: 5px;
outline: none;
}
.xyz-input {
height: 90%;
width: 30%;
background: rgba(0, 0, 0, 0.5);
border-radius: 3px;
border: none;
color: #ddd;
padding: 5px;
outline: none;
}
.y-margin {
margin-left: 5%;
margin-right: 5%;
}
.edit-model-btn {
cursor: pointer;
line-height: 5%;
}
.edit-model-btn-disable {
cursor: not-allowed;
}
.upload-box {
height: 100%;
width: 20%;
}
</style>

1
src/utils/earthMap/earthObj.ts

@ -764,6 +764,7 @@ export const addPin = (name, url, options) => {
if (options.far) {
objConfig.far = options.far;
}
pin.xbsjFromJSON(objConfig);
return pin;

7
src/views/earthMap/edit/EarthComp.vue

@ -1979,7 +1979,7 @@
}
let pickedFeature = this._viewer.scene.pick(click.position);
console.log('点击的船只:', pickedFeature);
// console.log(':', pickedFeature);
if (pickedFeature && pickedFeature.id) {
//
@ -2052,16 +2052,19 @@
JSON.parse(pickedFeature.id._xbsjOwner.customProp).labelAttr == '4'
) {
let labelCode = JSON.parse(pickedFeature.id._xbsjOwner.customProp).labelCode;
console.log(pickedFeature.id._xbsjOwner);
console.log('点击雷达:', pickedFeature.id._xbsjOwner);
if (pickedFeature.id._xbsjOwner.addViewShedReturn) {
///
// pickedFeature.id._xbsjOwner.addViewShedReturn.show = !pickedFeature.id._xbsjOwner.addViewShedReturn.show;
// console.log("pickedFeature.id._xbsjOwner.addViewShedReturn",pickedFeature.id._xbsjOwner.addViewShedReturn);
//undefined()
console.log('关闭扫描');
pickedFeature.id._xbsjOwner.addViewShedReturn.clear();
pickedFeature.id._xbsjOwner.addViewShedReturn = undefined;
} else {
console.log('打开扫描');
defHttp.get({ url: this.url.radarList, params: { radarCode: labelCode } }, { isTransformResponse: false }).then((res) => {
if (res.success) {
if (res.result.records.length > 0) {

Loading…
Cancel
Save