chengkun
2025-05-12 b6bc92ec11e1e280185ce7682d17589cb45c20f3
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/**
 * 封装layer.js的常用方法
 */
layui.use(['layer'], function () {
    var layer = layui.layer,
        $ = layui.$;
    layer.oriMsg = layer.msg;
    layer.msg = function (msg, timeSecond, icon, callback) {
        timeSecond = (typeof timeSecond !== 'undefined') ? timeSecond : 1.5;
        icon = (typeof icon !== 'undefined') ? icon : 6;
        callback = (typeof callback !== 'undefined') ? callback : function () { };
 
        //兼容原本layui.use(['layer'])的layer.msg()用法
        if (typeof (timeSecond) == 'object') {
            if (typeof (icon) == 'function') {
                return layer.oriMsg(msg, timeSecond, icon);
            } else {
                return layer.oriMsg(msg, timeSecond);
            }
        }
 
        var tm = timeSecond * 1000;
        if (icon == 8) {
            icon = 2;
        }
        if (icon == 9) {
            icon = 1;
        }
        console.log(icon);
        return layer.msg(msg,
            {
                time: tm,
                icon: icon,
                shade: [0.8, '#393D49'] //加过滤层黑色透明背景
            },
            function () {
                callback();
            }
        );
    };//end layer.msg
 
    //加载动画加遮罩层
    layer.oriLoad = layer.load;
    layer.load = function (icon, options) {
        icon = (typeof icon !== 'undefined') ? icon : 0;
        options = (typeof options == 'object') ? options : {};
 
        options.shade = [0.8, '#393D49'];
        return layer.oriLoad(icon, options);
    };
 
    //alert对话框
    layer.oriAlert = layer.alert;
    layer.alert = function (msg, icon, title, callback) {
        if (typeof icon == 'object') {
            //layui的layer模块原本调用方式
            if (typeof title == 'function') {
                return layer.oriAlert(msg, icon, title);
            } else {
                return layer.oriAlert(msg, icon);
            }
        } else if (typeof icon != 'undefined' && typeof title == 'undefined') {
            //兼容layer.min.js的调用方式
            return layer.msg(msg, 1.5, icon);
        } else if (typeof callback == 'function') {
            return layer.oriAlert(msg, { title: title }, callback);
        } else {
            return layer.oriAlert(msg);
        }
    }
 
    /**
     * 【页面层(和父窗口属于同一个html页面)】 封装layer.open({type:1})
     *
     * content : 展示的内容 : html代码(字符串),dom节点(例如:$("#id") )
     * area : ['300px', '200px']
     * offset :  ['100px', '50px'] , 'auto', 'r' 等
     * options : {} 其他layui文档中的参数
    */
    // layer.page = function (content, title, area, offset = 'auto', options = {}){
    layer.page = function (content, title, area, offset, options) {
        offset = (typeof offset !== 'undefined') ? offset : 'auto';
        options = (typeof options !== 'undefined') ? options : {};
 
        options.type = 1;
        options.content = content;
        options.area = area;
        options.offset = offset;
        options.title = title;
 
        return layer.open(options);
    };
 
    //封装layer.open({type:2})【iframe页面层】
    // layer.iframe = function (url, title, area, offset = 'auto', options = {}){
    layer.iframe = function (url, title, area, offset, options) {//浏览器兼容写法
        offset = (typeof offset !== 'undefined') ? offset : 'auto';
        options = (typeof options !== 'undefined') ? options : {};
 
        options.type = 2;
        options.content = url;
        options.area = area;
        options.offset = offset;
        options.title = title;
 
        return layer.open(options);
    };
});//end layui.use()
 
function monthclick(laydate, elem, hasdone) {
    var timestamp = new Date();
    nowyear = timestamp.getFullYear(),
        nowmonth = timestamp.getMonth() + 1;
    if (nowmonth < 10) {
        nowmonth = "0" + nowmonth;
    }
    nowday = timestamp.getDate();
    var max = '';
    if (elem == '#eduedate' || elem.indexOf("#edu_edate") >= 0) {
        max = '2099-12-30';
    } else {
        max = nowyear + '-' + nowmonth + '-' + nowday;
    }
    laydateobj =
        laydate.render({
            elem: elem,
            type: 'month',
            trigger: 'click',
            max: max,
            change: function (value, date, endDate) {
                var nowtimestr = nowyear + '-' + nowmonth;
                var oldVal = $(elem).val();
                if (nowtimestr >= value) {
                    $(elem).val(value);
                } else {
                    $(elem).val(nowtimestr);
                }
                if (oldVal.substr(0, 4) == value.substr(0, 4) || nowyear == value.substr(0, 4)) {
                    $('.laydate-btns-confirm').click();
                }
            },
            done: function (value, date, endDate) {
                if (hasdone == 1) {
                    var id = elem.replace('#', '');
                    //checkonblur(id);
                }
            }
        });
}
if (typeof ($) !== 'undefined') {
    $.layer = function (obj) {
        var retval;
        layui.use(['layer'], function () {
            var layer = layui.layer,
                $ = layui.$;
 
            var offset = 'auto';
            if (obj.offset) {
                offset = obj.offset;
            }
 
            var content = '';
            if (obj.page) {
                if (obj.page.dom) {
                    content = $(obj.page.dom);
                } else if (obj.page.html) {
                    content = obj.page.html;
                }
            } else if (obj.iframe) {
                if (obj.iframe.src) {
                    content = obj.iframe.src;
                }
            }
 
            var id = obj.id ? obj.id : '';
 
            var close = obj.close ? obj.close : function () { };
            var laydata = {
                content: content,
                offset: offset,
                id: id,
                end: close
            };
            if (obj.type) {
                laydata.type = obj.type;
            }
            if (obj.title) {
                laydata.title = obj.title;
            }
            if (obj.area) {
                laydata.area = obj.area;
            }
            if (obj.zIndex) {
                laydata.zIndex = obj.zIndex;
            }
            if (obj.success) {
                laydata.success = obj.success;
            }
            retval = layer.open(laydata);
        });//
 
        return retval;
    };//end $.layer  
}