CheckAccount.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.ars.CheckAccount', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.BaseUtil'],
  5. views: ['fa.ars.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(selModel.ownerCt, 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(grid, 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: '导出全部',
  121. iconCls: 'x-button-icon-excel',
  122. cls: 'x-btn-blue',
  123. handler: function(btn) {
  124. me.getAll(grid, record);
  125. }
  126. },{
  127. text: $I18N.common.button.erpCloseButton,
  128. cls: 'x-btn-blue',
  129. handler: function(btn) {
  130. btn.ownerCt.ownerCt.close();
  131. }
  132. }]
  133. });
  134. this.getBillError(record.get('type'), win.down('gridpanel'));
  135. }
  136. win.show();
  137. },
  138. getCurrentMonth: function(f) {
  139. var me = this;
  140. Ext.Ajax.request({
  141. url: basePath + 'fa/getMonth.action',
  142. params: {
  143. type: 'MONTH-C'
  144. },
  145. callback: function(opt, s, r) {
  146. var rs = Ext.decode(r.responseText);
  147. if(rs.data) {
  148. me.currentMonth = rs.data.PD_DETNO;
  149. me.datestart = Ext.Date.format(new Date(rs.data.PD_STARTDATE), 'Ymd');
  150. me.dateend = Ext.Date.format(new Date(rs.data.PD_ENDDATE), 'Ymd');
  151. f.setText(rs.data.PD_DETNO + ' 从' + Ext.Date.format(new Date(rs.data.PD_STARTDATE), 'Y-m-d')
  152. + ' 到 ' + Ext.Date.format(new Date(rs.data.PD_ENDDATE), 'Y-m-d'));
  153. }
  154. }
  155. });
  156. },
  157. getBillError: function(type, grid) {
  158. Ext.Ajax.request({
  159. url: basePath + 'fa/getBillError.action',
  160. params: {
  161. type: type
  162. },
  163. callback: function(opt, s, r) {
  164. var rs = Ext.decode(r.responseText);
  165. if(rs.data) {
  166. grid.store.loadData(rs.data);
  167. } else if(rs.exceptionInfo) {
  168. showError(rs.exceptionInfo);
  169. }
  170. }
  171. });
  172. },
  173. getAll: function(grid, record) {
  174. var p = Ext.create('Ext.ProgressBar', {
  175. renderTo: Ext.getBody(),
  176. floating: true,
  177. width: 300,
  178. value: 0.4,
  179. text: '获取全部数据...'
  180. }).show();
  181. this.checkAll(grid, record);
  182. p.updateProgress(0.8, '正在下载...', true);
  183. this.exportExcel(record.get('type'));
  184. Ext.defer(function(){
  185. p.setVisible(false);
  186. }, 3000);
  187. },
  188. checkAll: function(grid, record) {
  189. var me =this;
  190. record.set('check', 'loading');
  191. Ext.Ajax.request({
  192. url: basePath + record.get('action'),
  193. params: {
  194. type: record.get('type'),
  195. month: me.currentMonth,
  196. start: me.datestart,
  197. end: me.dateend,
  198. all: true
  199. },
  200. async: false,
  201. callback: function(opt, s, r) {
  202. var rs = Ext.decode(r.responseText);
  203. if(rs.ok) {
  204. record.set('check', 'checked');
  205. } else {
  206. record.set('check', 'error');
  207. }
  208. }
  209. });
  210. },
  211. exportExcel: function(type) {
  212. var title = Ext.Date.format(new Date(), 'Y-m-d H:m:s');
  213. if (!Ext.fly('ext-grid-excel')) {
  214. var frm = document.createElement('form');
  215. frm.id = 'ext-grid-excel';
  216. frm.name = id;
  217. frm.className = 'x-hidden';
  218. document.body.appendChild(frm);
  219. }
  220. Ext.Ajax.request({
  221. url: basePath + ('fa/exportBillError.xls'),
  222. method: 'post',
  223. form: Ext.fly('ext-grid-excel'),
  224. isUpload: true,
  225. params: {
  226. type: type,
  227. title: title
  228. }
  229. });
  230. }
  231. });