南昌市物联网技防平台-前端
shuishen
2021-04-23 8d837b97ffb27e4e26f067c1febde353bfdf91cf
public/map/widgets/supervisoryMap/SupervisoryMap.js
@@ -152,6 +152,13 @@
    //存放聚合实体
    clusterLayer: null,
    //左侧控制栏
    entityData: [],
    analysisAddEntitys: null,
    //防抖
    onceTimeMethodS: null,
    onceTime: 300,
    constructor: function (options, srcRefNode) {
      this._map = options.map;
      objThis = this;
@@ -175,29 +182,6 @@
      this._map.addLayer(this.addPolygonEntitys);
      this._map.addLayer(this.entityPolygonAll);
    },
    startup: function () {
      objThis._map.addLayer(objThis._siteLayer);
    },
    getQueryStringByKey: function (key) {
      return (document.location.search.match(new RegExp("(?:^\\?|&)" + key + "=(.*?)(?=&|$)")) || ['', null])[1];
    },
    entityData: [],
    //左侧控制栏
    analysisAddEntitys: null,
    constructor: function (options, srcRefNode) {
      this._map = options.map;
      objThis = this;
      this.analysisAddEntitys = new GraphicsLayer({ id: 'analysisAddEntitys' });
      // this.addOneEntitys = new GraphicsLayer({ id: 'addOneEntitys' });
      // this.addTwoEntitys = new GraphicsLayer({ id: 'addTwoEntitys' });
@@ -205,11 +189,78 @@
      this._map.addLayer(this.analysisAddEntitys);
      this._map.addLayer(this.addOneEntitys);
    },
    open: function () {
      var that = this;
      $.ajax({
        url: "/api/blade-jfpts/equipment/equipment/listAll",
        type: 'get',
        dataType: 'JSON',
        success: function (res) {
          var datas = res.data;
          var heatmapRenderer = null;
          that.entityData = [];
          for (var i = 0; i < datas.length; i++) {
            datas[i].x = Number(datas[i].jd);
            datas[i].y = Number(datas[i].wd);
            that.entityData.push({
              lgtd: Number(datas[i].jd),
              lttd: Number(datas[i].wd)
            })
          }
          that.flareClusterLayer(datas);
          that.heatmapfeatureLayer = that.heatmFeaLayers();
          that._map.addLayer(that.heatmapfeatureLayer);
          // that.checkBoxSelect();//左侧控制热力图重复
        }
      })
      var that = this;
      var intTime = () => {
        var time = this.getTime();
        $("#tabcontainer").css("width", "360px");
        $('#mapcontentClass').addClass('client-max-map'); //追加样式
        AppEvent.dispatchAppEvent(AppEvent.APPLICATION_RESIZE, {});
        that.tabIndex = 0;
        $('.analysis-and-judgment-tab li:eq(0)').addClass('on').siblings().removeClass('on');
        $($('.analysis-container > div')[0]).stop().show().siblings().stop().hide();
        that.heatmapfeatureLayer_1 = that.heatmFeaLayers();
        that._map.addLayer(that.heatmapfeatureLayer_1);
        $('#analysis_select_time_start').val(time.tomorrow);
        $('#analysis_select_time_end').val(time.current);
        layui.use('laydate', function () {
          that.layuiLadate = layui.laydate;
          //执行一个laydate实例 开始
          that.layuiLadate.render({
            elem: '#analysis_select_time_start', //指定元素
            type: "datetime",
            format: 'yyyy-MM-dd HH:mm',
            trigger: 'click'
          });
          // 结束
          that.layuiLadate.render({
            elem: '#analysis_select_time_end', //指定元素
            type: "datetime",
            format: 'yyyy-MM-dd HH:mm',
            trigger: 'click'
          });
        });
        that.getArea($('#policeArea'));
        that.getPoliceTableAnalysis($('.analysis-container-police').find('.tbody tbody'), time.tomorrow, time.current, '', '');
        that.clickHand();
      }
      intTime();
    },
    startup: function () {
      var mySelf = this;
      objThis._map.addLayer(objThis._siteLayer);
      var that = this;
      that.getEquipmentTable($('.analysis-container-equipment').find('.tbody tbody'),'');
      that.getEquipmentTable($('.analysis-container-equipment').find('.tbody tbody'), '');
      // 顶部tab得切换事件
      $('.analysis-and-judgment-tab li').click(function () {
        // if (that.tabIndex == $(this).index()) return;
@@ -367,40 +418,120 @@
      })
      // 设备列表中的点击事件
      $('.analysis-container-equipment .analysis-table-content .tbody').off('click', 'tr').on('click', 'tr', function () {
      $('.analysis-container-equipment .analysis-table-content .tbody').off('click', 'tr').on('click', 'tr', function (event) {
        var id = $(this).attr('term-listid');
        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,
          });
        })
      })
      $('.analysis-container-equipment .analysis-table-content .tbody').off('click', '.location').on('click', '.location', function (event) {
        //   // 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,
        //   //   });
        //   // })
        event.stopPropagation();
        var lgtd = Number($(this).find('input').attr('lgtd'));
        var lttd = Number($(this).find('input').attr('lttd'));
        // console.log($(this).find('input').attr('lttd'));
        var position = new esri.geometry.Point(lgtd, lttd, new esri.SpatialReference({ wkid: 4326 }));//根据输入坐标信息找地图上的点
        that._map.centerAndZoom(position, 18);//缩放,10是缩放级别,可以自定义,数值越大缩放越大
        var y = +window.innerHeight / 2 + 200;
        var x = (+window.innerWidth - 360) / 2 + 360 + 70;
        // document.elementFromPoint(x, y).click();
        // console.log(x, y)
        // var a = document.elementFromPoint(21, 122);
        // console.log(a);
        // console.log(that.clusterLayer, that._map, 6)
        // console.log(id, 'id');
        // console.log(that.clusterLayer.indexs);
        var Tattributes = null
          , ds = that.clusterLayer.allData;
        for (var key in ds) {
          if (ds[key].id == id){
            Tattributes = ds[key];
          }
        }
        if (mySelf.onceTimeMethod == null) {//防抖.限制时间内点击次数,否则会造成不能正确销毁前一个弹窗
          var evtdata = {};
          evtdata = {
            graphic: {
              attributes: Tattributes,
            },
            screenX: x,
            screenY: y,
          }
          that.clusterLayer._clickOpenOnclick(evtdata, '控制端', that.clusterLayer.indexs);
          mySelf.onceTimeMethod = setTimeout(() => {
            mySelf.onceTimeMethod = null;
          }, mySelf.onceTime);
        } else {
        };
      })
      // $('.analysis-container-equipment .analysis-table-content .tbody').off('click', '.location').on('click', '.location', function (event) {
      //   event.stopPropagation();
      // })
      $('.analysis-container-equipment .analysis-table-content .tbody').off('click', '.location input').on('click', '.location input', 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 y = +window.innerHeight / 2 + 200;
        var x = (+window.innerWidth - 360) / 2 + 360 + 70;
        // document.elementFromPoint(x, y).click();
        // console.log(x, y)
        // var a = document.elementFromPoint(21, 122);
        // console.log(a);
        // console.log(that.clusterLayer, that._map, 6)
        // console.log(id, 'id');
        // console.log(that.clusterLayer.indexs);
        var Tattributes = null
          , ds = that.clusterLayer.allData;
        for (var key in ds) {
          if (ds[key].id == id){
            Tattributes = ds[key];
          }
        }
        if (mySelf.onceTimeMethod == null) {//防抖.限制时间内点击次数,否则会造成不能正确销毁前一个弹窗
          var evtdata = {};
          evtdata = {
            graphic: {
              attributes: Tattributes,
            },
            screenX: x,
            screenY: y,
          }
          that.clusterLayer._clickOpenOnclick(evtdata, '控制端', that.clusterLayer.indexs);
          mySelf.onceTimeMethod = setTimeout(() => {
            mySelf.onceTimeMethod = null;
          }, mySelf.onceTime);
        } else {
        };
      })
      // 警情列表中得热力图是否选中事件
      $('#policeHeatMap').click(function () {
        that.checkBoxSelect(this);
@@ -520,12 +651,20 @@
      })
    },
    getQueryStringByKey: function (key) {
      return (document.location.search.match(new RegExp("(?:^\\?|&)" + key + "=(.*?)(?=&|$)")) || ['', null])[1];
    },
    //左侧控制栏
    getArea: function (dom) {
      dom.children('.select-list').children('ul').empty();
      dom.children('.select-list').children('ul').append($("<li areaid='all'>全部</li>"));
      var that = this;
      $.ajax({
        url: 'https://web.byisf.com/api/blade-system/region/select?code=3601',
        url: '/api/blade-system/region/select?code=3601',
        type: 'GET',
        dataType: 'JSON',
        success: function (data) {
@@ -540,7 +679,7 @@
      dom.empty();
      var that = this;
      $.ajax({
        url: "https://web.byisf.com/api/blade-jfpts/alarm/alarm/page?current=1&size=99999&waringType=&beginTime=" + beginTime + "&endTime=" + endTime + "&province=36&city=3601&district=" + addvcd,
        url: "/api/blade-jfpts/alarm/alarm/page?current=1&size=99999&waringType=&beginTime=" + beginTime + "&endTime=" + endTime + "&province=36&city=3601&district=" + addvcd,
        type: 'get',
        dataType: 'JSON',
        success: function (data) {
@@ -586,14 +725,44 @@
        }
      })
    },
    // 获取设备信息列表
    getEquipmentTable: function (dom, deviceType) {
    getOwnerType: function (dom) {
      dom.children('div:eq(0)').html("全部 <i></i>");
      dom.children('.select-list').children('ul').empty();
      dom.children('.select-list').children('ul').append($("<li ownerid='all'>全部</li>"));
      $.ajax({
        url: '/api/blade-jfpts/lx/lx/seleclx',
        type: 'GET',
        dataType: 'JSON',
        success: function (data) {
          var res = data.data;
          for (var i = 0; i < res.length; i++) {
            dom.children('.select-list').children('ul').append($("<li ownerid=" + res[i].tnumber + ">" + res[i].types + "</li>"));
          }
        }
      })
    },
    getOwnerDj: function (dom, tnumbers) {
      dom.children('div:eq(0)').html("全部 <i></i>");
      dom.children('.select-list').children('ul').empty();
      dom.children('.select-list').children('ul').append($("<li>全部</li>"));
      $.ajax({
        url: '/api/blade-jfpts/dj/dj/selectName?tnumbers=' + tnumbers,
        type: 'GET',
        dataType: 'JSON',
        success: function (data) {
          var res = data.data;
          for (var i = 0; i < res.length; i++) {
            dom.children('.select-list').children('ul').append($("<li>" + res[i].dj + "</li>"));
          }
        }
      })
    },
    // 获取业主信息列表
    getOwnerTable: function (dom, type, dj) {
      dom.empty();
      var that = this;
      // console.log(dom, deviceType);
      // dom.append(deviceType);
      $.ajax({
        url: '/api/blade-jfpts/equipment/equipment/selectList?deviceType=' + deviceType,
        url: '/api/blade-jfpts/suser/suser/selectList?type=' + type + '&dj=' + dj,
        type: 'GET',
        dataType: 'JSON',
        success: function (data) {
@@ -603,7 +772,54 @@
          that.analysisAddEntitys.clear();
          for (var a, i = 0; i < result.length; i++) {
            that.createEntitysAnalysis(that.analysisAddEntitys, that.entitysData, '业主信息', {
              lgtd: result[i].jd,
              lttd: result[i].wd,
              id: result[i].id
            }, result[i].jd, result[i].wd, './images/owner.png');
            a = Number(i) + 1;
            str += "<tr term-list=" + result[i].id + ">";
            str += '<td>' + a + '</td>';
            str += '<td>' + result[i].type + '</td>';
            str += '<td>' + result[i].dj + '</td>';
            str += '<td>' + result[i].yname + '</td>';
            str += "<td class='location'> <input type='button' value='定位'" + ' lgtd=' + result[i].jd + ' lttd=' + result[i].wd + "></td>";
            str += '</tr>';
            dom.append(str);
            str = '';
          }
        }
      })
    },
    // 获取设备信息列表
    getEquipmentTable: function (dom, deviceType) {
      dom.empty();
      var that = this;
      // console.log(dom, deviceType);
      // dom.append(deviceType);
      // var str = "<td class='locationb'> <input type='button' value='定位'" + ' lgtd=' + 114.9285 + ' lttd=' + 25.850693 + "></td>"
      // that.entitysData = [];
      // that.analysisAddEntitys.clear();
      // that.createEntitysAnalysis(that.analysisAddEntitys, that.entitysData, '设备信息', {
      //   lgtd: 114.9285,
      //   lttd: 25.850693,
      //   id: 5
      // }, 114.9285, 25.850693, './images/ceshi.png');
      // dom.append(str)
      $.ajax({
        url: '/api/blade-jfpts/equipment/equipment/selectList?deviceType=' + deviceType,
        type: 'GET',
        dataType: 'JSON',
        success: function (data) {
          var result = data.data;
          // console.log(data)
          var str = '';
          that.entitysData = [];
          that.analysisAddEntitys.clear();
          for (var a, i = 0; i < result.length; i++) {
            that.createEntitysAnalysis(that.analysisAddEntitys, that.entitysData, '设备信息', {
              lgtd: result[i].jd,
              lttd: result[i].wd,
@@ -635,77 +851,13 @@
      pt.entityData = item;
      var graphic = new esri.Graphic(pt, symbol);
      entitys.add(graphic);
      var bbb = document.getElementsByTagName("image");
      // console.log(bbb);
      entityContent.push(item);
  },
    },
    //左侧控制栏↑
    open: function () {
      var that = this;
      $.ajax({
        url: "https://web.byisf.com/api/blade-jfpts/equipment/equipment/listAll",
        type: 'get',
        dataType: 'JSON',
        success: function (res) {
          var datas = res.data;
          var heatmapRenderer = null;
          that.entityData = [];
          for (var i = 0; i < datas.length; i++) {
            datas[i].x = Number(datas[i].jd);
            datas[i].y = Number(datas[i].wd);
            that.entityData.push({
              lgtd: Number(datas[i].jd),
              lttd: Number(datas[i].wd)
            })
          }
          that.flareClusterLayer(datas);
          that.heatmapfeatureLayer = that.heatmFeaLayers();
          that._map.addLayer(that.heatmapfeatureLayer);
          // that.checkBoxSelect();//左侧控制热力图重复
        }
      })
      var that = this;
      var intTime = () => {
        var time = this.getTime();
        $("#tabcontainer").css("width", "360px");
        $('#mapcontentClass').addClass('client-max-map'); //追加样式
        AppEvent.dispatchAppEvent(AppEvent.APPLICATION_RESIZE, {});
        that.tabIndex = 0;
        $('.analysis-and-judgment-tab li:eq(0)').addClass('on').siblings().removeClass('on');
        $($('.analysis-container > div')[0]).stop().show().siblings().stop().hide();
        that.heatmapfeatureLayer_1 = that.heatmFeaLayers();
        that._map.addLayer(that.heatmapfeatureLayer_1);
        $('#analysis_select_time_start').val(time.tomorrow);
        $('#analysis_select_time_end').val(time.current);
        layui.use('laydate', function () {
          that.layuiLadate = layui.laydate;
          //执行一个laydate实例 开始
          that.layuiLadate.render({
            elem: '#analysis_select_time_start', //指定元素
            type: "datetime",
            format: 'yyyy-MM-dd HH:mm',
            trigger: 'click'
          });
          // 结束
          that.layuiLadate.render({
            elem: '#analysis_select_time_end', //指定元素
            type: "datetime",
            format: 'yyyy-MM-dd HH:mm',
            trigger: 'click'
          });
        });
        that.getArea($('#policeArea'));
        that.getPoliceTableAnalysis($('.analysis-container-police').find('.tbody tbody'), time.tomorrow, time.current, '', '');
        that.clickHand();
      }
      intTime();
    },
    heatmFeaLayers: function () {// liu 热力图渲染器,加载热力图
      var layerDefinition = {