i18n.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  1. /**
  2. * jsp引入此js实现国际化
  3. * 通过从cookie得到的language,再调用不同的messages
  4. * @author yingp
  5. */
  6. var language = getCookie("language");
  7. var basePath = document.URL.substring(0, document.URL.lastIndexOf("ERP/")+4);// http://[hostname]:[port]/ERP/
  8. var em_name = getCookie('em_name');
  9. var em_uu = getCookie('em_uu');
  10. var en_name = getCookie('en_name');
  11. var en_uu = getCookie('en_uu');
  12. var em_code = getCookie('em_code');
  13. var script = document.createElement("script");//自定義國際化js文件
  14. var extScript = document.createElement("script");//ext組件國際化js文件
  15. script.type = 'text/javascript';
  16. extScript.type = 'text/javascript';
  17. if(language == 'zh_TW'){
  18. script.src = basePath + 'resource/i18n/messages_zh_TW.js';
  19. extScript.src = basePath + 'resource/ext/ext-lang-zh_TW.js';
  20. } else if(language == 'en_US'){
  21. script.src = basePath + 'resource/i18n/messages_en_US.js';
  22. } else {
  23. script.src = basePath + 'resource/i18n/messages_zh_CN.js';
  24. extScript.src = basePath + 'resource/ext/ext-lang-zh_CN.js';
  25. }
  26. document.getElementsByTagName('head').item(0).appendChild(script);
  27. document.getElementsByTagName('head').item(0).appendChild(extScript);
  28. //解决ie下某些样式问题及函数不能用的问题
  29. if(Ext.isIE){
  30. var cssLink = document.createElement("link");
  31. cssLink.rel = 'stylesheet';
  32. cssLink.type = 'text/css';
  33. cssLink.href = basePath + 'resource/ext/resources/css/ext-ie.css';
  34. document.getElementsByTagName('head').item(0).appendChild(cssLink);
  35. String.prototype.trim = function(){
  36. return this.replace(/(^\s*)|(\s*$)/g,"");
  37. };
  38. }
  39. Ext.onReady(function(){
  40. // extend Ext.Object
  41. Ext.Object.equals = (function() {
  42. var check = function(o1, o2) {
  43. var key;
  44. for (key in o1) {
  45. if (o1.hasOwnProperty(key)) {
  46. if (o1[key] !== o2[key]) {
  47. return false;
  48. }
  49. }
  50. }
  51. return true;
  52. };
  53. return function(object1, object2) {
  54. if (object1 === object2) {
  55. return true;
  56. } if (object1 && object2) {
  57. return check(object1, object2) && check(object2, object1);
  58. } else if (!object1 && !object2) {
  59. return object1 === object2;
  60. } else {
  61. return false;
  62. }
  63. };
  64. })();
  65. // 控制同一请求(url及params完全一致)的间隔时间为0.5s
  66. var requestStack = {}, delay = 500;
  67. Ext.Ajax.on('beforerequest', function(me, options){
  68. var now = new Date(), last = requestStack[options.url];
  69. if(last && Ext.Object.equals(last.params, options.params) && now - last.time < delay) {
  70. //showError('您的操作太快了!', 1500);
  71. //取消提醒设置 记录异常日志
  72. saveRedoLog(options);
  73. return false;
  74. } else {
  75. requestStack[options.url] = {time: now, params: options.params};
  76. }
  77. });
  78. });
  79. //读取cookies函数
  80. function getCookie(name)
  81. {
  82. var arr = document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
  83. if(arr != null) return unescape(arr[2]); return null;
  84. }
  85. //两个参数,一个是cookie的名称,一个是值
  86. function SetCookie(name,value)
  87. {
  88. var Days = 30; //此 cookie 将被保存 30 天
  89. var exp = new Date(); //new Date("December 31, 9998");
  90. exp.setTime(exp.getTime() + Days*24*60*60*1000);
  91. document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString();
  92. }
  93. //删除cookie
  94. function delCookie(name)
  95. {
  96. var exp = new Date();
  97. exp.setTime(exp.getTime() - 1);
  98. var cval=getCookie(name);
  99. if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
  100. }
  101. //解析url,获得传递的参数
  102. function getUrlParam(name){
  103. var reg=new RegExp("(^|&)"+name+"=([^&]*)(&|$)");
  104. var r=window.location.search.substr(1).match(reg);
  105. if (r!=null) return decodeURI(r[2]);
  106. return null;
  107. }
  108. function onUrlClick(url){
  109. Ext.Ajax.request({
  110. url: basePath + url,
  111. method: 'post',
  112. callback: function(options,success,response){
  113. Ext.Msg.alert('提示','确认成功!');
  114. }
  115. });
  116. }
  117. function saveRedoLog(options){
  118. if(options.params) options.params= unescape(escape(Ext.JSON.encode(options.params)));
  119. Ext.Ajax.request({
  120. url: basePath + 'ma/saveReDoLog.action',
  121. params:options,
  122. method: 'post',
  123. callback: function(options,success,response){
  124. }
  125. });
  126. }
  127. function showAll(val, title){
  128. if(!title){
  129. title='详细信息';
  130. }
  131. Ext.create('Ext.window.Window', {
  132. height: 200,
  133. title:'<h2>'+title+'</h2>',
  134. width: 400,
  135. layout: 'fit',
  136. html:'<p>'+val+'</p>'
  137. }).show();
  138. }
  139. /**
  140. * string:原始字符串
  141. * substr:子字符串
  142. * isIgnoreCase:忽略大小写
  143. */
  144. function contains(string, substr, isIgnoreCase){
  145. if (string == null || substr == null) return false;
  146. if (isIgnoreCase === undefined || isIgnoreCase === true) {
  147. string = string.toLowerCase();
  148. substr = substr.toLowerCase();
  149. }
  150. return string.indexOf(substr) > -1;
  151. }
  152. /**
  153. * WebContent/resource/i18n/i18n.js
  154. * 浮动div,显示错误信息,div会自动消失
  155. * @param err 错误信息
  156. */
  157. function showError(err, time, autoClose){
  158. if(err != null) {
  159. window.errmessage = err;
  160. autoClose = autoClose == null ? true : autoClose;
  161. if(err == 'ERR_NETWORK_SESSIONOUT'){//session丢失
  162. showLoginDiv(true);
  163. } else if(err == 'ERR_NETWORK_LOCKED') {//锁定
  164. alert('您的账号已被管理员锁定,无法在当前IP登录,请重新登录或切换账号!');
  165. showLoginDiv(true);
  166. } else {
  167. var isPowerErr = false,
  168. errCode = null;
  169. if(err.indexOf('ERR_POWER') != -1) {//权限问题
  170. errCode = err.substring(0, err.indexOf(':'));
  171. err = err.substr(err.indexOf(':') + 1);
  172. isPowerErr = true;
  173. }
  174. var main = parent.Ext.getCmp('content-panel');
  175. if(main){
  176. parent.Ext.create('erp.view.core.window.Msg', {
  177. title: $I18N.common.msg.title_warn,
  178. context: err,
  179. autoClose: autoClose,
  180. autoCloseTime: time
  181. });
  182. } else if(main = parent.parent.Ext.getCmp('content-panel')){
  183. if(main._mobile) {
  184. Ext.Msg.alert(err);
  185. } else {
  186. parent.parent.Ext.create('erp.view.core.window.Msg', {
  187. title: $I18N.common.msg.title_warn,
  188. context: err,
  189. autoClose: autoClose,
  190. autoCloseTime: time
  191. });
  192. }
  193. } else {
  194. Ext.create('erp.view.core.window.Msg', {
  195. title: $I18N.common.msg.title_warn,
  196. context: err,
  197. autoClose: autoClose,
  198. autoCloseTime: time
  199. });
  200. }
  201. if(isPowerErr) {
  202. if(errCode == 'ERR_POWER_026' || errCode == 'ERR_POWER_027' ||
  203. errCode == 'ERR_POWER_025') {//025查看列表,026查看单据,027查看他人单据---->这些情况下,界面直接关闭
  204. if(main) {
  205. main.getActiveTab().close();
  206. } else {
  207. window.close();
  208. }
  209. }
  210. }
  211. }
  212. }
  213. }
  214. /**
  215. * 右下角出现消息提示
  216. * @param title 消息标题
  217. * @param msg 显示的消息
  218. */
  219. function showMessage(title, msg, time){
  220. if (time == null || time > 3000) {
  221. window.errmessage = msg;
  222. }
  223. if(parent.Ext.getCmp('content-panel')){
  224. parent.Ext.create('erp.view.core.window.Msg', {
  225. title: title,
  226. context: msg,
  227. isError: false,
  228. autoCloseTime: time
  229. });
  230. } else if(parent.parent.Ext.getCmp('content-panel')){
  231. parent.parent.Ext.create('erp.view.core.window.Msg', {
  232. title: title,
  233. context: msg,
  234. isError: false,
  235. autoCloseTime: time
  236. });
  237. } else {
  238. Ext.create('erp.view.core.window.Msg', {
  239. title: title,
  240. context: msg,
  241. isError: false,
  242. autoCloseTime: time
  243. });
  244. }
  245. }
  246. //form分组展开收拢
  247. function collapse(id){
  248. var dom = document.getElementById("group" + id);
  249. if(dom.getAttribute('class') == 'x-form-group-label'){
  250. dom.setAttribute('class', 'x-form-group-label-close');
  251. dom.title = "展开";
  252. } else {
  253. dom.setAttribute('class', 'x-form-group-label');
  254. dom.title = "收拢";
  255. }
  256. Ext.each(Ext.getCmp('form').items.items, function(item){
  257. if(item.group && item.group == id){
  258. if(item.hidden == false){
  259. item.hide();
  260. } else {
  261. item.show();
  262. }
  263. }
  264. });
  265. }
  266. //messagebox
  267. /**
  268. * @param fn function
  269. */
  270. function warnMsg(msg, fn){
  271. Ext.MessageBox.show({
  272. title: $I18N.common.msg.title_prompt,
  273. msg: msg,
  274. buttons: Ext.Msg.YESNO,
  275. icon: Ext.Msg.WARNING,
  276. fn: fn
  277. });
  278. }
  279. function checkLogin(){
  280. Ext.Ajax.request({
  281. url : basePath + 'common/checkLogin.action',
  282. params: {
  283. id: id
  284. },
  285. method : 'post',
  286. callback : function(options,success,response){
  287. var localJson = new Ext.decode(response.responseText);
  288. if(localJson.exceptionInfo){
  289. showError(localJson.exceptionInfo);
  290. }
  291. if(localJson.success){
  292. printSuccess();
  293. }
  294. }
  295. });
  296. warnMsg('<br/><center><span style="color:blue">网络连接中断<span></center><hr/>可能原因:<br/>' +
  297. '<ul><li>[网络状况问题][会话过期][服务器关闭或重启]</li><li>...</li></ul><hr/>' +
  298. '<input type="button" value="重新登录&raquo;" style="height:25;width:70;cursor:pointer" onclick="showLoginDiv()">' +
  299. '<input type="button" value="取消&raquo;" style="height:25;width:60;cursor:pointer" onclick="closeMessage();">', function(){});
  300. }
  301. function showLoginDiv(isSessionOut){
  302. if(!Ext.getCmp('login')){
  303. var title = '重&nbsp;新&nbsp;登&nbsp;录';
  304. if(isSessionOut){
  305. title = '会话过期,请重新登录';
  306. }
  307. Ext.create('erp.view.core.window.ReLogin', {
  308. isSessionOut: isSessionOut,
  309. title: title,
  310. id: 'login'
  311. });
  312. } else {
  313. Ext.getCmp('login').show();
  314. Ext.getCmp('login').refresh();
  315. }
  316. }
  317. function openUrl(url, newMaster){
  318. var main = parent.Ext.getCmp("content-panel");
  319. if(!main && parent.parent.Ext) {
  320. main = parent.parent.Ext.getCmp("content-panel");
  321. }
  322. if(main) {
  323. var item = main.items.items[0];
  324. item.firstGrid=Ext.getCmp('task_grid');
  325. }
  326. url = url.toString().replace(/IS/g, '=');
  327. var fr = url.substr(url.indexOf('formCondition=') + 14);
  328. if(contains(fr, '&')) {
  329. fr = fr.substring(0, fr.indexOf('&'));
  330. }
  331. var keyField = fr.split('=')[0];
  332. var value = fr.split('=')[1];
  333. url = url.replace(keyField + '=' + value, keyField + '=\'' + value + '\'');
  334. if(contains(url, 'gridCondition')) {
  335. var gr = url.substr(url.indexOf('gridCondition=') + 14);
  336. if(contains(gr, '&')) {
  337. gr = gr.substring(0, gr.indexOf('&'));
  338. }
  339. var gField = gr.split('=')[0];
  340. var gValue = gr.split('=')[1];
  341. url = url.replace(gField + '=' + gValue, gField + '=\'' + gValue + '\'');
  342. }
  343. if(newMaster){
  344. var currentMaster = parent.window.sob;
  345. if ( currentMaster && currentMaster != newMaster) {// 与当前帐套不一致
  346. if (parent.Ext) {
  347. Ext.Ajax.request({
  348. url: basePath + 'common/changeMaster.action',
  349. params: {
  350. to: newMaster
  351. },
  352. callback: function(opt, s, r) {
  353. if (s) {
  354. var win = parent.Ext.create('Ext.Window', {
  355. width: '100%',
  356. height: '100%',
  357. draggable: false,
  358. closable: false,
  359. modal: true,
  360. title: '创建到帐套' + newMaster + '的临时会话',
  361. html : '<iframe src="' + url + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',
  362. buttonAlign: 'center',
  363. buttons: [{
  364. text: $I18N.common.button.erpCloseButton,
  365. cls: 'x-btn-blue',
  366. id: 'close',
  367. handler: function(b) {
  368. Ext.Ajax.request({
  369. url: basePath + 'common/changeMaster.action',
  370. params: {
  371. to: currentMaster
  372. },
  373. callback: function(opt, s, r) {
  374. if (s) {
  375. b.up('window').close();
  376. } else {
  377. alert('切换到原帐套失败!');
  378. }
  379. }
  380. });
  381. }
  382. }]
  383. });
  384. win.show();
  385. } else {
  386. alert('无法创建到帐套' + newMaster + '的临时会话!');
  387. }
  388. }
  389. });
  390. }
  391. return;
  392. }
  393. }
  394. var panel = Ext.getCmp(keyField + "=" + value);
  395. var main = parent.Ext.getCmp("content-panel") || parent.parent.Ext.getCmp("content-panel");
  396. if(!panel){
  397. var title = "";
  398. if (value&&value.toString().length>4) {
  399. title = value.toString().substring(value.toString().length-4);
  400. } else {
  401. title = value;
  402. }
  403. panel = {
  404. title : $I18N.common.msg.title_info + '(' + title + ')',
  405. tag : 'iframe',
  406. tabConfig: {tooltip:$I18N.common.msg.title_info + '(' + keyField + "=" + value + ')'},
  407. frame : true,
  408. border : false,
  409. layout : 'fit',
  410. iconCls : 'x-tree-icon-tab-tab',
  411. html : '<iframe id="iframe_maindetail_'+keyField+"_"+value+'" src="' + basePath + url + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>',
  412. closable : true,
  413. listeners : {
  414. close : function(){
  415. main.setActiveTab(main.getActiveTab().id);
  416. }
  417. }
  418. };
  419. var p = main.add(panel);
  420. main.setActiveTab(p);
  421. }else{
  422. main.setActiveTab(panel);
  423. }
  424. }
  425. function openUrl2(url,title,keyField,value){
  426. var panel = Ext.getCmp(keyField + "=" + value);
  427. var main = parent.Ext.getCmp("content-panel");
  428. if(!panel){
  429. panel = {
  430. title : title,
  431. tag : 'iframe',
  432. tabConfig: {tooltip:title},
  433. frame : true,
  434. border : false,
  435. layout : 'fit',
  436. iconCls : 'x-tree-icon-tab-tab',
  437. html : '<iframe id="iframe_maindetail_'+keyField+"_"+value+'" src="' + basePath + url + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>',
  438. closable : true,
  439. listeners : {
  440. close : function(){
  441. main.setActiveTab(main.getActiveTab().id);
  442. }
  443. }
  444. };
  445. var p = main.add(panel);
  446. main.setActiveTab(p);
  447. }else{
  448. main.setActiveTab(panel);
  449. }
  450. }
  451. function openFormUrl(value, keyField, url, title,newMaster){
  452. if(contains(url,'?')){
  453. url =url+'&formCondition='+keyField+"="+value;
  454. }else url =url+'?formCondition='+keyField+"="+value;
  455. var panel = Ext.getCmp(keyField + "=" + value);
  456. var main = parent.Ext.getCmp("content-panel");
  457. var showtitle='';
  458. url = url.replace(/IS/g, "=\'").replace(/&/g, "\'&");
  459. if(newMaster){
  460. var currentMaster = parent.window.sob;
  461. if ( currentMaster && currentMaster != newMaster) {// 与当前帐套不一致
  462. if (parent.Ext) {
  463. Ext.Ajax.request({
  464. url: basePath + 'common/changeMaster.action',
  465. params: {
  466. to: newMaster
  467. },
  468. callback: function(opt, s, r) {
  469. if (s) {
  470. var win = parent.Ext.create('Ext.Window', {
  471. width: '100%',
  472. height: '100%',
  473. draggable: false,
  474. closable: false,
  475. modal: true,
  476. title: '创建到帐套' + newMaster + '的临时会话',
  477. html : '<iframe src="' + url + '" height="100%" width="100%" frameborder="0" style="border-width: 0px;padding: 0px;" scrolling="auto"></iframe>',
  478. buttonAlign: 'center',
  479. buttons: [{
  480. text: $I18N.common.button.erpCloseButton,
  481. cls: 'x-btn-blue',
  482. id: 'close',
  483. handler: function(b) {
  484. Ext.Ajax.request({
  485. url: basePath + 'common/changeMaster.action',
  486. params: {
  487. to: currentMaster
  488. },
  489. callback: function(opt, s, r) {
  490. if (s) {
  491. b.up('window').close();
  492. } else {
  493. alert('切换到原帐套失败!');
  494. }
  495. }
  496. });
  497. }
  498. }]
  499. });
  500. win.show();
  501. } else {
  502. alert('无法创建到帐套' + newMaster + '的临时会话!');
  503. }
  504. }
  505. });
  506. }
  507. return;
  508. }
  509. }
  510. if(!panel){
  511. if (title && title.toString().length>4) {
  512. showtitle = title.toString().substring(0,4);
  513. }else if(title){
  514. showtitle=title;
  515. }
  516. panel = {
  517. title : showtitle,
  518. tag : 'iframe',
  519. tabConfig:{tooltip:title.toString() + '(' + keyField + "=" + value + ')'},
  520. frame : true,
  521. border : false,
  522. layout : 'fit',
  523. iconCls : 'x-tree-icon-tab-tab',
  524. html : '<iframe src="' + basePath + url + '" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>',
  525. closable : true,
  526. listeners : {
  527. close : function(){
  528. main.setActiveTab(main.getActiveTab().id);
  529. }
  530. }
  531. };
  532. openTab(panel, keyField + "=" + value);
  533. }else{
  534. main.setActiveTab(panel);
  535. }
  536. }
  537. function openGridUrl(value, keyField, mainField, url, title){
  538. url = basePath + url + '?formCondition=' + keyField + "IS'" + value +"'"+
  539. '&gridCondition=' + mainField + "IS'" + value+"'";
  540. var panel = Ext.getCmp(keyField + "=" + value);
  541. var main = parent.Ext.getCmp("content-panel");
  542. var showtitle='';
  543. if(!panel){
  544. if (title && title.toString().length>4) {
  545. showtitle = title.toString().substring(0,5);
  546. }
  547. panel = {
  548. title : showtitle,
  549. tag : 'iframe',
  550. tabConfig:{tooltip:title + '(' + keyField + "=" + value + ')'},
  551. frame : true,
  552. border : false,
  553. layout : 'fit',
  554. iconCls : 'x-tree-icon-tab-tab',
  555. html : '<iframe id="iframe_maindetail_'+keyField+"_"+value+'" src="' + url + '" height="100%" width="100%" frameborder="0" scrolling="auto"></iframe>',
  556. closable : true,
  557. listeners : {
  558. close : function(){
  559. main.setActiveTab(main.getActiveTab().id);
  560. }
  561. }
  562. };
  563. openTab(panel, keyField + "=" + value);
  564. }else{
  565. main.setActiveTab(panel);
  566. }
  567. }
  568. function getSetting(type) {
  569. var result = false;
  570. Ext.Ajax.request({
  571. url : basePath + 'common/getFieldData.action',
  572. async: false,
  573. params: {
  574. caller: 'Setting',
  575. field: 'se_value',
  576. condition: 'se_what=\'' + type + '\''
  577. },
  578. method : 'post',
  579. callback : function(opt, s, res){
  580. var r = new Ext.decode(res.responseText);
  581. if(r.exceptionInfo){
  582. showError(r.exceptionInfo);return;
  583. } else if(r.success && r.data){
  584. result = r.data == 'true';
  585. }
  586. }
  587. });
  588. return result;
  589. }
  590. function openTable(title, url,caller){
  591. var panel = Ext.getCmp('datalist' + caller);
  592. var main = parent.Ext.getCmp("content-panel");
  593. if(!panel){
  594. panel = {
  595. title : title,
  596. tag : 'iframe',
  597. tabConfig:{tooltip: title},
  598. frame : true,
  599. border : false,
  600. layout : 'fit',
  601. iconCls : 'x-tree-icon-tab-tab',
  602. html : '<iframe id="iframe_maindetail_pageSet" src="' + basePath + url + '" height="100%" width="100%" frameborder="0" scrolling="no"></iframe>',
  603. closable : true,
  604. listeners : {
  605. close : function(){
  606. main.setActiveTab(main.getActiveTab().id);
  607. }
  608. }
  609. };
  610. var p = main.add(panel);
  611. main.setActiveTab(p);
  612. }else{
  613. main.setActiveTab(panel);
  614. }
  615. }
  616. function downLoadById(id){
  617. Ext.Ajax.request({
  618. method:'POST',
  619. params:{
  620. id:id
  621. },
  622. url:basePath+'common/downloadbyId.action',
  623. callback: function(options,success,response){
  624. }
  625. });
  626. }
  627. function openTab(panel,id){
  628. var o = (typeof panel == "string" ? panel : id || panel.id);
  629. var main = parent.Ext.getCmp("content-panel");
  630. /*var tab = main.getComponent(o); */
  631. if(!main) {
  632. main =parent.parent.Ext.getCmp("content-panel");
  633. }
  634. var tab = main.getComponent(o);
  635. if (tab) {
  636. main.setActiveTab(tab);
  637. } else if(typeof panel!="string"){
  638. panel.id = o;
  639. var p = main.add(panel);
  640. main.setActiveTab(p);
  641. }
  642. }
  643. function delSuccess(fn){
  644. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_del, fn);
  645. }
  646. function delFailure(fn){
  647. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.failure_del, fn);
  648. }
  649. function delFailure(){
  650. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.failure_del);
  651. }
  652. function updateSuccess(fn){
  653. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_update, fn);
  654. }
  655. function updateFailure(fn){
  656. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_update, fn);
  657. }
  658. function updateFailure(){
  659. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_update);
  660. }
  661. function addSuccess(fn){
  662. }
  663. function addSuccess(){
  664. }
  665. function closeFailure(msg, fn){
  666. }
  667. function closeFailure(msg){
  668. }
  669. function saveSuccess(fn){
  670. var box = Ext.create('Ext.window.MessageBox', {
  671. buttonAlign : 'center',
  672. buttons: [{
  673. text: '确定',
  674. handler: function(b) {
  675. var scope = b.ownerCt.ownerCt;
  676. scope.fireEvent('hide', scope, true);
  677. }
  678. },{
  679. text: '继续添加',
  680. handler: function(b) {
  681. var scope = b.ownerCt.ownerCt;
  682. scope.fireEvent('hide', scope, false);
  683. }
  684. }],
  685. listeners: {
  686. hide: function(w, ok) {
  687. w.close();
  688. if(typeof ok == 'boolean') {
  689. if(ok)
  690. fn && fn.call();
  691. else
  692. window.location.reload();
  693. } else
  694. fn && fn.call();
  695. }
  696. }
  697. });
  698. box.show({
  699. title : $I18N.common.msg.title_prompt,
  700. msg : $I18N.common.msg.success_save,
  701. icon : Ext.MessageBox.QUESTION
  702. });
  703. }
  704. function turnSuccess(fn){
  705. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_turn, fn);
  706. }
  707. function saveFaliure(fn){
  708. Ext.Msg.alert($I18N.common.msg.title_warn, $I18N.common.msg.failure_save, fn);
  709. }
  710. function catchFailure(){
  711. Ext.Msg.alert($I18N.common.msg.title_warn, $I18N.common.msg.failure_catch);
  712. }
  713. function cleanFailure(){
  714. Ext.Msg.alert($I18N.common.msg.title_warn, $I18N.common.msg.failure_clean);
  715. }
  716. function saveFailure(){
  717. Ext.Msg.alert($I18N.common.msg.title_warn, $I18N.common.msg.failure_save);
  718. }
  719. function submitSuccess(fn){
  720. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_submit, fn);
  721. }
  722. function resSubmitSuccess(){
  723. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_resSubmit);
  724. }
  725. function bannedSuccess(){
  726. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_banned);
  727. }
  728. function resBannedSuccess(){
  729. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_resBanned);
  730. }
  731. function postSuccess(fn){
  732. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_post, fn);
  733. }
  734. function resPostSuccess(fn){
  735. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_resPost, fn);
  736. }
  737. function turninSuccess(fn){
  738. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_turnin, fn);
  739. }
  740. function submitFailure(fn){
  741. }
  742. function submitFailure(){
  743. }
  744. function printSuccess(fn){
  745. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_print, fn);
  746. }
  747. function catchSuccess(fn){
  748. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_catch, fn);
  749. }
  750. function cleanSuccess(fn){
  751. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_clean, fn);
  752. }
  753. function printSuccess(){
  754. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_print);
  755. }
  756. function turnBugSuccess(){
  757. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_turnbug);
  758. }
  759. function turnBugFailure(){
  760. Ext.Msg.alert($I18N.common.msg.title_warn, $I18N.common.msg.failure_turnbug);
  761. }
  762. function auditSuccess(fn){
  763. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_audit, fn || Ext.emptyFn);
  764. }
  765. function printFaliure(fn){
  766. Ext.Msg.alert($I18N.common.msg.title_warn, $I18N.common.msg.failure_print, fn);
  767. }
  768. function resAuditSuccess(fn){
  769. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_resAudit, fn || Ext.emptyFn);
  770. }
  771. function accountedSuccess(fn){
  772. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_accounted, fn || Ext.emptyFn);
  773. }
  774. function resAccountedSuccess(fn){
  775. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_resAccounted, fn || Ext.emptyFn);
  776. }
  777. function printFailure(){
  778. Ext.Msg.alert($I18N.common.msg.title_warn, $I18N.common.msg.print_save);
  779. }
  780. function endSuccess(fn){
  781. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_end, fn);
  782. }
  783. function nullifySuccess(fn){
  784. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_nullify, fn);
  785. }
  786. function endFailure(){
  787. Ext.Msg.alert($I18N.common.msg.title_warn, $I18N.common.msg.failure_end);
  788. }
  789. function resEndSuccess(fn){
  790. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_resEnd, fn);
  791. }
  792. function importSuccess(){
  793. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_import);
  794. }
  795. function checkSuccess(fn){
  796. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_check, fn || Ext.emptyFn);
  797. }
  798. function resCheckSuccess(fn){
  799. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_resCheck, fn || Ext.emptyFn);
  800. }
  801. function endArSuccess(fn){
  802. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_endar, fn || Ext.emptyFn);
  803. }
  804. function attendDataComSuccess(fn){
  805. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_attendDataCom, fn || Ext.emptyFn);
  806. }
  807. function cardLogImpSuccess(fn){
  808. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_cardlogimp, fn || Ext.emptyFn);
  809. }
  810. function unEndArSuccess(fn){
  811. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_unendar, fn || Ext.emptyFn);
  812. }
  813. function turnGSSuccess(fn){
  814. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_turnGs, fn || Ext.emptyFn);
  815. }
  816. function turnESSuccess(fn){
  817. Ext.Msg.alert($I18N.common.msg.title_prompt, $I18N.common.msg.success_turnEs, fn || Ext.emptyFn);
  818. }