From 8aa3edd56c279100c9053576f3e90fa55459fe77 Mon Sep 17 00:00:00 2001
From: zengh <123456>
Date: Mon, 16 Jan 2023 16:15:55 +0800
Subject: [PATCH] 修改

---
 src/views/security/security.vue |   64 +++++++++++++++++++++++++-------
 1 files changed, 50 insertions(+), 14 deletions(-)

diff --git a/src/views/security/security.vue b/src/views/security/security.vue
index cbda06b..7005301 100644
--- a/src/views/security/security.vue
+++ b/src/views/security/security.vue
@@ -23,9 +23,20 @@
       </template>
     </avue-crud>
 
-    <el-drawer title="电子地图" append-to-body="true" :visible.sync="showMap">
-      <iframe id="mapDiv" ref="mapDiv" src="/map/index.html?openid=scurityMap&ISinit=1" frameborder="0" width="100%"
+    <!-- <el-drawer title="电子地图" append-to-body="true" :visible.sync="showMap">
+      <iframe id="mapDiv" ref="mapDiv" src="/map/index.html?ISinit=1&openid=SecurityMap" frameborder="0" width="100%"
               height="100%"></iframe>
+    </el-drawer> -->
+    <el-drawer title="电子地图" append-to-body="true" :visible.sync="showMap">
+      <iframe
+                id="securityMap"
+                ref="securityMap"
+                :src="baseUrl"
+                frameborder="0"
+                width="100%"
+                height="100%"
+                name="securityMap"
+              ></iframe>
     </el-drawer>
   </basic-container>
 </template>
@@ -45,6 +56,7 @@
   export default {
     data() {
       return {
+        baseUrl:"/map/index.html?ISinit=1",
         form: {},
         query: {},
         loading: true,
@@ -58,7 +70,7 @@
         selectionList: [],
         option: {
           height: 'auto',
-          calcHeight: 30,
+          calcHeight: 54,
           tip: false,
           searchShow: true,
           searchMenuSpan: 6,
@@ -106,11 +118,11 @@
               prop: "online_status",
               dicData: [{
                 label: "离线",
-                value: 0
+                value: "0"
               },
                 {
                   label: "在线",
-                  value: 1
+                  value: "1"
                 },
               ],
             },
@@ -233,17 +245,41 @@
             });
           });
       },
+      //打开地图
       handleMap(row) {
-        this.showMap = true;
+        var that =this;
+        this.showMap=true;
+        if(row.jd=="" || row.jd=="0.0"){
+          var rwjd = "115.862321";
+          var rwwd = "28.591108";
+          that.baseUrl = `/map/index.html?ISinit=1&openid=SecurityMap&jd=${rwjd}&wd=${rwwd}&code=${row.code}&name=${row.realName}`;
+        }else{
+          that.baseUrl = `/map/index.html?ISinit=1&openid=SecurityMap&jd=${row.jd}&wd=${row.wd}&code=${row.code}&name=${row.realName}`;
+        }
+        
         this.$nextTick(() => {
-          this.$refs.mapDiv.onload = () => {
-            window.frames[0].init("SecurityMap", {
-              x: row.jd,
-              y: row.wd,
-              code:row.code
-            });
-          };
-        })
+          this.$refs.securityMap.onload = () => {
+            if (window.frames[1].init) {
+              if(row.jd=="" || row.jd=="0.0"){
+                //如果处警员无位置信息,则赋值一个默认数据,否则地图无法加载
+                window.frames[1].init("SecurityMap", {
+                                x: rwjd,
+                                y: rwwd,
+                                code:row.code
+                            });
+              }else{
+                window.frames[1].init("SecurityMap", {
+                                x: row.jd,
+                                y: row.wd,
+                                code:row.code
+                            });
+              }
+              
+            } else {
+              console.log(`没有找到到window.frames[1].init`)
+            }
+          }
+        });
       },
       handleDelete() {
         if (this.selectionList.length === 0) {

--
Gitblit v1.9.3