CheckFIXAccount.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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(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. param:{date:Ext.getCmp('yearmonth').value}
  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. endArSuccess(function(){
  77. window.location.reload();
  78. });
  79. } else {
  80. if(localJson.exceptionInfo){
  81. var str = localJson.exceptionInfo;
  82. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  83. str = str.replace('AFTERSUCCESS', '');
  84. showMessage('提示', str);
  85. window.location.reload();
  86. } else {
  87. showError(str);return;
  88. }
  89. }
  90. }
  91. }
  92. });
  93. },
  94. overAccount: function(){
  95. var me = this;
  96. me.FormUtil.setLoading(true);
  97. Ext.Ajax.request({
  98. url : basePath + "fa/fix/confirmMonthCarryrestore.action",
  99. params:{
  100. param:{date:Ext.getCmp('yearmonth').value}
  101. },
  102. method:'post',
  103. callback:function(options,success,response){
  104. me.FormUtil.setLoading(false);
  105. var localJson = new Ext.decode(response.responseText);
  106. if(localJson.success){
  107. unEndArSuccess(function(){
  108. window.location.reload();
  109. });
  110. } else {
  111. if(localJson.exceptionInfo){
  112. var str = localJson.exceptionInfo;
  113. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){//特殊情况:操作成功,但是出现警告,允许刷新页面
  114. str = str.replace('AFTERSUCCESS', '');
  115. showMessage('提示', str);
  116. window.location.reload();
  117. } else {
  118. showError(str);return;
  119. }
  120. }
  121. }
  122. }
  123. });
  124. },
  125. check: function(grid, idx, btn) {
  126. var me =this,f = grid.store.getAt(idx);
  127. if(!f) {
  128. btn.setDisabled(false);
  129. return;
  130. }
  131. f.set('check', 'loading');
  132. var win = Ext.getCmp('win-' + f.get('type'));
  133. if(win) {
  134. win.destroy();
  135. }
  136. Ext.Ajax.request({
  137. url: basePath + f.get('action'),
  138. params: {
  139. type: f.get('type'),
  140. month: me.currentMonth,
  141. start: me.datestart,
  142. end: me.dateend
  143. },
  144. callback: function(opt, s, r) {
  145. me.check(grid, ++idx, btn);
  146. var rs = Ext.decode(r.responseText);
  147. if(rs.ok) {
  148. f.set('check', 'checked');
  149. } else {
  150. f.set('check', 'error');
  151. }
  152. if(idx == grid.store.data.length) {
  153. var ch = 0;
  154. grid.store.each(function(){
  155. if(this.get('check') == 'checked') {
  156. ch ++;
  157. }
  158. });
  159. if(idx == ch) {
  160. me.checked = true;
  161. Ext.getCmp('accoutover').setDisabled(false);
  162. } else {
  163. me.checked = false;
  164. Ext.getCmp('allow').show();
  165. }
  166. }
  167. }
  168. });
  169. },
  170. showDetail: function(record) {
  171. var me = this, wid = 'win-' + record.get('type'),
  172. win = Ext.getCmp(wid);
  173. if(!win) {
  174. win = Ext.create('Ext.Window', {
  175. title: record.get('value'),
  176. id: wid,
  177. width: 800,
  178. height: 500,
  179. layout: 'anchor',
  180. items: [{
  181. xtype: 'gridpanel',
  182. anchor: '100% 100%',
  183. columnLines: true,
  184. cls: 'custom',
  185. columns: [{
  186. text: '单据',
  187. flex: 1,
  188. dataIndex: 'be_class'
  189. },{
  190. text: '编号',
  191. flex: 1.6,
  192. dataIndex: 'be_code'
  193. },{
  194. text: '检测时间',
  195. flex: 1,
  196. dataIndex: 'be_date',
  197. renderer: function(val) {return Ext.Date.format(new Date(val), 'Y-m-d');}
  198. },{
  199. text: '检测人',
  200. flex: .8,
  201. dataIndex: 'be_checker'
  202. },{
  203. text: '备注',
  204. flex: 3,
  205. dataIndex: 'be_remark'
  206. }],
  207. store: new Ext.data.Store({
  208. fields: ['be_class', 'be_code', 'be_date', 'be_checker', 'be_remark']
  209. })
  210. }],
  211. buttonAlign: 'center',
  212. buttons: [{
  213. text: $I18N.common.button.erpExportButton,
  214. iconCls: 'x-button-icon-excel',
  215. cls: 'x-btn-blue',
  216. handler: function(btn) {
  217. me.BaseUtil.exportGrid(btn.up('window').down('gridpanel'));
  218. }
  219. },{
  220. text: $I18N.common.button.erpCloseButton,
  221. cls: 'x-btn-blue',
  222. handler: function(btn) {
  223. btn.ownerCt.ownerCt.close();
  224. }
  225. }]
  226. });
  227. this.getBillError(record.get('type'), win.down('gridpanel'));
  228. }
  229. win.show();
  230. },
  231. getCurrentMonth: function(f) {
  232. var me = this;
  233. Ext.Ajax.request({
  234. url: basePath + 'fa/getMonth.action',
  235. params: {
  236. type: 'MONTH-F'
  237. },
  238. callback: function(opt, s, r) {
  239. var rs = Ext.decode(r.responseText);
  240. if(rs.data) {
  241. me.currentMonth = rs.data.PD_DETNO;
  242. me.datestart = Ext.Date.format(new Date(rs.data.PD_STARTDATE), 'Ymd');
  243. me.dateend = Ext.Date.format(new Date(rs.data.PD_ENDDATE), 'Ymd');
  244. f.setText(rs.data.PD_DETNO + ' 从' + Ext.Date.format(new Date(rs.data.PD_STARTDATE), 'Y-m-d')
  245. + ' 到 ' + Ext.Date.format(new Date(rs.data.PD_ENDDATE), 'Y-m-d'));
  246. }
  247. }
  248. });
  249. },
  250. getBillError: function(type, grid) {
  251. Ext.Ajax.request({
  252. url: basePath + 'fa/getBillError.action',
  253. params: {
  254. type: type
  255. },
  256. callback: function(opt, s, r) {
  257. var rs = Ext.decode(r.responseText);
  258. if(rs.data) {
  259. grid.store.loadData(rs.data);
  260. } else if(rs.exceptionInfo) {
  261. showError(rs.exceptionInfo);
  262. }
  263. }
  264. });
  265. }
  266. });