瀏覽代碼

弹框组件统一替换为layer;

xueli.xue 8 年之前
父節點
當前提交
3357529dd0

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

@@ -49,7 +49,6 @@
 	<script src="${request.contextPath}/static/plugins/layer/layer.js"></script>
 
 	<#-- common -->
-    <script src="${request.contextPath}/static/js/xxl.alert.1.js"></script>
     <script src="${request.contextPath}/static/js/common.1.js"></script>
     <script>var base_url = '${request.contextPath}';</script>
 

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

@@ -2,17 +2,29 @@ $(function(){
 
 	// logout
 	$("#logoutBtn").click(function(){
-		ComConfirm.show("确认注销登录?", function(){
+		layer.confirm('确认注销登录?', {icon: 3, title:'系统提示'}, function(index){
+			layer.close(index);
+
 			$.post(base_url + "/logout", function(data, status) {
 				if (data.code == "200") {
-					ComAlert.show(1, "注销成功", function(){
-						window.location.href = base_url + "/";
+					layer.open({
+						title: '系统提示',
+						content: '注销成功',
+						icon: '1',
+						end: function(layero, index){
+							window.location.href = base_url + "/";
+						}
 					});
 				} else {
-					ComAlert.show(1, data.msg);
+					layer.open({
+						title: '系统提示',
+						content: (data.msg || "操作失败"),
+						icon: '2'
+					});
 				}
 			});
 		});
+
 	});
 
 	// slideToTop

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

@@ -18,7 +18,11 @@ $(function () {
                 lineChartInit(data)
                 pieChartInit(data);
             } else {
-                ComAlert.show(2, data.msg || '调度报表数据加载异常' );
+                layer.open({
+                    title: '系统提示',
+                    content: (data.msg || '调度报表数据加载异常'),
+                    icon: '2'
+                });
             }
         }
     });

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

@@ -49,14 +49,21 @@ $(function() {
 		var glueRemark = $("#glueRemark").val();
 		
 		if (!glueRemark) {
-			ComAlert.show(2, "请输入备注");
+			layer.open({
+				title: '系统提示',
+				content: '请输入备注',
+				icon: '2'
+			});
 			return;
 		}
 		if (glueRemark.length <4 || glueRemark.length > 100) {
-			ComAlert.show(2, "备注长度应该在4至100之间");
+			layer.open({
+				title: '系统提示',
+				content: '备注长度应该在4至100之间',
+				icon: '2'
+			});
 			return;
 		}
-		
 
 		$.ajax({
 			type : 'POST',
@@ -69,12 +76,21 @@ $(function() {
 			dataType : "json",
 			success : function(data){
 				if (data.code == 200) {
-					ComAlert.show(1, '保存成功', function(){
-						//$(window).unbind('beforeunload');
-						window.location.reload();
+					layer.open({
+						title: '系统提示',
+						content: '保存成功',
+						icon: '1',
+						end: function(layero, index){
+							//$(window).unbind('beforeunload');
+							window.location.reload();
+						}
 					});
 				} else {
-					ComAlert.show(2, data.msg);
+					layer.open({
+						title: '系统提示',
+						content: (data.msg || "保存失败"),
+						icon: '2'
+					});
 				}
 			}
 		});

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

@@ -4,7 +4,9 @@ $(function() {
 	$('.remove').on('click', function(){
 		var id = $(this).attr('id');
 
-		ComConfirm.show("确认删除分组?", function(){
+		layer.confirm('确认删除分组?', {icon: 3, title:'系统提示'}, function(index){
+			layer.close(index);
+
 			$.ajax({
 				type : 'POST',
 				url : base_url + '/jobgroup/remove',
@@ -12,18 +14,25 @@ $(function() {
 				dataType : "json",
 				success : function(data){
 					if (data.code == 200) {
-						ComAlert.show(1, '删除成功');
-						window.location.reload();
+						layer.open({
+							title: '系统提示',
+							content: '删除成功',
+							icon: '1',
+							end: function(layero, index){
+								window.location.reload();
+							}
+						});
 					} else {
-						if (data.msg) {
-							ComAlert.show(2, data.msg);
-						} else {
-							ComAlert.show(2, '删除失败');
-						}
+						layer.open({
+							title: '系统提示',
+							content: (data.msg || "删除失败"),
+							icon: '2'
+						});
 					}
 				},
 			});
 		});
+
 	});
 
 	// jquery.validate 自定义校验 “英文字母开头,只含有英文字母、数字和下划线”
@@ -86,17 +95,20 @@ $(function() {
 			$.post(base_url + "/jobgroup/save",  $("#addModal .form").serialize(), function(data, status) {
 				if (data.code == "200") {
 					$('#addModal').modal('hide');
-					setTimeout(function () {
-						ComAlert.show(1, "新增成功", function(){
+					layer.open({
+						title: '系统提示',
+						content: '新增成功',
+						icon: '1',
+						end: function(layero, index){
 							window.location.reload();
-						});
-					}, 315);
+						}
+					});
 				} else {
-					if (data.msg) {
-						ComAlert.show(2, data.msg);
-					} else {
-						ComAlert.show(2, "新增失败");
-					}
+					layer.open({
+						title: '系统提示',
+						content: (data.msg || "新增失败"),
+						icon: '2'
+					});
 				}
 			});
 		}
@@ -186,17 +198,21 @@ $(function() {
 			$.post(base_url + "/jobgroup/update",  $("#updateModal .form").serialize(), function(data, status) {
 				if (data.code == "200") {
 					$('#addModal').modal('hide');
-					setTimeout(function () {
-						ComAlert.show(1, "更新成功", function(){
+
+					layer.open({
+						title: '系统提示',
+						content: '更新成功',
+						icon: '1',
+						end: function(layero, index){
 							window.location.reload();
-						});
-					}, 315);
+						}
+					});
 				} else {
-					if (data.msg) {
-						ComAlert.show(2, data.msg);
-					} else {
-						ComAlert.show(2, "更新失败");
-					}
+					layer.open({
+						title: '系统提示',
+						content: (data.msg || "更新失败"),
+						icon: '2'
+					});
 				}
 			});
 		}

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

@@ -201,8 +201,10 @@ $(function() {
 		}
 		
 		var id = $(this).parent('p').attr("id");
-		
-		ComConfirm.show("确认" + typeName + "?", function(){
+
+		layer.confirm('确认' + typeName + '?', {icon: 3, title:'系统提示'}, function(index){
+			layer.close(index);
+
 			$.ajax({
 				type : 'POST',
 				url : url,
@@ -212,14 +214,24 @@ $(function() {
 				dataType : "json",
 				success : function(data){
 					if (data.code == 200) {
-						ComAlert.show(1, typeName + "成功", function(){
-							if (needFresh) {
-								//window.location.reload();
-								jobTable.fnDraw();
+
+						layer.open({
+							title: '系统提示',
+							content: typeName + "成功",
+							icon: '1',
+							end: function(layero, index){
+								if (needFresh) {
+									//window.location.reload();
+									jobTable.fnDraw();
+								}
 							}
 						});
 					} else {
-						ComAlert.show(1, typeName + "失败");
+						layer.open({
+							title: '系统提示',
+							content: (data.msg || typeName + "失败"),
+							icon: '2'
+						});
 					}
 				},
 			});
@@ -278,18 +290,21 @@ $(function() {
         	$.post(base_url + "/jobinfo/add",  $("#addModal .form").serialize(), function(data, status) {
     			if (data.code == "200") {
 					$('#addModal').modal('hide');
-					setTimeout(function () {
-						ComAlert.show(1, "新增任务成功", function(){
+					layer.open({
+						title: '系统提示',
+						content: '新增任务成功',
+						icon: '1',
+						end: function(layero, index){
 							jobTable.fnDraw();
 							//window.location.reload();
-						});
-					}, 315);
+						}
+					});
     			} else {
-    				if (data.msg) {
-    					ComAlert.show(2, data.msg);
-    				} else {
-    					ComAlert.show(2, "新增失败");
-    				}
+					layer.open({
+						title: '系统提示',
+						content: (data.msg || "新增失败"),
+						icon: '2'
+					});
     			}
     		});
 		}
@@ -394,18 +409,21 @@ $(function() {
     		$.post(base_url + "/jobinfo/reschedule", $("#updateModal .form").serialize(), function(data, status) {
     			if (data.code == "200") {
 					$('#updateModal').modal('hide');
-					setTimeout(function () {
-						ComAlert.show(1, "更新成功", function(){
+					layer.open({
+						title: '系统提示',
+						content: '更新成功',
+						icon: '1',
+						end: function(layero, index){
 							//window.location.reload();
 							jobTable.fnDraw();
-						});
-					}, 315);
+						}
+					});
     			} else {
-    				if (data.msg) {
-    					ComAlert.show(2, data.msg);
-					} else {
-						ComAlert.show(2, "更新失败");
-					}
+					layer.open({
+						title: '系统提示',
+						content: (data.msg || "更新失败"),
+						icon: '2'
+					});
     			}
     		});
 		}

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

@@ -48,11 +48,20 @@ $(function(){
         submitHandler : function(form) {
 			$.post(base_url + "/login", $("#loginForm").serialize(), function(data, status) {
 				if (data.code == "200") {
-					ComAlert.show(1, "登录成功", function(){
-						window.location.href = base_url;
-					});
+                    layer.open({
+                        title: '系统提示',
+                        content: '登录成功',
+                        icon: '1',
+                        end: function(layero, index){
+                            window.location.href = base_url;
+                        }
+                    });
 				} else {
-					ComAlert.show(2, data.msg);
+                    layer.open({
+                        title: '系统提示',
+                        content: (data.msg || "登录失败"),
+                        icon: '2'
+                    });
 				}
 			});
 		}

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

@@ -1,98 +0,0 @@
-/**
- * Created by xuxueli on 16/8/12.
- *
- * dependency, jquery + bootstrap
- */
-
-// 通用提示
-var ComAlert = {
-    html:function(){
-        var html =
-            '<div class="modal fade" id="ComAlert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' +
-                '<div class="modal-dialog">' +
-                    '<div class="modal-content">' +
-                        '<div class="modal-header hidden"><h4 class="modal-title"><strong>提示:</strong></h4></div>' +
-                        '<div class="modal-body"><div class="alert alert-success"></div></div>' +
-                        '<div class="modal-footer">' +
-                            '<div class="text-center" >' +
-                                '<button type="button" class="btn btn-default ok" data-dismiss="modal" >确认</button>' +
-                            '</div>' +
-                        '</div>' +
-                    '</div>' +
-                '</div>' +
-            '</div>';
-        return html;
-    },
-    show:function(type, msg, callback){
-        // dom init
-        if ($('#ComAlert').length == 0){
-            $('body').append(ComAlert.html());
-        }
-
-        // 弹框初始
-        if (type == 1) {
-            $('#ComAlert .alert').attr('class', 'alert alert-success');
-        } else {
-            $('#ComAlert .alert').attr('class', 'alert alert-warning');
-        }
-        $('#ComAlert .alert').html(msg);
-        $('#ComAlert').modal('show');
-
-        $('#ComAlert .ok').click(function(){
-            $('#ComAlert').modal('hide');
-            if(typeof callback == 'function') {
-                callback();
-            }
-        });
-
-        // $("#ComAlert").on('hide.bs.modal', function () {	});	// 监听关闭
-    }
-};
-
-// 通用确认弹框
-var ComConfirm = {
-    html:function(){
-        var html =
-            '<div class="modal fade" id="ComConfirm" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">' +
-                '<div class="modal-dialog">' +
-                    '<div class="modal-content">' +
-                        '<div class="modal-body"><div class="alert alert-success"></div></div>' +
-                            '<div class="modal-footer">' +
-                            '<div class="text-center" >' +
-                                '<button type="button" class="btn btn-primary ok" data-dismiss="modal" >确认</button>' +
-                                '<button type="button" class="btn btn-default cancel" data-dismiss="modal" >取消</button>' +
-                            '</div>' +
-                        '</div>' +
-                    '</div>' +
-                '</div>' +
-            '</div>';
-        return html;
-    },
-    show:function(msg, callback){
-        // dom init
-        if ($('#ComConfirm').length == 0){
-            $("body").append(ComConfirm.html());
-        }
-
-        // 弹框初始
-        $('#ComConfirm .alert').attr('class', 'alert alert-warning');
-        $('#ComConfirm .alert').html(msg);
-        $('#ComConfirm').modal('show');
-
-        $('#ComConfirm .ok').unbind("click");	// 解绑陈旧事件
-        $('#ComConfirm .ok').click(function(){
-            $('#ComConfirm').modal('hide');
-            if(typeof callback == 'function') {
-                setTimeout(function(){
-                    callback();
-                    return;
-                }, 315);
-            }
-        });
-
-        $('#ComConfirm .cancel').click(function(){
-            $('#ComConfirm').modal('hide');
-            return;
-        });
-    }
-};