i18n.js 2.0 KB

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