CheckFIXAccount.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.fa.fix.CheckFIXAccount', {
  3. extend : 'Ext.app.Controller',
  4. requires : [ 'erp.util.BaseUtil' ],
  5. views : [ 'fa.fix.CheckFIXAccount' ],
  6. FormUtil : Ext.create('erp.util.FormUtil'),
  7. init : function() {
  8. var me = this;
  9. this.BaseUtil = Ext.create('erp.util.BaseUtil');
  10. this.control({
  11. 'button[id=check]' : {
  12. click : function(btn) {
  13. var grid = btn.ownerCt.ownerCt;
  14. grid.store.each(function(r) {
  15. r.set('check', '');
  16. });
  17. btn.hide();
  18. me.check(grid, 0, btn);
  19. }
  20. },
  21. '#allow' : {
  22. change : function(f) {
  23. if (!me.checked) {
  24. if (f.getValue()) {
  25. Ext.getCmp('accoutover').setDisabled(false);
  26. } else {
  27. Ext.getCmp('accoutover').setDisabled(true);
  28. }
  29. }
  30. }
  31. },
  32. 'button[id=accoutover]' : {
  33. click : function() {
  34. this.startAccount();
  35. }
  36. },
  37. 'button[id=close]' : {
  38. click : function() {
  39. me.BaseUtil.getActiveTab().close();
  40. }
  41. },
  42. 'button[id=resaccoutover]' : {
  43. click : function() {
  44. this.overAccount();
  45. }
  46. },
  47. 'grid[id=account-check]' : {
  48. itemclick : function(selModel, record) {
  49. var val = record.get('check');
  50. if (val == 'error') {
  51. me.showDetail(selModel.ownerCt, record);
  52. }
  53. }
  54. },
  55. 'tbtext[id=yearmonth]' : {
  56. afterrender : function(f) {
  57. this.getCurrentMonth(f);
  58. }
  59. }
  60. });
  61. },
  62. startAccount : function() {
  63. var me = this;
  64. me.FormUtil.setLoading(true);
  65. Ext.Ajax.request({
  66. url : basePath + "fa/fix/confirmMonthCarryover.action",
  67. params : {
  68. date : me.currentMonth
  69. },
  70. timeout : 120000,
  71. method : 'post',
  72. callback : function(options, success, response) {
  73. me.FormUtil.setLoading(false);
  74. var localJson = new Ext.decode(response.responseText);
  75. if (localJson.success) {
  76. window.location.reload();
  77. } else {
  78. if (localJson.exceptionInfo) {
  79. var str = localJson.exceptionInfo;
  80. if (str.trim().substr(0, 12) == 'AFTERSUCCESS') {// 特殊情况:操作成功,但是出现警告,允许刷新页面
  81. str = str.replace('AFTERSUCCESS', '');
  82. showMessage('提示', str);
  83. window.location.reload();
  84. } else {
  85. showError(str);
  86. return;
  87. }
  88. }
  89. }
  90. }
  91. });
  92. },
  93. overAccount : function() {
  94. var me = this;
  95. me.FormUtil.setLoading(true);
  96. Ext.Ajax.request({
  97. url : basePath + "fa/fix/confirmMonthCarryrestore.action",
  98. params : {
  99. date : me.currentMonth
  100. },
  101. method : 'post',
  102. callback : function(options, success, response) {
  103. me.FormUtil.setLoading(false);
  104. var localJson = new Ext.decode(response.responseText);
  105. if (localJson.success) {
  106. window.location.reload();
  107. } else {
  108. if (localJson.exceptionInfo) {
  109. var str = localJson.exceptionInfo;
  110. if (str.trim().substr(0, 12) == 'AFTERSUCCESS') {// 特殊情况:操作成功,但是出现警告,允许刷新页面
  111. str = str.replace('AFTERSUCCESS', '');
  112. showMessage('提示', str);
  113. window.location.reload();
  114. } else {
  115. showError(str);
  116. return;
  117. }
  118. }
  119. }
  120. }
  121. });
  122. },
  123. check : function(grid, idx, btn) {
  124. var me = this, f = grid.store.getAt(idx);
  125. if (!f) {
  126. btn.setDisabled(false);
  127. return;
  128. }
  129. f.set('check', 'loading');
  130. var win = Ext.getCmp('win-' + f.get('type'));
  131. if (win) {
  132. win.destroy();
  133. }
  134. Ext.Ajax.request({
  135. url : basePath + f.get('action'),
  136. params : {
  137. type : f.get('type'),
  138. month : me.currentMonth,
  139. start : me.datestart,
  140. end : me.dateend
  141. },
  142. callback : function(opt, s, r) {
  143. me.check(grid, ++idx, btn);
  144. var rs = Ext.decode(r.responseText);
  145. if (rs.ok) {
  146. f.set('check', 'checked');
  147. } else {
  148. f.set('check', 'error');
  149. }
  150. if (idx == grid.store.data.length) {
  151. var ch = 0;
  152. grid.store.each(function() {
  153. if (this.get('check') == 'checked') {
  154. ch++;
  155. }
  156. });
  157. if (idx == ch) {
  158. me.checked = true;
  159. Ext.getCmp('accoutover').setDisabled(false);
  160. } else {
  161. me.checked = false;
  162. Ext.getCmp('allow').show();
  163. }
  164. }
  165. }
  166. });
  167. },
  168. showDetail : function(grid, record) {
  169. var me = this, wid = 'win-' + record.get('type'), win = Ext.getCmp(wid);
  170. if (!win) {
  171. win = Ext.create('Ext.Window', {
  172. title : record.get('value'),
  173. id : wid,
  174. width : 800,
  175. height : 500,
  176. layout : 'anchor',
  177. items : [ {
  178. xtype : 'gridpanel',
  179. anchor : '100% 100%',
  180. columnLines : true,
  181. cls : 'custom',
  182. columns : [ {
  183. text : '单据',
  184. flex : 1,
  185. dataIndex : 'be_class'
  186. }, {
  187. text : '编号',
  188. flex : 1.6,
  189. dataIndex : 'be_code'
  190. }, {
  191. text : '检测时间',
  192. flex : 1,
  193. dataIndex : 'be_date',
  194. renderer : function(val) {
  195. return Ext.Date.format(new Date(val), 'Y-m-d');
  196. }
  197. }, {
  198. text : '检测人',
  199. flex : .8,
  200. dataIndex : 'be_checker'
  201. }, {
  202. text : '备注',
  203. flex : 3,
  204. dataIndex : 'be_remark'
  205. } ],
  206. store : new Ext.data.Store({
  207. fields : [ 'be_class', 'be_code', 'be_date', 'be_checker', 'be_remark' ]
  208. })
  209. } ],
  210. buttonAlign : 'center',
  211. buttons : [ {
  212. text : $I18N.common.button.erpExportButton,
  213. iconCls : 'x-button-icon-excel',
  214. cls : 'x-btn-blue',
  215. handler : function(btn) {
  216. me.BaseUtil.exportGrid(btn.up('window').down('gridpanel'));
  217. }
  218. },{
  219. text: '导出全部',
  220. iconCls: 'x-button-icon-excel',
  221. cls: 'x-btn-blue',
  222. handler: function(btn) {
  223. me.getAll(grid, record);
  224. }
  225. }, {
  226. text : $I18N.common.button.erpCloseButton,
  227. cls : 'x-btn-blue',
  228. handler : function(btn) {
  229. btn.ownerCt.ownerCt.close();
  230. }
  231. } ]
  232. });
  233. this.getBillError(record.get('type'), win.down('gridpanel'));
  234. }
  235. win.show();
  236. },
  237. getCurrentMonth : function(f) {
  238. var me = this;
  239. Ext.Ajax.request({
  240. url : basePath + 'fa/getMonth.action',
  241. params : {
  242. type : 'MONTH-F'
  243. },
  244. callback : function(opt, s, r) {
  245. var rs = Ext.decode(r.responseText);
  246. if (rs.data) {
  247. me.currentMonth = rs.data.PD_DETNO;
  248. me.datestart = Ext.Date.format(new Date(rs.data.PD_STARTDATE), 'Ymd');
  249. me.dateend = Ext.Date.format(new Date(rs.data.PD_ENDDATE), 'Ymd');
  250. f.setText(rs.data.PD_DETNO + ' 从' + Ext.Date.format(new Date(rs.data.PD_STARTDATE), 'Y-m-d')
  251. + ' 到 ' + Ext.Date.format(new Date(rs.data.PD_ENDDATE), 'Y-m-d'));
  252. }
  253. }
  254. });
  255. },
  256. getBillError : function(type, grid) {
  257. Ext.Ajax.request({
  258. url : basePath + 'fa/getBillError.action',
  259. params : {
  260. type : type
  261. },
  262. callback : function(opt, s, r) {
  263. var rs = Ext.decode(r.responseText);
  264. if (rs.data) {
  265. grid.store.loadData(rs.data);
  266. } else if (rs.exceptionInfo) {
  267. showError(rs.exceptionInfo);
  268. }
  269. }
  270. });
  271. },
  272. getAll: function(grid, record) {
  273. var p = Ext.create('Ext.ProgressBar', {
  274. renderTo: Ext.getBody(),
  275. floating: true,
  276. width: 300,
  277. value: 0.4,
  278. text: '获取全部数据...'
  279. }).show();
  280. this.checkAll(grid, record);
  281. p.updateProgress(0.8, '正在下载...', true);
  282. this.exportExcel(record.get('type'));
  283. Ext.defer(function(){
  284. p.setVisible(false);
  285. }, 3000);
  286. },
  287. checkAll: function(grid, record) {
  288. var me =this;
  289. record.set('check', 'loading');
  290. Ext.Ajax.request({
  291. url: basePath + record.get('action'),
  292. params: {
  293. type: record.get('type'),
  294. month: me.currentMonth,
  295. start: me.datestart,
  296. end: me.dateend,
  297. all: true
  298. },
  299. async: false,
  300. callback: function(opt, s, r) {
  301. var rs = Ext.decode(r.responseText);
  302. if(rs.ok) {
  303. record.set('check', 'checked');
  304. } else {
  305. record.set('check', 'error');
  306. }
  307. }
  308. });
  309. },
  310. exportExcel: function(type) {
  311. var title = Ext.Date.format(new Date(), 'Y-m-d H:m:s');
  312. if (!Ext.fly('ext-grid-excel')) {
  313. var frm = document.createElement('form');
  314. frm.id = 'ext-grid-excel';
  315. frm.name = id;
  316. frm.className = 'x-hidden';
  317. document.body.appendChild(frm);
  318. }
  319. Ext.Ajax.request({
  320. url: basePath + ('fa/exportBillError.xls'),
  321. method: 'post',
  322. form: Ext.fly('ext-grid-excel'),
  323. isUpload: true,
  324. params: {
  325. type: type,
  326. title: title
  327. }
  328. });
  329. }
  330. });