Ver Fonte

feat:添加用户姓名校验和修改bug

wangsisi há 5 meses atrás
pai
commit
a6caf30ba1
2 ficheiros alterados com 31 adições e 20 exclusões
  1. 9 9
      src/views/authentic/authenticMap.js
  2. 22 11
      src/views/authentic/index.vue

+ 9 - 9
src/views/authentic/authenticMap.js

@@ -106,15 +106,7 @@ class AuthenticMap {
       if (e.type === "drawend") {
         mapData.isEdit = true;
         mapData.point = e.feature;
-        const coord = e.feature.getGeometry().getCoordinates()[0];
-        // console.log('coord',coord);
-      }else{
-        const coord = e.feature.getGeometry().getCoordinates()[0];
-        // console.log('coord',coord);
       }
-    //   console.log("e", e);
-    //   console.log('111',e.feature.get('geometry'));
-      //   this.drawnFeatures.push(e.feature);
     });
     this.kmap.modifyDraw((e) => {
       mapData.isEditArea = false;
@@ -241,6 +233,9 @@ class AuthenticMap {
       }
     });
     mapData.selectPointArr = arr;
+    if(arr.length>0){
+        this.fit([arr[0].get('featureWkt')])
+    }
   }
   //no全选
   allUnSelect(){
@@ -401,12 +396,18 @@ class AuthenticMap {
         condition.push(feature.get("farmName").includes(form.farmName))
       }
       if(form.masterName != ''){
+        const text = feature.get("masterName")
+        if(text!==form.masterName) return
         condition.push(feature.get("masterName").includes(form.masterName))
       }
       if(form.masterTel != ''){
+        const text = feature.get("masterTel")
+        if(text!==form.masterTel) return
         condition.push(feature.get("masterTel").includes(form.masterTel))
       }
       if(form.speciesTypeName != ''){
+        const text = feature.get("speciesTypeName")
+        if(text!==form.speciesTypeName) return
         condition.push(feature.get("speciesTypeName").includes(form.speciesTypeName))
       }
       let b = false
@@ -423,7 +424,6 @@ class AuthenticMap {
       }
     });
     this.allUnSelect()
-    // alert(arr)
     this.allSelect(arr)
   }
 }

+ 22 - 11
src/views/authentic/index.vue

@@ -300,6 +300,7 @@ const MAP_KEY = "CZLBZ-LJICQ-R4A5J-BN62X-YXCRJ-GNBUT";
 
 const handleSearchRes = (v) => {
   authenticMap.setMapCenter(v);
+  onRest()
 };
 
 const locationOptions = reactive({
@@ -312,7 +313,7 @@ const remoteMethod = async (keyword) => {
     const params = {
       key: MAP_KEY,
       keyword,
-      // location: store.getters.userLocation,
+    //   location: location.value,
       location: "22.574540836684672,113.1093017627431",
     };
     await VE_API.old_mini_map
@@ -336,7 +337,16 @@ const remoteMethod = async (keyword) => {
     locationOptions.list = [];
   }
 };
-
+const validatePhoneNumber = (rule, value, callback) => {
+    const phoneRegex = /^[1][3-9]\d{9}$/
+    if (!value) {
+        callback(new Error('请输入联系电话'))
+      } else if (!phoneRegex.test(value)) {
+        callback(new Error('手机号码格式不正确'));
+      } else {
+        callback();
+      }
+}
 const rules = {
   address: [{ required: true, message: "请输入农场地址", trigger: "change" }],
   farmName: [{ required: true, message: "请输入农场名称", trigger: "change" }],
@@ -344,7 +354,7 @@ const rules = {
     { required: true, message: "请输入作物物种", trigger: "change" },
   ],
   masterName: [{ required: true, message: "请输入姓名", trigger: "change" }],
-  masterTel: [{ required: true, message: "请输入联系电话", trigger: "change" }],
+  masterTel: [{ required: true, validator: validatePhoneNumber, trigger: "change" }],
 };
 const ruleFormRef = ref(null);
 const initForm = {
@@ -370,12 +380,12 @@ const formInlineSearch = reactive({
 });
 
 const onSearch = () => {
-    // isUpdata.value = false
   authenticMap.search(formInlineSearch)
 };
 
 const onRest = () => {
     Object.assign(formInlineSearch, initForm);
+    isUpdata.value = false
     onCancel()
 };
 
@@ -397,13 +407,14 @@ const onCancel = (isCancel) => {
   if (isUpdata.value || isCancel) {
     authenticMap.cancelDraw();
   } else {
+    // authenticMap.cancelDraw();
     getList((geoms)=>{
-      const geometriesWkt = []
-      for(let item of geoms){
-        geometriesWkt.push(item.featureWkt)
-      }
-      authenticMap.fit(geometriesWkt)
-      authenticMap.allSelect()
+    //   const geometriesWkt = []
+    //   for(let item of geoms){
+    //     geometriesWkt.push(item.featureWkt)
+    //   }
+    //   authenticMap.fit(geometriesWkt)
+      authenticMap.allUnSelect()
     });
   }
 };
@@ -573,7 +584,7 @@ const updatePointList = () => {
 
 watchEffect(() => {
     isRefresh.value = true
-  if (mapData.isEdit && mapData.selectPointArr.length < 2&&isRefresh.value) {
+  if (mapData.isEdit && mapData.selectPointArr.length < 2&& isRefresh.value) {
     isEdit.value = true;
     disabledForm.value = false;
     isUpdata.value = true;