/*
* 該庫主要封裝DWZ的一些常用函數,适用于平台開發。
*
* JQuery 1.4.4
* Version 0.1
*/
Namespace = new Object();
// 全局對象僅僅存在register函數,參數為名稱空間全路徑,如"trisun.ajax"
Namespace.register = function(fullNS)
{
// 将命名空間切成N部分, 比如trisun、ajax等
var nsArray = fullNS.split('.');
var sEval = "";
var sNS = "";
for (var i = 0; i < nsArray.length; i++){
if (i != 0) sNS += ".";
sNS += nsArray[i];
// 依次建立構造命名空間對象(假如不存在的話)的語句
// 比如先建立trisun,然後建立trisun.ajax,依次下去
sEval += "if (typeof(" + sNS + ") == 'undefined') " + sNS + " = new Object();"
}
if (sEval != "") eval(sEval);
};
Namespace.register("trisun.ajax");
Namespace.register("trisun.ui");
Namespace.register("trisun.event");
Namespace.register("dialog");
/**
* 設定查詢參數url用于 導出查詢結果
*/
trisun.setParams =function (form){
var param="";
var arr = $(form).serializeArray();
if(arr != null){
for(var i=0;i<arr.length;i++){
param = param + arr[i].name + "="+encodeURIComponent(arr[i].value)+"&";
}
}
return param.substring(0,param.length-1);
}
trisun.ajax.navSubmitAndConfirm = function (form, dgId) {
var $form = $(form);
try{
if(!$form.validationEngine({returnIsValid:true})){
return false;
}
}catch(e){
alert("驗證錯誤");
return false;
}
alertMsg.confirm("确定要歸檔工單嗎?", {
okCall:function() {
$.ajax({
type: form.method || 'POST',
url:$form.attr("action"),
data:$form.serializeArray(),
dataType:"json",
cache: false,
beforeSend: function (){
$(":submit").each(function(){
$(this).attr('disabled', true);
});
},
success: navAjaxDoneFlush,
error: function(xhr, ajaxOptions, thrownError){
$(":submit").each(function(){
$(this).attr('disabled', false);
});
DWZ.ajaxError(xhr, ajaxOptions, thrownError);
}
});
}
});
// 送出表單後傳回處理函數(主要功能:重新整理表單)
function navAjaxDoneFlush(json) {
DWZ.ajaxDone(json);
$(":submit").each(function(){
$(this).attr('disabled', false);
});
if (json.statusCode == DWZ.statusCode.ok) {
navTab.closeCurrentTab()
$("#" + dgId).flexReload();
}
}
return false;
};
trisun.ajax.navSubmitByAjaxAndFlushDG = function (form, dgId) {
var $form = $(form);
try{
if(!$form.validationEngine({returnIsValid:true})){
return false;
}
}catch(e){
alert("驗證錯誤");
return false;
}
$.ajax({
type: form.method || 'POST',
url:$form.attr("action"),
data:$form.serializeArray(),
dataType:"json",
cache: false,
beforeSend: function (){
$(":submit").each(function(){
$(this).attr('disabled', true);
});
},
success: navAjaxDoneFlush,
error: function(xhr, ajaxOptions, thrownError){
$(":submit").each(function(){
$(this).attr('disabled', false);
});
DWZ.ajaxError(xhr, ajaxOptions, thrownError);
}
});
// 送出表單後傳回處理函數(主要功能:重新整理表單)
function navAjaxDoneFlush(json) {
DWZ.ajaxDone(json);
$(":submit").each(function(){
$(this).attr('disabled', false);
});
if (json.statusCode == DWZ.statusCode.ok) {
navTab.closeCurrentTab()
$("#" + dgId).flexReload();
}
}
return false;
};
//确認提醒框
trisun.ui.distributeConfirm = function (form,dgId) {
alertMsg.confirm("确定要嗎?一經派單,不可回退!請慎重操作!",{
okCall:function(){
//alert("OK");
trisun.ajax.submitByAjaxAndFlushDG(form,dgId);
}
});
return false;
};
//稽核确認提醒框
trisun.ui.distributeConfirmHouseRent = function (form,dgId) {
var $form = $(form);
try{
if(!$form.validationEngine({returnIsValid:true})){
return false;
}
}catch(e){
alert("驗證錯誤");
return false;
}
alertMsg.confirm("确認稽核資訊!!!一經儲存,不可回退!請慎重操作!",{
okCall:function(){
//alert("OK");
trisun.ajax.submitByAjaxAndFlushDG(form,dgId);
}
});
return false;
};
//處理訂單提醒框
trisun.ui.dealConfirm = function (form,dgId) {
var $form = $(form);
try{
if(!$form.validationEngine({returnIsValid:true})){
return false;
}
}catch(e){
alert("驗證錯誤");
return false;
}
alertMsg.confirm("确定要儲存該處理結果嗎?",{
okCall:function(){
//alert("OK");
trisun.ajax.submitByAjaxAndFlushDG(form,dgId);
}
});
return false;
};
/**
* 修改費用的生成日期提示是否修改
*/
trisun.ui.upCostinfDateConfirm = function (form,dgId) {
alertMsg.confirm("您修改的資料會在下個月生效,請确定修改嗎?",{
okCall:function(){
//alert("OK");
trisun.ajax.submitByAjaxAndFlushDG(form,dgId);
}
});
return false;
};
/**
* 普通ajax表單送出後,重新整理DataGrid資料
* @param {Object} form
* @param {Object} callback
*/
trisun.ajax.submitByAjaxAndFlushDG = function (form, dgId) {
var $form = $(form);
try{
if(!$form.validationEngine({returnIsValid:true})){
return false;
}
}catch(e){
alert("驗證錯誤");
return false;
}
$.ajax({
type: form.method || 'POST',
url:$form.attr("action"),
data:$form.serializeArray(),
dataType:"json",
cache: false,
beforeSend: function (){
$(":submit").each(function(){
$(this).attr('disabled', true);
});
},
success: dialogAjaxDoneFlush,
error: function(xhr, ajaxOptions, thrownError){
$(":submit").each(function(){
$(this).attr('disabled', false);
});
DWZ.ajaxError(xhr, ajaxOptions, thrownError);
}
});
// 送出表單後傳回處理函數(主要功能:重新整理表單)
function dialogAjaxDoneFlush(json) {
DWZ.ajaxDone(json);
$(":submit").each(function(){
$(this).attr('disabled', false);
});
if (json.statusCode == DWZ.statusCode.ok) {
if(null != $.pdialog.getCurrent())
$.pdialog.closeCurrent();
//form.reset();
$("#" + dgId).flexReload();
}
}
return false;
};
/**
* 帶loading的ajax表單送出
* @param {Object} form
* @param {Object} dgId
* @return {TypeName}
*/
trisun.ajax.submitByAjaxAndFlushDGAndLoading = function (form, dgId) {
var $form = $(form);
try{
if(!$form.validationEngine({returnIsValid:true})){
return false;
}
}catch(e){
alert("驗證錯誤");
return false;
}
$(".dialog").mask(bms.terminal.waiting);
$.ajax({
type: form.method || 'POST',
url:$form.attr("action"),
data:$form.serializeArray(),
dataType:"json",
cache: false,
success: dialogAjaxDoneFlushLoading,
error: function(xhr, ajaxOptions, thrownError){
$(".dialog").unmask();
DWZ.ajaxError(xhr, ajaxOptions, thrownError);
}
});
// 送出表單後傳回處理函數(主要功能:重新整理表單)
function dialogAjaxDoneFlushLoading(json) {
DWZ.ajaxDone(json);
if (json.statusCode == DWZ.statusCode.ok) {
if(null != $.pdialog.getCurrent())
$.pdialog.closeCurrent();
$(".dialog").unmask();
$("#" + dgId).flexReload();
}else{
$(".dialog").unmask();
}
}
return false;
};
/**
* 普通ajax表單送出
* @param {Object} form
* @param {Object} callback
*/
trisun.ajax.submitByAjax = function (form) {
var $form = $(form);
try{
if(!$form.validationEngine({returnIsValid:true})){
return false;
}
}catch(e){
alert("驗證錯誤");
return false;
}
$.ajax({
type: form.method || 'POST',
url:$form.attr("action"),
data:$form.serializeArray(),
dataType:"json",
cache: false,
beforeSend: function (){
$(":submit").each(function(){
$(this).attr('disabled', true);
});
},
success: dialogAjaxDone,
error: function(xhr, ajaxOptions, thrownError){
$(":submit").each(function(){
$(this).attr('disabled', false);
});
DWZ.ajaxError(xhr, ajaxOptions, thrownError);
}
});
// 送出表單後傳回處理函數(主要功能:重新整理表單)
function dialogAjaxDone(json) {
DWZ.ajaxDone(json);
$(":submit").each(function(){
$(this).attr('disabled', false);
});
form.reset();
}
return false;
};
/**
* 删除提示對話框
* @param {} action 删除操作的action
* @param {} prototype 背景接收參數
* @param {} dgId DataGrid的ID
*/
trisun.ui.delDialog = function(action, prototype, dgId){
var url = action + "?";
var empty = true;
$("#" + dgId + " .noborder").each(function(){
if($(this).attr("checked") == true){
empty = false;
url = url + prototype + "=" + $(this).val() + "&";
}
});
if(empty == true) {
alertMsg.info("請選擇需要删除的記錄!");
return;
}
url = url.substring(0,url.length-1);
alertMsg.confirm("确定要删除該記錄?", {
okCall:function() {
$("#alertBackground").show();
navTabTodo(url,function(json){
DWZ.ajaxDone(json);
if (json.statusCode == DWZ.statusCode.ok){
$("#" + dgId).flexReload();
}
});
}
});
};
//add by jinac
/**
* 催費通知下發提示對話框
* @param {} action 操作的action
* @param {} prototype 背景接收參數
* @param {} dgId DataGrid的ID
*/
trisun.ui.noticeDialog = function(action, prototype, dgId){
var url = action + "?";
var empty = true;
$("#" + dgId + " .noborder").each(function(){
if($(this).attr("checked") == true){
empty = false;
url = url + prototype + "=" + $(this).val() + "&";
}
});
if(empty == true) {
alertMsg.info("請選擇需要下發的記錄!");
return;
}
url = url.substring(0,url.length-1);
alertMsg.confirm("确定要下發該記錄?", {
okCall:function() {
navTabTodo(url,function(json){
DWZ.ajaxDone(json);
if (json.statusCode == DWZ.statusCode.ok){
$("#" + dgId).flexReload();
}
});
}
});
};
//add by jinac
/**
* 全部催費通知下發提示對話框
* @param {} action 操作的action
* @param {} prototype 背景接收參數
* @param {} dgId DataGrid的ID
*/
trisun.ui.noticeAllDialog = function(action, prototype, dgId){
var url = action + "?";
var empty = true;
url = url.substring(0,url.length-1);
alertMsg.confirm("确定要下發全部記錄?", {
okCall:function() {
navTabTodo(url,function(json){
DWZ.ajaxDone(json);
if (json.statusCode == DWZ.statusCode.ok){
$("#" + dgId).flexReload();
}
});
}
});
};
trisun.ui.enabledDialog = function(action, prototype, dgId){
var url = action + "?";
var empty = true;
$("#" + dgId + " .noborder").each(function(){
if($(this).attr("checked") == true){
empty = false;
url = url + prototype + "=" + $(this).val() + "&";
}
});
if(empty == true) {
alertMsg.info("請選擇需要激活的記錄!");
return;
}
url = url.substring(0,url.length-1);
alertMsg.confirm("确定要執行激活嗎?", {
okCall:function() {
navTabTodo(url,function(json){
DWZ.ajaxDone(json);
if (json.statusCode == DWZ.statusCode.ok){
$("#" + dgId).flexReload();
}
});
}
});
};
//重新開機sip伺服器 author wenl
trisun.ui.restartServerDialog = function(action, prototype, dgId){
var url = action + "?";
var empty = true;
$("#" + dgId + " .noborder").each(function(){
if($(this).attr("checked") == true){
empty = false;
url = url + prototype + "=" + $(this).val() + "&";
}
});
if(empty == true) {
alertMsg.info("請選擇需要重新開機服務的SIP賬号!");
return;
}
url = url.substring(0,url.length-1);
alertMsg.confirm("确定要為選中的SIP賬号重新開機服務?", {
okCall:function() {
navTabTodo(url,function(json){
DWZ.ajaxDone(json);
if (json.statusCode == DWZ.statusCode.ok){
$("#" + dgId).flexReload();
}
});
}
});
};
//清理私有配置 author wenl
trisun.ui.clearPrivateConfigDialog = function(action, prototype, dgId){
var url = action + "?";
var empty = true;
$("#" + dgId + " .noborder").each(function(){
if($(this).attr("checked") == true){
empty = false;
url = url + prototype + "=" + $(this).val() + "&";
}
});
if(empty == true) {
alertMsg.info("請選擇需要清理配置的記錄!");
return;
}
url = url.substring(0,url.length-1);
alertMsg.confirm("确定要為選中的記錄清理配置?", {
okCall:function() {
navTabTodo(url,function(json){
//DWZ.ajaxDone(json);
if (json.statusCode == DWZ.statusCode.ok){
$("#" + dgId).flexReload();
var basePath = trisun.getSysUrl("bms");
//重新開機服務操作
alertMsg.confirm("是否需要重新開機相關服務,使關聯終端重新擷取配置資訊?", {
okCall:function() {
navTabTodo(basePath+"selectRestartSipServer.html?ids="+json.ids,function(back){
});
}
});
}
});
}
});
};
/**
* 以navTab的方式打開編輯對話框 -- add by wenchj
* @param {} action
* @param {} dlgId 對話框ID
* @param {} title 對話框标題
*/
trisun.ui.editNavTab = function(tabid, url, data){
// navTab.openTab(tabid, title, url);
navTab.openTab(tabid, url, data);
};
/**
* 編輯對話框
* @param {} action
* @param {} dlgId 對話框ID
* @param {} title 對話框标題
*/
trisun.ui.editDialog = function(action, dlgId, title, width, height){
if(width == null){
width = 800;
}
if(height == null){
height = 400;
}
$.pdialog.open(action, dlgId, title,{
width:width,
height:height
});
};
/**
* 編輯對話框
* @param {} action
* @param {} dlgId 對話框ID
* @param {} title 對話框标題
*/
trisun.ui.importDialog = function(action, dlgId, title, width, height){
if(width == null){
width = 800;
}
if(height == null){
height = 400;
}
$.pdialog.importDialog(action, dlgId, title,{
width:width,
height:height
});
};
/**
* 自定義對話框
* @param {} option 可選參數
*/
trisun.ui.customDialog = function(action, dlgId, title,option){
$.pdialog.open(action, dlgId, title,option);
};
/**
* 表單查詢Ajax操作
* @param {} dgId
* @param {} form
* @return {Boolean}
*/
trisun.ajax.search = function(dgId, form){
var $form = $(form);
var data = $form.serializeArray();
var surl = $form.attr("action");
// 05-04-07 搜尋按鈕 disabled + 遮罩進度圈
var $subObj = $(":submit",$form);
$subObj.css("color","gray").attr("disabled","disabled");
$("#container").mask("資料加載中,請稍等...");
$("#" + dgId).flexReload({url:surl, params:data, newp:1});
$subObj.css("color","#183152").removeAttr("disabled");
$("#container").unmask();
return false;
};
/**
* 表單查詢Ajax操作
* @param {} dgId
* @param {} form
* @return {Boolean}
*/
trisun.ajax.searchReserve = function(dgId, form, validate){
validate();
var $form = $(form);
var data = $form.serializeArray();
var surl = $form.attr("action");
// 05-04-07 搜尋按鈕 disabled + 遮罩進度圈
var $subObj = $(":submit",$form);
$subObj.css("color","gray").attr("disabled","disabled");
$("#container").mask("資料加載中,請稍等...");
$("#" + dgId).flexReload({url:surl, params:data, newp:1});
$subObj.css("color","#183152").removeAttr("disabled");
$("#container").unmask();
return false;
};
/**
* 鎖定系統視窗
*/
trisun.ui.lockDialog = function(){
islock = true;
// Ajax清除Session
// 彈出提示視窗
$.pdialog.open("lock.html", "lockDialog", "已鎖定", {
minable:false,
maxable:false,
resizable:false,
drawable:false,
width:350,
height:320,
mask:true
});
};
/**
* 退出系統确認對話框
*/
trisun.ui.logoutConfirm = function(){
$.pdialog.open("logoutConfirm.html", "logoutConfirm", "提示", {
minable:false,
maxable:false,
resizable:false,
drawable:false,
width:550,
height:200,
mask:true
});
};
/**
* 解鎖Ajax請求
*/
trisun.ajax.unlock = function(form){
var $form = $(form);
$.ajax({
type: form.method || 'POST',
url:$form.attr("action"),
data:$form.serializeArray(),
dataType:"json",
cache: false,
success: unlockAjaxDone,
error: DWZ.ajaxError
});
function unlockAjaxDone(json) {
if (json.statusCode == DWZ.statusCode.ok) {
islock = false;
$.pdialog.close("lockDialog");
}
}
return false;
};
/**
* 擷取DataGrid高度
* @param {} btnBar 頁面是否有btnBar
* @param {} searchBar 頁面是否有searchBar
* @param {} rowNum 搜尋欄行數
* @return {}
*/
trisun.ui.getDGHeight = function(btnBar, searchBar, rowNum){
var h = $(".tabsPageContent").outerHeight(true);
if(((searchBar == true) && (btnBar == true)) || ((searchBar == null) && (btnBar == null))){
h = h-15-50-25-55; // -145
}else {
// 自定義
if((btnBar == false) && (searchBar == true || searchBar == null)){
h = h-15-50-55;
}
if((searchBar == false) && (btnBar == true || btnBar == null)){
h = h-15-25-55;
}
if((btnBar == false) && (searchBar == false)){
h = h-15-55;
}
}
if(rowNum != null){
h = h - 25*(rowNum-1);
}
return h;
};
/**
* 上傳圖檔後,重新整理DataGrid資料
* @param {Object} form
* @param {Object} callback
*/
trisun.ajax.pictureUpLoadFormAndFlushDG = function(form, dgId){
var $form = $(form);
try{
if(!$form.validationEngine({returnIsValid:true})){
return false;
}
}catch(e){
alert("驗證錯誤");
return false;
}
$(":submit").each(function(){
$(this).attr('disabled', true);
});
window.donecallback = dialogAjaxDoneFlush;
if ($("#callbackframe").size() == 0) {
$("<iframe id='callbackframe' name='callbackframe' src='about:blank' style='display:none'></iframe>").appendTo("body");
}
if(!form.ajax) {
$(form).append('<input type="hidden" name="ajax" value="1" />');
}
form.target = "callbackframe";
function dialogAjaxDoneFlush(json) {
$(":submit").each(function(){
$(this).attr('disabled', false);
});
DWZ.ajaxDone(json);
if (json.statusCode == DWZ.statusCode.ok) {
$.pdialog.closeCurrent();
$("#" + dgId).flexReload();
}
}
};
/**
* 上傳檔案表單送出後,重新整理DataGrid資料
* @param {Object} form
* @param {Object} callback
*/
trisun.ajax.fileUpLoadFormAndFlushDG = function(form, dgId){
var $form = $(form);
try{
if(!$form.validationEngine({returnIsValid:true})){
return false;
}
}catch(e){
alert("驗證錯誤");
return false;
}
$(":submit").each(function(){
$(this).attr('disabled', true);
});
window.donecallback = dialogAjaxDoneFlush;
if ($("#callbackframe").size() == 0) {
$("<iframe id='callbackframe' name='callbackframe' src='about:blank' style='display:none'></iframe>").appendTo("body");
}
if(!form.ajax) {
$(form).append('<input type="hidden" name="ajax" value="1" />');
}
form.target = "callbackframe";
function dialogAjaxDoneFlush(json) {
$(":submit").each(function(){
$(this).attr('disabled', false);
});
DWZ.ajaxDone(json);
if (json.statusCode == DWZ.statusCode.ok) {
$.pdialog.closeCurrent();
$("#" + dgId).flexReload();
}
}
};
/**
* 展示鎖定系統事件
* @type time 鎖定時間(機關:秒)
*/
var mouseTimes = 0;
var islock = false;
trisun.event.lock = function(time){
setInterval(move, 1000);
function move(){
if(mouseTimes == time){
if(!islock){
mouseTimes = 0;
trisun.ui.lockDialog();
}
}else{
mouseTimes++;
}
}
$(window).mousemove(function(e){
mouseTimes = 0;
});
};
/**
* 擷取子系統url
* @param {} name 子系統名稱
*/
trisun.getSysUrl = function(name) {
return $("#"+name).val();
};
/**
* 按參數length截取長度
* @param {Object} value
* @param {Object} length
* @return {TypeName}
*/
trisun.substring = function(str,len){
if('' == str){
return '';
}
if(len == ''){
len = 20;
}
var str_length = 0;
var str_len = 0;
str_cut = new String();
str_len = str.length;
for(var i = 0;i<str_len;i++){
a = str.charAt(i);
str_length++;
if(escape(a).length > 4)
{
//中文字元的長度經編碼之後大于4
str_length++;
}
str_cut = str_cut.concat(a);
if(str_length>=len){
if(str.charAt(i+1) != ''){
str_cut = str_cut.concat("...");
}
return "<span style='text-decoration: none; cursor:default;cursor:pointer' title='"+str+"'>"+str_cut+"</span>";
}
}
//如果給定字元串小于指定長度,則傳回源字元串;
if(str_length<len){
return "<span style='text-decoration: none; cursor:default;cursor:pointer' title='"+str+"'>"+str+"</span>";
}
}
trisun.substringHref = function(value, length){
if('' == value){
return '';
}
if(length == ''){
length = 15;
}
if(value.length <= length){
return "<span style='text-decoration: none; cursor:default;cursor:pointer' title='"+value+"'>"+value+"</span>";
}else{
return "<span style='text-decoration: none; cursor:default;cursor:pointer' title='"+value+"'>"+value.substring(0,length)+"...</span>";
}
};
dialog.closeCurrent = function(dialogId) {
$.validationEngine.isValid = true;
if(dialogId == null){
$.pdialog.closeCurrent();
}else{
$.pdialog.close(dialogId+"");
}
};
//取得複選框的所有選中值,linsj[2012-02-17]
function getCheckboxValue(objName){
if(objName!=""){
var objArr=document.getElementsByName(objName);
var leng=objArr.length;
var guids="";
for(i=0;i<leng;i++){
var obj=objArr[i];
if(obj.checked){
guids+=obj.value;
if(i<leng-1){
guids+=",";
}
}
}
return guids;
}
}
//複選框的全選,linsj[2012-02-17]
function setAllCheckbox(objName){
if(objName!=""){
var objArr=document.getElementsByName(objName);
var leng=objArr.length;
for(i=0;i<leng;i++){
var temp=objArr[i];
temp.checked=true;
}
}
}
//複選框的反選
function setReverseCheckbox(objName){
if(objName!=""){
var objArr=document.getElementsByName(objName);
var leng=objArr.length;
for(i=0;i<leng;i++){
var temp=objArr[i];
if(temp.checked){
temp.checked=false;
}else{
temp.checked=true;
}
}
}
}
/**
*
* @param {} action 删除操作的action
* @param {} prototype 背景接收參數
* @param {} dgId DataGrid的ID
*
*
*/
trisun.ui.batchOpenAccount = function(action, prototype, dgId){
var url = action + "?";
var empty = true;
$("#" + dgId + " .noborder").each(function(){
if($(this).attr("checked") == true){
empty = false;
url = url + prototype + "=" + $(this).val() + "&";
}
});
if(empty == true) {
alertMsg.info("請選擇需要開戶的記錄!");
return;
}
url = url.substring(0,url.length-1);
alertMsg.confirm("确定要給選擇的記錄進行開戶?", {
okCall:function() {
navTabTodo(url,function(json){
DWZ.ajaxDone(json);
if (json.statusCode == DWZ.statusCode.ok){
$("#" + dgId).flexReload();
}
});
}
});
};
/**
* 功能開關
*/
trisun.ui.singleOpenOrCloseDialog = function(action, status, id, dgId) {
var url = action + "?id="+id;
url = url + "&status=" + status;
if (status == 1) {
alertMsg.confirm("确定要開啟小區功能?", {
okCall:function() {
navTabTodo(url,function(json){
DWZ.ajaxDone(json);
if (json.statusCode == DWZ.statusCode.ok){
$("#" + dgId).flexReload();
}
})
}
});
}
if (status == 0) {
alertMsg.confirm("确定要關閉小區功能?", {
okCall:function() {
navTabTodo(url,function(json){
DWZ.ajaxDone(json);
if (json.statusCode == DWZ.statusCode.ok){
$("#" + dgId).flexReload();
}
})
}
});
}
};
/**
* 房屋出租上下架開關
*/
trisun.ui.singleOpenOrCloseHouseRent= function(action, isShow, id, dgId) {
var url = action + "?houseId="+id;
url = url + "&isShow=" + isShow;
if (isShow == 1) {
alertMsg.confirm("确定要上架?", {
okCall:function() {
navTabTodo(url,function(json){
DWZ.ajaxDone(json);
if (json.statusCode == DWZ.statusCode.ok){
$("#" + dgId).flexReload();
}
})
}
});
}
if (isShow == 2) {
alertMsg.confirm("确定要下架?", {
okCall:function() {
navTabTodo(url,function(json){
DWZ.ajaxDone(json);
if (json.statusCode == DWZ.statusCode.ok){
$("#" + dgId).flexReload();
}
})
}
});
}
};
/**
* 轉換long值為日期字元串
* @param l long值
* @param pattern 格式字元串,例如:yyyy-MM-dd hh:mm:ss
*/
function getFormatDateByLong(l, pattern) {
return getFormatDate(new Date(l), pattern);
}
/**
* 轉換日期對象為日期字元串
* @param l long值
* @param pattern 格式字元串,例如:yyyy-MM-dd hh:mm:ss */
function getFormatDate(date, pattern) {
if (date == undefined) {
date = new Date();
}
if (pattern == undefined) {
pattern = "yyyy-MM-dd hh:mm:ss";
}
return date.format(pattern);
}
/**
* 擴充date.format
*/
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S": this.getMilliseconds()
}
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for (var k in o) {
if (new RegExp("(" + k + ")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
}
}
return format;
}
/**
*轉換日期對象為日期字元串
* @param date 日期對象
* @param isFull 是否為完整的日期資料,
* 為true時, 格式如"2000-03-05 01:05:04"
* 為false時, 格式如 "2000-03-05"
* @return 符合要求的日期字元串
*/
function getSmpFormatDate(date, isFull) {
var pattern = "";
if (isFull == true || isFull == undefined) {
pattern = "yyyy-MM-dd hh:mm:ss";
} else {
pattern = "yyyy-MM-dd";
}
return getFormatDate(date, pattern);
}
/**
*轉換目前日期對象為日期字元串
* @param date 日期對象
* @param isFull 是否為完整的日期資料,
* 為true時, 格式如"2000-03-05 01:05:04"
* 為false時, 格式如 "2000-03-05"
* @return 符合要求的日期字元串
*/
function getSmpFormatNowDate(isFull) {
return getSmpFormatDate(new Date(), isFull);
}
/**
*轉換long值為日期字元串
* @param l long值
* @param isFull 是否為完整的日期資料,
* 為true時, 格式如"2000-03-05 01:05:04"
* 為false時, 格式如 "2000-03-05"
* @return 符合要求的日期字元串
*/
function getSmpFormatDateByLong(l, isFull) {
return getSmpFormatDate(new Date(l), isFull);
}
轉載于:https://www.cnblogs.com/lansy/p/4735994.html