Index: ssts-web/src/main/webapp/disinfectsystem/invoice/invoiceView.js =================================================================== diff -u -r14591 -r14652 --- ssts-web/src/main/webapp/disinfectsystem/invoice/invoiceView.js (.../invoiceView.js) (revision 14591) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/invoiceView.js (.../invoiceView.js) (revision 14652) @@ -1308,14 +1308,14 @@ } } - var ids = null; - for ( var i = 0, len = records.length; i < len; i++) { - if (ids == null) { - ids = records[i].data['id']; - } else { - ids = ids + ',' + records[i].data['id']; - } - } + var ids = getSelectedIds(); +// for ( var i = 0, len = records.length; i < len; i++) { +// if (ids == null) { +// ids = records[i].data['id']; +// } else { +// ids = ids + ',' + records[i].data['id']; +// } +// } batchPrintInvoices(ids, depart, 0,sendTime,sender,serialNumber,remark,applicationTime); } @@ -1778,6 +1778,96 @@ ] }); + /** + * 显示和选择打印发货单的配置 + */ + function showSelectUser(){ + return openModalWindow(WWWROOT+"/disinfectsystem/invoice/selectInvoiceConfig.jsp?"); + } + function batchPrintInvoiceWithType(ids,type){ + var mask = new Ext.LoadMask(Ext.getBody(), { + msg : '正在处理打印请求,请稍候...' + }); + mask.show(); + + Ext.Ajax.timeout=300*000; + Ext.Ajax.request({ + timeout: 300*000, + url : WWWROOT + '/disinfectSystem/invoiceAction!mergeLoadPrintData.do', + params : {ids : ids,type:type}, + success : function(response){ + var result = Ext.decode(response.responseText); + if(!result.success){ + if(result.message){ + showResult(result.message); + } + }else{ + if(result.batches.length <= 0){ + showResult("没有打印数据"); + }else{ + for(var i = 0; i < result.batches.length;++i){ + batchPrintInvoices_result(result.batches[i], 0); + } + grid.dwrReload(); + } + + //updatePrintStatus(ids); + } + mask.hide(); + }, + failure: function(response){ + showResult("打印失败!"); + mask.hide(); + } + }); + } + function batchPrint(){ + var selectResult = showSelectUser(); + if(selectResult == null && selectResult == undefined){ + return; + } + var id = selectResult.split("&#;")[0]; + if(id == '' || id == null){ + showResult('请选择对应的班次!'); + return; + } + var mask = new Ext.LoadMask(Ext.getBody(), { + msg : '正在处理批量打印请求,请稍候...' + }); + mask.show(); + + Ext.Ajax.timeout=300*000; + Ext.Ajax.request({ + timeout: 300*000, + url : WWWROOT + '/disinfectSystem/invoiceAction!mergeLoadPrintDataByConfig.do', + params : {id : id}, + success : function(response){ + var result = Ext.decode(response.responseText); + if(!result.success){ + if(result.message){ + showResult(result.message); + } + }else{ + if(result.batches.length <= 0){ + showResult("没有打印数据"); + }else{ + for(var i = 0; i < result.batches.length;++i){ + batchPrintInvoices_result(result.batches[i], 0); + } + grid.dwrReload(); + } + + //updatePrintStatus(ids); + } + mask.hide(); + }, + failure: function(response){ + showResult("打印失败!"); + mask.hide(); + } + }); + } + var tbar = [{ text : '查看', hidden : SSTS_Invoice_Update, @@ -1799,13 +1889,79 @@ handler : function() { grid.dwrReload(); } - }, { + },{ + text : '设为已打印', + hidden : !(sstsConfig.printInvoiceVersion==2), + iconCls : 'icon_print', + handler : function() { + var ids = getSelectedIds(); + top.Ext.MessageBox.confirm("请确认", "要将所选发货单的状态设置为已打印吗?", + function(btn) { + if (btn == 'yes') { + updatePrintStatus(ids); + } + }); + } + },{ text : '批量打印', + hidden : (sstsConfig.printInvoiceVersion==2), iconCls : 'icon_print', handler : function() { mergePrintInvoices(); } },{ + type : 'button', + text : '打印'+entityName, + hidden : !(sstsConfig.printInvoiceVersion==2), + iconCls : 'icon_print', + menu: new Ext.menu.Menu({ + items: [ + {text: '批量打印' + entityName, hidden: !validateIsSupplyRoomUser,handler: batchPrint}, + {text: '打印一次性物品', handler:function(){ + checkPrintStatus(function(){ + var ids = getSelectedIds(); + if (ids != null && ids != false){ + top.Ext.MessageBox.confirm("请确认", "要打印所选的发货单的一次性物品吗?", + function(btn) { + if (btn == 'yes') { + batchPrintInvoiceWithType(ids,'一次性物品'); + } + }); + } + }); + } + }, + {text: '打印器械包及消毒物品', handler: function(){ + checkPrintStatus(function(){ + var ids = getSelectedIds(); + if (ids != null && ids != false){ + top.Ext.MessageBox.confirm("请确认", "要打印所选发货单的器械包及消毒物品吗?", + function(btn) { + if (btn == 'yes') { + batchPrintInvoiceWithType(ids,'器械包'); + } + }); + } + }); + } + }, + {text: '打印全部物品', handler: function(){ + checkPrintStatus(function(){ + var ids = getSelectedIds(); + if (ids != null && ids != false){ + top.Ext.MessageBox.confirm("请确认", "要打印所选发货单的全部物品吗?", + function(btn) { + if (btn == 'yes') { + batchPrintInvoiceWithType(ids,'全部'); + } + }); + } + }); + } + } + ] + }) + },{ text : '打印', hidden : true, // TODO:待实现 iconCls : 'icon_print', @@ -1974,20 +2130,48 @@ } }); + function checkPrintStatus(callback){ + var records = grid.getSelectionModel().getSelections(); + if (records.length == 0) { + showResult("请选择发货单!"); + return false; + } + var hasPrintedInvoice = false; + for ( var i = 0; i < records.length; i++) { + if(records[i].data['isPrint'] == '是'){ + hasPrintedInvoice = true; + break; + } + } + if(hasPrintedInvoice){ + top.Ext.MessageBox.confirm("请确认", "选中发货单中包含已打印的发货单,是否确定要打印?", function(button, + text) { + if ("yes" == button) { + if(callback){ + callback(); + } + } + }); + }else{ + if(callback){ + callback(); + } + } + } function getSelectedIds(){ var records = grid.getSelectionModel().getSelections(); if (records.length == 0) { - showResult("请选择要打印的发货单!"); + showResult("请选择发货单!"); return false; } var ids = null; for ( var i = 0, len = records.length; i < len; i++) { if (ids == null) { ids = records[i].data['id']; } else { - ids = ids + ';' + records[i].data['id']; + ids = ids + ',' + records[i].data['id']; } - } + } return ids; }