CheckAccount.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.reserve.CheckAccount', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.BaseUtil'],
  5. views: ['scm.reserve.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. pmonth: me.preYearmonth,
  57. start: me.datestart,
  58. end: me.dateend
  59. },
  60. callback: function(opt, s, r) {
  61. me.check(grid, ++idx, btn);
  62. var rs = Ext.decode(r.responseText);
  63. if(rs.ok) {
  64. f.set('check', 'checked');
  65. } else {
  66. f.set('check', 'error');
  67. }
  68. }
  69. });
  70. },
  71. showDetail: function(record) {
  72. var me = this, wid = 'win-' + record.get('type'),
  73. win = Ext.getCmp(wid);
  74. if(!win) {
  75. win = Ext.create('Ext.Window', {
  76. title: record.get('value'),
  77. id: wid,
  78. width: 800,
  79. height: 500,
  80. layout: 'anchor',
  81. items: [{
  82. xtype: 'gridpanel',
  83. anchor: '100% 100%',
  84. columnLines: true,
  85. cls: 'custom',
  86. columns: [{
  87. text: '单据',
  88. flex: 1,
  89. dataIndex: 'be_class'
  90. },{
  91. text: '编号',
  92. flex: 1.6,
  93. dataIndex: 'be_code'
  94. },{
  95. text: '检测时间',
  96. flex: 1,
  97. dataIndex: 'be_date',
  98. renderer: function(val) {return Ext.Date.format(new Date(val), 'Y-m-d');}
  99. },{
  100. text: '检测人',
  101. flex: .8,
  102. dataIndex: 'be_checker'
  103. },{
  104. text: '备注',
  105. flex: 3,
  106. dataIndex: 'be_remark'
  107. }],
  108. store: new Ext.data.Store({
  109. fields: ['be_class', 'be_code', 'be_date', 'be_checker', 'be_remark']
  110. })
  111. }],
  112. buttonAlign: 'center',
  113. buttons: [{
  114. text: $I18N.common.button.erpExportButton,
  115. iconCls: 'x-button-icon-excel',
  116. cls: 'x-btn-blue',
  117. handler: function(btn) {
  118. me.BaseUtil.exportGrid(btn.up('window').down('gridpanel'));
  119. }
  120. },{
  121. text: $I18N.common.button.erpCloseButton,
  122. cls: 'x-btn-blue',
  123. handler: function(btn) {
  124. btn.ownerCt.ownerCt.close();
  125. }
  126. }]
  127. });
  128. this.getBillError(record.get('type'), win.down('gridpanel'));
  129. }
  130. win.show();
  131. },
  132. getCurrentMonth: function(f) {
  133. var me = this;
  134. Ext.Ajax.request({
  135. url: basePath + 'fa/getMonth.action',
  136. params: {
  137. type: 'MONTH-P'
  138. },
  139. callback: function(opt, s, r) {
  140. var rs = Ext.decode(r.responseText);
  141. if(rs.data) {
  142. me.currentMonth = rs.data.PD_DETNO;
  143. me.datestart = Ext.Date.format(new Date(rs.data.PD_STARTDATE), 'Ymd');
  144. me.dateend = Ext.Date.format(new Date(rs.data.PD_ENDDATE), 'Ymd');
  145. f.setText(rs.data.PD_DETNO + ' 从' + Ext.Date.format(new Date(rs.data.PD_STARTDATE), 'Y-m-d')
  146. + ' 到 ' + Ext.Date.format(new Date(rs.data.PD_ENDDATE), 'Y-m-d'));
  147. }
  148. }
  149. });
  150. },
  151. getBillError: function(type, grid) {
  152. Ext.Ajax.request({
  153. url: basePath + 'fa/getBillError.action',
  154. params: {
  155. type: type
  156. },
  157. callback: function(opt, s, r) {
  158. var rs = Ext.decode(r.responseText);
  159. if(rs.data) {
  160. grid.store.loadData(rs.data);
  161. } else if(rs.exceptionInfo) {
  162. showError(rs.exceptionInfo);
  163. }
  164. }
  165. });
  166. }
  167. });