liuyg
2021-06-23 70d097137d08bf1a79943fb44b7086b4d45aac75
widgets/spatialAnalysis/Widget.js
@@ -33,50 +33,7 @@
            topic.subscribe("closeOnceUse", lang.hitch(this, this.closeOnceUse));
            // function createTooltip(frameDiv) {//抄录createTooltip函数
            //    var tooltip = function (frameDiv) {
            //       var div = document.createElement('DIV');
            //       div.className = "twipsy right";
            //       var arrow = document.createElement('DIV');
            //       arrow.className = "twipsy-arrow";
            //       div.appendChild(arrow);
            //       var title = document.createElement('DIV');
            //       title.className = "twipsy-inner";
            //       div.appendChild(title);
            //       this._div = div;
            //       this._title = title;
            //       this.message = '';
            //       // add to frame div and display coordinates
            //       frameDiv.appendChild(div);
            //       var that = this;
            //       div.onmousemove = function (evt) {
            //          that.showAt({ x: evt.clientX, y: evt.clientY }, that.message);
            //       };
            //    };
            //    tooltip.prototype.setVisible = function (visible) {
            //       this._div.style.display = visible ? 'block' : 'none';
            //    };
            //    tooltip.prototype.showAt = function (position, message) {
            //       if (position && message) {
            //          this.setVisible(true);
            //          this._title.innerHTML = message;
            //          this._div.style.left = position.x + 10 + "px";
            //          this._div.style.top = (position.y - this._div.clientHeight / 2) + "px";
            //          this.message = message;
            //       }
            //    };
            //    return new tooltip(frameDiv);
            // }
            // window.MYcreateTooltip = createTooltip;//全局使用
            var domHtmls = [//默认
               {
@@ -181,7 +138,7 @@
                  var promise = false;
                  $('.modesssssllll').click(() => {
                     var URL_CONFIG = {
                        SCENE_CBD: 'http://www.supermapol.com/realspace/services/3D-CBDCache20200416/rest/realspace',
                        SCENE_CBD: 'http://www.supermapol.com/realspace/services/3D-niaochao/rest/realspace',
                     }
                     promise = this.map.scene.open(URL_CONFIG.SCENE_CBD);
                  })
@@ -278,6 +235,181 @@
               topic.publish('beginSpatialQuery', 'beginSpatialQuery');
            })
            // var datas = [//layui舍弃
            //    {
            //       title: '默认:天地图影像'
            //       // , child: [
            //       //    {
            //       //       title: 'menu item 3-2-1'
            //       //       , id: 105
            //       //    }
            //       // ]
            //    }
            // ]
            // // that.beginRool(datas);
            // that.datas = datas;
            // // 注册添加工具事件--规定操作图层
            // topic.subscribe("addSelectLayerTool", lang.hitch(this, this.addSelectLayerTool));
            // // 注册删除工具事件--规定操作图层
            // topic.subscribe("removeSelectLayerTool", lang.hitch(this, this.removeSelectLayerTool));
            $('.SelectLayerTool').click(() => {
               $('#SelectLayerToolItem').toggle();
            })
            //参照Layemanagement
            topic.subscribe("appendItemS", lang.hitch(this, this.appendItemS));
            topic.subscribe("removeItemS", lang.hitch(this, this.removeItemS));
            topic.subscribe("appendTiltS", lang.hitch(this, this.appendTiltS));
            topic.subscribe("removeTiltS", lang.hitch(this, this.removeTiltS));
            this.liClick('默认:天地图影像','默认:天地图影像');
         },
         liClick: function (itemid,name) {
            var liList = $(`[itemid='${itemid}s']`);
            // console.log(liList);
            liList.click(() => {
               // console.log(itemid)
               var dom = $('.SelectLayerTool');
               layer.tips('选择了:' + name, dom, { tips: [1, '#5FB878'] });
               dom.empty();
               var str = `${name} <i class="layui-icon layui-icon-down layui-font-12"></i>`
               dom.append(str);
               dom = $('#SelectLayerToolItem').hide();
            })
         },
         fakeName: 'Layermanagement',
         appendItemS: function (item, obj, layer) {
            // console.log('a1')
            var that = this;
            if (item == this.fakeName) {
               // $("#SelectLayerToolItemTitle .no-data").stop().hide();
               var flag = true;
               var liList = $("#SelectLayerToolItemTitle li");
               // console.log(liList)
               // console.log($('#SelectLayerToolItemTitle'))
               for (var i = 0; i < liList.length; i++) {
                  if ($(liList[i]).attr('itemid') && $(liList[i]).attr('itemid') == obj.id) {
                     flag = false
                  }
               }
               if (flag == true) {
                  var liItem = $("<li itemid='" + obj.id + "s' itemtitle='" + obj.title + "'> <div>" +
                     "<span title='" + obj.title + "'>" +
                     obj.title +
                     "</span>" +
                     "</div> </li>");
                  that[obj.id] = layer;
                  $("#SelectLayerToolItemTitle").append(liItem);
               }
               that.liClick(obj.id,obj.title);
            }
         },
         removeItemS: function (item, obj) {
            // console.log('r1')
            if (item == this.fakeName) {
               var liList = $("#SelectLayerToolItemTitle li");
               for (var i = 0; i < liList.length; i++) {
                  if ($(liList[i]).attr('itemid') && $(liList[i]).attr('itemid') == obj.id) {
                     $(liList[i]).remove();
                  }
               }
               if ($("#SelectLayerToolItemTitle li").length == 1 && $("#SelectLayerToolItemTitle li").length == 0) {
                  $("#SelectLayerToolItemTitle .no-data").stop().show();
                  $(".jimu-widget-spatialAnalysis .tree-layer-opcity").stop().hide();
               }
            }
            // this.liClick();
         },
         appendTiltS: function (item, obj, layer) {
            // console.log('a2')
            var that = this;
            if (item == this.fakeName) {
               // $("#SelectLayerToolItemTitle .no-data").stop().hide();
               var flag = true;
               var liList = $("#SelectLayerToolItemTitle li");
               for (var i = 0; i < liList.length; i++) {
                  if ($(liList[i]).attr('itemid') && $(liList[i]).attr('itemid') == obj.id) {
                     flag = false
                  }
               }
               if (flag == true) {
                  var liItem = $("<li itemid='" + obj.id + "s' itemtitle='" + obj.title + "'> <div>" +
                     "<span title='" + obj.title + "'>" +
                     obj.title +
                     "</span>" +
                     "</div> </li>");
                  $("#SelectLayerToolItemTitle").append(liItem);
               }
               that.liClick(obj.id,obj.title);
            }
         },
         removeTiltS: function (item, obj) {
            // console.log('r2')
            if (item == this.fakeName) {
               var liList = $("#SelectLayerToolItemTitle li");
               for (var i = 0; i < liList.length; i++) {
                  if ($(liList[i]).attr('itemid') && $(liList[i]).attr('itemid') == obj.id) {
                     $(liList[i]).remove();
                  }
               }
               if ($("#SelectLayerToolItemTitle li").length == 1 && $("#SelectLayerToolItemTitle li").length == 0) {
                  // $("#SelectLayerToolItemTitle .no-data").stop().show();
                  // $(".jimu-widget-spatialAnalysis .tree-layer-opcity").stop().hide();
               }
            }
         },
         // datas: [],//layui舍弃
         // addSelectLayerTool: function (num, val) {
         //    console.log(num, val);
         //    var that = this
         //       , d = that.datas;
         //    //三维数据处理 添加全部 9 添加时删除 10 删除全部 6 //添加单个 9 添加时删除 10 删除全部 6
         //    // var sanwei = {};
         //    // if (num == 9) {
         //    //    sanwei.title = '三维倾斜数据'
         //    // }
         //    // d.push({
         //    //    title: val.title
         //    // })
         //    // that.beginRool(that.datas);
         // },
         // removeSelectLayerTool: function (num, val) {
         //    console.log(num, val)
         // },
         beginRool: function (data) {
            //选择图层Layui
            layui.use(['dropdown', 'util', 'layer', 'table'], function () {
               var dropdown = layui.dropdown
                  , layer = layui.layer;
               dropdown.render({
                  elem: '.SelectLayerTool'
                  , data: data
                  , click: function (obj) {
                     layer.tips('选择了:' + obj.title, this.elem, { tips: [1, '#5FB878'] });
                     var dom = $('.SelectLayerTool');
                     dom.empty();
                     var str = `${obj.title} <i class="layui-icon layui-icon-down layui-font-12"></i>`
                     dom.append(str);
                  }
               });
            });
         },
         closeToolBox: function (item) {
            if (item != this.name) {