FormPanelController.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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_whid',to:'pd_whid'
  37. }, {
  38. from:'pr_whcode',to:'pd_whcode'
  39. }, {
  40. from:'pr_whname',to:'pd_whname'
  41. }, {
  42. from:'pr_saleprice',to:'pd_sendprice'
  43. }],
  44. }) ;
  45. }
  46. },
  47. 'dbfindtrigger[name=pd_whname]':{
  48. beforerender:function(f){
  49. Ext.apply(f,{
  50. dbfinds:[{
  51. from:'id',to:'pd_whid',ignore:true
  52. }, {
  53. from:'wh_code',to:'pd_whcode'
  54. }, {
  55. from:'wh_description',to:'pd_whname'
  56. }],
  57. }) ;
  58. }
  59. },
  60. 'remotecombo[name=pi_address]':{
  61. focus:function(f){
  62. //获取客户ID
  63. var pi_custid = f.ownerCt.down('[name=pi_custid]').value;
  64. if(pi_custid&&pi_custid!=""){
  65. Ext.apply(f.store.proxy.extraParams, {
  66. id:pi_custid
  67. });
  68. f.store.load();
  69. }else{
  70. saas.util.BaseUtil.showErrorToast('请先选择客户后在维护交货地址');
  71. f.setDisabled(true);
  72. }
  73. },
  74. expand:function(f){
  75. if(f.picker&&f.isExpanded){
  76. f.picker.setHeight(33*f.store.getCount())
  77. }
  78. }
  79. }
  80. });
  81. },
  82. turnProdIn: function() {
  83. var me = this,
  84. form = me.getView(),
  85. id = form.getForm().findField(form._idField);
  86. form.setLoading(true);
  87. saas.util.BaseUtil.request({
  88. url: form._turnInUrl + '/' + id.value,
  89. method: 'POST',
  90. })
  91. .then(function(localJson) {
  92. form.setLoading(false);
  93. if(localJson.success){
  94. var intValue = localJson.data.id,
  95. codeValue= localJson.data.code,
  96. name = localJson.data.name;
  97. saas.util.BaseUtil.openTab('sale-salein-formpanel',name+"("+codeValue+")",codeValue+intValue, {
  98. initId: intValue
  99. });
  100. saas.util.BaseUtil.showSuccessToast('转单成功');
  101. saas.util.FormUtil.loadData(form);
  102. }
  103. })
  104. .catch(function(res) {
  105. form.setLoading(false);
  106. // console.error(res);
  107. saas.util.BaseUtil.showErrorToast('转单失败: ' + res.message);
  108. });
  109. }
  110. });