OSInfoUpdate.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. /**
  2. * 委外信息修改按钮
  3. */
  4. Ext.define('erp.view.core.button.OSInfoUpdate',{
  5. extend : 'Ext.Button',
  6. alias : 'widget.erpOSInfoUpdateButton',
  7. iconCls : 'x-button-icon-submit',
  8. cls : 'x-btn-gray',
  9. text : $I18N.common.button.erpOSVendorUpdateButton,
  10. style : {
  11. marginLeft : '10px'
  12. },
  13. width : 140,
  14. initComponent : function() {
  15. this.callParent(arguments);
  16. this.BaseUtil = Ext.create('erp.util.BaseUtil');
  17. },
  18. listeners: {
  19. afterrender: function(btn) {
  20. var me = this;
  21. var status = Ext.getCmp('ma_statuscode'),
  22. checkstatus = Ext.getCmp('ma_checkstatuscode');
  23. if(status && (status.value == 'ENTERING' || status.value == 'FINISH')){
  24. btn.hide();
  25. }
  26. me.BaseUtil.getSetting('Make', 'updateInfoNeedApprove', function(bool) {
  27. if(bool) {
  28. if(checkstatus && checkstatus.value == 'APPROVE'){
  29. btn.hide();
  30. }
  31. }
  32. });
  33. }
  34. },
  35. handler: function() {
  36. var me = this, win = Ext.getCmp('Complaint-win');
  37. me.BaseUtil.getSetting('Make', 'osInfoEditable', function(editable) {
  38. if(!win) {
  39. var vc = Ext.getCmp('ma_vendcode'), vn = Ext.getCmp('ma_vendname'),
  40. pr = Ext.getCmp('ma_price'), cr = Ext.getCmp('ma_currency'),tr = Ext.getCmp('ma_taxrate'),
  41. pac = Ext.getCmp('ma_paymentscode'), pan = Ext.getCmp('ma_payments'),ser=Ext.getCmp('ma_servicer'),
  42. remark = Ext.getCmp('ma_remark').value,
  43. val1 = vc ? vc.value : '', val2 = vn ? vn.value : '', val3 = pr ? pr.value : '',
  44. val4 = cr ? cr.value : '', val5 = tr ? tr.value : '', val6 = pac ? pac.value : '',
  45. val7 = pan ? pan.value : '',val8 = ser ? ser.value : '',val9 = remark ? remark.value : '';
  46. win = Ext.create('Ext.Window', {
  47. id: 'Complaint-win',
  48. title: '更新委外单 ' + Ext.getCmp('ma_code').value + ' 的委外信息',
  49. height: 400,
  50. width: 400,
  51. items: [{
  52. xtype: 'form',
  53. height: '100%',
  54. width: '100%',
  55. bodyStyle: 'background:#f1f2f5;',
  56. items: [{
  57. margin: '10 0 0 0',
  58. xtype: 'dbfindtrigger',
  59. fieldLabel: '委外商号',
  60. name:'ma_vendcode',
  61. allowBlank: false,
  62. value: val1,
  63. listeners:{
  64. aftertrigger:function(t, d){
  65. t.ownerCt.down('textfield[name=ma_vendname]').setValue(d.get('ve_name'));
  66. t.ownerCt.down('textfield[name=ma_currency]').setValue(d.get('ve_currency'));
  67. t.ownerCt.down('textfield[name=ma_paymentscode]').setValue(d.get('ve_paymentcode'));
  68. t.ownerCt.down('textfield[name=ma_payments]').setValue(d.get('ve_payment'));
  69. }
  70. }
  71. },{
  72. margin: '3 0 0 0',
  73. xtype: 'textfield',
  74. fieldLabel: '委外商名',
  75. readOnly:true,
  76. name:'ma_vendname',
  77. allowBlank: false,
  78. value: val2
  79. },{
  80. margin: '3 0 0 0',
  81. xtype: 'dbfindtrigger',
  82. fieldLabel: '币别',
  83. name:'ma_currency',
  84. readOnly:false,
  85. allowBlank: false,
  86. value: val4
  87. },{
  88. margin: '3 0 0 0',
  89. xtype: 'textfield',
  90. fieldLabel: '税率',
  91. name:'ma_taxrate',
  92. readOnly:true,
  93. allowBlank: false,
  94. value: val5,
  95. listeners:{
  96. afterrender:function(t, d){
  97. t.ownerCt.down('textfield[name=ma_taxrate]').setReadOnly(!editable);
  98. }
  99. }
  100. },{
  101. margin: '3 0 0 0',
  102. xtype: 'textfield',
  103. fieldLabel: '加工单价',
  104. name:'ma_price',
  105. readOnly:false,
  106. allowBlank: false,
  107. value: val3,
  108. listeners:{
  109. afterrender:function(t, d){
  110. t.ownerCt.down('textfield[name=ma_price]').setReadOnly(!editable);
  111. }
  112. }
  113. },{
  114. margin: '3 0 0 0',
  115. xtype: 'erpYnField',
  116. fieldLabel: '是否免费加工',
  117. name:'ma_servicer',
  118. value: val8,
  119. hidden:!ser
  120. },{
  121. margin: '3 0 0 0',
  122. xtype: 'dbfindtrigger',
  123. fieldLabel: '付款方式编号',
  124. name:'ma_paymentscode',
  125. allowBlank: false,
  126. readOnly:false,
  127. value: val6,
  128. listeners:{
  129. afterrender:function(t, d){
  130. t.ownerCt.down('textfield[name=ma_paymentscode]').setReadOnly(!editable);
  131. },
  132. aftertrigger:function(t, d){
  133. t.ownerCt.down('textfield[name=ma_payments]').setValue(d.get('pa_name'));
  134. }
  135. }
  136. },{
  137. margin: '3 0 0 0',
  138. xtype: 'textfield',
  139. fieldLabel: '付款方式',
  140. name:'ma_payments',
  141. allowBlank: false,
  142. readOnly:true,
  143. value: val7
  144. },{
  145. margin: '3 0 0 0',
  146. xtype: 'textfield',
  147. name:'ma_remark',
  148. fieldLabel: '备注',
  149. value: val9
  150. }],
  151. closeAction: 'hide',
  152. buttonAlign: 'center',
  153. layout: {
  154. type: 'vbox',
  155. align: 'center'
  156. },
  157. buttons: [{
  158. text: "按供应商取价",
  159. cls: 'x-btn-blue',
  160. listeners:{
  161. afterrender:function(btn){
  162. me.BaseUtil.getSetting('Make', 'osInfoGetPriceByVendor', function(bool) {
  163. if(!bool) {
  164. btn.hide();
  165. }
  166. });
  167. }
  168. },
  169. handler: function(btn) {
  170. Ext.Ajax.request({
  171. url: basePath + '/scm/purchase/getVendorPrice.action',
  172. params: {
  173. id: Ext.getCmp('ma_id').value,
  174. vendcode: Ext.getCmp('ma_vendcode').value,
  175. curr: Ext.getCmp('ma_currency').value
  176. },
  177. callback: function(opt, s, r) {
  178. var rs = Ext.decode(r.responseText);
  179. if(rs.exceptionInfo) {
  180. showError(rs.exceptionInfo);
  181. } else {
  182. Ext.Msg.alert("提示","获取成功!");
  183. window.location.reload();
  184. }
  185. }
  186. });
  187. }
  188. },{
  189. text: $I18N.common.button.erpConfirmButton,
  190. cls: 'x-btn-blue',
  191. formBind: true,//form.isValid() == false时,按钮disabled
  192. listeners:{
  193. afterrender:function(btn){
  194. if(!editable) {
  195. btn.hide();
  196. }
  197. }
  198. },
  199. handler: function(btn) {
  200. var form = btn.ownerCt.ownerCt,
  201. a = form.down('dbfindtrigger[name=ma_vendcode]'),
  202. b = form.down('dbfindtrigger[name=ma_currency]'),
  203. c = form.down('textfield[name=ma_taxrate]'),
  204. d = form.down('textfield[name=ma_price]'),
  205. e = form.down('textfield[name=ma_paymentscode]'),
  206. f = form.down('textfield[name=ma_payments]');
  207. g = form.down('textfield[name=ma_servicer]');
  208. h = form.down('textfield[name=ma_remark]');
  209. if(!Ext.isNumeric(c.value)){
  210. showError("税率必须是数字");
  211. return ;
  212. }
  213. if(!Ext.isNumeric(d.value)){
  214. showError("单价必须是数字");
  215. return ;
  216. }
  217. if(form.getForm().isDirty()) {
  218. me.updateOSInfoVendor(Ext.getCmp('ma_id').value, a.value, b.value, c.value, d.value, e.value, f.value,g.value,h.value);
  219. }
  220. }
  221. }, {
  222. text: $I18N.common.button.erpCloseButton,
  223. cls: 'x-btn-blue',
  224. handler: function(btn) {
  225. btn.up('window').hide();
  226. }
  227. }]
  228. }]
  229. });
  230. }
  231. win.show();
  232. });
  233. },
  234. updateOSInfoVendor: function(id, val1, val2, val3, val4, val5, val6, ser, h, i) {
  235. Ext.Ajax.request({
  236. url: basePath + 'pm/make/updateOSInfoVendor.action',
  237. params: {
  238. id: id,
  239. vend: val1,
  240. curr: val2,
  241. taxr: val3,
  242. price: val4,
  243. paymc: val5,
  244. paym: val6,
  245. ma_servicer: ser,
  246. remark: h
  247. },
  248. callback: function(opt, s, r) {
  249. var rs = Ext.decode(r.responseText);
  250. if(rs.exceptionInfo) {
  251. showError(rs.exceptionInfo);
  252. } else {
  253. Ext.Msg.alert("提示","更新成功!");
  254. window.location.reload();
  255. }
  256. }
  257. });
  258. }
  259. });