//****************************************************************************************//
//**************************************jquery扩展****************************************//
//$(function () {
// $(document.forms).submit(function () {
// });
//})
$.extend({
cmsPost: function (url, data, callback, type) {
var newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + url.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
return $.post(newUrl, data, callback, type);
},
cmsGet: function (url, data, callback, type) {
var newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + url.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
return $.get(newUrl, data, callback, type);
},
cmsGetJSON: function (url, data, callback) {
var newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + url.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
return $.getJSON(newUrl, data, callback);
},
cmsAjax: function (url, settings) {
var ajaxOptions = {};
if (settings) {
$.extend(ajaxOptions, settings);
ajaxOptions.url = ("/" + CMS_SystemConfig.VirtualDirectoryPath + url.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
}
else {
$.extend(ajaxOptions, url);
ajaxOptions.url = ("/" + CMS_SystemConfig.VirtualDirectoryPath + ajaxOptions.url.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
}
return $.ajax(ajaxOptions);
},
cmsGetScript: function (url, callback) {
var newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + url.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
return $.getScript(newUrl, callback);
},
exceptionThrow: function (jsonResult, callBackFun) {
///
/// 异常抛出方法
///
if (jsonResult) {
var documentID;
if (jsonResult.LogID) {
documentID = "#" + jsonResult.LogID;
}
else {
documentID = null;
}
if (jsonResult.StackTrace) {
var errorWinHTML = "
" + $.decode(jsonResult.StackTrace) + "
";
$(errorWinHTML).appendTo(window.top.document.body);
$(documentID).window({
width: 800,
height: 600,
modal: true,
closed: true,
collapsible: false,
minimizable: false,
title: '错误信息跟踪'
});
}
else {
var logID = (jsonResult.LogID ? "错误日志ID:
[" + jsonResult.LogID + "]
" : "");
var errorMsg = (jsonResult.ErrorMsg ? jsonResult.ErrorMsg + "
" : "");
var stackTrace = (jsonResult.StackTrace ? "错误跟踪:展开
" : "");
var returnVal = null;
$.messager.alert('系统提示 ', logID + errorMsg + stackTrace, 'error', function () {
if (documentID != null) {
$(documentID).window('window').remove();
if (callBackFun) {
callBackFun();
}
else {
returnVal = false;
}
}
});
if (returnVal != null) {
return returnVal;
}
}
}
},
bindClipBoard: function (id, obj) {
var clip = new ZeroClipboard.Client();
clip.setHandCursor(true);
clip.setText(obj);
clip.glue(id);
clip.addEventListener('complete', function (client, text) {
$.messager.alert("系统提示", "复制成功", "info");
});
},
String2XML: function (xmlString) {
// for IE
if (window.ActiveXObject) {
var xmlobject = new ActiveXObject("Microsoft.XMLDOM");
xmlobject.async = "false";
xmlobject.loadXML(xmlString);
return xmlobject;
}
// for other browsers
else {
var parser = new DOMParser();
var xmlobject = parser.parseFromString(xmlString, "text/xml");
return xmlobject;
}
}
});
$.fn.extend({
ajaxClick: function (config) {// 异步点击操作事件
if (!config) {
this.triggerHandler("ajaxPostEvent");
} else {
this.each(function () {
var _this = $(this);
var defaultConfig = { postData: {}, postUrl: "", postResponse: function (responseJson) { }, autoAlertMessage: true, progress: false };
var ajaxClickConfig = $.data(_this, "ajaxClickConfig");
if (!ajaxClickConfig) {
$.data(_this, "ajaxClickConfig", defaultConfig);
$.data(_this, "ajaxClickEventManager", { "postResponse": [] });
}
var ajaxClickEventManager = $.data(_this, "ajaxClickEventManager");
if (typeof (config) === "function") {
ajaxClickEventManager["postResponse"].push(config);
} else if (typeof (config) === "object") {
config = $.extend({}, defaultConfig, config);
$.data(_this, "ajaxClickConfig", config);
if (config.postResponse) {
ajaxClickEventManager["postResponse"].push(config.postResponse);
}
$.data(_this, "ajaxClickEventManager", ajaxClickEventManager);
_this.unbind("ajaxPostEvent");
_this.bind("ajaxPostEvent", function () {
_this.disable();
var ajaxClickConfig = $.data(_this, "ajaxClickConfig");
if (ajaxClickConfig.progress) {
//$.messager.progress({ msg: "等待服务器返回处理结果", autoClose: true, interval: 600 });
$.cmsLoading.show("等待服务器返回处理结果");
}
var newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + ajaxClickConfig.postUrl.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
$.post(newUrl,
typeof (ajaxClickConfig.postData) == "function" ? ajaxClickConfig.postData() : ajaxClickConfig.postData,
function (responseJson) {
_this.enable();
//$.messager.CloseProgress();
$.cmsLoading.hide();
//自动alert回传的提示内容
if (ajaxClickConfig.autoAlertMessage && $.isPlainObject(responseJson) && responseJson.message) {
$.messager.alert("系统提示", responseJson.message, "info", function () {
var ajaxClickEventManager = $.data(_this, "ajaxClickEventManager");
$.each(ajaxClickEventManager["postResponse"], function () {
this.call(_this, responseJson);
});
});
} else {
var ajaxClickEventManager = $.data(_this, "ajaxClickEventManager");
$.each(ajaxClickEventManager["postResponse"], function () {
this.call(_this, responseJson);
});
}
}, "json").error(function () {
_this.enable();
//$.messager.CloseProgress();
$.cmsLoading.hide();
});
});
}
});
}
},
exportClick: function (config) {
var defaultConfig = {
postUrl: '',
dowloadName: "",
postData: {},
progress: true
};
config = $.extend({}, defaultConfig, config);
config.postResponse = function (responseJson) {
if (responseJson.fileUrl) {
var url = "/Common/ExportExcel?filePath=" + responseJson.fileUrl;
var newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + url).replaceDoubleSlashesToSingle();
var src = "src='" + newUrl;
if (config.dowloadName != "") {
src.concat("&dowloadName=", config.dowloadName);
}
var iframHtml = "".concat("");
$("body").append(iframHtml);
} else {
if (!responseJson.IsSuccess) {
$.messager.alert('警告', responseJson.Message);
} else {
$.messager.alert("警告", "响应错误:未能找到属性:filePath");
}
}
};
config.autoAlertMessage = false;
this.ajaxClick(config);
this.ajaxClick();
}
});
//******************************************End******************************************//
//***************************************************************************************//
//****************************************************************************************//
//**********************************CMS系统内置脚本对象***********************************//
var CMS_SystemScriptObject = {
LogoutConfirm: function () {//注销登录
$.messager.confirm('提示', "是否确定退出系統?", "warning", function (r) {
if (r) {
$.System.logout();
}
});
}
};
//******************************************End******************************************//
//***************************************************************************************//
//****************************************************************************************//
//**********************************页面PageLoad事件**************************************//
var IndexTabStatus = new Array();
var CMS_PageLoadEvents = {
AddStarToRequired: function () {
//所有必填项提示,用"*"符号. added by 劳炳辉 2013-08-09
var targets = $("[validtype]").closest("li").prev("li").not($("[validtype]").closest("li").find("b.requiredstar"));
$(targets).each(function () {
if ($(this).find("b.requiredstar").length == 0) {
$(this).append("*"); //没有
}
});
},
SystemHandle: function () {
$.System = (function () {
var indexConfig = {};
indexConfig['indexTabPanel'] = function () {
return $('#index_center_tabs');
};
indexConfig['indexMenuPanel'] = $('#panelLeft');
var f_init = function () {
//屏蔽脚本错误
window.onerror = function () { };
$(window).resize(function () {
if ($.System.resizePageingTimeout) {
clearTimeout($.System.resizePageingTimeout);
}
$.System.resizePageingTimeout = setTimeout(function () {
$.System.resizePage();
}, 0);
});
//$.System.addTab('系统管理', '/EasyUI/Form');
indexConfig['indexMenuPanel'].cmsMenu({
onMenuClick: function (node) {
if (node.text == "系统首页") {
$.System.showDefaultIndex(true);
return false;
} else if (node.text == "系统注销") {
CMS_SystemScriptObject.LogoutConfirm();
return false;
}
if (node.url == null || node.url == '') return false;
$.System.addTab(node.text, node.url, node.mnuNo);
}
});
this.showDefaultIndex();
//this.resizePage();
//2013-07-10 解决用了uploadify的页面,在tab关闭时报空指针的问题
var tabPanel = this.getTabPanel();
tabPanel.tabs({
onBeforeClose: function (title, index) {
var tab = tabPanel.tabs('getTab', title);
if (tab) {
try {
tab.find("div.easyui-AttachmentUploader").AttachmentUploader("destroy");
} catch (ignore) { }
}
return true;
}
});
};
var f_resizePage = function () {
indexConfig['indexTabPanel']().tabs("resize");
if (typeof (this.selectedTabTimeout) != "undefined") {
clearTimeout(this.selectedTabTimeout);
}
this.selectedTabTimeout = setTimeout(function () {
try {
var tabPanel = $.System.getTabPanel();
var selectedTab = tabPanel.tabs('getSelected');
var selectedTabIndex = tabPanel.tabs('getTabIndex', selectedTab);
tabPanel.tabs('select', selectedTabIndex);
} catch (ignore) { }
}, 1000);
};
var f_addTab = function (title, url, mnuNo, postData) {
var newUrl = url;
newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + newUrl.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
var tabPanel = this.getTabPanel();
var oldTab = tabPanel.tabs('getTab', title);
if (oldTab) {//&& oldTab.href == url) {
tabPanel.tabs('select', title);
//tabPanel.tabs('getSelected').panel("refresh", url);
} else {
postData = postData || {};
var urlParams = $.param(postData);
if (newUrl.indexOf("?") > -1) {
newUrl += "&" + urlParams;
} else {
newUrl += "?&" + urlParams;
}
tabPanel.tabs('add', {
title: title,
//href: newUrl,
content: '',
cache: true,
closable: true,
fit: true,
maximized: true,
postData: postData
});
var tabIndex = tabPanel.tabs('getTabIndex', tabPanel.tabs("getSelected"));
IndexTabStatus.push({ index: tabIndex, firstLoad: true });
tabPanel.tabs("getSelected").panel("body").find("iframe").attr("src", newUrl);
}
$.System.hideDefaultIndex();
};
//刷新当前tab,可以指定新的url跟title
var f_refreshCurrentTab = function (newUrl, title, postData) {
newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + newUrl.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
var tabPanel = this.getTabPanel();
var tab = tabPanel.tabs('getSelected');
postData = postData || {};
var urlParams = $.param(postData);
if (newUrl.indexOf("?") > -1) {
newUrl += "&" + urlParams;
} else {
newUrl += "?&" + urlParams;
}
if (tab) {
try {
tab.find("div.easyui-AttachmentUploader").AttachmentUploader("destroy");
} catch (ignore) {
}
// tabPanel.tabs("update", {
// tab: tab,
// options: {
// title: title,
// content: '',
// cache: true,
// closable: true,
// fit: true,
// postData: postData
// }
// });
//var $iframe=tabPanel.tabs("getSelected").panel("body").find("iframe")
var $iframe = tabPanel.panel("body").find("iframe");
//$iframe.attr("src", "#");
$iframe.attr("src", newUrl);
}
};
var f_closeTabByTitle = function (title) {
try {
var tabPanel = this.getTabPanel();
tabPanel.tabs("close", title);
} catch (ignore) { }
};
//newUrl, title, postData
var f_closeTab = function (reflashOptions) {
var tabPanel = this.getTabPanel();
var selectedTable = tabPanel.tabs("getSelected");
var tableIndex = tabPanel.tabs("getTabIndex", selectedTable);
tabPanel.tabs("close", tableIndex);
if (reflashOptions != undefined) {
if (typeof (reflashOptions.newUrl) != "undefined" && reflashOptions.newUrl != "") {
var newUrl = reflashOptions.newUrl;
newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + newUrl.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
if (reflashOptions.title) {
var currentTab = tabPanel.tabs("getTab", reflashOptions.title);
if (currentTab) {
// tabPanel.tabs("update", { tab: currentTab, options: {
// title: reflashOptions.title,
// content: '',
// cache: true,
// closable: true,
// fit: true,
// postData: {}
// }
// });
var $iframe = tabPanel.panel("body").find("iframe");
//$iframe.attr("src", "#");
$iframe.attr("src", newUrl);
}
}
else {
var reflashPanel = tabPanel.tabs("getSelected");
if (reflashPanel) {
reflashPanel.panel("open").panel('refresh', newUrl);
}
}
}
}
};
var f_refreshDefaultIndexPage = function () {
$("#index_main_content").cmsLoadHtml();
};
var f_showDefaultIndex = function (isRefresh) {
$('#index_center_tabs').hide();
$('#index_main_content').show();
isRefresh = isRefresh || false;
if (isRefresh) {
$.System.refreshDefaultIndexPage();
}
};
var f_hideDefaultIndex = function () {
$('#index_main_content').hide();
$('#index_center_tabs').show();
var homepagetab = $('.easyui-tabs').find('.tabs-title:contains("首页")');
if (homepagetab.length > 0) {
homepagetab.css("padding-right", "8px");
homepagetab.parent().css("width", "50px");
homepagetab.parent().parent().find('.tabs-close').css('display', 'none');
}
$.System.resizePage();
};
var val_tabPanel = indexConfig['indexTabPanel']();
val_tabPanel.tabs({
onClose: function (title, index) {
var allTabs = val_tabPanel.tabs('tabs');
if (allTabs.length == 0) {
$.System.showDefaultIndex(true);
}
}
});
var f_logout = function () {
document.location = ("/" + CMS_SystemConfig.VirtualDirectoryPath + "/Account/LogOff").replaceDoubleSlashesToSingle();
};
var f_onMainPageLoad = function () {
$.System.resizePage();
};
var f_maxSizeBrowser = function () {
if (window.screen) { //判断浏览器是否支持window.screen判断浏览器是否支持screen
var myw = screen.availWidth; //定义一个myw,接受到当前全屏的宽
var myh = screen.availHeight; //定义一个myw,接受到当前全屏的高
window.moveTo(0, 0); //把window放在左上脚
window.resizeTo(myw, myh); //把当前窗体的长宽跳转为myw和myh
}
};
return { 'closeTabByTitle': f_closeTabByTitle, 'refreshDefaultIndexPage': f_refreshDefaultIndexPage, 'maxSizeBrowser': f_maxSizeBrowser, 'onMainPageLoad': f_onMainPageLoad, 'refreshCurrentTab': f_refreshCurrentTab, 'init': f_init, 'resizePage': f_resizePage, 'getTabPanel': indexConfig['indexTabPanel'], 'addTab': f_addTab, 'showDefaultIndex': f_showDefaultIndex, 'hideDefaultIndex': f_hideDefaultIndex, 'closeTab': f_closeTab, 'logout': f_logout };
})();
$.System.init();
},
BrowserHandle: function () {
if ($.browser.msie) {
if ($.browser.version < 7) {
$("body:first", document).addClass("ie6");
//document.execCommand("BackgroundImageCache", false, true);
} else if ($.browser.version < 8) {
$("body:first", document).addClass("ie7");
}
}
},
UserExperience: function () {//增强用户体验
//add by suzd 去掉下拉框后退事件
document.onkeydown = function (event) {
event = window.event || event;
if (event.keyCode == 8) {
event.keyCode = 0;
event.returnvalue = false;
}
};
//add by suzd 文本框回车激发提交事件
$("div.search_keyword").find("input[type='text']").live("keydown", function (event) {
var target = $(this);
switch (event.keyCode) {
case 13:
target.closest("div.search_keyword").find("div").not("search_input").find(".easyui-linkbutton").focus().click().blur();
break;
}
});
//扩展DateTimeBox控件,用户点击input输入框等同点击后面的日期图标
$('span.datebox').find('input.combo-text').live('click', function () {
$(this).siblings('span').find('span.combo-arrow').click();
});
//扩展DropdownList控件,用户点击input输入框等同点击后面的下拉图标
$('span.combo').find('input.combo-text').live('click', function () {
$(this).siblings('span').find('span.combo-arrow').click();
});
},
ValidateSelectBox: function () {
$("select.easyui-validatebox:not(:disabled)").validatebox("validate");
}
};
(function ($) {
if ($.parser) {
$.parser.parseEasyUI = function (loadPlugins) {
if (loadPlugins.length > 0) {
for (var i = 0; i < loadPlugins.length; i++) {
var _3 = loadPlugins[i];
var r = $(".easyui-" + _3);
if (r.length) {
if (r[_3]) {
r[_3]();
}
}
}
} else {
$.parser.parse();
}
};
}
// $(document).click(function() {
// var o = $(window.event.srcElement);
// if (o.get(0).tagName.toLowerCase() == "input" && o.attr("type").toLowerCase() == "text") {
// o.select();
// }
// });
})(jQuery);
$(function () {
CMS_PageLoadEvents.SystemHandle();
CMS_PageLoadEvents.BrowserHandle();
CMS_PageLoadEvents.UserExperience();
var delay = 0;
if ($.browser.msie) {
if ($.browser.version < 7) {
delay = 100;
}
}
setTimeout(function () {
// var dStart = new Date();
//CMS_PageLoadEvents.AddStarToRequired();
if ($.browser.msie && $.browser.version > 6) {
CMS_PageLoadEvents.ValidateSelectBox();
}
//var dEnd = new Date();
//alert(dEnd - dStart);
}, delay);
$('.frm-btn').click(function () {
var $this = $(this),
confirm = $this.data('confirm') || '';
if (confirm == '') {
var frmId = $this.data('frmid'),
$frm = $('#' + frmId),
actionUrl = $this.data('url'),
afterValidate = $this.data('aftervalidate') || '',
afterValidateRet = true,
isValid = $frm.form('validate');
if (isValid && afterValidate != '') {
afterValidateRet = window[afterValidate]();
}
if (isValid && afterValidateRet) {
$frm.attr('action', actionUrl);
$.cmsLoading.show("等待服务器返回处理结果");
$frm.submit();
}
return false;
}
$.messager.confirm("系统提示", confirm, function (r) {
if (r) {
var frmId = $this.data('frmid'),
$frm = $('#' + frmId),
actionUrl = $this.data('url'),
afterValidate = $this.data('aftervalidate') || '',
afterValidateRet = true,
isValid = $frm.form('validate');
if (isValid && afterValidate != '') {
afterValidateRet = window[afterValidate]();
}
if (isValid && afterValidateRet) {
$frm.attr('action', actionUrl);
$.cmsLoading.show("等待服务器返回处理结果");
$frm.submit();
}
}
});
return false;
});
});
$.fn.extend({
getFormParams: function () {
var jsonString = "({'QueryParamsDatas':'";
$(this).find('[name]').each(function (i, n) {
var jn = $(n);
if (jn.attr("name")) {
jsonString += jn.attr("name") + "|*|" + jn.val() + "|@|";
}
else {
var ezobject = jn.attr("comboname");
if (ezobject) {
if ($("[name='" + ezobject + "']").length > 0) {
jsonString += ezobject + "|*|" + $("[name='" + ezobject + "']").val() + "|@|";
}
if ($("[submitName='" + ezobject + "']").length > 0) {
jsonString += ezobject + "|*|" + $("[submitName='" + ezobject + "']").val() + "|@|";
}
}
}
});
jsonString += "'})";
return eval(jsonString);
},
getJsonFormParams: function () {
var jsonString = "({";
$(this).find('[name]').each(function (i, n) {
var jn = $(n);
if (jn.attr("name")) {
jsonString += jn.attr("name") + ":'" + jn.val() + "',";
}
else {
var ezobject = jn.attr("comboname");
if (ezobject) {
if ($("[name='" + ezobject + "']").length > 0) {
jsonString += ezobject + ":'" + $("[name='" + ezobject + "']").val() + "',";
}
if ($("[submitName='" + ezobject + "']").length > 0) {
jsonString += ezobject + ":'" + $("[submitName='" + ezobject + "']").val() + "',";
}
}
}
});
jsonString += "})";
return eval(jsonString);
}
});
$.extend({
getDataGridParams: function (gridid) {
var jsonString = "({'QueryParamsDatas':'";
$("[data-condition='" + gridid + "']").each(function (i, n) {
var jn = $(n);
if (jn.attr("type") == "checkbox") {
var jnValue = jn.attr("checked") == "checked";
jsonString += jn.attr("name") + "|*|" + jnValue + "|@|";
}
else if (jn.attr("name")) {
jsonString += jn.attr("name") + "|*|" + jn.val() + "|@|";
}
else {
var ezobject = jn.attr("comboname");
if (ezobject) {
if ($("[name='" + ezobject + "']").length > 0) {
jsonString += ezobject + "|*|" + $("[name='" + ezobject + "']").val() + "|@|";
}
if ($("[submitName='" + ezobject + "']").length > 0) {
jsonString += ezobject + "|*|" + $("[submitName='" + ezobject + "']").val() + "|@|";
}
}
}
});
jsonString += "'})";
return eval(jsonString);
}
});
//******************************************End******************************************//
//***************************************************************************************//