FreezeCheck.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.scm.reserve.FreezeCheck', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.BaseUtil'],
  5. views: ['scm.reserve.FreezeCheck','core.form.MonthDateField'],
  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. '#yearmonth': {
  56. afterrender: function(f) {
  57. this.getCurrentMonth(f);
  58. },
  59. change: function(f){
  60. if(f.value) {
  61. me.currentMonth = f.getValue();
  62. me.datestart = Ext.Date.format(Ext.Date.getFirstDateOfMonth(Ext.Date.parse(me.currentMonth, 'Ym')), 'Ymd');
  63. me.dateend = Ext.Date.format(Ext.Date.getLastDateOfMonth(Ext.Date.parse(me.currentMonth, 'Ym')), 'Ymd');
  64. me.preMonth = Ext.Date.format(new Date(Ext.Date.getFirstDateOfMonth(Ext.Date.parse(me.currentMonth, 'Ym'))-24*60*60*1000) , 'Ym');
  65. }
  66. }
  67. },
  68. '#date': {
  69. afterrender: function(f) {
  70. me.getFreezeDetno(f);
  71. }
  72. }
  73. });
  74. },
  75. startAccount: function(){
  76. var me = this;
  77. me.FormUtil.setLoading(true);
  78. Ext.Ajax.request({
  79. url : basePath + "scm/reserves/Periodsdetailfreeze.action",
  80. params:{
  81. pd_detno : Ext.getCmp('yearmonth').value
  82. },
  83. timeout: 120000,
  84. method:'post',
  85. callback:function(options,success,response){
  86. me.FormUtil.setLoading(false);
  87. var localJson = new Ext.decode(response.responseText);
  88. if (localJson.success) {
  89. window.location.reload();
  90. } else {
  91. if (localJson.exceptionInfo) {
  92. var str = localJson.exceptionInfo;
  93. if (str.trim().substr(0, 12) == 'AFTERSUCCESS') {// 特殊情况:操作成功,但是出现警告,允许刷新页面
  94. str = str.replace('AFTERSUCCESS', '');
  95. showMessage('提示', str);
  96. window.location.reload();
  97. } else {
  98. showError(str);
  99. return;
  100. }
  101. }
  102. }
  103. }
  104. });
  105. },
  106. overAccount: function(){
  107. var me = this;
  108. me.FormUtil.setLoading(true);
  109. Ext.Ajax.request({
  110. url : basePath + "scm/reserves/Periodsdetailcancelfreeze.action",
  111. method:'post',
  112. callback:function(options,success,response){
  113. me.FormUtil.setLoading(false);
  114. var localJson = new Ext.decode(response.responseText);
  115. if (localJson.success) {
  116. window.location.reload();
  117. } else {
  118. if (localJson.exceptionInfo) {
  119. var str = localJson.exceptionInfo;
  120. if (str.trim().substr(0, 12) == 'AFTERSUCCESS') {// 特殊情况:操作成功,但是出现警告,允许刷新页面
  121. str = str.replace('AFTERSUCCESS', '');
  122. showMessage('提示', str);
  123. window.location.reload();
  124. } else {
  125. showError(str);
  126. return;
  127. }
  128. }
  129. }
  130. }
  131. });
  132. },
  133. check: function(grid, idx, btn) {
  134. var me =this,f = grid.store.getAt(idx);
  135. if(!f) {
  136. btn.setDisabled(false);
  137. return;
  138. }
  139. f.set('check', 'loading');
  140. var win = Ext.getCmp('win-' + f.get('type'));
  141. if(win) {
  142. win.destroy();
  143. }
  144. Ext.Ajax.request({
  145. url: basePath + f.get('action'),
  146. params: {
  147. type: f.get('type'),
  148. month: me.currentMonth
  149. //pmonth: me.preMonth,
  150. //start: me.datestart,
  151. //end: me.dateend
  152. },
  153. callback: function(opt, s, r) {
  154. me.check(grid, ++idx, btn);
  155. var rs = Ext.decode(r.responseText);
  156. if(rs.ok) {
  157. f.set('check', 'checked');
  158. } else {
  159. f.set('check', 'error');
  160. }
  161. if(idx == grid.store.data.length) {
  162. var ch = 0;
  163. grid.store.each(function(){
  164. if(this.get('check') == 'checked') {
  165. ch ++;
  166. }
  167. });
  168. if(idx == ch) {
  169. me.checked = true;
  170. Ext.getCmp('accoutover').setDisabled(false);
  171. } else {
  172. me.checked = false;
  173. Ext.getCmp('allow').show();
  174. }
  175. }
  176. }
  177. });
  178. },
  179. showDetail: function(record) {
  180. var me = this, wid = 'win-' + record.get('type'),
  181. win = Ext.getCmp(wid);
  182. if(!win) {
  183. win = Ext.create('Ext.Window', {
  184. title: record.get('value'),
  185. id: wid,
  186. width: 800,
  187. height: 500,
  188. layout: 'anchor',
  189. items: [{
  190. xtype: 'gridpanel',
  191. anchor: '100% 100%',
  192. columnLines: true,
  193. cls: 'custom',
  194. columns: [{
  195. text: '单据',
  196. flex: 1,
  197. dataIndex: 'be_class'
  198. },{
  199. text: '编号',
  200. flex: 1.6,
  201. dataIndex: 'be_code'
  202. },{
  203. text: '检测时间',
  204. flex: 1,
  205. dataIndex: 'be_date',
  206. renderer: function(val) {return Ext.Date.format(new Date(val), 'Y-m-d');}
  207. },{
  208. text: '检测人',
  209. flex: .8,
  210. dataIndex: 'be_checker'
  211. },{
  212. text: '备注',
  213. flex: 3,
  214. dataIndex: 'be_remark'
  215. }],
  216. store: new Ext.data.Store({
  217. fields: ['be_class', 'be_code', 'be_date', 'be_checker', 'be_remark']
  218. })
  219. }],
  220. buttonAlign: 'center',
  221. buttons: [{
  222. text: $I18N.common.button.erpExportButton,
  223. iconCls: 'x-button-icon-excel',
  224. cls: 'x-btn-blue',
  225. handler: function(btn) {
  226. me.BaseUtil.exportGrid(btn.up('window').down('gridpanel'));
  227. }
  228. },{
  229. text: $I18N.common.button.erpCloseButton,
  230. cls: 'x-btn-blue',
  231. handler: function(btn) {
  232. btn.ownerCt.ownerCt.close();
  233. }
  234. }]
  235. });
  236. this.getBillError(record.get('type'), win.down('gridpanel'));
  237. }
  238. win.show();
  239. },
  240. getCurrentMonth: function(f) {
  241. var me = this;
  242. Ext.Ajax.request({
  243. url: basePath + 'fa/getMonth.action',
  244. params: {
  245. type: 'MONTH-P'
  246. },
  247. callback: function(opt, s, r) {
  248. var rs = Ext.decode(r.responseText);
  249. if(rs.data) {
  250. me.currentMonth = rs.data.PD_DETNO;
  251. me.datestart = Ext.Date.format(new Date(rs.data.PD_STARTDATE), 'Ymd');
  252. me.dateend = Ext.Date.format(new Date(rs.data.PD_ENDDATE), 'Ymd');
  253. me.preMonth = Ext.Date.format(new Date(rs.data.PD_STARTDATE-24*60*60*1000) , 'Ym');
  254. f.setValue(me.currentMonth);
  255. }
  256. }
  257. });
  258. },
  259. getBillError: function(type, grid) {
  260. Ext.Ajax.request({
  261. url: basePath + 'fa/getBillError.action',
  262. params: {
  263. type: type
  264. },
  265. callback: function(opt, s, r) {
  266. var rs = Ext.decode(r.responseText);
  267. if(rs.data) {
  268. grid.store.loadData(rs.data);
  269. } else if(rs.exceptionInfo) {
  270. showError(rs.exceptionInfo);
  271. }
  272. }
  273. });
  274. },
  275. getFreezeDetno: function(f) {
  276. Ext.Ajax.request({
  277. url: basePath + 'scm/reserve/getFreezeDetno.action',
  278. method: 'GET',
  279. callback: function(opt, s, r) {
  280. var rs = Ext.decode(r.responseText);
  281. if(rs.exceptionInfo) {
  282. showError(rs.exceptionInfo);
  283. } else if(rs.data) {
  284. f.setValue(rs.data);
  285. } else {
  286. f.setValue('无');
  287. }
  288. }
  289. });
  290. }
  291. });