shuishen
2021-07-20 0c9b152fd0a44fd54d7fe4c8b787d5040d86258a
public/map/widgets/patrolManagement/PatrolManagement.js
@@ -7,2037 +7,2111 @@
 * @LastEditTime: 2019-12-14 14:44:57
 */
define([
    "dojo",
    "dojo/_base/declare",
    "dojo/_base/lang",
    "base/BaseWidget",
    "dojo/text!widgets/patrolManagement/template.html",
    "base/AppEvent",
    "base/ConfigData",
    "widgets/patrolManagement/config",
    "dojo/dom",
    "dojo/dom-construct",
    "dojo/dom-attr",
    "dojo/dom-style",
    "dojo/on",
    "esri/layers/ArcGISDynamicMapServiceLayer",
    "esri/layers/ArcGISTiledMapServiceLayer",
    "esri/layers/FeatureLayer",
    "controls/tab/TabControl",
    "esri/dijit/SymbolStyler",
    "esri/styles/basic",
    "dojo/_base/array",
    "esri/InfoTemplate",
    "esri/tasks/query",
    "esri/tasks/QueryTask",
    "esri/Color",
    "esri/toolbars/edit",
    "esri/graphic",
    "esri/geometry/Point",
    "esri/geometry/Polyline",
    "esri/geometry/Polygon",
    "esri/geometry/Extent",
    "esri/tasks/FeatureSet",
    "esri/renderers/HeatmapRenderer",
    "esri/symbols/SimpleLineSymbol",
    "esri/symbols/SimpleFillSymbol",
    "esri/symbols/PictureMarkerSymbol",
    "esri/symbols/SimpleMarkerSymbol",
    "esri/SpatialReference",
    "esri/tasks/GeometryService",
    "esri/tasks/ProjectParameters",
    "esri/layers/GraphicsLayer",
    "esri/layers/LabelLayer",
    "esri/symbols/TextSymbol",
    "esri/renderers/SimpleRenderer",
    "esri/renderers/ClassBreaksRenderer",
    "esri/tasks/Geoprocessor",
    "esri/tasks/DataFile",
    "esri/geometry/webMercatorUtils",
    "esri/symbols/Font",
    "esri/geometry/ScreenPoint",
    "esri/layers/ImageParameters",
    "esri/geometry/geometryEngine",
    "esri/dijit/PopupTemplate",
    "widgets/clientManagement/FlareClusterLayer_v3",
    "dojo/domReady!"
  "dojo",
  "dojo/_base/declare",
  "dojo/_base/lang",
  "base/BaseWidget",
  "dojo/text!widgets/patrolManagement/template.html",
  "base/AppEvent",
  "base/ConfigData",
  "widgets/patrolManagement/config",
  "dojo/dom",
  "dojo/dom-construct",
  "dojo/dom-attr",
  "dojo/dom-style",
  "dojo/on",
  "esri/layers/ArcGISDynamicMapServiceLayer",
  "esri/layers/ArcGISTiledMapServiceLayer",
  "esri/layers/FeatureLayer",
  "controls/tab/TabControl",
  "esri/dijit/SymbolStyler",
  "esri/styles/basic",
  "dojo/_base/array",
  "esri/InfoTemplate",
  "esri/tasks/query",
  "esri/tasks/QueryTask",
  "esri/Color",
  "esri/toolbars/edit",
  "esri/graphic",
  "esri/geometry/Point",
  "esri/geometry/Polyline",
  "esri/geometry/Polygon",
  "esri/geometry/Extent",
  "esri/tasks/FeatureSet",
  "esri/renderers/HeatmapRenderer",
  "esri/symbols/SimpleLineSymbol",
  "esri/symbols/SimpleFillSymbol",
  "esri/symbols/PictureMarkerSymbol",
  "esri/symbols/SimpleMarkerSymbol",
  "esri/SpatialReference",
  "esri/tasks/GeometryService",
  "esri/tasks/ProjectParameters",
  "esri/layers/GraphicsLayer",
  "esri/layers/LabelLayer",
  "esri/symbols/TextSymbol",
  "esri/renderers/SimpleRenderer",
  "esri/renderers/ClassBreaksRenderer",
  "esri/tasks/Geoprocessor",
  "esri/tasks/DataFile",
  "esri/geometry/webMercatorUtils",
  "esri/symbols/Font",
  "esri/geometry/ScreenPoint",
  "esri/layers/ImageParameters",
  "esri/geometry/geometryEngine",
  "esri/dijit/PopupTemplate",
  "widgets/clientManagement/FlareClusterLayer_v3",
  "dojo/domReady!"
], function (
    dojo,
    declare,
    lang,
    BaseWidget,
    template,
    AppEvent,
    ConfigData,
    config,
    dom,
    domConstruct,
    domAttr,
    domStyle,
    on,
    ArcGISDynamicMapServiceLayer,
    ArcGISTiledMapServiceLayer,
    FeatureLayer,
    TabControl,
    SymbolStyler,
    basic,
    arrayUtils,
    InfoTemplate,
    Query,
    QueryTask,
    Color,
    Edit,
    Graphic,
    Point,
    Polyline,
    Polygon,
    Extent,
    FeatureSet,
    HeatmapRenderer,
    SimpleLineSymbol,
    SimpleFillSymbol,
    PictureMarkerSymbol,
    SimpleMarkerSymbol,
    SpatialReference,
    GeometryService,
    ProjectParameters,
    GraphicsLayer,
    LabelLayer,
    TextSymbol,
    SimpleRenderer,
    ClassBreaksRenderer,
    Geoprocessor,
    DataFile,
    webMercatorUtils,
    Font,
    ScreenPoint,
    ImageParameters,
    geometryEngine,
    PopupTemplate,
    FlareClusterLayer
  dojo,
  declare,
  lang,
  BaseWidget,
  template,
  AppEvent,
  ConfigData,
  config,
  dom,
  domConstruct,
  domAttr,
  domStyle,
  on,
  ArcGISDynamicMapServiceLayer,
  ArcGISTiledMapServiceLayer,
  FeatureLayer,
  TabControl,
  SymbolStyler,
  basic,
  arrayUtils,
  InfoTemplate,
  Query,
  QueryTask,
  Color,
  Edit,
  Graphic,
  Point,
  Polyline,
  Polygon,
  Extent,
  FeatureSet,
  HeatmapRenderer,
  SimpleLineSymbol,
  SimpleFillSymbol,
  PictureMarkerSymbol,
  SimpleMarkerSymbol,
  SpatialReference,
  GeometryService,
  ProjectParameters,
  GraphicsLayer,
  LabelLayer,
  TextSymbol,
  SimpleRenderer,
  ClassBreaksRenderer,
  Geoprocessor,
  DataFile,
  webMercatorUtils,
  Font,
  ScreenPoint,
  ImageParameters,
  geometryEngine,
  PopupTemplate,
  FlareClusterLayer
) {
    var Widget = declare([BaseWidget], {
        widgetName: "PatrolManagement",
        label: "巡逻管理",
        templateString: template,
        _map: null,
        objThis: null,
        _siteLayer: new GraphicsLayer(),
        layuiLayer: null,
        layuiLadate: null,
        tabIndex: 0,
  var Widget = declare([BaseWidget], {
    widgetName: "PatrolManagement",
    label: "巡逻管理",
    templateString: template,
    _map: null,
    objThis: null,
    _siteLayer: new GraphicsLayer(),
    layuiLayer: null,
    layuiLadate: null,
    tabIndex: 0,
        // 保留添加实体图层的变量
        addEntitys: null,
        entitysData: [],
    // 保留添加实体图层的变量
    addEntitys: null,
    entitysData: [],
        // 是否派发保安的 文字
        treatmentIndex: null,
        securityFlag: false,
        editParentInd: null,
    // 是否派发保安的 文字
    treatmentIndex: null,
    securityFlag: false,
    editParentInd: null,
        // 存储新增点,线,面,数据的地方
        polygonData: [],
        polygonFlag: false,
        editToolbar: null,
        addPolygonEntitys: null,
    // 存储新增点,线,面,数据的地方
    polygonData: [],
    polygonFlag: false,
    editToolbar: null,
    addPolygonEntitys: null,
        // 所有的面图层
        entityPolygonAll: null,
    // 所有的面图层
    entityPolygonAll: null,
        // 用来存储区域名称
        globalRegionName: null,
    // 用来存储区域名称
    globalRegionName: null,
        // 用来区域得最大最小经纬度
        currentDrawing: [],
    // 用来区域得最大最小经纬度
    currentDrawing: [],
        // 巡逻区域或者巡逻路线的描述
        routeOrRegionDescribe: null,
    // 巡逻区域或者巡逻路线的描述
    routeOrRegionDescribe: null,
        // 用来记录巡逻区域或者巡逻路线的下标的
        patrolIndex: 0,
    // 用来记录巡逻区域或者巡逻路线的下标的
    patrolIndex: 0,
        // 拖拽
        isDown: false,
        x: 0,
        y: 0,
        offset: null,
        moveThis: null,
        // 电子围栏需要新增的Id
        newElectronicFenceId: null,
    // 拖拽
    isDown: false,
    x: 0,
    y: 0,
    offset: null,
    moveThis: null,
    // 电子围栏需要新增的Id
    newElectronicFenceId: null,
        // 新增路线时,派发人员,人员名称,以及人员id
        peopleRealName: null,
        pepleRealId: null,
        constructor: function (options, srcRefNode) {
            this._map = options.map;
            objThis = this;
    // 新增路线时,派发人员,人员名称,以及人员id
    peopleRealName: null,
    pepleRealId: null,
    constructor: function (options, srcRefNode) {
      this._map = options.map;
      objThis = this;
            this.addEntitys = new GraphicsLayer({id: 'addEntitys'});
      this.addEntitys = new GraphicsLayer({
        id: 'addEntitys'
      });
            // 添加点面线的图层
            this.addPolygonEntitys = new GraphicsLayer({id: 'addPolygonEntitys'});
            // 添加所有图层的地方
            this.entityPolygonAll = new GraphicsLayer({id: 'entityPolygonAll'});
      // 添加点面线的图层
      this.addPolygonEntitys = new GraphicsLayer({
        id: 'addPolygonEntitys'
      });
      // 添加所有图层的地方
      this.entityPolygonAll = new GraphicsLayer({
        id: 'entityPolygonAll'
      });
            this._map.addLayer(this.addEntitys);
      this._map.addLayer(this.addEntitys);
            this._map.addLayer(this.addPolygonEntitys);
            this._map.addLayer(this.entityPolygonAll);
      this._map.addLayer(this.addPolygonEntitys);
      this._map.addLayer(this.entityPolygonAll);
        },
    },
        startup: function () {
            objThis._map.addLayer(objThis._siteLayer);
            var that = this;
            // 顶部tab得切换事件
            $('.police-dispatching-tab li').click(function () {
                if (that.tabIndex == $(this).index()) return;
                if (that.entitysData.length > 0) {
                    that.addEntitys.clear();
                    that.entitysData = [];
                }
    startup: function () {
      objThis._map.addLayer(objThis._siteLayer);
      var that = this;
      // 顶部tab得切换事件
      $('.police-dispatching-tab li').click(function () {
        if (that.tabIndex == $(this).index()) return;
        if (that.entitysData.length > 0) {
          that.addEntitys.clear();
          that.entitysData = [];
        }
                that.patrolIndex = 0;
                that.polygonFlag = false;
                that.entityPolygonAll.clear();
                that.modifyPolygon();
        that.patrolIndex = 0;
        that.polygonFlag = false;
        that.entityPolygonAll.clear();
        that.modifyPolygon();
                // 切换时清除新增点线面数组中保存得数据,与清除地图上得实体
                that.polygonData = [];
                that.addPolygonEntitys.clear();
        // 切换时清除新增点线面数组中保存得数据,与清除地图上得实体
        that.polygonData = [];
        that.addPolygonEntitys.clear();
                $(this).addClass('on').siblings().removeClass('on');
                var ind = $(this).index();
                $($('.police-container > div')[ind]).stop().show().siblings().stop().hide();
                if (ind == 0) {
                    $('#distributeCategory div:eq(0)').html('全部' + '<i></i>');
                    $('#distributeState div:eq(0)').html('全部' + '<i></i>');
                    that.getPoliceTable($('.police-container-distribute').find('.tbody tbody'), $('#dispatchingStartTime').val(), $('#dispatchingEndTime').val(), '', '', '');
                } else if (ind == 1) {
                    // that.getOwnerTable($($('.analysis-container > div')[ind]).find('.tbody tbody'), '', '');
                    $('.police-dispatching .police-container .police-container-patrol .tab-header li:eq(0)').addClass('on').siblings().removeClass('on');
                    $('.police-dispatching .police-container .police-container-patrol .main-content>li:eq(0)').stop().show().siblings().hide();
                    that.patrolArea($('.police-dispatching .police-container .police-container-patrol .main-content>li:eq(0) .table .tbody tbody'), '');
                } else if (ind == 2) {
                    that.getSecurityPeople($('.police-dispatching .police-container .police-container-policeforce .table .tbody tbody'), '');
                }
                that.tabIndex = $(this).index();
            })
            // 警情分发中的行点击事件
            $('.police-container .police-container-distribute .table .tbody').off('click', 'tr').on('click', 'tr', function () {
                var lgtd = Number($(this).attr('lgtd'));
                var lttd = Number($(this).attr('lttd'));
                var position = new esri.geometry.Point(lgtd, lttd, new esri.SpatialReference({wkid: 4326}));//根据输入坐标信息找地图上的点
                that._map.centerAndZoom(position, 18);//缩放,10是缩放级别,可以自定义,数值越大缩放越大
            })
            // 编辑,跟进按钮元素的父元素的点击事件
            $('.police-container .police-container-distribute .table .tbody').off('click', '.operation').on('click', '.operation', function (event) {
                event.stopPropagation();
            })
            // 警情分发中的编辑按钮的点击事件
            $('.police-container .police-container-distribute .table .tbody').off('click', '.edit').on('click', '.edit', function (event) {
                event.stopPropagation();
                that.editParentInd = null;
                that.editParentInd = $(this).parent().parent().index();
                var id = $(this).attr('term-list');
                that.treatmentIndex = null;
                if (!$('.police-container-distribute-details .security-guard-nearby').is(':hidden')) {
                    $('.police-container-distribute-details .security-guard-nearby').stop().hide();
                }
                if (!$('.police-container-distribute-details').is(':hidden')) {
                    $('.police-container-distribute-details').stop().hide();
                }
                $('.police-container-distribute-details .content table tbody').empty();
                var str = '';
                $.ajax({
                    url: 'http://s16s652780.51mypc.cn/api/jingdan/jingdan/selectdInfo?deviceNumber=&id=' + id,
        $(this).addClass('on').siblings().removeClass('on');
        var ind = $(this).index();
        $($('.police-container > div')[ind]).stop().show().siblings().stop().hide();
        if (ind == 0) {
          $('#distributeCategory div:eq(0)').html('全部' + '<i></i>');
          $('#distributeState div:eq(0)').html('全部' + '<i></i>');
          that.getPoliceTable($('.police-container-distribute').find('.tbody tbody'), $('#dispatchingStartTime').val(), $('#dispatchingEndTime').val(), '', '', '');
        } else if (ind == 1) {
          // that.getOwnerTable($($('.analysis-container > div')[ind]).find('.tbody tbody'), '', '');
          $('.police-dispatching .police-container .police-container-patrol .tab-header li:eq(0)').addClass('on').siblings().removeClass('on');
          $('.police-dispatching .police-container .police-container-patrol .main-content>li:eq(0)').stop().show().siblings().hide();
          that.patrolArea($('.police-dispatching .police-container .police-container-patrol .main-content>li:eq(0) .table .tbody tbody'), '');
        } else if (ind == 2) {
          that.getSecurityPeople($('.police-dispatching .police-container .police-container-policeforce .table .tbody tbody'), '');
        }
        that.tabIndex = $(this).index();
      })
      // 警情分发中的行点击事件
      $('.police-container .police-container-distribute .table .tbody').off('click', 'tr').on('click', 'tr', function () {
        var lgtd = Number($(this).attr('lgtd'));
        var lttd = Number($(this).attr('lttd'));
        var position = new esri.geometry.Point(lgtd, lttd, new esri.SpatialReference({
          wkid: 4326
        })); //根据输入坐标信息找地图上的点
        that._map.centerAndZoom(position, 18); //缩放,10是缩放级别,可以自定义,数值越大缩放越大
      })
      // 编辑,跟进按钮元素的父元素的点击事件
      $('.police-container .police-container-distribute .table .tbody').off('click', '.operation').on('click', '.operation', function (event) {
        event.stopPropagation();
      })
      // 警情分发中的编辑按钮的点击事件
      $('.police-container .police-container-distribute .table .tbody').off('click', '.edit').on('click', '.edit', function (event) {
        event.stopPropagation();
        that.editParentInd = null;
        that.editParentInd = $(this).parent().parent().index();
        var id = $(this).attr('term-list');
        that.treatmentIndex = null;
        if (!$('.police-container-distribute-details .security-guard-nearby').is(':hidden')) {
          $('.police-container-distribute-details .security-guard-nearby').stop().hide();
        }
        if (!$('.police-container-distribute-details').is(':hidden')) {
          $('.police-container-distribute-details').stop().hide();
        }
        $('.police-container-distribute-details .content table tbody').empty();
        var str = '';
        $.ajax({
          url: 'http://s16s652780.51mypc.cn/api/jingdan/jingdan/selectdInfo?deviceNumber=&id=' + id,
          type: 'POST',
          dataType: 'JSON',
          success: function (data) {
            var result = data.data[0];
            var t = result.galarmTime.substr(0, 10);
            var e = result.galarmTime.substr(11);
            var time = t + '&nbsp;' + e;
            str += "<tr> <td>报警人姓名:</td> <td>" + result.galarmPeople + "</td> <td>联系方式:</td> <td>" + result.phoneNumber + "</td> </tr>";
            str += "<tr> <td>事发地址:</td> <td>" + result.place + "</td> <td>行政区:</td> <td>" + result.addvnm + "</td> </>";
            str += "<tr> <td>报警时间:</td> <td>" + time + "</td> <td>报警内容:</td> <td>" + result.content + "</td> </tr>";
            str += "<tr> <td>警情级别:</td> <td>" + result.level + "</td> <td>警情类别:</td> <td>" + result.waringType + "</td> </tr>";
            str += "<tr> <td>处理方式:</td> <td class='treatment-method'> <input type='radio' name='treatmentMethod' value='派发保安' lgtd=" + result.jd + " lttd=" + result.wd + "> <span>派发保安</span> <input type='radio' name='treatmentMethod' value='提示业主'> <span>提示业主</span> </td> <td>处理人:</td> <td class='securityname'></td> </tr>";
            str += "<tr> <td>是否上报110:</td> <td class='report-oneonezero'> <input type='radio' name='callPhone' value='是'> <span>是</span> <input type='radio' name='callPhone' value='否'> <span>否</span> </td> <td>设备编号:</td> <td>" + result.deviceNumber + "</td> </tr>";
            $('.police-container-distribute-details .content table tbody').append(str);
            $('.police-container-distribute-details .handle-button .confirm').attr('police-id', result.id);
            $('.police-container-distribute-details .handle-button').stop().show();
            $('.police-container-distribute-details .header h4').text('警情分发');
            $('.police-container-distribute-details').stop().show();
            $('.police-container-distribute-details .content table tbody').off('click', '.treatment-method input').on('click', '.treatment-method input', function () {
              if (that.treatmentIndex != $(this).val()) {
                if ($(this).val() == '派发保安') {
                  var str = '';
                  $('.police-container-distribute-details .security-guard-nearby .security-staff-content tbody').empty();
                  $.ajax({
                    url: 'http://s16s652780.51mypc.cn/api/position/position/selectry',
                    type: 'POST',
                    dataType: 'JSON',
                    success: function (data) {
                        var result = data.data[0];
                        var t = result.galarmTime.substr(0, 10);
                        var e = result.galarmTime.substr(11);
                        var time = t + '&nbsp;' + e;
                        str += "<tr> <td>报警人姓名:</td> <td>" + result.galarmPeople + "</td> <td>联系方式:</td> <td>" + result.phoneNumber + "</td> </tr>";
                        str += "<tr> <td>事发地址:</td> <td>" + result.place + "</td> <td>行政区:</td> <td>" + result.addvnm + "</td> </>";
                        str += "<tr> <td>报警时间:</td> <td>" + time + "</td> <td>报警内容:</td> <td>" + result.content + "</td> </tr>";
                        str += "<tr> <td>警情级别:</td> <td>" + result.level + "</td> <td>警情类别:</td> <td>" + result.waringType + "</td> </tr>";
                        str += "<tr> <td>处理方式:</td> <td class='treatment-method'> <input type='radio' name='treatmentMethod' value='派发保安' lgtd=" + result.jd + " lttd=" + result.wd + "> <span>派发保安</span> <input type='radio' name='treatmentMethod' value='提示业主'> <span>提示业主</span> </td> <td>处理人:</td> <td class='securityname'></td> </tr>";
                        str += "<tr> <td>是否上报110:</td> <td class='report-oneonezero'> <input type='radio' name='callPhone' value='是'> <span>是</span> <input type='radio' name='callPhone' value='否'> <span>否</span> </td> <td>设备编号:</td> <td>" + result.deviceNumber + "</td> </tr>";
                        $('.police-container-distribute-details .content table tbody').append(str);
                        $('.police-container-distribute-details .handle-button .confirm').attr('police-id', result.id);
                        $('.police-container-distribute-details .handle-button').stop().show();
                        $('.police-container-distribute-details .header h4').text('警情分发');
                        $('.police-container-distribute-details').stop().show();
                        $('.police-container-distribute-details .content table tbody').off('click', '.treatment-method input').on('click', '.treatment-method input', function () {
                            if (that.treatmentIndex != $(this).val()) {
                                if ($(this).val() == '派发保安') {
                                    var str = '';
                                    $('.police-container-distribute-details .security-guard-nearby .security-staff-content tbody').empty();
                                    $.ajax({
                                        url: 'http://s16s652780.51mypc.cn/api/position/position/selectry',
                                        type: 'POST',
                                        data: {
                                            coordinate: "point(" + $(this).attr('lgtd') + "," + $(this).attr('lttd') + ")"
                                        },
                                        dataType: 'JSON',
                                        success: function (data) {
                                            var result = data.data;
                                            for (var i = 0; i < result.length; i++) {
                                                str += "<tr> <td>" + (Number(i) + 1) + "</td> <td>" + result[i].sname + "</td> <td>" + result[i].distance.toFixed(2) + "</td> <td><input type='radio' name='securityStaff' securityid=" + result[i].snumber + " securityname=" + result[i].sname + "> </td> </tr>"
                                            }
                                            $('.police-container-distribute-details .security-guard-nearby .security-staff-content tbody').append(str);
                                        }
                                    })
                                    $('.police-container-distribute-details .security-guard-nearby').stop().show();
                                } else {
                                    $('.police-container-distribute-details .content table tbody .securityname').text('');
                                    $('.police-container-distribute-details .security-guard-nearby').stop().hide();
                                }
                                that.treatmentIndex = $(this).val();
                            }
                        })
                    }
                })
            })
            // 警情分发中的详情的确认按钮
            $('.police-container-distribute-details .handle-button .confirm').off('click').click(function () {
                var self = this;
                layui.use('layer', function () {
                    var layer = layui.layer;
                    if (that.treatmentIndex == null) {
                        layer.msg('请选择处理方式', {
                            shade: [0.8, '#393D49'],
                            time: 1000
                        })
                        return
                    } else {
                        if (that.treatmentIndex == '派发保安') {
                            if (that.securityFlag == false) {
                                layer.msg('请选取保安', {
                                    shade: [0.8, '#393D49'],
                                    time: 1000
                                })
                                return
                            }
                        }
                    }
                    var id = $(self).attr('police-id');
                    var handletype = null;
                    if (that.treatmentIndex != null) {
                        if (that.treatmentIndex == '派发保安') {
                            handletype = '0';
                        } else {
                            handletype = '1';
                        }
                    }
                    // 发送请求修改警单数据
                    $.ajax({
                        url: 'http://s16s652780.51mypc.cn/api/jingdan/jingdan/updateInfo',
                        type: 'POST',
                        data: {
                            id: id,
                            // handleP: $('.police-container-distribute-details .content table tbody tr:eq(4) td:eq(3)').attr('people-id'),
                            // handName: $('.police-container-distribute-details .content table tbody tr:eq(4) td:eq(3)').text(),
                            handleP: $('.police-container-distribute-details .content table tbody .securityname').attr('id'),
                            handName: $('.police-container-distribute-details .content table tbody .securityname').text(),
                            handletype: handletype,
                            type: '2'
                        },
                        dataType: 'JSON',
                        success: function (data) {
                            if (data.code == 200) {
                                if (!$('.police-container-distribute-details .security-guard-nearby').is(':hidden')) {
                                    $('.police-container-distribute-details .security-guard-nearby').stop().hide();
                                }
                                $('.police-container-distribute-details').stop().hide();
                                $('.police-container .police-container-distribute .table .tbody tr:eq(' + that.editParentInd + ') td:eq(2)').text('处理中');
                                $('.police-container .police-container-distribute .table .tbody tr:eq(' + that.editParentInd + ') td:eq(4)').html("<input class='follow-up' type='button' value='跟进' >");
                            }
                        }
                    })
                });
            })
            // 警情分发中的跟进按钮的点击事件
            $('.police-container .police-container-distribute .table .tbody').off('click', '.follow-up').on('click', '.follow-up', function () {
                var id = $(this).attr('term-list');
                if (!$('.police-container-distribute-details').is(':hidden')) {
                    $('.police-container-distribute-details').stop().hide();
                }
                $('.police-container-distribute-details .content table tbody').empty();
                var str = '';
                $.ajax({
                    url: 'http://s16s652780.51mypc.cn/api/jingdan/jingdan/selectdInfo?deviceNumber=&id=' + id,
                    type: 'POST',
                    dataType: 'JSON',
                    success: function (data) {
                        var result = data.data[0];
                        var t = result.galarmTime.substr(0, 10);
                        var e = result.galarmTime.substr(11);
                        var time = t + '&nbsp;' + e;
                        str += "<tr> <td>报警人姓名:</td> <td>" + result.galarmPeople + "</td> <td>联系方式:</td> <td>" + result.phoneNumber + "</td> </tr>";
                        str += "<tr> <td>事发地址:</td> <td>" + result.place + "</td> <td>行政区:</td> <td>" + result.addvnm + "</td> </>";
                        str += "<tr> <td>报警时间:</td> <td>" + time + "</td> <td>报警内容:</td> <td>" + result.content + "</td> </tr>";
                        str += "<tr> <td>警情级别:</td> <td>" + result.level + "</td> <td>警情类别:</td> <td>" + result.waringType + "</td> </tr>";
                        str += "<tr> <td>处理方式:</td> <td class='treatment-method'> " + (result.type == 2 ? '处理中' : '待处理') + " </td> <td>处理人:</td> <td class='securityname'> " + result.handName + " </td> </tr>";
                        str += "<tr> <td>是否上报110:</td> <td class='report-oneonezero'> <input type='radio' name='callPhone' value='是'> <span>是</span> <input type='radio' name='callPhone' value='否'> <span>否</span> </td> <td>设备编号:</td> <td>" + 1111 + "</td> </tr>";
                        $('.police-container-distribute-details .content table tbody').append(str);
                        $('.police-container-distribute-details .header h4').text('警情跟进');
                        $('.police-container-distribute-details .handle-button').stop().hide();
                        $('.police-container-distribute-details').stop().show();
                    }
                })
            })
            // 警情分发中的详情的取消按钮
            $('.police-container-distribute-details .handle-button .cancel').off('click').click(function () {
                if (!$('.police-container-distribute-details .security-guard-nearby').is(':hidden')) {
                    $('.police-container-distribute-details .security-guard-nearby').stop().hide();
                }
                $('.police-container-distribute-details').stop().hide();
            })
            // 警情分发中详情的关闭按钮
            $('.police-container-distribute-details .header .close').off('click').click(function () {
                if (!$('.police-container-distribute-details .security-guard-nearby').is(':hidden')) {
                    $('.police-container-distribute-details .security-guard-nearby').stop().hide();
                }
                $('.police-container-distribute-details').stop().hide();
            })
            // 派发保安的确认按钮
            $('.police-container-distribute-details .security-guard-nearby .security-staff-confirm input').off('click').click(function () {
                var list = $('.police-container-distribute-details .security-guard-nearby .security-staff-content input');
                that.securityFlag = false;
                var id = null;
                var securityname = null;
                for (var i = 0; i < list.length; i++) {
                    if ($(list[i]).prop('checked') == true) {
                        that.securityFlag = true;
                        id = $(list[i]).attr('securityid');
                        securityname = $(list[i]).attr('securityname');
                        break;
                    }
                }
                if (that.securityFlag == false) {
                    layui.use('layer', function () {
                        var layer = layui.layer;
                        layer.msg('请选取保安', {
                            shade: [0.8, '#393D49'],
                            time: 1000
                        })
                    });
                } else {
                    $('.police-container-distribute-details .content table tbody .securityname').attr('id', id).text(securityname);
                    $('.police-container-distribute-details .security-guard-nearby').stop().hide();
                }
            })
            // 警情信息中类别移入事件
            $('#distributeCategory').mouseenter(function () {
                if ($('#distributeCategory .select-list').is(':hidden')) {
                    $('#distributeCategory .select-list').stop().slideDown(0);
                }
            })
            // 警情信息中得类别移出事件
            $('#distributeCategory').mouseleave(function () {
                if (!$('#distributeCategory .select-list').is(':hidden')) {
                    $('#distributeCategory .select-list').stop().slideUp(0);
                }
            })
            // 警情信息中类别移入事件
            $('#distributeState').mouseenter(function () {
                if ($('#distributeState .select-list').is(':hidden')) {
                    $('#distributeState .select-list').stop().slideDown(0);
                }
            })
            // 警情信息中得类别移出事件
            $('#distributeState').mouseleave(function () {
                if (!$('#distributeState .select-list').is(':hidden')) {
                    $('#distributeState .select-list').stop().slideUp(0);
                }
            })
            //  警情信息类,业主信息类,设备信息类别,具体项的点击事件
            $('.police-container > div .select-list').off('click', 'li').on('click', 'li', function (event) {
                var text = $(this).text();
                $(this).parent().parent().prev().html(text + '<i></i>');
                $(this).parent().parent().stop().slideUp(0);
                if (text == '全部') text = '';
                var textOrr = '';
                var textList = '';
                var stateType = '';
                if (that.tabIndex == 0) {
                    // that.getPoliceTable($('.analysis-container-police').find('.tbody tbody'), $('#dispatchingStartTime').val(), $('#dispatchingEndTime').val(), text);
                    if ($(this).attr('key')) {
                        textOrr = $('#distributeState div:eq(0)').text().trim();
                        textList = $('.police-dispatching .police-container .distribute-state .select-list ul li');
                        for (var i = 0; i < textList.length; i++) {
                            if (textOrr == $(textList[i]).text()) {
                                stateType = $(textList[i]).attr('statetype');
                            }
                        }
                        that.getPoliceTable($('.police-container-distribute').find('.tbody tbody'), $('#dispatchingStartTime').val(), $('#dispatchingEndTime').val(), '', $(this).attr('addvcd'), stateType);
                    } else {
                        textOrr = $('#distributeCategory div:eq(0)').text().trim();
                        textList = $('.police-dispatching .police-container .distribute-district .select-list ul li');
                        for (var i = 0; i < textList.length; i++) {
                            if (textOrr == $(textList[i]).text()) {
                                stateType = $(textList[i]).attr('addvcd');
                            }
                        }
                        that.getPoliceTable($('.police-container-distribute').find('.tbody tbody'), $('#dispatchingStartTime').val(), $('#dispatchingEndTime').val(), '', stateType, $(this).attr('stateType'));
                    }
                }
            })
            // 时间查询
            $('#dispatchingSelectTime').off('click').click(function () {
                var times = $(this).prevAll();
                // 开始时间
                var startTime = $(times[1]).val();
                // 结束时间
                var endTime = $(times[0]).val();
                var textOne = $('#distributeCategory div:eq(0)').text().trim();
                var addvcd = '';
                var list = $('.police-dispatching .police-container .distribute-district .select-list ul li');
                if (textOne == '全部') {
                    addvcd = '';
                } else {
                    if (list.length > 0) {
                        for (var i = 0; i < list.length; i++) {
                            if (textOne == $(list[i]).text()) {
                                addvcd = $(list[i]).attr('addvcd')
                            }
                        }
                    }
                }
                var textTwo = $('#distributeState div:eq(0)').text().trim();
                var stateType = '';
                var stateList = $('.police-dispatching .police-container .distribute-state .select-list ul li');
                if (textTwo == '全部') {
                    stateType = '';
                } else {
                    if (stateList.length > 0) {
                        for (var i = 0; i < stateList.length; i++) {
                            if (textTwo == $(stateList[i]).text()) {
                                stateType = $(stateList[i]).attr('statetype')
                            }
                        }
                    }
                }
                that.getPoliceTable($('.police-container-distribute').find('.tbody tbody'), startTime, endTime, '', addvcd, stateType);
            })
            //  巡逻区域中的行点击事件
            $('.police-container .police-container-patrol .main-content>li:eq(0) .table .tbody').off('click', 'tr').on('click', 'tr', function () {
                var flyid = $(this).attr('flyid');
                var flyname = $(this).attr('flyname');
                var extent = null;
                for (var i = 0; i < that.currentDrawing.length; i++) {
                    if (flyid == that.currentDrawing[i].id && flyname == that.currentDrawing[i].regionName) {
                        extent = that.currentDrawing[i].extent;
                    }
                }
                // debugger
                that._map.setExtent(extent.expand(1.5));
                // var myFeatureExtent = new Extent(extent.)
                // thisObj._map.setExtent(myFeatureExtent.expand(2));
                // var lgtd = Number($(this).attr('lgtd'));
                // var lttd = Number($(this).attr('lttd'));
                // var position = new esri.geometry.Point(lgtd, lttd, new esri.SpatialReference({ wkid: 4326 }));//根据输入坐标信息找地图上的点
                // that._map.centerAndZoom(position, 14);//缩放,10是缩放级别,可以自定义,数值越大缩放越大
            })
            // 巡逻区域的新增按钮
            $('.police-container .police-container-patrol .main-content>li:eq(0) .distribute-table-content .operation .add').off('click').click(function () {
                var url = './popup/html/region-name.html';
                layui.use('layer', function () {
                    that.layuiLayer = layui.layer;
                    that.layuiLayer.config({
                        extend: 'myskin/region-name.css'
                    });
                    that.layuiLayer.close(that.layuiLayer.index);
                    that.layuiLayer.open({
                        title: '区域名称',
                        type: 2,
                        shadeClose: false,
                        shade: 0.3,
                        maxmin: false, //开启最大化最小化按钮
                        area: ['320px', '206px'],
                        offset: 'auto',
                        skin: 'region-name',
                        content: url,
                        closeBtn: 1,
                        success: function (layero, index) {
                            layero.find('iframe').contents().find(".start-editing").off('click').click(function () {
                                // 区域名称
                                var regionName = layero.find('iframe').contents().find('.region-name-input').val();
                                var regionDescribe = layero.find('iframe').contents().find('.region-name-textarea').val();
                                if (regionName == '') {
                                    that.layuiLayer.msg('请填写区域名称', {
                                        time: 1000
                                    })
                                    return
                                }
                                if (regionDescribe == '') {
                                    that.layuiLayer.msg('请填写区域描述', {
                                        time: 1000
                                    })
                                    return
                                }
                                that.globalRegionName = regionName;
                                that.routeOrRegionDescribe = regionDescribe;
                                // 开启,可以勾选线段
                                that.polygonFlag = true;
                                that.layuiLayer.close(index);
                            })
                        }
                    });
                })
            })
            // 查找按钮
            $('.police-container .police-container-patrol .main-content>li:eq(0) .distribute-table-content .operation .query').off('click').click(function () {
                var routerName = $('.police-container .police-container-patrol .main-content>li:eq(0) .distribute-table-content .route-name').val();
                // if (routerName == '') {
                //   layui.use('layer', function () {
                //     layui.layer.msg('请填写区域名称', {
                //       time: 1000
                //     })
                //   })
                //   return
                // }
                that.patrolArea($('.police-dispatching .police-container .police-container-patrol .table .tbody tbody'), routerName);
                $('.police-container .police-container-patrol .main-content>li:eq(0) .distribute-table-content .route-name').val('');
            })
            // 保安出警管理表格中点击事件
            $('.police-dispatching .police-container .police-container-policeforce .table .tbody tbody').off('click', 'input').on('click', 'input', function (event) {
                event.stopPropagation();
                var lgtd = Number($(this).parent().parent().attr('lgtd'));
                var lttd = Number($(this).parent().parent().attr('lttd'));
                var position = new esri.geometry.Point(lgtd, lttd, new esri.SpatialReference({wkid: 4326}));//根据输入坐标信息找地图上的点
                that.newElectronicFenceId = null;
                that._map.centerAndZoom(position, 18);//缩放,10是缩放级别,可以自定义,数值越大缩放越大
                var graphic = that.entityPolygonAll.graphics;
                for (var i = 0; i < graphic.length; i++) {
                    if (graphic[i].objId.id == $(this).attr('resultid')) {
                        if (graphic[i].geometry.rings[0].length > 0) {
                            that.polygonFlag = false;
                            that.electronicFence();
                            that.activateToolbar(graphic[i]);
                        } else {
                            layui.use('layer', function () {
                                layui.layer.msg('请开始划分电子围栏');
                            })
                            that.polygonFlag = true;
                            that.newElectronicFenceId = graphic[i].objId;
                        }
                    }
                }
            })
            $('.police-dispatching .police-container .police-container-policeforce .table .tbody tbody').off('click', 'tr').on('click', 'tr', function (event) {
                event.stopPropagation();
                var lgtd = Number($(this).attr('lgtd'));
                var lttd = Number($(this).attr('lttd'));
                var position = new esri.geometry.Point(lgtd, lttd, new esri.SpatialReference({wkid: 4326}));//根据输入坐标信息找地图上的点
                that._map.centerAndZoom(position, 18);//缩放,10是缩放级别,可以自定义,数值越大缩放越大
                var snumber = $(this).attr('term-snumber');
                var url = './popup/html/personnel-information-management.html?id=' + snumber;
                layui.use('layer', function () {
                    that.layuiLayer = layui.layer;
                    that.layuiLayer.config({
                        extend: 'myskin/personnel-information-management.css'
                    });
                    that.layuiLayer.close(that.layuiLayer.index);
                    that.layuiLayer.open({
                        title: '保安人员信息',
                        type: 2,
                        shadeClose: true,
                        shade: false,
                        maxmin: false, //开启最大化最小化按钮
                        area: ['400px', '220px'],
                        offset: 'auto',
                        skin: 'personnel-information-management',
                        content: url,
                        closeBtn: 1,
                    });
                })
            })
            $('.police-dispatching .police-container .police-container-policeforce .table .tbody tbody').off('click', 'tr td').on('click', 'tr td', function (event) {
                if ($(this).index() == 4) {
                    event.stopPropagation();
                    return;
                }
            })
            // 巡逻管理中,巡逻路线和巡逻区域的切换换
            $('.police-dispatching .police-container .police-container-patrol .tab-header li').off('click').click(function () {
                if (that.patrolIndex == $(this).index()) return;
                $(this).addClass('on').siblings().removeClass('on');
                $(".police-dispatching .police-container .police-container-patrol .main-content li:eq(" + $(this).index() + ")").stop().show().siblings().stop().hide();
                that.polygonFlag = false;
                that.entityPolygonAll.clear();
                that.modifyPolygon();
                // 切换时清除新增点线面数组中保存得数据,与清除地图上得实体
                that.polygonData = [];
                that.addPolygonEntitys.clear();
                if ($(this).index() == 1) {
                    $('.police-dispatching .police-container .police-container-patrol .main-content .select-list ul').empty();
                    $.ajax({
                        url: 'http://s16s652780.51mypc.cn/api/regions/regions/selectqy',
                        type: 'GET',
                        dataType: 'JSON',
                        success: function (res) {
                            var result = res.data;
                            $('.police-dispatching .police-container .police-container-patrol .main-content .select>ul>li>div:eq(0)').html(result[0].regionName + '<i></i>').attr('regionId', result[0].regionId);
                            for (var i = 0; i < result.length; i++) {
                                $('.police-dispatching .police-container .police-container-patrol .main-content .select-list ul').append($("<li regionId='" + result[i].regionId + "'>" + result[i].regionName + "</li>"))
                            }
                        }
                    })
                    that.getRouteInformation($('.police-dispatching .police-container .police-container-patrol .main-content>li:eq(1) .table .tbody tbody'), '');
                } else {
                    that.patrolArea($('.police-dispatching .police-container .police-container-patrol .main-content>li:eq(0) .table .tbody tbody'), '');
                }
                that.patrolIndex = $(this).index();
            })
            // 巡逻管理下面的巡逻路线中的select选择框的移入事件
            $('#patrolRoute').mouseenter(function () {
                if ($('#patrolRoute .select-list').is(':hidden')) {
                    $('#patrolRoute .select-list').stop().slideDown(0);
                }
            })
            // 巡逻管理下面的巡逻路线中的select选择框的移出事件
            $('#patrolRoute').mouseleave(function () {
                if (!$('#patrolRoute .select-list').is(':hidden')) {
                    $('#patrolRoute .select-list').stop().slideUp(0);
                }
            })
            // 巡逻路线中区域选择的具体项的点击事件
            $('.police-dispatching .police-container .police-container-patrol .select-list').off('click', 'li').on('click', 'li', function (event) {
                var text = $(this).text();
                $(this).parent().parent().prev().html(text + '<i></i>').attr('regionId', $(this).attr('regionId'));
                $(this).parent().parent().stop().slideUp(0);
            })
            // 巡逻路线中的新增按钮的点击事件
            $('.police-dispatching .police-container .police-container-patrol .main-content>li:eq(1) .add').off('click').click(function () {
                var url = './popup/html/route-name-layer.html';
                layui.use('layer', function () {
                    that.layuiLayer = layui.layer;
                    that.layuiLayer.config({
                        extend: 'myskin/route-name-layer.css'
                    });
                    that.layuiLayer.closeAll();
                    that.layuiLayer.open({
                        title: '路线名称及描述',
                        type: 2,
                        shadeClose: false,
                        shade: 0.3,
                        maxmin: false, //开启最大化最小化按钮
                        area: ['320px', '266px'],
                        offset: 'auto',
                        skin: 'route-name-layer',
                        content: url,
                        closeBtn: 1,
                        resize: false,
                        success: function (layero, index) {
                            layero.find('iframe').contents().find(".start-editing").off('click').click(function () {
                                // 区域名称 or 路线名称
                                var routeName = layero.find('iframe').contents().find('.route-name-layer-input').val();
                                var routeDescribe = layero.find('iframe').contents().find('.route-name-layer-textarea').val();
                                var peopleRealName = layero.find('iframe').contents().find('.route-personnel').val();
                                var pepleRealId = layero.find('iframe').contents().find('.route-personnel').attr('peopleid');
                                if (routeName == '') {
                                    that.layuiLayer.msg('请填写路线名称', {
                                        time: 1000
                                    })
                                    return
                                }
                                if (routeDescribe == '') {
                                    that.layuiLayer.msg('请填写路线描述', {
                                        time: 1000
                                    })
                                    return
                                }
                                if (pepleRealId == '') {
                                    that.layuiLayer.msg('请选择人员', {
                                        time: 1000
                                    })
                                    return
                                }
                                that.peopleRealName = peopleRealName;
                                that.pepleRealId = pepleRealId;
                                that.globalRegionName = routeName;
                                that.routeOrRegionDescribe = routeDescribe;
                                // // 开启,可以勾选线段
                                that.polygonFlag = true;
                                that.layuiLayer.close(index);
                            })
                        }
                    });
                })
            })
            // 巡逻路线行点击事件
            $('.police-container .police-container-patrol .main-content>li:eq(1) .table .tbody').off('click', 'tr').on('click', 'tr', function () {
                var flyid = $(this).attr('flyid');
                var flyname = $(this).attr('flyname');
                var extent = null;
                for (var i = 0; i < that.currentDrawing.length; i++) {
                    if (flyid == that.currentDrawing[i].id && flyname == that.currentDrawing[i].routeName) {
                        extent = that.currentDrawing[i].extent;
                    }
                }
                that._map.setExtent(extent.expand(1.5));
            })
            $('.police-container .police-container-patrol .main-content>li:eq(1) .table .tbody').off('click', 'tr td').on('click', 'tr td', function (event) {
                if ($(this).index() == 4) {
                    event.stopPropagation();
                    return;
                }
            })
            $('.police-container .police-container-patrol .main-content>li:eq(1) .table .tbody').off('click', 'input').on('click', 'input', function (event) {
                event.stopPropagation();
                var routeName = $(this).parent().parent().children('td:eq(2)').text();
                var routeId = $(this).parent().parent().attr('flyid');
                var peopleName = $(this).parent().parent().children('td:eq(1)').text();
                var self = this;
                var url = './popup/html/routename-and-peoplename.html?routeName=' + routeName + '&routeId=' + routeId + '&peopleName=' + peopleName;
                layui.use('layer', function () {
                    that.layuiLayer = layui.layer;
                    that.layuiLayer.config({
                        extend: 'myskin/routename-and-peoplename.css'
                    });
                    that.layuiLayer.closeAll();
                    that.layuiLayer.open({
                        title: '路线巡逻人员',
                        type: 2,
                        shadeClose: false,
                        shade: 0.3,
                        maxmin: false, //开启最大化最小化按钮
                        area: ['320px', '172px'],
                        offset: 'auto',
                        skin: 'routename-and-peoplename',
                        content: url,
                        closeBtn: 1,
                        resize: false,
                        success: function (layero, index) {
                            layero.find('iframe').contents().find(".confirm-update").off('click').click(function () {
                                // 区域名称 or 路线名称
                                var peoplelayerName = layero.find('iframe').contents().find('.peoplename-update').val();
                                var peoplelayerId = layero.find('iframe').contents().find('.peoplename-update').attr('peopleid');
                                console.log(peoplelayerName, peoplelayerId);
                                if (peoplelayerName == peopleName) {
                                    that.layuiLayer.close(index);
                                    that.layuiLayer.msg('人员未更改!');
                                } else {
                                    $.ajax({
                                        url: 'http://s16s652780.51mypc.cn/api/duty/duty/updatedtInfo',
                                        type: 'POST',
                                        data: {
                                            rid: routeId,
                                            snumber: peoplelayerId,
                                            sname: peoplelayerName
                                        },
                                        dataType: 'JSON',
                                        success: function (res) {
                                            if (res.code == 200) {
                                                that.layuiLayer.close(index);
                                                $(self).parent().parent().children('td:eq(1)').text(peoplelayerName);
                                                that.layuiLayer.msg('人员已更改!');
                                            }
                                        }
                                    })
                                }
                            })
                        }
                    });
                })
            })
            // 查找按钮
            $('.police-container .police-container-patrol .main-content>li:eq(1) .distribute-table-content .operation .query').off('click').click(function () {
                var routerName = $('.police-container .police-container-patrol .main-content>li:eq(1) .distribute-table-content .route-name').val();
                // if (routerName == '') {
                //   layui.use('layer', function () {
                //     layui.layer.msg('请填写区域名称', {
                //       time: 1000
                //     })
                //   })
                //   return
                // }
                that.getRouteInformation($('.police-dispatching .police-container .police-container-patrol .main-content>li:eq(1) .table .tbody tbody'), routerName);
                $('.police-container .police-container-patrol .main-content>li:eq(1) .distribute-table-content .route-name').val('');
            })
        },
        open: function () {
            var that = this;
            $("#tabcontainer").css("width", "360px");
            $('#mapcontentClass').addClass('client-max-map'); //追加样式
            AppEvent.dispatchAppEvent(AppEvent.APPLICATION_RESIZE, {});
            document.oncontextmenu = function (event) {
                event.preventDefault();
            };
            document.getElementById('mainMapWidget').onmousedown = function (event) {
                if (event.button == 2) {
                    if (that.polygonData.length < 2) {
                        layui.use('layer', function () {
                            layui.layer.msg('不能形成区域,请继续划分!!!')
                        })
                        return;
                    }
                    if (that.polygonFlag == true) {
                        // 勾画最后一个点
                        var normalizedVal = webMercatorUtils.xyToLngLat(event.mapPoint.x, event.mapPoint.y);
                        that.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                        // 声明空字符串,存储数据
                        var dataStr = '';
                        var data = null;
                        if (that.patrolIndex == 1) {
                            that.addPolyline(that.addPolygonEntitys, that.polygonData);
                            // 获取数据
                            data = that.addPolygonEntitys.graphics[0].geometry.paths[0];
                        } else {
                            that.addPolygon(that.addPolygonEntitys, that.polygonData);
                            // 获取数据
                            data = that.addPolygonEntitys.graphics[0].geometry.rings[0];
                        }
                        for (var i = 0; i < data.length; i++) {
                            dataStr += (data[i][0] + ' ' + data[i][1] + ',');
                        }
                        // 组装数据
                        dataStr = dataStr.substring(0, dataStr.length - 1);
                        if (that.tabIndex == 1) {
                            if (that.patrolIndex == 1) {
                                $.ajax({
                                    url: 'http://s16s652780.51mypc.cn/api/routeIn/routein/insertlx',
                                    type: 'POST',
                                    dataType: 'JSON',
                                    data: {
                                        routeName: that.globalRegionName,
                                        regionId: $('#patrolRoute div:eq(0)').attr('regionid'),
                                        routeInfo: dataStr,
                                        remarks: that.routeOrRegionDescribe,
                                        creatName: ''
                                    },
                                    success: function (result) {
                                        if (result.code == 200) {
                                            that.addPolygonEntitys.clear();
                                            that.polygonData = [];
                                            that.getRouteInformation($('.police-dispatching .police-container .police-container-patrol .table .tbody tbody'), '');
                                            $.ajax({
                                                url: 'http://s16s652780.51mypc.cn/api/duty/duty/insertduty',
                                                type: 'POST',
                                                dataType: 'JSON',
                                                data: {
                                                    sname: that.peopleRealName,
                                                    snumber: that.pepleRealId,
                                                    rid: result.data,
                                                    regionId: $('#patrolRoute div:eq(0)').attr('regionid'),
                                                    type: 0
                                                },
                                                success: function (data) {
                                                    if (data.code == 200) {
                                                        alert(1);
                                                    }
                                                }
                                            })
                                        }
                                    }
                                })
                                // that.peopleRealName = peopleRealName;
                                // that.pepleRealId = pepleRealId;
                            } else {
                                $.ajax({
                                    url: 'http://s16s652780.51mypc.cn/api/regions/regions/insterqy',
                                    type: 'POST',
                                    dataType: 'JSON',
                                    data: {
                                        regionName: that.globalRegionName,
                                        coordinate: dataStr,
                                        remarks: that.routeOrRegionDescribe
                                    },
                                    success: function (result) {
                                        if (result.code == 200) {
                                            that.addPolygonEntitys.clear();
                                            that.polygonData = [];
                                            that.patrolArea($('.police-dispatching .police-container .police-container-patrol .table .tbody tbody'), '');
                                        }
                                    }
                                })
                            }
                        } else if (that.tabIndex == 2) {
                            $.ajax({
                                url: 'http://s16s652780.51mypc.cn/api/enclosure/enclosure/insertes',
                                type: 'POST',
                                dataType: 'JSON',
                                data: {
                                    anumber: that.newElectronicFenceId.anumber,
                                    aname: that.newElectronicFenceId.aname,
                                    routeInfo: dataStr
                                },
                                success: function (result) {
                                    if (result.code == 200) {
                                        that.addPolygonEntitys.clear();
                                        that.polygonData = [];
                                        that.getSecurityPeople($('.police-dispatching .police-container .police-container-policeforce .table .tbody tbody'), '');
                                    }
                                }
                            })
                        }
                    }
                    that.polygonFlag = false;
                    // that.polygonData = [];
                }
            }
            that.treatmentIndex = null;
            that.tabIndex = 0;
            $('.police-dispatching-tab li:eq(0)').addClass('on').siblings().removeClass('on');
            $($('.police-container > div')[0]).stop().show().siblings().stop().hide();
            $('.police-dispatching .police-container .distribute-district .select-list ul').empty();
            $('.police-dispatching .police-container .distribute-district .select-list ul').append("<li key='addvcd' addvcd=''>全部</li>");
            $.ajax({
                url: 'http://s16s652780.51mypc.cn/api/district/district/selectList',
                type: 'POST',
                dataType: 'JSON',
                success: function (data) {
                    for (var i = 0; i < data.data.length; i++) {
                        $('.police-dispatching .police-container .distribute-district .select-list ul').append("<li key='addvcd' addvcd=" + data.data[i].addvcd + ">" + data.data[i].addvnm + "</li>");
                    }
                }
            })
            layui.use('laydate', function () {
                that.layuiLadate = layui.laydate;
                //执行一个laydate实例 开始
                that.layuiLadate.render({
                    elem: '#dispatchingStartTime', //指定元素
                    type: "datetime",
                    format: 'yyyy-MM-dd HH:mm',
                    btns: ['confirm'],
                    trigger: 'click',
                });
                // 结束
                that.layuiLadate.render({
                    elem: '#dispatchingEndTime', //指定元素
                    type: "datetime",
                    format: 'yyyy-MM-dd HH:mm',
                    btns: ['confirm'],
                    trigger: 'click',
                });
            });
            // that.getPoliceTable($('.police-container-distribute').find('.tbody tbody'), $('#dispatchingStartTime').val(), $('#dispatchingEndTime').val(), '', '', '');
            that.clickHand();
            $('.police-dispatching-tab li:eq(1)').trigger('click');
        },
        close: function () {
            $("#tabcontainer").css("width", "66%");
            $('#mapcontentClass').removeClass('client-max-map'); //删除样式
            this.entitysData = [];
            this.addEntitys.clear();
            this.entityPolygonAll.clear();
            this.modifyPolygon();
            // 切换时清除新增点线面数组中保存得数据,与清除地图上得实体
            this.polygonData = [];
            this.addPolygonEntitys.clear();
        },
        // 鼠标点击事件
        clickHand: function () {
            var self = this;
            self._map.onClick = mapClick;
            // $('#mainMapWidget')[0].ondblclick = function (event) {
            //   event.preventDefault();
            //   // if ()
            //   self.activateToolbar(event.graphic);
            //   return false;
            // };
            function mapClick(evt) {
                var normalizedVal = webMercatorUtils.xyToLngLat(evt.mapPoint.x, evt.mapPoint.y);
                var y = self._map.toMap({
                    spatialReference: '4326',
                    type: "point",
                    x: evt.screenPoint.x,
                    y: evt.screenPoint.y,
                });
                if (self.tabIndex == 0) {
                    if (evt.graphic) {
                        var result = evt.graphic.geometry.entityData;
                        // var liText = evt.graphic.symbol.name;
                        self.policeDetails(result.id);
                    }
                } else if (self.tabIndex == 1) {
                    if (self.patrolIndex == 1) {
                        // 编辑中的
                        if (self.polygonFlag == true) {
                            var normalizedVal = webMercatorUtils.xyToLngLat(evt.mapPoint.x, evt.mapPoint.y);
                            if (self.polygonData.length == 0) {
                                self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                                self.addPoint(self.addPolygonEntitys, normalizedVal[0], normalizedVal[1]);
                            } else {
                                self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                                self.addPolyline(self.addPolygonEntitys, self.polygonData);
                                return;
                            }
                        } else { // 不在编辑中
                            if (evt.graphic) { // 点击在图形上
                                // 保存当前点击得图形
                                // self.currentDrawing = evt.graphic;
                                self.modifyPolygon();
                                self.activateToolbar(evt.graphic);
                            } else { // 点击不在图形上
                                self.modifyPolygon()
                            }
                        }
                    } else {
                        // 编辑中的
                        if (self.polygonFlag == true) {
                            var normalizedVal = webMercatorUtils.xyToLngLat(evt.mapPoint.x, evt.mapPoint.y);
                            if (self.polygonData.length == 0) {
                                self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                                self.addPoint(self.addPolygonEntitys, normalizedVal[0], normalizedVal[1]);
                            } else if (self.polygonData.length == 1) {
                                self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                                self.addPolyline(self.addPolygonEntitys, self.polygonData);
                                return;
                            } else if (self.polygonData.length > 1) {
                                self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                                self.addPolygon(self.addPolygonEntitys, self.polygonData);
                            }
                        } else { // 不在编辑中
                            if (evt.graphic) { // 点击在图形上
                                // 保存当前点击得图形
                                // self.currentDrawing = evt.graphic;
                                self.modifyPolygon();
                                self.activateToolbar(evt.graphic);
                            } else { // 点击不在图形上
                                self.modifyPolygon()
                            }
                        }
                    }
                } else if (self.tabIndex == 2) {
                    if (self.polygonFlag == true) {
                        var normalizedVal = webMercatorUtils.xyToLngLat(evt.mapPoint.x, evt.mapPoint.y);
                        if (self.polygonData.length == 0) {
                            self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                            self.addPoint(self.addPolygonEntitys, normalizedVal[0], normalizedVal[1]);
                        } else if (self.polygonData.length == 1) {
                            self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                            self.addPolyline(self.addPolygonEntitys, self.polygonData);
                            return;
                        } else if (self.polygonData.length > 1) {
                            self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                            self.addPolygon(self.addPolygonEntitys, self.polygonData);
                        }
                    } else {
                        if (evt.graphic) { // 点击在图形上
                            // 保存当前点击得图形
                            // self.currentDrawing = evt.graphic;
                            self.electronicFence();
                            self.activateToolbar(evt.graphic);
                        } else { // 点击不在图形上
                            self.electronicFence()
                        }
                    }
                    // self.equipmentDetails(result.id);
                }
            }
            // 提示信息
            $(document).off('mousemove').mousemove(function (e) {
                var y = e.clientY + 10;
                var x = e.clientX + 20;
                if (e.clientX < 40) {
                    var x = 40;
                }
                if (e.clientY < 42) {
                    y = 42;
                }
                if (e.clientY > ($(window).height() - 82)) {
                    y = ($(window).height() - 66);
                }
                if (e.clientX > ($(window).width() - 184)) {
                    x = ($(window).width() - 184);
                }
                if (self.tabIndex == 1 || self.tabIndex == 2) {
                    if (self.polygonFlag == true) {
                        $('.police-dispatching .tips').stop().show();
                        if (self.polygonData.length == 0) {
                            $('.police-dispatching .tips').text('单击左键开始绘制。');
                        } else {
                            if (e.clientY > ($(window).height() - 98)) {
                                y = ($(window).height() - 88);
                            }
                            $('.police-dispatching .tips').text('单击左键新增加点。单击右键完成绘制。');
                        }
                        $('.police-dispatching .tips').css({
                            'top': y,
                            'left': x,
                        })
                    } else {
                        $('.police-dispatching .tips').stop().hide();
                    }
                } else {
                    $('.police-dispatching .tips').stop().hide();
                }
            })
        },
        // 警情详情弹框
        /**
         *
         * @param {number} id 警情ID
         */
        policeDetails: function (id) {
            var that = this;
            var url = './popup/html/police-details.html?obj=' + id;
            layui.use('layer', function () {
                that.layuiLayer = layui.layer;
                that.layuiLayer.config({
                    extend: 'myskin/police-details.css'
                });
                that.layuiLayer.close(that.layuiLayer.index);
                that.layuiLayer.open({
                    title: '警情详情',
                    type: 2,
                    shadeClose: true,
                    shade: false,
                    maxmin: false, //开启最大化最小化按钮
                    area: ['500px', '400px'],
                    offset: 'auto',
                    skin: 'police-details',
                    content: url,
                    closeBtn: 1,
                });
            })
        },
        // 业主详情弹框
        /**
         *
         * @param {number} id 警情ID
         */
        ownerDetails: function (id) {
            var that = this;
            var url = './popup/html/owner-details.html?id=' + id;
            layui.use('layer', function () {
                that.layuiLayer = layui.layer;
                that.layuiLayer.config({
                    extend: 'myskin/owner-details.css'
                });
                that.layuiLayer.close(that.layuiLayer.index);
                that.layuiLayer.open({
                    title: '业主详情',
                    type: 2,
                    shadeClose: true,
                    shade: false,
                    maxmin: false, //开启最大化最小化按钮
                    area: ['500px', '340px'],
                    offset: 'auto',
                    skin: 'owner-details',
                    content: url,
                    closeBtn: 1,
                });
            })
        },
        // 设备详情弹框
        /**
         *
         * @param {number} id 设备ID
         */
        equipmentDetails: function (id) {
            var that = this;
            var url = './popup/html/equipment-details.html?obj=' + id;
            layui.use('layer', function () {
                that.layuiLayer = layui.layer;
                that.layuiLayer.config({
                    extend: 'myskin/equipment-details.css'
                });
                that.layuiLayer.close(that.layuiLayer.index);
                that.layuiLayer.open({
                    title: '警情详情',
                    type: 2,
                    shadeClose: true,
                    shade: false,
                    maxmin: false, //开启最大化最小化按钮
                    area: ['520px', '320px'],
                    offset: 'auto',
                    skin: 'equipment-details',
                    content: url,
                    closeBtn: 1,
                });
            })
        },
        // 获取当前时间,以及昨天现在的时间
        getTime: function getTime() {
            var timestamp = Date.parse(new Date());
            // 当前时间
            var currentTime = new Date(timestamp);
            // 年
            var currentY = currentTime.getFullYear();
            // 月
            var currentM = currentTime.getMonth() + 1 < 10 ? '0' + (currentTime.getMonth() + 1) : currentTime.getMonth() + 1;
            // 日
            var currentD = currentTime.getDate() < 10 ? '0' + currentTime.getDate() : currentTime.getDate();
            // 时
            var currentH = currentTime.getHours() < 10 ? '0' + currentTime.getHours() : currentTime.getHours();
            // 分
            var currentDd = currentTime.getMinutes() < 10 ? '0' + currentTime.getMinutes() : currentTime.getMinutes();
            // 明天
            var tomorrowTime = new Date(timestamp - 60 * 60 * 24 * 1000);
            // 年
            var tomorrowY = tomorrowTime.getFullYear();
            // 月
            var tomorrowM = tomorrowTime.getMonth() + 1 < 10 ? '0' + (tomorrowTime.getMonth() + 1) : tomorrowTime.getMonth() + 1;
            // 日
            var tomorrowD = tomorrowTime.getDate() < 10 ? '0' + tomorrowTime.getDate() : tomorrowTime.getDate();
            // 时
            var tomorrowH = tomorrowTime.getHours() < 10 ? '0' + tomorrowTime.getHours() : tomorrowTime.getHours();
            // 分
            var tomorrowDd = tomorrowTime.getMinutes() < 10 ? '0' + tomorrowTime.getMinutes() : tomorrowTime.getMinutes();
            return {
                current: currentY + '-' + currentM + '-' + currentD + ' ' + currentH + ':' + currentDd,
                tomorrow: tomorrowY + '-' + tomorrowM + '-' + tomorrowD + ' ' + tomorrowH + ':' + tomorrowDd,
                month: currentM + currentD
            };
        },
        // 获取警情信息列表
        /**
         *
         * @param {object} dom jq对象
         * @param {string} beginTime 开始时间
         * @param {string} endTime 结束时间
         * @param {*} waringType 警情的类别
         */
        getPoliceTable: function (dom, beginTime, endTime, waringType, addvcd, type) {
            dom.empty();
            var that = this;
            $.ajax({
                url: 'http://s16s652780.51mypc.cn/api/jingdan/jingdan/selectList',
                type: 'POST',
                dataType: 'JSON',
                data: {
                    beginTime: beginTime,
                    endTime: endTime,
                    waringType: waringType,
                    addvcd: addvcd,
                    type: type
                },
                success: function (data) {
                    var result = data.data;
                    var str = '';
                    that.entitysData = [];
                    that.addEntitys.clear();
                    for (var a, time, t, e, y, h, i = 0; i < result.length; i++) {
                        if (result[i].type != 1) {
                            that.createEntitys(that.addEntitys, that.entitysData, '警情信息', {
                                lgtd: result[i].jd,
                                lttd: result[i].wd,
                                id: result[i].id
                            }, result[i].jd, result[i].wd, './images/jingbaored.png');
                            t = result[i].galarmTime.substr(0, 10);
                            e = result[i].galarmTime.substr(11);
                            time = t + '&nbsp;' + e;
                            y = result[i].galarmTime.substr(5, 5);
                            h = result[i].galarmTime.substr(11, 5);
                            a = Number(i) + 1;
                            str += '<tr term-list=' + result[i].id + ' lgtd=' + result[i].jd + ' lttd=' + result[i].wd + '>';
                            str += '<td>' + a + '</td>';
                            str += '<td title=' + result[i].addvnm + '>' + result[i].addvnm + '</td>';
                            str += '<td title=' + (result[i].type == 2 ? '处理中' : '待处理') + '>' + (result[i].type == 2 ? '处理中' : '待处理') + '</td>';
                            str += "<td><a href='javascript:;' title=" + time + ">" + y + ' ' + h + "</a></td>";
                            if (result[i].type == 2) {
                                str += "<td class='operation'> <input class='follow-up' type='button' value='跟进' term-list=" + result[i].id + "> </td>";
                            } else {
                                str += "<td class='operation'> <input class='edit' type='button' value='编辑' term-list=" + result[i].id + "> </td>";
                            }
                            str += '</tr>';
                            dom.append(str);
                            str = '';
                        }
                    }
                    for (var i = 0; i < 1000; i++) {
                        var dd = Math.random();
                        var cc = Math.random();
                    }
                }
            })
        },
        // 获取区域信息列表
        patrolArea: function (dom, regionName) {
            dom.empty();
            var that = this;
            that.currentDrawing = [];
            that.entityPolygonAll.clear();
            $.ajax({
                url: 'http://s16s652780.51mypc.cn/api/regions/regions/selectList',
                type: 'POST',
                dataType: 'JSON',
                data: {
                    regionName: regionName
                },
                success: function (data) {
                    var result = data.data;
                    var str = '';
                    var entityArr = [];
                    var objId = {};
                    var entityData = '';
                    for (var i = 0; i < result.length; i++) {
                        entityArr = [];
                        objId = {};
                        entityData = result[i].coordinate.match(/\(([^)]*)\)/);
                        // 此时result=["(dsfasjfj3124123)", "dsfasjfj3124123"];
                        if (entityData && entityData != '') {
                            entityData = entityData[1].split(',');
                            for (var j = 0; j < entityData.length; j++) {
                                entityArr.push([Number(entityData[j].split(' ')[0]), Number(entityData[j].split(' ')[1])]);
                            }
                        }
                        objId.id = result[i].id;
                        objId.regionId = result[i].regionId;
                        objId.regionName = result[i].regionName;
                        objId.remarks = result[i].remarks;
                        that.addPolygonAll(that.entityPolygonAll, entityArr, objId);
                        str += "<tr flyid=" + result[i].id + " flyname=" + result[i].regionName + "> <td>" + (Number(i) + 1) + "</td> <td>" + result[i].regionName + "</td> <td>" + result[i].ttime + "</td> </tr>";
                        dom.append(str);
                        str = '';
                    }
                }
            })
        },
        // 获取路线信息列表
        getRouteInformation: function (dom, routeName) {
            dom.empty();
            var that = this;
            that.currentDrawing = [];
            that.entityPolygonAll.clear();
            $.ajax({
                url: 'http://s16s652780.51mypc.cn/api/routeIn/routein/selectList',
                type: 'POST',
                dataType: 'JSON',
                data: {
                    routeName: routeName
                },
                success: function (data) {
                    var result = data.data;
                    var str = '';
                    var entityArr = [];
                    var objId = {};
                    var entityData = '';
                    for (var i = 0; i < result.length; i++) {
                        entityArr = [];
                        objId = {};
                        entityData = result[i].routeInfo.match(/\(([^)]*)\)/);
                        // 此时result=["(dsfasjfj3124123)", "dsfasjfj3124123"];
                        if (entityData && entityData != '') {
                            entityData = entityData[1].split(',');
                            for (var j = 0; j < entityData.length; j++) {
                                entityArr.push([Number(entityData[j].split(' ')[0]), Number(entityData[j].split(' ')[1])]);
                            }
                        }
                        objId.id = result[i].id;
                        objId.regionId = result[i].regionId;
                        objId.routeName = result[i].routeName;
                        objId.remarks = result[i].remarks;
                        that.addPolygonAll(that.entityPolygonAll, entityArr, objId);
                        str += "<tr flyid=" + result[i].id + " flyname=" + result[i].routeName + "> <td>" + (Number(i) + 1) + "</td> <td>" + result[i].sname + "</td> <td>" + result[i].routeName + "</td> <td> <a href='javascript:;' title=" + result[i].rtime + ">" + result[i].rtime.substr(5, 11) + "</a></td> <td><input type='button' value='编辑'></td> </tr>";
                        dom.append(str);
                        str = '';
                    }
                }
            })
        },
        // 获取保安人员信息列表
        getSecurityPeople: function (dom, deviceType) {
            dom.empty();
            var that = this;
            that.currentDrawing = [];
            that.entityPolygonAll.clear();
            $.ajax({
                url: 'http://s16s652780.51mypc.cn/api/security/security/selectList',
                type: 'POST',
                dataType: 'JSON',
                success: function (data) {
                    var result = data.data;
                    var str = '';
                    that.entitysData = [];
                    that.addEntitys.clear();
                    var entityArr = [];
                    var objId = {};
                    var entityData = '';
                    for (var a, i = 0; i < result.length; i++) {
                        that.createEntitys(that.addEntitys, that.entitysData, '出警信息', {
                            lgtd: result[i].jd,
                            lttd: result[i].wd,
                            id: result[i].id
                        }, result[i].jd, result[i].wd, './images/security.png');
                        entityArr = [];
                        objId = {};
                        entityData = result[i].coordinate.match(/\(([^)]*)\)/);
                        a = Number(i) + 1;
                        str += "<tr term-snumber=" + snumber + " lgtd=" + result[i].jd + " lttd=" + result[i].wd + ">";
                        str += '<td>' + a + '</td>';
                        str += '<td title=' + result[i].snumber + '>' + result[i].snumber + '</td>';
                        str += '<td title=' + result[i].sname + '>' + result[i].sname + '</td>';
                        str += '<td title=' + result[i].phone + '>' + result[i].phone + '</td>';
                        str += "<td> <input type='button' value='编辑' resultid=" + result[i].id + "> </td>";
                        str += '</tr>';
                        dom.append(str);
                        str = '';
                        // 此时result=["(dsfasjfj3124123)", "dsfasjfj3124123"];
                        if (entityData && entityData != '') {
                            entityData = entityData[1].split(',');
                            for (var j = 0; j < entityData.length; j++) {
                                entityArr.push([Number(entityData[j].split(' ')[0]), Number(entityData[j].split(' ')[1])]);
                            }
                        }
                        objId.id = result[i].id;
                        objId.anumber = result[i].snumber;
                        objId.aname = result[i].sname;
                        that.addPolygonAll(that.entityPolygonAll, entityArr, objId);
                    }
                }
            })
        },
        // 创建实体图层
        createEntitys: function (entitys, entityContent, name, item, lgtd, lttd, outlineColors) {
            var symbol = new esri.symbol.PictureMarkerSymbol(outlineColors, 26, 26);
            symbol.name = name;
            var pt = new Point(lgtd, lttd, new esri.SpatialReference({wkid: 4326}));
            pt.entityData = item;
            var graphic = new esri.Graphic(pt, symbol);
            entitys.add(graphic);
            entityContent.push(item);
        },
        addPoint: function (entitys, lgtd, lttd) {
            var symbol = new esri.symbol.PictureMarkerSymbol('./images/real-time-callPolice.png', 10, 10);
            var pt = new Point(lgtd, lttd, new SpatialReference({wkid: 4326}));
            var graphic = new esri.Graphic(pt, symbol);
            entitys.add(graphic);
        },
        addPolyline: function (entitys, path) {
            entitys.clear();
            var polylineSymbol = new SimpleLineSymbol();
            polylineSymbol.color = [255, 0, 0, 1];
            polylineSymbol.width = 4;
            var polyline = new Polyline({
                "paths": [path],
                "spatialReference": {
                    "wkid": 4326
                }
            });
            entitys.add(new Graphic(polyline, polylineSymbol));
        },
        addPolygon: function (entitys, rings) {
            entitys.clear();
            var polygonSymbol = new SimpleFillSymbol();
            polygonSymbol.color = [24, 255, 243, 0.411];
            var polygon = new Polygon({
                "rings": [rings],
                "spatialReference": {
                    "wkid": 4326
                }
            });
            entitys.add(new Graphic(polygon, polygonSymbol));
        },
        activateToolbar: function (graphic) {
            var tool = 0;
            this.editToolbar = new Edit(this._map);
            // if (registry.byId("tool_move").checked) {
            tool = tool | Edit.MOVE;
            // }
            // if (registry.byId("tool_vertices").checked) {
            tool = tool | Edit.EDIT_VERTICES;
            // }
            // if (registry.byId("tool_scale").checked) {
            tool = tool | Edit.SCALE;
            // }
            // if (registry.byId("tool_rotate").checked) {
            tool = tool | Edit.ROTATE;
            // }
            // enable text editing if a graphic uses a text symbol
            // if ( graphic.symbol.declaredClass === "esri.symbol.TextSymbol" ) {
            tool = tool | Edit.EDIT_TEXT;
            // }
            var options = {
                allowAddVertices: true,
                allowDeleteVertices: true,
                uniformScaling: true
            };
            this.editToolbar.activate(tool, graphic, options);
        },
        addPolygonAll: function (entitys, rings, objId) {
            // entitys.clear();
            var graphic = null;
            if (this.patrolIndex == 1) {
                var polylineSymbol = new SimpleLineSymbol();
                polylineSymbol.color = [255, 0, 0, 1];
                polylineSymbol.width = 4;
                var polyline = new Polyline({
                    "paths": [rings],
                    "spatialReference": {
                        "wkid": 4326
                    }
                });
                graphic = new Graphic(polyline, polylineSymbol)
            } else {
                var polygonSymbol = new SimpleFillSymbol();
                polygonSymbol.color = [24, 255, 243, 0.411];
                var polygon = new Polygon({
                    "rings": [rings],
                    "spatialReference": {
                        "wkid": 4326
                    }
                });
                graphic = new Graphic(polygon, polygonSymbol);
            }
            graphic.objId = objId;
            if (this.tabIndex == 1) {
                if (this.patrolIndex == 1) {
                    this.currentDrawing.push({
                        id: objId.id,
                        regionId: objId.regionId,
                        routeName: objId.routeName,
                        remarks: objId.remarks,
                        extent: graphic.geometry.getExtent()
                    });
                } else {
                    this.currentDrawing.push({
                        id: objId.id,
                        regionId: objId.regionId,
                        regionName: objId.regionName,
                        remarks: objId.remarks,
                        extent: graphic.geometry.getExtent()
                    });
                }
            } else {
                this.currentDrawing.push({
                    id: objId.id,
                    aname: objId.aname,
                    anumber: objId.anumber,
                    extent: graphic.geometry.getExtent()
                });
            }
            entitys.add(graphic);
        },
        modifyPolygon: function () {
            var self = this;
            if (self.editToolbar != null) {
                if (self.patrolIndex == 1) {
                    var polygon = self.editToolbar.getCurrentState();
                    for (var i = 0; i < self.currentDrawing.length; i++) {
                        if (self.currentDrawing[i].id == polygon.graphic.objId.id) {
                            self.currentDrawing[i].extent = polygon.graphic.geometry.getExtent();
                        }
                    }
                    self.editToolbar.deactivate();
                    self.editToolbar = null;
                    // 声明空字符串,存储数据
                    var dataStr = '';
                    // 获取数据
                    var data = polygon.graphic.geometry.paths[0];
                    for (var i = 0; i < data.length; i++) {
                        dataStr += (data[i][0] + ' ' + data[i][1] + ',');
                    }
                    // 组装数据
                    dataStr = dataStr.substring(0, dataStr.length - 1);
                    $.ajax({
                        url: 'http://s16s652780.51mypc.cn/api/routeIn/routein/updatelx',
                        type: 'POST',
                        dataType: 'JSON',
                        data: {
                            id: polygon.graphic.objId.id,
                            regionId: polygon.graphic.objId.regionId,
                            routeName: polygon.graphic.objId.routeName,
                            routeInfo: dataStr,
                            remarks: polygon.graphic.objId.remarks,
                        },
                        success: function (result) {
                            if (result.code == 200) {
                            }
                        }
                    })
                } else {
                    var polygon = self.editToolbar.getCurrentState();
                    for (var i = 0; i < self.currentDrawing.length; i++) {
                        if (self.currentDrawing[i].id == polygon.graphic.objId.id) {
                            self.currentDrawing[i].extent = polygon.graphic.geometry.getExtent();
                        }
                    }
                    self.editToolbar.deactivate();
                    self.editToolbar = null;
                    // 声明空字符串,存储数据
                    var dataStr = '';
                    // 获取数据
                    var data = polygon.graphic.geometry.rings[0];
                    for (var i = 0; i < data.length; i++) {
                        dataStr += (data[i][0] + ' ' + data[i][1] + ',');
                    }
                    // 组装数据
                    dataStr = dataStr.substring(0, dataStr.length - 1);
                    $.ajax({
                        url: 'http://s16s652780.51mypc.cn/api/regions/regions/updateqy',
                        type: 'POST',
                        dataType: 'JSON',
                        data: {
                            id: polygon.graphic.objId.id,
                            regionId: polygon.graphic.objId.regionId,
                            regionName: polygon.graphic.objId.regionName,
                            coordinate: dataStr,
                            remarks: polygon.graphic.objId.remarks
                        },
                        success: function (result) {
                            if (result.code == 200) {
                            }
                        }
                    })
                }
            }
        },
        electronicFence: function () {
            var self = this;
            if (self.editToolbar != null) {
                var polygon = self.editToolbar.getCurrentState();
                for (var i = 0; i < self.currentDrawing.length; i++) {
                    if (self.currentDrawing[i].id == polygon.graphic.objId.id) {
                        self.currentDrawing[i].extent = polygon.graphic.geometry.getExtent();
                    }
                }
                self.editToolbar.deactivate();
                self.editToolbar = null;
                // 声明空字符串,存储数据
                var dataStr = '';
                // 获取数据
                var data = polygon.graphic.geometry.rings[0];
                for (var i = 0; i < data.length; i++) {
                    dataStr += (data[i][0] + ' ' + data[i][1] + ',');
                }
                // 组装数据
                dataStr = dataStr.substring(0, dataStr.length - 1);
                $.ajax({
                    url: 'http://s16s652780.51mypc.cn/api/enclosure/enclosure/updatee',
                    type: 'POST',
                    dataType: 'JSON',
                    data: {
                        id: polygon.graphic.objId.id,
                        aname: polygon.graphic.objId.aname,
                        anumber: polygon.graphic.objId.anumber,
                        routeInfo: dataStr
                      coordinate: "point(" + $(this).attr('lgtd') + "," + $(this).attr('lttd') + ")"
                    },
                    success: function (result) {
                        if (result.code == 200) {
                    dataType: 'JSON',
                    success: function (data) {
                        }
                      var result = data.data;
                      for (var i = 0; i < result.length; i++) {
                        str += "<tr> <td>" + (Number(i) + 1) + "</td> <td>" + result[i].sname + "</td> <td>" + result[i].distance.toFixed(2) + "</td> <td><input type='radio' name='securityStaff' securityid=" + result[i].snumber + " securityname=" + result[i].sname + "> </td> </tr>"
                      }
                      $('.police-container-distribute-details .security-guard-nearby .security-staff-content tbody').append(str);
                    }
                })
            }
        },
        //聚合图层事件
        flareClusterLayer: function (datas) {
            var that = this;
            var preClustered = false;
            var displaySingleFlaresAtCount = 10;
            var areaDisplayMode = "";
            // var allData = JSON.parse(DATA);
            // DataManager.setData(allData);
            //init the layer, more options are available and explained in the cluster layer constructor
            that.clusterLayer = new FlareClusterLayer({
                id: "flare-cluster-layer",
                spatialReference: new esri.SpatialReference({"wkid": 4326}),
                subTypeFlareProperty: "facilityType",
                singleFlareTooltipProperty: "name",
                displaySubTypeFlares: true,
                displaySingleFlaresAtCount: displaySingleFlaresAtCount,
                flareShowMode: "mouse",
                preClustered: preClustered,
                clusterRatio: 75,
                clusterAreaDisplay: areaDisplayMode,
                clusteringBegin: function () {
                    console.log("clustering begin");
                },
                clusteringComplete: function () {
                    console.log("clustering complete");
                  })
                  $('.police-container-distribute-details .security-guard-nearby').stop().show();
                } else {
                  $('.police-container-distribute-details .content table tbody .securityname').text('');
                  $('.police-container-distribute-details .security-guard-nearby').stop().hide();
                }
            });
                that.treatmentIndex = $(this).val();
              }
            })
          }
        })
      })
      // 警情分发中的详情的确认按钮
      $('.police-container-distribute-details .handle-button .confirm').off('click').click(function () {
        var self = this;
        layui.use('layer', function () {
          var layer = layui.layer;
          if (that.treatmentIndex == null) {
            layer.msg('请选择处理方式', {
            //set up a class breaks renderer to render different symbols based on the cluster count. Use the required clusterCount property to break on.
            var defaultSym = new PictureMarkerSymbol("./images/ceshi.png", 32, 32).setOffset(0, 15);
            var renderer = new ClassBreaksRenderer(defaultSym, "clusterCount");
            var xlSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 32, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([200, 52, 59, 0.8]), 1), new dojo.Color([250, 65, 74, 0.8]));
            var lgSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 28, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([41, 163, 41, 0.8]), 1), new dojo.Color([51, 204, 51, 0.8]));
            var mdSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 24, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([82, 163, 204, 0.8]), 1), new dojo.Color([102, 204, 255, 0.8]));
            var smSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 22, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([230, 184, 92, 0.8]), 1), new dojo.Color([255, 204, 102, 0.8]));
            renderer.addBreak(0, 19, smSymbol);
            renderer.addBreak(20, 150, mdSymbol);
            renderer.addBreak(151, 1000, lgSymbol);
            renderer.addBreak(1001, Infinity, xlSymbol);
            that.clusterLayer.setRenderer(renderer); //use standard setRenderer.
              shade: [0.8, '#393D49'],
            //set up a popup template
            var template = new PopupTemplate({
                title: "{name}",
                fieldInfos: [
                    {fieldName: "facilityType", label: "Facility Type", visible: true},
                    {fieldName: "postcode", label: "Post Code", visible: true},
                    {fieldName: "isOpen", label: "Opening Hours", visible: true}
                ]
            });
              time: 1000
            })
            return
          } else {
            if (that.treatmentIndex == '派发保安') {
              if (that.securityFlag == false) {
                layer.msg('请选取保安', {
            //clusterLayer.infoTemplate = template;
            that._map.infoWindow.titleInBody = false;
            that._map.addLayer(that.clusterLayer);
                  shade: [0.8, '#393D49'],
            //var data = DataManager.getData();
            that.clusterLayer.addData(datas);
                  time: 1000
                })
                return
              }
            }
          }
          var id = $(self).attr('police-id');
          var handletype = null;
          if (that.treatmentIndex != null) {
            if (that.treatmentIndex == '派发保安') {
              handletype = '0';
            } else {
              handletype = '1';
            }
          }
          // 发送请求修改警单数据
          $.ajax({
            url: 'http://s16s652780.51mypc.cn/api/jingdan/jingdan/updateInfo',
            type: 'POST',
            data: {
              id: id,
              // handleP: $('.police-container-distribute-details .content table tbody tr:eq(4) td:eq(3)').attr('people-id'),
              // handName: $('.police-container-distribute-details .content table tbody tr:eq(4) td:eq(3)').text(),
              handleP: $('.police-container-distribute-details .content table tbody .securityname').attr('id'),
              handName: $('.police-container-distribute-details .content table tbody .securityname').text(),
              handletype: handletype,
              type: '2'
            },
            dataType: 'JSON',
            success: function (data) {
              if (data.code == 200) {
                if (!$('.police-container-distribute-details .security-guard-nearby').is(':hidden')) {
                  $('.police-container-distribute-details .security-guard-nearby').stop().hide();
                }
                $('.police-container-distribute-details').stop().hide();
                $('.police-container .police-container-distribute .table .tbody tr:eq(' + that.editParentInd + ') td:eq(2)').text('处理中');
                $('.police-container .police-container-distribute .table .tbody tr:eq(' + that.editParentInd + ') td:eq(4)').html("<input class='follow-up' type='button' value='跟进' >");
              }
            }
          })
        });
      })
      // 警情分发中的跟进按钮的点击事件
      $('.police-container .police-container-distribute .table .tbody').off('click', '.follow-up').on('click', '.follow-up', function () {
        var id = $(this).attr('term-list');
        if (!$('.police-container-distribute-details').is(':hidden')) {
          $('.police-container-distribute-details').stop().hide();
        }
        $('.police-container-distribute-details .content table tbody').empty();
        var str = '';
        $.ajax({
          url: 'http://s16s652780.51mypc.cn/api/jingdan/jingdan/selectdInfo?deviceNumber=&id=' + id,
          type: 'POST',
          dataType: 'JSON',
          success: function (data) {
            var result = data.data[0];
            var t = result.galarmTime.substr(0, 10);
            var e = result.galarmTime.substr(11);
            var time = t + '&nbsp;' + e;
            str += "<tr> <td>报警人姓名:</td> <td>" + result.galarmPeople + "</td> <td>联系方式:</td> <td>" + result.phoneNumber + "</td> </tr>";
            str += "<tr> <td>事发地址:</td> <td>" + result.place + "</td> <td>行政区:</td> <td>" + result.addvnm + "</td> </>";
            str += "<tr> <td>报警时间:</td> <td>" + time + "</td> <td>报警内容:</td> <td>" + result.content + "</td> </tr>";
            str += "<tr> <td>警情级别:</td> <td>" + result.level + "</td> <td>警情类别:</td> <td>" + result.waringType + "</td> </tr>";
            str += "<tr> <td>处理方式:</td> <td class='treatment-method'> " + (result.type == 2 ? '处理中' : '待处理') + " </td> <td>处理人:</td> <td class='securityname'> " + result.handName + " </td> </tr>";
            str += "<tr> <td>是否上报110:</td> <td class='report-oneonezero'> <input type='radio' name='callPhone' value='是'> <span>是</span> <input type='radio' name='callPhone' value='否'> <span>否</span> </td> <td>设备编号:</td> <td>" + 1111 + "</td> </tr>";
            $('.police-container-distribute-details .content table tbody').append(str);
            $('.police-container-distribute-details .header h4').text('警情跟进');
            $('.police-container-distribute-details .handle-button').stop().hide();
            $('.police-container-distribute-details').stop().show();
          }
        })
      })
      // 警情分发中的详情的取消按钮
      $('.police-container-distribute-details .handle-button .cancel').off('click').click(function () {
        if (!$('.police-container-distribute-details .security-guard-nearby').is(':hidden')) {
          $('.police-container-distribute-details .security-guard-nearby').stop().hide();
        }
        $('.police-container-distribute-details').stop().hide();
      })
      // 警情分发中详情的关闭按钮
      $('.police-container-distribute-details .header .close').off('click').click(function () {
        if (!$('.police-container-distribute-details .security-guard-nearby').is(':hidden')) {
          $('.police-container-distribute-details .security-guard-nearby').stop().hide();
        }
        $('.police-container-distribute-details').stop().hide();
      })
      // 派发保安的确认按钮
      $('.police-container-distribute-details .security-guard-nearby .security-staff-confirm input').off('click').click(function () {
        var list = $('.police-container-distribute-details .security-guard-nearby .security-staff-content input');
        that.securityFlag = false;
        var id = null;
        var securityname = null;
        for (var i = 0; i < list.length; i++) {
          if ($(list[i]).prop('checked') == true) {
            that.securityFlag = true;
            id = $(list[i]).attr('securityid');
            securityname = $(list[i]).attr('securityname');
            break;
          }
        }
        if (that.securityFlag == false) {
          layui.use('layer', function () {
            var layer = layui.layer;
            layer.msg('请选取保安', {
              shade: [0.8, '#393D49'],
              time: 1000
            })
          });
        } else {
          $('.police-container-distribute-details .content table tbody .securityname').attr('id', id).text(securityname);
          $('.police-container-distribute-details .security-guard-nearby').stop().hide();
        }
      })
      // 警情信息中类别移入事件
      $('#distributeCategory').mouseenter(function () {
        if ($('#distributeCategory .select-list').is(':hidden')) {
          $('#distributeCategory .select-list').stop().slideDown(0);
        }
      })
      // 警情信息中得类别移出事件
      $('#distributeCategory').mouseleave(function () {
        if (!$('#distributeCategory .select-list').is(':hidden')) {
          $('#distributeCategory .select-list').stop().slideUp(0);
        }
      })
      // 警情信息中类别移入事件
      $('#distributeState').mouseenter(function () {
        if ($('#distributeState .select-list').is(':hidden')) {
          $('#distributeState .select-list').stop().slideDown(0);
        }
      })
      // 警情信息中得类别移出事件
      $('#distributeState').mouseleave(function () {
        if (!$('#distributeState .select-list').is(':hidden')) {
          $('#distributeState .select-list').stop().slideUp(0);
        }
      })
      //  警情信息类,业主信息类,设备信息类别,具体项的点击事件
      $('.police-container > div .select-list').off('click', 'li').on('click', 'li', function (event) {
        var text = $(this).text();
        $(this).parent().parent().prev().html(text + '<i></i>');
        $(this).parent().parent().stop().slideUp(0);
        if (text == '全部') text = '';
        var textOrr = '';
        var textList = '';
        var stateType = '';
        if (that.tabIndex == 0) {
          // that.getPoliceTable($('.analysis-container-police').find('.tbody tbody'), $('#dispatchingStartTime').val(), $('#dispatchingEndTime').val(), text);
          if ($(this).attr('key')) {
            textOrr = $('#distributeState div:eq(0)').text().trim();
            textList = $('.police-dispatching .police-container .distribute-state .select-list ul li');
            for (var i = 0; i < textList.length; i++) {
              if (textOrr == $(textList[i]).text()) {
                stateType = $(textList[i]).attr('statetype');
              }
            }
            that.getPoliceTable($('.police-container-distribute').find('.tbody tbody'), $('#dispatchingStartTime').val(), $('#dispatchingEndTime').val(), '', $(this).attr('addvcd'), stateType);
          } else {
            textOrr = $('#distributeCategory div:eq(0)').text().trim();
            textList = $('.police-dispatching .police-container .distribute-district .select-list ul li');
            for (var i = 0; i < textList.length; i++) {
              if (textOrr == $(textList[i]).text()) {
                stateType = $(textList[i]).attr('addvcd');
              }
            }
            that.getPoliceTable($('.police-container-distribute').find('.tbody tbody'), $('#dispatchingStartTime').val(), $('#dispatchingEndTime').val(), '', stateType, $(this).attr('stateType'));
          }
        }
      })
      // 时间查询
      $('#dispatchingSelectTime').off('click').click(function () {
        var times = $(this).prevAll();
        // 开始时间
        var startTime = $(times[1]).val();
        // 结束时间
        var endTime = $(times[0]).val();
        var textOne = $('#distributeCategory div:eq(0)').text().trim();
        var addvcd = '';
        var list = $('.police-dispatching .police-container .distribute-district .select-list ul li');
        if (textOne == '全部') {
          addvcd = '';
        } else {
          if (list.length > 0) {
            for (var i = 0; i < list.length; i++) {
              if (textOne == $(list[i]).text()) {
                addvcd = $(list[i]).attr('addvcd')
              }
            }
          }
        }
        var textTwo = $('#distributeState div:eq(0)').text().trim();
        var stateType = '';
        var stateList = $('.police-dispatching .police-container .distribute-state .select-list ul li');
        if (textTwo == '全部') {
          stateType = '';
        } else {
          if (stateList.length > 0) {
            for (var i = 0; i < stateList.length; i++) {
              if (textTwo == $(stateList[i]).text()) {
                stateType = $(stateList[i]).attr('statetype')
              }
            }
          }
        }
        that.getPoliceTable($('.police-container-distribute').find('.tbody tbody'), startTime, endTime, '', addvcd, stateType);
      })
      //  巡逻区域中的行点击事件
      $('.police-container .police-container-patrol .main-content>li:eq(0) .table .tbody').off('click', 'tr').on('click', 'tr', function () {
        var flyid = $(this).attr('flyid');
        var flyname = $(this).attr('flyname');
        var extent = null;
        for (var i = 0; i < that.currentDrawing.length; i++) {
          if (flyid == that.currentDrawing[i].id && flyname == that.currentDrawing[i].regionName) {
            extent = that.currentDrawing[i].extent;
          }
        }
        // debugger
        that._map.setExtent(extent.expand(1.5));
        // var myFeatureExtent = new Extent(extent.)
        // thisObj._map.setExtent(myFeatureExtent.expand(2));
        // var lgtd = Number($(this).attr('lgtd'));
        // var lttd = Number($(this).attr('lttd'));
        // var position = new esri.geometry.Point(lgtd, lttd, new esri.SpatialReference({ wkid: 4326 }));//根据输入坐标信息找地图上的点
        // that._map.centerAndZoom(position, 14);//缩放,10是缩放级别,可以自定义,数值越大缩放越大
      })
      // 巡逻区域的新增按钮
      $('.police-container .police-container-patrol .main-content>li:eq(0) .distribute-table-content .operation .add').off('click').click(function () {
        var url = './popup/html/region-name.html';
        layui.use('layer', function () {
          that.layuiLayer = layui.layer;
          that.layuiLayer.config({
            extend: 'myskin/region-name.css'
          });
          that.layuiLayer.close(that.layuiLayer.index);
          that.layuiLayer.open({
            title: '区域名称',
            type: 2,
            shadeClose: false,
            shade: 0.3,
            maxmin: false, //开启最大化最小化按钮
            area: ['320px', '206px'],
            offset: 'auto',
            skin: 'region-name',
            content: url,
            closeBtn: 1,
            success: function (layero, index) {
              layero.find('iframe').contents().find(".start-editing").off('click').click(function () {
                // 区域名称
                var regionName = layero.find('iframe').contents().find('.region-name-input').val();
                var regionDescribe = layero.find('iframe').contents().find('.region-name-textarea').val();
                if (regionName == '') {
                  that.layuiLayer.msg('请填写区域名称', {
                    time: 1000
                  })
                  return
                }
                if (regionDescribe == '') {
                  that.layuiLayer.msg('请填写区域描述', {
                    time: 1000
                  })
                  return
                }
                that.globalRegionName = regionName;
                that.routeOrRegionDescribe = regionDescribe;
                // 开启,可以勾选线段
                that.polygonFlag = true;
                that.layuiLayer.close(index);
              })
            }
          });
        })
      })
      // 查找按钮
      $('.police-container .police-container-patrol .main-content>li:eq(0) .distribute-table-content .operation .query').off('click').click(function () {
        var routerName = $('.police-container .police-container-patrol .main-content>li:eq(0) .distribute-table-content .route-name').val();
        // if (routerName == '') {
        //   layui.use('layer', function () {
        //     layui.layer.msg('请填写区域名称', {
        //       time: 1000
        //     })
        //   })
        //   return
        // }
        that.patrolArea($('.police-dispatching .police-container .police-container-patrol .table .tbody tbody'), routerName);
        $('.police-container .police-container-patrol .main-content>li:eq(0) .distribute-table-content .route-name').val('');
      })
      // 保安出警管理表格中点击事件
      $('.police-dispatching .police-container .police-container-policeforce .table .tbody tbody').off('click', 'input').on('click', 'input', function (event) {
        event.stopPropagation();
        var lgtd = Number($(this).parent().parent().attr('lgtd'));
        var lttd = Number($(this).parent().parent().attr('lttd'));
        var position = new esri.geometry.Point(lgtd, lttd, new esri.SpatialReference({
          wkid: 4326
        })); //根据输入坐标信息找地图上的点
        that.newElectronicFenceId = null;
        that._map.centerAndZoom(position, 18); //缩放,10是缩放级别,可以自定义,数值越大缩放越大
        var graphic = that.entityPolygonAll.graphics;
        for (var i = 0; i < graphic.length; i++) {
          if (graphic[i].objId.id == $(this).attr('resultid')) {
            if (graphic[i].geometry.rings[0].length > 0) {
              that.polygonFlag = false;
              that.electronicFence();
              that.activateToolbar(graphic[i]);
            } else {
              layui.use('layer', function () {
                layui.layer.msg('请开始划分电子围栏');
              })
              that.polygonFlag = true;
              that.newElectronicFenceId = graphic[i].objId;
            }
          }
        }
      })
      $('.police-dispatching .police-container .police-container-policeforce .table .tbody tbody').off('click', 'tr').on('click', 'tr', function (event) {
        event.stopPropagation();
        var lgtd = Number($(this).attr('lgtd'));
        var lttd = Number($(this).attr('lttd'));
        var position = new esri.geometry.Point(lgtd, lttd, new esri.SpatialReference({
          wkid: 4326
        })); //根据输入坐标信息找地图上的点
        that._map.centerAndZoom(position, 18); //缩放,10是缩放级别,可以自定义,数值越大缩放越大
        var snumber = $(this).attr('term-snumber');
        var url = './popup/html/personnel-information-management.html?id=' + snumber;
        layui.use('layer', function () {
          that.layuiLayer = layui.layer;
          that.layuiLayer.config({
            extend: 'myskin/personnel-information-management.css'
          });
          that.layuiLayer.close(that.layuiLayer.index);
          that.layuiLayer.open({
            title: '保安人员信息',
            type: 2,
            shadeClose: true,
            shade: false,
            maxmin: false, //开启最大化最小化按钮
            area: ['400px', '220px'],
            offset: 'auto',
            skin: 'personnel-information-management',
            content: url,
            closeBtn: 1,
          });
        })
      })
      $('.police-dispatching .police-container .police-container-policeforce .table .tbody tbody').off('click', 'tr td').on('click', 'tr td', function (event) {
        if ($(this).index() == 4) {
          event.stopPropagation();
          return;
        }
      })
      // 巡逻管理中,巡逻路线和巡逻区域的切换换
      $('.police-dispatching .police-container .police-container-patrol .tab-header li').off('click').click(function () {
        if (that.patrolIndex == $(this).index()) return;
        $(this).addClass('on').siblings().removeClass('on');
        $(".police-dispatching .police-container .police-container-patrol .main-content li:eq(" + $(this).index() + ")").stop().show().siblings().stop().hide();
        that.polygonFlag = false;
        that.entityPolygonAll.clear();
        that.modifyPolygon();
        // 切换时清除新增点线面数组中保存得数据,与清除地图上得实体
        that.polygonData = [];
        that.addPolygonEntitys.clear();
        if ($(this).index() == 1) {
          $('.police-dispatching .police-container .police-container-patrol .main-content .select-list ul').empty();
          $.ajax({
            url: 'http://s16s652780.51mypc.cn/api/regions/regions/selectqy',
            type: 'GET',
            dataType: 'JSON',
            success: function (res) {
              var result = res.data;
              $('.police-dispatching .police-container .police-container-patrol .main-content .select>ul>li>div:eq(0)').html(result[0].regionName + '<i></i>').attr('regionId', result[0].regionId);
              for (var i = 0; i < result.length; i++) {
                $('.police-dispatching .police-container .police-container-patrol .main-content .select-list ul').append($("<li regionId='" + result[i].regionId + "'>" + result[i].regionName + "</li>"))
              }
            }
          })
          that.getRouteInformation($('.police-dispatching .police-container .police-container-patrol .main-content>li:eq(1) .table .tbody tbody'), '');
        } else {
          that.patrolArea($('.police-dispatching .police-container .police-container-patrol .main-content>li:eq(0) .table .tbody tbody'), '');
        }
        that.patrolIndex = $(this).index();
      })
      // 巡逻管理下面的巡逻路线中的select选择框的移入事件
      $('#patrolRoute').mouseenter(function () {
        if ($('#patrolRoute .select-list').is(':hidden')) {
          $('#patrolRoute .select-list').stop().slideDown(0);
        }
      })
      // 巡逻管理下面的巡逻路线中的select选择框的移出事件
      $('#patrolRoute').mouseleave(function () {
        if (!$('#patrolRoute .select-list').is(':hidden')) {
          $('#patrolRoute .select-list').stop().slideUp(0);
        }
      })
      // 巡逻路线中区域选择的具体项的点击事件
      $('.police-dispatching .police-container .police-container-patrol .select-list').off('click', 'li').on('click', 'li', function (event) {
        var text = $(this).text();
        $(this).parent().parent().prev().html(text + '<i></i>').attr('regionId', $(this).attr('regionId'));
        $(this).parent().parent().stop().slideUp(0);
      })
      // 巡逻路线中的新增按钮的点击事件
      $('.police-dispatching .police-container .police-container-patrol .main-content>li:eq(1) .add').off('click').click(function () {
        var url = './popup/html/route-name-layer.html';
        layui.use('layer', function () {
          that.layuiLayer = layui.layer;
          that.layuiLayer.config({
            extend: 'myskin/route-name-layer.css'
          });
          that.layuiLayer.closeAll();
          that.layuiLayer.open({
            title: '路线名称及描述',
            type: 2,
            shadeClose: false,
            shade: 0.3,
            maxmin: false, //开启最大化最小化按钮
            area: ['320px', '216px'],
            offset: 'auto',
            skin: 'route-name-layer',
            content: url,
            closeBtn: 1,
            resize: false,
            success: function (layero, index) {
              layero.find('iframe').contents().find(".start-editing").off('click').click(function () {
                // 区域名称 or 路线名称
                var routeName = layero.find('iframe').contents().find('.route-name-layer-input').val();
                var routeDescribe = layero.find('iframe').contents().find('.route-name-layer-textarea').val();
                var peopleRealName = layero.find('iframe').contents().find('.route-personnel').val();
                var pepleRealId = layero.find('iframe').contents().find('.route-personnel').attr('peopleid');
                if (routeName == '') {
                  that.layuiLayer.msg('请填写路线名称', {
                    time: 1000
                  })
                  return
                }
                if (routeDescribe == '') {
                  that.layuiLayer.msg('请填写路线描述', {
                    time: 1000
                  })
                  return
                }
                // if (pepleRealId == '') {
                //   that.layuiLayer.msg('请选择人员', {
                //     time: 1000
                //   })
                //   return
                // }
                that.peopleRealName = peopleRealName;
                that.pepleRealId = '485';
                that.globalRegionName = routeName;
                that.routeOrRegionDescribe = routeDescribe;
                // // 开启,可以勾选线段
                that.polygonFlag = true;
                that.layuiLayer.close(index);
              })
            }
          });
        })
      })
      // 巡逻路线行点击事件
      $('.police-container .police-container-patrol .main-content>li:eq(1) .table .tbody').off('click', 'tr').on('click', 'tr', function () {
        var flyid = $(this).attr('flyid');
        var flyname = $(this).attr('flyname');
        var extent = null;
        for (var i = 0; i < that.currentDrawing.length; i++) {
          if (flyid == that.currentDrawing[i].id && flyname == that.currentDrawing[i].routeName) {
            extent = that.currentDrawing[i].extent;
          }
        }
        that._map.setExtent(extent.expand(1.5));
      })
      $('.police-container .police-container-patrol .main-content>li:eq(1) .table .tbody').off('click', 'tr td').on('click', 'tr td', function (event) {
        if ($(this).index() == 4) {
          event.stopPropagation();
          return;
        }
      })
      $('.police-container .police-container-patrol .main-content>li:eq(1) .table .tbody').off('click', 'input').on('click', 'input', function (event) {
        event.stopPropagation();
        var routeName = $(this).parent().parent().children('td:eq(2)').text();
        var routeId = $(this).parent().parent().attr('flyid');
        var peopleName = $(this).parent().parent().children('td:eq(1)').text();
        var self = this;
        var url = './popup/html/routename-and-peoplename.html?routeName=' + routeName + '&routeId=' + routeId + '&peopleName=' + peopleName;
        layui.use('layer', function () {
          that.layuiLayer = layui.layer;
          that.layuiLayer.config({
            extend: 'myskin/routename-and-peoplename.css'
          });
          that.layuiLayer.closeAll();
          that.layuiLayer.open({
            title: '路线巡逻人员',
            type: 2,
            shadeClose: false,
            shade: 0.3,
            maxmin: false, //开启最大化最小化按钮
            area: ['320px', '132px'],
            offset: 'auto',
            skin: 'routename-and-peoplename',
            content: url,
            closeBtn: 1,
            resize: false,
            success: function (layero, index) {
              layero.find('iframe').contents().find(".confirm-update").off('click').click(function () {
                // 区域名称 or 路线名称
                var peoplelayerName = layero.find('iframe').contents().find('.peoplename-update').val();
                var peoplelayerId = layero.find('iframe').contents().find('.peoplename-update').attr('peopleid');
                console.log(peoplelayerName, peoplelayerId);
                // if (peoplelayerName == peopleName) {
                //   that.layuiLayer.close(index);
                //   that.layuiLayer.msg('人员未更改!');
                // } else {
                  $.ajax({
                    url: 'http://s16s652780.51mypc.cn/api/duty/duty/updatedtInfo',
                    type: 'POST',
                    data: {
                      rid: routeId,
                      snumber: peoplelayerId,
                      sname: '张三'
                    },
                    dataType: 'JSON',
                    success: function (res) {
                      if (res.code == 200) {
                        that.layuiLayer.close(index);
                        $(self).parent().parent().children('td:eq(1)').text(peoplelayerName);
                        that.layuiLayer.msg('人员已更改!');
                      }
                    }
                  })
                // }
              })
            }
          });
        })
      })
      // 查找按钮
      $('.police-container .police-container-patrol .main-content>li:eq(1) .distribute-table-content .operation .query').off('click').click(function () {
        var routerName = $('.police-container .police-container-patrol .main-content>li:eq(1) .distribute-table-content .route-name').val();
        // if (routerName == '') {
        //   layui.use('layer', function () {
        //     layui.layer.msg('请填写区域名称', {
        //       time: 1000
        //     })
        //   })
        //   return
        // }
        that.getRouteInformation($('.police-dispatching .police-container .police-container-patrol .main-content>li:eq(1) .table .tbody tbody'), routerName);
        $('.police-container .police-container-patrol .main-content>li:eq(1) .distribute-table-content .route-name').val('');
      })
    },
    open: function () {
      var that = this;
      $("#tabcontainer").css("width", "360px");
      $('#mapcontentClass').addClass('client-max-map'); //追加样式
      AppEvent.dispatchAppEvent(AppEvent.APPLICATION_RESIZE, {});
      document.oncontextmenu = function (event) {
        event.preventDefault();
      };
      document.getElementById('mainMapWidget').onmousedown = function (event) {
        if (event.button == 2) {
          if (that.polygonData.length < 2) {
            layui.use('layer', function () {
              layui.layer.msg('不能形成区域,请继续划分!!!')
            })
            return;
          }
          if (that.polygonFlag == true) {
            // 勾画最后一个点
            var normalizedVal = webMercatorUtils.xyToLngLat(event.mapPoint.x, event.mapPoint.y);
            that.polygonData.push([normalizedVal[0], normalizedVal[1]]);
            // 声明空字符串,存储数据
            var dataStr = '';
            var data = null;
            if (that.patrolIndex == 1) {
              that.addPolyline(that.addPolygonEntitys, that.polygonData);
              // 获取数据
              data = that.addPolygonEntitys.graphics[0].geometry.paths[0];
            } else {
              that.addPolygon(that.addPolygonEntitys, that.polygonData);
              // 获取数据
              data = that.addPolygonEntitys.graphics[0].geometry.rings[0];
            }
            for (var i = 0; i < data.length; i++) {
              dataStr += (data[i][0] + ' ' + data[i][1] + ',');
            }
            // 组装数据
            dataStr = dataStr.substring(0, dataStr.length - 1);
            if (that.tabIndex == 1) {
              if (that.patrolIndex == 1) {
                $.ajax({
                  url: 'http://s16s652780.51mypc.cn/api/routeIn/routein/insertlx',
                  type: 'POST',
                  dataType: 'JSON',
                  data: {
                    routeName: that.globalRegionName,
                    regionId: $('#patrolRoute div:eq(0)').attr('regionid'),
                    routeInfo: dataStr,
                    remarks: that.routeOrRegionDescribe,
                    creatName: ''
                  },
                  success: function (result) {
                    if (result.code == 200) {
                      that.addPolygonEntitys.clear();
                      that.polygonData = [];
                      that.getRouteInformation($('.police-dispatching .police-container .police-container-patrol .table .tbody tbody'), '');
                      $.ajax({
                        url: 'http://s16s652780.51mypc.cn/api/duty/duty/insertduty',
                        type: 'POST',
                        dataType: 'JSON',
                        data: {
                          sname: that.peopleRealName,
                          snumber: that.pepleRealId,
                          rid: result.data,
                          regionId: $('#patrolRoute div:eq(0)').attr('regionid'),
                          type: 0
                        },
                        success: function (data) {
                          if (data.code == 200) {
                            alert(1);
                          }
                        }
                      })
                    }
                  }
                })
                // that.peopleRealName = peopleRealName;
                // that.pepleRealId = pepleRealId;
              } else {
                $.ajax({
                  url: 'http://s16s652780.51mypc.cn/api/regions/regions/insterqy',
                  type: 'POST',
                  dataType: 'JSON',
                  data: {
                    regionName: that.globalRegionName,
                    coordinate: dataStr,
                    remarks: that.routeOrRegionDescribe
                  },
                  success: function (result) {
                    if (result.code == 200) {
                      that.addPolygonEntitys.clear();
                      that.polygonData = [];
                      that.patrolArea($('.police-dispatching .police-container .police-container-patrol .table .tbody tbody'), '');
                    }
                  }
                })
              }
            } else if (that.tabIndex == 2) {
              $.ajax({
                url: 'http://s16s652780.51mypc.cn/api/enclosure/enclosure/insertes',
                type: 'POST',
                dataType: 'JSON',
                data: {
                  anumber: that.newElectronicFenceId.anumber,
                  aname: that.newElectronicFenceId.aname,
                  routeInfo: dataStr
                },
                success: function (result) {
                  if (result.code == 200) {
                    that.addPolygonEntitys.clear();
                    that.polygonData = [];
                    that.getSecurityPeople($('.police-dispatching .police-container .police-container-policeforce .table .tbody tbody'), '');
                  }
                }
              })
            }
          }
          that.polygonFlag = false;
          // that.polygonData = [];
        }
        , clearLayer: function () {
            var that = this;
            that._map.removeLayer(that.clusterLayer);
            that.clusterLayer = null;
      }
      // $('.police-dispatching .police-container .police-container-patrol .main-content .select-list ul').empty();
      // $.ajax({
      //     url: 'http://s16s652780.51mypc.cn/api/regions/regions/selectqy',
      //     type: 'GET',
      //     dataType: 'JSON',
      //     success: function (res) {
      //         var result = res.data;
      //         $('.police-dispatching .police-container .police-container-patrol .main-content .select>ul>li>div:eq(0)').html(result[0].regionName + '<i></i>').attr('regionId', result[0].regionId);
      //         for (var i = 0; i < result.length; i++) {
      //             $('.police-dispatching .police-container .police-container-patrol .main-content .select-list ul').append($("<li regionId='" + result[i].regionId + "'>" + result[i].regionName + "</li>"))
      //         }
      //     }
      // })
      // that.getRouteInformation($('.police-dispatching .police-container .police-container-patrol .main-content>li:eq(1) .table .tbody tbody'), '');
      that.polygonFlag = false;
      that.entityPolygonAll.clear();
      that.modifyPolygon();
      // 切换时清除新增点线面数组中保存得数据,与清除地图上得实体
      that.polygonData = [];
      that.addPolygonEntitys.clear();
      that.treatmentIndex = null;
      that.tabIndex = 1;
      that.patrolIndex = 1;
      $('.police-dispatching-tab li:eq(1)').addClass('on').siblings().removeClass('on');
      $($('.police-container > div')[1]).stop().show().siblings().stop().hide();
      $('.police-dispatching .police-container .distribute-district .select-list ul').empty();
      $('.police-dispatching .police-container .distribute-district .select-list ul').append("<li key='addvcd' addvcd=''>全部</li>");
      $.ajax({
        url: 'http://s16s652780.51mypc.cn/api/regions/regions/selectqy',
        type: 'GET',
        dataType: 'JSON',
        success: function (res) {
          var result = res.data;
          $('.police-dispatching .police-container .police-container-patrol .main-content .select>ul>li>div:eq(0)').html(result[0].regionName + '<i></i>').attr('regionId', result[0].regionId);
          for (var i = 0; i < result.length; i++) {
            $('.police-dispatching .police-container .police-container-patrol .main-content .select-list ul').append($("<li regionId='" + result[i].regionId + "'>" + result[i].regionName + "</li>"))
          }
        }
      })
      that.getRouteInformation($('.police-dispatching .police-container .police-container-patrol .main-content>li:eq(1) .table .tbody tbody'), '');
      // $.ajax({
      //     url: 'http://s16s652780.51mypc.cn/api/district/district/selectList',
      //     type: 'POST',
      //     dataType: 'JSON',
      //     success: function (data) {
      //         for (var i = 0; i < data.data.length; i++) {
      //             $('.police-dispatching .police-container .distribute-district .select-list ul').append("<li key='addvcd' addvcd=" + data.data[i].addvcd + ">" + data.data[i].addvnm + "</li>");
      //         }
      //     }
      // })
      layui.use('laydate', function () {
        that.layuiLadate = layui.laydate;
        //执行一个laydate实例 开始
        that.layuiLadate.render({
          elem: '#dispatchingStartTime', //指定元素
          type: "datetime",
          format: 'yyyy-MM-dd HH:mm',
          btns: ['confirm'],
          trigger: 'click',
        });
        // 结束
        that.layuiLadate.render({
          elem: '#dispatchingEndTime', //指定元素
          type: "datetime",
          format: 'yyyy-MM-dd HH:mm',
          btns: ['confirm'],
          trigger: 'click',
        });
      });
      // that.getPoliceTable($('.police-container-distribute').find('.tbody tbody'), $('#dispatchingStartTime').val(), $('#dispatchingEndTime').val(), '', '', '');
      that.clickHand();
      $('.police-dispatching-tab li:eq(1)').trigger('click');
    },
    close: function () {
      $("#tabcontainer").css("width", "66%");
      $('#mapcontentClass').removeClass('client-max-map'); //删除样式
      this.entitysData = [];
      this.addEntitys.clear();
      this.entityPolygonAll.clear();
      this.modifyPolygon();
      // 切换时清除新增点线面数组中保存得数据,与清除地图上得实体
      this.polygonData = [];
      this.addPolygonEntitys.clear();
    },
    // 鼠标点击事件
    clickHand: function () {
      var self = this;
      self._map.onClick = mapClick;
      // $('#mainMapWidget')[0].ondblclick = function (event) {
      //   event.preventDefault();
      //   // if ()
      //   self.activateToolbar(event.graphic);
      //   return false;
      // };
      function mapClick(evt) {
        var normalizedVal = webMercatorUtils.xyToLngLat(evt.mapPoint.x, evt.mapPoint.y);
        var y = self._map.toMap({
          spatialReference: '4326',
          type: "point",
          x: evt.screenPoint.x,
          y: evt.screenPoint.y,
        });
        if (self.tabIndex == 0) {
          if (evt.graphic) {
            var result = evt.graphic.geometry.entityData;
            // var liText = evt.graphic.symbol.name;
            self.policeDetails(result.id);
          }
        } else if (self.tabIndex == 1) {
          if (self.patrolIndex == 1) {
            // 编辑中的
            if (self.polygonFlag == true) {
              var normalizedVal = webMercatorUtils.xyToLngLat(evt.mapPoint.x, evt.mapPoint.y);
              if (self.polygonData.length == 0) {
                self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                self.addPoint(self.addPolygonEntitys, normalizedVal[0], normalizedVal[1]);
              } else {
                self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                self.addPolyline(self.addPolygonEntitys, self.polygonData);
                return;
              }
            } else { // 不在编辑中
              if (evt.graphic) { // 点击在图形上
                // 保存当前点击得图形
                // self.currentDrawing = evt.graphic;
                self.modifyPolygon();
                self.activateToolbar(evt.graphic);
              } else { // 点击不在图形上
                self.modifyPolygon()
              }
            }
          } else {
            // 编辑中的
            if (self.polygonFlag == true) {
              var normalizedVal = webMercatorUtils.xyToLngLat(evt.mapPoint.x, evt.mapPoint.y);
              if (self.polygonData.length == 0) {
                self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                self.addPoint(self.addPolygonEntitys, normalizedVal[0], normalizedVal[1]);
              } else if (self.polygonData.length == 1) {
                self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                self.addPolyline(self.addPolygonEntitys, self.polygonData);
                return;
              } else if (self.polygonData.length > 1) {
                self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
                self.addPolygon(self.addPolygonEntitys, self.polygonData);
              }
            } else { // 不在编辑中
              if (evt.graphic) { // 点击在图形上
                // 保存当前点击得图形
                // self.currentDrawing = evt.graphic;
                self.modifyPolygon();
                self.activateToolbar(evt.graphic);
              } else { // 点击不在图形上
                self.modifyPolygon()
              }
            }
          }
        } else if (self.tabIndex == 2) {
          if (self.polygonFlag == true) {
            var normalizedVal = webMercatorUtils.xyToLngLat(evt.mapPoint.x, evt.mapPoint.y);
            if (self.polygonData.length == 0) {
              self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
              self.addPoint(self.addPolygonEntitys, normalizedVal[0], normalizedVal[1]);
            } else if (self.polygonData.length == 1) {
              self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
              self.addPolyline(self.addPolygonEntitys, self.polygonData);
              return;
            } else if (self.polygonData.length > 1) {
              self.polygonData.push([normalizedVal[0], normalizedVal[1]]);
              self.addPolygon(self.addPolygonEntitys, self.polygonData);
            }
          } else {
            if (evt.graphic) { // 点击在图形上
              // 保存当前点击得图形
              // self.currentDrawing = evt.graphic;
              self.electronicFence();
              self.activateToolbar(evt.graphic);
            } else { // 点击不在图形上
              self.electronicFence()
            }
          }
          // self.equipmentDetails(result.id);
        }
    });
    return Widget;
      }
      // 提示信息
      $(document).off('mousemove').mousemove(function (e) {
        var y = e.clientY + 10;
        var x = e.clientX + 20;
        if (e.clientX < 40) {
          var x = 40;
        }
        if (e.clientY < 42) {
          y = 42;
        }
        if (e.clientY > ($(window).height() - 82)) {
          y = ($(window).height() - 66);
        }
        if (e.clientX > ($(window).width() - 184)) {
          x = ($(window).width() - 184);
        }
        if (self.tabIndex == 1 || self.tabIndex == 2) {
          if (self.polygonFlag == true) {
            $('.police-dispatching .tips').stop().show();
            if (self.polygonData.length == 0) {
              $('.police-dispatching .tips').text('单击左键开始绘制。');
            } else {
              if (e.clientY > ($(window).height() - 98)) {
                y = ($(window).height() - 88);
              }
              $('.police-dispatching .tips').text('单击左键新增加点。单击右键完成绘制。');
            }
            $('.police-dispatching .tips').css({
              'top': y,
              'left': x,
            })
          } else {
            $('.police-dispatching .tips').stop().hide();
          }
        } else {
          $('.police-dispatching .tips').stop().hide();
        }
      })
    },
    // 警情详情弹框
    /**
     *
     * @param {number} id 警情ID
     */
    policeDetails: function (id) {
      var that = this;
      var url = './popup/html/police-details.html?obj=' + id;
      layui.use('layer', function () {
        that.layuiLayer = layui.layer;
        that.layuiLayer.config({
          extend: 'myskin/police-details.css'
        });
        that.layuiLayer.close(that.layuiLayer.index);
        that.layuiLayer.open({
          title: '警情详情',
          type: 2,
          shadeClose: true,
          shade: false,
          maxmin: false, //开启最大化最小化按钮
          area: ['500px', '400px'],
          offset: 'auto',
          skin: 'police-details',
          content: url,
          closeBtn: 1,
        });
      })
    },
    // 业主详情弹框
    /**
     *
     * @param {number} id 警情ID
     */
    ownerDetails: function (id) {
      var that = this;
      var url = './popup/html/owner-details.html?id=' + id;
      layui.use('layer', function () {
        that.layuiLayer = layui.layer;
        that.layuiLayer.config({
          extend: 'myskin/owner-details.css'
        });
        that.layuiLayer.close(that.layuiLayer.index);
        that.layuiLayer.open({
          title: '业主详情',
          type: 2,
          shadeClose: true,
          shade: false,
          maxmin: false, //开启最大化最小化按钮
          area: ['500px', '340px'],
          offset: 'auto',
          skin: 'owner-details',
          content: url,
          closeBtn: 1,
        });
      })
    },
    // 设备详情弹框
    /**
     *
     * @param {number} id 设备ID
     */
    equipmentDetails: function (id) {
      var that = this;
      var url = './popup/html/equipment-details.html?obj=' + id;
      layui.use('layer', function () {
        that.layuiLayer = layui.layer;
        that.layuiLayer.config({
          extend: 'myskin/equipment-details.css'
        });
        that.layuiLayer.close(that.layuiLayer.index);
        that.layuiLayer.open({
          title: '警情详情',
          type: 2,
          shadeClose: true,
          shade: false,
          maxmin: false, //开启最大化最小化按钮
          area: ['520px', '320px'],
          offset: 'auto',
          skin: 'equipment-details',
          content: url,
          closeBtn: 1,
        });
      })
    },
    // 获取当前时间,以及昨天现在的时间
    getTime: function getTime() {
      var timestamp = Date.parse(new Date());
      // 当前时间
      var currentTime = new Date(timestamp);
      // 年
      var currentY = currentTime.getFullYear();
      // 月
      var currentM = currentTime.getMonth() + 1 < 10 ? '0' + (currentTime.getMonth() + 1) : currentTime.getMonth() + 1;
      // 日
      var currentD = currentTime.getDate() < 10 ? '0' + currentTime.getDate() : currentTime.getDate();
      // 时
      var currentH = currentTime.getHours() < 10 ? '0' + currentTime.getHours() : currentTime.getHours();
      // 分
      var currentDd = currentTime.getMinutes() < 10 ? '0' + currentTime.getMinutes() : currentTime.getMinutes();
      // 明天
      var tomorrowTime = new Date(timestamp - 60 * 60 * 24 * 1000);
      // 年
      var tomorrowY = tomorrowTime.getFullYear();
      // 月
      var tomorrowM = tomorrowTime.getMonth() + 1 < 10 ? '0' + (tomorrowTime.getMonth() + 1) : tomorrowTime.getMonth() + 1;
      // 日
      var tomorrowD = tomorrowTime.getDate() < 10 ? '0' + tomorrowTime.getDate() : tomorrowTime.getDate();
      // 时
      var tomorrowH = tomorrowTime.getHours() < 10 ? '0' + tomorrowTime.getHours() : tomorrowTime.getHours();
      // 分
      var tomorrowDd = tomorrowTime.getMinutes() < 10 ? '0' + tomorrowTime.getMinutes() : tomorrowTime.getMinutes();
      return {
        current: currentY + '-' + currentM + '-' + currentD + ' ' + currentH + ':' + currentDd,
        tomorrow: tomorrowY + '-' + tomorrowM + '-' + tomorrowD + ' ' + tomorrowH + ':' + tomorrowDd,
        month: currentM + currentD
      };
    },
    // 获取警情信息列表
    /**
     *
     * @param {object} dom jq对象
     * @param {string} beginTime 开始时间
     * @param {string} endTime 结束时间
     * @param {*} waringType 警情的类别
     */
    getPoliceTable: function (dom, beginTime, endTime, waringType, addvcd, type) {
      dom.empty();
      var that = this;
      $.ajax({
        url: 'http://s16s652780.51mypc.cn/api/jingdan/jingdan/selectList',
        type: 'POST',
        dataType: 'JSON',
        data: {
          beginTime: beginTime,
          endTime: endTime,
          waringType: waringType,
          addvcd: addvcd,
          type: type
        },
        success: function (data) {
          var result = data.data;
          var str = '';
          that.entitysData = [];
          that.addEntitys.clear();
          for (var a, time, t, e, y, h, i = 0; i < result.length; i++) {
            if (result[i].type != 1) {
              that.createEntitys(that.addEntitys, that.entitysData, '警情信息', {
                lgtd: result[i].jd,
                lttd: result[i].wd,
                id: result[i].id
              }, result[i].jd, result[i].wd, './images/jingbaored.png');
              t = result[i].galarmTime.substr(0, 10);
              e = result[i].galarmTime.substr(11);
              time = t + '&nbsp;' + e;
              y = result[i].galarmTime.substr(5, 5);
              h = result[i].galarmTime.substr(11, 5);
              a = Number(i) + 1;
              str += '<tr term-list=' + result[i].id + ' lgtd=' + result[i].jd + ' lttd=' + result[i].wd + '>';
              str += '<td>' + a + '</td>';
              str += '<td title=' + result[i].addvnm + '>' + result[i].addvnm + '</td>';
              str += '<td title=' + (result[i].type == 2 ? '处理中' : '待处理') + '>' + (result[i].type == 2 ? '处理中' : '待处理') + '</td>';
              str += "<td><a href='javascript:;' title=" + time + ">" + y + ' ' + h + "</a></td>";
              if (result[i].type == 2) {
                str += "<td class='operation'> <input class='follow-up' type='button' value='跟进' term-list=" + result[i].id + "> </td>";
              } else {
                str += "<td class='operation'> <input class='edit' type='button' value='编辑' term-list=" + result[i].id + "> </td>";
              }
              str += '</tr>';
              dom.append(str);
              str = '';
            }
          }
          for (var i = 0; i < 1000; i++) {
            var dd = Math.random();
            var cc = Math.random();
          }
        }
      })
    },
    // 获取区域信息列表
    patrolArea: function (dom, regionName) {
      dom.empty();
      var that = this;
      that.currentDrawing = [];
      that.entityPolygonAll.clear();
      $.ajax({
        url: 'http://s16s652780.51mypc.cn/api/regions/regions/selectList',
        type: 'POST',
        dataType: 'JSON',
        data: {
          regionName: regionName
        },
        success: function (data) {
          var result = data.data;
          var str = '';
          var entityArr = [];
          var objId = {};
          var entityData = '';
          for (var i = 0; i < result.length; i++) {
            entityArr = [];
            objId = {};
            entityData = result[i].coordinate.match(/\(([^)]*)\)/);
            // 此时result=["(dsfasjfj3124123)", "dsfasjfj3124123"];
            if (entityData && entityData != '') {
              entityData = entityData[1].split(',');
              for (var j = 0; j < entityData.length; j++) {
                entityArr.push([Number(entityData[j].split(' ')[0]), Number(entityData[j].split(' ')[1])]);
              }
            }
            objId.id = result[i].id;
            objId.regionId = result[i].regionId;
            objId.regionName = result[i].regionName;
            objId.remarks = result[i].remarks;
            that.addPolygonAll(that.entityPolygonAll, entityArr, objId);
            str += "<tr flyid=" + result[i].id + " flyname=" + result[i].regionName + "> <td>" + (Number(i) + 1) + "</td> <td>" + result[i].regionName + "</td> <td>" + result[i].ttime + "</td> </tr>";
            dom.append(str);
            str = '';
          }
        }
      })
    },
    // 获取路线信息列表
    getRouteInformation: function (dom, routeName) {
      dom.empty();
      var that = this;
      that.currentDrawing = [];
      that.entityPolygonAll.clear();
      $.ajax({
        url: 'http://s16s652780.51mypc.cn/api/routeIn/routein/selectList',
        type: 'POST',
        dataType: 'JSON',
        data: {
          routeName: routeName
        },
        success: function (data) {
          var result = data.data;
          var str = '';
          var entityArr = [];
          var objId = {};
          var entityData = '';
          for (var i = 0; i < result.length; i++) {
            entityArr = [];
            objId = {};
            entityData = result[i].routeInfo.match(/\(([^)]*)\)/);
            // 此时result=["(dsfasjfj3124123)", "dsfasjfj3124123"];
            if (entityData && entityData != '') {
              entityData = entityData[1].split(',');
              for (var j = 0; j < entityData.length; j++) {
                entityArr.push([Number(entityData[j].split(' ')[0]), Number(entityData[j].split(' ')[1])]);
              }
            }
            objId.id = result[i].id;
            objId.regionId = result[i].regionId;
            objId.routeName = result[i].routeName;
            objId.remarks = result[i].remarks;
            that.addPolygonAll(that.entityPolygonAll, entityArr, objId);
            str += "<tr flyid=" + result[i].id + " flyname=" + result[i].routeName + "> <td>" + (Number(i) + 1) + "</td> <td style='display: none;'>" + result[i].sname + "</td> <td>" + result[i].routeName + "</td> <td> <a href='javascript:;' title=" + result[i].rtime + ">" + result[i].rtime.substr(5, 11) + "</a></td> <td><input type='button' value='编辑'></td> </tr>";
            dom.append(str);
            str = '';
          }
        }
      })
    },
    // 获取保安人员信息列表
    getSecurityPeople: function (dom, deviceType) {
      dom.empty();
      var that = this;
      that.currentDrawing = [];
      that.entityPolygonAll.clear();
      $.ajax({
        url: 'http://s16s652780.51mypc.cn/api/security/security/selectList',
        type: 'POST',
        dataType: 'JSON',
        success: function (data) {
          var result = data.data;
          var str = '';
          that.entitysData = [];
          that.addEntitys.clear();
          var entityArr = [];
          var objId = {};
          var entityData = '';
          for (var a, i = 0; i < result.length; i++) {
            that.createEntitys(that.addEntitys, that.entitysData, '出警信息', {
              lgtd: result[i].jd,
              lttd: result[i].wd,
              id: result[i].id
            }, result[i].jd, result[i].wd, './images/security.png');
            entityArr = [];
            objId = {};
            entityData = result[i].coordinate.match(/\(([^)]*)\)/);
            a = Number(i) + 1;
            str += "<tr term-snumber=" + snumber + " lgtd=" + result[i].jd + " lttd=" + result[i].wd + ">";
            str += '<td>' + a + '</td>';
            str += '<td title=' + result[i].snumber + '>' + result[i].snumber + '</td>';
            str += '<td title=' + result[i].sname + '>' + result[i].sname + '</td>';
            str += '<td title=' + result[i].phone + '>' + result[i].phone + '</td>';
            str += "<td> <input type='button' value='编辑' resultid=" + result[i].id + "> </td>";
            str += '</tr>';
            dom.append(str);
            str = '';
            // 此时result=["(dsfasjfj3124123)", "dsfasjfj3124123"];
            if (entityData && entityData != '') {
              entityData = entityData[1].split(',');
              for (var j = 0; j < entityData.length; j++) {
                entityArr.push([Number(entityData[j].split(' ')[0]), Number(entityData[j].split(' ')[1])]);
              }
            }
            objId.id = result[i].id;
            objId.anumber = result[i].snumber;
            objId.aname = result[i].sname;
            that.addPolygonAll(that.entityPolygonAll, entityArr, objId);
          }
        }
      })
    },
    // 创建实体图层
    createEntitys: function (entitys, entityContent, name, item, lgtd, lttd, outlineColors) {
      var symbol = new esri.symbol.PictureMarkerSymbol(outlineColors, 26, 26);
      symbol.name = name;
      var pt = new Point(lgtd, lttd, new esri.SpatialReference({
        wkid: 4326
      }));
      pt.entityData = item;
      var graphic = new esri.Graphic(pt, symbol);
      entitys.add(graphic);
      entityContent.push(item);
    },
    addPoint: function (entitys, lgtd, lttd) {
      var symbol = new esri.symbol.PictureMarkerSymbol('./images/real-time-callPolice.png', 10, 10);
      var pt = new Point(lgtd, lttd, new SpatialReference({
        wkid: 4326
      }));
      var graphic = new esri.Graphic(pt, symbol);
      entitys.add(graphic);
    },
    addPolyline: function (entitys, path) {
      entitys.clear();
      var polylineSymbol = new SimpleLineSymbol();
      polylineSymbol.color = [255, 0, 0, 1];
      polylineSymbol.width = 4;
      var polyline = new Polyline({
        "paths": [path],
        "spatialReference": {
          "wkid": 4326
        }
      });
      entitys.add(new Graphic(polyline, polylineSymbol));
    },
    addPolygon: function (entitys, rings) {
      entitys.clear();
      var polygonSymbol = new SimpleFillSymbol();
      polygonSymbol.color = [24, 255, 243, 0.411];
      var polygon = new Polygon({
        "rings": [rings],
        "spatialReference": {
          "wkid": 4326
        }
      });
      entitys.add(new Graphic(polygon, polygonSymbol));
    },
    activateToolbar: function (graphic) {
      var tool = 0;
      this.editToolbar = new Edit(this._map);
      // if (registry.byId("tool_move").checked) {
      tool = tool | Edit.MOVE;
      // }
      // if (registry.byId("tool_vertices").checked) {
      tool = tool | Edit.EDIT_VERTICES;
      // }
      // if (registry.byId("tool_scale").checked) {
      tool = tool | Edit.SCALE;
      // }
      // if (registry.byId("tool_rotate").checked) {
      tool = tool | Edit.ROTATE;
      // }
      // enable text editing if a graphic uses a text symbol
      // if ( graphic.symbol.declaredClass === "esri.symbol.TextSymbol" ) {
      tool = tool | Edit.EDIT_TEXT;
      // }
      var options = {
        allowAddVertices: true,
        allowDeleteVertices: true,
        uniformScaling: true
      };
      this.editToolbar.activate(tool, graphic, options);
    },
    addPolygonAll: function (entitys, rings, objId) {
      // entitys.clear();
      var graphic = null;
      if (this.patrolIndex == 1) {
        var polylineSymbol = new SimpleLineSymbol();
        polylineSymbol.color = [255, 0, 0, 1];
        polylineSymbol.width = 4;
        var polyline = new Polyline({
          "paths": [rings],
          "spatialReference": {
            "wkid": 4326
          }
        });
        graphic = new Graphic(polyline, polylineSymbol)
      } else {
        var polygonSymbol = new SimpleFillSymbol();
        polygonSymbol.color = [24, 255, 243, 0.411];
        var polygon = new Polygon({
          "rings": [rings],
          "spatialReference": {
            "wkid": 4326
          }
        });
        graphic = new Graphic(polygon, polygonSymbol);
      }
      graphic.objId = objId;
      if (this.tabIndex == 1) {
        if (this.patrolIndex == 1) {
          this.currentDrawing.push({
            id: objId.id,
            regionId: objId.regionId,
            routeName: objId.routeName,
            remarks: objId.remarks,
            extent: graphic.geometry.getExtent()
          });
        } else {
          this.currentDrawing.push({
            id: objId.id,
            regionId: objId.regionId,
            regionName: objId.regionName,
            remarks: objId.remarks,
            extent: graphic.geometry.getExtent()
          });
        }
      } else {
        this.currentDrawing.push({
          id: objId.id,
          aname: objId.aname,
          anumber: objId.anumber,
          extent: graphic.geometry.getExtent()
        });
      }
      entitys.add(graphic);
    },
    modifyPolygon: function () {
      var self = this;
      if (self.editToolbar != null) {
        if (self.patrolIndex == 1) {
          var polygon = self.editToolbar.getCurrentState();
          for (var i = 0; i < self.currentDrawing.length; i++) {
            if (self.currentDrawing[i].id == polygon.graphic.objId.id) {
              self.currentDrawing[i].extent = polygon.graphic.geometry.getExtent();
            }
          }
          self.editToolbar.deactivate();
          self.editToolbar = null;
          // 声明空字符串,存储数据
          var dataStr = '';
          // 获取数据
          var data = polygon.graphic.geometry.paths[0];
          for (var i = 0; i < data.length; i++) {
            dataStr += (data[i][0] + ' ' + data[i][1] + ',');
          }
          // 组装数据
          dataStr = dataStr.substring(0, dataStr.length - 1);
          $.ajax({
            url: 'http://s16s652780.51mypc.cn/api/routeIn/routein/updatelx',
            type: 'POST',
            dataType: 'JSON',
            data: {
              id: polygon.graphic.objId.id,
              regionId: polygon.graphic.objId.regionId,
              routeName: polygon.graphic.objId.routeName,
              routeInfo: dataStr,
              remarks: polygon.graphic.objId.remarks,
            },
            success: function (result) {
              if (result.code == 200) {
              }
            }
          })
        } else {
          var polygon = self.editToolbar.getCurrentState();
          for (var i = 0; i < self.currentDrawing.length; i++) {
            if (self.currentDrawing[i].id == polygon.graphic.objId.id) {
              self.currentDrawing[i].extent = polygon.graphic.geometry.getExtent();
            }
          }
          self.editToolbar.deactivate();
          self.editToolbar = null;
          // 声明空字符串,存储数据
          var dataStr = '';
          // 获取数据
          var data = polygon.graphic.geometry.rings[0];
          for (var i = 0; i < data.length; i++) {
            dataStr += (data[i][0] + ' ' + data[i][1] + ',');
          }
          // 组装数据
          dataStr = dataStr.substring(0, dataStr.length - 1);
          $.ajax({
            url: 'http://s16s652780.51mypc.cn/api/regions/regions/updateqy',
            type: 'POST',
            dataType: 'JSON',
            data: {
              id: polygon.graphic.objId.id,
              regionId: polygon.graphic.objId.regionId,
              regionName: polygon.graphic.objId.regionName,
              coordinate: dataStr,
              remarks: polygon.graphic.objId.remarks
            },
            success: function (result) {
              if (result.code == 200) {
              }
            }
          })
        }
      }
    },
    electronicFence: function () {
      var self = this;
      if (self.editToolbar != null) {
        var polygon = self.editToolbar.getCurrentState();
        for (var i = 0; i < self.currentDrawing.length; i++) {
          if (self.currentDrawing[i].id == polygon.graphic.objId.id) {
            self.currentDrawing[i].extent = polygon.graphic.geometry.getExtent();
          }
        }
        self.editToolbar.deactivate();
        self.editToolbar = null;
        // 声明空字符串,存储数据
        var dataStr = '';
        // 获取数据
        var data = polygon.graphic.geometry.rings[0];
        for (var i = 0; i < data.length; i++) {
          dataStr += (data[i][0] + ' ' + data[i][1] + ',');
        }
        // 组装数据
        dataStr = dataStr.substring(0, dataStr.length - 1);
        $.ajax({
          url: 'http://s16s652780.51mypc.cn/api/enclosure/enclosure/updatee',
          type: 'POST',
          dataType: 'JSON',
          data: {
            id: polygon.graphic.objId.id,
            aname: polygon.graphic.objId.aname,
            anumber: polygon.graphic.objId.anumber,
            routeInfo: dataStr
          },
          success: function (result) {
            if (result.code == 200) {
            }
          }
        })
      }
    },
    //聚合图层事件
    flareClusterLayer: function (datas) {
      var that = this;
      var preClustered = false;
      var displaySingleFlaresAtCount = 10;
      var areaDisplayMode = "";
      // var allData = JSON.parse(DATA);
      // DataManager.setData(allData);
      //init the layer, more options are available and explained in the cluster layer constructor
      that.clusterLayer = new FlareClusterLayer({
        id: "flare-cluster-layer",
        spatialReference: new esri.SpatialReference({
          "wkid": 4326
        }),
        subTypeFlareProperty: "facilityType",
        singleFlareTooltipProperty: "name",
        displaySubTypeFlares: true,
        displaySingleFlaresAtCount: displaySingleFlaresAtCount,
        flareShowMode: "mouse",
        preClustered: preClustered,
        clusterRatio: 75,
        clusterAreaDisplay: areaDisplayMode,
        clusteringBegin: function () {
          console.log("clustering begin");
        },
        clusteringComplete: function () {
          console.log("clustering complete");
        }
      });
      //set up a class breaks renderer to render different symbols based on the cluster count. Use the required clusterCount property to break on.
      var defaultSym = new PictureMarkerSymbol("./images/ceshi.png", 32, 32).setOffset(0, 15);
      var renderer = new ClassBreaksRenderer(defaultSym, "clusterCount");
      var xlSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 32, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([200, 52, 59, 0.8]), 1), new dojo.Color([250, 65, 74, 0.8]));
      var lgSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 28, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([41, 163, 41, 0.8]), 1), new dojo.Color([51, 204, 51, 0.8]));
      var mdSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 24, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([82, 163, 204, 0.8]), 1), new dojo.Color([102, 204, 255, 0.8]));
      var smSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbol.STYLE_CIRCLE, 22, new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID, new dojo.Color([230, 184, 92, 0.8]), 1), new dojo.Color([255, 204, 102, 0.8]));
      renderer.addBreak(0, 19, smSymbol);
      renderer.addBreak(20, 150, mdSymbol);
      renderer.addBreak(151, 1000, lgSymbol);
      renderer.addBreak(1001, Infinity, xlSymbol);
      that.clusterLayer.setRenderer(renderer); //use standard setRenderer.
      //set up a popup template
      var template = new PopupTemplate({
        title: "{name}",
        fieldInfos: [{
            fieldName: "facilityType",
            label: "Facility Type",
            visible: true
          },
          {
            fieldName: "postcode",
            label: "Post Code",
            visible: true
          },
          {
            fieldName: "isOpen",
            label: "Opening Hours",
            visible: true
          }
        ]
      });
      //clusterLayer.infoTemplate = template;
      that._map.infoWindow.titleInBody = false;
      that._map.addLayer(that.clusterLayer);
      //var data = DataManager.getData();
      that.clusterLayer.addData(datas);
    },
    clearLayer: function () {
      var that = this;
      that._map.removeLayer(that.clusterLayer);
      that.clusterLayer = null;
    }
  });
  return Widget;
});