CMS.Core.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782
  1. 
  2. //****************************************************************************************//
  3. //**************************************jquery扩展****************************************//
  4. //$(function () {
  5. // $(document.forms).submit(function () {
  6. // });
  7. //})
  8. $.extend({
  9. cmsPost: function (url, data, callback, type) {
  10. var newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + url.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
  11. return $.post(newUrl, data, callback, type);
  12. },
  13. cmsGet: function (url, data, callback, type) {
  14. var newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + url.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
  15. return $.get(newUrl, data, callback, type);
  16. },
  17. cmsGetJSON: function (url, data, callback) {
  18. var newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + url.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
  19. return $.getJSON(newUrl, data, callback);
  20. },
  21. cmsAjax: function (url, settings) {
  22. var ajaxOptions = {};
  23. if (settings) {
  24. $.extend(ajaxOptions, settings);
  25. ajaxOptions.url = ("/" + CMS_SystemConfig.VirtualDirectoryPath + url.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
  26. }
  27. else {
  28. $.extend(ajaxOptions, url);
  29. ajaxOptions.url = ("/" + CMS_SystemConfig.VirtualDirectoryPath + ajaxOptions.url.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
  30. }
  31. return $.ajax(ajaxOptions);
  32. },
  33. cmsGetScript: function (url, callback) {
  34. var newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + url.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
  35. return $.getScript(newUrl, callback);
  36. },
  37. exceptionThrow: function (jsonResult, callBackFun) {
  38. /// <summary>
  39. /// 异常抛出方法
  40. /// </summary>
  41. if (jsonResult) {
  42. var documentID;
  43. if (jsonResult.LogID) {
  44. documentID = "#" + jsonResult.LogID;
  45. }
  46. else {
  47. documentID = null;
  48. }
  49. if (jsonResult.StackTrace) {
  50. var errorWinHTML = "<div id='" + jsonResult.LogID + "' style=\"background: blanchedalmond;\"><b>" + $.decode(jsonResult.StackTrace) + "</b></div>";
  51. $(errorWinHTML).appendTo(window.top.document.body);
  52. $(documentID).window({
  53. width: 800,
  54. height: 600,
  55. modal: true,
  56. closed: true,
  57. collapsible: false,
  58. minimizable: false,
  59. title: '错误信息跟踪'
  60. });
  61. }
  62. else {
  63. var logID = (jsonResult.LogID ? "错误日志ID:<br />[<span style=\"color:red;\" >" + jsonResult.LogID + "</span>]<br /><br />" : "");
  64. var errorMsg = (jsonResult.ErrorMsg ? jsonResult.ErrorMsg + "<br /><br />" : "");
  65. var stackTrace = (jsonResult.StackTrace ? "错误跟踪:<a href=\"JavaScript:void(0);\" onclick=\"JavaScript:\$('" + documentID + "').window('open');\" >展开</a><br /><br />" : "");
  66. var returnVal = null;
  67. $.messager.alert('系统提示 ', logID + errorMsg + stackTrace, 'error', function () {
  68. if (documentID != null) {
  69. $(documentID).window('window').remove();
  70. if (callBackFun) {
  71. callBackFun();
  72. }
  73. else {
  74. returnVal = false;
  75. }
  76. }
  77. });
  78. if (returnVal != null) {
  79. return returnVal;
  80. }
  81. }
  82. }
  83. },
  84. bindClipBoard: function (id, obj) {
  85. var clip = new ZeroClipboard.Client();
  86. clip.setHandCursor(true);
  87. clip.setText(obj);
  88. clip.glue(id);
  89. clip.addEventListener('complete', function (client, text) {
  90. $.messager.alert("系统提示", "复制成功", "info");
  91. });
  92. }
  93. });
  94. $.fn.extend({
  95. ajaxClick: function (config) {// 异步点击操作事件
  96. if (!config) {
  97. this.triggerHandler("ajaxPostEvent");
  98. } else {
  99. this.each(function () {
  100. var _this = $(this);
  101. var defaultConfig = { postData: {}, postUrl: "", postResponse: function (responseJson) { }, autoAlertMessage: true, progress: false };
  102. var ajaxClickConfig = $.data(_this, "ajaxClickConfig");
  103. if (!ajaxClickConfig) {
  104. $.data(_this, "ajaxClickConfig", defaultConfig);
  105. $.data(_this, "ajaxClickEventManager", { "postResponse": [] });
  106. }
  107. var ajaxClickEventManager = $.data(_this, "ajaxClickEventManager");
  108. if (typeof (config) === "function") {
  109. ajaxClickEventManager["postResponse"].push(config);
  110. } else if (typeof (config) === "object") {
  111. config = $.extend({}, defaultConfig, config);
  112. $.data(_this, "ajaxClickConfig", config);
  113. if (config.postResponse) {
  114. ajaxClickEventManager["postResponse"].push(config.postResponse);
  115. }
  116. $.data(_this, "ajaxClickEventManager", ajaxClickEventManager);
  117. _this.unbind("ajaxPostEvent");
  118. _this.bind("ajaxPostEvent", function () {
  119. _this.disable();
  120. var ajaxClickConfig = $.data(_this, "ajaxClickConfig");
  121. if (ajaxClickConfig.progress) {
  122. //$.messager.progress({ msg: "等待服务器返回处理结果", autoClose: true, interval: 600 });
  123. $.cmsLoading.show("等待服务器返回处理结果");
  124. }
  125. var newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + ajaxClickConfig.postUrl.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
  126. $.post(newUrl,
  127. typeof (ajaxClickConfig.postData) == "function" ? ajaxClickConfig.postData() : ajaxClickConfig.postData,
  128. function (responseJson) {
  129. _this.enable();
  130. //$.messager.CloseProgress();
  131. $.cmsLoading.hide();
  132. //自动alert回传的提示内容
  133. if (ajaxClickConfig.autoAlertMessage && $.isPlainObject(responseJson) && responseJson.message) {
  134. $.messager.alert("系统提示", responseJson.message, "info", function () {
  135. var ajaxClickEventManager = $.data(_this, "ajaxClickEventManager");
  136. $.each(ajaxClickEventManager["postResponse"], function () {
  137. this.call(_this, responseJson);
  138. });
  139. });
  140. } else {
  141. var ajaxClickEventManager = $.data(_this, "ajaxClickEventManager");
  142. $.each(ajaxClickEventManager["postResponse"], function () {
  143. this.call(_this, responseJson);
  144. });
  145. }
  146. }, "json").error(function () {
  147. _this.enable();
  148. //$.messager.CloseProgress();
  149. $.cmsLoading.hide();
  150. });
  151. });
  152. }
  153. });
  154. }
  155. },
  156. exportClick: function (config) {
  157. var defaultConfig = {
  158. postUrl: '',
  159. dowloadName: "",
  160. postData: {},
  161. progress: true
  162. };
  163. config = $.extend({}, defaultConfig, config);
  164. config.postResponse = function (responseJson) {
  165. if (responseJson.fileUrl) {
  166. var url = "/Common/ExportExcel?filePath=" + responseJson.fileUrl;
  167. var newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + url).replaceDoubleSlashesToSingle();
  168. var src = "src='" + newUrl;
  169. if (config.dowloadName != "") {
  170. src.concat("&dowloadName=", config.dowloadName);
  171. }
  172. var iframHtml = "".concat("<iframe ", src, "' frameborder='0' style='border:0;width:0;height:0;' />");
  173. $("body").append(iframHtml);
  174. } else {
  175. if (!responseJson.IsSuccess) {
  176. $.messager.alert('警告', responseJson.Message);
  177. } else {
  178. $.messager.alert("警告", "响应错误:未能找到属性:filePath");
  179. }
  180. }
  181. };
  182. config.autoAlertMessage = false;
  183. this.ajaxClick(config);
  184. this.ajaxClick();
  185. }
  186. });
  187. //******************************************End******************************************//
  188. //***************************************************************************************//
  189. //****************************************************************************************//
  190. //**********************************CMS系统内置脚本对象***********************************//
  191. var CMS_SystemScriptObject = {
  192. LogoutConfirm: function () {//注销登录
  193. $.messager.confirm('提示', "是否确定退出系統?", "warning", function (r) {
  194. if (r) {
  195. $.System.logout();
  196. }
  197. });
  198. }
  199. };
  200. //******************************************End******************************************//
  201. //***************************************************************************************//
  202. //****************************************************************************************//
  203. //**********************************页面PageLoad事件**************************************//
  204. var IndexTabStatus = new Array();
  205. var CMS_PageLoadEvents = {
  206. AddStarToRequired: function () {
  207. //所有必填项提示,用"*"符号. added by 劳炳辉 2013-08-09
  208. var targets = $("[validtype]").closest("li").prev("li").not($("[validtype]").closest("li").find("b.requiredstar"));
  209. $(targets).each(function () {
  210. if ($(this).find("b.requiredstar").length == 0) {
  211. $(this).append("<b class=\"requiredstar\">*</b>"); //没有
  212. }
  213. });
  214. },
  215. SystemHandle: function () {
  216. $.System = (function () {
  217. var indexConfig = {};
  218. indexConfig['indexTabPanel'] = function () {
  219. return $('#index_center_tabs');
  220. };
  221. indexConfig['indexMenuPanel'] = $('#panelLeft');
  222. var f_init = function () {
  223. //屏蔽脚本错误
  224. window.onerror = function () { };
  225. $(window).resize(function () {
  226. if ($.System.resizePageingTimeout) {
  227. clearTimeout($.System.resizePageingTimeout);
  228. }
  229. $.System.resizePageingTimeout = setTimeout(function () {
  230. $.System.resizePage();
  231. }, 0);
  232. });
  233. //$.System.addTab('系统管理', '/EasyUI/Form');
  234. indexConfig['indexMenuPanel'].cmsMenu({
  235. onMenuClick: function (node) {
  236. if (node.text == "系统首页") {
  237. $.System.showDefaultIndex(true);
  238. return false;
  239. } else if (node.text == "系统注销") {
  240. CMS_SystemScriptObject.LogoutConfirm();
  241. return false;
  242. }
  243. if (node.url == null || node.url == '') return false;
  244. $.System.addTab(node.text, node.url, node.mnuNo);
  245. }
  246. });
  247. this.showDefaultIndex();
  248. //this.resizePage();
  249. //2013-07-10 解决用了uploadify的页面,在tab关闭时报空指针的问题
  250. var tabPanel = this.getTabPanel();
  251. tabPanel.tabs({
  252. onBeforeClose: function (title, index) {
  253. var tab = tabPanel.tabs('getTab', title);
  254. if (tab) {
  255. try {
  256. tab.find("div.easyui-AttachmentUploader").AttachmentUploader("destroy");
  257. } catch (ignore) { }
  258. }
  259. return true;
  260. }
  261. });
  262. };
  263. var f_resizePage = function () {
  264. indexConfig['indexTabPanel']().tabs("resize");
  265. if (typeof (this.selectedTabTimeout) != "undefined") {
  266. clearTimeout(this.selectedTabTimeout);
  267. }
  268. this.selectedTabTimeout = setTimeout(function () {
  269. try {
  270. var tabPanel = $.System.getTabPanel();
  271. var selectedTab = tabPanel.tabs('getSelected');
  272. var selectedTabIndex = tabPanel.tabs('getTabIndex', selectedTab);
  273. tabPanel.tabs('select', selectedTabIndex);
  274. } catch (ignore) { }
  275. }, 1000);
  276. };
  277. var f_addTab = function (title, url, mnuNo, postData) {
  278. var newUrl = url;
  279. newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + newUrl.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
  280. var tabPanel = this.getTabPanel();
  281. var oldTab = tabPanel.tabs('getTab', title);
  282. if (oldTab) {//&& oldTab.href == url) {
  283. tabPanel.tabs('select', title);
  284. //tabPanel.tabs('getSelected').panel("refresh", url);
  285. } else {
  286. postData = postData || {};
  287. var urlParams = $.param(postData);
  288. if (newUrl.indexOf("?") > -1) {
  289. newUrl += "&" + urlParams;
  290. } else {
  291. newUrl += "?&" + urlParams;
  292. }
  293. tabPanel.tabs('add', {
  294. title: title,
  295. //href: newUrl,
  296. content: '<iframe frameborder="0" scrolling="no" style="border:0;width:100%;height:99.6%;overflow:hidden;"></iframe><div data-tab="" style="width:100%;height:100%;top:50px;left:0;position:absolute;background-color:White;filter:alpha(opacity=50); -moz-opacity:0.5;opacity:0.5;"><img src="../../Content/images/loading.gif" alt="" style="top:48%;left:48%;position:absolute;" /></div>',
  297. cache: true,
  298. closable: true,
  299. fit: true,
  300. maximized: true,
  301. postData: postData
  302. });
  303. var tabIndex = tabPanel.tabs('getTabIndex', tabPanel.tabs("getSelected"));
  304. IndexTabStatus.push({ index: tabIndex, firstLoad: true });
  305. tabPanel.tabs("getSelected").panel("body").find("iframe").attr("src", newUrl);
  306. }
  307. $.System.hideDefaultIndex();
  308. };
  309. //刷新当前tab,可以指定新的url跟title
  310. var f_refreshCurrentTab = function (newUrl, title, postData) {
  311. newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + newUrl.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
  312. var tabPanel = this.getTabPanel();
  313. var tab = tabPanel.tabs('getSelected');
  314. postData = postData || {};
  315. var urlParams = $.param(postData);
  316. if (newUrl.indexOf("?") > -1) {
  317. newUrl += "&" + urlParams;
  318. } else {
  319. newUrl += "?&" + urlParams;
  320. }
  321. if (tab) {
  322. try {
  323. tab.find("div.easyui-AttachmentUploader").AttachmentUploader("destroy");
  324. } catch (ignore) {
  325. }
  326. // tabPanel.tabs("update", {
  327. // tab: tab,
  328. // options: {
  329. // title: title,
  330. // content: '<iframe src="#" frameborder="0" scrolling="no" style="border:0;width:100%;height:100%;overflow:hidden;"></iframe><div data-tab="" style="width:100%;height:100%;top:50px;left:0;position:absolute;background-color:White;filter:alpha(opacity=50); -moz-opacity:0.5;opacity:0.5;"><img src="../../Content/images/loading.gif" alt="" style="top:48%;left:48%;position:absolute;" /></div>',
  331. // cache: true,
  332. // closable: true,
  333. // fit: true,
  334. // postData: postData
  335. // }
  336. // });
  337. //var $iframe=tabPanel.tabs("getSelected").panel("body").find("iframe")
  338. var $iframe = tabPanel.panel("body").find("iframe");
  339. //$iframe.attr("src", "#");
  340. $iframe.attr("src", newUrl);
  341. }
  342. };
  343. var f_closeTabByTitle = function (title) {
  344. try {
  345. var tabPanel = this.getTabPanel();
  346. tabPanel.tabs("close", title);
  347. } catch (ignore) { }
  348. };
  349. //newUrl, title, postData
  350. var f_closeTab = function (reflashOptions) {
  351. var tabPanel = this.getTabPanel();
  352. var selectedTable = tabPanel.tabs("getSelected");
  353. var tableIndex = tabPanel.tabs("getTabIndex", selectedTable);
  354. tabPanel.tabs("close", tableIndex);
  355. if (reflashOptions != undefined) {
  356. if (typeof (reflashOptions.newUrl) != "undefined" && reflashOptions.newUrl != "") {
  357. var newUrl = reflashOptions.newUrl;
  358. newUrl = ("/" + CMS_SystemConfig.VirtualDirectoryPath + newUrl.replace(CMS_SystemConfig.VirtualDirectoryPath, "")).replaceDoubleSlashesToSingle();
  359. if (reflashOptions.title) {
  360. var currentTab = tabPanel.tabs("getTab", reflashOptions.title);
  361. if (currentTab) {
  362. // tabPanel.tabs("update", { tab: currentTab, options: {
  363. // title: reflashOptions.title,
  364. // content: '<iframe src="#" frameborder="0" scrolling="no" style="border:0;width:100%;height:100%;overflow:hidden;"></iframe><div data-tab="" style="width:100%;height:100%;top:50px;left:0;position:absolute;background-color:White;filter:alpha(opacity=50); -moz-opacity:0.5;opacity:0.5;"><img src="../../Content/images/loading.gif" alt="" style="top:48%;left:48%;position:absolute;" /></div>',
  365. // cache: true,
  366. // closable: true,
  367. // fit: true,
  368. // postData: {}
  369. // }
  370. // });
  371. var $iframe = tabPanel.panel("body").find("iframe");
  372. //$iframe.attr("src", "#");
  373. $iframe.attr("src", newUrl);
  374. }
  375. }
  376. else {
  377. var reflashPanel = tabPanel.tabs("getSelected");
  378. if (reflashPanel) {
  379. reflashPanel.panel("open").panel('refresh', newUrl);
  380. }
  381. }
  382. }
  383. }
  384. };
  385. var f_refreshDefaultIndexPage = function () {
  386. $("#index_main_content").cmsLoadHtml();
  387. };
  388. var f_showDefaultIndex = function (isRefresh) {
  389. $('#index_center_tabs').hide();
  390. $('#index_main_content').show();
  391. isRefresh = isRefresh || false;
  392. if (isRefresh) {
  393. $.System.refreshDefaultIndexPage();
  394. }
  395. };
  396. var f_hideDefaultIndex = function () {
  397. $('#index_main_content').hide();
  398. $('#index_center_tabs').show();
  399. var homepagetab = $('.easyui-tabs').find('.tabs-title:contains("首页")');
  400. if (homepagetab.length > 0) {
  401. homepagetab.css("padding-right", "8px");
  402. homepagetab.parent().css("width", "50px");
  403. homepagetab.parent().parent().find('.tabs-close').css('display', 'none');
  404. }
  405. $.System.resizePage();
  406. };
  407. var val_tabPanel = indexConfig['indexTabPanel']();
  408. val_tabPanel.tabs({
  409. onClose: function (title, index) {
  410. var allTabs = val_tabPanel.tabs('tabs');
  411. if (allTabs.length == 0) {
  412. $.System.showDefaultIndex(true);
  413. }
  414. }
  415. });
  416. var f_logout = function () {
  417. document.location = ("/" + CMS_SystemConfig.VirtualDirectoryPath + "/Account/LogOff").replaceDoubleSlashesToSingle();
  418. };
  419. var f_onMainPageLoad = function () {
  420. $.System.resizePage();
  421. };
  422. var f_maxSizeBrowser = function () {
  423. if (window.screen) { //判断浏览器是否支持window.screen判断浏览器是否支持screen
  424. var myw = screen.availWidth; //定义一个myw,接受到当前全屏的宽
  425. var myh = screen.availHeight; //定义一个myw,接受到当前全屏的高
  426. window.moveTo(0, 0); //把window放在左上脚
  427. window.resizeTo(myw, myh); //把当前窗体的长宽跳转为myw和myh
  428. }
  429. };
  430. 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 };
  431. })();
  432. $.System.init();
  433. },
  434. BrowserHandle: function () {
  435. if ($.browser.msie) {
  436. if ($.browser.version < 7) {
  437. $("body:first", document).addClass("ie6");
  438. //document.execCommand("BackgroundImageCache", false, true);
  439. } else if ($.browser.version < 8) {
  440. $("body:first", document).addClass("ie7");
  441. }
  442. }
  443. },
  444. UserExperience: function () {//增强用户体验
  445. //add by suzd 去掉下拉框后退事件
  446. document.onkeydown = function (event) {
  447. event = window.event || event;
  448. if (event.keyCode == 8) {
  449. event.keyCode = 0;
  450. event.returnvalue = false;
  451. }
  452. };
  453. //add by suzd 文本框回车激发提交事件
  454. $("div.search_keyword").find("input[type='text']").live("keydown", function (event) {
  455. var target = $(this);
  456. switch (event.keyCode) {
  457. case 13:
  458. target.closest("div.search_keyword").find("div").not("search_input").find(".easyui-linkbutton").focus().click().blur();
  459. break;
  460. }
  461. });
  462. //扩展DateTimeBox控件,用户点击input输入框等同点击后面的日期图标
  463. $('span.datebox').find('input.combo-text').live('click', function () {
  464. $(this).siblings('span').find('span.combo-arrow').click();
  465. });
  466. //扩展DropdownList控件,用户点击input输入框等同点击后面的下拉图标
  467. $('span.combo').find('input.combo-text').live('click', function () {
  468. $(this).siblings('span').find('span.combo-arrow').click();
  469. });
  470. },
  471. ValidateSelectBox: function () {
  472. $("select.easyui-validatebox:not(:disabled)").validatebox("validate");
  473. }
  474. };
  475. (function ($) {
  476. if ($.parser) {
  477. $.parser.parseEasyUI = function (loadPlugins) {
  478. if (loadPlugins.length > 0) {
  479. for (var i = 0; i < loadPlugins.length; i++) {
  480. var _3 = loadPlugins[i];
  481. var r = $(".easyui-" + _3);
  482. if (r.length) {
  483. if (r[_3]) {
  484. r[_3]();
  485. }
  486. }
  487. }
  488. } else {
  489. $.parser.parse();
  490. }
  491. };
  492. }
  493. // $(document).click(function() {
  494. // var o = $(window.event.srcElement);
  495. // if (o.get(0).tagName.toLowerCase() == "input" && o.attr("type").toLowerCase() == "text") {
  496. // o.select();
  497. // }
  498. // });
  499. })(jQuery);
  500. $(function () {
  501. CMS_PageLoadEvents.SystemHandle();
  502. CMS_PageLoadEvents.BrowserHandle();
  503. CMS_PageLoadEvents.UserExperience();
  504. var delay = 0;
  505. if ($.browser.msie) {
  506. if ($.browser.version < 7) {
  507. delay = 100;
  508. }
  509. }
  510. setTimeout(function () {
  511. // var dStart = new Date();
  512. //CMS_PageLoadEvents.AddStarToRequired();
  513. if ($.browser.msie && $.browser.version > 6) {
  514. CMS_PageLoadEvents.ValidateSelectBox();
  515. }
  516. //var dEnd = new Date();
  517. //alert(dEnd - dStart);
  518. }, delay);
  519. $('.frm-btn').click(function () {
  520. var $this = $(this),
  521. confirm = $this.data('confirm') || '';
  522. if (confirm == '') {
  523. var frmId = $this.data('frmid'),
  524. $frm = $('#' + frmId),
  525. actionUrl = $this.data('url'),
  526. afterValidate = $this.data('aftervalidate') || '',
  527. afterValidateRet = true,
  528. isValid = $frm.form('validate');
  529. if (isValid && afterValidate != '') {
  530. afterValidateRet = window[afterValidate]();
  531. }
  532. if (isValid && afterValidateRet) {
  533. $frm.attr('action', actionUrl);
  534. $.cmsLoading.show("等待服务器返回处理结果");
  535. $frm.submit();
  536. }
  537. return false;
  538. }
  539. $.messager.confirm("系统提示", confirm, function (r) {
  540. if (r) {
  541. var frmId = $this.data('frmid'),
  542. $frm = $('#' + frmId),
  543. actionUrl = $this.data('url'),
  544. afterValidate = $this.data('aftervalidate') || '',
  545. afterValidateRet = true,
  546. isValid = $frm.form('validate');
  547. if (isValid && afterValidate != '') {
  548. afterValidateRet = window[afterValidate]();
  549. }
  550. if (isValid && afterValidateRet) {
  551. $frm.attr('action', actionUrl);
  552. $.cmsLoading.show("等待服务器返回处理结果");
  553. $frm.submit();
  554. }
  555. }
  556. });
  557. return false;
  558. });
  559. });
  560. $.fn.extend({
  561. getFormParams: function () {
  562. var jsonString = "({'QueryParamsDatas':'";
  563. $(this).find('[name]').each(function (i, n) {
  564. var jn = $(n);
  565. if (jn.attr("name")) {
  566. jsonString += jn.attr("name") + "|*|" + jn.val() + "|@|";
  567. }
  568. else {
  569. var ezobject = jn.attr("comboname");
  570. if (ezobject) {
  571. if ($("[name='" + ezobject + "']").length > 0) {
  572. jsonString += ezobject + "|*|" + $("[name='" + ezobject + "']").val() + "|@|";
  573. }
  574. if ($("[submitName='" + ezobject + "']").length > 0) {
  575. jsonString += ezobject + "|*|" + $("[submitName='" + ezobject + "']").val() + "|@|";
  576. }
  577. }
  578. }
  579. });
  580. jsonString += "'})";
  581. return eval(jsonString);
  582. },
  583. getJsonFormParams: function () {
  584. var jsonString = "({";
  585. $(this).find('[name]').each(function (i, n) {
  586. var jn = $(n);
  587. if (jn.attr("name")) {
  588. jsonString += jn.attr("name") + ":'" + jn.val() + "',";
  589. }
  590. else {
  591. var ezobject = jn.attr("comboname");
  592. if (ezobject) {
  593. if ($("[name='" + ezobject + "']").length > 0) {
  594. jsonString += ezobject + ":'" + $("[name='" + ezobject + "']").val() + "',";
  595. }
  596. if ($("[submitName='" + ezobject + "']").length > 0) {
  597. jsonString += ezobject + ":'" + $("[submitName='" + ezobject + "']").val() + "',";
  598. }
  599. }
  600. }
  601. });
  602. jsonString += "})";
  603. return eval(jsonString);
  604. }
  605. });
  606. $.extend({
  607. getDataGridParams: function (gridid) {
  608. var jsonString = "({'QueryParamsDatas':'";
  609. $("[data-condition='" + gridid + "']").each(function (i, n) {
  610. var jn = $(n);
  611. if (jn.attr("type") == "checkbox") {
  612. var jnValue = jn.attr("checked") == "checked";
  613. jsonString += jn.attr("name") + "|*|" + jnValue + "|@|";
  614. }
  615. else if (jn.attr("name")) {
  616. jsonString += jn.attr("name") + "|*|" + jn.val() + "|@|";
  617. }
  618. else {
  619. var ezobject = jn.attr("comboname");
  620. if (ezobject) {
  621. if ($("[name='" + ezobject + "']").length > 0) {
  622. jsonString += ezobject + "|*|" + $("[name='" + ezobject + "']").val() + "|@|";
  623. }
  624. if ($("[submitName='" + ezobject + "']").length > 0) {
  625. jsonString += ezobject + "|*|" + $("[submitName='" + ezobject + "']").val() + "|@|";
  626. }
  627. }
  628. }
  629. });
  630. jsonString += "'})";
  631. return eval(jsonString);
  632. }
  633. });
  634. //******************************************End******************************************//
  635. //***************************************************************************************//