Parcourir la source

导出确权pdf

shuhao il y a 5 mois
Parent
commit
51d57380ac

+ 5 - 4
src/utils/ol-map/Map.js

@@ -69,6 +69,7 @@ class Map {
 	 * @constructor
   */
   constructor(id,zoomLevel,lng,lat,projection, minZoom,maxZoom){
+  		this.defaultCursor = 'default'
 		if(Map.Instance){
 			Map.Instance = false;
 		}
@@ -466,12 +467,12 @@ class Map {
 				vm.clearMouseMoveInfoWindow()
 			}
 			//设置鼠标悬停到覆盖物上的样式
-			var mapContainer = vm.getTarget()
+			let mapContainer = vm.getTarget()
 			if(mousemoveFeature) {
 				mapContainer.style.cursor = "pointer"
 			}
 			else {
-				mapContainer.style.cursor = "default"
+				mapContainer.style.cursor = this.defaultCursor
 			}
 		})
 	}
@@ -1055,6 +1056,7 @@ class Map {
 	 * @memberof Map
 	*/
 	setDefaultCursor(cursorStyle) {
+		this.defaultCursor = cursorStyle
 		let mapContainer = this.map.getTargetElement()
 		if(cursorStyle != undefined) {
 			mapContainer.style.cursor = cursorStyle
@@ -1072,14 +1074,13 @@ class Map {
 	setFeatureCursor(cursorStyle) {
 		cursorStyle = (cursorStyle == undefined)? "default" : cursorStyle
 		let mapContainer = this.map.getTargetElement()
-		let defaultCursor = mapContainer.style.cursor
 		this.map.on("pointermove",function(e){
 			let features = this.map.forEachFeatureAtPixel(e.pixel,function(feature) { return feature })
 			if(features) {
 				mapContainer.style.cursor = cursorStyle
 			}
 			else {
-				mapContainer.style.cursor = defaultCursor
+				mapContainer.style.cursor = this.defaultCursor
 			}
 		})
 	}

+ 4 - 4
src/views/authentic/Pdf.vue

@@ -68,6 +68,8 @@ const emit = defineEmits(["closeDialog","success"])
 const state = useStore().state;
 const sendConfirmShow = ref(false)
 const mapRef = ref(null)
+let pdfMap = new PdfMap()
+let rowData = ref({})
 
 async function send(){
   closeDialog();
@@ -96,6 +98,8 @@ let printObj = {
     console.log('打开之前')
   },
   openCallback (vue) {
+    let {masterName, farmName, masterTel} = rowData.value
+    document.title =`${masterName}-${farmName}-${masterTel}`
     console.log('执行了打印')
   },
   closeCallback (vue) {
@@ -125,10 +129,6 @@ function  toImg(map) {
 }
 
 
-let pdfMap = new PdfMap()
-let rowData = ref({})
-
-
 onMounted(()=>{
   VE_API.authentic.getDetails({id:rowId.value}).then(({data})=>{
     data.createDate = dateFormat(new Date(), "YYYY-mm-dd HH:MM:SS");

+ 58 - 5
src/views/authentic/authenticMap.js

@@ -14,6 +14,7 @@ import { getArea } from "ol/sphere.js";
 import * as proj from "ol/proj";
 import proj4 from "proj4";
 import { register } from "ol/proj/proj4";
+import GeometryCollection from 'ol/geom/GeometryCollection.js';
 proj4.defs(
   "EPSG:38572",
   "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs"
@@ -28,6 +29,15 @@ export let mapData = reactive({
   isPointHide: null,
 });
 
+function resetMapData(){
+  mapData.isEdit= false
+  mapData.isEditArea= false
+  mapData.curPointData= {}
+  mapData.point= null
+  mapData.selectPointArr= []
+  mapData.isPointHide= null
+}
+
 /**
  * @description 地图层对象
  */
@@ -115,6 +125,18 @@ class AuthenticMap {
     this.addMapSingerClick();
   }
 
+
+
+  fit(geometriesWkt){
+    let geometries = []
+    let f = new WKT();
+    for(let wkt of geometriesWkt){
+      geometries.push(f.readGeometry(wkt))
+    }
+    let extent = new GeometryCollection(geometries).getExtent()
+    this.kmap.fit(extent)
+  }
+
   undoLastDraw() {
     const features = this.kmap.getLayerFeatures();
     features.forEach((feature) => {
@@ -141,9 +163,8 @@ class AuthenticMap {
     const arrPoints = [];
     if (points && points.length > 0) {
       points.forEach((item) => {
-        arrPoints.push(
-          newPoint({ ...item, icon: "point", iconBg: "name-bg" }, "point")
-        );
+        let f = newPoint({ ...item, icon: "point", iconBg: "name-bg" }, "point");
+        arrPoints.push(f);
       });
       this.clickPointLayer.source.addFeatures(arrPoints);
     }
@@ -162,6 +183,7 @@ class AuthenticMap {
 
   // 开始勾画
   startDraw() {
+    this.kmap.setDefaultCursor("crosshair");
     this.kmap.startDraw();
   }
   //结束勾画
@@ -181,10 +203,41 @@ class AuthenticMap {
   }
 
   // 清空单个数据
-  clearMapData(name, val) {
+  clearMapData(name, val, id) {
     mapData[name] = val;
+    // resetMapData()
+    this.clickPointLayer.source.forEachFeature((feature) => {
+      if (feature.get("id") === id) {
+        feature.set("icon", "point");
+        feature.set("iconBg", "name-bg");
+      }
+    });
+    const points = this.kmap.getLayerFeatures();
+    points.forEach((feature) => {
+      if (feature.get("id") === id) {
+        feature.set("icon", "point");
+        this.kmap.polygonStyle(feature);
+        mapData.isPointHide = feature;
+      }
+    });
+    mapData.selectPointArr = [];
+  }
+  //全选
+  allSelect(){
+    let arr = []
+    this.clickPointLayer.source.forEachFeature((feature) => {
+        feature.set("icon", "point-act");
+        feature.set("iconBg", "name-act-bg");
+    });
+    const points = this.kmap.getLayerFeatures();
+    points.forEach((feature) => {
+        feature.set("icon", "point-act");
+        this.kmap.polygonStyle(feature);
+        mapData.isPointHide = feature;
+        arr.push(feature)
+    });
+    mapData.selectPointArr = arr;
   }
-
   // 地图点击事件
   addMapSingerClick() {
     let that = this;

+ 18 - 9
src/views/authentic/index.vue

@@ -93,8 +93,8 @@
         </div>
       </el-form>
       <div class="box">
-        <div class="map-box">
-          <div ref="mapRef" class="map"></div>
+        <div class="map-box" :class="{'cursor-pointer':mouseStyle}">
+          <div ref="mapRef" class="map" ></div>
         </div>
         <div class="tool-group">
           <!-- <div class="btn" @click="handleCancel" v-show="isEdit&&mapData.point">
@@ -195,7 +195,7 @@
             </div>
           </div>
           <div class="edit-footer">
-            <div @click="onCancel" class="btn cancel">取消</div>
+            <div @click="onCancel(true)" class="btn cancel">取消</div>
             <div @click="onSubmit" class="btn save">保存</div>
           </div>
         </div>
@@ -264,6 +264,7 @@ import { dateFormat } from "@/utils/date_util";
 import { exportExcel, parseMultiPolygon } from "@/utils/index";
 import Pdf from "./Pdf";
 const pdfShow = ref(false)
+const mouseStyle = ref(1)
 const router = useRouter();
 
 let authenticMap = new AuthenticMap();
@@ -278,7 +279,7 @@ onMounted(() => {
 
 // 获取地块列表
 const plotList = ref([]);
-const getList = () => {
+const getList = (callback) => {
   authenticMap.clearLayer();
   return VE_API.authentic.getList(formInlineSearch).then(({ code, data }) => {
     plotList.value = data || [];
@@ -288,6 +289,7 @@ const getList = () => {
     });
     authenticMap.setAreaGeometry(geom);
     authenticMap.addPoint(data);
+    callback && callback(geom)
   });
 };
 
@@ -387,15 +389,22 @@ const handleEdit = () => {
 
 // 取消
 const isUpdata = ref(true);
-const onCancel = () => {
+const onCancel = (isCancel) => {
   isEdit.value = false;
   authenticMap.setPoint("point");
-  authenticMap.clearMapData("isEdit", false);
+  authenticMap.clearMapData("isEdit", false, formInline.id);
   authenticMap.endDraw();
-  if (isUpdata.value) {
+  if (isUpdata.value || isCancel) {
     authenticMap.cancelDraw();
   } else {
-    getList();
+    getList((geoms)=>{
+      const geometriesWkt = []
+      for(let item of geoms){
+        geometriesWkt.push(item.featureWkt)
+      }
+      authenticMap.fit(geometriesWkt)
+      authenticMap.allSelect()
+    });
   }
 };
 
@@ -661,7 +670,7 @@ watch(
       .input-with-select {
         margin-left: 25px;
       }
-      
+
       .upload {
         background: #2199f8;
         margin-left: 25px;