From 8d837b97ffb27e4e26f067c1febde353bfdf91cf Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Fri, 23 Apr 2021 09:16:27 +0800
Subject: [PATCH] Merge branch 'master' of http://s16s652780.51mypc.cn:49896/r/jfpt-Vue

---
 public/map/widgets/securityMap/SecurityMap.js |  148 ++++++++++++++++++++++---------------------------
 1 files changed, 67 insertions(+), 81 deletions(-)

diff --git a/public/map/widgets/securityMap/SecurityMap.js b/public/map/widgets/securityMap/SecurityMap.js
index 1ca59f9..afed30a 100644
--- a/public/map/widgets/securityMap/SecurityMap.js
+++ b/public/map/widgets/securityMap/SecurityMap.js
@@ -125,18 +125,10 @@
         _siteLayer: new GraphicsLayer(),
         layuiLayer: null,
         layuiLadate: null,
-        tabIndex: 0,
 
         // 保留添加实体图层的变量
         addEntitys: null,
         entitysData: [],
-
-
-        // 用来存储区域名称
-        globalRegionName: null,
-
-        // 用来区域得最大最小经纬度
-        currentDrawing: [],
 
         // 存储新增点,线,面,数据的地方
         polygonData: [],
@@ -149,9 +141,6 @@
 
         //当前处警员是否已有电子围栏
         isEngineer: false,
-
-        //当前处警员是否有位置信息
-        isPosition: true,
 
         // 用来记录巡逻区域或者巡逻路线的下标的
         patrolIndex: 0,
@@ -180,6 +169,7 @@
             this._map = options.map;
             objThis = this;
 
+            //创建图层
             this.addEntitys = new GraphicsLayer({
                 id: 'addEntitys'
             });
