南昌市物联网技防平台-前端
shuishen
2021-04-23 8d837b97ffb27e4e26f067c1febde353bfdf91cf
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,10 +198,11 @@
            //删除电子围栏点击事件
            $(".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',
@@ -220,21 +211,21 @@
                                anumber: anumber
                            },
                            success: function(result) {
                                if (result.code == 200) {}
                            if (result.code == 200) {
                                layui.use('layer', function() {
                                    layui.layer.msg('删除电子围栏成功!')
                                })
                            }
                            }
                        })
                    that.addPolygonEntitys.clear();
                        //修改围栏状态
                    that.isEngineer = false;
                } else {
                    layui.use('layer', function() {
                        layui.layer.msg('请先选中需要删除的电子围栏');
                    })
                }
            })
            //新增电子围栏
            $('.mapBtn .insert').click(function() {
                if (that.isPosition) {
                    if (that.isEngineer) {
                        layui.use('layer', function() {
                            layui.layer.msg('已存在电子围栏');
@@ -244,11 +235,6 @@
                            layui.layer.msg('请开始划分电子围栏');
                        })
                        that.polygonFlag = true;
                    }
                } else {
                    layui.use('layer', function() {
                        layui.layer.msg('当前处警员无位置信息,不能划分电子围栏');
                    })
                }
            })
@@ -275,11 +261,12 @@
            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',
@@ -309,16 +296,11 @@
                                //如果无电子围栏信息,则提示请编辑电子围栏信息
                                //编辑好电子围栏信息后,将当前处警员的电子围栏信息保存到数据库
                                that.newElectronicFenceId = null;
                                //that.polygonFlag = true;
                                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;
});