var divmaskdialog = $("<div class='div_mask_dialog'></div>");
function openAlert(message,callback) {
$("body").append(divmaskdialog);
divmaskdialog.show();
var divContent = "<div id='alert_dialog' class='div-dialog-modal'>"
+"<div class='modal-header'> <h3>提示信息</h3> </div>"
+"<div class='modal-body' id='divShowMessasgeContent' >"+message+"</div>"
+"<div class='modal-footer'>"
+"<div class='toolButton' id='divShowMessasgeBtnOk' >确定</div></div>"//οnclick='confirmButton(2)'
+"</div>";
$("body").append(divContent);
$("#divShowMessasgeBtnOk").bind('click',function(){
$("#alert_dialog").remove();
divmaskdialog.hide();
if(callback && typeof(callback)=='function'){
callback();
}
});
$("#alert_dialog").show();
}
function confirmButton(id){
if(id == 1){
$("#confirm_dialog").remove();
}else{
$("#alert_dialog").remove();
}
divmaskdialog.hide();
}
function openConfirm(message,o, functionName, para) {
$("body").append(divmaskdialog);
divmaskdialog.show();
var divContent = "<div id='confirm_dialog' class='div-dialog-modal'>"
+"<div class='modal-header'> <h3>提示信息</h3> </div>"
+"<div class='modal-body' id='divShowMessasgeContent' >"+message+"</div>"
+"<div class='modal-footer'>"
+"<div class='toolButton' id='divShowMessasgeBtnYes'>是</div>"
+"<div class='toolButton' id='divShowMessasgeBtnNo' οnclick='confirmButton(1)'>否</div></div>"
+"</div>";
$("body").append(divContent);
$("#confirm_dialog").show();
$("#divShowMessasgeBtnYes").click(function(){
o = o == undefined ? window : Object(o);//obj可以是js基本类型
para = para == undefined ? window : Object(para);//obj可以是js基本类型
functionName.apply(o, para);
$("#confirm_dialog").remove();
divmaskdialog.hide();
});
}
function popUpPanel(url,param,w,h){
var left = (window.screen.width-w)/2;
var top = (window.screen.height-h)/2;
var windowPara = "dialogHeight: "+h+"px;dialogWidth:"+w+"px;dialogTop:"+top+"px;dialogLeft:"+left+"px;";
return window.showModalDialog(url,param,windowPara);
}
function deleteArrayByIndex(index,array){
if(index != null){
for(var i = index;i<array.length;i++){
array[i] = array[i+1];
}
array.length = array.length-1;
}
return array;
}
var chooseIds = new Array;
var chooseId;
function chooseRow(o,isMultipSelect){
var id = $(o).attr("id");
if(isMultipSelect==false){
$("#"+chooseId).removeClass("list_choosedRow");
if(chooseId!=id){
$("#"+id).addClass("list_choosedRow");
chooseId = id;
}else{
chooseId = null;
}
}
if(isMultipSelect==true){
var flag = false;
var index = null;
if(chooseIds.length > 0){
for(var i =0 ;i<chooseIds.length;i++){
if(chooseIds[i] == id){
index = i;
flag = true;
break;
}
}
}
if(flag){
$(o).removeClass("list_choosedRow");
chooseIds = deleteArrayByIndex(index,chooseIds);
}else{
$(o).addClass("list_choosedRow");
chooseIds.push(id);
}
}
}
function getSelectedRows(){
if(chooseId)
return chooseId;
return chooseIds;
}
function getFormObj(formId){
var rlt = {};
$("#"+formId+" input").each(function(){
if($(this).val()!=null){
rlt[$(this).attr("name")] =$(this).val().trim();
}else{
rlt[$(this).attr("name")] =$(this).val();
}
});
return rlt;
}
/**
* 进行Html转义
* */
function switcHtml(str)
{
if(str){
var s = "";
s = str.replace(/&/g, "&");
s = s.replace(/</g, "<");
s = s.replace(/>/g, ">");
s = s.replace(/\'/g, "'");
s = s.replace(/\"/g, """);
s = s.replace(/\\n/g, "");
s = s.replace(/\\r/g, "");
s = s.replace(/\//g, "/");
return s;
}
return "";
}
/**
* 进行Html反转
* */
function switchHtmlReverse(str)
{
if(str){
var s = "";
s = str.replace(/&/g, "&");
s = s.replace(/</g, "<");
s = s.replace(/>/g, ">");
s = s.replace(/'/g, "\'");
s = s.replace(/"/g, "\"");
s = s.replace(/<br>/g, "\n");
return s;
}
return "";
}
/**
* SessionStorage常用方法封装
*/
var SessionStorage = {
/**
* 向sessionStorage中存储数据
* @param key
* @param value json格式
* @returns
*/
setItem: function(key, value){
if(key && key!==null && key!=='undefined'){
sessionStorage.setItem(key, JSON.stringify(value));
}
},
/**
* 获取sessionStorage中的数据
* @param key
*/
getItem: function(key){
if(key && key!==null && key!=='undefined'){
var result = sessionStorage.getItem(key);
if(result){
return JSON.parse(result);
}
}
return null;
},
/**
* 清空sessionStorage
* @returns
*/
clear: function(){
sessionStorage.clear();
},
/**
* 设置查询参数到sessionStorage
* @param value
* searchParam:{
* showCount: 20,
* currentPage: 1,
* 自定义
* },
* formParam:{
* 自定义
* }
*/
setSearchParam: function(value){
this.setItem("pageParam", value);
},
/*
* 获取查询参数
*/
getSearchParam: function(){
var result = this.getItem("pageParam");
return result;
}
};
function openAlert(message,callback) {
$("body").append(divmaskdialog);
divmaskdialog.show();
var divContent = "<div id='alert_dialog' class='div-dialog-modal'>"
+"<div class='modal-header'> <h3>提示信息</h3> </div>"
+"<div class='modal-body' id='divShowMessasgeContent' >"+message+"</div>"
+"<div class='modal-footer'>"
+"<div class='toolButton' id='divShowMessasgeBtnOk' >确定</div></div>"//οnclick='confirmButton(2)'
+"</div>";
$("body").append(divContent);
$("#divShowMessasgeBtnOk").bind('click',function(){
$("#alert_dialog").remove();
divmaskdialog.hide();
if(callback && typeof(callback)=='function'){
callback();
}
});
$("#alert_dialog").show();
}
function confirmButton(id){
if(id == 1){
$("#confirm_dialog").remove();
}else{
$("#alert_dialog").remove();
}
divmaskdialog.hide();
}
function openConfirm(message,o, functionName, para) {
$("body").append(divmaskdialog);
divmaskdialog.show();
var divContent = "<div id='confirm_dialog' class='div-dialog-modal'>"
+"<div class='modal-header'> <h3>提示信息</h3> </div>"
+"<div class='modal-body' id='divShowMessasgeContent' >"+message+"</div>"
+"<div class='modal-footer'>"
+"<div class='toolButton' id='divShowMessasgeBtnYes'>是</div>"
+"<div class='toolButton' id='divShowMessasgeBtnNo' οnclick='confirmButton(1)'>否</div></div>"
+"</div>";
$("body").append(divContent);
$("#confirm_dialog").show();
$("#divShowMessasgeBtnYes").click(function(){
o = o == undefined ? window : Object(o);//obj可以是js基本类型
para = para == undefined ? window : Object(para);//obj可以是js基本类型
functionName.apply(o, para);
$("#confirm_dialog").remove();
divmaskdialog.hide();
});
}
function popUpPanel(url,param,w,h){
var left = (window.screen.width-w)/2;
var top = (window.screen.height-h)/2;
var windowPara = "dialogHeight: "+h+"px;dialogWidth:"+w+"px;dialogTop:"+top+"px;dialogLeft:"+left+"px;";
return window.showModalDialog(url,param,windowPara);
}
function deleteArrayByIndex(index,array){
if(index != null){
for(var i = index;i<array.length;i++){
array[i] = array[i+1];
}
array.length = array.length-1;
}
return array;
}
var chooseIds = new Array;
var chooseId;
function chooseRow(o,isMultipSelect){
var id = $(o).attr("id");
if(isMultipSelect==false){
$("#"+chooseId).removeClass("list_choosedRow");
if(chooseId!=id){
$("#"+id).addClass("list_choosedRow");
chooseId = id;
}else{
chooseId = null;
}
}
if(isMultipSelect==true){
var flag = false;
var index = null;
if(chooseIds.length > 0){
for(var i =0 ;i<chooseIds.length;i++){
if(chooseIds[i] == id){
index = i;
flag = true;
break;
}
}
}
if(flag){
$(o).removeClass("list_choosedRow");
chooseIds = deleteArrayByIndex(index,chooseIds);
}else{
$(o).addClass("list_choosedRow");
chooseIds.push(id);
}
}
}
function getSelectedRows(){
if(chooseId)
return chooseId;
return chooseIds;
}
function getFormObj(formId){
var rlt = {};
$("#"+formId+" input").each(function(){
if($(this).val()!=null){
rlt[$(this).attr("name")] =$(this).val().trim();
}else{
rlt[$(this).attr("name")] =$(this).val();
}
});
return rlt;
}
/**
* 进行Html转义
* */
function switcHtml(str)
{
if(str){
var s = "";
s = str.replace(/&/g, "&");
s = s.replace(/</g, "<");
s = s.replace(/>/g, ">");
s = s.replace(/\'/g, "'");
s = s.replace(/\"/g, """);
s = s.replace(/\\n/g, "");
s = s.replace(/\\r/g, "");
s = s.replace(/\//g, "/");
return s;
}
return "";
}
/**
* 进行Html反转
* */
function switchHtmlReverse(str)
{
if(str){
var s = "";
s = str.replace(/&/g, "&");
s = s.replace(/</g, "<");
s = s.replace(/>/g, ">");
s = s.replace(/'/g, "\'");
s = s.replace(/"/g, "\"");
s = s.replace(/<br>/g, "\n");
return s;
}
return "";
}
/**
* SessionStorage常用方法封装
*/
var SessionStorage = {
/**
* 向sessionStorage中存储数据
* @param key
* @param value json格式
* @returns
*/
setItem: function(key, value){
if(key && key!==null && key!=='undefined'){
sessionStorage.setItem(key, JSON.stringify(value));
}
},
/**
* 获取sessionStorage中的数据
* @param key
*/
getItem: function(key){
if(key && key!==null && key!=='undefined'){
var result = sessionStorage.getItem(key);
if(result){
return JSON.parse(result);
}
}
return null;
},
/**
* 清空sessionStorage
* @returns
*/
clear: function(){
sessionStorage.clear();
},
/**
* 设置查询参数到sessionStorage
* @param value
* searchParam:{
* showCount: 20,
* currentPage: 1,
* 自定义
* },
* formParam:{
* 自定义
* }
*/
setSearchParam: function(value){
this.setItem("pageParam", value);
},
/*
* 获取查询参数
*/
getSearchParam: function(){
var result = this.getItem("pageParam");
return result;
}
};