新增弹窗状态码 modal_status

pull/3/head
RuoYi 2018-05-23 09:43:52 +08:00
parent 4de464dc2d
commit e223e695d5
19 changed files with 51 additions and 48 deletions

View File

@ -2,13 +2,21 @@
* 通用方法封装处理 * 通用方法封装处理
* Copyright (c) 2018 ruoyi * Copyright (c) 2018 ruoyi
*/ */
/*
参数解释 /** 消息状态码 */
title 标题 web_status = {
url 请求的url SUCCESS: 0,
w 弹出层宽度缺省调默认值 FAIL: 500
h 弹出层高度缺省调默认值 };
*/
/** 弹窗状态码 */
modal_status = {
SUCCESS: "success",
FAIL: "error",
WARNING: "warning"
};
/** 弹出层指定宽度 */
function layer_show(title, url, w, h) { function layer_show(title, url, w, h) {
if (title == null || title == '') { if (title == null || title == '') {
title = false; title = false;
@ -34,23 +42,18 @@ function layer_show(title, url, w, h) {
}); });
} }
/** 弹出层自动宽高 */
function layer_showAuto(title, url) { function layer_showAuto(title, url) {
layer_show(title, url, '', ''); layer_show(title, url, '', '');
} }
/*关闭弹出框口*/ /** 关闭弹出框口 */
function layer_close() { function layer_close() {
var index = parent.layer.getFrameIndex(window.name); var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index); parent.layer.close(index);
} }
//状态码 /** 对ajax的post方法再次封装 */
web_status = {
SUCCESS: 0,
FAIL: 500
};
//对ajax的post方法再次封装
_ajax_save = function(url, data) { _ajax_save = function(url, data) {
var config = { var config = {
url: url, url: url,
@ -64,7 +67,7 @@ _ajax_save = function(url, data) {
$.ajax(config) $.ajax(config)
}; };
//对jquery的ajax方法再次封装 /** 对jquery的ajax方法再次封装 */
_ajax = function(url, data, type) { _ajax = function(url, data, type) {
var config = { var config = {
url: url, url: url,
@ -81,10 +84,10 @@ _ajax = function(url, data, type) {
/** 返回结果处理 */ /** 返回结果处理 */
function simpleSuccess(result) { function simpleSuccess(result) {
if (result.code == web_status.SUCCESS) { if (result.code == web_status.SUCCESS) {
$.modalMsg(result.msg, "success"); $.modalMsg(result.msg, modal_status.SUCCESS);
$.refreshTable(); $.refreshTable();
} else { } else {
$.modalAlert(result.msg, "error"); $.modalAlert(result.msg, modal_status.FAIL);
} }
} }
@ -95,7 +98,7 @@ function handleSuccess(result) {
$.parentReload(); $.parentReload();
}); });
} else { } else {
$.modalAlert(result.msg, "error"); $.modalAlert(result.msg, modal_status.FAIL);
} }
} }
@ -129,7 +132,7 @@ Date.prototype.format = function(format) {
return format; return format;
} }
// 创建选项卡 /** 创建选项卡 */
function createMenuItem(dataUrl, menuName) { function createMenuItem(dataUrl, menuName) {
dataIndex = Math.floor(Math.random()*100), dataIndex = Math.floor(Math.random()*100),
flag = true; flag = true;
@ -168,7 +171,7 @@ function createMenuItem(dataUrl, menuName) {
return false; return false;
} }
//设置全局ajax超时处理 /** 设置全局ajax超时处理 */
$.ajaxSetup({ $.ajaxSetup({
complete: function(XMLHttpRequest, textStatus) { complete: function(XMLHttpRequest, textStatus) {
if (textStatus == "parsererror") { if (textStatus == "parsererror") {

View File

@ -7,13 +7,13 @@ $(function(){
$.modalMsg = function(content, type) { $.modalMsg = function(content, type) {
if (type != undefined) { if (type != undefined) {
var icon = ""; var icon = "";
if (type == 'warning') { if (type == modal_status.WARNING) {
icon = 0; icon = 0;
} }
else if (type == 'success') { else if (type == modal_status.SUCCESS) {
icon = 1; icon = 1;
} }
else if (type == 'error') { else if (type == modal_status.FAIL) {
icon = 2; icon = 2;
} }
layer.msg(content, { icon: icon, time: 2000, shift: 0 }); layer.msg(content, { icon: icon, time: 2000, shift: 0 });
@ -25,11 +25,11 @@ $(function(){
// 弹出窗体 // 弹出窗体
$.modalAlert = function(content, type) { $.modalAlert = function(content, type) {
var icon = ""; var icon = "";
if (type == 'warning') { if (type == modal_status.WARNING) {
icon = 0; icon = 0;
} else if (type == 'success') { } else if (type == modal_status.SUCCESS) {
icon = 1; icon = 1;
} else if (type == 'error') { } else if (type == modal_status.FAIL) {
icon = 2; icon = 2;
} else { } else {
icon = 3; icon = 3;

View File

@ -104,7 +104,7 @@ function remove(id) {
function batchRemove() { function batchRemove() {
var rows = $.getSelections("jobId"); var rows = $.getSelections("jobId");
if (rows.length == 0) { if (rows.length == 0) {
$.modalMsg("请选择要删除的数据", "warning"); $.modalMsg("请选择要删除的数据", modal_status.WARNING);
return; return;
} }
$.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() { $.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() {

View File

@ -68,7 +68,7 @@ function remove(jobLogId) {
function batchRemove() { function batchRemove() {
var rows = $.getSelections("jobLogId"); var rows = $.getSelections("jobLogId");
if (rows.length == 0) { if (rows.length == 0) {
$.modalMsg("请选择要删除的数据", "warning"); $.modalMsg("请选择要删除的数据", modal_status.WARNING);
return; return;
} }
$.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() { $.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() {

View File

@ -52,7 +52,7 @@ $(function() {
function batchRemove() { function batchRemove() {
var rows = $.getSelections("infoId"); var rows = $.getSelections("infoId");
if (rows.length == 0) { if (rows.length == 0) {
$.modalMsg("请选择要删除的数据", "warning"); $.modalMsg("请选择要删除的数据", modal_status.WARNING);
return; return;
} }
$.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() { $.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() {

View File

@ -71,7 +71,7 @@ function forceLogout(id) {
function batchForceLogout() { function batchForceLogout() {
var rows = $.getSelections("sessionId"); var rows = $.getSelections("sessionId");
if (rows.length == 0) { if (rows.length == 0) {
$.modalMsg("请选择要删除的数据", "warning"); $.modalMsg("请选择要删除的数据", modal_status.WARNING);
return; return;
} }
$.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() { $.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() {

View File

@ -67,7 +67,7 @@ function detail(id) {
function batchRemove() { function batchRemove() {
var rows = $.getSelections("operId"); var rows = $.getSelections("operId");
if (rows.length == 0) { if (rows.length == 0) {
$.modalMsg("请选择要删除的数据", "warning"); $.modalMsg("请选择要删除的数据", modal_status.WARNING);
return; return;
} }
$.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() { $.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() {

View File

@ -73,7 +73,7 @@ function remove(id) {
function batchRemove() { function batchRemove() {
var rows = $.getSelections("configId"); var rows = $.getSelections("configId");
if (rows.length == 0) { if (rows.length == 0) {
$.modalMsg("请选择要删除的数据", "warning"); $.modalMsg("请选择要删除的数据", modal_status.WARNING);
return; return;
} }
$.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() { $.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() {

View File

@ -82,7 +82,7 @@ function remove(id) {
function batchRemove() { function batchRemove() {
var rows = $.getSelections("dictCode"); var rows = $.getSelections("dictCode");
if (rows.length == 0) { if (rows.length == 0) {
$.modalMsg("请选择要删除的数据", "warning"); $.modalMsg("请选择要删除的数据", modal_status.WARNING);
return; return;
} }
$.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() { $.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() {

View File

@ -80,7 +80,7 @@ function remove(id) {
function batchRemove() { function batchRemove() {
var rows = $.getSelections("dictId"); var rows = $.getSelections("dictId");
if (rows.length == 0) { if (rows.length == 0) {
$.modalMsg("请选择要删除的数据", "warning"); $.modalMsg("请选择要删除的数据", modal_status.WARNING);
return; return;
} }
$.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() { $.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() {

View File

@ -91,6 +91,6 @@ function selectMenuTree() {
} }
else else
{ {
$.modalAlert("主菜单不能选择", "error"); $.modalAlert("主菜单不能选择", modal_status.FAIL);
} }
} }

View File

@ -72,7 +72,7 @@ function remove(id) {
function batchRemove() { function batchRemove() {
var rows = $.getSelections("postId"); var rows = $.getSelections("postId");
if (rows.length == 0) { if (rows.length == 0) {
$.modalMsg("请选择要删除的数据", "warning"); $.modalMsg("请选择要删除的数据", modal_status.WARNING);
return; return;
} }
$.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() { $.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() {

View File

@ -86,7 +86,7 @@ function add() {
}, },
async : false, async : false,
error : function(request) { error : function(request) {
$.modalAlert("系统错误", "error"); $.modalAlert("系统错误", modal_status.FAIL);
}, },
success : function(data) { success : function(data) {
if (data.code == 0) { if (data.code == 0) {
@ -94,7 +94,7 @@ function add() {
$.parentReload(); $.parentReload();
}); });
} else { } else {
$.modalAlert(data.msg, "error"); $.modalAlert(data.msg, modal_status.FAIL);
} }
} }

View File

@ -91,7 +91,7 @@ function update() {
}, },
async : false, async : false,
error : function(request) { error : function(request) {
$.modalAlert("系统错误", "error"); $.modalAlert("系统错误", modal_status.FAIL);
}, },
success : function(data) { success : function(data) {
if (data.code == 0) { if (data.code == 0) {
@ -99,7 +99,7 @@ function update() {
$.parentReload(); $.parentReload();
}); });
} else { } else {
$.modalAlert(data.msg, "error"); $.modalAlert(data.msg, modal_status.FAIL);
} }
} }

View File

@ -73,7 +73,7 @@ function remove(id) {
function batchRemove() { function batchRemove() {
var rows = $.getSelections("roleId"); var rows = $.getSelections("roleId");
if (rows.length == 0) { if (rows.length == 0) {
$.modalMsg("请选择要删除的数据", "warning"); $.modalMsg("请选择要删除的数据", modal_status.WARNING);
return; return;
} }
$.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() { $.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() {

View File

@ -114,7 +114,7 @@ function add() {
}, },
async : false, async : false,
error : function(request) { error : function(request) {
$.modalAlert("系统错误", "error"); $.modalAlert("系统错误", modal_status.FAIL);
}, },
success : function(data) { success : function(data) {
if (data.code == 0) { if (data.code == 0) {
@ -122,7 +122,7 @@ function add() {
$.parentReload(); $.parentReload();
}); });
} else { } else {
$.modalAlert(data.msg, "error"); $.modalAlert(data.msg, modal_status.FAIL);
} }
} }

View File

@ -89,7 +89,7 @@ function update() {
}, },
async : false, async : false,
error : function(request) { error : function(request) {
$.modalAlert("系统错误", "error"); $.modalAlert("系统错误", modal_status.FAIL);
}, },
success : function(data) { success : function(data) {
if (data.code == 0) { if (data.code == 0) {
@ -97,7 +97,7 @@ function update() {
$.parentReload(); $.parentReload();
}); });
} else { } else {
$.modalAlert(data.msg, "error"); $.modalAlert(data.msg, modal_status.FAIL);
} }
} }
}); });

View File

@ -155,7 +155,7 @@ function resetPwd(userId) {
function batchRemove() { function batchRemove() {
var rows = $.getSelections("userId"); var rows = $.getSelections("userId");
if (rows.length == 0) { if (rows.length == 0) {
$.modalMsg("请选择要删除的数据", "warning"); $.modalMsg("请选择要删除的数据", modal_status.WARNING);
return; return;
} }
$.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() { $.modalConfirm("确认要删除选中的" + rows.length + "条数据吗?", function() {

View File

@ -44,7 +44,7 @@ function genCode(tableName) {
function batchGenCode() { function batchGenCode() {
var rows = $.getSelections("tableName"); var rows = $.getSelections("tableName");
if (rows.length == 0) { if (rows.length == 0) {
$.modalMsg("请选择要生成的数据", "warning"); $.modalMsg("请选择要生成的数据", modal_status.WARNING);
return; return;
} }
$.modalConfirm("确认要生成选中的" + rows.length + "条数据吗?", function() { $.modalConfirm("确认要生成选中的" + rows.length + "条数据吗?", function() {