UpdatePrLevel.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /**
  2. * 更新物料优选等级
  3. */
  4. Ext.define('erp.view.core.button.UpdatePrLevel', {
  5. extend : 'Ext.Button',
  6. alias : 'widget.erpUpdatePrLevelButton',
  7. iconCls : 'x-button-icon-submit',
  8. cls : 'x-btn-gray',
  9. text : '更新物料等级',
  10. style : {
  11. marginLeft : '10px'
  12. },
  13. width : 120,
  14. initComponent : function() {
  15. this.callParent(arguments);
  16. },
  17. listeners: {
  18. afterrender: function(btn) {
  19. var status = Ext.getCmp('pr_statuscode');
  20. if(status && status.value == 'ENTERING'){
  21. btn.hide();
  22. }
  23. }
  24. },
  25. handler: function() {
  26. var me = this, win = Ext.getCmp('prlevel-win');
  27. if(!win) {
  28. var f = Ext.getCmp('pr_level'),
  29. val = f ? f.value : '';
  30. win = Ext.create('Ext.Window', {
  31. id: 'prlevel-win',
  32. title: '更新物料等级',
  33. height: 200,
  34. width: 400,
  35. items: [{
  36. margin: '10 0 0 0',
  37. xtype: 'dbfindtrigger',
  38. name:'pr_level',
  39. fieldLabel: '物料等级',
  40. readOnly:false,
  41. allowBlank: false,
  42. value: val
  43. },
  44. {
  45. margin: '10 0 0 0',
  46. xtype: 'textfield',
  47. fieldLabel: '物料等级备注',
  48. name:'levelremark',
  49. value: ''
  50. }],
  51. closeAction: 'hide',
  52. buttonAlign: 'center',
  53. layout: {
  54. type: 'vbox',
  55. align: 'center'
  56. },
  57. buttons: [{
  58. text: $I18N.common.button.erpConfirmButton,
  59. cls: 'x-btn-blue',
  60. handler: function(btn) {
  61. var tx = btn.ownerCt.ownerCt.down('textfield[name=pr_level]');
  62. var remark=btn.ownerCt.ownerCt.down('textfield[name=levelremark]').value;
  63. if (remark==null || remark==''){
  64. showError('物料等级备注必须填写');
  65. return;
  66. }
  67. if((tx.isDirty() && !Ext.isEmpty(tx.value))) {
  68. me.updateProductLevel(Ext.getCmp('pr_id').value, tx.value,remark);
  69. }
  70. }
  71. }, {
  72. text: $I18N.common.button.erpCloseButton,
  73. cls: 'x-btn-blue',
  74. handler: function(btn) {
  75. btn.ownerCt.ownerCt.hide();
  76. }
  77. }]
  78. });
  79. }
  80. win.show();
  81. },
  82. updateProductLevel: function(id, val1,remark) {
  83. Ext.Ajax.request({
  84. url: basePath + 'scm/product/updateProductLevel.action',
  85. params: {
  86. id: id,
  87. value: val1 ,
  88. remark:remark
  89. },
  90. callback: function(opt, s, r) {
  91. var rs = Ext.decode(r.responseText);
  92. if(rs.exceptionInfo) {
  93. showError(rs.exceptionInfo);
  94. } else {
  95. alert('设置成功!');
  96. window.location.reload();
  97. }
  98. }
  99. });
  100. },
  101. getComboData:function(caller,field){
  102. var combodata=null;
  103. Ext.Ajax.request({
  104. url : basePath +'common/getComboDataByCallerAndField.action',
  105. params: {
  106. caller:caller,
  107. field:field
  108. },
  109. async: false,
  110. method : 'post',
  111. callback : function(options,success,response){
  112. var res = new Ext.decode(response.responseText);
  113. if(res.exceptionInfo != null){
  114. showError(res.exceptionInfo);
  115. return;
  116. }
  117. if(res.success){
  118. combodata=res.data;
  119. }
  120. }
  121. });
  122. if(combodata.length<1){
  123. this.add10EmptyData(combodata,caller, field);
  124. }
  125. return combodata;
  126. }
  127. });