From 993d7de6a866192ba86b055cf1b7ef3b9a82903c Mon Sep 17 00:00:00 2001 From: DIAMOND <276397553@qq.com> Date: Sat, 20 Jan 2024 10:57:51 +0800 Subject: [PATCH] =?UTF-8?q?MsMapLineForm=20=E7=BC=96=E8=BE=91=E7=BA=BF?= =?UTF-8?q?=E8=B7=AF=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/earthMap/Toolbar.vue | 84 +++++++++++-------- src/utils/earthMap/getLineInfo.ts | 2 +- .../msMapLine/components/MsMapLineForm.vue | 24 ++++-- 3 files changed, 70 insertions(+), 40 deletions(-) diff --git a/src/components/earthMap/Toolbar.vue b/src/components/earthMap/Toolbar.vue index 8342397..fa44b8b 100644 --- a/src/components/earthMap/Toolbar.vue +++ b/src/components/earthMap/Toolbar.vue @@ -1104,9 +1104,33 @@ addRadarComShow.value = true; } // 添加防区, msMapLineHandler标识 后台防区管理调用 - function addArea(msMapLineHandler = null) { + function addArea(msMapLineHandler: any = {}) { // console.log("添加防区",msMapLineHandler); - + let objConfig: any = {} + if (typeof msMapLineHandler === 'object' && Object.keys(msMapLineHandler).length != 0 && msMapLineHandler.create){ + //创建 -后台防区管理调用 + objConfig.from = "msMapLineHandler.create"; + } + else if (typeof msMapLineHandler === 'object' && Object.keys(msMapLineHandler).length != 0) { + //编辑 -后台防区管理调用 + //不是空对象,则为编辑状态 + // console.log("msMapLineHandler",msMapLineHandler); + let config = { + id: msMapLineHandler.id, + name: msMapLineHandler.name, + sceneId: msMapLineHandler.sceneId, + // guid: msMapLineHandler.lineCode, + loop: Boolean(msMapLineHandler.isLoop), + depthTest: Boolean(msMapLineHandler.isDepthCheck), + width: msMapLineHandler.width, + arcType: msMapLineHandler.interpolation, + positions: JSON.parse(msMapLineHandler.positions), + material: JSON.parse(msMapLineHandler.material), + from : "msMapLineHandler.edit" + } + return addPolyline(config) + } + $mitt.emit('drawShapeShow', { show: true, title: '防区创建工具', from: 'addArea' }); $mitt.on('addAreaFinished', (t: any) => { // console.log('addAreaFinished', t); @@ -1119,15 +1143,15 @@ if (n == false) { //面 - let positions: any = []; + // let positions: any = []; if (t._polygon) { - positions = t._polygon._polyline.positions; + objConfig.positions = t._polygon._polyline.positions; } //线 else if (t._polyline) { - positions = t._polyline.positions; + objConfig.positions = t._polyline.positions; } else { - positions = t.positions; + objConfig.positions = t.positions; } //销毁临时图形 @@ -1138,7 +1162,7 @@ * */ nextTick(() => { - addPolyline(positions,msMapLineHandler); + addPolyline(objConfig); }); } else { } @@ -1151,9 +1175,8 @@ } /** * @params 需要调用 addArea 方法进行绘图,获取坐标点position - * @params msMapLineHandler标识 后台防区管理调用 */ - function addPolyline(positions: any = null, msMapLineHandler:any =null) { + function addPolyline(objConf: any = null) { // console.log('positions', positions); @@ -1163,35 +1186,18 @@ const currentModel = new window.XE.Obj.Polyline(window.$earth); // 设置配置参数 const objConfig: any = { - positions: positions, + positions: objConf.positions, }; - - /** - * 后台防区管理调用 - * */ - // if (typeof msMapLineHandler === 'object' && Object.keys(msMapLineHandler).length != 0) { - // console.log("不是空对象,则为编辑状态"); - // //不是空对象,则为编辑状态 - // //数据融合 - // objConfig.loop = msMapLineHandler.isLoop; - // objConfig.depthTest = msMapLineHandler.isDepthCheck; - // objConfig.width = msMapLineHandler.width; - // objConfig.arcType = msMapLineHandler.interpolation; - // objConfig.positions = JSON.parse(msMapLineHandler.positions); - // objConfig.material = JSON.parse(msMapLineHandler.material); - // } + // 融合数据 + Object.assign(objConfig, objConf); + console.log("objConfig",objConfig); // 插入数据 currentModel.xbsjFromJSON(objConfig); - // console.log('currentModel', currentModel); + console.log('currentModel', currentModel); // 获取地图ui对象 const earthUI = window.$uia; - // console.log("msMapLineHandler",msMapLineHandler); - //后台防区管理调用,直接return终止 - if(msMapLineHandler){ - $mitt.emit('toMsMapLineForm',currentModel) - return - } + // 打开一个防区编辑ui窗体 earthUI.showPropertyWindow(currentModel); nextTick(() => { @@ -1236,8 +1242,13 @@ const xBtn = el.children[1].children[1]; // 设置确认按钮点击事件 okBtn.onclick = function () { - // console.log("currentModel",currentModel); - // return + + //后台防区管理调用,直接return终止 + if(currentModel.from == "msMapLineHandler.edit" || currentModel.from == "msMapLineHandler.create"){ + $mitt.emit('toMsMapLineForm',currentModel) + return + } + // 判断所属区域 if (!currentModel.sceneId) { createMessage.warning('请选择所属区域', 2); @@ -1398,6 +1409,11 @@ }; // 取消按钮 cancelBtn.onclick = xBtn.onclick = function () { + //后台防区管理调用,直接return终止 + if(currentModel.from == "msMapLineHandler.edit" || currentModel.from == "msMapLineHandler.create"){ + $mitt.emit('toMsMapLineForm') + return + } $mitt.off('windowCancel'); // 消耗当前窗体的dom节点 el.remove(); diff --git a/src/utils/earthMap/getLineInfo.ts b/src/utils/earthMap/getLineInfo.ts index cd36b73..df96783 100644 --- a/src/utils/earthMap/getLineInfo.ts +++ b/src/utils/earthMap/getLineInfo.ts @@ -14,7 +14,7 @@ import $ from 'jquery'; let userStore = useUserStore(); let store = useEarthMapStore(); export default function getLineInfo(models, type) { - // console.log("加载防区"); + console.log("加载防区"); return new Promise((resolve, reject) => { //请求线路信息 diff --git a/src/views/military/modules/earthMap/msMapLine/components/MsMapLineForm.vue b/src/views/military/modules/earthMap/msMapLine/components/MsMapLineForm.vue index 3de364d..b499860 100644 --- a/src/views/military/modules/earthMap/msMapLine/components/MsMapLineForm.vue +++ b/src/views/military/modules/earthMap/msMapLine/components/MsMapLineForm.vue @@ -95,11 +95,19 @@ - - + + - + @@ -175,7 +183,7 @@ const validatorRules = { isLoop: [{ required: true, message: '请选择是否首尾相连!' },], isDepthCheck: [{ required: true, message: '请选择是否深度检测!' },], width: [{ required: true, message: '请输入宽度!' },], - dashLength: [{ required: true, message: '请输入虚线长度!' },], + // dashLength: [{ required: true, message: '请输入虚线长度!' },], }; const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true }); @@ -342,7 +350,9 @@ function destroyed() { //赋值 function areaAssign(currentModel) { // 模型名称 - // formData.name = currentModel.name + formData.name = currentModel.name + // 场景区域 + formData.sceneId = currentModel.sceneId; // 线段编码 formData.lineCode = currentModel.guid // 首尾相连属性 @@ -417,7 +427,11 @@ onMounted(() => { $mitt.on('toMsMapLineForm', (currentModel: any) => { console.log("currentModel", currentModel); //赋值 + if(currentModel) areaAssign(currentModel) + nextTick(()=>{ + destroyed() + }) }) })