Quellcode durchsuchen

弹框组件统一替换为layer;

xueli.xue vor 8 Jahren
Ursprung
Commit
3357529dd0

+ 0 - 1
xxl-job-admin/src/main/webapp/WEB-INF/template/common/common.macro.ftl Datei anzeigen

49
 	<script src="${request.contextPath}/static/plugins/layer/layer.js"></script>
49
 	<script src="${request.contextPath}/static/plugins/layer/layer.js"></script>
50
 
50
 
51
 	<#-- common -->
51
 	<#-- common -->
52
-    <script src="${request.contextPath}/static/js/xxl.alert.1.js"></script>
53
     <script src="${request.contextPath}/static/js/common.1.js"></script>
52
     <script src="${request.contextPath}/static/js/common.1.js"></script>
54
     <script>var base_url = '${request.contextPath}';</script>
53
     <script>var base_url = '${request.contextPath}';</script>
55
 
54
 

+ 16 - 4
xxl-job-admin/src/main/webapp/static/js/common.1.js Datei anzeigen

2
 
2
 
3
 	// logout
3
 	// logout
4
 	$("#logoutBtn").click(function(){
4
 	$("#logoutBtn").click(function(){
5
-		ComConfirm.show("确认注销登录?", function(){
5
+		layer.confirm('确认注销登录?', {icon: 3, title:'系统提示'}, function(index){
6
+			layer.close(index);
7
+
6
 			$.post(base_url + "/logout", function(data, status) {
8
 			$.post(base_url + "/logout", function(data, status) {
7
 				if (data.code == "200") {
9
 				if (data.code == "200") {
8
-					ComAlert.show(1, "注销成功", function(){
9
-						window.location.href = base_url + "/";
10
+					layer.open({
11
+						title: '系统提示',
12
+						content: '注销成功',
13
+						icon: '1',
14
+						end: function(layero, index){
15
+							window.location.href = base_url + "/";
16
+						}
10
 					});
17
 					});
11
 				} else {
18
 				} else {
12
-					ComAlert.show(1, data.msg);
19
+					layer.open({
20
+						title: '系统提示',
21
+						content: (data.msg || "操作失败"),
22
+						icon: '2'
23
+					});
13
 				}
24
 				}
14
 			});
25
 			});
15
 		});
26
 		});
27
+
16
 	});
28
 	});
17
 
29
 
18
 	// slideToTop
30
 	// slideToTop

+ 5 - 1
xxl-job-admin/src/main/webapp/static/js/index.js Datei anzeigen

18
                 lineChartInit(data)
18
                 lineChartInit(data)
19
                 pieChartInit(data);
19
                 pieChartInit(data);
20
             } else {
20
             } else {
21
-                ComAlert.show(2, data.msg || '调度报表数据加载异常' );
21
+                layer.open({
22
+                    title: '系统提示',
23
+                    content: (data.msg || '调度报表数据加载异常'),
24
+                    icon: '2'
25
+                });
22
             }
26
             }
23
         }
27
         }
24
     });
28
     });

+ 23 - 7
xxl-job-admin/src/main/webapp/static/js/jobcode.index.1.js Datei anzeigen

49
 		var glueRemark = $("#glueRemark").val();
49
 		var glueRemark = $("#glueRemark").val();
50
 		
50
 		
51
 		if (!glueRemark) {
51
 		if (!glueRemark) {
52
-			ComAlert.show(2, "请输入备注");
52
+			layer.open({
53
+				title: '系统提示',
54
+				content: '请输入备注',
55
+				icon: '2'
56
+			});
53
 			return;
57
 			return;
54
 		}
58
 		}
55
 		if (glueRemark.length <4 || glueRemark.length > 100) {
59
 		if (glueRemark.length <4 || glueRemark.length > 100) {
56
-			ComAlert.show(2, "备注长度应该在4至100之间");
60
+			layer.open({
61
+				title: '系统提示',
62
+				content: '备注长度应该在4至100之间',
63
+				icon: '2'
64
+			});
57
 			return;
65
 			return;
58
 		}
66
 		}
59
-		
60
 
67
 
61
 		$.ajax({
68
 		$.ajax({
62
 			type : 'POST',
69
 			type : 'POST',
69
 			dataType : "json",
76
 			dataType : "json",
70
 			success : function(data){
77
 			success : function(data){
71
 				if (data.code == 200) {
78
 				if (data.code == 200) {
72
-					ComAlert.show(1, '保存成功', function(){
73
-						//$(window).unbind('beforeunload');
74
-						window.location.reload();
79
+					layer.open({
80
+						title: '系统提示',
81
+						content: '保存成功',
82
+						icon: '1',
83
+						end: function(layero, index){
84
+							//$(window).unbind('beforeunload');
85
+							window.location.reload();
86
+						}
75
 					});
87
 					});
76
 				} else {
88
 				} else {
77
-					ComAlert.show(2, data.msg);
89
+					layer.open({
90
+						title: '系统提示',
91
+						content: (data.msg || "保存失败"),
92
+						icon: '2'
93
+					});
78
 				}
94
 				}
79
 			}
95
 			}
80
 		});
96
 		});