@@ -208,47 +198,43 @@
             //删除电子围栏点击事件
             $(".mapBtn .delete").click(function() {
                 //需选中电子围栏,然后进行删除
-                if (that.isChecked) {
-                    that.addPolygonEntitys.clear();
+                layer.confirm('是否确认删除', {
+                    btn: ['确定', '取消'], //按钮
+                    title: false
+                }, function() {
                     //删除数据库数据
-                    //更新电子围栏数据
                     $.ajax({
-                            url: that.pathUrl + '/enclosure/enclosure/deleteByAnumber',
-                            type: 'POST',
-                            dataType: 'JSON',
-                            data: {
-                                anumber: anumber
-                            },
-                            success: function(result) {
-                                if (result.code == 200) {}
+                        url: that.pathUrl + '/enclosure/enclosure/deleteByAnumber',
+                        type: 'POST',
+                        dataType: 'JSON',
+                        data: {
+                            anumber: anumber
+                        },
+                        success: function(result) {
+                            if (result.code == 200) {
+                                layui.use('layer', function() {
+                                    layui.layer.msg('删除电子围栏成功!')
+                                })
                             }
-                        })
-                        //修改围栏状态
-                    that.isEngineer = false;
-                } else {
-                    layui.use('layer', function() {
-                        layui.layer.msg('请先选中需要删除的电子围栏');
+                        }
                     })
-                }
+                    that.addPolygonEntitys.clear();
+                    //修改围栏状态
+                    that.isEngineer = false;
+                })
             })
 
             //新增电子围栏
             $('.mapBtn .insert').click(function() {
-                if (that.isPosition) {
-                    if (that.isEngineer) {
-                        layui.use('layer', function() {
-                            layui.layer.msg('已存在电子围栏');
-                        })
-                    } else {
-                        layui.use('layer', function() {
-                            layui.layer.msg('请开始划分电子围栏');
-                        })
-                        that.polygonFlag = true;
-                    }
+                if (that.isEngineer) {
+                    layui.use('layer', function() {
+                        layui.layer.msg('已存在电子围栏');
+                    })
                 } else {
                     layui.use('layer', function() {
-                        layui.layer.msg('当前处警员无位置信息,不能划分电子围栏');
+                        layui.layer.msg('请开始划分电子围栏');
                     })
+                    that.polygonFlag = true;
                 }
             })
 
@@ -275,50 +261,46 @@
             var lttd = that.getQueryStringByKey('wd');
             anumber = that.getQueryStringByKey('code');
             realname = that.getQueryString('name');
-            console.log(lgtd, 1111);
             //如果处警员的位置信息存在
             if (lgtd != null && lgtd != "") {
                 //所在位置标记
                 that.addPoint(that.addEntitys, lgtd, lttd, './images/security.png');
-                //获取当前处警员的电子围栏信息
-                $.ajax({
-                    url: this.pathUrl + '/enclosure/enclosure/selectEnclosureDetail',
-                    type: 'GET',
-                    dataType: 'JSON',
-                    data: {
-                        anumber: anumber
-                    },
-                    success: function(result) {
-                        //如果已有电子围栏信息,展示出围栏区域,并且可以编辑
-                        if (result.code == 200) {
-                            if (JSON.stringify(result.data) != "{}") {
-                                var entityArr = [];
-                                var coordinate = result.data.coordinate.match(/\(([^)]*)\)/).toString();
-                                var a = coordinate.indexOf("(");
-                                var b = coordinate.indexOf(")");
-                                coordinate = coordinate.substring(a + 1, b) + "";
-                                if (coordinate && coordinate != '') {
-                                    coordinate = coordinate.split(',');
-                                    for (var i = 0; i < coordinate.length; i++) {
-                                        entityArr.push([Number(coordinate[i].split(' ')[0]), Number(coordinate[i].split(' ')[1])]);
-                                    }
+            }
+
+            //获取当前处警员的电子围栏信息
+            $.ajax({
+                url: this.pathUrl + '/enclosure/enclosure/selectEnclosureDetail',
+                type: 'GET',
+                dataType: 'JSON',
+                data: {
+                    anumber: anumber
+                },
+                success: function(result) {
+                    //如果已有电子围栏信息,展示出围栏区域,并且可以编辑
+                    if (result.code == 200) {
+                        if (JSON.stringify(result.data) != "{}") {
+                            var entityArr = [];
+                            var coordinate = result.data.coordinate.match(/\(([^)]*)\)/).toString();
+                            var a = coordinate.indexOf("(");
+                            var b = coordinate.indexOf(")");
+                            coordinate = coordinate.substring(a + 1, b) + "";
+                            if (coordinate && coordinate != '') {
+                                coordinate = coordinate.split(',');
+                                for (var i = 0; i < coordinate.length; i++) {
+                                    entityArr.push([Number(coordinate[i].split(' ')[0]), Number(coordinate[i].split(' ')[1])]);
                                 }
-                                that.isEngineer = true;
-                                that.addPolygon(that.addPolygonEntitys, entityArr);
-                            } else {
-                                //如果无电子围栏信息,则提示请编辑电子围栏信息
-                                //编辑好电子围栏信息后,将当前处警员的电子围栏信息保存到数据库
-                                that.newElectronicFenceId = null;
-                                //that.polygonFlag = true;
-                                that.newElectronicFenceId = anumber;
                             }
+                            that.isEngineer = true;
+                            that.addPolygon(that.addPolygonEntitys, entityArr);
+                        } else {
+                            //如果无电子围栏信息,则提示请编辑电子围栏信息
+                            //编辑好电子围栏信息后,将当前处警员的电子围栏信息保存到数据库
+                            that.newElectronicFenceId = null;
+                            that.newElectronicFenceId = anumber;
                         }
                     }
-                })
-            } else {
-                //当前处警员没有位置信息,则默认定位到市中心位置
-                that.isPosition = false;
-            }
+                }
+            })
 
             //调用点击事件
             that.clickHand();
@@ -357,8 +339,7 @@
 
                         //将数据存入数据库
                         $.ajax({
-                            url: that
-                                .pathUrl + '/enclosure/enclosure/insertes',
+                            url: that.pathUrl + '/enclosure/enclosure/insertes',
                             type: 'POST',
                             dataType: 'JSON',
                             data: {
@@ -367,7 +348,11 @@
                                 routeInfo: dataStr
                             },
                             success: function(result) {
-                                if (result.code == 200) {}
+                                if (result.code == 200) {
+                                    layui.use('layer', function() {
+                                        layui.layer.msg('新增电子围栏成功!')
+                                    })
+                                }
                             }
                         })
                     }
@@ -384,7 +369,6 @@
         // 鼠标点击事件
         clickHand: function() {
             var that = this;
-
             var self = this;
             self._map.onClick = mapClick;
 
@@ -605,5 +589,7 @@
         }
 
     });
+
+
     return Widget;
 });
\ No newline at end of file

--
Gitblit v1.9.3