username@email.com
2021-06-03 904fb460b9359fe92e00ce25804d96c8a52bb513
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
(function ($, zou) {
    "use strict";
    //初始化菜单和tab页的属性Id
    var iframeIdList = {};
 
    zou.frameTab = {
        iframeId: '',
        init: function () {
            zou.frameTab.bind();
        },
        bind: function () {
            $(".z-frame-tabs-wrap").mCustomScrollbar({ // 优化滚动条
                axis: "x",
                theme: "minimal-dark"
            });
           
        },
        setCurrentIframeId: function (iframeId) {
            zou.iframeId = iframeId;
        },
        open: function (module, notAllowClosed) {
            var $tabsUl = $('#lr_frame_tabs_ul');
            var $frameMain = $('#lr_frame_main');
 
            if (iframeIdList[module.F_ModuleId] == undefined || iframeIdList[module.F_ModuleId] == null) {
                // 隐藏之前的tab和窗口
                if (zou.frameTab.iframeId != '') {
                    $tabsUl.find('#lr_tab_' + zou.frameTab.iframeId).removeClass('active');
                    $frameMain.find('#lr_iframe_' + zou.frameTab.iframeId).removeClass('active');
                    iframeIdList[zou.frameTab.iframeId] = 0;
                }
                var parentId = zou.frameTab.iframeId;
                zou.frameTab.iframeId = module.F_ModuleId;
                iframeIdList[zou.frameTab.iframeId] = 1;
 
                // 打开一个功能模块tab_iframe页面
                var $tabItem = $('<li class="z-frame-tabItem active" id="lr_tab_' + module.F_ModuleId + '" parent-id="' + parentId + '"  ><span><i class="' + module.F_Icon + '"></i>&nbsp;' + module.F_FullName + '</span></li>');
                if (!notAllowClosed) {
                    $tabItem.append('<span class="reomve" title="关闭窗口"></span>');
                }
                var $iframe = $('<iframe class="z-frame-iframe active" id="lr_iframe_' + module.F_ModuleId + '" frameborder="0" src="' + $.rootUrl + module.F_UrlAddress + '"></iframe>');
                $tabsUl.append($tabItem);
                $frameMain.append($iframe);
 
                $(".z-frame-tabs-wrap").mCustomScrollbar("update");
                $(".z-frame-tabs-wrap").mCustomScrollbar("scrollTo", $tabItem);
 
                //绑定一个点击事件
                $tabItem.on('click', function () {
                    var id = $(this).attr('id').replace('lr_tab_', '');
                    zou.frameTab.focus(id);
                });
                $tabItem.find('.reomve').on('click', function () {
                    var id = $(this).parent().attr('id').replace('lr_tab_', '');
                    zou.frameTab.close(id);
                    return false;
                });
 
                if (!!zou.frameTab.opencallback) {
                    zou.frameTab.opencallback();
                }
                if (!notAllowClosed) {
                    $.ajax({
                        url: top.$.rootUrl + "/Home/VisitModule",
                        data: { moduleName: module.F_FullName, moduleUrl: module.F_UrlAddress },
                        type: "post",
                        dataType: "text"
                    });
                }
            }
            else {
                zou.frameTab.focus(module.F_ModuleId);
            }
        },
        focus: function (moduleId) {
            if (iframeIdList[moduleId] == 0) {
                // 定位焦点tab页
                $('#lr_tab_' + zou.frameTab.iframeId).removeClass('active');
                $('#lr_iframe_' + zou.frameTab.iframeId).removeClass('active');
                iframeIdList[zou.frameTab.iframeId] = 0;
 
                $('#lr_tab_' + moduleId).addClass('active');
                $('#lr_iframe_' + moduleId).addClass('active');
                zou.frameTab.iframeId = moduleId;
                iframeIdList[moduleId] = 1;
 
                $(".z-frame-tabs-wrap").mCustomScrollbar("scrollTo", $('#lr_tab_' + moduleId));
 
                if (!!zou.frameTab.opencallback) {
                    zou.frameTab.opencallback();
                }
            }
        },
        leaveFocus: function () {
            $('#lr_tab_' + zou.frameTab.iframeId).removeClass('active');
            $('#lr_iframe_' + zou.frameTab.iframeId).removeClass('active');
            iframeIdList[zou.frameTab.iframeId] = 0;
            zou.frameTab.iframeId = '';
        },
        close: function (moduleId) {
            delete iframeIdList[moduleId];
 
            var $this = $('#lr_tab_' + moduleId);
            var $prev = $this.prev();// 获取它的上一个节点数据;
            if ($prev.length < 1) {
                $prev = $this.next();
            }
            $this.remove();
            $('#lr_iframe_' + moduleId).remove();
            if (moduleId == zou.frameTab.iframeId && $prev.length > 0) {
                var prevId = $prev.attr('id').replace('lr_tab_', '');
 
                $prev.addClass('active');
                $('#lr_iframe_' + prevId).addClass('active');
                zou.frameTab.iframeId = prevId;
                iframeIdList[prevId] = 1;
 
                $('.z-frame-tabs').css('width', '10000px');
                $(".z-frame-tabs-wrap").mCustomScrollbar("update");
                $('.z-frame-tabs').css('width', '100%');
                $(".z-frame-tabs-wrap").mCustomScrollbar("scrollTo", $prev);
            }
            else {
                if ($prev.length < 1) {
                    zou.frameTab.iframeId = "";
                }
                $('.z-frame-tabs').css('width', '10000px');
                $(".z-frame-tabs-wrap").mCustomScrollbar("update");
                $('.z-frame-tabs').css('width', '100%');
            }
 
            if (!!zou.frameTab.closecallback) {
                zou.frameTab.closecallback();
            }
        }
        // 获取当前窗口
        ,currentIframe: function () {
            var ifameId = 'lr_iframe_' + zou.frameTab.iframeId;
            if (top.frames[ifameId].contentWindow != undefined) {
                return top.frames[ifameId].contentWindow;
            }
            else {
                return top.frames[ifameId];
            }
        }
        ,parentIframe: function () {
            var ifameId = 'lr_iframe_' + top.$('#lr_tab_'+zou.frameTab.iframeId).attr('parent-id');
            if (top.frames[ifameId].contentWindow != undefined) {
                return top.frames[ifameId].contentWindow;
            }
            else {
                return top.frames[ifameId];
            }
        }
 
 
        , opencallback: false
        , closecallback: false
    };
 
    zou.frameTab.init();
})(window.jQuery, top.zou);