Browse Source

1.编辑区域 addArea方法 修改参数

2.调用创建/编辑区域 addMonitorPoint方法
3.保留MsCameraSiteFormDeprecated
master
DIAMOND 11 months ago
parent
commit
3021219083
  1. 45
      src/components/earthMap/Toolbar.vue
  2. 907
      src/components/earthMap/toolbar/AddMonitorPointCom.vue
  3. 27
      src/views/earthMap/edit/EarthComp.vue
  4. 53
      src/views/military/modules/earthMap/camera/components/MsCameraSiteForm.vue
  5. 350
      src/views/military/modules/earthMap/camera/components/MsCameraSiteFormDeprecated.vue
  6. 4
      src/views/military/modules/earthMap/msMapLine/components/MsMapLineForm.vue
  7. 827
      src/views/military/modules/earthMap/scene/model/mapModel/EarthMapModal copy.vue

45
src/components/earthMap/Toolbar.vue

@ -93,7 +93,7 @@
</ul>
</div>
<!-- 添加监控点 -->
<AddMonitorPointCom v-if="addMonitorPointComShow"></AddMonitorPointCom>
<AddMonitorPointCom v-if="addMonitorPointComShow" :msCameraSiteHandle="msCameraSiteHandle"></AddMonitorPointCom>
<!-- 添加微波 -->
<AddWaveCom v-if="addWaveComShow" :setLabelStatus="setLabelStatus"></AddWaveCom>
<!-- 添加雷达 -->
@ -202,6 +202,7 @@
//
const addMonitorPointComShow = ref(false);
const msCameraSiteHandle = ref(false);
//
const addWaveComShow = ref(false);
//
@ -264,10 +265,15 @@
drawShapePackage.value = res;
});
/// addArea
$mitt.on('addAreaHandler', function (res: any) {
// console.log("addAreaHandlerres",res);
$mitt.on('msMapLineHandler', function (res: any) {
// console.log("msMapLineHandlerres",res);
addArea(res)
});
/// addMonitorPoint
$mitt.on('msCameraSiteHandle', function (res: any) {
// console.log("msMapLineHandlerres",res);
addMonitorPoint(res)
});
}
//
@ -994,7 +1000,7 @@
}
function openPopModal(id, e) {
let popModal = document.getElementById(id);
let popModal: any = document.getElementById(id);
let node = e.target;
if (node.nodeName === 'IMG') {
node = node.parentNode;
@ -1015,9 +1021,9 @@
popModalDisplay === 'block' ? (popModal.style.display = 'none') : (popModal.style.display = 'block');
}
function closePopModal(type, menu = null, button = null) {
let popModalList = document.getElementsByClassName('popModal');
let tbImgHoverList = document.getElementsByClassName('tbImgHover');
function closePopModal(type, menu: any = null, button: any = null) {
let popModalList: any = document.getElementsByClassName('popModal');
let tbImgHoverList: any = document.getElementsByClassName('tbImgHover');
switch (type) {
case 'all':
//
@ -1044,7 +1050,7 @@
}
break;
default:
let popModal = document.getElementById(menu);
let popModal: any = document.getElementById(menu);
button.classList.remove('tbImgHover');
popModal.style.display = 'none';
break;
@ -1085,8 +1091,9 @@
}
//
function addMonitorPoint() {
function addMonitorPoint(data= false) {
addMonitorPointComShow.value = true;
msCameraSiteHandle.value = data;
}
//
function addWave() {
@ -1096,9 +1103,9 @@
function addRadar() {
addRadarComShow.value = true;
}
// , addAreaHandler
function addArea(addAreaHandler = null) {
// console.log("",addAreaHandler);
// , msMapLineHandler
function addArea(msMapLineHandler = null) {
// console.log("",msMapLineHandler);
$mitt.emit('drawShapeShow', { show: true, title: '区域创建工具', from: 'addArea' });
$mitt.on('addAreaFinished', (t: any) => {
@ -1131,7 +1138,7 @@
*
*/
nextTick(() => {
addPolyline(positions,addAreaHandler);
addPolyline(positions,msMapLineHandler);
});
} else {
}
@ -1144,9 +1151,9 @@
}
/**
* @params 需要调用 addArea 方法进行绘图获取坐标点position
* @params addAreaHandler标识 后台区域管理调用
* @params msMapLineHandler标识 后台区域管理调用
*/
function addPolyline(positions: any = null, addAreaHandler =null) {
function addPolyline(positions: any = null, msMapLineHandler =null) {
// console.log('positions', positions);
//
@ -1162,9 +1169,9 @@
// console.log('currentModel', currentModel);
// ui
const earthUI = window.$uia;
// console.log("addAreaHandler",addAreaHandler);
// console.log("msMapLineHandler",msMapLineHandler);
//return
if(addAreaHandler){
if(msMapLineHandler){
$mitt.emit('toMsMapLineForm',currentModel)
return
}
@ -1358,7 +1365,8 @@
$mitt.off('warnInfoMan');
$mitt.off('addAreaFinished');
$mitt.off('drawShapeShow');
$mitt.off('addAreaHandler');
$mitt.off('msMapLineHandler');
$mitt.off('msCameraSiteHandle');
});
return {
@ -1426,6 +1434,7 @@
addArea,
addModelWinShow,
addMonitorPointComShow,
msCameraSiteHandle,
addWaveComShow,
addRadarComShow,
roamPathListShow,

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

@ -1,19 +1,8 @@
<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="!msCameraSiteHandle" :showcloseButton="!msCameraSiteHandle"
v-show="!creating" :expand="expand">
<div class="object-box">
<div style="display: flex" class="custom-item">
<label class="custom-label">监控点名称:</label>
@ -56,28 +45,19 @@
</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"
<button @click="currentModel.positionEditing = true"
:class="['xbsj-button', 'edit-model-btn', !currentModel || positionEditing ? 'edit-model-btn-disable' : '']"
:disabled="creating"
style="width: 20%"
>
: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>
@ -88,434 +68,495 @@
</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';
import { onMounted, nextTick, defineComponent, ref, getCurrentInstance, computed, onBeforeUnmount } 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';
import $mitt from '@/utils/earthMap/mitt';
import { useUserStore } from '/@/store/modules/user';
export default defineComponent({
name: 'AddMonitorPointCom',
components: {
xbsjScale,
XbsjSelect,
upload,
XbsjColorButton,
Window,
export default defineComponent({
name: 'AddMonitorPointCom',
components: {
xbsjScale,
XbsjSelect,
upload,
XbsjColorButton,
Window,
},
props: {
title: {
type: String,
default: '添加监控点',
},
props: {
title: {
type: String,
default: '添加监控点',
},
msCameraSiteHandle: {
type: Object,
default: null,
},
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);
},
setup(props) {
const { proxy }: any = getCurrentInstance();
const { createMessage } = useMessage();
const userStore = useUserStore();
//
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,
sceneId: userStore.userInfo?.sceneId + "*"
};
return defHttp
.get(
{
url: '/military/msMapLine/list',
params: submitData,
},
{ isTransformResponse: false }
)
.then((res) => {
if (res.success) {
areaList.value = res.result.records;
}
currentModel.value.editing = false;
currentModel.value.destroy();
}
});
}
//
function cancel() {
if (isUpdateModel.value) {
//
updateClose();
} else {
//
close();
}
//
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;
}
//
//v-if
proxy.$parent.addMonitorPointComShow = false;
}
//
function updateClose() {
//
if (currentModel.value) {
currentModel.value.xbsjFromJSON(revert.value);
currentModel.value.editing = false;
//
submitData();
currentModel.value.positionEditing = false;
currentModel.value.rotationEditing = false;
}
//
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 });
}
//
function close() {
//
if (currentModel.value) {
if (currentModel.value.addViewShedReturn) {
window.$earth.czm.viewer.entities.remove(currentModel.value.addViewShedReturn);
}
//
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();
});
currentModel.value.editing = false;
currentModel.value.destroy();
}
//
function finish() {
if (currentModel.value) {
//
currentModel.value.rotationEditing = false;
currentModel.value.positionEditing = false;
currentModel.value = null;
}
//v-if
proxy.$parent.addMonitorPointComShow = false;
}
//
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;
}
// ,
function modelState(propName) {
proxy[propName] = !proxy[propName];
//
currentModel.value.editing = false;
//
submitData();
}
//
function submitData(msg: any= null) {
// /
let startNum = currentModel.value.url.lastIndexOf('/') + 1;
//
let modelName = '';
if (startNum > -1) {
modelName = currentModel.value.url.substring(startNum, currentModel.value.url.length);
}
//
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;
//
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? 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, //
};
////
if(msg == "msCameraSiteHandleOK"){
return submitObject.value
}
//
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'));
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 });
}
//
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];
//
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;
}
return true;
}
onMounted(() => {
//
isUpdateModel.value = false;
//
getAreas().then(() => {
//
expand.value = true;
//
currentModel.value = addModel();
});
onMounted(() => {
//
isUpdateModel.value = false;
//
getAreas().then(() => {
//
expand.value = true;
//
currentModel.value = addModel();
return currentModel.value
})
.then((res)=>{
if(props.msCameraSiteHandle.id)
msCameraSiteHandleResolve(props.msCameraSiteHandle)
});
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,
};
},
});
// msCameraSiteHandle
function msCameraSiteHandleResolve(data) {
isUpdateModel.value = true
console.log(currentModel.value);
console.log("data",props.msCameraSiteHandle);
// currentModel.value.xbsjPosition = [data.longitude, data.latitude, data.height];
LngLatHeight.value = [data.longitude, data.latitude, data.height];
// currentModel.value.xbsjRotation = [data.yaw, data.pitch, data.roll];
rotation.value = [data.yaw, data.pitch, data.roll];
currentModel.value.scale = data.scale;
currentModel.value.xyzScale = data.xyz_scale;
currentModel.value.minimumPixelSize = data.minimum_pixel_size
name.value = data.sitename;
selectArea.value = {id:data.line_id,name:data.name};
}
//
$mitt.on("msCameraSiteHandleOK", (data: any) => {
let callbackData = submitData("msCameraSiteHandleOK")
// data.callback(currentModel.value);
data.callback(callbackData);
// console.log(callbackData);
//
nextTick(()=>{
data.destroyed()
})
})
});
onBeforeUnmount(() => {
$mitt.off("msCameraSiteHandleOK")
})
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%;
.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;
label {
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%;
}
:deep(.custom-item-box > div > input) {
width: 45% !important;
margin-right: 0% !important;
}
.edit-model-btn-disable {
cursor: not-allowed;
}
: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>

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

