ModifyVendInfoWin.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. Ext.define('make.view.osmake.osMake.ModifyVendInfoWin', {
  2. extend: 'Ext.window.Window',
  3. xtype: 'osmake-osmake-modifyvendinfowin',
  4. cls: 'x-window-dbfind',
  5. modal: true,
  6. width: 1000,
  7. minHeight: 300,
  8. scrollable: true,
  9. bodyPadding: 10,
  10. constrain: true,
  11. closable: true,
  12. layout: 'fit',
  13. title: '外协信息更新',
  14. viewModel: {
  15. data: {
  16. form : {
  17. id:null,
  18. ma_vendid:null,
  19. ma_vendcode:null,
  20. ma_vendname:null,
  21. ma_contact:null,
  22. ma_shipaddresscode:null,
  23. ma_tel:null,
  24. ma_paymentscode:null,
  25. ma_paymentsid:null,
  26. ma_payments:null,
  27. ma_currency:null,
  28. ma_taxrate:null,
  29. ma_taxprice:null,
  30. ma_ipdid:null
  31. }
  32. },
  33. },
  34. items: [{
  35. xtype: 'form',
  36. layout: 'column',
  37. autoScroll: true,
  38. buttonAlign : 'center',
  39. defaults:{
  40. columnWidth:0.3 ,
  41. margin: '0 0 10 0',
  42. labelAlign: 'right',
  43. labelWidth: 90
  44. },
  45. bodyPadding: '8 12 8 12',
  46. _saveUrl: '/api/make/make/modifyVendInfo',
  47. _getVendPrice:'/api/make/make/getVendPrice',
  48. items:[{
  49. xtype: 'hidden',
  50. name: 'id',
  51. fieldLabel: 'id',
  52. allowBlank: true,
  53. columnWidth: 0,
  54. bind:'{form.id}',
  55. },{
  56. xtype: "vendorDbfindTrigger",
  57. name: "ma_vendname",
  58. fieldLabel: "外协厂商",
  59. allowBlank: false,
  60. bind:'{form.ma_vendname}',
  61. }, {
  62. xtype: "hidden",
  63. name: "ma_vendid",
  64. fieldLabel: "外协厂商ID",
  65. bind:'{form.ma_vendid}',
  66. }, {
  67. xtype: "hidden",
  68. name: "ma_vendcode",
  69. fieldLabel: "外协厂商编号",
  70. bind:'{form.ma_vendcode}',
  71. },{
  72. xtype: "textfield",
  73. name: "ma_contact",
  74. fieldLabel: "联系人",
  75. bind:'{form.ma_contact}',
  76. }, {
  77. xtype: "textfield",
  78. name: "ma_shipaddresscode",
  79. fieldLabel: "交货地址",
  80. bind:'{form.ma_shipaddresscode}',
  81. },{
  82. xtype: "textfield",
  83. name: "ma_tel",
  84. fieldLabel: "联系电话",
  85. bind:'{form.ma_tel}',
  86. }, {
  87. xtype: 'hidden',
  88. name: 'ma_paymentscode',
  89. fieldLabel: '付款方式编号',
  90. bind:'{form.ma_paymentscode}',
  91. }, {
  92. xtype: 'hidden',
  93. fieldLabel: '付款方式编号',
  94. name: "ma_paymentsid",
  95. bind:'{form.ma_paymentsid}',
  96. },{
  97. xtype: "remotecombo",
  98. name: "ma_payments",
  99. fieldLabel: "付款方式",
  100. storeUrl:'/api/document/paymentspay/list/enable',
  101. valueField:'pa_name',
  102. displayField: 'pa_name',
  103. allowBlank: false,
  104. bind:'{form.ma_payments}',
  105. addHandler: function (b) {
  106. var document = Ext.create('saas.view.document.paymentspay.DataList', {});
  107. var form = this.ownerCmp.ownerCt;
  108. this.dialog = form.getController().getView().add({
  109. xtype: 'document-paymentspay-window',
  110. bind: {
  111. title: '新增付款方式'
  112. },
  113. dataKind: 'paymentspay',
  114. belong: document.etc['paymentspay'],
  115. _parent: form,
  116. _combo: this.ownerCmp,
  117. record: null,
  118. session: true
  119. });
  120. this.dialog.show();
  121. },
  122. editHandler:function(btn,type){
  123. saas.util.BaseUtil.openTab('document-paymentspay-datalist', '付款方式设置','maintab--document-paymentspay-datalist');
  124. var combo = btn.ownerCt.up('remotecombo');
  125. if(combo){
  126. combo.collapse();
  127. }
  128. }
  129. }, {
  130. xtype: 'hidden',
  131. name:'ma_tasktype',
  132. fieldLabel: '单据类型',
  133. allowBlank: false,
  134. defaultValue:'OS',
  135. bind:'{form.ma_tasktype}',
  136. },{
  137. xtype: 'currencyCombo',
  138. name:'ma_currency',
  139. fieldLabel: '币种',
  140. allowBlank: false,
  141. rateField:'ma_rate',
  142. bind:'{form.ma_currency}',
  143. },{
  144. xtype: 'hidden',
  145. fieldLabel: '汇率',
  146. name:'ma_rate',
  147. allowBlank: false,
  148. bind:'{form.ma_rate}',
  149. },{
  150. xtype: 'numberfield',
  151. fieldLabel: '税率',
  152. name:'ma_taxrate',
  153. allowBlank: true,
  154. bind:'{form.ma_taxrate}',
  155. },{
  156. xtype: 'numberfield',
  157. fieldLabel: '含税单价',
  158. name:'ma_taxprice',
  159. fixDecimal:false,
  160. decimalPrecision:8,
  161. bind:'{form.ma_taxprice}',
  162. thousandSeparator: ',',
  163. renderer: function (v){
  164. if(!v){
  165. v=0;
  166. }
  167. return '<p class="money-rtl"><B>'+saas.util.BaseUtil.numberFormat(v, 8, true)+''
  168. }
  169. },{
  170. xtype: 'numberfield',
  171. fieldLabel: '明细id',
  172. name:'ma_ipdid',
  173. hidden:true,
  174. bind:'{form.ma_ipdid}'
  175. },{
  176. xtype: 'numberfield',
  177. fieldLabel: 'qty',
  178. name:'ma_qty',
  179. hidden:true,
  180. bind:'{form.ma_qty}'
  181. },{
  182. xtype: 'textfield',
  183. fieldLabel: 'ma_prodcode',
  184. name:'ma_prodcode',
  185. hidden:true,
  186. bind:'{form.ma_prodcode}'
  187. }],
  188. buttons: [{
  189. text:'保存',
  190. disabled: true,
  191. formBind: true,
  192. handler:function(){
  193. this.up('window').onSave();
  194. }
  195. }, {
  196. text:'按供应商取价',
  197. disabled: true,
  198. formBind: true,
  199. bind: {
  200. disabled: '{form.ma_vendcode}'
  201. },
  202. handler:function(){
  203. this.up('window').getVendPrice(window);
  204. }
  205. },{
  206. text: '关闭',
  207. handler:function(){
  208. this.up('window').onClose();
  209. }
  210. }]
  211. }],
  212. initComponent: function () {
  213. var me = this;
  214. me.callParent();
  215. },
  216. /**
  217. * 保存
  218. */
  219. onSave: function(){
  220. var me = this,
  221. form = me.down('form'),
  222. vm = me.getViewModel();
  223. params = Ext.clone(vm.get('form'));
  224. form.setLoading(true);
  225. saas.util.BaseUtil.request({
  226. url: form._saveUrl,
  227. params: JSON.stringify(params),
  228. method: 'POST',
  229. })
  230. .then(function(localJson) {
  231. form.setLoading(false);
  232. if(localJson.success){
  233. //刷新查询页面
  234. saas.util.FormUtil.loadData(me._parent);
  235. saas.util.BaseUtil.showSuccessToast('保存成功');
  236. me.onClose();
  237. }
  238. })
  239. .catch(function(e) {
  240. form.setLoading(false);
  241. saas.util.BaseUtil.showErrorToast('保存失败: ' + e.message);
  242. });
  243. },
  244. getVendPrice:function(win){
  245. var me = this,
  246. form = me.down('form'),
  247. vm = me.getViewModel(),
  248. formparams = Ext.clone(vm.get('form'));
  249. if(!formparams.ma_vendcode){
  250. saas.util.BaseUtil.showErrorToast('请先选择供应商.');
  251. return false;
  252. }
  253. if(!formparams.ma_currency){
  254. saas.util.BaseUtil.showErrorToast('请先选择币别.');
  255. return false;
  256. }
  257. if(!formparams.ma_prodcode){
  258. saas.util.BaseUtil.showErrorToast('请先选择产品.');
  259. return false;
  260. }
  261. var params = {
  262. vendId:formparams.ma_vendid,
  263. currency:formparams.ma_currency,
  264. prodCode:formparams.ma_prodcode,
  265. qty:formparams.ma_qty
  266. };
  267. form.setLoading(true);
  268. saas.util.BaseUtil.request({
  269. url: form._getVendPrice,
  270. params: JSON.stringify(params),
  271. method: 'POST',
  272. })
  273. .then(function(localJson) {
  274. form.setLoading(false);
  275. if(localJson.success){
  276. //刷新查询页面
  277. if(localJson.data){
  278. if(localJson.data.ipdId){
  279. form.down('[name=ma_taxprice]').setValue(localJson.data.price);
  280. form.down('[name=ma_ipdid]').setValue(localJson.data.ipdId);
  281. saas.util.BaseUtil.showSuccessToast('取价成功');
  282. }else{
  283. form.down('[name=ma_ipdid]').setValue(-1);
  284. saas.util.BaseUtil.showSuccessToast('取价失败 无产品价格信息。');
  285. }
  286. }
  287. }
  288. })
  289. .catch(function(e) {
  290. form.setLoading(false);
  291. saas.util.BaseUtil.showErrorToast('保取价失败: ' + e.message);
  292. });
  293. },
  294. onClose:function(){
  295. this.close();
  296. }
  297. })