OSInfoUpdate.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. },
  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_vendcode'), vn = Ext.getCmp('ma_vendname'),
  41. pr = Ext.getCmp('ma_price'), cr = Ext.getCmp('ma_currency'),tr = Ext.getCmp('ma_taxrate'),
  42. pac = Ext.getCmp('ma_paymentscode'), pan = Ext.getCmp('ma_payments'),ser=Ext.getCmp('ma_servicer'),
  43. flowstyle = Ext.getCmp('ma_flowstyle').value,remark = Ext.getCmp('ma_remark').value,
  44. val1 = vc ? vc.value : '', val2 = vn ? vn.value : '', val3 = pr ? pr.value : '',
  45. val4 = cr ? cr.value : '', val5 = tr ? tr.value : '', val6 = pac ? pac.value : '',
  46. val7 = pan ? pan.value : '',val8 = ser ? ser.value : '',val9 = remark ? remark.value : '';
  47. win = Ext.create('Ext.Window', {
  48. id: 'Complaint-win',
  49. title: '更新委外单 ' + Ext.getCmp('ma_code').value + ' 的委外信息',
  50. height: 400,
  51. width: 400,
  52. items: [{
  53. xtype: 'form',
  54. height: '100%',
  55. width: '100%',
  56. bodyStyle: 'background:#f1f2f5;',
  57. items: [{
  58. margin: '10 0 0 0',
  59. xtype: 'dbfindtrigger',
  60. fieldLabel: '委外商号',
  61. name:'ma_vendcode',
  62. allowBlank: false,
  63. value: val1,
  64. listeners:{
  65. aftertrigger:function(t, d){
  66. t.ownerCt.down('textfield[name=ma_vendname]').setValue(d.get('ve_name'));
  67. t.ownerCt.down('textfield[name=ma_currency]').setValue(d.get('ve_currency'));
  68. t.ownerCt.down('textfield[name=ma_paymentscode]').setValue(d.get('ve_paymentcode'));
  69. t.ownerCt.down('textfield[name=ma_payments]').setValue(d.get('ve_payment'));
  70. }
  71. }
  72. },{
  73. margin: '3 0 0 0',
  74. xtype: 'textfield',
  75. fieldLabel: '委外商名',
  76. readOnly:true,
  77. name:'ma_vendname',
  78. allowBlank: false,
  79. value: val2
  80. },{
  81. margin: '3 0 0 0',
  82. xtype: 'dbfindtrigger',
  83. fieldLabel: '币别',
  84. name:'ma_currency',
  85. readOnly:false,
  86. allowBlank: false,
  87. value: val4
  88. },{
  89. margin: '3 0 0 0',
  90. xtype: 'textfield',
  91. fieldLabel: '税率',
  92. name:'ma_taxrate',
  93. readOnly:true,
  94. allowBlank: false,
  95. value: val5
  96. },{
  97. margin: '3 0 0 0',
  98. xtype: 'textfield',
  99. fieldLabel: '加工单价',
  100. name:'ma_price',
  101. readOnly:false,
  102. allowBlank: false,
  103. value: val3,
  104. listeners:{
  105. afterrender:function(t, d){
  106. var res = me.getSetting('makeOSInfo.save');
  107. if(res) {
  108. t.ownerCt.down('textfield[name=ma_price]').setReadOnly(true);
  109. }
  110. }
  111. }
  112. },{
  113. margin: '3 0 0 0',
  114. xtype: 'erpYnField',
  115. fieldLabel: '是否免费加工',
  116. name:'ma_servicer',
  117. value: val8,
  118. hidden:!ser,
  119. },{
  120. margin: '3 0 0 0',
  121. xtype: 'dbfindtrigger',
  122. fieldLabel: '付款方式编号',
  123. name:'ma_paymentscode',
  124. allowBlank: false,
  125. readOnly:false,
  126. value: val6,
  127. listeners:{
  128. afterrender:function(t, d){
  129. var res = me.getSetting('makeOSInfo.save');
  130. if(res) {
  131. t.ownerCt.down('textfield[name=ma_paymentscode]').setReadOnly(true);
  132. }
  133. },
  134. aftertrigger:function(t, d){
  135. t.ownerCt.down('textfield[name=ma_payments]').setValue(d.get('pa_name'));
  136. }
  137. },
  138. },{
  139. margin: '3 0 0 0',
  140. xtype: 'textfield',
  141. fieldLabel: '付款方式',
  142. name:'ma_payments',
  143. allowBlank: false,
  144. readOnly:true,
  145. value: val7
  146. },{
  147. margin: '3 0 0 0',
  148. xtype: 'combo',
  149. name:'ma_flowstyle',
  150. fieldLabel: '委外单位',
  151. store: states,
  152. queryMode: 'local',
  153. displayField: 'name',
  154. valueField: 'abbr',
  155. value:flowstyle,
  156. listeners:{
  157. afterrender:function(t, d){
  158. var res = me.getSetting('makeOSInfo.flowstyle');
  159. if(res) {
  160. t.ownerCt.down('textfield[name=ma_flowstyle]').hide();
  161. }
  162. }
  163. }
  164. },{
  165. margin: '3 0 0 0',
  166. xtype: 'textfield',
  167. name:'ma_remark',
  168. fieldLabel: '备注',
  169. value: val9
  170. }],
  171. closeAction: 'hide',
  172. buttonAlign: 'center',
  173. layout: {
  174. type: 'vbox',
  175. align: 'center'
  176. },
  177. buttons: [{
  178. text: "按供应商取价",
  179. cls: 'x-btn-blue',
  180. listeners:{
  181. afterrender:function(btn){
  182. var res = me.getSetting('makeOSInfo.price');
  183. if(res) {
  184. btn.hide();
  185. }
  186. }
  187. },
  188. handler: function(btn) {
  189. Ext.Ajax.request({
  190. url: basePath + '/scm/purchase/getVendorPrice.action',
  191. params: {
  192. id: Ext.getCmp('ma_id').value,
  193. vendcode: Ext.getCmp('ma_vendcode').value,
  194. curr: Ext.getCmp('ma_currency').value
  195. },
  196. callback: function(opt, s, r) {
  197. var rs = Ext.decode(r.responseText);
  198. if(rs.exceptionInfo) {
  199. showError(rs.exceptionInfo);
  200. } else {
  201. Ext.Msg.alert("提示","获取成功!");
  202. window.location.reload();
  203. }
  204. }
  205. });
  206. }
  207. },{
  208. text: $I18N.common.button.erpConfirmButton,
  209. cls: 'x-btn-blue',
  210. listeners:{
  211. afterrender:function(btn){
  212. var res = me.getSetting('makeOSInfo.save');
  213. if(res) {
  214. btn.hide();
  215. }
  216. }
  217. },
  218. handler: function(btn) {
  219. var form = btn.ownerCt.ownerCt,
  220. a = form.down('dbfindtrigger[name=ma_vendcode]'),
  221. b = form.down('dbfindtrigger[name=ma_currency]'),
  222. c = form.down('textfield[name=ma_taxrate]'),
  223. d = form.down('textfield[name=ma_price]'),
  224. e = form.down('textfield[name=ma_paymentscode]'),
  225. f = form.down('textfield[name=ma_payments]');
  226. g = form.down('textfield[name=ma_servicer]');
  227. h = form.down('textfield[name=ma_flowstyle]');
  228. i = form.down('textfield[name=ma_remark]');
  229. if(form.getForm().isDirty()) {
  230. me.updateOSInfoVendor(Ext.getCmp('ma_id').value, a.value, b.value, c.value, d.value, e.value, f.value,g.value,h.value,i.value);
  231. }
  232. }
  233. }, {
  234. text: $I18N.common.button.erpCloseButton,
  235. cls: 'x-btn-blue',
  236. handler: function(btn) {
  237. btn.up('window').hide();
  238. }
  239. }]
  240. }]
  241. });
  242. }
  243. win.show();
  244. },
  245. updateOSInfoVendor: function(id, val1, val2, val3, val4, val5, val6,ser,h,i) {
  246. Ext.Ajax.request({
  247. url: basePath + 'pm/make/updateOSInfoVendor.action',
  248. params: {
  249. id: id,
  250. vend: val1,
  251. curr: val2,
  252. taxr: val3,
  253. price: val4,
  254. paymc: val5,
  255. paym: val6,
  256. ma_servicer: ser,
  257. maflowstyle:h,
  258. remark: i
  259. },
  260. callback: function(opt, s, r) {
  261. var rs = Ext.decode(r.responseText);
  262. if(rs.exceptionInfo) {
  263. showError(rs.exceptionInfo);
  264. } else {
  265. Ext.Msg.alert("提示","更新成功!");
  266. window.location.reload();
  267. }
  268. }
  269. });
  270. },
  271. getFlowStyle: function() {
  272. var field = Ext.getCmp('ma_flowstyle'), datas = [];
  273. if(field && field.store) {
  274. field.store.each(function(item){
  275. datas.push({
  276. name: item.get('display'),
  277. abbr: item.get('value')
  278. });
  279. });
  280. }
  281. return datas;
  282. },
  283. getSetting: function(type) {
  284. var result = false;
  285. Ext.Ajax.request({
  286. url : basePath + 'common/getFieldData.action',
  287. async: false,
  288. params: {
  289. caller: 'Setting',
  290. field: 'se_value',
  291. condition: 'se_what=\'' + type + '\''
  292. },
  293. callback : function(opt, s, res){
  294. var r = new Ext.decode(res.responseText);
  295. if(r.exceptionInfo){
  296. showError(r.exceptionInfo);return;
  297. } else if(r.success && r.data){
  298. result = r.data == 'true';
  299. }
  300. }
  301. });
  302. return result;
  303. }
  304. });