MakeCommon.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.pm.make.MakeCommon', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil'],
  5. views:[
  6. 'core.form.Panel','pm.make.MakeCommon','core.grid.Panel2','core.toolbar.Toolbar',
  7. 'core.button.Save','core.button.Add','core.button.Close','core.button.Delete','core.button.Update','core.button.DeleteDetail',
  8. 'core.trigger.DbfindTrigger','core.button.SetMain'
  9. ],
  10. init:function(){
  11. var me = this;
  12. me.FormUtil = Ext.create('erp.util.FormUtil');
  13. me.GridUtil = Ext.create('erp.util.GridUtil');
  14. me.BaseUtil = Ext.create('erp.util.BaseUtil');
  15. this.control({
  16. 'erpGridPanel2': {
  17. afterrender: function(grid){
  18. grid.setReadOnly(true);
  19. },
  20. itemclick:me.ItemClick
  21. },
  22. 'erpSaveButton' :{
  23. click:function(btn){
  24. this.FormUtil.beforeSave(this);
  25. }
  26. },
  27. 'erpDeleteButton': {
  28. click: function(btn){
  29. if(caller=='MakeBase!Sub'){
  30. //需要传多个参数所以借用下update 方法
  31. this.FormUtil.onUpdate(this);
  32. }
  33. },
  34. afterrender:function(btn){
  35. btn.setDisabled(true);
  36. }
  37. },
  38. 'erpCloseButton':{
  39. click:function(btn){
  40. parent.Ext.getCmp('win').close();
  41. }
  42. },
  43. 'erpAddButton': {
  44. click: function(){
  45. if(caller=='MakeBase!Sub'){
  46. Ext.getCmp('deletebutton').setDisabled(true);
  47. Ext.getCmp('mp_detno').setValue("");
  48. Ext.getCmp('mp_prodcode').setValue("");
  49. Ext.getCmp('pr_detail').setValue("");
  50. Ext.getCmp('pr_spec').setValue("");
  51. Ext.getCmp('mp_canuseqty').setValue("");
  52. Ext.getCmp('mp_warehouseid').setValue("");
  53. Ext.getCmp('mp_remark').setValue("");
  54. }
  55. },
  56. afterrender:function(){
  57. if(caller=='MakeBase!Sub'){
  58. Ext.getCmp('mp_detno').setValue("");
  59. Ext.getCmp('mp_prodcode').setValue("");
  60. Ext.getCmp('pr_detail').setValue("");
  61. Ext.getCmp('pr_spec').setValue("");
  62. Ext.getCmp('mp_canuseqty').setValue("");
  63. Ext.getCmp('mp_warehouseid').setValue("");
  64. Ext.getCmp('mp_remark').setValue("");
  65. }
  66. }
  67. },
  68. 'erpSetMainButton':{
  69. click:function(btn){
  70. if(caller=='MakeBase!Sub'){
  71. Ext.Ajax.request({
  72. url : basePath + 'pm/make/setMain.action',
  73. params: {
  74. mmid:Ext.getCmp('mm_id').value,
  75. detno:Ext.getCmp('mp_detno').value
  76. },
  77. method : 'post',
  78. callback : function(options,success,response){
  79. var localJson = new Ext.decode(response.responseText);
  80. if(localJson.exceptionInfo){
  81. showError(localJson.exceptionInfo);
  82. } else {
  83. if(localJson.success){
  84. parent.Ext.getCmp('win').close();
  85. parent.window.location.reload();
  86. }
  87. }
  88. }
  89. });
  90. }
  91. }
  92. }
  93. });
  94. },
  95. getForm: function(btn){
  96. return btn.ownerCt.ownerCt;
  97. },
  98. ItemClick:function(view ,record){
  99. if(record.data["mp_prodcode"]!='' && record.data["mp_prodcode"]!=null){
  100. if(caller=='MakeBase!Sub'){
  101. Ext.getCmp('deletebutton').setDisabled(false);
  102. var form=view.ownerCt.ownerCt.items.items[0];
  103. form.getForm().setValues(record.data);
  104. }
  105. }
  106. }
  107. });