@ -309,10 +309,15 @@ import { nextTick } from 'vue';
default: false,
},
//
addAreaHandler: {
msMapLineHandler: {
type: Boolean,
default: false,
},
//
msCameraSiteHandle: {
type: Object,
default: null,
},
},
})
export default class EarthComp extends Vue {
@ -542,14 +547,25 @@ import { nextTick } from 'vue';
this.cameraModalShow = false;
}
//
//
areaHandler(){
//
window.$viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(
window.Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK
);
this.$nextTick(() => {
$mitt.emit('addAreaHandler', this.addAreaHandler);
$mitt.emit('msMapLineHandler', this.msMapLineHandler);
})
}
//
cameraSiteHandler(){
//
window.$viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(
window.Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK
);
this.$nextTick(() => {
$mitt.emit('msCameraSiteHandle', this.msCameraSiteHandle);
})
}
@ -755,7 +771,10 @@ import { nextTick } from 'vue';
if (this.PropsCreateBBHLineOpen) await this.createBBHLine();
//使
if (this.addAreaHandler) this.areaHandler()
if (this.msMapLineHandler) this.areaHandler()
//使
if (this.msCameraSiteHandle) this.cameraSiteHandler()
});
}

53
src/views/military/modules/earthMap/camera/components/MsCameraSiteForm.vue

