CMS.Core.js 32 KB

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