SysrefreshGrid.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. Ext.define('erp.view.common.sysinit.SysrefreshGrid', {
  2. extend: 'Ext.grid.Panel',
  3. alias: 'widget.sysrefreshgrid',
  4. autoScroll: true,
  5. manageHeight: false,
  6. store:Ext.create('Ext.data.Store', {
  7. fields:['IC_DESCRIPTION','IC_URL'],
  8. }),
  9. columns:[{
  10. header:'刷新项',
  11. dataIndex:'IC_DESCRIPTION',
  12. flex:1
  13. },{
  14. header:'刷新路径',
  15. dataIndex:'IC_URL',
  16. width:0,
  17. },{
  18. text: '',
  19. dataIndex: 'check',
  20. flex: 0.3,
  21. renderer: function(val, meta, record) {
  22. meta.tdCls = val;
  23. return '';
  24. }
  25. },{
  26. menuDisabled: true,
  27. sortable: false,
  28. xtype: 'actioncolumn',
  29. width: 50,
  30. items: [{
  31. iconCls: 'refresh',
  32. tooltip: '刷新',
  33. text:'刷新',
  34. handler: function(grid, rowIndex, colIndex) {
  35. console.log(grid);
  36. grid.ownerCt.refreshItem(grid.ownerCt,rowIndex);
  37. }
  38. }]
  39. }],
  40. listeners:{
  41. afterrender:function(grid){
  42. Ext.defer(grid.loadStore(),600);
  43. }
  44. },
  45. initComponent : function() {
  46. var me = this;
  47. this.callParent();
  48. },
  49. refreshItem:function(grid,idx){
  50. console.log('sdsdd');
  51. var me = this, r;
  52. if(Ext.isNumber(idx)) {
  53. r = grid.store.getAt(idx);
  54. }
  55. r.set('check', 'loading');
  56. var action=r.get('IC_URL');
  57. console.log(action);
  58. Ext.Ajax.request({
  59. url: basePath + action,
  60. async:false,
  61. method: 'GET',
  62. timeout: 600000,
  63. callback: function(opt, s, re) {
  64. r.set('check', 'checked');
  65. grid.toggleRow(r);
  66. var rs = Ext.decode(re.responseText);
  67. if(rs.error) {
  68. r.set('check', 'error');
  69. }
  70. if(rs.result) {
  71. r.set('detail', rs.result);
  72. }
  73. if(Ext.isNumber(idx)) {
  74. me.check(grid, ++idx, btn);
  75. } else {
  76. btn.setDisabled(false);
  77. }
  78. }
  79. });
  80. },
  81. loadStore:function(){
  82. var me=this;
  83. Ext.Ajax.request({
  84. url : basePath + 'common/getFieldsDatas.action',
  85. params: {
  86. fields:'ic_description,ic_url',
  87. caller:'initcheckitem',
  88. condition:"ic_model='"+getUrlParam('whoami')+"'"
  89. },
  90. method : 'post',
  91. callback : function(options, success, response){
  92. var res = new Ext.decode(response.responseText);
  93. var data=Ext.decode(res.data);
  94. me.getStore().loadData(data);
  95. }
  96. });
  97. }
  98. });