OSVendorUpdate.js 7.3 KB

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