userGroupPower.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.ma.userGroupPower', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil'],
  5. views:[
  6. 'ma.userGroup.userGroupForm','ma.userGroup.userGroupGrid','core.trigger.DbfindTrigger'
  7. ],
  8. init:function(){
  9. var me = this;
  10. me.FormUtil = Ext.create('erp.util.FormUtil');
  11. me.BaseUtil = Ext.create('erp.util.BaseUtil');
  12. this.control({
  13. '#query':{
  14. click:function(){
  15. me.onQuery();
  16. }
  17. },
  18. '#save':{
  19. click:function(){
  20. me.save();
  21. }
  22. },
  23. 'field[name=eg_groupcode]':{
  24. aftertrigger:function(f){
  25. me.onQuery();
  26. }
  27. },
  28. '#sn_module':{
  29. select:function(){
  30. me.onQuery(true);
  31. }
  32. }
  33. });
  34. },
  35. onQuery:function(bool){
  36. var me = this;
  37. var eg_groupcode = Ext.getCmp('eg_groupcode').value;
  38. if(eg_groupcode==null || eg_groupcode == ''){
  39. if(!bool){
  40. showError('请先选择用户组!');
  41. }
  42. return;
  43. }
  44. var sn_module = Ext.getCmp('sn_module').value;
  45. var param;
  46. me.FormUtil.setLoading(true);
  47. Ext.Ajax.request({
  48. url : basePath + 'ma/queryCSPower.action',
  49. params: {
  50. eg_groupcode: eg_groupcode,
  51. sn_module : sn_module||''
  52. },
  53. method : 'post',
  54. callback : function(options,success,response){
  55. me.FormUtil.setLoading(false);
  56. var localJson = new Ext.decode(response.responseText);
  57. if(localJson.success){
  58. Ext.getCmp('grid').getStore().loadData(localJson.data);
  59. } else if(localJson.exceptionInfo){
  60. showError(localJson.exceptionInfo);
  61. return;
  62. }
  63. }
  64. });
  65. },
  66. save:function(){
  67. var me = this, grid = Ext.getCmp('grid');
  68. var eg_groupcode = Ext.getCmp('eg_groupcode').value;
  69. if(eg_groupcode==null || eg_groupcode == ''){
  70. showError('用户组必填!');
  71. return;
  72. }
  73. var param = grid.GridUtil.getGridStore();
  74. if(param==null || param == ''){
  75. showError('还未做任何修改!');
  76. return;
  77. }
  78. me.FormUtil.setLoading(true);
  79. Ext.Ajax.request({
  80. url : basePath + 'ma/saveCSPower.action',
  81. params: {
  82. groupcode: eg_groupcode,
  83. params: param
  84. },
  85. method : 'post',
  86. callback : function(options,success,response){
  87. me.FormUtil.setLoading(false);
  88. var localJson = new Ext.decode(response.responseText);
  89. if(localJson.success){
  90. Ext.Msg.alert('提示','保存成功',function(){
  91. me.onQuery();
  92. })
  93. } else if(localJson.exceptionInfo){
  94. showError(localJson.exceptionInfo);
  95. return;
  96. }
  97. }
  98. });
  99. }
  100. });