BoxCodeTrigger.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * 自动获取包装箱号的trigger
  3. */
  4. Ext.define('erp.view.core.trigger.BoxCodeTrigger', {
  5. extend: 'Ext.form.field.Trigger',
  6. alias: 'widget.boxcodetrigger',
  7. triggerCls: 'x-form-autocode-trigger',
  8. afterrender: function() {
  9. this.addEvent({
  10. 'beforetrigger': true
  11. });
  12. },
  13. onTriggerClick: function() {
  14. warnMsg('确定生成包装箱号?', function(btn){
  15. if(btn == 'yes'){
  16. var pa_totalqty = Ext.getCmp("pa_totalqty").value, mc_makecode = Ext.getCmp("mc_makecode").value,
  17. mc_prodcode = Ext.getCmp("mc_prodcode").value , pr_id = Ext.getCmp("pr_id").value,
  18. sc_code = Ext.getCmp("sc_code").value,result = Ext.getCmp('t_result');
  19. if(Ext.isEmpty(sc_code)){
  20. showError('请先指定资源编号!');
  21. return ;
  22. }else if(Ext.isEmpty(mc_makecode)){
  23. showError('请先指定制造单号!');
  24. return ;
  25. }else if(Ext.isEmpty(pa_totalqty) || pa_totalqty == 0 || pa_totalqty == '0'){
  26. showError("箱内容量不允许为空或者零!");
  27. return ;
  28. }
  29. Ext.Ajax.request({//拿到grid的columns
  30. url : basePath + "pm/mes/generatePackage.action",
  31. params: {
  32. pa_totalqty : pa_totalqty, //箱内容量
  33. pa_prodcode : mc_prodcode, //物料编号
  34. pr_id : pr_id, //物料ID
  35. pa_makecode : mc_makecode //制造单号
  36. },
  37. method : 'post',
  38. callback : function(options,success,response){
  39. var res = new Ext.decode(response.responseText);
  40. if(res.exceptionInfo){
  41. result.append(res.exceptionInfo,'error');
  42. showError(res.exceptionInfo);return;
  43. }
  44. var data = res.data;
  45. if(data ){//设置包装箱号
  46. result.append('生成箱号:'+data['pa_code']+'成功!');
  47. Ext.MessageBox.alert('系统提示', '生成箱号成功!');
  48. Ext.getCmp("pa_code").setValue(data.pa_code);
  49. Ext.getCmp("pa_restqty").setValue(data['pa_totalqty']);
  50. }
  51. }
  52. });
  53. } else {
  54. return;
  55. }
  56. });
  57. }
  58. });