BatchDeal.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687
  1. Ext.QuickTips.init();
  2. Ext.define('erp.controller.common.BatchDeal', {
  3. extend: 'Ext.app.Controller',
  4. requires: ['erp.util.FormUtil', 'erp.util.GridUtil', 'erp.util.BaseUtil', 'erp.util.RenderUtil'],
  5. views:[
  6. 'common.batchDeal.Viewport','common.batchDeal.Form','common.batchDeal.GridPanel','core.trigger.AddDbfindTrigger','core.button.CheckCustomerUU',
  7. 'core.trigger.DbfindTrigger','core.form.FtField','core.form.FtFindField','core.form.ConDateField','core.button.TurnMeetingButton','core.button.CheckVendorUU',
  8. 'core.trigger.TextAreaTrigger','core.form.YnField', 'core.form.MonthDateField','core.form.ConMonthDateField','core.trigger.SchedulerTrigger',
  9. 'core.grid.YnColumn','core.form.DateHourMinuteField','core.form.SeparNumber','core.grid.YnColumnNV','core.button.ExportScanLogin'
  10. ],
  11. BaseUtil: Ext.create('erp.util.BaseUtil'),
  12. FormUtil: Ext.create('erp.util.FormUtil'),
  13. GridUtil: Ext.create('erp.util.GridUtil'),
  14. init:function(){
  15. var me = this;
  16. me.resized = false;
  17. this.control({
  18. 'erpBatchDealFormPanel': {
  19. alladded: function(form){
  20. var grid = Ext.getCmp('batchDealGridPanel');
  21. me.resize(form, grid);
  22. var items = form.items.items, autoQuery = false;
  23. Ext.each(items, function() {
  24. var val = getUrlParam(this.name);
  25. if(!Ext.isEmpty(val)) {
  26. this.setValue(val);
  27. autoQuery = true;
  28. if(this.xtype == 'dbfindtrigger') {
  29. this.autoDbfind('form', caller, this.name, this.name + " like '%" + val + "%'");
  30. }
  31. }
  32. });
  33. if(autoQuery) {
  34. setTimeout(function(){
  35. form.onQuery();
  36. }, 1000);
  37. }
  38. }
  39. },
  40. 'erpBatchDealGridPanel': {
  41. afterrender: function(grid){
  42. var form = Ext.getCmp('dealform');
  43. me.resize(form, grid);
  44. grid.store.on('datachanged', function(store){
  45. me.getProductWh(grid);
  46. });
  47. if(caller == 'ARBill!ToBillOut!Deal'||caller == 'APBill!ToBillOutAP!Deal'){
  48. grid.plugins[0].on('afteredit',function(){
  49. me.countAmount(grid);
  50. });
  51. grid.on('selectionchange',function(){
  52. me.countAmount(grid);
  53. });
  54. }
  55. }
  56. },
  57. 'field[name=differ]': {
  58. change: function(field){
  59. var grid = Ext.getCmp('batchDealGridPanel');
  60. me.countAmount(grid);
  61. }
  62. },
  63. 'erpExportScanLoginButton':{
  64. click:function(btn){
  65. me.beforeExportScanLogin();
  66. }
  67. },
  68. 'erpVastDealButton': {
  69. click: function(btn){
  70. me.vastDeal(btn.ownerCt.ownerCt.dealUrl);
  71. }
  72. },
  73. 'erpVastAnalyseButton': {
  74. click: function(btn){
  75. me.vastDeal(btn.ownerCt.ownerCt.dealUrl);
  76. }
  77. },
  78. 'erpVastPrintButton': {
  79. click: function(btn){
  80. me.vastDeal(btn.ownerCt.ownerCt.dealUrl);
  81. }
  82. },
  83. 'erpVastAllotButton':{
  84. click:function(btn){
  85. me.vastDeal(btn.ownerCt.ownerCt.dealUrl);
  86. }
  87. },
  88. 'erpSaveCostDetailButton':{
  89. click:function(btn){
  90. me.vastDeal('cost/vastSaveCostDetail.action');
  91. }
  92. },
  93. 'erpDifferVoucherCreditButton':{
  94. click:function(btn){
  95. me.vastDeal('cost/vastDifferVoucherCredit.action');
  96. }
  97. },
  98. 'SchedulerTrigger':{
  99. afterrender:function(trigger){
  100. trigger.setFields=[{field:'va_vecard',mappingfield:'ID'},{field:'va_driver',mappingfield:'VA_DRIVER'}];
  101. }
  102. },
  103. 'erpEndCRMButton':{
  104. click:function(btn){
  105. me.vastDeal('crm/chanceTurnEnd.action');
  106. }
  107. },
  108. 'monthdatefield': {
  109. afterrender: function(f) {
  110. var type = '', con = null;
  111. if(f.name == 'vo_yearmonth' && caller == 'Voucher!Audit!Deal') {
  112. type = 'MONTH-A';
  113. con = Ext.getCmp('condatefield');
  114. } else if(f.name == 'vo_yearmonth' && caller == 'Voucher!ResAudit!Deal') {
  115. type = 'MONTH-A';
  116. con = Ext.getCmp('condatefield');
  117. } else if(f.name == 'vo_yearmonth' && caller == 'CashFlowSet') {
  118. type = 'MONTH-A';
  119. con = Ext.getCmp('condatefield');
  120. } else if(f.name == 'vm_yearmonth' && caller == 'VendMonth!Cyf!Batch') {
  121. type = 'MONTH-V';
  122. con = Ext.getCmp('condatefield');
  123. } else if(f.name == 'cm_yearmonth' && caller == 'CustMonth!Cys!Batch') {
  124. type = 'MONTH-C';
  125. con = Ext.getCmp('condatefield');
  126. } else if(f.name == 'cd_yearmonth' && caller == 'Make!Cost!Deal') {
  127. type = 'MONTH-T';
  128. con = Ext.getCmp('condatefield');
  129. }
  130. if(type != '') {
  131. this.getCurrentMonth(f, type, con);
  132. }
  133. },
  134. change: function(f) {
  135. if(f.name == 'vo_yearmonth' &&( caller == 'Voucher!Audit!Deal'||caller == 'Voucher!ResAudit!Deal')){
  136. if(!Ext.isEmpty(f.value)) {
  137. var d = Ext.ComponentQuery.query('condatefield');
  138. if(d && d.length > 0)
  139. d[0].setMonthValue(f.value);
  140. }
  141. }
  142. }
  143. },
  144. 'erpRefreshQtyButton': {
  145. click : function() {
  146. this.refreshQty(caller);
  147. }
  148. }
  149. });
  150. },
  151. resize: function(form, grid){
  152. if(!this.resized && form && grid && form.items.items.length > 0){
  153. var height = window.innerHeight,
  154. fh = form.getEl().down('.x-panel-body>.x-column-inner').getHeight();
  155. if(Ext.isIE){
  156. height = screen.height*0.75;
  157. }
  158. form.setHeight(35 + fh);
  159. grid.setHeight(height - fh - 35);
  160. this.resized = true;
  161. }
  162. },
  163. countGrid: function(){
  164. //重新计算合计栏值
  165. var grid = Ext.getCmp('batchDealGridPanel');
  166. Ext.each(grid.columns, function(column){
  167. if(column.summary){
  168. var sum = 0;
  169. Ext.each(grid.store.data.items, function(item){
  170. if(item.value != null && item.value != ''){
  171. sum += Number(item.value);
  172. }
  173. });
  174. Ext.getCmp(column.dataIndex + '_sum').setText(column.text + '(sum):' + sum);
  175. } else if(column.average) {
  176. var average = 0;
  177. Ext.each(grid.store.data.items, function(item){
  178. if(item.value != null && item.value != ''){
  179. average += Number(item.value);
  180. }
  181. });
  182. average = average/grid.store.data.items.length;
  183. Ext.getCmp(column.dataIndex + '_average').setText(column.text + '(average):' + average);
  184. } else if(column.count) {
  185. var count = 0;
  186. Ext.each(grid.store.data.items, function(item){
  187. if(item.value != null && item.value != ''){
  188. count++;
  189. }
  190. });
  191. Ext.getCmp(column.dataIndex + '_count').setText(column.text + '(count):' + count);
  192. }
  193. });
  194. },
  195. vastDeal: function(url){
  196. var me = this, grid = Ext.getCmp('batchDealGridPanel');
  197. var items = grid.selModel.getSelection();
  198. grid.multiselected = [];
  199. Ext.each(items, function(item, index){
  200. if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  201. && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
  202. item.index = this.data[grid.keyField];
  203. grid.multiselected.push(item);
  204. }
  205. });
  206. var form = Ext.getCmp('dealform');
  207. var records = Ext.Array.unique(grid.multiselected);
  208. if(records.length > 0){
  209. if(contains(url,'common/form/vastPost.action',true)) {
  210. this.vastPost(grid, records, url);
  211. return;
  212. }
  213. var params = new Object();
  214. params.id=new Array();
  215. params.caller = caller;
  216. var data = new Array();
  217. var bool = false;
  218. Ext.each(records, function(record, index){
  219. var f = form.fo_detailMainKeyField;
  220. if((grid.keyField && this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  221. && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0)
  222. ||(f && this.data[f] != null && this.data[f] != ''
  223. && this.data[f] != '0' && this.data[f] != 0)){
  224. bool = true;
  225. var o = new Object();
  226. if(grid.keyField){
  227. o[grid.keyField] = record.data[grid.keyField];
  228. } else {
  229. params.id[index] = record.data[form.fo_detailMainKeyField];
  230. }
  231. if(grid.toField){
  232. Ext.each(grid.toField, function(f, index){
  233. var v = Ext.getCmp(f).value;
  234. if(v != null && v.toString().trim() != '' && v.toString().trim() != 'null'){
  235. if(Ext.isDate(v)){
  236. v = Ext.Date.toString(v);
  237. }
  238. o[f] = v;
  239. } else {
  240. o[f] = '';
  241. }
  242. });
  243. }
  244. if(grid.necessaryFields){
  245. Ext.each(grid.necessaryFields, function(f, index){
  246. var v = record.data[f];
  247. if(Ext.isDate(v)){
  248. v = Ext.Date.toString(v);
  249. }
  250. if(Ext.isNumber(v)){
  251. v = (v).toString();
  252. }
  253. o[f] = v;
  254. });
  255. }
  256. data.push(o);
  257. }
  258. });
  259. if(bool && !me.dealing){
  260. params.data = unescape(Ext.JSON.encode(data).replace(/\\/g,"%"));
  261. me.dealing = true;
  262. var main = parent.Ext.getCmp("content-panel");
  263. main.getActiveTab().setLoading(true);//loading...
  264. Ext.Ajax.request({
  265. url : basePath + url,
  266. params: params,
  267. method : 'post',
  268. timeout: 6000000,
  269. callback : function(options,success,response){
  270. main.getActiveTab().setLoading(false);
  271. me.dealing = false;
  272. var localJson = new Ext.decode(response.responseText);
  273. if(localJson.exceptionInfo){
  274. var str = localJson.exceptionInfo;
  275. if(str.trim().substr(0, 12) == 'AFTERSUCCESS'){
  276. str = str.replace('AFTERSUCCESS', '');
  277. grid.multiselected = new Array();
  278. Ext.getCmp('dealform').onQuery();
  279. }
  280. showError(str);return;
  281. }
  282. if(localJson.success){
  283. if(localJson.log){
  284. showMessage("提示", localJson.log);
  285. }
  286. grid.multiselected = new Array();
  287. Ext.getCmp('dealform').onQuery();
  288. /*Ext.Msg.alert("提示", "处理成功!", function(){
  289. grid.multiselected = new Array();
  290. Ext.getCmp('dealform').onQuery();
  291. });*/
  292. }
  293. }
  294. });
  295. } else {
  296. showError("没有需要处理的数据!");
  297. }
  298. } else {
  299. showError("请勾选需要的明细!");
  300. }
  301. },
  302. getCurrentMonth: function(f, type, con) {
  303. Ext.Ajax.request({
  304. url: basePath + 'fa/getMonth.action',
  305. params: {
  306. type: type
  307. },
  308. callback: function(opt, s, r) {
  309. var rs = Ext.decode(r.responseText);
  310. if(rs.data) {
  311. f.setValue(rs.data.PD_DETNO);
  312. if(con != null) {
  313. con.setMonthValue(rs.data.PD_DETNO);
  314. }
  315. }
  316. }
  317. });
  318. },
  319. vastPost: function(grid, records, url) {
  320. var me = this, win = Ext.getCmp('win-post');
  321. grid._postrecords = records;
  322. if(!win) {
  323. win = Ext.create('Ext.Window', {
  324. id: 'win-post',
  325. width: '70%',
  326. height: '60%',
  327. modal: true,
  328. layout: 'anchor',
  329. items: [{
  330. xtype: 'form',
  331. anchor: '100% 100%',
  332. bodyStyle: 'background: #f1f1f1;',
  333. layout: 'column',
  334. defaults: {
  335. xtype: 'checkbox',
  336. margin: '2 10 2 10',
  337. columnWidth: .33
  338. },
  339. items: [{
  340. xtype: 'displayfield',
  341. fieldLabel: '当前账套',
  342. id: 'ma_name'
  343. },{
  344. xtype: 'displayfield',
  345. fieldLabel: '账套描述',
  346. margin: '2 10 30 10',
  347. id: 'ma_function'
  348. },{
  349. xtype: 'displayfield',
  350. fieldLabel: '目标账套',
  351. columnWidth: 1
  352. },{
  353. boxLabel: '全选',
  354. columnWidth: 1,
  355. listeners: {
  356. change: function(f) {
  357. var form = f.up('form');
  358. form.getForm().getFields().each(function(a){
  359. if(a.xtype == 'checkbox' && a.id != f.id) {
  360. a.setValue(f.value);
  361. }
  362. });
  363. }
  364. }
  365. }]
  366. }],
  367. buttonAlign: 'center',
  368. buttons: [{
  369. text: $I18N.common.button.erpConfirmButton,
  370. cls: 'x-btn-blue',
  371. handler: function(btn) {
  372. var w = btn.ownerCt.ownerCt, form = w.down('form'),
  373. from = form.down('#ma_name').value,
  374. items = form.query('checkbox[checked=true]'),
  375. data = new Array();
  376. Ext.each(items, function(item){
  377. if (item.ma_name)
  378. data.push(item.ma_name);
  379. });
  380. if(data.length > 0)
  381. me.post(w, grid, url, from, data.join(','));
  382. }
  383. },{
  384. text: $I18N.common.button.erpCloseButton,
  385. cls: 'x-btn-blue',
  386. handler: function(btn) {
  387. btn.ownerCt.ownerCt.hide();
  388. }
  389. }]
  390. });
  391. if(contains(url,'?_out=1',true)) this.getOutMasters(win);
  392. else this.getMasters(win);
  393. }
  394. win.show();
  395. },
  396. post: function(w, grid, url, from, to) {
  397. var records = grid._postrecords;
  398. w.setLoading(true);
  399. var d = new Array(), f = grid.keyField;
  400. Ext.each(records, function(r) {
  401. d.push(r.get(f));
  402. });
  403. Ext.Ajax.request({
  404. url: basePath + url,
  405. params: {
  406. caller: caller,
  407. data: d.join(','),
  408. to: to
  409. },
  410. callback: function(opt, s, r) {
  411. w.setLoading(false);
  412. if(s) {
  413. var rs = Ext.decode(r.responseText);
  414. if(rs.data) {
  415. showMessage('提示', rs.data);
  416. } else {
  417. alert('抛转成功!');
  418. }
  419. grid.multiselected = new Array();
  420. grid._postrecords = null;
  421. Ext.getCmp('dealform').onQuery();
  422. w.hide();
  423. }
  424. }
  425. });
  426. },
  427. /**
  428. * 加载系统所有账套
  429. */
  430. getMasters: function(win){
  431. Ext.Ajax.request({
  432. url: basePath + 'common/getMasters.action',
  433. method: 'get',
  434. callback: function(opt, s, res){
  435. var r = Ext.decode(res.responseText), c = r.currentMaster;
  436. if(r.masters){
  437. var form = win.down('form'), items = new Array();
  438. for(var i in r.masters) {
  439. var d = r.masters[i];
  440. if(d.ma_name != c) {
  441. if(d.ma_type == 3) {
  442. var o = {boxLabel: d.ma_name + '(' + d.ma_function + ')', ma_name: d.ma_name};
  443. items.push(o);
  444. }
  445. } else {
  446. form.down('#ma_name').setValue(c);
  447. form.down('#ma_function').setValue(d.ma_function);
  448. }
  449. }
  450. form.add(items);
  451. }
  452. }
  453. });
  454. },
  455. getOutMasters:function(win){
  456. Ext.Ajax.request({
  457. url: basePath + 'common/getOutMasters.action',
  458. method: 'get',
  459. callback: function(opt, s, res){
  460. var r = Ext.decode(res.responseText), c = r.currentMaster;
  461. if(r.data){
  462. var form = win.down('form'), items = new Array();
  463. Ext.Array.each(r.data,function(d){
  464. var o = {boxLabel: d.MO_LOCATION + '(' + d.MO_NAME + ')', ma_name: d.MO_LOCATION};
  465. items.push(o);
  466. });
  467. form.down('#ma_name').setValue(c);
  468. //form.down('#ma_function').setValue(d.ma_function);
  469. form.add(items);
  470. }
  471. }
  472. });
  473. },
  474. refreshQty : function(cal) {
  475. var tab = null;
  476. switch(cal) {
  477. case 'Purchase!ToCheckAccept!Deal' :
  478. tab = 'Purchase';
  479. break;
  480. case 'Purchase!ToNotify!Deal' :
  481. tab = 'Purchase';
  482. break;
  483. case 'Sale!ToAccept!Deal':
  484. tab = 'Sale';
  485. break;
  486. case 'SendNotify!ToProdIN!Deal':
  487. tab = 'SendNotify';
  488. break;
  489. }
  490. var form = Ext.getCmp('dealform');
  491. form.setLoading(true);
  492. Ext.Ajax.request({
  493. url : basePath + 'common/resetqty.action',
  494. params : {
  495. tab : tab
  496. },
  497. callback : function(opt, s, res) {
  498. form.setLoading(false);
  499. var r = Ext.decode(res.responseText);
  500. if (r.success) {
  501. alert('已转数量重置成功!');
  502. // form.onQuery();
  503. }
  504. }
  505. });
  506. },
  507. getProductWh: function(grid) {
  508. var prodfield = grid.getProdField();
  509. if(prodfield) {
  510. var codes = [];
  511. grid.store.each(function(d){
  512. codes.push("'" + d.get(prodfield) + "'");
  513. });
  514. Ext.Ajax.request({
  515. url: basePath + 'scm/product/getProductwh.action',
  516. params: {
  517. codes: codes.join(',')
  518. },
  519. callback: function (opt, s, r) {
  520. if(s) {
  521. var rs = Ext.decode(r.responseText);
  522. if(rs.data) {
  523. grid.productwh = rs.data;
  524. }
  525. }
  526. }
  527. });
  528. }
  529. },
  530. countAmount: function(grid){
  531. var me = this;
  532. var items = grid.selModel.selected.items;
  533. var countamount=0;
  534. var taxsum = 0,
  535. differ = Ext.getCmp('differ');
  536. priceFormat = grid.down('gridcolumn[dataIndex=abd_thisvoprice]').format,
  537. fsize = (priceFormat && priceFormat.indexOf('.') > -1) ?
  538. priceFormat.substr(priceFormat.indexOf('.') + 1).length : 6;
  539. Ext.each(items,function(item,index){
  540. var a = Number(grid.BaseUtil.numberFormat(Number(item.data['abd_thisvoprice']),fsize));
  541. var b = Number(grid.BaseUtil.numberFormat(Number(item.data['abd_thisvoqty']),2));
  542. var rate = Number(grid.BaseUtil.numberFormat(Number(item.data['abd_taxrate']),2));
  543. countamount = countamount + Number(grid.BaseUtil.numberFormat(a*b,2));
  544. taxsum = taxsum + Number(grid.BaseUtil.numberFormat((a*b*rate/100)/(1+rate/100),2));
  545. });
  546. //金额合计 不能填写 自动显示所选数据条目的本次发票数*本次发票单价 的总和
  547. Ext.getCmp('pi_amounttotal').setValue(Ext.util.Format.number(countamount, "0.00"));
  548. if(differ && !Ext.isEmpty(differ.value)){
  549. Ext.getCmp('taxsum').setValue(Ext.util.Format.number(taxsum+differ.value, "0.00"));
  550. } else {
  551. Ext.getCmp('taxsum').setValue(Ext.util.Format.number(taxsum, "0.00"));
  552. }
  553. },
  554. //确认投放数量,在修改完计划投放数量时候点击按钮,将选中行的数量保存,并且限制不能超过建议变更数
  555. ConfirmThrowQty:function(){
  556. var grid = Ext.getCmp('batchDealGridPanel');
  557. var count=0;
  558. if(grid.multiselected.length==0){
  559. var items = grid.selModel.getSelection();
  560. Ext.each(items, function(item, index){
  561. if(this.data[grid.keyField] != null && this.data[grid.keyField] != ''
  562. && this.data[grid.keyField] != '0' && this.data[grid.keyField] != 0){
  563. grid.multiselected.push(item);
  564. }
  565. });
  566. }
  567. var records = Ext.Array.unique(grid.multiselected);
  568. var gridStore = new Array();
  569. var dd;
  570. if(records.length>0){
  571. Ext.each(records, function(records, index){
  572. if(records.data.md_prodcode!=''){
  573. dd=new Object();
  574. dd['mr_mpsid']=records.data.mr_mpsid;
  575. gridStore[index] = Ext.JSON.encode(dd);
  576. count++;
  577. }
  578. });
  579. this.ConfirmThrow(gridStore);
  580. } else {
  581. showError("没有需要处理的数据!");
  582. }
  583. },
  584. ComfirmThrow:function(store){
  585. if(this.throwing) {
  586. alert('正在执行...不要重复点击!');
  587. return;
  588. }
  589. var me = this, gridstore = store;
  590. var main = parent.Ext.getCmp("content-panel");
  591. main.getActiveTab().setLoading(true);//loading...
  592. var btn = Ext.getCmp('erpConfirmThrowQtyButton');
  593. if(btn) btn.setDisabled(true);
  594. this.throwing = true;
  595. Ext.Ajax.request({
  596. url : basePath + "pm/MPSMain/NeedThrow.action",
  597. params: {
  598. mainCode:Ext.getCmp('md_mpscode').value,
  599. caller:caller,
  600. gridStore:unescape(gridstore.toString().replace(/\\/g,"%")),
  601. toWhere:'AUTO',
  602. toCode:Ext.getCmp('md_ordercode').value,
  603. condition:''
  604. },
  605. timeout: 60000,
  606. method : 'post',
  607. callback : function(options,success,response){
  608. btn.setDisabled(false);
  609. me.throwing = false;
  610. main.getActiveTab().setLoading(false);
  611. var localJson = new Ext.decode(response.responseText);
  612. if(localJson.exceptionInfo){
  613. showError(localJson.exceptionInfo);
  614. return "";
  615. }
  616. if(localJson.success){
  617. if(localJson.log){
  618. showMessage("提示", localJson.log);
  619. }
  620. Ext.Msg.alert("提示", "处理成功!", function(){
  621. Ext.getCmp('dealform').onQuery();
  622. });
  623. }
  624. }
  625. });
  626. },
  627. beforeExportScanLogin:function(){
  628. //form里面数据
  629. var me = this;
  630. var grid = Ext.getCmp('batchDealGridPanel');
  631. var data=me.GridUtil.getGridSelected(grid);
  632. if(data.length == 0 || data == null){
  633. showError("请先选择需要批量导出的人员资料");
  634. return ;
  635. }
  636. var param = new Array();
  637. Ext.each(data,function(item,index){
  638. param.push(item.em_id);
  639. })
  640. param = param == null ? [] : "[" + param.toString().replace(/\\/g,"%") + "]";
  641. var mb = new Ext.window.MessageBox();
  642. mb.wait('正在查询中','请稍后...',{
  643. interval: 10000, //bar will move fast!
  644. duration: 50000,
  645. increment: 5,
  646. /* text: 'Runing...',*/
  647. scope: this
  648. });
  649. //me.FormUtil.setLoading(true);//loading...
  650. Ext.Ajax.request({
  651. url : basePath+'hr/employee/ExportScanLogin.action',
  652. params: {
  653. caller:caller,
  654. gridStore:param
  655. },
  656. method : 'post',
  657. timeout:50000,
  658. callback : function(options,success,response){
  659. //me.FormUtil.setLoading(false);
  660. mb.close();
  661. var localJson = new Ext.decode(response.responseText);
  662. if(localJson.success){
  663. showMessage('提示', '操作成功!', 1000);
  664. var ids=localJson.ids;
  665. //导出
  666. var con="em_id in"+ids;
  667. me.BaseUtil.createExcel('ScanCodeLogin!query', 'detailgrid', con);
  668. grid.GridUtil.loadNewStore(grid, {
  669. caller: caller,
  670. condition: 'em_id in'+ids
  671. });
  672. } else if(localJson.exceptionInfo){
  673. var str = localJson.exceptionInfo;
  674. showError(str);return;
  675. }
  676. }
  677. });
  678. }
  679. });