Batch.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.reserve.Batch', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'scm.reserve.Batch','core.form.Panel',
  8. 'core.button.Audit','core.button.Save','core.button.Close',
  9. 'core.button.Upload','core.button.Update','core.button.Delete',
  10. 'core.trigger.TextAreaTrigger','core.trigger.DbfindTrigger','core.form.YnField',
  11. 'core.form.FileField'
  12. ],
  13. init:function(){
  14. this.control({
  15. 'erpFormPanel' : {
  16. afterload : function(form) {
  17. form.getForm().getFields().each(function() {
  18. var val = getUrlParam(this.name);
  19. if(!Ext.isEmpty(val)) {
  20. this.setValue(val);
  21. }
  22. });
  23. var t = form.down('#ba_kind');
  24. this.hidecolumns(t);
  25. }
  26. },
  27. 'erpCloseButton': {
  28. click: function(btn){
  29. var kind = Ext.getCmp('ba_kind').value;
  30. if(kind == ''){
  31. }
  32. this.FormUtil.beforeClose(this);
  33. }
  34. },
  35. 'erpUpdateButton': {
  36. click: function(btn){
  37. var kind = Ext.getCmp('ba_kind').value;
  38. if(kind == '10'){
  39. Ext.getCmp('ba_barcode').setValue(null);
  40. } else if (kind == '20') {
  41. Ext.getCmp('ba_salecode').setValue(null);
  42. } else {
  43. Ext.getCmp('ba_barcode').setValue(null);
  44. Ext.getCmp('ba_salecode').setValue(null);
  45. }
  46. this.FormUtil.onUpdate(this);
  47. }
  48. },
  49. 'combo[name=ba_kind]': {
  50. delay: 200,
  51. change: function(m){
  52. this.hidecolumns(m);
  53. var f = m.ownerCt, s = f.down('field[name=ba_salecode]'),
  54. c = f.down('field[name=ba_barcode]');
  55. if (s) {
  56. if(m.value == '10') {
  57. s.allowBlank = false;
  58. } else {
  59. s.allowBlank = true;
  60. }
  61. }
  62. if (c) {
  63. if(m.value == '20') {
  64. c.allowBlank = false;
  65. } else {
  66. c.allowBlank = true;
  67. }
  68. }
  69. }
  70. },
  71. });
  72. },
  73. getForm: function(btn){
  74. return btn.ownerCt.ownerCt;
  75. },
  76. hidecolumns:function(m){
  77. if(!Ext.isEmpty(m.getValue())) {
  78. var form = m.ownerCt;
  79. if(m.value == 10){
  80. form.down('#ba_salecode').show();
  81. form.down('#ba_barcode').hide();
  82. } else if(m.value == 20){
  83. form.down('#ba_salecode').hide();
  84. form.down('#ba_barcode').show();
  85. }else{
  86. form.down('#ba_salecode').hide();
  87. form.down('#ba_barcode').hide();
  88. }
  89. }
  90. }
  91. });