OSUpdate.js 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  1. /**
  2. * 委外信息修改按钮
  3. */
  4. Ext.define('erp.view.core.button.OSUpdate',{
  5. extend : 'Ext.Button',
  6. alias : 'widget.erpOSUpdateButton',
  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. },
  17. listeners: {
  18. afterrender: function(btn) {
  19. var me = this;
  20. var res = me.getSetting('makeos.check'),
  21. status = Ext.getCmp('ma_statuscode'),
  22. checkstatus = Ext.getCmp('ma_checkstatus');
  23. if(status && status.value == 'ENTERING'){
  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 : [
  38. {"abbr":"光明委外", "name":"光明委外"},
  39. {"abbr":"白芒委外", "name":"白芒委外"}
  40. ]
  41. });
  42. if(!win) {
  43. var vc = Ext.getCmp('ma_vendcode'), vn = Ext.getCmp('ma_vendname'),
  44. pr = Ext.getCmp('ma_price'), cr = Ext.getCmp('ma_currency'),tr = Ext.getCmp('ma_taxrate'),
  45. pac = Ext.getCmp('ma_paymentscode'), pan = Ext.getCmp('ma_payments'),ser=Ext.getCmp('ma_servicer'),
  46. flowstyle = Ext.getCmp('ma_flowstyle').value,remark = Ext.getCmp('ma_remark').value,
  47. val1 = vc ? vc.value : '', val2 = vn ? vn.value : '', val3 = pr ? pr.value : '',
  48. val4 = cr ? cr.value : '', val5 = tr ? tr.value : '', val6 = pac ? pac.value : '',
  49. val7 = pan ? pan.value : '',val8 = ser ? ser.value : '',val9 = remark ? remark.value : '';
  50. win = Ext.create('Ext.Window', {
  51. id: 'Complaint-win',
  52. title: '更新委外单 ' + Ext.getCmp('ma_code').value + ' 的委外信息',
  53. height: 400,
  54. width: 400,
  55. items: [{
  56. xtype: 'form',
  57. height: '100%',
  58. width: '100%',
  59. bodyStyle: 'background:#f1f2f5;',
  60. items: [{
  61. margin: '10 0 0 0',
  62. xtype: 'dbfindtrigger',
  63. fieldLabel: '委外商号',
  64. name:'ma_vendcode',
  65. allowBlank: false,
  66. value: val1,
  67. listeners:{
  68. aftertrigger:function(t, d){
  69. t.ownerCt.down('textfield[name=ma_vendname]').setValue(d.get('ve_name'));
  70. t.ownerCt.down('textfield[name=ma_currency]').setValue(d.get('ppd_currency'));
  71. t.ownerCt.down('textfield[name=ma_taxrate]').setValue(d.get('ppd_rate'));
  72. t.ownerCt.down('textfield[name=ma_price]').setValue(d.get('ppd_price'));
  73. t.ownerCt.down('textfield[name=ma_paymentscode]').setValue(d.get('ve_paymentcode'));
  74. t.ownerCt.down('textfield[name=ma_payments]').setValue(d.get('ve_payment'));
  75. },
  76. afterrender:function(trigger){
  77. trigger.dbKey='ma_prodcode';
  78. trigger.mappingKey='ppd_prodcode';
  79. trigger.dbMessage='请先选物料编号!';
  80. }
  81. }
  82. },{
  83. margin: '3 0 0 0',
  84. xtype: 'textfield',
  85. fieldLabel: '委外商名',
  86. readOnly:true,
  87. name:'ma_vendname',
  88. allowBlank: false,
  89. value: val2
  90. },{
  91. margin: '3 0 0 0',
  92. xtype: 'dbfindtrigger',
  93. fieldLabel: '币别',
  94. name:'ma_currency',
  95. readOnly:true,
  96. allowBlank: false,
  97. value: val4
  98. },{
  99. margin: '3 0 0 0',
  100. xtype: 'textfield',
  101. fieldLabel: '税率',
  102. name:'ma_taxrate',
  103. readOnly:true,
  104. allowBlank: false,
  105. value: val5
  106. },{
  107. margin: '3 0 0 0',
  108. xtype: 'textfield',
  109. fieldLabel: '加工单价',
  110. name:'ma_price',
  111. readOnly:true,
  112. allowBlank: false,
  113. value: val3,
  114. listeners:{
  115. afterrender:function(t, d){
  116. var res = me.getSetting('makeos.price');
  117. if(res) {
  118. t.ownerCt.down('textfield[name=ma_price]').setReadOnly(true);
  119. }
  120. }
  121. }
  122. },{
  123. margin: '3 0 0 0',
  124. xtype: 'erpYnField',
  125. fieldLabel: '是否免费加工',
  126. name:'ma_servicer',
  127. value: val8,
  128. hidden:!ser
  129. },{
  130. margin: '3 0 0 0',
  131. xtype: 'dbfindtrigger',
  132. fieldLabel: '付款方式编号',
  133. name:'ma_paymentscode',
  134. allowBlank: false,
  135. readOnly:true,
  136. value: val6
  137. },{
  138. margin: '3 0 0 0',
  139. xtype: 'textfield',
  140. fieldLabel: '付款方式',
  141. name:'ma_payments',
  142. allowBlank: false,
  143. readOnly:true,
  144. value: val7
  145. },{
  146. margin: '3 0 0 0',
  147. xtype: 'combo',
  148. name:'ma_flowstyle',
  149. fieldLabel: '委外单位',
  150. store: states,
  151. queryMode: 'local',
  152. displayField: 'name',
  153. valueField: 'abbr',
  154. value:flowstyle
  155. },{
  156. margin: '3 0 0 0',
  157. xtype: 'textfield',
  158. name:'ma_remark',
  159. fieldLabel: '备注',
  160. value: val9
  161. }],
  162. closeAction: 'hide',
  163. buttonAlign: 'center',
  164. layout: {
  165. type: 'vbox',
  166. align: 'center'
  167. },
  168. buttons: [{
  169. text: "自动获取",
  170. cls: 'x-btn-blue',
  171. handler: function(btn) {
  172. Ext.Ajax.request({
  173. url: basePath + '/scm/purchase/getMakeVendorPrice.action',
  174. params: {
  175. id: Ext.getCmp('ma_id').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. handler: function(btn) {
  192. var form = btn.ownerCt.ownerCt,
  193. a = form.down('dbfindtrigger[name=ma_vendcode]'),
  194. b = form.down('dbfindtrigger[name=ma_currency]'),
  195. c = form.down('textfield[name=ma_taxrate]'),
  196. d = form.down('textfield[name=ma_price]'),
  197. e = form.down('textfield[name=ma_paymentscode]'),
  198. f = form.down('textfield[name=ma_payments]');
  199. g = form.down('textfield[name=ma_servicer]');
  200. h = form.down('textfield[name=ma_flowstyle]');
  201. i = form.down('textfield[name=ma_remark]');
  202. if(form.getForm().isDirty()) {
  203. me.updateOSVendor(Ext.getCmp('ma_id').value, a.value, b.value, c.value, d.value, e.value, f.value,g.value,h.value,i.value);
  204. }
  205. }
  206. }, {
  207. text: $I18N.common.button.erpCloseButton,
  208. cls: 'x-btn-blue',
  209. handler: function(btn) {
  210. btn.up('window').hide();
  211. }
  212. }]
  213. }]
  214. });
  215. }
  216. win.show();
  217. },
  218. updateOSVendor: function(id, val1, val2, val3, val4, val5, val6,ser,h,i) {
  219. Ext.Ajax.request({
  220. url: basePath + 'pm/make/updateOSVendor.action',
  221. params: {
  222. id: id,
  223. vend: val1,
  224. curr: val2,
  225. taxr: val3,
  226. price: val4,
  227. paymc: val5,
  228. paym: val6,
  229. ma_servicer: ser,
  230. maflowstyle:h,
  231. remark: i
  232. },
  233. callback: function(opt, s, r) {
  234. var rs = Ext.decode(r.responseText);
  235. if(rs.exceptionInfo) {
  236. showError(rs.exceptionInfo);
  237. } else {
  238. Ext.Msg.alert("提示","更新成功!");
  239. window.location.reload();
  240. }
  241. }
  242. });
  243. },
  244. getSetting: function(type) {
  245. var result = false;
  246. Ext.Ajax.request({
  247. url : basePath + 'common/getFieldData.action',
  248. async: false,
  249. params: {
  250. caller: 'Setting',
  251. field: 'se_value',
  252. condition: 'se_what=\'' + type + '\''
  253. },
  254. method : 'post',
  255. callback : function(opt, s, res){
  256. var r = new Ext.decode(res.responseText);
  257. if(r.exceptionInfo){
  258. showError(r.exceptionInfo);return;
  259. } else if(r.success && r.data){
  260. result = r.data == 'true';
  261. }
  262. }
  263. });
  264. return result;
  265. }
  266. });