FormPanelController.js 5.7 KB

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