UnpackApply.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.hr.attendance.UnpackApply', {
  3. extend: 'Ext.app.Controller',
  4. FormUtil: Ext.create('erp.util.FormUtil'),
  5. BaseUtil: Ext.create('erp.util.BaseUtil'),
  6. GridUtil: Ext.create('erp.util.GridUtil'),
  7. views: ['hr.attendance.UnpackApply', 'core.form.Panel', 'core.form.FileField', 'core.form.MultiField', 'core.form.CheckBoxGroup', 'core.button.Save', 'core.button.Add', 'core.button.Submit', 'core.button.Print', 'core.button.Upload', 'core.button.ResAudit', 'core.button.Audit', 'core.button.Close', 'core.button.Delete', 'core.button.Update', 'core.button.ResSubmit', 'core.grid.Panel2', 'core.button.TurnCustomer', 'core.button.Flow', 'core.button.DownLoad', 'core.button.Scan', 'common.datalist.Toolbar', 'core.button.Confirm', 'core.trigger.DbfindTrigger', 'core.trigger.TextAreaTrigger', 'core.form.YnField', 'core.trigger.AutoCodeTrigger'],
  8. init: function() {
  9. var me = this;
  10. this.control({
  11. 'erpSaveButton': {
  12. click: function(btn) {
  13. var form = me.getForm(btn);
  14. if (Ext.getCmp(form.codeField).value == null || Ext.getCmp(form.codeField).value == '') {
  15. me.BaseUtil.getRandomNumber(); //自动添加编号
  16. }
  17. //保存之前的一些前台的逻辑判定
  18. this.FormUtil.beforeSave(this);
  19. }
  20. },
  21. 'erpDeleteButton': {
  22. click: function(btn) {
  23. me.FormUtil.onDelete(Ext.getCmp('ua_id').value);
  24. }
  25. },
  26. 'erpUpdateButton': {
  27. click: function(btn) {
  28. this.FormUtil.onUpdate(this);
  29. }
  30. },
  31. 'erpAddButton': {
  32. click: function() {
  33. me.FormUtil.onAdd('addUnpackApply', '新增拆包申请', 'jsps/hr/attendance/unpackApply.jsp');
  34. }
  35. },
  36. 'erpSubmitButton': {
  37. afterrender: function(btn) {
  38. var status = Ext.getCmp('ua_statuscode');
  39. if (status && status.value != 'ENTERING') {
  40. btn.hide();
  41. }
  42. },
  43. click: function(btn) {
  44. me.FormUtil.onSubmit(Ext.getCmp('ua_id').value);
  45. }
  46. },
  47. 'erpResSubmitButton': {
  48. afterrender: function(btn) {
  49. var status = Ext.getCmp('ua_statuscode');
  50. if (status && status.value != 'COMMITED') {
  51. btn.hide();
  52. }
  53. },
  54. click: function(btn) {
  55. me.FormUtil.onResSubmit(Ext.getCmp('ua_id').value);
  56. }
  57. },
  58. 'erpAuditButton': {
  59. afterrender: function(btn) {
  60. var status = Ext.getCmp('ua_statuscode');
  61. if (status && status.value != 'COMMITED') {
  62. btn.hide();
  63. }
  64. },
  65. click: function(btn) {
  66. me.FormUtil.onAudit(Ext.getCmp('ua_id').value);
  67. }
  68. },
  69. 'erpResAuditButton': {
  70. afterrender: function(btn) {
  71. var status = Ext.getCmp('ua_statuscode');
  72. if (status && status.value != 'AUDITED') {
  73. btn.hide();
  74. }
  75. },
  76. click: function(btn) {
  77. me.FormUtil.onResAudit(Ext.getCmp('ua_id').value);
  78. }
  79. },
  80. 'erpPrintButton': {
  81. click: function(btn) {
  82. var reportName = '';
  83. reportName = "cbapp";
  84. var condition = '{UnpackApply.ua_id}=' + Ext.getCmp('ua_id').value + '';
  85. var id = Ext.getCmp('ua_id').value;
  86. me.FormUtil.onwindowsPrint(id, reportName, condition);
  87. }
  88. },
  89. 'erpCloseButton': {
  90. click: function(btn) {
  91. me.FormUtil.beforeClose(me);
  92. }
  93. },
  94. 'erpConfirmButton': {
  95. afterrender: function(btn) {
  96. var statu = Ext.getCmp('ua_statuscode'), confirmStatus=Ext.getCmp('ua_confirmstatus');
  97. if (statu && statu.value != 'AUDITED') {
  98. btn.hide();
  99. }
  100. if (confirmStatus && confirmStatus.value == '已处理') {
  101. btn.hide();
  102. }
  103. },
  104. click: function(btn) {
  105. me.onConfirm(Ext.getCmp('ua_id').value);
  106. }
  107. }
  108. });
  109. },
  110. getForm: function(btn) {
  111. return btn.ownerCt.ownerCt;
  112. },
  113. onConfirm: function(id) {
  114. var form = Ext.getCmp('form');
  115. Ext.Ajax.request({
  116. url: basePath + form.confirmUrl,
  117. params: {
  118. id: id,
  119. caller: caller
  120. },
  121. method: 'post',
  122. callback: function(options, success, response) {
  123. var localJson = new Ext.decode(response.responseText);
  124. if (localJson.success) {
  125. window.location.reload();
  126. } else {
  127. if (localJson.exceptionInfo) {
  128. var str = localJson.exceptionInfo;
  129. if (str.trim().substr(0, 12) == 'AFTERSUCCESS') { //特殊情况:操作成功,但是出现警告,允许刷新页面
  130. str = str.replace('AFTERSUCCESS', '');
  131. showMessage("提示", '确认成功');
  132. window.location.reload();
  133. } else {
  134. showError(str);
  135. return;
  136. }
  137. }
  138. }
  139. }
  140. });
  141. }
  142. });