+ 42 - 26
xxl-job-admin/src/main/webapp/static/js/jobgroup.index.1.js Datei anzeigen

4
 	$('.remove').on('click', function(){
4
 	$('.remove').on('click', function(){
5
 		var id = $(this).attr('id');
5
 		var id = $(this).attr('id');
6
 
6
 
7
-		ComConfirm.show("确认删除分组?", function(){
7
+		layer.confirm('确认删除分组?', {icon: 3, title:'系统提示'}, function(index){
8
+			layer.close(index);
9
+
8
 			$.ajax({
10
 			$.ajax({
9
 				type : 'POST',
11
 				type : 'POST',
10
 				url : base_url + '/jobgroup/remove',
12
 				url : base_url + '/jobgroup/remove',
12
 				dataType : "json",
14
 				dataType : "json",
13
 				success : function(data){
15
 				success : function(data){
14
 					if (data.code == 200) {
16
 					if (data.code == 200) {
15
-						ComAlert.show(1, '删除成功');
16
-						window.location.reload();
17
+						layer.open({
18
+							title: '系统提示',
19
+							content: '删除成功',
20
+							icon: '1',
21
+							end: function(layero, index){
22
+								window.location.reload();
23
+							}
24
+						});
17
 					} else {
25
 					} else {
18
-						if (data.msg) {
19
-							ComAlert.show(2, data.msg);
20
-						} else {
21
-							ComAlert.show(2, '删除失败');
22
-						}
26
+						layer.open({
27
+							title: '系统提示',
28
+							content: (data.msg || "删除失败"),
29
+							icon: '2'
30
+						});
23
 					}
31
 					}
24
 				},
32
 				},
25
 			});
33
 			});
26
 		});
34
 		});
35
+
27
 	});
36
 	});
28
 
37
 
29
 	// jquery.validate 自定义校验 “英文字母开头,只含有英文字母、数字和下划线”
38
 	// jquery.validate 自定义校验 “英文字母开头,只含有英文字母、数字和下划线”
86
 			$.post(base_url + "/jobgroup/save",  $("#addModal .form").serialize(), function(data, status) {
95
 			$.post(base_url + "/jobgroup/save",  $("#addModal .form").serialize(), function(data, status) {
87
 				if (data.code == "200") {
96
 				if (data.code == "200") {
88
 					$('#addModal').modal('hide');
97
 					$('#addModal').modal('hide');
89
-					setTimeout(function () {
90
-						ComAlert.show(1, "新增成功", function(){
98
+					layer.open({
99
+						title: '系统提示',
100
+						content: '新增成功',
101
+						icon: '1',
102
+						end: function(layero, index){
91
 							window.location.reload();
103
 							window.location.reload();
92
-						});
93
-					}, 315);
104
+						}
105
+					});
94
 				} else {
106
 				} else {
95
-					if (data.msg) {
96
-						ComAlert.show(2, data.msg);
97
-					} else {
98
-						ComAlert.show(2, "新增失败");
99
-					}
107
+					layer.open({
108
+						title: '系统提示',
109
+						content: (data.msg || "新增失败"),
110
+						icon: '2'
111
+					});
100
 				}
112
 				}
101
 			});
113
 			});
102
 		}
114
 		}
186
 			$.post(base_url + "/jobgroup/update",  $("#updateModal .form").serialize(), function(data, status) {
198
 			$.post(base_url + "/jobgroup/update",  $("#updateModal .form").serialize(), function(data, status) {
187
 				if (data.code == "200") {
199
 				if (data.code == "200") {
188
 					$('#addModal').modal('hide');
200
 					$('#addModal').modal('hide');
189
-					setTimeout(function () {
190
-						ComAlert.show(1, "更新成功", function(){
201
+
202
+					layer.open({
203
+						title: '系统提示',
204
+						content: '更新成功',
205
+						icon: '1',
206
+						end: function(layero, index){
191
 							window.location.reload();
207
 							window.location.reload();
192
-						});
193
-					}, 315);
208
+						}
209
+					});
194
 				} else {
210
 				} else {
195
-					if (data.msg) {
196
-						ComAlert.show(2, data.msg);
197
-					} else {
198
-						ComAlert.show(2, "更新失败");
199
-					}
211
+					layer.open({
212
+						title: '系统提示',
213
+						content: (data.msg || "更新失败"),
214
+						icon: '2'
215
+					});
200
 				}
216
 				}
201
 			});
217
 			});
