B2CSetting.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.b2c.B2CSetting', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. GridUtil: Ext.create('erp.util.GridUtil'),
  6. BaseUtil: Ext.create('erp.util.BaseUtil'),
  7. views:[
  8. 'b2c.B2CSetting','core.button.Add','core.button.Save','core.trigger.DbfindTrigger'
  9. ],
  10. init:function(){
  11. var me=this;
  12. this.control({
  13. '#form':{
  14. beforerender:function(f){
  15. me.getB2CSetting();
  16. }
  17. },
  18. '#startB2C':{//启用
  19. click:function(btn){
  20. me.startB2C();
  21. }
  22. },
  23. '#save':{
  24. click:function(btn){
  25. me.save();
  26. }
  27. },
  28. '#saveCustomer': {
  29. click: function(btn){//保存商城客户编号
  30. var code = Ext.getCmp('b2ccusomter').getValue();
  31. if(code!= null && code !=''){//保存
  32. me.saveCustomer(code,btn);
  33. }else{
  34. showError("请选择客户编号");
  35. Ext.getCmp('b2ccusomter').focus();
  36. }
  37. }
  38. },
  39. '#saveVendor': {
  40. click: function(btn){//保存商城供应商编号
  41. var code = Ext.getCmp('b2cvendor').getValue();
  42. if(code!= null && code !=''){//保存
  43. me.saveVendor(code,btn);
  44. }else{
  45. showError("请选择供应商编号");
  46. Ext.getCmp('b2cvendor').focus();
  47. }
  48. }
  49. },
  50. '#saveSaleKind': {
  51. click: function(btn){//保存商城客户编号
  52. var code = Ext.getCmp('b2csalekind').getValue();
  53. if(code!= null && code !=''){//保存
  54. me.saveSaleKind(code,btn);
  55. }else{
  56. showError("请选择销售类型");
  57. Ext.getCmp('b2csalekind').focus();
  58. }
  59. }
  60. },
  61. '#newCustomer': {//新增客户编号
  62. click: function(){
  63. me.FormUtil.onAdd('add_' + caller, '新增客户资料', 'jsps/scm/sale/customerBase.jsp?whoami=Customer!Base');
  64. }
  65. },
  66. '#newVendor': {//新增供应商
  67. click: function(){
  68. me.FormUtil.onAdd('add_' + caller, '新增供应商资料', 'jsps/scm/purchase/vendor.jsp?whoami=Vendor');
  69. }
  70. },
  71. '#tips':{
  72. afterrender:function(e){
  73. }
  74. }
  75. });
  76. },
  77. getForm: function(btn){
  78. return btn.ownerCt.ownerCt;
  79. },
  80. getB2CSetting: function(){
  81. var main = parent.Ext.getCmp("content-panel"), me = this;
  82. main.getActiveTab().setLoading(true);//loading...
  83. var form = Ext.getCmp("form");
  84. Ext.Ajax.request({
  85. url : basePath +'b2c/getB2CSetting.action',
  86. params : {
  87. _noc: 1,
  88. caller:caller
  89. //data: unescape(Ext.JSON.encode(dd))
  90. },
  91. method : 'post',
  92. callback : function(opt, s, res){
  93. main.getActiveTab().setLoading(false);
  94. var r = new Ext.decode(res.responseText);
  95. if(r.success){
  96. form.getForm().setValues(r.data);
  97. } else if(r.exceptionInfo){
  98. showError(r.exceptionInfo);
  99. }
  100. }
  101. });
  102. },
  103. startB2C : function(){
  104. var main = parent.Ext.getCmp("content-panel"), me = this;
  105. main.getActiveTab().setLoading(true);//loading...
  106. Ext.Ajax.request({
  107. url : basePath +'b2c/startB2C.action',
  108. params : {
  109. _noc: 1,
  110. caller: caller
  111. },
  112. method : 'post',
  113. callback : function(opt, s, res){
  114. main.getActiveTab().setLoading(false);//loading...
  115. var r = new Ext.decode(res.responseText);
  116. if(r.success){
  117. //重新加载页面window.location.href = basePath + "jsps/pm/bom/BOM.jsp";
  118. //me.getB2CSetting();
  119. } else if(r.exceptionInfo){
  120. showError(r.exceptionInfo);
  121. }
  122. }
  123. });
  124. },
  125. save:function(){
  126. var main = parent.Ext.getCmp("content-panel"), me = this;
  127. main.getActiveTab().setLoading(true);//loading...
  128. Ext.Ajax.request({
  129. url : basePath +'b2c/saveB2CSetting.action',
  130. params : {
  131. _noc: 1,
  132. caller: caller,
  133. param: code
  134. },
  135. method : 'post',
  136. callback : function(opt, s, res){
  137. main.getActiveTab().setLoading(false);//loading...
  138. var r = new Ext.decode(res.responseText);
  139. if(r.success){
  140. // window.location.href = basePath + "jsps/pm/mps/B2CSetting.jsp?whoami=B2CSetting";
  141. showMessage('提示', '保存成功!', 1000);
  142. me.getB2CSetting();
  143. } else if(r.exceptionInfo){
  144. showError(r.exceptionInfo);
  145. }
  146. }
  147. });
  148. },
  149. saveCustomer : function(code,btn){
  150. var main = parent.Ext.getCmp("content-panel"), me = this;
  151. main.getActiveTab().setLoading(true);//loading...
  152. Ext.Ajax.request({
  153. url : basePath +'b2c/saveB2CCustomer.action',
  154. params : {
  155. _noc: 1,
  156. caller: caller,
  157. param: code
  158. },
  159. method : 'post',
  160. callback : function(opt, s, res){
  161. main.getActiveTab().setLoading(false);//loading...
  162. var r = new Ext.decode(res.responseText);
  163. if(r.success){
  164. // window.location.href = basePath + "jsps/pm/mps/B2CSetting.jsp?whoami=B2CSetting";
  165. showMessage('提示', '保存成功!', 1000);
  166. me.getB2CSetting();
  167. } else if(r.exceptionInfo){
  168. showError(r.exceptionInfo);
  169. }
  170. }
  171. });
  172. },
  173. saveVendor : function(code,btn){
  174. var main = parent.Ext.getCmp("content-panel"), me = this;
  175. main.getActiveTab().setLoading(true);//loading...
  176. Ext.Ajax.request({
  177. url : basePath +'b2c/saveB2CVendor.action',
  178. params : {
  179. _noc: 1,
  180. caller: caller,
  181. param: code
  182. },
  183. method : 'post',
  184. callback : function(opt, s, res){
  185. main.getActiveTab().setLoading(false);//loading...
  186. var r = new Ext.decode(res.responseText);
  187. if(r.success){
  188. showMessage('提示', '保存成功!', 1000);
  189. me.getB2CSetting();
  190. //window.location.href = basePath + "jsps/pm/mps/B2CSetting.jsp?whoami=B2CSetting";
  191. } else if(r.exceptionInfo){
  192. showError(r.exceptionInfo);
  193. }
  194. }
  195. });
  196. },
  197. saveSaleKind : function(code,btn){
  198. var main = parent.Ext.getCmp("content-panel"), me = this;
  199. main.getActiveTab().setLoading(true);//loading...
  200. Ext.Ajax.request({
  201. url : basePath +'b2c/saveB2CSaleKind.action',
  202. params : {
  203. _noc: 1,
  204. caller: caller,
  205. param: code
  206. },
  207. method : 'post',
  208. callback : function(opt, s, res){
  209. main.getActiveTab().setLoading(false);//loading...
  210. var r = new Ext.decode(res.responseText);
  211. if(r.success){
  212. showMessage('提示', '保存成功!', 1000);
  213. me.getB2CSetting();
  214. //window.location.href = basePath + "jsps/pm/mps/B2CSetting.jsp?whoami=B2CSetting";
  215. } else if(r.exceptionInfo){
  216. showError(r.exceptionInfo);
  217. }
  218. }
  219. });
  220. }
  221. });