UpdatePrLevel.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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: 'combo',
  38. name:'pr_level',
  39. fieldLabel: '优选等级',
  40. store: {
  41. fields: ['dlc_display', 'dlc_value'],
  42. data :[],
  43. },
  44. displayField: 'dlc_display',
  45. valueField: 'dlc_value',
  46. value:val,
  47. //queryMode: 'local',
  48. onTriggerClick:function(trigger){
  49. var combodata=me.getComboData('Product','pr_level');
  50. //这里写方法查找combo的数据
  51. this.getStore().loadData(combodata);
  52. this.expand();
  53. /*
  54. if (!me.readOnly && !me.disabled) {
  55. if (me.isExpanded) {
  56. me.collapse();
  57. } else {
  58. me.expand();
  59. }
  60. me.inputEl.focus();
  61. }
  62. */
  63. }
  64. },
  65. {
  66. margin: '10 0 0 0',
  67. xtype: 'textfield',
  68. fieldLabel: '优选等级备注',
  69. name:'levelremark',
  70. value: '',
  71. }],
  72. closeAction: 'hide',
  73. buttonAlign: 'center',
  74. layout: {
  75. type: 'vbox',
  76. align: 'center'
  77. },
  78. buttons: [{
  79. text: $I18N.common.button.erpConfirmButton,
  80. cls: 'x-btn-blue',
  81. handler: function(btn) {
  82. var tx = btn.ownerCt.ownerCt.down('combobox');
  83. var remark=btn.ownerCt.ownerCt.down('textfield[name=levelremark]').value;
  84. if (remark==null || remark==''){
  85. showError('优选等级备注必须填写');
  86. return;
  87. }
  88. if((tx.isDirty() && !Ext.isEmpty(tx.value))) {
  89. me.updateProductLevel(Ext.getCmp('pr_id').value, tx.value,remark);
  90. }
  91. }
  92. }, {
  93. text: $I18N.common.button.erpCloseButton,
  94. cls: 'x-btn-blue',
  95. handler: function(btn) {
  96. btn.ownerCt.ownerCt.hide();
  97. }
  98. }]
  99. });
  100. }
  101. win.show();
  102. },
  103. updateProductLevel: function(id, val1,remark) {
  104. Ext.Ajax.request({
  105. url: basePath + 'scm/product/updateProductLevel.action',
  106. params: {
  107. id: id,
  108. value: val1 ,
  109. remark:remark
  110. },
  111. callback: function(opt, s, r) {
  112. var rs = Ext.decode(r.responseText);
  113. if(rs.exceptionInfo) {
  114. showError(rs.exceptionInfo);
  115. } else {
  116. alert('设置成功!');
  117. window.location.reload();
  118. }
  119. }
  120. });
  121. },
  122. getComboData:function(caller,field){
  123. var combodata=null;
  124. Ext.Ajax.request({
  125. url : basePath +'common/getComboDataByCallerAndField.action',
  126. params: {
  127. caller:caller,
  128. field:field
  129. },
  130. async: false,
  131. method : 'post',
  132. callback : function(options,success,response){
  133. var res = new Ext.decode(response.responseText);
  134. if(res.exceptionInfo != null){
  135. showError(res.exceptionInfo);
  136. return;
  137. }
  138. if(res.success){
  139. combodata=res.data;
  140. }
  141. }
  142. });
  143. if(combodata.length<1){
  144. this.add10EmptyData(combodata,caller, field);
  145. }
  146. return combodata;
  147. }
  148. });