OSInfoVendReply.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /**
  2. * 委外信息修改按钮
  3. */
  4. Ext.define('erp.view.core.button.OSInfoVendReply',{
  5. extend : 'Ext.Button',
  6. alias : 'widget.erpOSInfoVendReplyButton',
  7. iconCls : 'x-button-icon-submit',
  8. cls : 'x-btn-gray',
  9. text : $I18N.common.button.erpOSInfoVendReplyButton,
  10. style : {
  11. marginLeft : '10px'
  12. },
  13. width : 140,
  14. initComponent : function() {
  15. this.callParent(arguments);
  16. },
  17. listeners: {
  18. afterrender: function(btn) {
  19. var me = this;
  20. //var res = me.getSetting('makeOSInfo.check'),
  21. status = Ext.getCmp('ma_statuscode'),
  22. checkstatus = Ext.getCmp('ma_checkstatus');
  23. if(status && (status.value == 'ENTERING' || status.value == 'FINISH')){
  24. btn.hide();
  25. }
  26. /*if(res) {
  27. if(checkstatus && checkstatus.value == 'APPROVE'){
  28. btn.hide();
  29. }
  30. }*/
  31. }
  32. },
  33. handler: function() {
  34. var me = this, win = Ext.getCmp('Complaint-win');
  35. var states = Ext.create('Ext.data.Store', {
  36. fields: ['abbr', 'name'],
  37. data : me.getFlowStyle()
  38. });
  39. if(!win) {
  40. var vc = Ext.getCmp('ma_vendorreplydate'), vn = Ext.getCmp('ma_replyqty'),
  41. pr = Ext.getCmp('ma_isok'), cr = Ext.getCmp('ma_vendorreply'),
  42. val1 = vc ? vc.value : '', val2 = vn ? vn.value : '', val3 = pr ? pr.value : '',
  43. val4 = cr ? cr.value : '';
  44. win = Ext.create('Ext.Window', {
  45. width: 430,
  46. height: 250,
  47. closeAction: 'destroy',
  48. cls: 'custom-blue',
  49. title: '<h1>更新供应商回信息</h1>',
  50. layout: {
  51. type: 'vbox'
  52. },
  53. items: [
  54. {
  55. margin: '5 0 0 5',
  56. xtype: 'datefield',
  57. fieldLabel: '回复交期',
  58. name: 'DELIVERYREPLY',
  59. format: 'Y-m-d',
  60. value: val1,
  61. id: 'DELIVERYREPLY'
  62. },
  63. {
  64. margin: '5 0 0 5',
  65. xtype: 'numberfield',
  66. fieldLabel: '回复数量',
  67. name: 'QTYREPLY',
  68. hideTrigger: true,
  69. value: val2,
  70. id: 'QTYREPLY'
  71. },{
  72. margin: '5 0 0 5',
  73. xtype: 'checkbox',
  74. columnidth: 0.4,
  75. fieldLabel: '能否按时交货',
  76. name: 'isok',
  77. value:val3,
  78. id: 'isok'
  79. },
  80. {
  81. margin: '5 0 0 5',
  82. xtype: 'textareatrigger',
  83. columnidth: 0.4,
  84. fieldLabel: '回复明细',
  85. name: 'replydetail',
  86. value:val4,
  87. id: 'replydetail'
  88. }
  89. ],
  90. buttonAlign: 'center',
  91. buttons: [{
  92. xtype: 'button',
  93. text: '保存',
  94. width: 60,
  95. iconCls: 'x-button-icon-save',
  96. handler: function(btn) {
  97. var w = btn.up('window');
  98. me.saveVendorInfo(w);
  99. win.close();
  100. win.destroy();
  101. }
  102. },
  103. {
  104. xtype: 'button',
  105. columnWidth: 0.1,
  106. text: '关闭',
  107. width: 60,
  108. iconCls: 'x-button-icon-close',
  109. margin: '0 0 0 10',
  110. handler: function(btn) {
  111. var win = btn.up('window');
  112. win.close();
  113. win.destroy();
  114. }
  115. }]
  116. });
  117. }
  118. win.show();
  119. },
  120. saveVendorInfo: function(w) {
  121. var deliveryreply = w.down('field[name=DELIVERYREPLY]').getValue();
  122. var qty = w.down('field[name=QTYREPLY]').getValue();
  123. if (!deliveryreply && !qty && !Ext.getCmp('replydetail').value) {
  124. showError('请先设置回复信息');
  125. return;
  126. } else {
  127. var isok = w.down('field[name=isok]').getValue();
  128. var dd = {
  129. ma_id:Ext.getCmp('ma_id').getValue() ,
  130. ma_replyqty: qty ? qty: 0,
  131. ma_vendorreplydate: deliveryreply ? Ext.Date.format(deliveryreply, 'Y-m-d') : null,
  132. ma_isok: isok ? '是': '否',
  133. ma_vendorreply:Ext.getCmp('replydetail').value
  134. };
  135. Ext.Ajax.request({
  136. url: basePath + 'pm/make/updateVendorInfo.action',
  137. params: {
  138. data: unescape(Ext.JSON.encode(dd)),
  139. caller: caller
  140. },
  141. method: 'post',
  142. callback: function(opt, s, res) {
  143. var r = new Ext.decode(res.responseText);
  144. if (r.success) {
  145. showMessage('提示', '更新成功!', 1000);
  146. window.location.reload();
  147. } else if (r.exceptionInfo) {
  148. showError(r.exceptionInfo);
  149. } else {
  150. saveFailure();
  151. }
  152. }
  153. });
  154. }
  155. },
  156. getFlowStyle: function() {
  157. var field = Ext.getCmp('ma_flowstyle'), datas = [];
  158. if(field && field.store) {
  159. field.store.each(function(item){
  160. datas.push({
  161. name: item.get('display'),
  162. abbr: item.get('value')
  163. });
  164. });
  165. }
  166. return datas;
  167. },
  168. getSetting: function(type) {
  169. var result = false;
  170. Ext.Ajax.request({
  171. url : basePath + 'common/getFieldData.action',
  172. async: false,
  173. params: {
  174. caller: 'Setting',
  175. field: 'se_value',
  176. condition: 'se_what=\'' + type + '\''
  177. },
  178. callback : function(opt, s, res){
  179. var r = new Ext.decode(res.responseText);
  180. if(r.exceptionInfo){
  181. showError(r.exceptionInfo);return;
  182. } else if(r.success && r.data){
  183. result = r.data == 'true';
  184. }
  185. }
  186. });
  187. return result;
  188. }
  189. });