From c2a1e5ca8c702739ac0753accd65004926867bed Mon Sep 17 00:00:00 2001 From: Surpriseplus <845948745@qq.com> Date: 星期四, 16 二月 2023 09:56:54 +0800 Subject: [PATCH] 用户管理批量修改用户密码,数据上传附件上传 --- src/views/Synthesis/LeftMenu.vue | 279 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 265 insertions(+), 14 deletions(-) diff --git a/src/views/Synthesis/LeftMenu.vue b/src/views/Synthesis/LeftMenu.vue index a41aa50..a229ce9 100644 --- a/src/views/Synthesis/LeftMenu.vue +++ b/src/views/Synthesis/LeftMenu.vue @@ -21,6 +21,16 @@ class="file" style="display: none" /> + <input + :accept="'.shp, .shx, .dbf, .prj'" + style="display: none" + ref="pathClear" + type="file" + name="file" + id="shpFile" + multiple="multiple" + @change="handleOpenShp()" + /> </div> </template> @@ -29,6 +39,8 @@ import mapinfo from '../Tools/mapinfo.vue'; import maplayer from '../Tools/maplayer.vue'; import queryinfo from '../Tools/queryinfo.vue'; +import $ from 'jquery' +import { getToken } from '@/utils/auth'; import { OverviewMap, defaults as defaultControls, @@ -36,6 +48,9 @@ ScaleLine, Rotate, } from "ol/control.js" +import * as turf from '@turf/turf'; +import { geometry } from '@turf/turf'; + export default { components: { mapinfo, maplayer, queryinfo }, data() { @@ -303,10 +318,10 @@ css: 'twoMenu_imge81', }, { - id: "h8", - label: "synthesis.textLabel", - name: "鏂囨湰鐐�", - css: "twoMenu_imge81", + id: 'h8', + label: 'synthesis.addlabel', + name: '鏂囧瓧', + css: 'twoMenu_imge88', }, { id: 'h2', @@ -329,21 +344,30 @@ { id: 'h5', label: 'synthesis.import', - name: '瀵煎叆', + name: '瀵煎叆KML', css: 'twoMenu_imge85', }, { id: 'h6', label: 'synthesis.export', - name: '瀵煎嚭', + name: '瀵煎嚭KML', css: 'twoMenu_imge86', }, - { - id: 'h8', - label: 'synthesis.addlabel', - name: '鏂囧瓧', - css: 'twoMenu_imge88', - }, + + // { + // id: 'h9', + // label: 'synthesis.import1', + // name: '瀵煎叆SHP', + // css: 'twoMenu_imge85', + // }, + // { + // id: 'h10', + // label: 'synthesis.export1', + // name: '瀵煎嚭SHP', + // css: 'twoMenu_imge86', + // }, + + { id: 'h7', label: 'synthesis.removepaint', @@ -378,13 +402,14 @@ UndergroundMode: false, scaleLine: null, Excavation: false, + entityaLayers: [], }; }, methods: { //浜岀礆鑿滃崟鐐瑰嚮鍒囨崲 setChangeTwoMenu(res) { //娓呴櫎缁樺埗鍥惧舰瀵硅薄 - sgworld.Creator.SimpleGraphic.clear(); + // sgworld.Creator.SimpleGraphic.clear(); if (window.Viewer.scene.primitives.length != null) { window.Viewer.scene.primitives.removeAll(); } @@ -476,8 +501,19 @@ case 'h6': this.handleSaveClick(); break; + case 'h9': + // this.handleOpenShp(); + $("#shpFile").click(); + break; + case 'h10': + this.handleSaveShp(); + break; case 'h7': sgworld.Creator.SimpleGraphic.clear(); + for (var i in this.entityaLayers) { + sgworld.Viewer.entities.remove(this.entityaLayers[i]); + } + this.entityaLayers = []; break; case 'h8': sgworld.Creator.createSimpleGraphic('label', {}, function (entity) { @@ -524,8 +560,222 @@ alert('褰撳墠鍦烘櫙娌℃湁entities瀹炰綋'); } }, + handleSaveShp() { + var entities = sgworld.Viewer.entities.values; + if (entities.length == 0) { + return; + } + var std = []; + for (var i in entities) { + var type, fillColor, alpha, wkt, name; + var bak = {} + + if (entities[i].name) { + + name = entities[i].name + } + if (entities[i].properties) { + + var properties = entities[i].properties.propertyNames; + for (var j in properties) { + bak[properties[j]] = entities[i].properties[properties[j]]._value; + } + } else { + bak = { + "name": entities[i].name + } + } + if (entities[i].rectangle) {//鐭╁舰 + type = 'rectangle' + var east = Cesium.Math.toDegrees(entities[i].rectangle.coordinates.getValue().east); + var north = Cesium.Math.toDegrees(entities[i].rectangle.coordinates.getValue().north); + var west = Cesium.Math.toDegrees(entities[i].rectangle.coordinates.getValue().west); + var south = Cesium.Math.toDegrees(entities[i].rectangle.coordinates.getValue().south); + var line = turf.lineString([[east, north], [west, south]]) + wkt = this.$wkt.convert(line.geometry) + var fill = entities[i].rectangle._material._color._value; + fillColor = fill.red + ',' + fill.green + ',' + fill.blue; + alpha = fill.alpha; + } else if (entities[i].point) {//鐐� + type = 'point' + let ellipsoid = Viewer.scene.globe.ellipsoid; + let cartographic = ellipsoid.cartesianToCartographic(entities[i].position.getValue()); + let lat = Cesium.Math.toDegrees(cartographic.latitude); + let lng = Cesium.Math.toDegrees(cartographic.longitude); + let alt = cartographic.height; + let point = turf.point([lng, lat, alt]) + wkt = this.$wkt.convert(point.geometry) + var fill = entities[i].point._color._value; + fillColor = fill.red + ',' + fill.green + ',' + fill.blue; + alpha = fill.alpha; + + + } else if (entities[i].polygon) { + type = 'polygon'; + var fill = entities[i].polygon._material._color._value; + fillColor = fill.red + ',' + fill.green + ',' + fill.blue; + alpha = fill.alpha; + var geometry = entities[i].polygon.hierarchy.getValue().positions; + var coordinates = []; + for (var k in geometry) { + coordinates.push(this.setCartesianToEightFour(geometry[k])) + } + if (coordinates[0] != coordinates[1]) { + coordinates.push(coordinates[0]) + } + var polygon = turf.polygon([coordinates]) + wkt = this.$wkt.convert(polygon.geometry) + } else if (entities[i].polyline) { + type = "polyline"; + var coordinates = []; + var geometry = entities[i].polyline.positions.getValue(); + for (var k in geometry) { + coordinates.push(this.setCartesianToEightFour(geometry[k])) + } + var polyline = turf.lineString(coordinates) + wkt = this.$wkt.convert(polyline.geometry) + + var fill = entities[i].polyline._material._color._value; + fillColor = fill.red + ',' + fill.green + ',' + fill.blue; + alpha = fill.alpha; + } else if (entities[i].label) { + type = "label"; + let ellipsoid = Viewer.scene.globe.ellipsoid; + let cartographic = ellipsoid.cartesianToCartographic(entities[i].position.getValue()); + let lat = Cesium.Math.toDegrees(cartographic.latitude); + let lng = Cesium.Math.toDegrees(cartographic.longitude); + let alt = cartographic.height; + let point = turf.point([lng, lat, alt]) + wkt = this.$wkt.convert(point.geometry) + var fill = entities[i].label.backgroundColor._value; + fillColor = fill.red + ',' + fill.green + ',' + fill.blue; + alpha = fill.alpha; + } + std.push({ + id: parseInt(i) + 1, + type: type, + fillColor: fillColor, + opacity: alpha, + name: name, + bak: JSON.stringify(bak), + wkt: wkt + }) + } + $.ajax({ + url: BASE_URL + "/comprehensive/downloadShp?token=" + getToken(), + type: "POST", + data: JSON.stringify(std), + dataType: 'json', // html銆乯son銆乯sonp銆乻cript銆乼ext + contentType: "application/json", // "application/x-www-form-urlencoded" + success: (rs) => { + if (rs && rs.code == 200) { + var a = document.createElement('a'); // 鍒涘缓涓�涓猘鏍囩鍏冪礌 + a.style.display = 'none'; // 璁剧疆鍏冪礌涓嶅彲瑙� + + a.href = BASE_URL + "/comprehensive/downloadFile?token=" + getToken() + "&guid=" + rs.result; + + document.body.appendChild(a); // 鍔犲叆 + a.click(); // 瑙﹀彂鐐瑰嚮,涓嬭浇 + document.body.removeChild(a); // 閲婃斁 + } + }, + error: function (e) { + } + }); + + }, + handleOpenShp() { + var formData = new FormData(); + var fs = document.getElementById("shpFile"); + var exts = [".shp", ".shx", ".dbf", ".prj"]; + var count = 0; + for (var i = 0, c = fs.files.length; i < c; i++) { + var name = fs.files[i].name.toLocaleLowerCase(); + var ext = name.substring(name.lastIndexOf(".")); + if (exts.indexOf(ext) > -1) { + count++; + formData.append(fs.files[i].name, fs.files[i]); // fs.files[i].name,file + } + } + if (count != 4) { + alert("ShapeFile鏂囦欢閫夋嫨涓嶅叏锛�"); + return; + } + var that = this; + $.ajax(BASE_URL + "/comprehensive/uploadShp?token=" + getToken(), { + type: "post", + data: formData, + async: true, + cache: false, + processData: false, + contentType: false, + success: function (rs) { + + if (rs.code == 200) { + that.showShpEntity(rs.result); + } + }, + error: function (e) { + console.error(e); + } + }); + }, + showShpEntity(res) { + + for (var i in res) { + + var wkt = this.$wkt.parse(res[i].wkt); + var fillColor = res[i].fillColor.split(","); + var color = new Cesium.Color(fillColor[0], fillColor[1], fillColor[2], res[i].opacity) + switch (res[i].type) { + case 'rectangle': + debugger + break; + case 'point': + debugger + break; + case 'polygon': + var std = []; + var geo = wkt.coordinates[0]; + for (var i in geo) { + std.push(geo[i][0]) + std.push(geo[i][1]) + } + const entity = Viewer.entities.add({ + name: 'Wyoming', + polygon: { + hierarchy: Cesium.Cartesian3.fromDegreesArray(std), + //height : 100000, + material:color, + outline: true, + outlineColor: color, + } + }) + this.entityaLayers.push(entity) + break; + case 'polyline': + debugger + break; + case 'label': + debugger + break; + } + } + }, + + setCartesianToEightFour(res) { + var std = []; + let ellipsoid = Viewer.scene.globe.ellipsoid; + let cartographic = ellipsoid.cartesianToCartographic(res); + let lat = Cesium.Math.toDegrees(cartographic.latitude); + let lng = Cesium.Math.toDegrees(cartographic.longitude); + let alt = cartographic.height; + std = [lng, lat, alt] + return std; + }, handleOpenClick() { + var that = this; sgworld.Creator.SimpleGraphic.edit(true, { editProp: true }); let fileInput = document.querySelector('.file'); fileInput.onchange = function (evt) { @@ -544,9 +794,10 @@ fileReader.result, kmlOptions ); + geocachePromise.then(function (dataSource) { var geocacheEntities = dataSource.entities.values; - + that.entityaLayers = geocacheEntities; for (var i = 0; i < geocacheEntities.length; i++) { var entity = geocacheEntities[i]; -- Gitblit v1.9.3