Main.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*
  2. * @Description: 修改样式
  3. * @Author: hy
  4. * @Date: 2019-08-12 17:59:33
  5. * @LastEditTime: 2019-08-13 08:59:31
  6. */
  7. Ext.define('uas.view.main.Main', {
  8. extend: 'Ext.container.Viewport',
  9. controller: 'main',
  10. viewModel: 'main',
  11. layout: 'border',
  12. requires: [
  13. 'Ext.layout.container.Border'
  14. ],
  15. items: [{
  16. region: 'north',
  17. xtype: 'toolbar',
  18. dock: 'top',
  19. height:48,
  20. items:[{
  21. xtype:'displayfield',
  22. value:'<h2 style="margin-top: 7px;">UAS2.0组件库</h2>',
  23. },'->',{
  24. xtype:'combo',
  25. width: 210,
  26. labelWidth:110,
  27. editable: false,
  28. fieldLabel:'当前主题&语言',
  29. store: Ext.create('Ext.data.Store', {
  30. fields: ['display', 'value'],
  31. data : [
  32. {"display":"时尚蓝", "value": 'triton'},
  33. {"display":"时尚灰", "value": 'crisp'},
  34. {"display":"商务蓝", "value": 'neptune'},
  35. {"display":"深邃黑", "value": 'aria'}
  36. ]
  37. }),
  38. cls:'x-desktop-combo',
  39. triggerAction: 'all',
  40. forceSelection: true,
  41. queryMode: 'local',
  42. displayField: 'display',
  43. valueField: 'value',
  44. listeners: {
  45. select: function(combo, records, obj){
  46. setCookie('theme',combo.value,0);
  47. window.location.reload();
  48. },
  49. beforerender:function(c){
  50. c.setValue(getCookie('theme'))
  51. }
  52. }
  53. },{
  54. xtype:'combo',
  55. width: 110,
  56. labelWidth:0,
  57. editable: false,
  58. store: Ext.create('Ext.data.Store', {
  59. fields: ['display', 'value'],
  60. data : [
  61. {"display":"简体中文", "value": 'zh_CN'},
  62. {"display":"英语", "value": 'en_US'}
  63. ]
  64. }),
  65. cls:'x-desktop-combo2',
  66. triggerAction: 'all',
  67. forceSelection: true,
  68. queryMode: 'local',
  69. displayField: 'display',
  70. valueField: 'value',
  71. listeners: {
  72. select: function(combo, records, obj){
  73. setCookie('locale',combo.value,0);
  74. window.location.reload();
  75. },
  76. beforerender:function(c){
  77. c.setValue(getCookie('locale'))
  78. }
  79. }
  80. }]
  81. },{
  82. region: 'west',
  83. collapsible: true,
  84. title: '目录',
  85. width: 260,
  86. split:true,
  87. layout: 'border',
  88. items: [{
  89. region: 'center',
  90. xtype: 'navigation-tree',
  91. tbar:{
  92. layout:'fit',
  93. items:[{
  94. xtype: 'searchfield',
  95. name: 'query',
  96. emptyText: '请输入关键词',
  97. store: 'Navigation',
  98. onClearClick : function(){
  99. var me = this;
  100. me.setValue('');
  101. me.store.clearFilter();
  102. me.getTrigger('clear').hide();
  103. me.updateLayout();
  104. },
  105. onSearchClick : function(){
  106. var me = this,tree = me.ownerCt.ownerCt,
  107. value = me.getValue();
  108. if (value.length > 0) {
  109. me.store.clearFilter();
  110. me.store.setRemoteFilter(false);
  111. me.store.filter([{
  112. filterFn: function(item) {
  113. item.expand();
  114. if(item.id == 'root'){
  115. return true;
  116. }else if(!item.isLeaf()){
  117. let hasChild = item.findChildBy(function(item){
  118. return item.get('text').indexOf(value)>-1
  119. },item,5);
  120. if(hasChild){
  121. return true
  122. }else{
  123. return false
  124. }
  125. }else if(item.get('text').indexOf(value)>-1){
  126. return true;
  127. }else{
  128. return false;
  129. }
  130. }
  131. }]);
  132. me.getTrigger('clear').show();
  133. me.updateLayout();
  134. }else{
  135. me.getTrigger('clear').hide();
  136. me.store.clearFilter();
  137. }
  138. }
  139. },'->']
  140. }
  141. }]
  142. }, {
  143. split:true,
  144. region: 'center',
  145. xtype: 'contentPanel',
  146. reference: 'contentPanel',
  147. ariaRole: 'main'
  148. }]
  149. });