TurnEstimate.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.arp.TurnEstimate', {
  3. extend: 'Ext.app.Controller',
  4. GridUtil: Ext.create('erp.util.GridUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views:[
  7. 'fa.arp.TurnEstimate','common.datalist.GridPanel','common.datalist.Toolbar',
  8. 'core.button.TurnEstimate'
  9. ],
  10. init:function(){
  11. var me = this;
  12. this.control({
  13. 'erpDatalistGridPanel': {
  14. afterrender: function(grid){
  15. var t = grid.down('erpDatalistToolbar');
  16. t.insert(t.items.items.length - 2, {
  17. xtype: 'erpTurnEstimateButton'
  18. });
  19. }
  20. },
  21. 'erpTurnEstimateButton': {
  22. click: function(btn) {
  23. warnMsg('确定全部转应付暂估吗?', function(b){
  24. if(b == 'ok' || b == 'yes') {
  25. me.turnEstimate(btn.ownerCt.ownerCt);
  26. }
  27. });
  28. }
  29. }
  30. });
  31. },
  32. //点击 转应付暂估 按钮
  33. turnEstimate:function(grid){
  34. grid.setLoading(true);
  35. Ext.Ajax.request({
  36. url : basePath + '/fa/EstimateController/turnEstimate.action',
  37. timeout: 120000,
  38. callback : function(options, success, response){
  39. grid.setLoading(false);
  40. var localJson = new Ext.decode(response.responseText);
  41. if(localJson.success){
  42. alert('转暂估成功!');
  43. window.location.reload();
  44. } else {
  45. if(localJson.exceptionInfo){
  46. var str = localJson.exceptionInfo;
  47. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){
  48. str = str.replace('AFTERSUCCESS', '');
  49. alert('转暂估成功!');
  50. window.location.reload();
  51. }
  52. showMessage("提示", str);return;
  53. }
  54. }
  55. }
  56. });
  57. }
  58. });