SplitProdIODetail.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.reserve.SplitProdIODetail', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. GridUtil: Ext.create('erp.util.GridUtil'),
  6. BaseUtil: Ext.create('erp.util.BaseUtil'),
  7. views:[
  8. 'core.form.Panel','scm.reserve.SplitProdIODetail','core.grid.Panel2','core.toolbar.Toolbar',
  9. 'core.button.Save','core.button.Close','core.button.DeleteDetail',
  10. 'core.trigger.DbfindTrigger','core.trigger.TextAreaTrigger'
  11. ],
  12. init:function(){
  13. var me = this;
  14. this.control({
  15. 'erpGridPanel2': {
  16. itemclick: this.onGridItemClick
  17. },
  18. 'erpSaveButton':{
  19. click: function(btn){
  20. var grid = Ext.getCmp('grid'), items = grid.store.data.items;
  21. var bool = true;
  22. var inqty = 0, outqty = 0,
  23. qty = Number(Ext.getCmp('pd_inqty').value) + Number(Ext.getCmp('pd_outqty').value);
  24. Ext.Array.each(items, function(item) {
  25. if (!Ext.isEmpty(item.data['pd_inqty']) || !Ext.isEmpty(item.data['pd_outqty'])){
  26. if(Number(item.data['pd_inqty']) + Number(item.data['pd_outqty']) < Number(item.data['pd_yqty'])){
  27. bool = false;
  28. showError('分拆数量不能小于已转数量!') ;
  29. return;
  30. }
  31. inqty= inqty + Number(item.data['pd_inqty']);
  32. outqty= outqty + Number(item.data['pd_outqty']);
  33. }
  34. });
  35. if(qty!=inqty + outqty){
  36. bool = false;
  37. showError('分拆数量必须等于原数量!') ;
  38. return;
  39. }
  40. if(bool){
  41. this.FormUtil.beforeSave(this);
  42. }
  43. }
  44. },
  45. 'erpCloseButton': {
  46. click: function(btn){
  47. me.FormUtil.beforeClose(me);
  48. }
  49. },
  50. 'erpDeleteDetailButton': {
  51. afterrender:function(btn){
  52. btn.handler=function(){
  53. var sm = Ext.getCmp('grid').getSelectionModel();
  54. var record=sm.getSelection(), pd_id=record[0].data.pd_id;
  55. if(pd_id && pd_id != 0){
  56. Ext.Msg.alert('提示','不能删除已拆批次或原始行号!');
  57. return;
  58. }
  59. var store=Ext.getCmp('grid').getStore();
  60. store.remove(record);
  61. if (store.getCount() > 0) {
  62. sm.select(0);
  63. }
  64. };
  65. }
  66. },
  67. });
  68. },
  69. onGridItemClick: function(selModel, record){//grid行选择
  70. this.GridUtil.onGridItemClick(selModel, record);
  71. },
  72. getForm: function(btn){
  73. return btn.ownerCt.ownerCt;
  74. }
  75. });