202
 		}
218
 		}

+ 43 - 25
xxl-job-admin/src/main/webapp/static/js/jobinfo.index.1.js Datei anzeigen

201
 		}
201
 		}
202
 		
202
 		
203
 		var id = $(this).parent('p').attr("id");
203
 		var id = $(this).parent('p').attr("id");
204
-		
205
-		ComConfirm.show("确认" + typeName + "?", function(){
204
+
205
+		layer.confirm('确认' + typeName + '?', {icon: 3, title:'系统提示'}, function(index){
206
+			layer.close(index);
207
+
206
 			$.ajax({
208
 			$.ajax({
207
 				type : 'POST',
209
 				type : 'POST',
208
 				url : url,
210
 				url : url,
212
 				dataType : "json",
214
 				dataType : "json",
213
 				success : function(data){
215
 				success : function(data){
214
 					if (data.code == 200) {
216
 					if (data.code == 200) {
215
-						ComAlert.show(1, typeName + "成功", function(){
216
-							if (needFresh) {
217
-								//window.location.reload();
218
-								jobTable.fnDraw();
217
+
218
+						layer.open({
219
+							title: '系统提示',
220
+							content: typeName + "成功",
221
+							icon: '1',
222
+							end: function(layero, index){
223
+								if (needFresh) {
224
+									//window.location.reload();
225
+									jobTable.fnDraw();
226
+								}
219
 							}
227
 							}
220
 						});
228
 						});
221
 					} else {
229
 					} else {
222
-						ComAlert.show(1, typeName + "失败");
230
+						layer.open({
231
+							title: '系统提示',
232
+							content: (data.msg || typeName + "失败"),
233
+							icon: '2'
234
+						});
223
 					}
235
 					}
224
 				},
236
 				},
225
 			});
237
 			});
278
         	$.post(base_url + "/jobinfo/add",  $("#addModal .form").serialize(), function(data, status) {
290
         	$.post(base_url + "/jobinfo/add",  $("#addModal .form").serialize(), function(data, status) {
279
     			if (data.code == "200") {
291
     			if (data.code == "200") {
280
 					$('#addModal').modal('hide');
292
 					$('#addModal').modal('hide');
281
-					setTimeout(function () {
282
-						ComAlert.show(1, "新增任务成功", function(){
293
+					layer.open({
294
+						title: '系统提示',
295
+						content: '新增任务成功',
296
+						icon: '1',
297
+						end: function(layero, index){
283
 							jobTable.fnDraw();
298
 							jobTable.fnDraw();
284
 							//window.location.reload();
299
 							//window.location.reload();
285
-						});
286
-					}, 315);
300
+						}
301
+					});
287
     			} else {
302
     			} else {
288
-    				if (data.msg) {
289
-    					ComAlert.show(2, data.msg);
290
-    				} else {
291
-    					ComAlert.show(2, "新增失败");
292
-    				}
303
+					layer.open({
304
+						title: '系统提示',
305
+						content: (data.msg || "新增失败"),
306
+						icon: '2'
307
+					});
293
     			}
308
     			}
294
     		});
309
     		});
295
 		}
310
 		}
394
     		$.post(base_url + "/jobinfo/reschedule", $("#updateModal .form").serialize(), function(data, status) {
409
     		$.post(base_url + "/jobinfo/reschedule", $("#updateModal .form").serialize(), function(data, status) {
395
     			if (data.code == "200") {
410
     			if (data.code == "200") {
396
 					$('#updateModal').modal('hide');
411
 					$('#updateModal').modal('hide');
397
-					setTimeout(function () {
398
-						ComAlert.show(1, "更新成功", function(){
412
+					layer.open({
413
+						title: '系统提示',
414
+						content: '更新成功',
415
+						icon: '1',
416
+						end: function(layero, index){
399
 							//window.location.reload();
417
 							//window.location.reload();
400
 							jobTable.fnDraw();
418
 							jobTable.fnDraw();
401
-						});
402
-					}, 315);
419
+						}
420
+					});
403
     			} else {
421
     			} else {
404
-    				if (data.msg) {
405
-    					ComAlert.show(2, data.msg);
406
-					} else {
407
-						ComAlert.show(2, "更新失败");
408
-					}
422
+					layer.open({
423
+						title: '系统提示',
424
+						content: (data.msg || "更新失败"),
425
+						icon: '2'
426
+					});
409
     			}
427
     			}
410
     		});
428
     		});
411
 		}
429
 		}

+ 13 - 4
xxl-job-admin/src/main/webapp/static/js/login.1.js Datei anzeigen

