WageAccount.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.wg.WageAccount', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. views: ['fa.wg.WageAccountForm', 'fa.wg.WageAccount', 'core.button.Confirm', 'core.button.Close', 'core.form.MonthDateField'],
  7. init: function() {
  8. var me = this;
  9. this.control({
  10. 'erpCloseButton': {
  11. click: function(btn) {
  12. me.FormUtil.onClose();
  13. }
  14. },
  15. 'erpConfirmButton': {
  16. click: function(btn) {
  17. this.confirm();
  18. }
  19. },
  20. 'monthdatefield': {
  21. afterrender: function(f) {
  22. this.getCurrentMonth(f, "MONTH-A");
  23. }
  24. }
  25. });
  26. },
  27. getForm: function(btn) {
  28. return btn.ownerCt.ownerCt;
  29. },
  30. confirm: function() {
  31. var me = this;
  32. Ext.MessageBox.confirm('提示', '确实要计算佣金吗?',
  33. function(btn) {
  34. if (btn == 'yes') {
  35. me.FormUtil.setLoading(true);
  36. Ext.Ajax.request({
  37. url: basePath + "fa/wg/WageAccount.action",
  38. params: {
  39. date: Ext.getCmp('date').value
  40. },
  41. method: 'post',
  42. timeout: 1200000,
  43. callback: function(options, success, response) {
  44. me.FormUtil.setLoading(false);
  45. var localJson = new Ext.decode(response.responseText);
  46. if (localJson.success) {
  47. Ext.Msg.alert("提示", "操作成功!");
  48. } else {
  49. if (localJson.exceptionInfo) {
  50. var str = localJson.exceptionInfo;
  51. if (str.trim().substr(0, 12) == 'AFTERSUCCESS') { //特殊情况:操作成功,但是出现警告,允许刷新页面
  52. str = str.replace('AFTERSUCCESS', '');
  53. showError(str);
  54. postSuccess(function() {
  55. window.location.reload();
  56. });
  57. } else {
  58. showError(str);
  59. return;
  60. }
  61. }
  62. }
  63. }
  64. });
  65. }
  66. });
  67. },
  68. getCurrentMonth: function(f, type) {
  69. Ext.Ajax.request({
  70. url: basePath + 'fa/getMonth.action',
  71. params: {
  72. type: type
  73. },
  74. callback: function(opt, s, r) {
  75. var rs = Ext.decode(r.responseText);
  76. if (rs.data) {
  77. f.setValue(rs.data.PD_DETNO);
  78. }
  79. }
  80. });
  81. }
  82. });