i18n.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**
  2. * 打开/切换到新页签
  3. * @param xtype: view xtype
  4. * @param title: 标题
  5. * @param id: id
  6. * @param config: 绑定到view的其他配置
  7. */
  8. function openTab(xtype, title, id, config) {
  9. var mainTab = Ext.getCmp('main-tab-panel');
  10. var panel = mainTab.query('[tabId="' + id + '"]')[0];
  11. if(!panel) {
  12. panel = Ext.create('saas.view.core.tab.Panel', {
  13. tabId: id,
  14. title: title,
  15. viewType: xtype,
  16. viewConfig: config
  17. });
  18. Ext.suspendLayouts();
  19. mainTab.setActiveTab(mainTab.add(panel));
  20. Ext.resumeLayouts(true);
  21. }else {
  22. panel.viewConfig = config;
  23. mainTab.setActiveTab(panel);
  24. }
  25. }
  26. /**
  27. * 重设tab标题
  28. */
  29. function refreshTabTitle(id, title) {
  30. var currentTab = getCurrentTab();
  31. currentTab.tabId = id;
  32. currentTab.setTitle(title);
  33. }
  34. /**
  35. * 获得当前Tab
  36. */
  37. function getCurrentTab() {
  38. var mainTab = Ext.getCmp('main-tab-panel');
  39. var currentTab = mainTab.getActiveTab();
  40. return currentTab;
  41. }
  42. /**
  43. * 显示toast提示(无需用户操作)
  44. * @param content: 内容
  45. * @param title: 标题
  46. *
  47. */
  48. function showToast(content, title) {
  49. Ext.toast({
  50. html: content,
  51. title: title,
  52. closable: false,
  53. align: 't',
  54. slideDUration: 400,
  55. maxWidth: 400
  56. });
  57. }
  58. /**
  59. * 显示警告(需要选择是、否)
  60. * @param title: 标题
  61. * @param message: 内容
  62. * @return : Promise
  63. */
  64. function showConfirm(title, message) {
  65. return new Ext.Promise(function (resolve, reject) {
  66. Ext.MessageBox.confirm(title, message, function(buttonId) {
  67. return resolve(buttonId);
  68. });
  69. })
  70. }
  71. function warnMsg(msg, fn){
  72. Ext.MessageBox.show({
  73. title: '提示',
  74. msg: msg,
  75. buttons: Ext.Msg.YESNO,
  76. icon: Ext.Msg.WARNING,
  77. fn: fn
  78. });
  79. }
  80. function deleteWarn(msg, fn){
  81. Ext.MessageBox.show({
  82. title: '提示',
  83. msg: msg || '确定要删除当前表单?',
  84. buttons: Ext.Msg.YESNO,
  85. icon: Ext.Msg.WARNING,
  86. fn: fn,
  87. renderTo: Ext.getCmp('main-tab-panel').getActiveTab().getEl()
  88. });
  89. }
  90. /**
  91. * 判断字符串是否日期字符串
  92. * 需要满足格式 yyyy-MM-dd hh:mm:ss
  93. * 或者yyyy-M-d h:m:s
  94. * @param str: 字符串
  95. * @returns Boolean
  96. */
  97. function isDateString(str) {
  98. return (/^(\d{4})-(\d{1,2})-(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/).test(str);
  99. }