shuhao 5 tháng trước cách đây
mục cha
commit
ce0dc3b4a4

+ 3 - 0
src/utils/ol-map/Map.js

@@ -184,11 +184,14 @@ class Map {
 	modifyDraw(callback) {
 		this.modify = new Modify({
 			source: this.polygonLayer.source,
+			condition:callback,
 			pixelTolerance: 10, //设置吸附像素值
+
 		})
 		this.modify.setActive(false)
         this.map.addInteraction(this.modify);
 		this.modify.on("modifyend",callback)
+		this.modify.on("modifystart",callback)
 	}
 
 	startModify(){

+ 27 - 2
src/views/authentic/authenticMap.js

@@ -15,6 +15,7 @@ import * as proj from "ol/proj";
 import proj4 from "proj4";
 import { register } from "ol/proj/proj4";
 import GeometryCollection from 'ol/geom/GeometryCollection.js';
+import { ElMessage, ElMessageBox } from "element-plus";
 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"
@@ -27,6 +28,7 @@ export let mapData = reactive({
   point: null,
   selectPointArr: [],
   isPointHide: null,
+  disabledForm : false
 });
 
 function resetMapData(){
@@ -36,6 +38,7 @@ function resetMapData(){
   mapData.point= null
   mapData.selectPointArr= []
   mapData.isPointHide= null
+  mapData.disabledForm= false
 }
 
 /**
@@ -109,8 +112,22 @@ class AuthenticMap {
       }
     });
     this.kmap.modifyDraw((e) => {
-      mapData.isEditArea = false;
-      mapData.isEditArea = true;
+      if(e.type === "pointerdown"){
+        let f = null
+        this.kmap.map.forEachFeatureAtPixel(e.pixel, function (feature, layer) {
+          f= feature
+        });
+        let res = f.get("id") === mapData.curPointData.id || !f.get("id")
+        if(!res){
+          ElMessage.warning("编辑中")
+        }
+        return res
+      }
+
+      if(e.type === "modifyend"){
+        mapData.isEditArea = false;
+        mapData.isEditArea = true;
+      }
     });
     this.kmap.addLayer(this.clickPointLayer.layer);
     this.kmap.addLayer(this.locationLayer.layer);
@@ -255,6 +272,14 @@ class AuthenticMap {
   addMapSingerClick() {
     let that = this;
     that.kmap.on("singleclick", (evt) => {
+      if(mapData.curPointData.id && !mapData.disabledForm){
+        ElMessage.warning("编辑中")
+        return;
+      }
+      if(!mapData.curPointData.id && mapData.isEdit){
+        ElMessage.warning("编辑中")
+        return;
+      }
       let num = 0;
       that.kmap.map.forEachFeatureAtPixel(evt.pixel, function (feature, layer) {
         // 点击的图层是否是VectorLayer

+ 12 - 4
src/views/authentic/index.vue

@@ -413,6 +413,7 @@ const isEdit = ref(false);
 // 编辑
 const handleEdit = () => {
   disabledForm.value = false;
+  mapData.disabledForm = false
   authenticMap.startModify();
 };
 
@@ -446,14 +447,16 @@ const onSubmit = () => {
       VE_API.authentic.saveData(formInline).then((res) => {
         isUpdata.value = false;
         disabledForm.value = true;
+        mapData.disabledForm = true;
         const point = mapData.curPointData;
         authenticMap.endDraw();
         getList().then(() => {
           isRefresh.value = false;
-          isEdit.value = true;
-          authenticMap.getSelectPointArr(
-            point.id || plotList.value[plotList.value.length - 1].id
-          );
+          isEdit.value = false;
+          authenticMap.allUnSelect()
+          // authenticMap.getSelectPointArr(
+          //   point.id || plotList.value[plotList.value.length - 1].id
+          // );
         });
       });
     }
@@ -577,6 +580,7 @@ const getDetailsData = (id) => {
   VE_API.authentic.getDetails({ id }).then(({ data }) => {
     isEdit.value = true;
     disabledForm.value = true;
+    mapData.disabledForm = true
 
     data.createDate = dateFormat(
       new Date(data.createDate),
@@ -627,6 +631,7 @@ watch(
     if (newVale && mapData.selectPointArr.length < 2 && !isRefresh.value) {
       isEdit.value = true;
       disabledForm.value = false;
+      mapData.disabledForm = false
       isUpdata.value = true;
     //   isRefresh.value = false;
       formInline.createDate = dateFormat(new Date(), "YYYY-mm-dd HH:MM:SS");
@@ -648,6 +653,9 @@ watch(
         authenticMap.endDraw();
         isRefresh.value = true;
       }
+      if(mapData.selectPointArr.length === 0){
+        isEdit.value = false;
+      }
     }
   }
 );