CheckAccount.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.arp.CheckAccount', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.BaseUtil'],
  5. views: ['fa.arp.CheckAccount'],
  6. init:function(){
  7. var me = this;
  8. this.BaseUtil = Ext.create('erp.util.BaseUtil');
  9. this.control({
  10. 'button[id=check]': {
  11. click: function(btn) {
  12. var grid = btn.ownerCt.ownerCt;
  13. grid.store.each(function(r){
  14. r.set('check', '');
  15. });
  16. btn.setDisabled(true);
  17. me.check(grid, 0, btn);
  18. }
  19. },
  20. 'button[id=close]': {
  21. click: function() {
  22. me.BaseUtil.getActiveTab().close();
  23. }
  24. },
  25. 'grid[id=account-check]': {
  26. itemclick: function(selModel, record) {
  27. var val = record.get('check');
  28. if(val == 'error') {
  29. me.showDetail(record);
  30. }
  31. }
  32. },
  33. 'tbtext[id=yearmonth]': {
  34. afterrender: function(f) {
  35. this.getCurrentMonth(f);
  36. }
  37. }
  38. });
  39. },
  40. check: function(grid, idx, btn) {
  41. var me =this,f = grid.store.getAt(idx);
  42. if(!f) {
  43. btn.setDisabled(false);
  44. return;
  45. }
  46. f.set('check', 'loading');
  47. var win = Ext.getCmp('win-' + f.get('type'));
  48. if(win) {
  49. win.destroy();
  50. }
  51. Ext.Ajax.request({
  52. url: basePath + f.get('action'),
  53. params: {
  54. type: f.get('type'),
  55. month: me.currentMonth,
  56. start: me.datestart,
  57. end: me.dateend
  58. },
  59. callback: function(opt, s, r) {
  60. me.check(grid, ++idx, btn);
  61. var rs = Ext.decode(r.responseText);
  62. if(rs.ok) {
  63. f.set('check', 'checked');
  64. } else {
  65. f.set('check', 'error');
  66. }
  67. }
  68. });
  69. },
  70. showDetail: function(record) {
  71. var me = this, wid = 'win-' + record.get('type'),
  72. win = Ext.getCmp(wid);
  73. if(!win) {
  74. win = Ext.create('Ext.Window', {
  75. title: record.get('value'),
  76. id: wid,
  77. width: 800,
  78. height: 500,
  79. layout: 'anchor',
  80. items: [{
  81. xtype: 'gridpanel',
  82. anchor: '100% 100%',
  83. columnLines: true,
  84. cls: 'custom',
  85. columns: [{
  86. text: '单据',
  87. flex: 1,
  88. dataIndex: 'be_class'
  89. },{
  90. text: '编号',
  91. flex: 1.6,
  92. dataIndex: 'be_code'
  93. },{
  94. text: '检测时间',
  95. flex: 1,
  96. dataIndex: 'be_date',
  97. renderer: function(val) {return Ext.Date.format(new Date(val), 'Y-m-d');}
  98. },{
  99. text: '检测人',
  100. flex: .8,
  101. dataIndex: 'be_checker'
  102. },{
  103. text: '备注',
  104. flex: 3,
  105. dataIndex: 'be_remark'
  106. }],
  107. store: new Ext.data.Store({
  108. fields: ['be_class', 'be_code', 'be_date', 'be_checker', 'be_remark']
  109. })
  110. }],
  111. buttonAlign: 'center',
  112. buttons: [{
  113. text: $I18N.common.button.erpExportButton,
  114. iconCls: 'x-button-icon-excel',
  115. cls: 'x-btn-blue',
  116. handler: function(btn) {
  117. me.BaseUtil.exportGrid(btn.up('window').down('gridpanel'));
  118. }
  119. },{
  120. text: $I18N.common.button.erpCloseButton,
  121. cls: 'x-btn-blue',
  122. handler: function(btn) {
  123. btn.ownerCt.ownerCt.close();
  124. }
  125. }]
  126. });
  127. this.getBillError(record.get('type'), win.down('gridpanel'));
  128. }
  129. win.show();
  130. },
  131. getCurrentMonth: function(f) {
  132. var me = this;
  133. Ext.Ajax.request({
  134. url: basePath + 'fa/getMonth.action',
  135. params: {
  136. type: 'MONTH-V'
  137. },
  138. callback: function(opt, s, r) {
  139. var rs = Ext.decode(r.responseText);
  140. if(rs.data) {
  141. me.currentMonth = rs.data.PD_DETNO;
  142. me.datestart = Ext.Date.format(new Date(rs.data.PD_STARTDATE), 'Ymd');
  143. me.dateend = Ext.Date.format(new Date(rs.data.PD_ENDDATE), 'Ymd');
  144. f.setText(rs.data.PD_DETNO + ' 从' + Ext.Date.format(new Date(rs.data.PD_STARTDATE), 'Y-m-d')
  145. + ' 到 ' + Ext.Date.format(new Date(rs.data.PD_ENDDATE), 'Y-m-d'));
  146. }
  147. }
  148. });
  149. },
  150. getBillError: function(type, grid) {
  151. Ext.Ajax.request({
  152. url: basePath + 'fa/getBillError.action',
  153. params: {
  154. type: type
  155. },
  156. callback: function(opt, s, r) {
  157. var rs = Ext.decode(r.responseText);
  158. if(rs.data) {
  159. grid.store.loadData(rs.data);
  160. } else if(rs.exceptionInfo) {
  161. showError(rs.exceptionInfo);
  162. }
  163. }
  164. });
  165. }
  166. });