FormPanelController.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. }) ;
  22. }
  23. },
  24. 'multidbfindtrigger[name=pd_prodcode]':{
  25. beforerender:function(f){
  26. Ext.apply(f,{
  27. dbfinds:[{
  28. from:'id',to:'pd_prodid',ignore:true
  29. }, {
  30. from:'pr_code',to:'pd_prodcode'
  31. }, {
  32. from:'pr_detail',to:'pr_detail'
  33. }, {
  34. from:'pr_spec',to:'pr_spec'
  35. },{
  36. from: 'pr_brand', to: 'pr_brand'
  37. },{
  38. from: 'pr_orispeccode', to: 'pr_orispeccode'
  39. },{
  40. from: 'pr_unit', to: 'pr_unit'
  41. }, {
  42. from:'pr_whid',to:'pd_whid'
  43. }, {
  44. from:'pr_whcode',to:'pd_whcode'
  45. }, {
  46. from:'pr_whname',to:'pd_whname'
  47. }, {
  48. from:'pr_saleprice',to:'pd_sendprice'
  49. }],
  50. }) ;
  51. }
  52. },
  53. 'dbfindtrigger[name=pd_whname]':{
  54. beforerender:function(f){
  55. Ext.apply(f,{
  56. dbfinds:[{
  57. from:'id',to:'pd_whid',ignore:true
  58. }, {
  59. from:'wh_code',to:'pd_whcode'
  60. }, {
  61. from:'wh_description',to:'pd_whname'
  62. }],
  63. }) ;
  64. }
  65. },
  66. 'dbfindtrigger[name=pi_seller]': {
  67. beforerender: function (f) {
  68. Ext.apply(f, {
  69. dbfinds: [{
  70. from: 'id',
  71. to: 'pi_sellerid',
  72. ignore: true
  73. }, {
  74. from: 'em_code',
  75. to: 'pi_sellercode'
  76. }, {
  77. from: 'em_name',
  78. to: 'pi_seller'
  79. }],
  80. });
  81. }
  82. },
  83. 'remotecombo[name=pi_address]':{
  84. focus:function(f){
  85. //获取客户ID
  86. var pi_custid = f.ownerCt.down('[name=pi_custid]').value;
  87. if(pi_custid&&pi_custid!=""){
  88. Ext.apply(f.store.proxy.extraParams, {
  89. id:pi_custid
  90. });
  91. f.store.load();
  92. }else{
  93. saas.util.BaseUtil.showErrorToast('请先选择客户后在维护交货地址');
  94. f.setDisabled(true);
  95. }
  96. },
  97. expand:function(f){
  98. if(f.picker&&f.isExpanded){
  99. f.picker.setHeight(33*f.store.getCount())
  100. }
  101. }
  102. }
  103. });
  104. },
  105. turnProdIn: function() {
  106. var me = this,
  107. form = me.getView(),
  108. id = form.getForm().findField(form._idField);
  109. form.setLoading(true);
  110. saas.util.BaseUtil.request({
  111. url: form._turnInUrl + '/' + id.value,
  112. method: 'POST',
  113. })
  114. .then(function(localJson) {
  115. form.setLoading(false);
  116. if(localJson.success){
  117. var intValue = localJson.data.id,
  118. codeValue= localJson.data.code,
  119. name = localJson.data.name;
  120. saas.util.BaseUtil.openTab('sale-salein-formpanel',name+"("+codeValue+")",codeValue+intValue, {
  121. initId: intValue
  122. });
  123. saas.util.BaseUtil.showSuccessToast('转单成功');
  124. saas.util.FormUtil.loadData(form);
  125. }
  126. })
  127. .catch(function(e) {
  128. form.setLoading(false);
  129. saas.util.BaseUtil.showErrorToast('转单失败: ' + e.message);
  130. });
  131. }
  132. });