From 13f87b980adfcaa0a3f5b0854c75bdc7deec8301 Mon Sep 17 00:00:00 2001 From: xing <xingjs@qq.com> Date: 星期六, 25 二月 2023 09:35:47 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/components/MapView/mapMenuTop.vue | 224 ++++++++++++++++++++++++++----------------------------- 1 files changed, 107 insertions(+), 117 deletions(-) diff --git a/src/components/MapView/mapMenuTop.vue b/src/components/MapView/mapMenuTop.vue index 25f6627..7155efe 100644 --- a/src/components/MapView/mapMenuTop.vue +++ b/src/components/MapView/mapMenuTop.vue @@ -1,20 +1,14 @@ <template> <div class="menuBox"> - <el-form - :inline="true" - :model="menuTopFrom" - class="demo-form-inline" - > + <el-form :inline="true" :model="menuTopFrom" class="demo-form-inline"> <el-form-item> <el-select v-model="menuTopFrom.queryLayer" :title="treeChange" placeholder="璇烽�夋嫨..." + :popper-append-to-body="false" > - <el-option - :value="menuTopFrom.queryLayer" - style="height: 100%" - > + <el-option :value="menuTopFrom.queryLayer" style="height: 100%"> <div style="height: 200px; overflow: auto"> <el-tree :data="layerData" @@ -28,17 +22,16 @@ </el-tree> </div> <div style="margin-top: 5px"> - <el-button - size="small" - plain - @click="getCheckedNodes" - >纭</el-button> + <el-button size="small" plain @click="getCheckedNodes" + >纭</el-button + > <el-button size="small" type="info" plain @click="resetCheckedNodes" - >閲嶇疆</el-button> + >閲嶇疆</el-button + > </div> </el-option> </el-select> @@ -49,6 +42,7 @@ @change="changeValue($event)" v-model="menuTopFrom.queryType" placeholder="璇烽�夋嫨..." + :popper-append-to-body="false" > <el-option v-for="item in queryOption" @@ -75,17 +69,12 @@ > --> </el-form-item> <el-form-item> - <el-button - plain - size="small" - @click="getAttributeQuery" - >鏌ヨ</el-button> - <el-button - type="info" - size="small" - @click="clearQuery" - plain - >閲嶇疆</el-button> + <el-button plain size="small" @click="getAttributeQuery" + >鏌ヨ</el-button + > + <el-button type="info" size="small" @click="clearQuery" plain + >閲嶇疆</el-button + > </el-form-item> <!-- <el-form-item> <el-button @@ -99,72 +88,76 @@ @click="flyRemove" >鍙栨秷</el-button> </el-form-item> --> - </el-form> <queryinfo ref="queryinfo" /> </div> </template> - + <script> -import queryinfo from "../../views/Tools/queryinfo.vue" -import $ from 'jquery'; -import { inquiry_SelectTabs, inquiry_uploadShp, encr, dataLib_selectTabs } from '../../api/api.js'; -import { getToken } from '@/utils/auth'; -import * as turf from '@turf/turf'; +import queryinfo from "../../views/Tools/queryinfo.vue"; +import $ from "jquery"; +import { + inquiry_SelectTabs, + inquiry_uploadShp, + encr, + dataLib_selectTabs, +} from "../../api/api.js"; +import { getToken } from "@/utils/auth"; +import * as turf from "@turf/turf"; export default { components: { queryinfo }, data() { return { menuTopFrom: { - queryType: '', + queryType: "", }, treeChange: [], layerData: [ { id: 1, - label: '鍩虹鏁版嵁', - tabDesc: '鍩虹鏁版嵁', - value: 'BD', + label: "鍩虹鏁版嵁", + tabDesc: "鍩虹鏁版嵁", + value: "BD", children: [], }, { id: 2, - label: '涓氬姟鏁版嵁', - tabDesc: '涓氬姟鏁版嵁', - value: 'BS', + label: "涓氬姟鏁版嵁", + tabDesc: "涓氬姟鏁版嵁", + value: "BS", children: [], }, ], queryOption: [ { - value: 'point', - label: '鐐归��', + value: "point", + label: "鐐归��", }, { - value: 'polyline', - label: '绾块��', + value: "polyline", + label: "绾块��", }, { - value: 'rectangle', - label: '鐭╁舰', + value: "rectangle", + label: "鐭╁舰", }, { - value: 'circle', - label: '鍦嗗舰', + value: "circle", + label: "鍦嗗舰", }, { - value: 'polygon', - label: '澶氳竟褰�', + value: "polygon", + label: "澶氳竟褰�", }, { - value: 'inputFile', - label: '瀵煎叆閫夋嫨鑼冨洿', + value: "inputFile", + label: "瀵煎叆閫夋嫨鑼冨洿", }, ], defaultProps: { - children: 'children', - label: 'label', + children: "children", + label: "label", }, graphicLayer: null, flyEntity: null, @@ -172,38 +165,37 @@ }, mounted() { - this.menuTopFrom.queryType = 'rectangle'; + this.menuTopFrom.queryType = "rectangle"; this.getAllTable(); }, methods: { - changeValue(value) { var obj = {}; obj = this.queryOption.find(function (item) { return item.value === value; }); - if (obj.value == 'inputFile') { + if (obj.value == "inputFile") { this.getMenuTopFile(); } }, async getAllTable() { const data = await dataLib_selectTabs({ pageIndex: 1, - pageSize: 500 + pageSize: 500, }); if (data.code != 200) { - this.$message.error('鍒楄〃璋冪敤澶辫触'); + this.$message.error("鍒楄〃璋冪敤澶辫触"); } var option = data.result.filter((res) => { if (res.rows != 0) { return res; } - }) + }); for (var i in option) { var val_Data = option[i]; - val_Data.id = '1' + i; + val_Data.id = "1" + i; val_Data.label = val_Data.tabDesc; - if (option[i].ns == 'bd') { + if (option[i].ns == "bd") { this.layerData[0].children.push(val_Data); } else { this.layerData[1].children.push(val_Data); @@ -225,18 +217,17 @@ this.treeChange = []; this.menuTopFrom.queryLayer = null; this.$refs.tree.setCheckedKeys([]); - }, //瀵煎叆shp鏂囦欢 async setMenuTopFile() { - var val = document.getElementById('getMenuTopFile').files; + var val = document.getElementById("getMenuTopFile").files; if (!val || !val.length) return; var formData = new FormData(); - var exts = ['.shp', '.shx', '.dbf', '.prj']; + var exts = [".shp", ".shx", ".dbf", ".prj"]; var count = 0; for (var i = 0; i < val.length; i++) { var name = val[i].name.toLocaleLowerCase(); - var ext = name.substring(name.lastIndexOf('.')); + var ext = name.substring(name.lastIndexOf(".")); if (exts.indexOf(ext) > -1) { count++; formData.append(val[i].name, val[i]); // fs.files[i].name,file @@ -244,15 +235,14 @@ } if (count != 4) { - this.$message({ - message: 'ShapeFile鏂囦欢閫夋嫨涓嶅叏锛�', - type: 'warning' + message: "ShapeFile鏂囦欢閫夋嫨涓嶅叏锛�", + type: "warning", }); return; } - $.ajax(BASE_URL + '/inquiry/uploadShp?token=' + getToken(), { - type: 'post', + $.ajax(BASE_URL + "/inquiry/uploadShp?token=" + getToken(), { + type: "post", data: formData, async: true, cache: false, @@ -260,9 +250,9 @@ contentType: false, success: (rs) => { if (rs.code !== 200) { - return this.$message.error('鐢ㄦ埛瑙掕壊璇锋眰閿欒'); + return this.$message.error("鐢ㄦ埛瑙掕壊璇锋眰閿欒"); } - + this.$store.state.mapMenuShpFile = rs.result.wkt; this.showMapMenuPop(); }, @@ -272,7 +262,7 @@ }); }, getMenuTopFile() { - $('#getMenuTopFile').click(); + $("#getMenuTopFile").click(); }, //鏌ヨ getAttributeQuery() { @@ -290,19 +280,18 @@ this.$store.state.primitLayer = null; } if (this.treeChange.length == 0) { - this.$message.error('璇烽�夋嫨瑕佹煡璇㈢殑鏁版嵁'); + this.$message.error("璇烽�夋嫨瑕佹煡璇㈢殑鏁版嵁"); return; } - if (this.menuTopFrom.queryType != 'inputFile') { + if (this.menuTopFrom.queryType != "inputFile") { sgworld.Creator.createSimpleGraphic( this.menuTopFrom.queryType, { - color: '#00FF0060', - outlineColor: '#0f0', + color: "#00FF0060", + outlineColor: "#0f0", outlineWidth: 5, }, (entity) => { - this.setTurfGeometry(entity); } ); @@ -314,17 +303,17 @@ var that = this; var res_val; switch (this.menuTopFrom.queryType) { - case 'point': //鐐� + case "point": //鐐� var val = that.setCartesianToEightFour(res.position.getValue()); res_val = val; that.setTurfCircle([val.lng, val.lat], 10); break; - case 'polyline': //绾� + case "polyline": //绾� var polyline = res.polyline.positions.getValue(); res_val = polyline; - that.setTurfPolyOrLine(polyline, 'polyline'); + that.setTurfPolyOrLine(polyline, "polyline"); break; - case 'rectangle': //鐭╁舰 + case "rectangle": //鐭╁舰 let rectangle = res.rectangle.coordinates.getValue(); res_val = rectangle; var result = new Cesium.Rectangle.subsample( @@ -332,28 +321,28 @@ Cesium.Ellipsoid.WGS84, rectangle.height ); - that.setTurfPolyOrLine(result, 'rectangle'); + that.setTurfPolyOrLine(result, "rectangle"); break; - case 'circle': //鍦� + case "circle": //鍦� var val = that.setCartesianToEightFour(res.position.getValue()); res_val = res.position.getValue(); var radius = res.ellipse.semiMajorAxis.getValue(); that.setTurfCircle([val.lng, val.lat], radius); break; - case 'polygon': //澶氳竟褰� + case "polygon": //澶氳竟褰� var polygon = res.polygon.hierarchy.getValue().positions; res_val = polygon; - that.setTurfPolyOrLine(polygon, 'polygon'); + that.setTurfPolyOrLine(polygon, "polygon"); break; } - this.flyEntity = res_val + this.flyEntity = res_val; }, setTurfCircle(position, radius) { var options = { steps: 10, - units: 'meters', - properties: { foo: 'bar' }, + units: "meters", + properties: { foo: "bar" }, }; var circle = turf.circle(position, radius, options); @@ -366,23 +355,22 @@ var line_data = this.setCartesianToEightFour(res[i]); std.push([line_data.lng, line_data.lat]); } - if (type == 'polyline') { - var line = turf.lineString(std, { name: 'polyline' }); - restVal = turf.buffer(line, 10, { units: 'meters' }); - } else if (type == 'rectangle') { + if (type == "polyline") { + var line = turf.lineString(std, { name: "polyline" }); + restVal = turf.buffer(line, 10, { units: "meters" }); + } else if (type == "rectangle") { var ste = this.setCartesianToEightFour(res[0]); std.push([ste.lng, ste.lat]); - restVal = turf.polygon([std], { name: 'rectangle' }); - } else if (type == 'polygon') { + restVal = turf.polygon([std], { name: "rectangle" }); + } else if (type == "polygon") { var ste = this.setCartesianToEightFour(res[0]); std.push([ste.lng, ste.lat]); - restVal = turf.polygon([std], { name: 'polygon' }); + restVal = turf.polygon([std], { name: "polygon" }); } this.setJonToWKT(restVal); }, setJonToWKT(res) { - var jsonToWkt = this.$wkt.convert(res.geometry); this.$store.state.mapMenuShpFile = encr(jsonToWkt); @@ -390,34 +378,34 @@ }, showMapMenuPop() { this.$store.state.mapSpaceQueryLayer = this.treeChange; - this.$store.state.mapPopBoxFlag = '1'; + this.$store.state.mapPopBoxFlag = "1"; this.$refs && this.$refs.queryinfo && this.$refs.queryinfo.close(); - this.$refs && this.$refs.queryinfo && this.$refs.queryinfo.open("绌洪棿鏌ヨ", null, { - close: () => { - - // if (this.$store.state.primitLayer != null) { - // // sgworld.Creator.DeleteObject(this.$store.state.primitLayer); - // this.$store.state.primitLayer = null; - // } - - // if (window.Viewer.scene.primitives.length != 0) { - // window.Viewer.scene.primitives.removeAll() - // } - } - }); + this.$refs && + this.$refs.queryinfo && + this.$refs.queryinfo.open("绌洪棿鏌ヨ", null, { + close: () => { + // if (this.$store.state.primitLayer != null) { + // // sgworld.Creator.DeleteObject(this.$store.state.primitLayer); + // this.$store.state.primitLayer = null; + // } + // if (window.Viewer.scene.primitives.length != 0) { + // window.Viewer.scene.primitives.removeAll() + // } + }, + }); // this.$bus.$emit('changeMapMenuTop', 'true'); // sgworld.Creator.SimpleGraphic.clear(); //娓呯┖inputFile // var file = document.getElementById('getMenuTopFile'); // file.outerHTML = file.outerHTML; - this.$refs.pathClear.value = ''; + this.$refs.pathClear.value = ""; }, clearQuery() { - this.$refs.pathClear.value = ''; + this.$refs.pathClear.value = ""; this.treeChange = []; this.menuTopFrom.queryLayer = null; - this.menuTopFrom.queryType = 'rectangle'; + this.menuTopFrom.queryType = "rectangle"; this.$refs.tree.setCheckedKeys([]); //娓呯┖鏍囩粯 sgworld.Creator.SimpleGraphic.edit(false, { editProp: false }); @@ -429,7 +417,9 @@ this.$store.state.queryInfo = []; } //鍏抽棴绐楀彛 - this.$refs && this.$refs.queryinfo && this.$refs.queryinfo.close("queryinfo"); + this.$refs && + this.$refs.queryinfo && + this.$refs.queryinfo.close("queryinfo"); if (this.$store.state.primitLayer != null) { sgworld.Creator.DeleteObject(this.$store.state.primitLayer); this.$store.state.primitLayer = null; @@ -447,7 +437,7 @@ }, }; </script> - + <style lang="less" scoped> .menuBox { width: 98%; -- Gitblit v1.9.3