ShiftCheck.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.ma.ShiftCheck', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.BaseUtil'],
  5. views: ['ma.ShiftCheck'],
  6. init:function(){
  7. this.BaseUtil = Ext.create('erp.util.BaseUtil');
  8. this.control({
  9. 'button[id=check]': {
  10. click: function(btn) {
  11. var grid = btn.ownerCt.ownerCt;
  12. grid.store.each(function(r){
  13. r.set('check', '');
  14. });
  15. btn.setDisabled(true);
  16. this.check(grid, 0, btn);
  17. }
  18. },
  19. 'button[id=close]': {
  20. click: function() {
  21. this.BaseUtil.getActiveTab().close();
  22. }
  23. }
  24. });
  25. },
  26. check: function(grid, idx, btn) {
  27. var me =this,f = grid.store.getAt(idx);
  28. if(!f) {
  29. btn.setDisabled(false);
  30. return;
  31. }
  32. f.set('check', 'loading');
  33. var win = Ext.getCmp('win-' + f.get('type'));
  34. if(win) {
  35. win.destroy();
  36. }
  37. Ext.Ajax.request({
  38. url: basePath + f.get('action'),
  39. params: {
  40. type: f.get('type')
  41. },
  42. callback: function(opt, s, r) {
  43. me.check(grid, ++idx, btn);
  44. var rs = Ext.decode(r.responseText);
  45. if(rs.ok) {
  46. f.set('check', 'checked');
  47. } else {
  48. f.set('check', 'error');
  49. }
  50. }
  51. });
  52. }
  53. });