2 Commits fbd01495d7 ... 19f3d2abc4

Author SHA1 Message Date
  duxiangyu 19f3d2abc4 Merge branch 'master' into dev_duxiangyu 2 years ago
  duxiangyu 36fd0a6adf 地图标点 数字判断 2 years ago

+ 4 - 2
src/components/project-manage/components/geo.vue

@@ -72,7 +72,7 @@ export default {
         });
         _this.map.on("click", (e) => {
           console.log(e);
-          this.regeoCode(e.lnglat);
+          this.regeoCode(Amap, e.lnglat);
         });
         this.addMarker(
           Amap,
@@ -142,7 +142,7 @@ export default {
     clearMarker() {
       this.markers.forEach((marker) => this.map.remove(marker));
     },
-    regeoCode(lnglat) {
+    regeoCode(Amap, lnglat) {
       this.geocoder.getAddress(lnglat, (status, result) => {
         if (status === "complete" && result.regeocode) {
           const address = result.regeocode.formattedAddress;
@@ -150,6 +150,8 @@ export default {
           this.geoFormData.address = address;
           this.geoFormData.longitude = lnglat.lng.toString();
           this.geoFormData.latitude = lnglat.lat.toString();
+          this.setLocation(Amap, { lng: lnglat.lng, lat: lnglat.lat });
+          this.addMarker(Amap, { lng: lnglat.lng, lat: lnglat.lat }, address);
           this.$emit("change", this.geoFormData);
         } else {
           log.error("根据经纬度查询地址失败");

+ 0 - 5
src/components/project-manage/form/items/date.vue

@@ -7,8 +7,6 @@
 </template>
 
 <script>
-import { $Bus } from "@/utils/Bus";
-
 export default {
   props: {
     initValue: {
@@ -30,9 +28,6 @@ export default {
       value: this.filterInitValue(this.initValue),
     };
   },
-  mounted() {
-    console.log(this.formItemObj.isRegion);
-  },
   methods: {
     filterInitValue(str) {
       if (!str) return str;

+ 9 - 1
src/components/project-manage/form/items/input.vue

@@ -120,7 +120,8 @@ export default {
       // this.$emit("change", this.value);
       console.log(this.trueValue);
       this.errorInfo = "";
-      const isNum = /^[0-9]+.?[0-9]*$/;
+      const isNum = /^[0-9]+.?[0-9]*$/; // 是否都为数字
+      const isDouble = /^[+-]?\d+(?:\.\d{1,2})?$/; // 最多两位小数,可为正负
       if (!["STRING", "TEXT"].includes(this.formItemObj.dataType)) {
         if (!isNum.test(e)) {
           this.errorInfo = "仅支持数字输入";
@@ -128,6 +129,13 @@ export default {
         }
       }
 
+      if (!["DOUBLE"].includes(this.formItemObj.dataType)) {
+        if (!isDouble.test(e)) {
+          this.errorInfo = "仅支持小数点后两位";
+          return;
+        }
+      }
+
       this.$emit("change", this.trueValue);
     },
     inputHandle(type, index) {

+ 8 - 15
src/components/project-manage/index.vue

@@ -18,12 +18,6 @@
         <Button type="primary" @click="save">保存</Button>
       </div>
     </div>
-    <Modal :show="modalStatusTip" title="提示" mode="tip" type="info">
-      <template #content> 填写内容未保存,确定保存吗? </template>
-      <template #handle>
-        <Button>11</Button>
-      </template>
-    </Modal>
   </div>
 </template>
 <script>
@@ -62,10 +56,9 @@ export default {
     return {
       anchorList: [],
       info: {},
-      refresh: false,
-      modalStatusTip: false,
-      isSaved: true,
-      hasChange: false,
+      refresh: false, // 节点重新渲染
+      isSaved: true, // 是否已经保存
+      hasChange: false, // 是否有修改
     };
   },
   computed: {
@@ -78,6 +71,7 @@ export default {
     this.initEvent();
   },
   methods: {
+    // 获取参数字典
     async getDict() {
       return Dic.getDataDictionary({
         type: "project",
@@ -108,6 +102,7 @@ export default {
         console.log(keys);
       });
     },
+    // 获取数据信息
     async getInfo() {
       return ScanController.getAllProject({
         filters: `projectId=${this.projectId}`,
@@ -119,6 +114,7 @@ export default {
         }
       });
     },
+    // 跳转到锚点
     goAnchor(anchor) {
       let name = anchor;
       let dom = document.querySelector(`.${name}-container`);
@@ -127,6 +123,7 @@ export default {
         right.scrollTop = dom.offsetTop - 120;
       }
     },
+    // 保存
     save() {
       ScanController.updateProjectInfo({ content: [this.info] }).then((res) => {
         this.$message.success("保存成功");
@@ -178,18 +175,14 @@ export default {
       this.loading = IndexLoading();
       this.refresh = true;
       Promise.all([this.getInfo(), this.getDict()]).then(() => {
-        console.log(222);
         this.refresh = false;
         IndexLoading.remove(this.loading);
       });
-      // this.getInfo();
-      // this.getDict();
-      // this.openLoading();
     },
   },
+  // 二次确认
   beforeRouteLeave(to, from, next) {
     if (this.hasChange && !this.isSaved) {
-      // this.modalStatusTip = true;
       next(false);
       this.$confirm("填写内容未保存,确定保存吗?", "提示", {
         confirmButtonText: "保存",