48
         submitHandler : function(form) {
48
         submitHandler : function(form) {
49
 			$.post(base_url + "/login", $("#loginForm").serialize(), function(data, status) {
49
 			$.post(base_url + "/login", $("#loginForm").serialize(), function(data, status) {
50
 				if (data.code == "200") {
50
 				if (data.code == "200") {
51
-					ComAlert.show(1, "登录成功", function(){
52
-						window.location.href = base_url;
53
-					});
51
+                    layer.open({
52
+                        title: '系统提示',
53
+                        content: '登录成功',
54
+                        icon: '1',
55
+                        end: function(layero, index){
56
+                            window.location.href = base_url;
57
+                        }
58
+                    });
54
 				} else {
59
 				} else {
55
-					ComAlert.show(2, data.msg);
60
+                    layer.open({
61
+                        title: '系统提示',
62
+                        content: (data.msg || "登录失败"),
63
+                        icon: '2'
64
+                    });
56
 				}
65
 				}
57
 			});
66
 			});
58
 		}
67
 		}

+ 0 - 98
xxl-job-admin/src/main/webapp/static/js/xxl.alert.1.js Datei anzeigen

1
-/**
2
- * Created by xuxueli on 16/8/12.
3
- *
4
- * dependency, jquery + bootstrap
5
- */
6
-
7
-// 通用提示
8
-var ComAlert = {
9
-    html:function(){
10
-        var html =
11
-            '<div class="modal fade" id="ComAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' +
12
-                '<div class="modal-dialog">' +
13
-                    '<div class="modal-content">' +
14
-                        '<div class="modal-header hidden"><h4 class="modal-title"><strong>提示:</strong></h4></div>' +
15
-                        '<div class="modal-body"><div class="alert alert-success"></div></div>' +
16
-                        '<div class="modal-footer">' +
17
-                            '<div class="text-center" >' +
18
-                                '<button type="button" class="btn btn-default ok" data-dismiss="modal" >确认</button>' +
19
-                            '</div>' +
20
-                        '</div>' +
21
-                    '</div>' +
22
-                '</div>' +
23
-            '</div>';
24
-        return html;
25
-    },
26
-    show:function(type, msg, callback){
27
-        // dom init
28
-        if ($('#ComAlert').length == 0){
29
-            $('body').append(ComAlert.html());
30
-        }
31
-
32
-        // 弹框初始
33
-        if (type == 1) {
34
-            $('#ComAlert .alert').attr('class', 'alert alert-success');
35
-        } else {
36
-            $('#ComAlert .alert').attr('class', 'alert alert-warning');
37
-        }
38
-        $('#ComAlert .alert').html(msg);
39
-        $('#ComAlert').modal('show');
40
-
41
-        $('#ComAlert .ok').click(function(){
42
-            $('#ComAlert').modal('hide');
43
-            if(typeof callback == 'function') {
44
-                callback();
45
-            }
46
-        });
47
-
48
-        // $("#ComAlert").on('hide.bs.modal', function () {	});	// 监听关闭
49
-    }
50
-};
51
-
52
-// 通用确认弹框
53
-var ComConfirm = {
54
-    html:function(){
55
-        var html =
56
-            '<div class="modal fade" id="ComConfirm" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' +
57
-                '<div class="modal-dialog">' +
58
-                    '<div class="modal-content">' +
59
-                        '<div class="modal-body"><div class="alert alert-success"></div></div>' +
60
-                            '<div class="modal-footer">' +
61
-                            '<div class="text-center" >' +
62
-                                '<button type="button" class="btn btn-primary ok" data-dismiss="modal" >确认</button>' +
63
-                                '<button type="button" class="btn btn-default cancel" data-dismiss="modal" >取消</button>' +
64
-                            '</div>' +
65
-                        '</div>' +
66
-                    '</div>' +
67
-                '</div>' +
68
-            '</div>';
69
-        return html;
70
-    },
71
-    show:function(msg, callback){
72
-        // dom init
73
-        if ($('#ComConfirm').length == 0){
74
-            $("body").append(ComConfirm.html());
75
-        }
76
-
77
-        // 弹框初始
78
-        $('#ComConfirm .alert').attr('class', 'alert alert-warning');
79
-        $('#ComConfirm .alert').html(msg);
80
-        $('#ComConfirm').modal('show');
81
-
82
-        $('#ComConfirm .ok').unbind("click");	// 解绑陈旧事件
83
-        $('#ComConfirm .ok').click(function(){
84
-            $('#ComConfirm').modal('hide');
85
-            if(typeof callback == 'function') {
86
-                setTimeout(function(){
87
-                    callback();
88
-                    return;
89
-                }, 315);
90
-            }
91
-        });
92
-
93
-        $('#ComConfirm .cancel').click(function(){
94
-            $('#ComConfirm').modal('hide');
95
-            return;
96
-        });
97
-    }
98
-};