liuyg
2021-06-15 ebefa651ad2d6edbfdb30fea3fc1ff97232a0aee
widgets/LeftNavigationBar/Widget.js
@@ -61,6 +61,51 @@
            });
            $('#left-navigation-bar-main-search').click(() => { //搜索事件
               leftSearchItemLayer()
            })
            $(".jimu-widget-LeftNavigationBar input[type='search']").bind('input propertychange', function () {
               //做一些事情
               var val = $(this).val();
               if (val == '') {
                  that.changeData(that.dataAllArray, val); //重写数据
                  layui.use('tree', function () {
                     layui.tree.reload('demoId1', {
                        data: that.data
                     });
                     var jqDom = $("#left-tree-list > .layui-tree > div");
                     for (var i = 0; i < jqDom.length; i++) {
                        if ($(jqDom[i]).text().indexOf("三维倾斜数据") != -1) {
                           $(jqDom[i]).find('.layui-btn-group').remove()
                        }
                        var textList = $(jqDom[i]).find('.layui-tree-txt');
                        for (var j = 0; j < textList.length; j++) {
                           $(textList[j]).attr('title', $(textList[j]).text())
                        }
                     }
                  })
               }
            })
            $(".jimu-widget-LeftNavigationBar input[type='search']").keyup(function (e) {
               if (e.keyCode == 13) {
                  leftSearchItemLayer()
               }
            })
            $(".jimu-widget-LeftNavigationBar .tree-layer-opcity .close").click(function () {
               $(".jimu-widget-LeftNavigationBar .tree-layer-opcity").stop().hide();
            })
            function leftSearchItemLayer() {
               var val = $('#left-navigation-bar-main-input').val();
               if (val != '') {
                  var clearOur = () => {
@@ -119,43 +164,8 @@
                     useit(that.data);
                  })
               } else {}
            })
            $(".jimu-widget-LeftNavigationBar input[type='search']").bind('input propertychange', function () {
               //做一些事情
               var val = $(this).val();
               if (val == '') {
                  that.changeData(that.dataAllArray, val); //重写数据
                  layui.use('tree', function () {
                     layui.tree.reload('demoId1', {
                        data: that.data
                     });
                     var jqDom = $("#left-tree-list > .layui-tree > div");
                     for (var i = 0; i < jqDom.length; i++) {
                        if ($(jqDom[i]).text().indexOf("三维倾斜数据") != -1) {
                           $(jqDom[i]).find('.layui-btn-group').remove()
                        }
                        var textList = $(jqDom[i]).find('.layui-tree-txt');
                        for (var j = 0; j < textList.length; j++) {
                           $(textList[j]).attr('title', $(textList[j]).text())
                        }
                     }
                  })
               }
            })
            $(".jimu-widget-LeftNavigationBar .tree-layer-opcity .close").click(function () {
               $(".jimu-widget-LeftNavigationBar .tree-layer-opcity").stop().hide();
            })
            }
         },
         closeToolBox: function (item) {},
@@ -198,6 +208,7 @@
            })
         },
         changeData: function (val, type) { //重写数据
            var that = this;
            var data = [],
               i = 1,
               inits = (d, childData) => {
@@ -227,6 +238,21 @@
                        a.model = true
                     }
                     if (a.model) {
                        if (that[a.id]) {
                           Cesium.when(that[a.id], function (layer) {
                              that.map.scene.layers.remove(layer[0].name)
                           })
                        }
                     } else {
                        if (that[a.id]) {
                           that.map.imageryLayers.remove(that[a.id]);
                        }
                     }
                     b.push(a);
                     i++;
@@ -299,6 +325,25 @@
                  }
               }
            }
            var keyId = this.getUrlKeyId("serviceName");
            if (keyId && keyId != "") {
               for (var i = 0; i < data.length; i++) {
                  if (data[i].title == keyId) {
                     data[i].checked = true
                  }
                  for (var j = 0; j < data[i].children.length; j++) {
                     if (data[i].children[j].title == keyId) {
                        data[i].children[j].checked = true
                     }
                  }
               }
            }
@@ -438,12 +483,14 @@
                        if (obj.checked == true) {
                           if (obj.data.model) {
                              that.map.scene.globe.depthTestAgainstTerrain = false;
                              var host = that.returnStr(obj.data.src).host;
                              var scene = that.map.scene;
                              var partOfUrl = that.returnStr(obj.data.src).partOfUrl;
                              //添加S3M图层服务
                              that[obj.data.id] = scene.open(host + partOfUrl);
                              //定位到场景
                              Cesium.loadJson(host + partOfUrl + '/scenes.json').then(function (scenes) {
                                 // var sname = scenes[0].name;
                                 // Cesium.loadJson(host + partOfUrl + '/scenes/' + sname + '.json').then(function (jsonData) {
@@ -934,6 +981,12 @@
               }]
            }],
         }],
         getUrlKeyId: function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return decodeURI(r[2]);
            return null;
         },
         destroy: function () {
            //销毁的时候触发
            //todo