FormPanelController.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. Ext.define('saas.view.sale.saleout.FormPanelController', {
  2. extend: 'saas.view.core.form.FormPanelController',
  3. alias: 'controller.sale-saleout-formpanel',
  4. init: function (form) {
  5. var me = this;
  6. this.control({
  7. //放大镜赋值关系 以及 tpl模板
  8. 'dbfindtrigger[name=pi_custname]':{
  9. beforerender:function(f){
  10. Ext.apply(f,{
  11. dbfinds:[
  12. {
  13. from:'id',to:'pi_custid',ignore:true
  14. },{
  15. from:'cu_code',to:'pi_custcode'
  16. },{
  17. from:'cu_name',to:'pi_custname'
  18. },{
  19. from:'ca_address',to:'pi_address'
  20. },{
  21. from:'cu_currency',to:'pi_currency'
  22. },{
  23. from:'cr_rate',to:'pi_rate'
  24. }],
  25. }) ;
  26. }
  27. },
  28. 'multidbfindtrigger[name=pd_prodcode]':{
  29. beforerender:function(f){
  30. Ext.apply(f,{
  31. dbfinds:[{
  32. from:'id',to:'pd_prodid',ignore:true
  33. }, {
  34. from:'pr_code',to:'pd_prodcode'
  35. }, {
  36. from:'pr_detail',to:'pr_detail'
  37. }, {
  38. from:'pr_spec',to:'pr_spec'
  39. },{
  40. from: 'pr_brand', to: 'pr_brand'
  41. },{
  42. from: 'pr_orispeccode', to: 'pr_orispeccode'
  43. },{
  44. from: 'pr_unit', to: 'pr_unit'
  45. }, {
  46. from:'pr_whid',to:'pd_whid'
  47. }, {
  48. from:'pr_whcode',to:'pd_whcode'
  49. }, {
  50. from:'pr_whname',to:'pd_whname'
  51. }, {
  52. from:'pr_saleprice',to:'pd_sendprice'
  53. }],
  54. }) ;
  55. }
  56. },
  57. 'dbfindtrigger[name=pd_whname]':{
  58. beforerender:function(f){
  59. Ext.apply(f,{
  60. dbfinds:[{
  61. from:'id',to:'pd_whid',ignore:true
  62. }, {
  63. from:'wh_code',to:'pd_whcode'
  64. }, {
  65. from:'wh_description',to:'pd_whname'
  66. }],
  67. }) ;
  68. }
  69. },
  70. 'dbfindtrigger[name=pi_seller]': {
  71. beforerender: function (f) {
  72. Ext.apply(f, {
  73. dbfinds: [{
  74. from: 'id',
  75. to: 'pi_sellerid',
  76. ignore: true
  77. }, {
  78. from: 'em_code',
  79. to: 'pi_sellercode'
  80. }, {
  81. from: 'em_name',
  82. to: 'pi_seller'
  83. }],
  84. });
  85. }
  86. },
  87. 'remotecombo[name=pi_address]':{
  88. focus:function(f){
  89. //获取客户ID
  90. var pi_custid = f.ownerCt.down('[name=pi_custid]').value;
  91. if(pi_custid&&pi_custid!=""){
  92. Ext.apply(f.store.proxy.extraParams, {
  93. id:pi_custid
  94. });
  95. f.store.load();
  96. }else{
  97. saas.util.BaseUtil.showErrorToast('请先选择客户后在维护交货地址');
  98. f.setDisabled(true);
  99. }
  100. },
  101. expand:function(f){
  102. if(f.picker&&f.isExpanded){
  103. f.picker.setHeight(33*f.store.getCount())
  104. }
  105. }
  106. },
  107. // 'currencyDbfindTrigger[name=pi_currency]':{
  108. // beforerender:function(f){
  109. // Ext.apply(f,{
  110. // dbfinds:[{
  111. // from:'cr_name',to:'pi_currency'
  112. // },{
  113. // from:'cr_rate',to:'pi_rate'
  114. // }],
  115. // }) ;
  116. // }
  117. // },
  118. });
  119. },
  120. turnProdIn: function() {
  121. var me = this,
  122. form = me.getView(),
  123. id = form.getForm().findField(form._idField);
  124. form.setLoading(true);
  125. saas.util.BaseUtil.request({
  126. url: form._turnInUrl + '/' + id.value,
  127. method: 'POST',
  128. })
  129. .then(function(localJson) {
  130. form.setLoading(false);
  131. if(localJson.success){
  132. var intValue = localJson.data.id,
  133. codeValue= localJson.data.code,
  134. name = localJson.data.name;
  135. saas.util.BaseUtil.openTab('sale-salein-formpanel',name+"("+codeValue+")",codeValue+intValue, {
  136. initId: intValue
  137. });
  138. saas.util.BaseUtil.showSuccessToast('转单成功');
  139. saas.util.FormUtil.loadData(form);
  140. }
  141. })
  142. .catch(function(e) {
  143. form.setLoading(false);
  144. saas.util.BaseUtil.showErrorToast('转单失败: ' + e.message);
  145. });
  146. }
  147. });