From 2b8e498c0550d8e8bf17a9dafddb136cc7bd1e1a Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Thu, 01 Jul 2021 10:28:35 +0800
Subject: [PATCH] 导航样式

---
 widgets/LeftNavigationBar/Widget.js |  199 +++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 157 insertions(+), 42 deletions(-)

diff --git a/widgets/LeftNavigationBar/Widget.js b/widgets/LeftNavigationBar/Widget.js
index 592e483..3f27068 100644
--- a/widgets/LeftNavigationBar/Widget.js
+++ b/widgets/LeftNavigationBar/Widget.js
@@ -3,16 +3,16 @@
 // 模块描述:显示坐标
 ///////////////////////////////////////////////////////////////////////////
 define([
-        'dojo/_base/declare',
-        'dojo/_base/lang',
-        'dojo/_base/array',
-        'dojo/_base/html',
-        'dojo/topic',
-        'jimu/BaseWidget',
-        'jimu/utils',
-        'jimu/css!libs/zTree_v3/css/zTreeStyle/zTreeStyle.css',
-        'libs/zTree_v3/js/jquery.ztree.all'
-    ],
+    'dojo/_base/declare',
+    'dojo/_base/lang',
+    'dojo/_base/array',
+    'dojo/_base/html',
+    'dojo/topic',
+    'jimu/BaseWidget',
+    'jimu/utils',
+    'jimu/css!libs/zTree_v3/css/zTreeStyle/zTreeStyle.css',
+    'libs/zTree_v3/js/jquery.ztree.all'
+],
     function (declare,
         lang,
         array,
@@ -34,24 +34,103 @@
                 var that = this;
                 this.getData();
 
+                // $('.left-navigation-bar-but').click(() => {
+                //     this.changeImg = !this.changeImg;
+                //     if (this.changeImg) {
+                //         $('.l-n-b-b-img').attr("src", "./images/addL/xzuo.png"); //打开
+                //         $('.jimu-widget-LeftNavigationBar').css({
+                //             'left': '0px'
+                //         });
+                //         $('.jimu-widget-instructions').css({
+                //             'left': '260px'
+                //         });
+                //     } else {
+                //         $('.l-n-b-b-img').attr("src", "./images/addL/xyou.png"); //关闭
+                //         $('.jimu-widget-LeftNavigationBar').css({
+                //             'left': '-250px'
+                //         });
+                //         $('.jimu-widget-instructions').css({
+                //             'left': '10px'
+                //         });
+                //     }
+                // })
+                var time = null;
                 $('.left-navigation-bar-but').click(() => {
                     this.changeImg = !this.changeImg;
                     if (this.changeImg) {
-                        $('.l-n-b-b-img').attr("src", "./images/addL/xzuo.png"); //打开
-                        $('.jimu-widget-LeftNavigationBar').css({
-                            'left': '0px'
+                        if (time != null) {
+                            clearTimeout(time);
+                            time = null;
+                        }
+                        // $('.l-n-b-b-img').attr("src", "./images/addL/xzuo.png"); //打开
+                        $('.left-navigation-bar-main').css({
+                            'display': 'block',
+                            'width': '300px',
+                            'padding': '10px',
+                            'height': 'auto',
                         });
-                        $('.jimu-widget-instructions').css({
-                            'left': '260px'
-                        });
+                        $('.l-n-b-m-search').css({
+                            'display': 'flex',
+                        })
+                        $('#left-tree-list').css({
+                            'display': 'block',
+                        })
+
                     } else {
-                        $('.l-n-b-b-img').attr("src", "./images/addL/xyou.png"); //关闭
-                        $('.jimu-widget-LeftNavigationBar').css({
-                            'left': '-250px'
+                        // $('.l-n-b-b-img').attr("src", "./images/addL/xyou.png"); //关闭
+                        $('.l-n-b-m-search').css({
+                            'display': 'none',
+                        })
+                        $('#left-tree-list').css({
+                            'display': 'none',
+                        })
+                        $('.left-navigation-bar-main').css({
+                            'width': '0px',
+                            'padding': '0px',
+                            'height': '0px',
                         });
-                        $('.jimu-widget-instructions').css({
-                            'left': '10px'
+                        if (time != null) {
+                            clearTimeout(time);
+                            time = null;
+                        }
+                        time = setTimeout(() => {
+                            $('.left-navigation-bar-main').css({
+                                'display': 'none'
+                            });
+                            clearTimeout(time);
+                            time = null;
+                        }, 500);
+                    }
+                })
+                $('#l-n-b-m-search-closeOUR').click(() => {
+                    this.changeImg = !this.changeImg;
+                    if (!this.changeImg) {
+                        if (time != null) {
+                            clearTimeout(time);
+                            time = null;
+                        }
+                        $('.l-n-b-m-search').css({
+                            'display': 'none',
+                        })
+                        $('#left-tree-list').css({
+                            'display': 'none',
+                        })
+                        $('.left-navigation-bar-main').css({
+                            'width': '0px',
+                            'padding': '0px',
+                            'height': '0px',
                         });
+                        if (time != null) {
+                            clearTimeout(time);
+                            time = null;
+                        }
+                        time = setTimeout(() => {
+                            $('.left-navigation-bar-main').css({
+                                'display': 'none'
+                            });
+                            clearTimeout(time);
+                            time = null;
+                        }, 500);
                     }
                 })
 
@@ -102,13 +181,13 @@
                     var val = $('#left-navigation-bar-main-input').val();
                     if (val != '') {
                         var clearOur = () => {
-                                let dom = $(`[data-id]`);
-                                dom.removeClass('layui-tree-spread');
-                                let domDiv = dom.find('.layui-tree-pack');
-                                domDiv.css({
-                                    'display': 'none'
-                                })
-                            },
+                            let dom = $(`[data-id]`);
+                            dom.removeClass('layui-tree-spread');
+                            let domDiv = dom.find('.layui-tree-pack');
+                            domDiv.css({
+                                'display': 'none'
+                            })
+                        },
                             a, useit = (d) => {
                                 for (var k in d) {
                                     if (d[k].who == 'father') {
@@ -159,7 +238,7 @@
                 }
             },
 
-            closeToolBox: function (item) {},
+            closeToolBox: function (item) { },
 
             onOpen: function () {
                 //面板打开的时候触发 (when open this panel trigger)
@@ -331,7 +410,7 @@
             },
             begin: function (data) {
                 var that = this;
-
+                window.mySanweiShujuOpens = {};//全局scene.open资源
                 var a = null;
 
                 layui.use(function () {
@@ -343,7 +422,7 @@
 
                     tree.render({
                         elem: '#left-tree-list' //默认是点击节点可进行收缩
-                            ,
+                        ,
                         data: data,
                         id: 'demoId1',
                         showCheckbox: true, //是否显示复选框
@@ -376,18 +455,30 @@
                                         that.map.scene.globe.depthTestAgainstTerrain = false;
                                         obj.data.children.forEach(item => {
                                             Cesium.when(that[item.id], function (layer) {
+                                                topic.publish('removeTilt', 'Layermanagement', item);
+                                                topic.publish('removeTiltS', 'spatialAnalysis', item);
+                                                topic.publish('removeLayersLegends', 'legends', item);
                                                 that.map.scene.layers.remove(layer[0].name)
                                             })
                                             var host = that.returnStr(item.src).host;
                                             var scene = that.map.scene;
                                             var partOfUrl = that.returnStr(item.src).partOfUrl;
                                             //添加S3M图层服务
-                                            that[item.id] = scene.open(host + partOfUrl);
+                                            that[item.id] = scene.open(host + partOfUrl, undefined, {
+                                                autoSetView: false //不自动定位
+                                            });
+
+                                            window.mySanweiShujuOpens[item.id] = that[item.id];
+                                            // console.log(222)
+                                            topic.publish('appendTilt', 'Layermanagement', item);
+                                            topic.publish('appendTiltS', 'spatialAnalysis', item);
+                                            topic.publish('addLayersLegends', 'legends', item);
                                             //定位到场景
                                             Cesium.loadJson(host + partOfUrl + '/scenes.json').then(function (scenes) {
                                                 var sname = scenes[0].name;
                                                 Cesium.loadJson(host + partOfUrl + '/scenes/' + sname + '.json').then(function (jsonData) {
                                                     Cesium.when(that[item.id], function (layer) {
+
                                                         //设置相机位置、视角,便于观察场景
                                                         scene.camera.setView({
                                                             destination: new Cesium.Cartesian3.fromDegrees(Number(item.lon), Number(item.lat), Number(item.height)),
@@ -408,6 +499,8 @@
                                                     });
                                                 });
                                             });
+
+
                                         });
                                     } else {
 
@@ -420,7 +513,9 @@
                                                         destination: rectangle
                                                     });
                                                 });
+                                                // console.log(444)
                                                 topic.publish('appendItem', 'Layermanagement', item, that[item.id]);
+                                                topic.publish('appendItemS', 'spatialAnalysis', item, that[item.id]);
                                                 topic.publish('addLayersLegends', 'legends', item);
                                             } else {
                                                 $.ajax({
@@ -429,11 +524,12 @@
                                                     dataType: 'JSON',
                                                     success: function (res) {
 
-
+                                                        // console.log(111)
                                                         that[item.id] = that.map.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({
                                                             url: res[0].path,
                                                         }));
                                                         topic.publish('appendItem', 'Layermanagement', item, that[item.id]);
+                                                        topic.publish('appendItemS', 'spatialAnalysis', item, that[item.id]);
                                                         topic.publish('addLayersLegends', 'legends', item);
                                                         that[item.id].alpha = item.alpha;
                                                         that[item.id].getViewableRectangle().then(function (rectangle) {
@@ -450,14 +546,14 @@
                                     }
 
 
-
-
-
                                 } else {
 
                                     if (obj.data.model) {
                                         obj.data.children.forEach(item => {
                                             Cesium.when(that[item.id], function (layer) {
+                                                topic.publish('removeTilt', 'Layermanagement', item);
+                                                topic.publish('removeTiltS', 'spatialAnalysis', item);
+                                                topic.publish('removeLayersLegends', 'legends', item);
                                                 that.map.scene.layers.remove(layer[0].name)
                                             })
                                         });
@@ -465,6 +561,7 @@
                                         obj.data.children.forEach(item => {
                                             if (that[item.id]) {
                                                 topic.publish('removeItem', 'Layermanagement', item);
+                                                topic.publish('removeItemS', 'spatialAnalysis', item);
                                                 topic.publish('removeLayersLegends', 'legends', item);
                                                 that[item.id].show = false;
                                             }
@@ -482,6 +579,9 @@
 
                                     if (obj.data.model) {
                                         Cesium.when(that[obj.data.id], function (layer) {
+                                            topic.publish('removeTilt', 'Layermanagement', obj.data);
+                                            topic.publish('removeTiltS', 'spatialAnalysis', obj.data);
+                                            topic.publish('removeLayersLegends', 'legends', obj.data);
                                             that.map.scene.layers.remove(layer[0].name)
                                         })
 
@@ -491,9 +591,15 @@
                                         var partOfUrl = that.returnStr(obj.data.src).partOfUrl;
                                         //添加S3M图层服务
 
-                                        that[obj.data.id] = scene.open(host + partOfUrl);
-                                        //定位到场景
+                                        that[obj.data.id] = scene.open(host + partOfUrl, undefined, {
+                                            autoSetView: false //不自动定位
+                                        });
+                                        window.mySanweiShujuOpens[obj.data.id] = that[obj.data.id];
 
+                                        topic.publish('appendTilt', 'Layermanagement', obj.data);
+                                        topic.publish('appendTiltS', 'spatialAnalysis', obj.data);
+                                        topic.publish('addLayersLegends', 'legends', obj.data);
+                                        //定位到场景
                                         Cesium.loadJson(host + partOfUrl + '/scenes.json').then(function (scenes) {
                                             var sname = scenes[0].name;
                                             Cesium.loadJson(host + partOfUrl + '/scenes/' + sname + '.json').then(function (jsonData) {
@@ -528,7 +634,9 @@
                                                     destination: rectangle
                                                 });
                                             });
+                                            // console.log(555)
                                             topic.publish('appendItem', 'Layermanagement', obj.data, that[obj.data.id]);
+                                            topic.publish('appendItemS', 'spatialAnalysis', obj.data, that[obj.data.id]);
                                             topic.publish('addLayersLegends', 'legends', obj.data);
                                         } else {
                                             $.ajax({
@@ -543,6 +651,7 @@
                                                     }));
 
                                                     topic.publish('appendItem', 'Layermanagement', obj.data, that[obj.data.id]);
+                                                    topic.publish('appendItemS', 'spatialAnalysis', obj.data, that[obj.data.id]);
                                                     topic.publish('addLayersLegends', 'legends', obj.data);
 
                                                     that[obj.data.id].alpha = obj.data.alpha
@@ -565,6 +674,10 @@
 
                                     if (obj.data.model) {
                                         Cesium.when(that[obj.data.id], function (layer) {
+
+                                            topic.publish('removeTilt', 'Layermanagement', obj.data);
+                                            topic.publish('removeTiltS', 'spatialAnalysis', obj.data);
+                                            topic.publish('removeLayersLegends', 'legends', obj.data);
                                             that.map.scene.layers.remove(layer[0].name)
                                         })
 
@@ -572,6 +685,7 @@
 
                                         if (that[obj.data.id]) {
                                             topic.publish('removeItem', 'Layermanagement', obj.data);
+                                            topic.publish('removeItemS', 'spatialAnalysis', obj.data);
                                             topic.publish('removeLayersLegends', 'legends', obj.data);
                                             that[obj.data.id].show = false;
                                         }
@@ -584,6 +698,7 @@
 
 
                             }
+
 
                             for (var i = 0; i < that.dataAllArray.length; i++) {
 
@@ -671,15 +786,15 @@
                 title: '采集站点',
                 id: 1,
                 field: '1'
-                    // , checked: true
-                    ,
+                // , checked: true
+                ,
                 spread: true,
                 children: [{
                     title: '南矶山保护区',
                     id: 11,
                     field: '1-1'
-                        // , checked: true
-                        ,
+                    // , checked: true
+                    ,
                     spread: true,
                     children: [{
                         title: '北深渊',

--
Gitblit v1.9.3