Online.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. Ext.define('erp.view.ma.Online',{
  2. extend: 'Ext.Viewport',
  3. layout: 'anchor',
  4. hideBorders: true,
  5. initComponent : function(){
  6. var me = this;
  7. Ext.apply(me, {
  8. items: [{
  9. xtype: 'grid',
  10. id: 'online-grid',
  11. anchor: '100% 100%',
  12. tbar: ['->',{
  13. cls: 'x-btn-blue',
  14. id: 'refresh',
  15. text: $I18N.common.button.erpRefreshButton,
  16. width: 80,
  17. margin: '0 0 0 5'
  18. },{
  19. cls: 'x-btn-blue',
  20. id: 'close',
  21. text: $I18N.common.button.erpCloseButton,
  22. width: 80,
  23. margin: '0 0 0 5'
  24. },'->',{
  25. xtype: 'tbtext',
  26. id: 'online_count'
  27. }],
  28. plugins: [Ext.create('erp.view.core.grid.HeaderFilter')],
  29. columns: [{
  30. text: 'ID',
  31. dataIndex: 'em_id',
  32. hidden: true
  33. },{
  34. text: '登录账号',
  35. dataIndex: 'em_code',
  36. cls: 'x-grid-header-1',
  37. flex: 0.8,
  38. filter: {xtype:"textfield", filterName:"em_code"}
  39. },{
  40. text: '姓名',
  41. dataIndex: 'em_name',
  42. cls: 'x-grid-header-1',
  43. flex: 0.8,
  44. filter: {xtype:"textfield", filterName:"em_name"}
  45. },{
  46. text: '登录IP',
  47. dataIndex: 'ip',
  48. cls: 'x-grid-header-1',
  49. flex: 1.5,
  50. filter: {xtype:"textfield", filterName:"ip"}
  51. },{
  52. text: '账套',
  53. dataIndex: 'sob',
  54. cls: 'x-grid-header-1',
  55. flex: 0.5,
  56. filter: {xtype:"textfield", filterName:"sob"}
  57. },{
  58. text: '最近请求时间',
  59. dataIndex: 'date',
  60. cls: 'x-grid-header-1',
  61. flex: 1.5,
  62. filter: {xtype:"datefield", filterName:"date"},
  63. renderer: function(val) {
  64. if(val != null) {
  65. return Ext.Date.format(new Date(val), 'Y-m-d h:i:s');
  66. }
  67. return null;
  68. }
  69. },{
  70. text: 'SessionID',
  71. dataIndex: 'sid',
  72. cls: 'x-grid-header-1',
  73. filter: {xtype:"textfield", filterName:"sid"},
  74. flex: 2.5
  75. },{
  76. text: '',
  77. dataIndex: 'lock',
  78. cls: 'x-grid-header-1',
  79. flex: 0.5,
  80. renderer: function(val, meta, record, x, y, store) {
  81. if(val == 'true') {
  82. return "<font color=red>已锁定</font>";
  83. }
  84. return '<button class="custom-button" onclick="Ext.getCmp(\'online-grid\').fireEvent(\'lockitem\', ' +
  85. x + ')">锁定</button>';
  86. }
  87. }],
  88. columnLines: true,
  89. enableColumnResize: true,
  90. store: Ext.create('Ext.data.Store',{
  91. fields: [{name: 'em_id', type: 'number'}, 'em_code', 'em_name', 'ip', 'sob', 'date', 'sid', 'lock'],
  92. proxy: {
  93. type: 'ajax',
  94. url : basePath + 'ma/user/online.action',
  95. reader: {
  96. type: 'json',
  97. root: 'data'
  98. }
  99. },
  100. autoLoad: true,
  101. listeners: {
  102. load: function(store, items) {
  103. Ext.getCmp('online_count').setText('共' + items.length + '人在线');
  104. }
  105. }
  106. }),
  107. selModel: new Ext.selection.CellModel()
  108. }]
  109. });
  110. me.callParent(arguments);
  111. }
  112. });