shuishen
2021-06-09 81695a6227625197cff2f8f1c219d20ae6bd3adc
widgets/searchL/Widget.js
@@ -55,29 +55,43 @@
            })
            $(".searchImg").click(function () {
               // that.getInputData();
               // that.setVal(that.searchDatas);
               $('.searchLMain').show();
               // console.log(2324345)
               that.getInputData();
               // console.log(that.searchDatas)
               if(typeof that.searchDatas == 'string'){
                  var han = /^[\u4e00-\u9fa5]+$/;
                  if (han.test(that.searchDatas) || that.searchDatas == '  ') {
                     that.getData(0, that.searchDatas);
                     $('.searchLMain').show();
                  } else {
                     layui.use(function () { //亦可加载特定模块:layui.use(['layer', 'laydate', function(){
                        //得到各种内置组件
                        var layer = layui.layer //弹层
                        // layer.msg('请先填写关键字', { icon: 1, time: 1000, shift: 6 });
                        layer.tips('请先填写关键字', '.searchImg',{
                           tips: [2,'#FF5722']
                        });
                     })
                     $('.searchLMain').hide();
                  }
               }else{
                  if(that.searchDatas[0] && that.searchDatas[1]){
                     console.log(that.searchDatas);
                  }else{
                     layui.use(function () { //亦可加载特定模块:layui.use(['layer', 'laydate', function(){
                        //得到各种内置组件
                        var layer = layui.layer //弹层
                        // layer.msg('请先填写关键字', { icon: 1, time: 1000, shift: 6 });
                        layer.tips('请先填写完整坐标', '.searchImg',{
                           tips: [2,'#FF5722']
                        });
                     })
                  }
               }
            })
            $(".searchColce").click(function () {
               $('.searchLMain').hide();
            })
            // that.getInputData();
            // that.setVal(that.searchDatas);
            // 自动展开面板   面板和搜索无关!
            $('.searchLMain').show();
         },
         closeToolBox: function (item) {
            // if (item != this.name) {
            //    $('.tool-y-box').hide();
            // }
         },
         getInputData: function () {
@@ -87,76 +101,59 @@
               this.searchDatas = [$('#local_data1').val(), $('#local_data2').val()];
            }
         },
         setVal: function (val) {
            var that = this;
            if (typeof val == "string") {
               var url = 'http://171.34.76.171:8880/pyh-wetResource/GeoData/queryGeoData?name=' + val + '&protectAreald=&type=0&dataSort=1',
                  token = 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJlY2hpc2FuIiwic3ViIjoiYWRtaW4iLCJpYXQiOjE2MjMxMTYwMzYsImV4cCI6MTYyNTcwODAzNn0.p2qqmcWrC9QDLAFgu1n0eR4k4wrr3udFKKhjBqGJXAzz1jdR57agyyYMsTZPXIPkH7hviE64uHLW8T7fM_VvNw';
               axios.get(url, {
                  headers: {
                     'token': token
                  }
               }).then((res) => {
                  if (res.status == 200) {
                     var data = res.data.data;
                     that.createData(data);
                  } else {
                     console.log('请求访问失败')
                  }
               })
            } else if (typeof val == "object") {
            }
         },
         createData: function (d) {
            var i = 1;
            for (var k in d) {
               d[k].tableId = i++;
            }
            var data = d;
            this.beginLayUi(data);
         },
         getData: function (index) {
         getData: function (index, val) {
            val = val == '  '? '': val;
            var d = $('.searchLMain').find('.layui-tab-item').hide;
            // console.log(d)
            var that = this,
               url = index == 0 ?
                  'http://171.34.76.171:8880/pyh-wetResource/monitorRecords/queryMonitorRecords?name=&startTime=&endTime=&type=2&startPage=1&limit=10&soId=056c6f9fa3f14c168fa90cf1563cd01f'
                  :
                  index == 1 ?
                     'http://171.34.76.171:8880/pyh-station/video/queryPyhVideoByFilter?id=&protectAreaId=&name=&buildTime=&buildType=&start=1&limit=10'
                     :
                     index == 2 ?
                        'http://171.34.76.171:8880/pyh-station/monitorStation/queryMonitorStationByFilter?leftTreeId=&isShow=&stcd=&stnm=&status=&startPage=1&limit=10' :
                        false
               , token = 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJlY2hpc2FuIiwic3ViIjoiYWRtaW4iLCJpYXQiOjE2MjMxMzIzMjYsImV4cCI6MTYyNTcyNDMyNn0.2ug9No32Ij3DxXCw8utXbahYsAe6l_FdzRTH5ysaBsOuKLbmQ80faGclncCdNahQ3rgiV54U-gawqw9JhGsAJA';
               url = `http://171.34.76.171:8880/pyh-wetResource/monitorRecords/queryMonitorData?name=${val}&start&limit&type=${index}`
               // url = `http://171.34.76.171:8880/pyh-wetResource/monitorRecords/queryMonitorData?name=&start&limit&type=${index}`
               , token = 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJlY2hpc2FuIiwic3ViIjoiYWRtaW4iLCJpYXQiOjE2MjMyMjU5OTcsImV4cCI6MTYyNTgxNzk5N30.zWpoKa5AK7xLIPNm-CXoHY9D5kpk9AiUTGkuAQOZi2Rdl2BfroT4IqxjBpyUPZlgwCjG2CoJqy_7rnnodpmqNw';
            axios.get(url, {
               headers: {
                  'token': token
               }
            }).then((res) => {
               if (res.status == 200) {
                  var data = res.data.data;
                  that.createDatas(data, index);
               if (res.data.code == 200) {
                  var data = res.data.data.panoramaList || res.data.data.stationList || res.data.data.videoList || [];
                  // console.log(data)
                  var val = index;//数据的2和1对调
                  if (index == 1) {
                     val = 2;
                  } else if (index == 2) {
                     val = 1;
                  }
                  that.createDatas(data, val);
               } else {
                  console.log('请求访问失败')
               }
            })
         },
         createDatas: function (d, n) {
            var i = 1;
            for (var k in d) {
               d[k].tableId = i++;
            }
            var data = d;
            if (n == 0) {
               this.beginLayUi(data);
            } else if (n == 1) {
               this.beginLayUi(1, data);
            } else if (n == 2) {
               this.beginLayUi(1, 1, data);
            if (d == []) {
               if (n == 0) {
                  this.beginLayUi(d);
               } else if (n == 1) {
                  this.beginLayUi(1, d);
               } else if (n == 2) {
                  this.beginLayUi(1, 1, d);
               }
            } else {
               var i = 1;
               for (var k in d) {
                  d[k].tableId = i++;
               }
               var data = d;
               if (n == 0) {
                  this.beginLayUi(data);
               } else if (n == 1) {
                  this.beginLayUi(1, data);
               } else if (n == 2) {
                  this.beginLayUi(1, 1, data);
               }
            }
         },
         onOpen: function () {
@@ -167,7 +164,15 @@
               var $ = layui.jquery
                  , element = layui.element;
               element.on('tab(docDemoTabBrief)', function (elem) {
                  that.getData(elem.index)
                  var val = elem.index;//数据的2和1对调
                  if (elem.index == 1) {
                     val = 2;
                  } else if (elem.index == 2) {
                     val = 1;
                  }
                  that.getData(val, that.searchDatas);
               });
            });
         },
@@ -220,8 +225,8 @@
                     , cols: [[
                        { field: 'tableId', width: 59, align: 'center', unresize: true, title: '序号' }
                        , { field: 'name', width: 90, align: 'center', unresize: true, title: '图层名称' }
                        , { field: 'protectArea', width: 95, align: 'center', unresize: true, title: '图层属性1' }
                        , { field: 'protectArea', width: 95, align: 'center', unresize: true, title: '图层属性2' }
                        , { field: 'remarks', width: 95, align: 'center', unresize: true, title: '图层属性1' }
                        , { field: 'createTime', width: 95, align: 'center', unresize: true, title: '图层属性2' }
                        , { fixed: 'right', align: 'center', unresize: true, title: '操作', toolbar: '#demoTable' }
                     ]],
                     data: data,
@@ -239,7 +244,7 @@
                     if (layEvent === 'detail') {
                        //   layer.msg('查看操作');
                        window.open(obj.data.panAddress);
                        console.log(obj.data.panAddress)
                        // console.log(obj.data.panAddress)
                     } else if (layEvent === 'edit') {
                        that.goOnPosition([obj.data.lon, obj.data.lat]);
                     }
@@ -371,7 +376,9 @@
                              </tr>
                              <tr>
                                 <th>图片:</th>
                                 <td class="left" colspan="3"></td>
                                 <td class="left" colspan="3">
                                 <img src="${obj.data.attList[0].uaOriginPath}" alt="">
                                 </td>
                              </tr>`;
                        str += '</table>';
                        XQDom.append(str);
@@ -379,7 +386,7 @@
                        $('.jimu-widget-searchTabaPopup').css({ 'display': 'block' });
                        $('.jimu-widget-searchTabaPopup').find('.p-main').eq(1).css({ 'display': 'block' }).siblings().css({ 'display': 'none' });
                        console.log(obj.data.name)
                        // console.log(obj.data.name)
                     } else if (layEvent === 'edit') {
                        that.goOnPosition([obj.data.lon, obj.data.lat]);
                     }