From 14e02654e0545ee69456d64aef2f35c7c219d708 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Fri, 07 May 2021 11:26:49 +0800
Subject: [PATCH] 地图模式设备状态修改

---
 src/views/security/security.vue |   88 +++++++++++++++++++++++++++++++++++--------
 1 files changed, 71 insertions(+), 17 deletions(-)

diff --git a/src/views/security/security.vue b/src/views/security/security.vue
index 17e28c7..f5e744e 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,23 +56,26 @@
   export default {
     data() {
       return {
+        baseUrl:"/map/index.html?ISinit=1",
         form: {},
         query: {},
         loading: true,
-        showMap: false,
+        showMap: true,
         page: {
           pageSize: 10,
           currentPage: 1,
           total: 0
         },
+        dialogVisible: false,
         selectionList: [],
         option: {
           height: 'auto',
-          calcHeight: 30,
+          calcHeight: 54,
           tip: false,
           searchShow: true,
           searchMenuSpan: 6,
-          border: true,
+          border: false,
+          stripe: true,
           index: true,
           viewBtn: true,
           selection: true,
@@ -94,6 +108,23 @@
                 message: "请输入名称",
                 trigger: "blur"
               }]
+            },
+            {
+              label: "所属部门",
+              prop: "deptName"
+            },
+            {
+              label: "在线状态",
+              prop: "online_status",
+              dicData: [{
+                label: "离线",
+                value: "0"
+              },
+                {
+                  label: "在线",
+                  value: "1"
+                },
+              ],
             },
             {
               label: "性别",
@@ -139,6 +170,7 @@
             {
               label: "创建时间",
               prop: "createTime",
+              width:160,
               display: false,
               rules: [{
                 required: true,
@@ -168,6 +200,9 @@
         });
         return ids.join(",");
       }
+    },
+    mounted() {
+      this.showMap = false;
     },
     methods: {
       rowSave(row, done, loading) {
@@ -213,19 +248,38 @@
             });
           });
       },
+      //打开地图
       handleMap(row) {
-        this.showMap = true;
-        console.log("row.id="+row.id);
-        console.log("row.wd="+row.wd);
-        this.$nextTick(() => {
-          this.$refs.mapDiv.onload = () => {
-            window.frames[0].init("SecurityMap", {
-              x: row.jd,
-              y: row.wd,
-              code:row.code
-            });
-          };
-        })
+        var that =this;
+        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.showMap=true;
+        this.$refs.securityMap.onload = () => {
+          if (window.frames[0].init) {
+            if(row.jd=="" || row.jd=="0.0"){
+              //如果处警员无位置信息,则赋值一个默认数据,否则地图无法加载
+              window.frames[0].init("SecurityMap", {
+                              x: rwjd,
+                              y: rwwd,
+                              code:row.code
+                          });
+            }else{
+              window.frames[0].init("SecurityMap", {
+                              x: row.jd,
+                              y: row.wd,
+                              code:row.code
+                          });
+            }
+            
+          } else {
+            console.log(`没有找到到window.frames[0].init`)
+          }
+        }
       },
       handleDelete() {
         if (this.selectionList.length === 0) {

--
Gitblit v1.9.3