i18n.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. mainTab.setActiveTab(panel);
  23. }
  24. }
  25. /**
  26. * 显示toast提示
  27. * @param content: 内容
  28. * @param title: 标题
  29. *
  30. */
  31. function showToast(content, title) {
  32. Ext.toast({
  33. html: content,
  34. title: title,
  35. closable: false,
  36. align: 't',
  37. slideDUration: 400,
  38. maxWidth: 400
  39. });
  40. }
  41. /**
  42. * 重设tab标题
  43. */
  44. function refreshTabTitle(id, title) {
  45. var currentTab = getCurrentTab();
  46. currentTab.tabId = id;
  47. currentTab.setTitle(title);
  48. }
  49. /**
  50. * 获得当前Tab
  51. */
  52. function getCurrentTab() {
  53. var mainTab = Ext.getCmp('main-tab-panel');
  54. var currentTab = mainTab.getActiveTab();
  55. return currentTab;
  56. }
  57. function showConfirm(title, message) {
  58. return new Ext.Promise(function (resolve, reject) {
  59. Ext.MessageBox.confirm(title, message, function(buttonId) {
  60. return resolve(buttonId);
  61. });
  62. })
  63. }
  64. function warnMsg(msg, fn){
  65. Ext.MessageBox.show({
  66. title: '提示',
  67. msg: msg,
  68. buttons: Ext.Msg.YESNO,
  69. icon: Ext.Msg.WARNING,
  70. fn: fn
  71. });
  72. }
  73. function deleteWarn(msg, fn){
  74. Ext.MessageBox.show({
  75. title: '提示',
  76. msg: msg || '确定要删除当前表单?',
  77. buttons: Ext.Msg.YESNO,
  78. icon: Ext.Msg.WARNING,
  79. fn: fn,
  80. renderTo: Ext.getCmp('main-tab-panel').getActiveTab().getEl()
  81. });
  82. }