shuishen
2021-06-19 7e48b9940384d66b7f6e57449cb06c9dc854cf76
保护区加到图层管理
1 files modified
306 ■■■■■ changed files
widgets/instructions/Widget.js 306 ●●●●● patch | view | raw | blame | history
widgets/instructions/Widget.js
@@ -3,161 +3,209 @@
// 模块描述:显示坐标
///////////////////////////////////////////////////////////////////////////
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'
    ],
    function (declare,
        lang,
        array,
        html,
        topic,
        BaseWidget,
        aspect,
        string,
        utils
    ) {
        return declare([BaseWidget], {
            baseClass: 'jimu-widget-instructions',
            name: 'instructions',
            layers: {},
            startup: function () {
                // 暴露在外的接口
                var that = this,
                    url = 'http://171.34.76.171:8880/pyh-station/metaWetlandProtect/queryNameAndIdAssembleMap',
                    token = "Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJlY2hpc2FuIiwic3ViIjoiYWRtaW4iLCJpYXQiOjE2MjMzOTIwNTcsImV4cCI6MTYyNTk4NDA1N30.wyhtQWDfyBM4Wvu9x_GpzWErqDkZ3J-PWEjyzoaHT9w6mMBenso5q0ZdnFueCZaCOjsHM5AMwLawATT0Zqc4aQ";
                axios.get(url, {
                    headers: {
                        "token": token
                    }
                }).then((res) => {
                    if (res.data.code == 200) {
                        var data = res.data.data;
                        that.beginLayuiDropdown(data)
        '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,
        html,
        topic,
        BaseWidget,
        aspect,
        string,
        utils
    ) {
        return declare([BaseWidget], {
            baseClass: 'jimu-widget-instructions',
            name: 'instructions',
            layers: {},
            startup: function () {
                // 暴露在外的接口
                var that = this,
                    url = 'http://171.34.76.171:8880/pyh-station/metaWetlandProtect/queryNameAndIdAssembleMap',
                    token = "Bearer eyJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJlY2hpc2FuIiwic3ViIjoiYWRtaW4iLCJpYXQiOjE2MjMzOTIwNTcsImV4cCI6MTYyNTk4NDA1N30.wyhtQWDfyBM4Wvu9x_GpzWErqDkZ3J-PWEjyzoaHT9w6mMBenso5q0ZdnFueCZaCOjsHM5AMwLawATT0Zqc4aQ";
                axios.get(url, {
                    headers: {
                        "token": token
                    }
                }).then((res) => {
                    if (res.data.code == 200) {
                        var data = res.data.data;
                        that.beginLayuiDropdown(data)
                    }
                })
                    }
                })
            },
            beginLayuiDropdown: function (data) {
                var that = this;
                var d = [];
                for (var k in data) {
                    var obj = {
                        title: data[k].NAME,
                        id: data[k].id,
                    }
                    if (data[k].seviceUrl) {
                        obj.src = data[k].seviceUrl
                    }
                    d.push(obj)
            },
            beginLayuiDropdown: function (data) {
                var that = this;
                var d = [];
                for (var k in data) {
                    var obj = {
                        title: data[k].NAME,
                        id: data[k].id,
                    }
                    if (data[k].seviceUrl) {
                        obj.src = data[k].seviceUrl
                    }
                    d.push(obj)
                }
                layui.use(['dropdown', 'util', 'layer', 'table'], function () {
                    var dropdown = layui.dropdown,
                        util = layui.util,
                        layer = layui.layer,
                        table = layui.table,
                        $ = layui.jquery;
                }
                layui.use(['dropdown', 'util', 'layer', 'table'], function () {
                    var dropdown = layui.dropdown,
                        util = layui.util,
                        layer = layui.layer,
                        table = layui.table,
                        $ = layui.jquery;
                    dropdown.render({
                        elem: '.demo1',
                        data: d,
                        trigger: 'hover',
                        className: 'site-dropdown-demo',
                        click: function (obj) {
                            //点击事件
                            // layer.tips('点击了:' + obj.title, this.elem, { tips: [1, '#5FB878'] })
                            var str = obj.title;
                    dropdown.render({
                        elem: '.demo1',
                        data: d,
                        trigger: 'hover',
                        className: 'site-dropdown-demo',
                        click: function (obj) {
                            //点击事件
                            // layer.tips('点击了:' + obj.title, this.elem, { tips: [1, '#5FB878'] })
                            var str = obj.title;
                            $('.jimu-widget-instructions').find('.instructions-title').empty().append(str);
                            $('.jimu-widget-instructions').find('.instructions-title').empty().append(str);
                            for (var i = 0; i < d.length; i++) {
                                if (that['layer' + d[i].id]) {
                                    that.map.imageryLayers.remove(that['layer' + d[i].id]);
                                }
                            }
                            for (var i = 0; i < d.length; i++) {
                                var itemObj = {};
                            if (obj.src) {
                                $.ajax({
                                    url: obj.src + '/maps.json',
                                    type: 'get',
                                    dataType: 'JSON',
                                    success: function (result) {
                                itemObj.src = d[i].src;
                                        that['layer' + obj.id] = that.map.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({
                                            url: result[0].path,
                                        }));
                                itemObj.title = d[i].title;
                                        that['layer' + obj.id].alpha = 1;
                                itemObj.id = 'layer' + d[i].id;
                                        that['layer' + obj.id].getViewableRectangle().then(function (rectangle) {
                                            return that.map.camera.flyTo({
                                                destination: rectangle
                                            });
                                        });
                                    }
                                })
                            } else {
                                if (that[itemObj.id]) {
                                layui.use(function () { //亦可加载特定模块:layui.use(['layer', 'laydate', function(){
                                    //得到各种内置组件
                                    var layer = layui.layer //弹层
                                    // layer.msg('请先填写关键字', { icon: 1, time: 1000, shift: 6 });
                                    layer.tips('暂无该服务', '.jimu-widget-instructions', {
                                        tips: [2, '#FF5722']
                                    });
                                })
                            }
                                    itemObj.alpha = that[itemObj.id].alpha;
                                    that[itemObj.id].show = false;
                                    topic.publish('removeItem', 'Layermanagement', itemObj);
                                }
                            }
                            if (obj.src) {
                                var itemObj = {};
                                itemObj.src = obj.src;
                                itemObj.title = obj.title;
                                itemObj.id = 'layer' + obj.id;
                                if (that[itemObj.id]) {
                                    itemObj.alpha = that[itemObj.id].alpha;
                                    that[itemObj.id].show = true;
                                    that[itemObj.id].getViewableRectangle().then(function (rectangle) {
                                        return that.map.camera.flyTo({
                                            destination: rectangle
                                        });
                                    });
                                    topic.publish('appendItem', 'Layermanagement', itemObj, that[itemObj.id]);
                                } else {
                                    itemObj.alpha = 1;
                                    $.ajax({
                                        url: itemObj.src + '/maps.json',
                                        type: 'get',
                                        dataType: 'JSON',
                                        success: function (result) {
                                            that[itemObj.id] = that.map.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({
                                                url: result[0].path,
                                            }));
                                            that[itemObj.id].alpha = 1;
                                            topic.publish('appendItem', 'Layermanagement', itemObj, that[itemObj.id]);
                                            that[itemObj.id].getViewableRectangle().then(function (rectangle) {
                                                return that.map.camera.flyTo({
                                                    destination: rectangle
                                                });
                                            });
                                        }
                                    })
                                }
                            } else {
                                layui.use(function () { //亦可加载特定模块:layui.use(['layer', 'laydate', function(){
                                    //得到各种内置组件
                                    var layer = layui.layer //弹层
                                    // layer.msg('请先填写关键字', { icon: 1, time: 1000, shift: 6 });
                                    layer.tips('暂无该服务', '.jimu-widget-instructions', {
                                        tips: [2, '#FF5722']
                                    });
                                })
                            }
                        }
                    });
                });
            },
            closeToolBox: function (item) {},
                        }
                    });
                });
            },
            closeToolBox: function (item) {},
            onOpen: function () {
                //面板打开的时候触发 (when open this panel trigger)
            },
            onOpen: function () {
                //面板打开的时候触发 (when open this panel trigger)
            },
            onClose: function () {
                //面板关闭的时候触发 (when this panel is closed trigger)
            },
            onClose: function () {
                //面板关闭的时候触发 (when this panel is closed trigger)
            },
            onMinimize: function () {
                this.resize();
            },
            onMinimize: function () {
                this.resize();
            },
            onMaximize: function () {
                this.resize();
            },
            onMaximize: function () {
                this.resize();
            },
            resize: function () {
            resize: function () {
            },
            begin: function () {},
            },
            begin: function () {},
            destroy: function () {
                //销毁的时候触发
                //todo
                //do something before this func
                this.inherited(arguments);
            }
            destroy: function () {
                //销毁的时候触发
                //todo
                //do something before this func
                this.inherited(arguments);
            }
        });
    });
        });
    });