MainController.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /**
  2. * This class is the controller for the main view for the application. It is specified as
  3. * the "controller" of the Main view class.
  4. */
  5. Ext.define('saas.view.main.MainController', {
  6. extend: 'Ext.app.ViewController',
  7. alias: 'controller.main',
  8. init: function() {
  9. this.setCompanyMenu();
  10. },
  11. setCompanyMenu: function() {
  12. var me = this, view = me.getView(), viewModel = me.getViewModel(),
  13. account = viewModel.get('account'), companies = account && account.companies,
  14. companyMenu = view.lookup('mainprofile').getMenu(), items = [];
  15. if (companies) {
  16. items = companies.map(function(c){
  17. return {
  18. text: c.name,
  19. value: c.id,
  20. handler: 'selectCompany',
  21. iconCls: c.id == account.companyId ? 'x-fa fa-check' : ''
  22. }
  23. });
  24. }
  25. companyMenu.insert(0, items);
  26. },
  27. onToggleNavigationSize: function () {
  28. var me = this,
  29. viewModel = me.getViewModel(),
  30. refs = me.getReferences(),
  31. navigationList = refs.navigationTreeList,
  32. navCollapsed = !navigationList.navCollapsed,
  33. new_width = navCollapsed ? viewModel.get('smallNavWidth') : viewModel.get('navWidth'),
  34. newLogoImgStyle = navCollapsed ? {
  35. width: 50,
  36. height: 50,
  37. top: 7,
  38. left: 6
  39. } : {
  40. width: 54,
  41. height: 54,
  42. top: 5,
  43. left: 16
  44. },
  45. newLogoTextStyle = navCollapsed ? {
  46. 5: {
  47. opacity: 0
  48. },
  49. 10: {
  50. opacity: 0
  51. },
  52. 100: {
  53. opacity: 0,
  54. display: 'none'
  55. }
  56. } : {
  57. 25: {
  58. opacity: 0
  59. },
  60. 50: {
  61. opacity: 1
  62. }
  63. },
  64. newNavIconStyle = navCollapsed ? {
  65. marginLeft: 6,
  66. fontSize: 28
  67. } : {
  68. marginLeft: 22,
  69. fontSize: 24
  70. },
  71. newNavTextStyle = navCollapsed ? {
  72. opacity: 0
  73. } : {
  74. opacity: 1
  75. },
  76. ope = navCollapsed ? 'addCls' : 'removeCls';
  77. var mainLogo = refs.mainLogo;
  78. var logoImg = mainLogo.el.dom.getElementsByTagName('img')[0];
  79. var logoText = mainLogo.el.dom.getElementsByClassName('logo-text')[0];
  80. var navItems = navigationList.el.dom.getElementsByClassName('x-navitem');
  81. mainLogo.animate({dynamic: true, duration: 500, to: {width: new_width}});
  82. Ext.fly(logoImg).animate({dynamic: true, duration: 500, to: newLogoImgStyle});
  83. Ext.fly(logoText).animate({dynamic: true, duration: 500, keyframes: newLogoTextStyle});
  84. navigationList.body.animate({dynamic: true, duration: 500, to: {width: new_width}});
  85. navigationList.animate({dynamic: true, duration: 500, to: {width: new_width}});
  86. for(var i = 0; i < navItems.length; i++) {
  87. var item = navItems[i];
  88. var icon = item.getElementsByClassName('nav-inner-icon')[0];
  89. var text = item.getElementsByClassName('nav-inner-text')[0];
  90. Ext.fly(icon).animate({dynamic: true, duration: 500, to: newNavIconStyle});
  91. Ext.fly(text).animate({dynamic: true, duration: 500, to: newNavTextStyle});
  92. }
  93. navigationList.el[ope]('nav-collapsed');
  94. navigationList.navCollapsed = navCollapsed;
  95. },
  96. selectCompany: function(item) {
  97. this.fireEvent('selectCompany', item.value);
  98. },
  99. onLogout: function() {
  100. this.fireEvent('logout');
  101. },
  102. feedbackMsg:function(btn){
  103. console.log("意见反馈!");
  104. var me = this,
  105. win = Ext.getCmp("feedbackWin");
  106. if (!win) {
  107. win = Ext.create('Ext.window.Window', {
  108. modal: true,
  109. id:"feedbackWin",
  110. height: '60%',
  111. width: '80%',
  112. title: '意见反馈',
  113. scrollable: true,
  114. constrain: true,
  115. closable: true,
  116. layout: 'fit',
  117. items: [{
  118. xtype: 'sys-feedback-formpanel'
  119. }]
  120. });
  121. };
  122. win.show();
  123. }
  124. });