@ -35,22 +35,18 @@
</a-form-item>
</a-col>
<!-- <a-modal title="点位设置" :visible="mapVisible" @ok="earthMapOk" @cancel="destroyed" width="60vw" destroyOnClose
wrapClassName="EarthMap">
<a-row style="height: 60vh;">
<a-modal title="点位设置" :visible="mapVisible" @ok="ok" @cancel="destroyed" width="80vw" destroyOnClose
wrapClassName="EarthMap" style="top: 20px">
<a-row style="height: 80vh;">
<a-col :span="24">
<EarthComp
ref="earth"
@customFly="moveChinaPosition"
:hasMoveMethod="subObject && subObject.id ? true : false"
:enablePointer="true"
:listenMouseHandlerSenceOpen="true"
@checkPosition="checkPositionCache"
/>
:msCameraSiteHandle="formData.id ? formData: {}"
/>
</a-col>
</a-row>
</a-modal> -->
<EarthMapModal
</a-modal>
<!-- <EarthMapModal
ref="earthMapModal"
:enableTile="false"
:visible="mapVisible"
@ -61,12 +57,12 @@
"
@checkPosition="checkPosition"
:hasMoveMethod="true"
@moveChinaPosition="moveChinaPosition"
:editTileModel="mapModel"
initModeType="3D"
:enable-pointer="false"
>
</EarthMapModal>
</EarthMapModal> -->
</template>
<a-col :span="24">
<a-form-item label="经度" v-bind="validateInfos.longitude">
@ -115,6 +111,7 @@
import locationPng from '@/assets/images/getLocation.png';
import { useUserStore } from '/@/store/modules/user';
import EarthComp from '@/views/earthMap/edit/EarthComp.vue';
import $mitt from '@/utils/earthMap/mitt';
const userStore = useUserStore();
const lineSelect: any = ref([]);
@ -169,21 +166,7 @@
});
//线
function setSelectList() {
// defHttp
// .get(
// {
// url: '/military/msMapLine/mapLineSelect',
// },
// { isTransformResponse: false }
// )
// // getAction(this.url.querySelectList, {})
// .then((res) => {
// if (res.success) {
// lineSelect.value = res.result;
// }
// });
defHttp
.get(
defHttp.get(
{
url: '/military/msMapLine/list',
params: {
@ -195,8 +178,6 @@
lineSelect.value = res.result.records;
}
});
}
/**
@ -214,6 +195,7 @@
resetFields();
//
Object.assign(formData, record);
formData.lineId = record.line_id? record.line_id: undefined
});
}
@ -300,7 +282,7 @@
formData.roll = CMath.toDegrees(rotation[2]);
// subObject.value.viewDistance = fov;
};
};
const earthMapModal: any = ref(null);
//
const moveChinaPosition = function () {
@ -318,7 +300,14 @@ function destroyed() {
nextTick(() => {
mapVisible.value = false
})
}
function ok() {
$mitt.emit("msCameraSiteHandleOK",{ destroyed: destroyed, callback:(data)=>{
// console.log("data", data);
//
Object.assign(formData, data);
}})
}
defineExpose({

350
src/views/military/modules/earthMap/camera/components/MsCameraSiteFormDeprecated.vue

@ -0,0 +1,350 @@
<!--
使用EarthMapModal组件 编辑监控杆功能
已被弃用
-->
<template>
<a-spin :spinning="confirmLoading">
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol">
<a-row>
<a-col :span="24">
<a-form-item label="防区" v-bind="validateInfos.lineId">
<!-- <j-dict-select-tag v-model:value="formData.lineId" dictCode="" placeholder="" :disabled="disabled"/> -->
<a-select
v-model:value="formData.lineId"
style="width: 300px"
@change="changeLineValue"
:disabled="disabled"
placeholder="请选择所属防区"
>
<a-select-option v-for="(item, index) in lineSelect" :value="item.id" :key="item.id">
{{ item.name }}
</a-select-option>
</a-select>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="点位序号" v-bind="validateInfos.sitecode">
<a-input v-model:value="formData.sitecode" placeholder="请输入点位序号" :disabled="disabled"></a-input>
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="点位名称" v-bind="validateInfos.sitename">
<a-input v-model:value="formData.sitename" placeholder="请输入点位名称" :disabled="disabled"></a-input>
</a-form-item>
</a-col>
<template v-if="disabled == false">
<a-col :span="24">
<a-form-item label="位置">
<a><img :src="locationPng" class="dwImg" @click="mapShow" /></a>
</a-form-item>
</a-col>
<!-- <a-modal title="点位设置" :visible="mapVisible" @ok="earthMapOk" @cancel="destroyed" width="60vw" destroyOnClose
wrapClassName="EarthMap">
<a-row style="height: 60vh;">
<a-col :span="24">
<EarthComp
ref="earth"
@customFly="moveChinaPosition"
:hasMoveMethod="subObject && subObject.id ? true : false"
:enablePointer="true"
:listenMouseHandlerSenceOpen="true"
@checkPosition="checkPositionCache"
/>
</a-col>
</a-row>
</a-modal> -->
<EarthMapModal
ref="earthMapModal"
:enableTile="false"
:visible="mapVisible"
@closeWin="
() => {
mapVisible = false;
}
"
@checkPosition="checkPosition"
:hasMoveMethod="true"
@moveChinaPosition="moveChinaPosition"
:editTileModel="mapModel"
initModeType="3D"
:enable-pointer="false"
>
</EarthMapModal>
</template>
<a-col :span="24">
<a-form-item label="经度" v-bind="validateInfos.longitude">
<a-input-number v-model:value="formData.longitude" placeholder="请输入经度" style="width: 100%" :disabled="disabled" />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="纬度" v-bind="validateInfos.latitude">
<a-input-number v-model:value="formData.latitude" placeholder="请输入纬度" style="width: 100%" :disabled="disabled" />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="高度" v-bind="validateInfos.height">
<a-input-number v-model:value="formData.height" placeholder="请输入高度" style="width: 100%" :disabled="disabled" />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="偏航角" v-bind="validateInfos.yaw">
<a-input-number v-model:value="formData.yaw" placeholder="请输入偏航角" style="width: 100%" :disabled="disabled" />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="俯仰角" v-bind="validateInfos.pitch">
<a-input-number v-model:value="formData.pitch" placeholder="请输入俯仰角" style="width: 100%" :disabled="disabled" />
</a-form-item>
</a-col>
<a-col :span="24">
<a-form-item label="翻转角" v-bind="validateInfos.roll">
<a-input-number v-model:value="formData.roll" placeholder="请输入翻转角" style="width: 100%" :disabled="disabled" />
</a-form-item>
</a-col>
</a-row>
</a-form>
</a-spin>
</template>
<script lang="ts" setup>
import { ref, reactive, nextTick, computed, onMounted } from 'vue';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
// import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
import { getValueType } from '/@/utils';
import { saveOrUpdate } from '../MsCameraSite.api';
import { Form } from 'ant-design-vue';
import EarthMapModal from '@/views/military/modules/earthMap/scene/model/mapModel/EarthMapModal.vue';
import locationPng from '@/assets/images/getLocation.png';
import { useUserStore } from '/@/store/modules/user';
import EarthComp from '@/views/earthMap/edit/EarthComp.vue';
const userStore = useUserStore();
const lineSelect: any = ref([]);
const props = defineProps({
formDisabled: { type: Boolean, default: false },
formData: { type: Object, default: () => {} },
formBpm: { type: Boolean, default: true },
});
const formRef = ref();
const useForm = Form.useForm;
const emit = defineEmits(['register', 'ok']);
const formData = reactive<Record<string, any>>({
id: undefined,
lineId: undefined,
sitecode: '',
sitename: '',
longitude: undefined,
latitude: undefined,
height: undefined,
yaw: undefined,
pitch: undefined,
roll: undefined,
});
const { createMessage } = useMessage();
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
const confirmLoading = ref<boolean>(false);
//
const validatorRules = {
sitecode: [{ required: true, message: '请输入点位序号!' }],
sitename: [{ required: true, message: '请输入点位名称!' }],
longitude: [{ required: true, message: '请输入经度!' }],
latitude: [{ required: true, message: '请输入纬度!' }],
lineId: [{ required: true, message: '请选择所属防区!' }],
};
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true });
//
const disabled = computed(() => {
if (props.formBpm === true) {
if (props.formData.disabled === false) {
return false;
} else {
return true;
}
}
return props.formDisabled;
});
onMounted(() => {
setSelectList();
});
//线
function setSelectList() {
// defHttp
// .get(
// {
// url: '/military/msMapLine/mapLineSelect',
// },
// { isTransformResponse: false }
// )
// // getAction(this.url.querySelectList, {})
// .then((res) => {
// if (res.success) {
// lineSelect.value = res.result;
// }
// });
defHttp
.get(
{
url: '/military/msMapLine/list',
params: {
sceneId: userStore.userInfo?.sceneId + "*"
},
},{ isTransformResponse: false })
.then((res) => {
if (res.success) {
lineSelect.value = res.result.records;
}
});
}
/**
* 新增
*/
function add() {
edit({});
}
/**
* 编辑
*/
function edit(record) {
nextTick(() => {
resetFields();
//
Object.assign(formData, record);
});
}
/**
* 提交数据
*/
async function submitForm() {
//
await validate();
confirmLoading.value = true;
const isUpdate = ref<boolean>(false);
//
let model = formData;
if (model.id) {
isUpdate.value = true;
}
//
for (let data in model) {
//
if (model[data] instanceof Array) {
let valueType = getValueType(formRef.value.getProps, data);
//
if (valueType === 'string') {
model[data] = model[data].join(',');
}
}
}
await saveOrUpdate(model, isUpdate.value)
.then((res) => {
if (res.success) {
createMessage.success(res.message);
emit('ok');
} else {
createMessage.warning(res.message);
}
})
.finally(() => {
confirmLoading.value = false;
});
}
function changeLineValue(item, option) {
formData.lineId = option.key;
}
//
const mapVisible = ref(false);
const mapModel = ref();
const mapShow = function () {
mapModel.value = {
custom: {
id: formData.id,
},
czmObject: {
name: formData.sitename,
xbsjType: 'Model',
url: '/dt/sys/common/static/' + formData.modelUrl,
// "color": [0.52, 0.6, 0.58, 1],
minimumPixelSize: formData.minimumPixelSize,
// maximumScale: 0.02,
scale: formData.scale,
xbsjScale: formData.xyzScale ? formData.xyzScale.split(',') : [1, 1, 1],
xbsjPosition: [window.Cesium.Math.toRadians(formData.longitude), window.Cesium.Math.toRadians(formData.latitude), formData.height],
xbsjRotation: [
window.Cesium.Math.toRadians(formData.yaw),
window.Cesium.Math.toRadians(formData.pitch),
window.Cesium.Math.toRadians(formData.roll),
],
viewDistance: 150,
distanceDisplayCondition: [1.0, 30000.0],
},
};
mapVisible.value = true;
};
const checkPosition = function (position, rotation, fov) {
const CMath = window.Cesium.Math;
formData.longitude = CMath.toDegrees(position[0]);
formData.latitude = CMath.toDegrees(position[1]);
formData.height = CMath.toDegrees(position[2]);
formData.yaw = CMath.toDegrees(rotation[0]);
formData.pitch = CMath.toDegrees(rotation[1]);
formData.roll = CMath.toDegrees(rotation[2]);
// subObject.value.viewDistance = fov;
};
const earthMapModal: any = ref(null);
//
const moveChinaPosition = function () {
earthMapModal.value.CModel.czmObject.flyTo();
// const CMath = window.Cesium.Math;
// window.earth.camera.position = [CMath.toRadians(formData.longitude) - 0.000001, CMath.toRadians(formData.latitude) - 0.000001, CMath.toRadians(formData.height) - 0.000001];
// window.earth.camera.rotation = [CMath.toRadians(formData.yaw), CMath.toRadians(formData.pitch), CMath.toRadians(formData.roll)]
};
const earth = ref()
function destroyed() {
// console.log("earth", earth.value);
earth.value.destroy();
nextTick(() => {
mapVisible.value = false
})
}
defineExpose({
add,
edit,
submitForm,
earth,
destroyed
});
</script>
<style lang="less" scoped>
.antd-modal-form {
min-height: 500px !important;
overflow-y: auto;
padding: 24px 24px 24px 24px;
}
.dwImg {
width: 32px;
height: 32px;
}
</style>

4
src/views/military/modules/earthMap/msMapLine/components/MsMapLineForm.vue

@ -96,10 +96,10 @@
</a-form>
<a-modal title="绘制区域" :visible="mapVisible" @cancel="destroyed" width="60vw" destroyOnClose wrapClassName="EarthMap">
<a-modal title="绘制区域" :visible="mapVisible" @ok="destroyed" @cancel="destroyed" width="60vw" destroyOnClose wrapClassName="EarthMap">
<a-row style="height: 60vh;">
<a-col :span="24">
<EarthComp ref="earth" :addAreaHandler=true />
<EarthComp ref="earth" :msMapLineHandler=true />
</a-col>
</a-row>
</a-modal>

827
src/views/military/modules/earthMap/scene/model/mapModel/EarthMapModal copy.vue

@ -1,827 +0,0 @@
<template>
<a-modal :title="title" :visible="visible" @ok="handleOk" @cancel="handleCancel" width="60vw" :destroyOnClose="true"
wrapClassName="EarthMap">
<a-row>
<a-col :span="24">
<div id="earthContainer" :style="{ cursor: cursorCss }"></div>
<!-- <span class="mapManage" @click="() => { mapManageShow = !mapManageShow }">
<a-icon type="setting" theme="filled" />
</span> -->
<span :class="['scaleWin', 'iconSpan', scaleWin.status ? 'colorBlue' : '']" title="放大或缩小" @click="scaleWinFunc">
<ExpandOutlined v-if="!scaleWin.status" />
<CompressOutlined v-else />
</span>
<span :class="['mapModel', 'iconSpan']" @click="modelChange" title="地图维度切换">
{{ modelText == "2D" ? "3D" : "2D" }}
</span>
<template v-if="editTileModel != undefined && modelText == '3D'">
<span class="buildManage iconSpan" @click="enableTileChange" title="建筑加载">
<img src="../../../../../../../assets/images/build_close.png" class="iconSize" v-show="!enableTile" />
<img src="../../../../../../../assets/images/build_able.png" class="iconSize" v-show="enableTile" />
</span>
<span class="modelDw iconSpan" @click="modelDwFunc" title="模型跟随鼠标">
<img src="../../../../../../../assets/images/dw_close.png" class="iconSize" v-show="!modelDw" />
<img src="../../../../../../../assets/images/dw_able.png" class="iconSize" v-show="modelDw" />
</span>
<span class="modelMove iconSpan" @click="modelMoveFunc" title="模型移动">
<img src="../../../../../../../assets/images/move_close.png" class="iconSize" v-show="!modelMove" />
<img src="../../../../../../../assets/images/move_able.png" class="iconSize" v-show="modelMove" />
</span>
<span class="modelRotation iconSpan" @click="modelRotationFunc" title="模型旋转">
<img src="../../../../../../../assets/images/rotation_close.png" class="iconSize" v-show="!modelRotation" />
<img src="../../../../../../../assets/images/rotation_able.png" class="iconSize" v-show="modelRotation" />
</span>
<span class="modelScale iconSpan" title="缩放">
<a-tooltip placement="left" trigger="click"
:getPopupContainer="(triggerNode) => { return triggerNode.parentElement }">
<img src="../../../../../../../assets/images/scale_close.png" class="iconSize" v-show="!modelScaleStatus"
@click="modelScaleStatusChange" />
<img src="../../../../../../../assets/images/scale_able.png" class="iconSize" v-show="modelScaleStatus"
@click="modelScaleStatusChange" />
<template #title>
<div class="sliderContainer">
<a-row class="sliderRow">
<a-col :span="4">
X轴:
</a-col>
<a-col :span="11">
<a-slider v-model:value="scaleValues[0]" :min="scaleConfig.X.min" :max="scaleConfig.X.max"
:step="scaleConfig.X.step" />
</a-col>
<a-col :span="6">
<a-input-number v-model:value="scaleValues[0]" :min="scaleConfig.X.min" :max="scaleConfig.X.max"
:step="scaleConfig.X.step" style="width:100%"></a-input-number>
</a-col>
<a-col :span="2" :offset="1" @click="() => { scaleConfig.X.show = !scaleConfig.X.show }">
<SettingOutlined :style="{ color: scaleConfig.X.show ? '#1296db' : '#FFF' }" />
</a-col>
</a-row>
<a-row v-show="scaleConfig.X.show" type="flex" justify="space-around" align="middle" :gutter="[0, 12]">
<a-col :span="8">
最小值:
</a-col>
<a-col :span="16">
<a-input-number v-model:value="scaleConfig.X.min" class="fill-9-row"></a-input-number>
</a-col>
<a-col :span="8">
最大值:
</a-col>
<a-col :span="16">
<a-input-number v-model:value="scaleConfig.X.max" class="fill-9-row"></a-input-number>
</a-col>
<a-col :span="8">
步长:
</a-col>
<a-col :span="16">
<a-input-number v-model:value="scaleConfig.X.step" class="fill-9-row"></a-input-number>
</a-col>
<a-col :span="24" class="sliderRow">
<a-button type="primary" class="fill-9-row" @click="() => { allSetting('X') }">应用全部</a-button>
</a-col>
</a-row>
<a-row class="sliderRow">
<a-col :span="4">
Y轴:
</a-col>
<a-col :span="11">
<a-slider v-model:value="scaleValues[1]" :min="scaleConfig.Y.min" :max="scaleConfig.Y.max"
:step="scaleConfig.Y.step" />
</a-col>
<a-col :span="6">
<a-input-number v-model:value="scaleValues[1]" :min="scaleConfig.Y.min" :max="scaleConfig.Y.max"
:step="scaleConfig.Y.step" style="width:100%"></a-input-number>
</a-col>
<a-col :span="2" :offset="1" @click="() => { scaleConfig.Y.show = !scaleConfig.Y.show }">
<SettingOutlined :style="{ color: scaleConfig.X.show ? '#1296db' : '#FFF' }" />
</a-col>
</a-row>
<a-row v-show="scaleConfig.Y.show" type="flex" justify="space-around" align="middle" :gutter="[0, 12]">
<a-col :span="8">
最小值:
</a-col>
<a-col :span="16">
<a-input-number v-model:value="scaleConfig.Y.min" class="fill-9-row"></a-input-number>
</a-col>
<a-col :span="8">
最大值:
</a-col>
<a-col :span="16">
<a-input-number v-model:value="scaleConfig.Y.max" class="fill-9-row"></a-input-number>
</a-col>
<a-col :span="8">
步长:
</a-col>
<a-col :span="16">
<a-input-number v-model:value="scaleConfig.Y.step" class="fill-9-row"></a-input-number>
</a-col>
<a-col :span="24" class="sliderRow">
<a-button type="primary" class="fill-9-row" @click="() => { allSetting('Y') }">应用全部</a-button>
</a-col>
</a-row>
<a-row class="sliderRow">
<a-col :span="4">
Z轴:
</a-col>
<a-col :span="11">
<a-slider v-model:value="scaleValues[2]" :min="scaleConfig.Z.min" :max="scaleConfig.Z.max"
:step="scaleConfig.Z.step" />
</a-col>
<a-col :span="6">
<a-input-number v-model:value="scaleValues[2]" :min="scaleConfig.Z.min" :max="scaleConfig.Z.max"
:step="scaleConfig.Z.step" style="width:100%"></a-input-number>
</a-col>
<a-col :span="2" :offset="1" @click="() => { scaleConfig.Z.show = !scaleConfig.Z.show }">
<SettingOutlined :style="{ color: scaleConfig.X.show ? '#1296db' : '#FFF' }" />
</a-col>
</a-row>
<a-row v-show="scaleConfig.Z.show" type="flex" justify="space-around" align="middle" :gutter="[0, 12]">
<a-col :span="8">
最小值:
</a-col>
<a-col :span="16">
<a-input-number v-model:value="scaleConfig.Z.min" class="fill-9-row"></a-input-number>
</a-col>
<a-col :span="8">
最大值:
</a-col>
<a-col :span="16">
<a-input-number v-model:value="scaleConfig.Z.max" class="fill-9-row"></a-input-number>
</a-col>
<a-col :span="8">
步长:
</a-col>
<a-col :span="16">
<a-input-number v-model:value="scaleConfig.Z.step" class="fill-9-row"></a-input-number>
</a-col>
<a-col :span="24" class="sliderRow">
<a-button type="primary" class="fill-9-row" @click="() => { allSetting('Z') }">应用全部</a-button>
</a-col>
</a-row>
</div>
</template>
</a-tooltip>
</span>
</template>
</a-col>
</a-row>
</a-modal>
</template>
<script setup>
import { toRefs, watch, nextTick, ref, reactive, onMounted, getCurrentInstance } from 'vue';
import { message } from 'ant-design-vue';
import { useEarthMapStore } from '/@/store/modules/earthMap';
import rotationXYZ from '@/assets/images/rotationXYZ.png';
import { defHttp } from '@/utils/http/axios';
import { FormatPainterOutlined, SettingOutlined, ExpandOutlined, GatewayOutlined, ZoomInOutlined, ZoomOutOutlined, CompressOutlined } from '@ant-design/icons-vue';
// import dwPng from '/@/assets/images/dwPng.png';
import dwPng from '@/assets/images/rotationXYZ.png';
import { drawPolygonSave, drawGeoSmoothPolygon } from "@/utils/earthMap/earthDraw";
const store = useEarthMapStore();
const { proxy } = getCurrentInstance();
//
const getMapPage = (params) => defHttp.get({ url: "/military/msMapManage/list/page", params: params }, { isTransformResponse: false });
//
const cursorCss = ref("grab");
const props = defineProps(['title', 'visible', 'hasMoveMethod', 'initModeType', 'editTileModel', 'enableTile', 'enablePointer']);
const { title, visible, hasMoveMethod, initModeType, editTileModel, enablePointer } = toRefs(props);
//
const enableTile = ref(props.enableTile);
const pointerXyz = ref([]);
const defaultPinUrl = "../";
const emit = defineEmits(["closeWin", "checkPosition", "moveChinaPosition"])
//
const handleOk = function () {
let position = null;
let rotation = null;
let fov = null;
if (CModel.value) {
position = [...CModel.value.czmObject.xbsjPosition];
rotation = [...CModel.value.czmObject.xbsjRotation];
emit("checkPosition", position, rotation, [...scaleValues.value]);
} else {
let cposition = [window.earth.camera.position[0], window.earth.camera.position[1], window.earth.camera.position[2]];
if (pin) {
position = [pin.position[0], pin.position[1], pin.position[2]];
}
rotation = [window.earth.camera.rotation[0], window.earth.camera.rotation[1], window.earth.camera.rotation[2]];
fov = window.earth.camera.fov;
emit("checkPosition", position, cposition, rotation, fov);
}
handleCancel();
}
const handleCancel = function () {
emit("closeWin");
}
//
let earth = undefined;
let _viewer = undefined;
watch(
visible, async (value, oldValue) => {
//
if (value) {
await nextTick()
//
window.XE.ready().then(() => {
//
return window.XE.HTML.loadJS('/earthsdk/XbsjEarth-Plugins/plottingSymbol/plottingSymbol.js');
}).then(async () => {
earth = new window.XE.Earth('earthContainer');
window.earth = window.$earth = earth
window.$viewer = _viewer = window.earth.czm.viewer;
initMode();
listenMouseHandler();
listenMouseHandlerSelect();
addContainerClickListen();
await getDataSource();
moveChinaPosition();
});
} else {
//
destroyCache();
}
}
)
const mapManageShow = ref(false);
const modelText = ref('2D');
const modelChange = function () {
const viewer = window.earth.czm.viewer;
if (modelText.value == '3D') {
// 2D
// const loyauts = window.earth.sceneTree.$refs["loyauts"].children;
// loyauts.forEach(loyaut => {
// loyaut.enabled = false;
// });
modelText.value = "2D";
enableTile.value = false;
if (CModel.value) {
// CModel.value.show = false;
if (modelDw.value) {
modelDwFunc();
}
if (modelMove.value) {
modelMoveFunc();
}
if (modelRotation.value) {
modelRotationFunc();
}
}
viewer.scene.morphTo2D(0)
} else {
viewer.scene.morphTo3D(0)
modelText.value = "3D";
}
}
const enableTileChange = function () {
if (modelText.value != "3D") {
message.info("2D切片。若要加载切片,请切换至3D模式!")
return;
}
enableTile.value = !enableTile.value;
}
const initMode = function () {
const viewer = window.earth.czm.viewer;
// initModeType2D
if (!initModeType.value) {
modelText.value = "3D"
viewer.scene.morphTo3D(0)
return;
}
// 2D
if (initModeType.value == "2D") {
modelText.value = "3D"
viewer.scene.morphTo2D(0)
} else if (initModeType.value == "3D") {
// 3D
modelText.value = "3D"
viewer.scene.morphTo3D(0)
}
}
const CModel = ref(null);
//
const editTileModelFunc = function (root) {
//
if (!editTileModel || !editTileModel.value) {
return;
}
//
const modelObj = {
ref: editTileModel.value.custom.id,
czmObject: editTileModel.value.czmObject,
enabled: true,
}
//
root.push(modelObj);
//
CModel.value = window.earth.sceneTree.$refs[editTileModel.value.custom.id];
//
CModel.value.enabled = true;
CModel.value.czmObject.enabled = true;
//
scaleValues.value = [...CModel.value.czmObject.xbsjScale];
}
const moveChinaPosition = function () {
// moveChinaPosition
if (hasMoveMethod.value) {
emit('moveChinaPosition');
} else {
//
window.earth.camera.fov = 1.0471975511965976;
window.earth.camera.position = [1.8833961240252113, 0.6131398723508994, 8921610.846366767];
window.earth.camera.rotation = [6.283185307179586, -1.5704896980852325, 0]
}
}
let viewer = undefined;
//
const cssGrab = function (e) {
const buttonNum = e.button;
if (buttonNum == 0) {
cursorCss.value = `grabbing`;
} else if (buttonNum == 1) {
cursorCss.value = `${rotationXYZ}`;
}
}
//
const addContainerClickListen = function () {
const dom = document.getElementById("earthContainer");
dom.addEventListener("mousedown", cssGrab, true)
// dom.addEventListener("mouseup", cssGrab)
}
//
const modelFollowMouse = (event) => {
if (CModel.value && modelText.value == "3D") {
if (CModel.value.enabled == false) {
CModel.value.enabled = true;
}
//
//
let cartesian = viewer.scene.globe.pick(viewer.camera.getPickRay(event.endPosition), viewer.scene);
if (!cartesian) {
return;
}
//
let ellipsoid = viewer.scene.globe.ellipsoid;
let cartographic = ellipsoid.cartesianToCartographic(cartesian);
let lon = cartographic.longitude; //
let lat = cartographic.latitude; //
// let alt = cartographic.height; //
let alt = 0; //
CModel.value.czmObject.xbsjPosition = [lon, lat, alt];
}
}
let pin = undefined;
//
const listenMouseHandler = function () {
viewer = window.earth.czm.viewer;
window.viewer = viewer;
window.earth.interaction.picking.enabled = true;
window.earth.interaction.picking.clickedColor = [1, 0, 0, 1];
const handler = new window.Cesium.ScreenSpaceEventHandler(
viewer.scene.canvas
);
window.CesiumGlobalHandler = handler;
//
viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(
window.Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK
);
// handler.setInputAction(modelFollowMouse, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
if (enablePointer.value) {
viewer.cesiumWidget.screenSpaceEventHandler.setInputAction((event) => {
let cartesian = viewer.scene.globe.pick(viewer.camera.getPickRay(event.position), viewer.scene);
if (!cartesian) {
return;
}
//
let ellipsoid = viewer.scene.globe.ellipsoid;
let cartographic = ellipsoid.cartesianToCartographic(cartesian);
//
let pointLon = Cesium.Math.toDegrees(cartographic.longitude); //
let pointLat = Cesium.Math.toDegrees(cartographic.latitude); //
let pointAlt = cartographic.height; //
console.log("点击的的经纬度坐标是:", {
"经度:": pointLon,
"纬度:": pointLat
});
pin && pin.destroy();
pin = new window.XE.Obj.Pin(window.earth);
pin.position = [cartographic.longitude, cartographic.latitude, pointAlt];
pin.imageUrl = dwPng;
},
window.Cesium.ScreenSpaceEventType.LEFT_CLICK
);
}
// /* */
handler.setInputAction((event) => {
handler.removeInputAction(window.Cesium.ScreenSpaceEventType.MOUSE_MOVE)
modelDw.value = false;
if (clearId != null) {
clearTimeout(clearId);
clearId = null;
}
cursorCss.value = `grabbing`;
}, window.Cesium.ScreenSpaceEventType.LEFT_DOWN);
handler.setInputAction((event) => {
if (clearId != null) {
clearTimeout(clearId);
clearId = null;
}
cursorCss.value = `grab`;
}, window.Cesium.ScreenSpaceEventType.LEFT_UP);
handler.setInputAction((event) => {
if (clearId != null) {
clearTimeout(clearId);
clearId = null;
}
cursorCss.value = `url(${rotationXYZ}),grab`;
}, window.Cesium.ScreenSpaceEventType.MIDDLE_DOWN);
handler.setInputAction((event) => {
if (clearId != null) {
clearTimeout(clearId);
clearId = null;
}
cursorCss.value = `grab`;
}, window.Cesium.ScreenSpaceEventType.MIDDLE_UP);
let clearId = null;
handler.setInputAction((event) => {
if (event > 0) {
cursorCss.value = `zoom-in`;
} else {
cursorCss.value = `zoom-out`;
}
clearId = setTimeout(() => {
clearTimeout(clearId);
cursorCss.value = `grab`
}, 2000);
}, window.Cesium.ScreenSpaceEventType.WHEEL);
// window.earth.onclick = function () {
// console.log(1);
// }
}
//-
const listenMouseHandlerSelect = function () {
// window.$earth.interaction.picking.enabled = true;
// window.$earth.interaction.picking.clickedColor = [1, 0, 0, 1];
const _handler = new window.Cesium.ScreenSpaceEventHandler(
_viewer.scene.canvas
);
// window.CesiumGlobalHandler = handler;
//
_viewer.cesiumWidget.screenSpaceEventHandler.removeInputAction(
window.Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK
);
_handler.setInputAction((click) => {
//
// `primitive`
let pickedFeature = _viewer.scene.pick(click.position);
// console.log("pick", pickedFeature);
let entity = pickedFeature && pickedFeature.id;
if (entity == undefined) { return; }
//
else if (typeof pickedFeature !== 'undefined' && entity.name == '区域选取') {
console.log("entity", entity);
//
entity.showProperty()
}
}, window.Cesium.ScreenSpaceEventType.RIGHT_CLICK); //
}
//
const getDataSource = async function () {
const params = {
pageNo: 1,
pageSize: 9999,
status: 1,
}
return getMapPage(params).then(
(res) => {
if (res.code == 200) {
const loyaut = {
ref: "loyauts",
expand: false,
title: "地图图层",
children: []
}
const records = res.result.records;
records.forEach(item => {
const czmObject = JSON.parse(item.czmObject);
const child = {
ref: item.id,
czmObject: czmObject,
enabled: true,
}
loyaut.children.push(child);
});
window.earth.sceneTree.root.children.push(loyaut);
const loyauts = window.earth.sceneTree.$refs["loyauts"].children;
editTileModelFunc(loyauts);
//
watch([modelText, enableTile], ([newVal, newVal1], [oldValue, oldValue1]) => {
// 3D
if (newVal == "3D" && newVal1) {
loyauts.forEach(loyaut => {
if (loyaut.czmObject.xbsjType == "Tileset") {
loyaut.enabled = true;
}
if (CModel.value) {
CModel.value.enabled = true;
}
});
} else if (newVal == "2D" || !newVal1) {
// 3D
loyauts.forEach(loyaut => {
if (loyaut.czmObject.xbsjType == "Tileset") {
loyaut.enabled = false;
}
if (CModel.value) {
CModel.value.enabled = false;
}
});
}
})
} else {
message.error("无法显示数据!");
}
}
).catch(
(e) => {
message.error("无法显示数据!");
}
)
}
//
const scaleWin = reactive({
status: false
})
const scaleWinFunc = function () {
const el = document.getElementsByClassName("EarthMap")[0].querySelector(".ant-modal-content");
if (!scaleWin.status) {
const width = window.innerWidth;
el.setAttribute("style", `width:${width}px;position:fixed;left:0;top:0;`);
scaleWin.status = true;
} else {
el.removeAttribute("style");
scaleWin.status = false;
}
}
//
const modelDw = ref(false);
const modelDwFunc = function (e) {
modelScaleStatus.value = false;
if (!modelDw.value) {
window.CesiumGlobalHandler.setInputAction(
modelFollowMouse, window.Cesium.ScreenSpaceEventType.MOUSE_MOVE
);
modelDw.value = true;
} else {
window.CesiumGlobalHandler.removeInputAction(window.Cesium.ScreenSpaceEventType.MOUSE_MOVE)
modelDw.value = false
}
}
//
const modelMove = ref(false);
const modelMoveFunc = function (e) {
if (!CModel.value) {
return;
}
if (!modelMove.value) {
if (CModel.value.enabled == false) {
CModel.value.enabled = true;
}
CModel.value.czmObject.positionEditing = true;
modelRotation.value = false;
modelMove.value = true;
} else {
CModel.value.czmObject.positionEditing = false;
modelMove.value = false
}
}
//
const modelRotation = ref(false);
const modelRotationFunc = function (e) {
if (!CModel.value) {
return;
}
if (!modelRotation.value) {
if (CModel.value.enabled == false) {
CModel.value.enabled = true;
}
CModel.value.czmObject.rotationEditing = true;
modelMove.value = false;
modelRotation.value = true;
} else {
CModel.value.czmObject.rotationEditing = false;
modelRotation.value = false
}
}
//
const scaleValues = ref([1, 1, 1]);
const modelScaleStatus = ref(false);
//
const modelScaleStatusChange = function () {
modelScaleStatus.value = !modelScaleStatus.value;
}
//
const scaleConfigObj = {
X: {
min: -10,
max: 10,
step: 1,
show: false,
},
Y: {
min: -10,
max: 10,
step: 1,
show: false,
},
Z: {
min: -10,
max: 10,
step: 1,
show: false,
},
};
const scaleConfig = ref(
{
...scaleConfigObj
}
)
// xyz
const allSetting = function (propName) {
const keys = Object.keys(scaleConfig.value);
const beCopyObj = scaleConfig.value[propName];
keys.forEach(key => {
scaleConfig.value[key] = { ...beCopyObj, show: scaleConfig.value[key].show }
});
}
//
watch(scaleValues, (new_scale, scale) => {
if (!CModel.value || !CModel.value.czmObject) {
return;
}
CModel.value.czmObject.xbsjScale = new_scale;
}, {
deep: true
})
//
const destroyCache = function () {
scaleConfig.value = { ...scaleConfigObj };
scaleValues.value = [1, 1, 1];
modelRotation.value = false;
modelMove.value = false;
scaleWin.value = false;
modelScaleStatus.value = false;
modelDw.value = false;
enableTile.value = false;
// window.CesiumGlobalHandler.removeInputAction(window.Cesium.ScreenSpaceEventType.MOUSE_MOVE)
// window.CesiumGlobalHandler.removeInputAction(window.Cesium.ScreenSpaceEventType.LEFT_DOWN)
// window.CesiumGlobalHandler.removeInputAction(window.Cesium.ScreenSpaceEventType.LEFT_UP)
// window.CesiumGlobalHandler.removeInputAction(window.Cesium.ScreenSpaceEventType.MIDDLE_DOWN)
// window.CesiumGlobalHandler.removeInputAction(window.Cesium.ScreenSpaceEventType.MIDDLE_UP)
// window.CesiumGlobalHandler.removeInputAction(window.Cesium.ScreenSpaceEventType.WHEEL)
CModel.value && CModel.value.destroy();
earth && earth.destroy();
modelText.value = "2D";
scaleWin.status = false;
}
defineExpose(
{
CModel
}
);
</script>
<style scoped>
.fill-9-row {
width: 90%;
}
.sliderRow {
display: flex;
justify-content: center;
align-items: center;
min-height: 50px;
}
.sliderContainer {
width: 200px;
}
.iconSize {
width: 16px;
height: 16px;
}
.colorBlue {
color: #1296db !important;
}
.iconSpan {
color: #fff;
display: block;
width: 36px;
height: 36px;
font-size: 16px;
font-style: normal;
line-height: 36px;
text-align: center;
text-transform: none;
text-rendering: auto;
background-color: rgba(0, 0, 0, 0.4);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
}
.selectIcon {
position: absolute;
top: 108px;
left: 0;
}
.clearIcon {
position: absolute;
top: 144px;
left: 0;
}
.modelScale {
position: absolute;
top: 252px;
left: 0;
}
.modelRotation {
position: absolute;
top: 216px;
left: 0;
}
.modelMove {
position: absolute;
top: 180px;
left: 0;
}
.modelDw {
position: absolute;
top: 144px;
left: 0;
}
.scaleWin {
position: absolute;
top: 36px;
left: 0;
}
.mapModel {
position: absolute;
top: 72px;
left: 0;
}
.buildManage {
position: absolute;
top: 108px;
left: 0;
}
:deep(.ant-modal-body) {
padding: 0px !important;
}
:deep(.ant-modal-close-x) {
color: #fff;
background-color: rgba(0, 0, 0, 0.4);
width: 36px;
height: 36px;
line-height: 36px;
}
</style>
Loading…
Cancel
Save