GridPage.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.pm.make.GridPage', {
  3. extend: 'Ext.app.Controller',
  4. GridUtil: Ext.create('erp.util.GridUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'common.GridPage','core.grid.Panel4','core.toolbar.Toolbar3',
  8. 'core.button.Save','core.button.Add','core.button.Submit','core.button.Print','core.button.Upload',
  9. 'core.button.ResAudit','core.button.Audit','core.button.Close','core.button.Delete','core.button.Close',
  10. 'core.button.Update','core.button.DeleteDetail','core.button.ResSubmit','core.button.Scan',
  11. 'core.trigger.DbfindTrigger', 'core.grid.YnColumn','core.form.MonthDateField','core.button.BankInit'
  12. ],
  13. init:function(){
  14. this.control({
  15. 'erpGridPanel4': {
  16. reconfigure: function(g) {
  17. var grid = Ext.getCmp('grid');
  18. if(grid.store.data.items[0].data['mf_code']==''){
  19. return;
  20. }
  21. var codes = Ext.Array.concate(grid.store.data.items, ',', 'mf_code');
  22. Ext.Ajax.request({
  23. url : basePath + "pm/make/checkmfcode.action",
  24. params: {
  25. mf_code: codes
  26. },
  27. method : 'post',
  28. callback : function(options,success,response){
  29. grid.setLoading(false);
  30. var res = new Ext.decode(response.responseText);
  31. if(!res.success){
  32. var data = res.data;
  33. grid.store.each(function(item){
  34. Ext.each(data, function(d){
  35. if(d == item.get('mf_code')) {
  36. item.readonly = true;
  37. }
  38. });
  39. });
  40. };
  41. }
  42. });
  43. g.plugins[0].on('beforeedit', function(args){
  44. return !args.record.readonly;
  45. });
  46. },
  47. itemclick: function(selModel, record) {
  48. this.onGridItemClick(selModel, record);
  49. }
  50. },
  51. 'erpSaveButton': {
  52. click: function(btn){
  53. var grid = Ext.getCmp('grid');
  54. var items = grid.store.data.items;
  55. var num=0;
  56. Ext.each(items, function(item){
  57. if(item.data[grid.necessaryField] != null && item.data[grid.necessaryField] != ''){
  58. item.set('mf_maid', parent.Ext.getCmp('ma_id').value);
  59. num =num+item.data['mf_qty'];
  60. }
  61. });
  62. if(num>parent.Ext.getCmp('ma_qty').value){
  63. showError("数量总数超过制造单总数!");
  64. return;
  65. }
  66. var data = grid.getGridStore();
  67. grid.setLoading(true);
  68. Ext.Ajax.request({
  69. url : basePath + (btn.url || grid.saveUrl),
  70. params: {
  71. gridStore: "[" + data.toString() + "]"
  72. },
  73. method : 'post',
  74. callback : function(options,success,response){
  75. grid.setLoading(false);
  76. var res = new Ext.decode(response.responseText);
  77. if(res.exceptionInfo){
  78. showError(res.exceptionInfo);return;
  79. }
  80. if(res.success){
  81. saveSuccess(function(){
  82. window.location.href = window.location.href;
  83. });
  84. };
  85. }
  86. });
  87. }
  88. },
  89. 'erpDeleteButton': {
  90. click: function(btn){
  91. this.GridUtil.deleteDetailForEditGrid(btn);
  92. }
  93. },
  94. 'erpCloseButton': {
  95. click: function(btn){
  96. this.FormUtil.beforeClose(this);
  97. }
  98. },
  99. 'erpBankInitButton': {
  100. click: function(btn){
  101. var grid = Ext.getCmp('grid');
  102. var data = grid.getGridStore();
  103. grid.setLoading(true);
  104. Ext.Ajax.request({
  105. url : basePath + btn.url,
  106. params: {
  107. gridStore: "[" + data.toString() + "]"
  108. },
  109. method : 'post',
  110. callback : function(options,success,response){
  111. grid.setLoading(false);
  112. var res = new Ext.decode(response.responseText);
  113. if(res.exceptionInfo){
  114. showError(res.exceptionInfo);return;
  115. }
  116. if(res.success){
  117. saveSuccess(function(){
  118. window.location.href = window.location.href;
  119. });
  120. };
  121. }
  122. });
  123. }
  124. }
  125. });
  126. },
  127. onGridItemClick: function(selModel, record){//grid行选择
  128. this.GridUtil.onGridItemClick(selModel, record);
  129. },
  130. getGrid: function(btn){
  131. return btn.ownerCt.ownerCt;
  132. }
  133. });