Bladeren bron

问题处理

sunkuosheng 3 maanden geleden
bovenliggende
commit
a418b915f2

+ 13 - 1
ruoyi-ui/src/views/system/jkyj/module/component/mapfence.vue

@@ -20,6 +20,14 @@
           return ''
         }
       },
+      lng:{
+        type: String,
+        default:'',
+      },
+      lat:{
+        type: String,
+        default:'',
+      },
       isEdit: {
         type: Boolean,
         default: function() {
@@ -88,7 +96,6 @@
             }
           ]
         })
-
         // 缩放地图到合适的视野级别
         this.map.setFitView()
       },
@@ -126,6 +133,11 @@
           this.polyEditor = new AMap.PolygonEditor(this.map, this.polygons[0])
         } else {
           this.polyEditor = new AMap.PolygonEditor(this.map)
+          if(this.lng&&this.lat)
+          {
+            this.map.setCenter([Number(this.lng),Number(this.lat)])
+            this.map.setZoom(16)
+          }
         }
         // this.polyEditor.open()
         let _this = this

+ 34 - 10
ruoyi-ui/src/views/system/jkyj/module/znsh.vue

@@ -2,7 +2,7 @@
   <!--智能手环-->
   <div>
   <el-dialog v-dialog-drag title="设备配置" :visible.sync="open" width="930px" @close="cancel()" append-to-body>
-    <el-form class="formClass" ref="formClass" :model="form" :rules="rules"
+    <el-form class="formClassRef" ref="formClassRef" :model="form" :rules="rules"
              label-width="120px">
 
 
@@ -340,7 +340,7 @@
             </div>
           </el-form-item>
           <el-form-item v-if="form.vlxz==='圆形'" prop="fanwei" label="范围" :rules="{required:activeName==='dzwl'?true:false, message: '范围不能为空', trigger: 'blur'}">
-            <number placeholder="范围" v-model.sync="form.fanwei" :min="0" :max="999999" :precision="0"/>
+            <number placeholder="范围" v-model.sync="form.fanwei" :min="1" :max="999999" :precision="0"/>
           </el-form-item>
           <el-form-item label="定位:"  v-if="form.vlxz==='多边形'">
             <div style="display: flex">
@@ -449,7 +449,7 @@
     </div>
   </el-dialog>
     <el-dialog v-dialog-drag title="多边形绘制" :visible.sync="isDt2" width="1400px" append-to-body>
-      <MapFence v-if="isDt2"  :isEdit="isDt2" :areas="polygonArr" @clearPolygonMap="getPolygonMap" @getPolygonMap="getPolygonMap"></MapFence>
+      <MapFence v-if="isDt2"  :lat="jgLat" :lng="jgLng"  :isEdit="isDt2" :areas="polygonArr" @clearPolygonMap="getPolygonMap" @getPolygonMap="getPolygonMap"></MapFence>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="submitPosition" >保 存</el-button>
         <el-button @click="isDt2=false">取 消</el-button>
@@ -462,6 +462,7 @@
   import {tansParams} from "@/utils/ruoyi";
   import {chineseOne, idCard, Regular, Mobile} from '@/utils/regular'
   import axios from 'axios'
+  import {mapState} from 'vuex'
   import AMapLoader from "@amap/amap-jsapi-loader";
   import MapFence from "./component/mapfence"
   import {encrypt_ECBdef} from '@/api/tool/sm4';
@@ -485,7 +486,7 @@
         immediate: true,
         handler(newOpen) {
           if(newOpen){
-            this.open=true;
+
             this.getYq()
           }else {
             this.open=false;
@@ -493,12 +494,22 @@
         }
       }
     },
+    computed: {
+      ...mapState(['user']),
+    },
+    mounted(){
+      this.jgLat=this.user.userData.jgLat;
+      this.jgLng=this.user.userData.jgLng;
+    },
     data() {
       return {
+        jgLat:'',
+        jgLng:'',
         options:[
           {label:'圆形',value:'圆形'},
           {label:'多边形',value:'多边形'}
         ],
+        mapCenter:[],
         open:false,
         activeName:'sos',
         urla: "http://yg.hxinwatch.com/sdkapi/api/push/hjk/setWatch.htm?",
@@ -743,11 +754,13 @@
         this.txrdhArr=[];
         this.txrgxArr=[];
         this.txrxmArr=[];
-        this.resetForm("formClass");
+        this.resetForm("formClassRef");
       },
       getYq(){
-        this.reset();
+
         getJkyj(this.opt.id).then(response => {
+          this.open=true;
+          this.reset();
           let dataOpt = JSON.parse(response.data.sbcs1);
           console.log(dataOpt,'我是获取到的数据');
           this.form={ ...this.form ,...dataOpt};
@@ -789,9 +802,10 @@
       },
       getPolygonMap(path){
         if(path){
-          this.polygonArr2=path
+          this.polygonArr2=path;
         }else {
-          this.polygonArr2=[]
+          this.polygonArr2=[];
+          this.polygonArr=[];
         }
 
       },
@@ -818,7 +832,7 @@
       },
       async submitForm() {
         if(this.activeName==='dzwl'){
-          this.$refs["formClass"].validate(async valid => {
+          this.$refs["formClassRef"].validate(async valid => {
             if (valid){
               let qur=tansParams({
                 ...this.opt,
@@ -851,7 +865,7 @@
           });
         }
         // if(this.activeName==='yxdzwl'){
-        //   this.$refs["formClass"].validate(async valid => {
+        //   this.$refs["formClassRef"].validate(async valid => {
         //     if (valid){
         //       let qur=tansParams({
         //         ...this.opt,
@@ -993,6 +1007,12 @@
               // this.map.add(this.marker)
               // this.map.setFitView(this.marker)
               this.initPatroMap([this.lng, this.lat])
+            }else {
+              if(this.jgLng &&this.jgLat)
+              {
+                this.map.setCenter([Number(this.jgLng),Number(this.jgLat)])
+                this.map.setZoom(16)
+              }
             }
           }
 
@@ -1117,6 +1137,10 @@
         this.isDt2=true;
         this.polygonArr2=JSON.parse(JSON.stringify(this.form.path));
         this.polygonArr=[this.form.path];
+        // if(!this.polygonArr2||this.polygonArr2.length===0)
+        // {
+        //   this.mapCenter=[this.user.userData.jgLng,this.user.userData.jgLat]
+        // }
         // this.initMap()
       },