From c954cdb51f93585b58b761c2663688c36e6b044f Mon Sep 17 00:00:00 2001 From: jihongshun <1151753686@qq.com> Date: 星期五, 15 八月 2025 17:13:54 +0800 Subject: [PATCH] 创建航线新增全局配置 --- src/views/system/project/components/addPorjectDialog.vue | 242 +++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 237 insertions(+), 5 deletions(-) diff --git a/src/views/system/project/components/addPorjectDialog.vue b/src/views/system/project/components/addPorjectDialog.vue index 217b3eb..df93c17 100644 --- a/src/views/system/project/components/addPorjectDialog.vue +++ b/src/views/system/project/components/addPorjectDialog.vue @@ -12,9 +12,11 @@ <div class="chooseModel"> <div class="fontJust">璁惧鍒楄〃</div> <el-button @click="addDevice"> 鏂板</el-button> + <el-button @click="lineSet"> 鑸嚎璁剧疆</el-button> <el-table :data="tableData" max-height = '180' + :row-key="getRowKeys" style="width: 100%"> <el-table-column prop="deviceName" @@ -45,6 +47,7 @@ <div class="fontJust">宸℃鐐圭洰褰�</div> <el-tree class="filter-tree" + node-key="id" :data="treeData" :props="defaultProps" default-expand-all @@ -64,6 +67,77 @@ </el-dialog> <chooseDeviceDialog v-if="showDevice" @cancel ='cancel' @dealChooseArr="dealChooseArr" ></chooseDeviceDialog> <chooseModelDialog v-if="showModel" @cancelModel ='cancelModel' @receiveModel="receiveModel" :deviceId="deviceId"></chooseModelDialog> + <el-drawer + title="鑸嚎璁剧疆" + :visible.sync="drawer" + direction="rtl"> + <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm"> + <el-form-item label="璧烽鐖崌" prop="region"> + <el-select v-model="ruleForm.region" placeholder="璇烽�夋嫨璧烽鐖崌"> + <el-option label="鍨傜洿" value="鍨傜洿"></el-option> + <el-option label="鍊炬枩" value="鍊炬枩"></el-option> + </el-select> + </el-form-item> + <el-form-item label="鍏ㄥ眬鑸嚎閫熷害" prop="region"> + <div class="speed-control"> + <el-input-number + v-model="ruleForm.speed" + :min="0" + :max="50" + :step="1" + controls-position="both" + @change="handleChange" + /> + <span class="unit">m/s</span> + </div> + </el-form-item> + <el-form-item label="璧烽閫熷害" prop="fly"> + <div class="speed-control"> + <el-input-number + v-model="ruleForm.flySpeed" + :min="0" + :max="50" + :step="1" + controls-position="both" + @change="handleChange" + /> + <span class="unit">m/s</span> + </div> + </el-form-item> + <el-form-item label="鑸偣绫诲瀷" prop="region1"> + <el-select v-model="ruleForm.region1" placeholder="璇烽�夋嫨鑸偣绫诲瀷"> + <el-option label="鍗忚皟杞集锛屼笉杩囩偣锛屾彁鍓嶈浆寮�" value="鍗忚皟杞集锛屼笉杩囩偣锛屾彁鍓嶈浆寮�"></el-option> + <el-option label="鐩寸嚎椋炶锛岄琛屽櫒鍒扮偣鍋�" value="鐩寸嚎椋炶锛岄琛屽櫒鍒扮偣鍋�"></el-option> + <el-option label="骞虫粦杩囩偣锛屾彁鍓嶈浆寮�" value="骞虫粦杩囩偣锛屾彁鍓嶈浆寮�"></el-option> + </el-select> + </el-form-item> + <el-form-item label="椋炶鍣ㄥ亸鑸妯″紡" prop="region2"> + <el-select v-model="ruleForm.region2" placeholder="璇烽�夋嫨椋炶鍣ㄥ亸鑸妯″紡"> + <el-option label="娌胯埅绾挎柟鍚�" value="娌胯埅绾挎柟鍚�"></el-option> + <el-option label="鎵嬪姩鎺у埗" value="鎵嬪姩鎺у埗"></el-option> + <el-option label="閿佸畾褰撳墠鍋忚埅瑙�" value="閿佸畾褰撳墠鍋忚埅瑙�"></el-option> + </el-select> + </el-form-item> + <el-form-item label="鑸偣闂翠簯鍙颁刊浠拌鎺у埗妯″紡" prop="region3"> + <el-select v-model="ruleForm.region3" placeholder="璇烽�夋嫨鑸偣闂翠簯鍙颁刊浠拌鎺у埗妯″紡"> + <el-option label="鎵嬪姩鎺у埗" value="鎵嬪姩鎺у埗"></el-option> + <el-option label="渚濈収姣忎釜鑸偣璁剧疆" value="渚濈収姣忎釜鑸偣璁剧疆"></el-option> + </el-select> + </el-form-item> + <el-form-item label="瀹屾垚鍔ㄤ綔" prop="region4"> + <el-select v-model="ruleForm.region4" placeholder="璇烽�夋嫨瀹屾垚鍔ㄤ綔"> + <el-option label="鑷姩杩旇埅" value="鑷姩杩旇埅"></el-option> + <el-option label="杩斿洖鑸嚎璧峰鐐规偓鍋�" value="杩斿洖鑸嚎璧峰鐐规偓鍋�"></el-option> + <el-option label="閫�鍑鸿埅绾挎ā寮�" value="閫�鍑鸿埅绾挎ā寮�"></el-option> + <el-option label="鍘熷湴闄嶈惤" value="鍘熷湴闄嶈惤"></el-option> + </el-select> + </el-form-item> + <el-form-item> + <el-button type="primary" @click="submitForm('ruleForm')">淇濆瓨</el-button> + <el-button @click="resetForm('ruleForm')">鍙栨秷</el-button> + </el-form-item> + </el-form> + </el-drawer> </div> </template> <script> @@ -72,6 +146,7 @@ import chooseModelDialog from './chooseModelDialog.vue'; import { obtainRealData ,buildKmz} from "@/api/system/template" let rotationAngle = Cesium.Math.toRadians(0) +let lastConnectPolyline export default{ components: { CesiumMap, @@ -90,7 +165,13 @@ showDevice:false, multipleSelection: [], showModel:false, - deviceId:null + deviceId:null, + drawer:false, + ruleForm:{ + speed:14, + flySpeed:15 + }, + } }, methods:{ @@ -178,14 +259,60 @@ })); }, deleteData(row){ + console.log(row) // 鎵惧埌 id 涓� "1" 鐨勫厓绱犵储寮� const index = this.tableData.findIndex(item => item.id === row.id); // 濡傛灉鎵惧埌浜嗭紝鍒犻櫎璇ュ厓绱� if (index !== -1) { this.tableData.splice(index, 1); } - const dealTreeData = this.dealTee() - this.treeData = dealTreeData + const indexTree = this.treeData.findIndex(item => item.id === row.id); + // 濡傛灉鎵惧埌浜嗭紝鍒犻櫎璇ュ厓绱� + if (index !== -1) { + this.treeData.splice(indexTree, 1); + } + if(this.treeData?.length >=2 && this.treeData[0]?.children?.length > 0 && this.treeData[1]?.children?.length > 0 ) { + this.dealAddHeight() + } else if(this.treeData?.length ==1) { + this.treeData.map((device,index) => { + // 纭繚璁惧鏈塩hildren鏁扮粍 + if(index == 0) { + //绗竴涓暟鎹� + if (device.children && Array.isArray(device.children) && device.children.length > 0) { + // 鑾峰彇鏈�鍚庝竴涓┖涓偣 + const lastChild = device.children[device.children.length - 1]; + const firstChild = device.children[0]; + // 娣辨嫹璐濇渶鍚庝竴涓厓绱狅紙鍖呮嫭宓屽鐨刢hildren锛� + const newChildJson = JSON.parse(JSON.stringify(lastChild)); + // 娣辨嫹璐濇渶涓�涓�涓厓绱狅紙鍖呮嫭宓屽鐨刢hildren锛� + const firstChildJson = JSON.parse(JSON.stringify(firstChild)); + + if(newChildJson && newChildJson.label.includes('鍔犻珮')){ + device.children?.pop(newChild); + }else if(firstChildJson && firstChildJson.label.includes('鍔犻珮')) { + device.children?.shift(firstChildJson); + } + // 娣诲姞鍒癱hildren鏁扮粍鏈熬 + } + } + }) + } + const entitiesToRemove = []; + viewer.entities.values.forEach(entity => { + if (entity.id && entity.id.includes(row.id)) { + entitiesToRemove.push(entity.id); + } + }); + entitiesToRemove.forEach(id => { + viewer.entities.removeById(id); + }); + this.drawConnectionsWithLabels(this.treeData) + // console.log(this.tableData) + console.log(this.treeData) + // const dealTreeData = this.dealTee() + // console.log(dealTreeData) + // this.treeData = dealTreeData + // this.drawConnectionsWithLabels(this.treeData) }, chooseModel(row){ this.deviceId = row.id @@ -203,14 +330,89 @@ obtainRealData(flightTemplateId,deviceId).then(res=>{ console.log(res) let treeDealData = this.transformFlightData(res.data?.coordinateSystemVoS || []) + console.log(treeDealData) this.dealTreeMerge(obj,treeDealData) + this.rotateAllPoints(this.treeData || [],res.data.longitude,res.data.latitude,res.data.height) + console.log(this.treeData) + if(this.treeData?.length >=2 && this.treeData[0]?.children?.length > 0 && this.treeData[1]?.children?.length > 0 ) { + this.dealAddHeight() + } + console.log(this.treeData) this.drawConnectionsWithLabels(this.treeData) }) // this.dealTreeMerge(obj) }, + dealAddHeight(){ + let currentLength = this.treeData.filter(item=>item.children)?.length || 0 + console.log(this.treeData) + console.log(currentLength) + this.treeData.map((device,index) => { + // 纭繚璁惧鏈塩hildren鏁扮粍 + if(index == 0) { + //绗竴涓暟鎹� + if (device.children && Array.isArray(device.children) && device.children.length > 0) { + // 鑾峰彇鏈�鍚庝竴涓┖涓偣 + const lastChild = device.children[device.children.length - 1]; + // 娣辨嫹璐濇渶鍚庝竴涓厓绱狅紙鍖呮嫭宓屽鐨刢hildren锛� + const newChild = JSON.parse(JSON.stringify(lastChild)); + if(newChild.label.includes('鍔犻珮')) { + + }else { + newChild.label = newChild.label + '-鍔犻珮' + // 楂樺害澧炲姞20 + // newChild.height += 20; + //濉旈珮 - 楂樺害 + 寰�涓婇澶氬皯绫� + newChild.height += (device.ardTowerModel?.modelHeight - newChild.height + 20) ; + console.log('push11111111111111') + // 娣诲姞鍒癱hildren鏁扮粍鏈熬 + device.children.push(newChild); + } + } + } + else if(index == currentLength -1) { + if (device.children && Array.isArray(device.children) && device.children.length > 0) { + // 鑾峰彇鏈�鍚庝竴涓┖涓偣 + const lastChild = device.children[0]; + // 娣辨嫹璐濇渶涓�涓�涓厓绱狅紙鍖呮嫭宓屽鐨刢hildren锛� + const newChild = JSON.parse(JSON.stringify(lastChild)); + if(newChild.label.includes('鍔犻珮')) { + }else { + newChild.label = newChild.label + '-鍔犻珮绗竴涓偣' + newChild.height += (device.ardTowerModel?.modelHeight - newChild.height + 20) ; + // 娣诲姞鍒癱hildren鏁扮粍鏈熬 + device.children.unshift(newChild); + } + + } + } else { + if (device.children && Array.isArray(device.children) && device.children.length > 0) { + // 鑾峰彇鏈�鍚庝竴涓┖涓偣 + const firstChild = device.children[0]; + const lastChild = device.children[device.children.length - 1]; + // 娣辨嫹璐濇渶涓�涓�涓厓绱狅紙鍖呮嫭宓屽鐨刢hildren锛� + const newFirstChild = JSON.parse(JSON.stringify(firstChild)); + const newLastChildChild = JSON.parse(JSON.stringify(lastChild)); + //楂樺害澧炲姞20 + if(newFirstChild.label.includes('鍔犻珮')) { + }else { + newFirstChild.label = newFirstChild.label + '-鍔犻珮' + newFirstChild.height += (device.ardTowerModel?.modelHeight - newFirstChild.height + 20) ; + device.children.unshift(firstChild); + } + if(newLastChildChild.label.includes('鍔犻珮')) { + }else { + newLastChildChild.label = newLastChildChild.label + '-鍔犻珮' + newLastChildChild.height += (device.ardTowerModel?.modelHeight - newLastChildChild.height + 20) ; + device.children.push(newLastChildChild); + } + } + } + }) + }, //杩斿洖鏁版嵁杞崲鏍戠粨鏋� transformFlightData(data) { + console.log(data) const result = []; data.forEach(item => { @@ -257,8 +459,27 @@ } }); }, + generateId() { + return 'id_' + Math.random().toString(36).substring(2, 10); + }, drawConnectionsWithLabels(devices) { + if(lastConnectPolyline) { + viewer.entities.remove(lastConnectPolyline) + lastConnectPolyline = null + } + // 鐩存帴鎿嶄綔EntityCollection锛堟帹鑽愶級 + const entitiesToRemove = []; + viewer.entities.values.forEach(entity => { + if (entity.id && entity.id.includes(this.deviceId)) { + entitiesToRemove.push(entity.id); + } + }); + + entitiesToRemove.forEach(id => { + viewer.entities.removeById(id); + }); const airPoints = []; + console.log(devices) devices.forEach(device => { if (!Array.isArray(device.children)) return; device.children.forEach(airPoint => { @@ -272,6 +493,7 @@ // 鉁� 娣诲姞绌轰腑鐐瑰疄浣撳拰 label viewer.entities.add({ position: airPos, + id:device.id +'airpoint' + this.generateId(), point: { pixelSize: 6, color: Cesium.Color.YELLOW @@ -301,6 +523,7 @@ // 鉁� 娣诲姞鍦伴潰鐐瑰疄浣撳拰 label viewer.entities.add({ + id:device.id +'groundpoint' + this.generateId(), position: groundPos, point: { pixelSize: 6, @@ -320,6 +543,7 @@ // 鉁� 钃濊壊铏氱嚎杩炴帴锛氱┖涓偣 鉃� 鍦伴潰鐐� viewer.entities.add({ + id:device.id +'polyline' + this.generateId(), polyline: { positions: [airPos, groundPos], width: 2, @@ -333,10 +557,10 @@ } }); }); - + console.log(airPoints) // 鉁� 榛勮壊瀹炵嚎杩炴帴鎵�鏈夌┖涓偣 if (airPoints.length > 1) { - viewer.entities.add({ + lastConnectPolyline = viewer.entities.add({ polyline: { positions: airPoints, width: 3, @@ -375,6 +599,7 @@ }; }); }); + console.log(newGround.children) return newGround; } @@ -396,6 +621,10 @@ const rotatedZ = localStartPoint.z; //聽Z杞村潗鏍囦繚鎸佷笉鍙� //聽灏嗘棆杞悗鐨勫眬閮ㄥ潗鏍囪浆鎹㈠洖涓栫晫鍧愭爣绯� return Cesium.Matrix4.multiplyByPoint(transformationMatrix,聽new聽Cesium.Cartesian3(rotatedX,聽rotatedY,聽rotatedZ),聽new聽Cesium.Cartesian3()); + }, + getRowKeys(row){ + console.log(row) + return row.id +this.generateId() }, submit(){ console.log(this.treeData) @@ -438,6 +667,9 @@ }) } }) + }, + lineSet(){ + this.drawer =true } } } -- Gitblit v1.9.3