Index: ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/action/InvoiceAction.java =================================================================== diff -u -r21092 -r21115 --- ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/action/InvoiceAction.java (.../InvoiceAction.java) (revision 21092) +++ ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/action/InvoiceAction.java (.../InvoiceAction.java) (revision 21115) @@ -2215,4 +2215,20 @@ util.addFunctionCall("testReverseAjax", msg); } } + /** + * 干预-修改装配时间 + */ + public void modifyInvoiceTime(){ + String id = StrutsParamUtils.getPraramValue("id", null); + String invoiceTime = StrutsParamUtils.getPraramValue("invoiceTime1", null); + + JSONObject obj = new JSONObject(); + try { + invoiceManager.interfere_modifyInvoiceTime(id, invoiceTime); + obj = JSONUtil.buildJsonObject(true, "操作成功!"); + } catch (Exception e) { + obj = JSONUtil.buildJsonObject(false, e.getMessage()); + } + StrutsResponseUtils.output(obj); + } } Index: ssts-web/src/main/webapp/disinfectsystem/interfere/invoice/invoiceView.js =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/interfere/invoice/invoiceView.js (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/interfere/invoice/invoiceView.js (revision 21115) @@ -0,0 +1,2295 @@ +var entityName = "发货单"; +var grid; +var tousseTypeDataArray = [['全部','全部'],['一次性物品','一次性物品'],['器械包','器械包'],['敷料包','敷料包'],['消毒物品','消毒物品'],['自定义器械包','自定义器械包'],['外来器械包','外来器械包'],['外来器械拆分小包','外来器械拆分小包'],['外部代理灭菌','外部代理灭菌']]; +var rd = new Ext.data.JsonReader({ + fields : [ + {name : 'id'}, + {name : 'barcode'}, + {name : 'name'}, + {name : 'unit'}, + {name : 'showTousseName'}, + {name : 'count'}, + {name : 'diposable'}, + {name : 'price'}, + {name : 'tempAmount'}, + {name : 'amount'}, + {name : 'applicationAmount'}, + {name : 'batchNumber'}, + {name : 'type'} + ] +}); + +var tousseInstanceStoreReader = new Ext.data.JsonReader({ + fields : [ + {name : 'id'}, + {name : 'barcode'}, + {name : 'expensiveDGBarcode'}, + {name : 'name'}, + {name : 'specification'}, + {name : 'showTousseName'}, + {name : 'count'}, + {name : 'unit'}, + {name : 'diposable'}, + {name : 'price'}, + {name : 'fluctuationPrice'}, + {name : 'storage'}, + {name : 'batchNumber'}, + {name : 'sterilizerName'}, + {name : 'frequency'}, + {name : 'externalCode'}, + {name : 'tousseType'}, + {name : 'expireDate'}, + {name : 'manufacturer'}, + {name : 'certification'}, + {name : 'type'} + ] +}); + +function getDefaultAmount(v, p, record) { + if (v == null || v.length <= 0) { + return 0; + } else { + return v; + } +} +function removeGridItem(id) { + var rows = top.Ext.getCmp('recyclingGrid2').getSelectionModel() + .getSelections();// 返回值为 + if (rows) { + for ( var i = 0; i < rows.length; i++) { + var name = rows[i].data['name']; + var amount = rows[i].data['count']; + tousseInstanceStore.remove(rows[i]); + updateAmount1(name, amount); + } + } +} +function removeGridItem2(id) { + var rows = top.Ext.getCmp('recyclingGrid1').getSelectionModel() + .getSelections();// 返回值为 + if (rows) { + for ( var i = 0; i < rows.length; i++) { + var name = rows[i].data['name']; + var amount = rows[i].data['count']; + invoiceStore.remove(rows[i]); + var str = top.Ext.getCmp('deleteInvoicePlanItems').getValue(); + if (str.length <= 0) { + top.Ext.getCmp('deleteInvoicePlanItems').setValue(name); + } else { + top.Ext.getCmp('deleteInvoicePlanItems').setValue( + str + ";" + name); + } + } + } +} + +function removeGridForeignItem() { + var rows = top.Ext.getCmp('recyclingGrid1').getSelectionModel() + .getSelections();// 返回值为 + if (rows) { + for ( var i = 0; i < rows.length; i++) { + removeForeignBarcodeItemArr.push(rows[i].data.barcode); + var index = tousseInstanceStore.find('barcode', + rows[i].data.barcode); + if (index != -1) { + var record = tousseInstanceStore.getAt(index); + tousseInstanceStore.remove(record); + } + invoiceStore.remove(rows[i]); + } + } +} + +function removeGridForeignItem2() { + var rows = top.Ext.getCmp('recyclingGrid2').getSelectionModel() + .getSelections();// 返回值为 + if (rows) { + for ( var i = 0; i < rows.length; i++) { + var barcode = rows[i].data['barcode']; + tousseInstanceStore.remove(rows[i]); + updateAmountWithBarcode(barcode, 0); + } + } +} + +function addReturnTousseByInvoice(invoiceId){ + document.location.href = WWWROOT+'/disinfectsystem/returnGoodsRecord/returnTousseByInvoice.jsp?invoiceId='+invoiceId; +} +var diposableGooodsStore = new Ext.data.SimpleStore({ + fields : [ 'typeName' ], + url : WWWROOT + '/disinfectSystem/diposableGoodsAction!getDiposableGoodsType.do' +}); +// 发货时扫描的器械包 +var tousseInstanceStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + + '/disinfectSystem/invoiceAction!loadTousseInstaceByid.do', + method : 'POST' + }), + reader : tousseInstanceStoreReader +}); + +// 申请的物品 +var invoiceStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/invoiceAction!loadRecyclingApplicationByid.do', + method : 'POST' + }), + reader : rd +}); + +// 回收误差 +var recyclingErrorStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/invoiceAction!loadRecyclingRecordByid.do', + method : 'POST' + }), + reader : rd +}); + +// 扫描抢扫器械包事件 +var tempTousseInstanceJson = null; +var tousseType = null; +var addTousseInstance = Ext.data.Record.create([ + {name : 'id'}, + {name : 'barcode'}, + {name : 'name'}, + {name : 'showTousseName'}, + {name : 'count'}, + {name : 'diposable'}, + {name : 'price'}, + {name : 'fluctuationPrice'}, + {name : 'storage'}, + {name : 'batchNumber'}, + {name : 'tousseType'}, + {name : 'sterilizerName'}, + {name : 'frequency'}, + {name : 'isTracable'}, + {name : 'tousseDefinitionId'} +]); + +function loadTousseInstance(id, type) { + var barcode = top.Ext.getCmp("depart1").getValue().Trim(); + top.Ext.getCmp("depart1").setValue(''); + var invoiceType = type; + var b = isBarcodeRepeat(barcode); + if (b) { + showResult('条形码:' + barcode + ' 已经存在!'); + return false; + } + Ext.Ajax.request({ + url : WWWROOT + '/disinfectSystem/invoiceAction!loadTousseInstanceInfo.do', + params : { + idStr : id, + barcode : barcode, + invoiceType : invoiceType + }, + success : function(response, options) { + var result = Ext.decode(response.responseText); + + if (true) { + var validatePass = result.data.validatePass; + if (validatePass == false) { + showResult(result.data.showResult); + } else { + var goodsName = result.data.name; + var b = isInvoiceGoods(goodsName);// 验证是否为申请的物品 + if (b) { + var count = 1; + var totalAmount = 0; // 总库存 + for ( var i = 0; i < result.data.storage + .split('#%').length; i++) { + totalAmount += parseInt(result.data.storage + .split('#%')[i], 10); + } + if (result.data.diposable == '是') { + var index = invoiceStore.find( + "name", goodsName); + var waitDeliveryCount = invoiceStore + .getAt(index).data['count']; + var sendAmount = 0; + if (waitDeliveryCount <= totalAmount) { + for ( var i = 0; i < tousseInstanceStore + .getCount(); i++) { + var record = tousseInstanceStore + .getAt(i); + var tempGoodsName = record + .get("name"); + if (tempGoodsName == goodsName) { + sendAmount += record + .get("count"); + } + } + if (sendAmount != 0 + || sendAmount < waitDeliveryCount) { + count = (waitDeliveryCount - sendAmount); + } else { + count = waitDeliveryCount; + } + + } else { + count = totalAmount; + } + } + var showTousseName = goodsName; + + // 同一个批次有可能会有多个价格 + var totalAddAmount = count; + for ( var i = 0; i < result.data.price + .split('#%').length; i++) { + if (count <= parseInt(result.data.storage + .split('#%')[i], 10)) { + var record = new addTousseInstance( + { + id : 0, + barcode : barcode, + name : result.data.name, + showTousseName : showTousseName, + count : count, + diposable : result.data.diposable, + price : result.data.price + .split('#%')[i], + fluctuationPrice : result.data.fluctuationPrice + .split('#%')[i], + storage : result.data.storage + .split('#%')[i], + batchNumber : result.data.batchNumber, + tousseType : result.data.tousseType, + sterilizerName : result.data.sterilizerName, + frequency : result.data.frequency, + isTracable : result.data.isTracable, + tousseDefinitionId : result.data.tousseDefinitionId, + externalCode : result.data.externalCode + }); + tousseInstanceStore.add(record); + count = 0; + break; + } else { + var record = new addTousseInstance( + { + id : 0, + barcode : barcode, + name : result.data.name, + showTousseName : showTousseName, + count : result.data.storage + .split('#%')[i], + diposable : result.data.diposable, + price : result.data.price + .split('#%')[i], + fluctuationPrice : result.data.fluctuationPrice + .split('#%')[i], + storage : result.data.storage + .split('#%')[i], + batchNumber : result.data.batchNumber, + tousseType : result.data.tousseType, + sterilizerName : result.data.sterilizerName, + frequency : result.data.frequency, + isTracable : result.data.isTracable, + tousseDefinitionId : result.data.tousseDefinitionId, + externalCode : result.data.externalCode + }); + tousseInstanceStore.add(record); + count -= parseInt(result.data.storage + .split('#%')[i], 10); + } + } + updateAmount(result.data.name, totalAddAmount + - count); + } else { + showResult('[' + result.data.name + ']不在发货单中!'); + } + } + } else { + showResult('输入的条码无效!'); + } + }, + failure : function(response, options) { + var result = Ext.decode(response.responseText); + showResult(result.data.showResult); + } + }); +} + +function refreshList(){ +// alert('refreshList') + grid.dwrReload(); +} +// 验证条码是否是在发货单中存在--用于外部代理灭菌单 +function isBarcodeRepeatForeignProxy(barcode) { + if (barcode != null && barcode.length > 0) { + var index = invoiceStore.find('barcode', barcode); + if (index != -1) { + return true; + } + } + return false; +} + +// 验证条码是否重复扫描 +function isBarcodeRepeat(barcode) { + if (barcode != null && barcode.length > 0) { + for ( var i = 0; i < tousseInstanceStore.getCount(); i++) { + var record = tousseInstanceStore.getAt(i); + var tempBarcode = record.get('barcode'); + if (barcode == tempBarcode) { + return true; + break; + } + } + } + return false; +} +// 扫描的物品是否是发货单上的物品 +function isInvoiceGoods(name) { + if (name != null && name.length > 0) { + for ( var i = 0; i < invoiceStore.getCount(); i++) { + var record = invoiceStore.getAt(i); + var name1 = record.get('showTousseName'); + if (name == name1) { + return true; + break; + } + } + } + return false; +} +// 发货单明细累加 +function updateAmount(name, amount) { + if (name != null && name.length > 0) { + for ( var i = 0; i < invoiceStore.getCount(); i++) { + var record = invoiceStore.getAt(i); + var tempName = record.get('showTousseName'); + var tempAmount = record.get('tempAmount'); + if (tempName == name) { + if (tempAmount == null || tempAmount.length <= 0) { + tempAmount = 0; + } + record.set('tempAmount', Number(amount) + Number(tempAmount)); + } + } + } + return false; +} + +// 发货单明细累加 +function updateAmountWithBarcode(barcode, amount) { + if (barcode != null && barcode.length > 0) { + for ( var i = 0; i < invoiceStore.getCount(); i++) { + var record = invoiceStore.getAt(i); + var tempBarcode = record.get('barcode'); + if (tempBarcode == barcode) { + record.set('tempAmount', Number(amount)); + } + } + } + return false; +} +// 发货单明细修改 +function updateAmount2(name, amount) { + if (name != null && name.length > 0) { + for ( var i = 0; i < invoiceStore.getCount(); i++) { + var record = invoiceStore.getAt(i); + var tempName = record.get('name'); + var tempAmount = record.get('tempAmount'); + if (tempName == name) { + if (tempAmount == null || tempAmount.length <= 0) { + tempAmount = 0; + } + record.set('tempAmount', Number(amount)); + } + } + } + return false; +} +// 发货单明细累减 +function updateAmount1(name, amount) { + if (name != null && name.length > 0) { + for ( var i = 0; i < invoiceStore.getCount(); i++) { + var record = invoiceStore.getAt(i); + var tempName = record.get('showTousseName'); + var tempAmount = record.get('tempAmount'); + if (tempName == name) { + if (tempAmount == null || tempAmount.length <= 0) { + tempAmount = 0; + } + record.set('tempAmount', Number(tempAmount) - Number(amount)); + } + } + } + return false; +} + +// 查找对应的记录 +function getRecord(store, field, value, startIndex) { + for ( var i = 0; i < store.getCount(); i++) { + var record = store.getAt(i); + if (record.get(field) == value) { + return record; + } + } +} + +// 发货单窗口 +function openInvoiceForm(id, type) { + invoiceStore.removeAll(); + invoiceStore.on("beforeload", function(thiz, options) { + thiz.baseParams["id"] = id; + }); + invoiceStore.load(); + + recyclingErrorStore.removeAll(); + recyclingErrorStore.on("beforeload", function(thiz, options) { + thiz.baseParams["id"] = id; + }); + recyclingErrorStore.load(); + + tousseInstanceStore.removeAll(); + tousseInstanceStore.on("beforeload", function(thiz, options) { + thiz.baseParams["id"] = id; + }); + tousseInstanceStore.load(); + + // 外部器械包代理灭菌申请单 + var isForeignProxyDisinfection = (type == invoicePlanTypeForeignProxy ? true: false); + var recyclingapplicationCm = new Ext.grid.ColumnModel([ + {header : "申请的物品",dataIndex : 'showTousseName',width : 140,menuDisabled : true}, + {header : "name",dataIndex : 'name',hidden : true,menuDisabled : true}, + {header : "申请",dataIndex : 'count',width : 35,menuDisabled : true, + editor : new Ext.form.TextField({ + allowBlank : false, + listeners : { + focus : function(thiz) { + thiz.selectText(); + } + } + }) + }, + {header : '实发',id : 'tempAmount',dataIndex : 'tempAmount',width : 35,value : 0,menuDisabled : true,renderer : getDefaultAmount}, + {id : 'type',header : '类型',dataIndex : 'type',hidden:true,width : 40}, + {id : 'applicationAmount',header : "申请数量",dataIndex : 'applicationAmount',hidden : true,width : 50}, + {id : 'deleteItem',hidden:true,header : '删除',width : 30,menuDisabled : true, + renderer : function(v, p, record) { + var str = ""; + return str; + }, + dataIndex : 'button' + } + ]); + + var recyclingErrorCm = new Ext.grid.ColumnModel([ + {header : "材料名称",dataIndex : 'name',width : 200,menuDisabled : true}, + {header : "缺失数量",dataIndex : 'count',width : 60,menuDisabled : true}, + {header : '单价',id : 'price',dataIndex : 'price',width : 60,value : 0,menuDisabled : true} + ]); + + + var cm = new Ext.grid.ColumnModel([ + {id : 'id',dataIndex : 'id',hidden : true}, + {header : "条码",dataIndex : 'barcode',width : 50,menuDisabled : true, + renderer : function(v, p, record) { + if(!isUndefinedOrNullOrEmpty(record.data.expensiveDGBarcode)){ + return record.data.expensiveDGBarcode; + } + return record.data.barcode; + }}, + {header : "物品名称",dataIndex : 'showTousseName',width : 170,menuDisabled : true}, + {header : "name",dataIndex : 'name',hidden : true,menuDisabled : true}, + {header : "批次/灭菌日期",dataIndex : 'batchNumber',width : 70,menuDisabled : true}, + {header : "灭菌炉名称",dataIndex : 'sterilizerName',width : 100,menuDisabled : true,hidden : true}, + {header : "炉次",dataIndex : 'frequency',width : 50,menuDisabled : true,hidden : true}, + {id : 'diposable',header : "是否一次性材料",dataIndex : 'diposable',hidden : true,width : 50}, + {header : "单价",dataIndex : 'fluctuationPrice',width : 40,menuDisabled : false, + editor : new Ext.form.NumberField ({ + listeners : { + focus : function(thiz){ + if("自定义器械包申请单" == type){ + + var record = top.Ext.getCmp('recyclingGrid2').getSelectionModel().getSelected(); + top.Ext.MessageBox.prompt("自定义器械包价格修改提示","请输入价格",function(bu, txt){ + if(bu == "ok"){ + if(isPositiveNumeric(txt)){ + var invoiceId = top.Ext.getCmp('id').getValue(); + var customTousseBarcode = record.get('barcode'); + + Ext.Ajax.request({ + url: WWWROOT + '/disinfectSystem/invoiceAction!updateCustomToussePrice.do?id='+invoiceId+'&customTousseBarcode='+customTousseBarcode+'&newPrice='+txt, + success: function(response, options){ + showResult('价格更新成功'); + }, + failure: function(response, options) { + showResult('价格更新失败,请刷新页面再重试'); + } + }); + + record.set('price',txt); + record.set('fluctuationPrice',txt); + }else{ + showResult("请输入正确的价格"); + } + } + }); + + }else{ + top.Ext.MessageBox.alert("提示","非自定义器械包不能修改价格"); + } + } + } + }) + }, + {header : "数量",dataIndex : 'count',width : 30,menuDisabled : true, + editor : new Ext.form.NumberField ({ + listeners : { + focus:function(thiz){ + if("一次性物品申请单" != type){ + top.Ext.MessageBox.alert("提示","非一次性物品不能修改数量"); + }else{ + top.Ext.MessageBox.prompt("一次性物品数量修改提示","请输入数量",function(bu, txt){ + if(bu == "ok"){ + if(isPositiveInteger(txt)){ + var record = top.Ext.getCmp('recyclingGrid2').getSelectionModel().getSelected(); + record.set('count',txt); + var id = record.data['id']; + var name = record.data['name']; + var count = record.data['count']; + var storage = record.data['storage']; + if(id==0){ + if(parseInt(count) <= parseInt(storage)){ + updateAmount2(name,count); + } else { + showResult('库存量为:' + storage + ',已超过库存量!'); + var index = invoiceStore.find("name",name); + var tempAmount = invoiceStore.getAt(index).data['tempAmount']; + record.set('count',tempAmount); + + } + } else { + var record2 = getRecord(invoiceStore, "name", name, 0); + if(record2 != null) { + var tempAmount = record2.data['tempAmount']; + if(parseInt(count) <= (parseInt(storage) + parseInt(tempAmount))){ + updateAmount2(name,count); + } else { + showResult('库存量为:' + storage + ',已超过库存量!'); + record.set('count',tempAmount); + } + } + } + }else{ + showResult("请输入正确的数量"); + } + } + }); + } + } + } + }) + }, + {header : "发货类型",dataIndex : 'type',width : 40,menuDisabled : true} + ]); + + var form = new top.Ext.FormPanel({ + id : 'recyclingApplicationForm', + frame : true, + labelSeparator : ':', + bodyStyle : 'padding:5px 5px 0px 5px', + width : 1000, + height : 620, + // autoHeight : true, + autoScroll : true, + labelAlign : 'right', + layout : 'form', + items : [{ + xtype : "fieldset", + title : "基础数据", + layout : 'column', + autoHeight : true, + items : [{ + layout : 'column', + columnWidth : .55, + items : [{ + xtype : 'hidden', + name : 'id', + id : 'id' + },{ + xtype : 'hidden', + name : 'tousseInstanceIds', + id : 'tousseInstanceIds' + },{ + xtype : 'hidden', + name : 'recyclingappStoreData', + id : 'recyclingappStoreData' + },{ + xtype : 'hidden', + name : 'deleteInvoicePlanItems', + id : 'deleteInvoicePlanItems' + },{ + xtype : 'hidden', + name : 'status', + id : 'status' + },{ + layout : 'form', + labelWidth : 70, + columnWidth : .5, + items : [{ + xtype : 'textfield', + fieldLabel : '流水号', + maxLength : '41', + id : 'serialNumber', + name : 'serialNumber', + readOnly : true, + anchor : '99%', + cls : 'fieldReadOnlyNoRemove' + }] + },{ + layout : 'form', + labelWidth : 70, + columnWidth : .5, + items : [{ + xtype : 'textfield', + fieldLabel : '申请人', + maxLength : '41', + id : 'applicant2', + name : 'applicant', + readOnly : true, + anchor : '99%', + cls : 'fieldReadOnlyNoRemove' + }] + },{ + layout : 'form', + labelWidth : 70, + columnWidth : .5, + items : [{ + xtype : 'textfield', + fieldLabel : '申请科室', + maxLength : '100', + id : 'depart2', + name : 'depart', + readOnly : true, + anchor : '99%', + cls : 'fieldReadOnlyNoRemove' + + }] + },{ + layout : 'form', + labelWidth : 70, + columnWidth : .5, + items : [{ + xtype : 'textfield', + fieldLabel : '申请时间', + id : 'applicationTime2', + name : 'applicationTime', + readOnly : true, + anchor : '99%', + cls : 'fieldReadOnlyNoRemove' + }] + },{ + layout : 'form', + labelWidth : 70, + columnWidth : .5, +// hidden : true, + items : [{ + xtype : 'textfield', + fieldLabel : '责任人', + maxLength : '41', + id : 'personInCharge', + name : 'personInCharge', + readOnly : true, + allowBlank : false, + anchor : '99%', + cls : 'x-item-disabled' + }] + + + },{ + layout : 'form', + labelWidth : 70, + columnWidth : .5, + hidden : true, + items : [{ + xtype : 'textfield', + fieldLabel : '发货员条码', + maxLength : '16', + id : 'senderBarcode', + name : 'senderBarcode', + anchor : '99%', + listeners : { + render : function(p) { + p.getEl().on('keypress',function(e) { + if (e.getKey() == 13) {// 回车键 + InvoiceTableManager.getUserNameByBarcode(top.Ext.getCmp('senderBarcode').getValue(), + function(userName) { + if (userName != null) { + var resultArray = userName.split(":"); + if (resultArray[0] == "success") { + top.Ext.getCmp('sender').setValue(resultArray[1]); + Ext.state.Manager.getProvider().set('cookieSender',resultArray[1]); + } else { + showResult(resultArray[1]); + top.Ext.getCmp('sender').setValue(""); + } + } + top.Ext.getCmp('senderBarcode').setValue(""); + }); + } + }); + } + } + }] + },{ + layout : 'form', + labelWidth : 70, + columnWidth : .5, + items : [{ + xtype : 'textfield', + fieldLabel : '发货员', + maxLength : '41', + id : 'sender', + name : 'sender', + readOnly : true, + allowBlank : false, + anchor : '99%', + cls : 'x-item-disabled' + }] + },{ + layout : 'form', + labelWidth : 70, + columnWidth : .5, + items : [{ + xtype : 'datefieldWithMin', + fieldLabel : '发货时间', + id : 'sendTime', + name : 'sendTime', + allowBlank : false, + altFormats:'Y-m-d|Y-n-j|y-n-j|y-m-j|y-m-d|y-n-d|Y-n-d|Y-m-j|Ymd|Ynj|ynj|ymj|ymd|ynd|Ynd|Ymj|Y/m/d|Y/n/j|y/n/j|y/m/j|y/m/d|y/n/d|Y/n/d|Y/m/j', + format : 'Y-m-d H:i', + anchor : '99%' + }] + },{ + layout : 'form', + labelWidth : 70, + columnWidth : .5, + items : [{ + xtype : 'textfield', + fieldLabel : '住院号', + maxLength : '41', + id : 'hospitalNumber', + name : 'hospitalNumber', + readOnly : true, + anchor : '99%', + cls : 'x-item-disabled' + }] + },{ + layout : 'form', + columnWidth : 1, + labelWidth : 70, + items : [{ + xtype : 'textfield', + fieldLabel : '备注', + id : 'remark2', + name : 'remark', + anchor : '99.5%', + height : 40, + cls : 'x-item-disabled', + readOnly : true + }] + }] + },{ + layout : 'form', + hidden : (isForeignProxyDisinfection ? true: false), + columnWidth : 0.45, + items : [ + new top.Ext.grid.EditorGridPanel({ + id : 'recyclingError', + title : '丢失材料明细', + store : recyclingErrorStore, + cm : recyclingErrorCm, + enableHdMenu : false, + width : 405, + height : 135, + autoExpandColumn : 'price', + frame : false, + bodyStyle : 'border:1px solid #afd7af', + viewConfig : {forceFit : true}, + clicksToEdit : 1, + selModel : new top.Ext.grid.RowSelectionModel({ + singleSelect : false + }) + }) + ] + }] + },{ + layout : 'column', + items : [{ + layout : 'form', + columnWidth : 0.65, + autoScroll: true, + items : [ + new top.Ext.grid.EditorGridPanel({ + id : 'recyclingGrid2', + store : tousseInstanceStore, + cm : cm, + width : 650, + height : 385, + autoExpandColumn : 'deleteItem', + enableHdMenu : false, + frame : false, + bodyStyle : 'border:1px solid #afd7af', + viewConfig : {forceFit : true}, + clicksToEdit : 1,// 设置点击几次才可编辑 + selModel : new top.Ext.grid.RowSelectionModel({ + singleSelect : false + }) + })] + },{ + layout : 'form', + columnWidth : 0.35, + items : [ + new top.Ext.grid.EditorGridPanel({ + id : 'recyclingGrid1', + title : '发货单明细', + store : invoiceStore, + cm : recyclingapplicationCm, + enableHdMenu : false, + width : 350, + height : 385, + autoExpandColumn : 'deleteItem', + frame : false, + bodyStyle : 'border:1px solid #afd7af', + viewConfig : {forceFit : true}, + clicksToEdit : 1, + selModel : new top.Ext.grid.RowSelectionModel({ + singleSelect : false + }), + listeners : { + validateedit : function(o) { + if (!isPositiveInteger(o.value)){ + return false; + } + } + } + })] + }] + }], + buttons : [{ + text : '打印预览', + handler : function() { + printInvoiceLocal(1,type,id); + } + },{ + text : '打印', + handler : function() { + printInvoiceLocal(0,type,id); + } + },{ + text : '器械包退货', + handler : function() { + window.close(); + addReturnTousseByInvoice(id); + } + }, { + text : '取消', + handler : function() { + window.close(); + } + }] + }); + + var window = new top.Ext.Window({ + id : 'recyclingApplicationWin', + layout : 'fit', + title : '发货单', + width : 1000, + height : top.screen.height > 800 ? 660 : 500, + border : false, + modal : true, + plain : true, + items : [ form ] + }); + + window.show(); + //top.Ext.getCmp('depart1').focus(false, 100); + + form.form.load({ + url : WWWROOT + '/disinfectSystem/invoiceAction!loadInvoice.do', + method : 'GET', + waitMsg : '正在加载数据,请稍候', + params : { + id : id + }, + success : function(form, action) { + top.Ext.getCmp('applicationTime2').setValue( + formatDateYear(action.result.data.applicationTime)); + var status = action.result.data.status; + var applicationTime = action.result.data.applicationTime; + top.Ext.getCmp('applicationTime2').setValue( + formatDateYear(applicationTime)); + + if (status == '未发货') { + top.Ext.getCmp('sendTime').setValue(new Date()); + } else { + top.Ext.getCmp('sendTime').setValue( + formatDateYear(action.result.data.sendTime)); + } + if (status == "收货签收") { + top.Ext.getCmp('saveButton').disable(); + } + if (action.result.data.sender == null + || action.result.data.sender == "") { + var cookieSender = Ext.state.Manager.getProvider().get( + 'cookieSender'); + if (cookieSender) { + top.Ext.getCmp('sender').setValue(cookieSender); + } + } + }, + failure : function(form, action) { + } + }); +} + +function changeTwoDecimal(floatvar) { + var f_x = parseFloat(floatvar); + if (isNaN(f_x)) { + alert('function:changeTwoDecimal->parameter error'); + return false; + } + var f_x = Math.round(floatvar * 100) / 100; + return f_x; +} + +function getInvoicesInfoForPrint(){} +function getDepartBarcodeByDepart(depart) { + var departBarcode = ''; + DWREngine.setAsync(false); + + SupplyRoomConfigTableManager.getDepartBarcode(depart, function(result) { + if (result != null) { + departBarcode = result; + } + }); + DWREngine.setAsync(true); + return departBarcode; +} +function printInvoiceLocal(printType,type,id){ + var depart = top.Ext.getCmp("depart2").getValue(); + var sendTime = top.Ext.getCmp("sendTime").getRawValue().substring(0,10); + var sendFullTime = top.Ext.getCmp("sendTime").getRawValue(); + var serialNumber = top.Ext.getCmp("serialNumber").getValue(); + var sender = top.Ext.getCmp("sender").getValue(); + var remark = top.Ext.getCmp("remark2").getValue(); + var hospitalNumber = top.Ext.getCmp("hospitalNumber").getValue(); + var applicationTime2 = top.Ext.getCmp("applicationTime2").getValue(); + var applicant = top.Ext.getCmp("applicant2").getValue(); + + batchPrintInvoices(id, depart, printType,sendTime,sender,serialNumber,remark,applicationTime2,hospitalNumber,applicant,sendFullTime); + +} +// 统计总价 +function getTotalPrice(type) { + + var recyclingPrice = 0; + for ( var i = 0; i < recyclingErrorStore.getCount(); i++) { + var record = recyclingErrorStore.getAt(i); + var price = record.get('price'); + var count = record.get('count'); + var totalPrice = Number(price) * Number(count); + recyclingPrice = recyclingPrice + Number(price) * Number(count); + } + + var toussePrice = 0; + for ( var i = 0; i < tousseInstanceStore.getCount(); i++) { + var record = tousseInstanceStore.getAt(i); + var price = record.get('fluctuationPrice'); + var count = record.get('count'); + var totalPrice = Number(price) * Number(count); + toussePrice = toussePrice + Number(price) * Number(count); + } + return changeTwoDecimal(Number(recyclingPrice) + Number(toussePrice)); +} + +//统计总数量 +function getTotalAmount(type) { + + var totalAmount = 0; + for ( var i = 0; i < recyclingErrorStore.getCount(); i++) { + var record = recyclingErrorStore.getAt(i); + var count = record.get('count'); + totalAmount = totalAmount + count; + } + + for ( var i = 0; i < tousseInstanceStore.getCount(); i++) { + var record = tousseInstanceStore.getAt(i); + var count = record.get('count'); + totalAmount = totalAmount + count; + } + return totalAmount; +} + +function getTousseGridData1(type) { + var goods = null; + var map = new Map(); + // group by 器械包名称 + for ( var i = 0; i < tousseInstanceStore.getCount(); i++) { + var record = tousseInstanceStore.getAt(i); + var name = record.get('name'); + var count = record.get('count'); + var data = map.get(name); + if (data != null) { + map.put(name, Number(data) + Number(count)); + } else { + map.put(name, count); + } + } + var jsonArray = []; + + for ( var i = 0; i < tousseInstanceStore.getCount(); i++) { + var record = tousseInstanceStore.getAt(i); + var name = record.get('name'); + var specification = record.get('specification'); + var tousseType = record.get('tousseType'); + var price = record.get('fluctuationPrice'); + var amount = record.get('count'); + var unit = record.get('unit'); + var batchNumber = record.get('batchNumber'); + var sterilizerName = record.get('sterilizerName'); + var frequency = record.get('frequency'); + var diposable = record.get('diposable'); + var externalCode = record.get('externalCode'); + var expireDate = record.get('expireDate'); + var certification = record.get('certification'); + var manufacturer = record.get('manufacturer'); + var totalPrice = Number(price) * Number(amount); + // 去掉名字相同的器械包,数量累加 + if (map.get(name) != null && diposable == "否") {// 器械包 + var count = map.get(name); + totalPrice = Number(price) * Number(count); + var printTousseName = name; + + // 消毒物品显示材料 + if (type == TYPE_DISINFECT_GOODS) { + var goodsBarcode = record.get('barcode'); + DWREngine.setAsync(false); + InvoiceTableManager.getDisinfectGoodsMaterial(goodsBarcode, + function(materialStr) { + if (materialStr.length > 0) { + var materailArray = materialStr + .split("@@"); + for ( var n = 0; n < materailArray.length; n++) { + var materialName = materailArray[n] + .split("&&")[0]; + var materialAmount = materailArray[n] + .split("&&")[1]; + var materialPrice = materailArray[n] + .split("&&")[2]; + var operationTime = materailArray[n] + .split("&&")[3]; + var validUntil = materailArray[n] + .split("&&")[4]; + var materialTotalPrice = Number(materialAmount) + * Number(materialPrice); + + var obj = {}; + obj.name = materialName; + obj.specification = ""; + obj.tousseType = tousseType; + obj.diposable = diposable; + obj.count = materialAmount; + obj.unit = unit; + obj.price = materialPrice; + obj.totalPrice = materialTotalPrice; + obj.batchNumber = batchNumber; + obj.sterilizerName = sterilizerName; + obj.frequency = frequency; + obj.operationTime = operationTime; + obj.validUntil = validUntil; + obj.externalCode = externalCode; + + obj.expireDate = expireDate; + obj.certification = certification; + obj.manufacturer = manufacturer; + + jsonArray.push(obj); + + } + } + }); + DWREngine.setAsync(true); + continue; + } + + var obj = {}; + obj.name = printTousseName; + obj.specification = specification; + obj.tousseType = tousseType; + obj.diposable = diposable; + obj.count = count; + obj.unit = unit; + obj.price = price; + obj.totalPrice = totalPrice; + obj.batchNumber = batchNumber; + obj.sterilizerName = sterilizerName; + obj.frequency = frequency; + obj.externalCode = externalCode; + + obj.expireDate = expireDate; + obj.certification = certification; + obj.manufacturer = manufacturer; + + jsonArray.push(obj); + + map.remove(name); + } else if (diposable == "是") {// 一次性物品 + var count = record.get('count'); + + var obj = {}; + var position = name.indexOf("["); + if (position > 0){ + obj.name = name.substring(0, position); + } + else{ + obj.name = name; + } + obj.specification = specification; + obj.tousseType = tousseType; + obj.diposable = diposable; + obj.count = count; + obj.unit = unit; + obj.price = price; + obj.totalPrice = totalPrice; + obj.batchNumber = batchNumber; + obj.sterilizerName = sterilizerName; + obj.frequency = frequency; + obj.externalCode = externalCode; + + obj.expireDate = expireDate; + obj.certification = certification; + obj.manufacturer = manufacturer; + + jsonArray.push(obj); + + } + } + + for ( var i = 0; i < recyclingErrorStore.getCount(); i++) { + var record = recyclingErrorStore.getAt(i); + var name = record.get('name'); + var price = record.get('price'); + var count = record.get('count'); + var unit = record.get('unit'); + var totalPrice = Number(price) * Number(count); + + var obj = {}; + obj.name = name; + obj.unit = unit; + obj.specification = ""; + obj.tousseType = "器械包"; + obj.diposable = "否"; + obj.count = count; + obj.price = price; + obj.totalPrice = totalPrice; + obj.batchNumber = ""; + obj.expireDate = ""; + obj.sterilizerName = ""; + obj.frequency = ""; + obj.externalCode = ""; + + jsonArray.push(obj); + + } + return jsonArray; +} + +function formatDateYear(v, p, record) { + try { + return Ext.util.Format.date(new Date(v.time), 'Y-m-d H:i'); + } catch (e) { + } +} + +// 删除 +function deleteInvoice(grid) { + var records = grid.getSelectionModel().getSelections(); + + if (records.length == 0) { + showResult("请选择要删除的发货单!"); + return false; + } + var ids = null; + for ( var i = 0, len = records.length; i < len; i++) { + var serialNumber = records[i].data['serialNumber']; + var status = records[i].data['status']; + + if (status == '未发货') { + if (ids == null) { + ids = records[i].data['id']; + } else { + ids = ids + ';' + records[i].data['id']; + } + } + } + if (ids != null) { + Ext.MessageBox.confirm("请确认","是否确定要删除选中的回收申领单信息?", + function(button, text) { + if ("yes" == button) { + Ext.Ajax.request({ + url : WWWROOT + '/disinfectSystem/invoiceAction!deleteInvoice.do', + params : {ids : ids}, + success : function(response,options) { + MsgTip.msg('提示', '删除成功!', true,3); + grid.dwrReload(); + }, + failure : function(response,options) { + MsgTip.msg('提示',response.responseText,true, 3); + } + }); + } + } + ); + } else { + MsgTip.msg('提示', '已发货的发货单不能删除!', true, 3); + } +} +//更新打印状态 +function updatePrintStatus(ids){ + InvoiceTableManager.updatePrintStatus(ids,function(printSuccess){ + if(printSuccess){ + grid.dwrReload(); + showResult("已打印!"); + }else{ + showResult("更新打印状态失败!"); + } + }); +} + +function getSelectedIds(){ + var records = grid.getSelectionModel().getSelections(); + if (records.length == 0) { + 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']; + } + } + return ids; +} + +function mergePrintInvoices(){ + var records = grid.getSelectionModel().getSelections(); + if (records.length == 0) { + showResult("请选择要打印的发货单!"); + return; + } + + // 保证选的是同一部门的发货单 + var depart = records[0].data['depart']; + var sendTime = records[0].data['sendTime'].substring(0,10); + var sendFullTime = records[0].data['sendTime']; + var serialNumber = records[0].data['serialNumber']; + var sender = records[0].data['sender']; + var remark = records[0].data['remark']; + var applicant = records[0].data['applicant']; + var applicationTime = records[0].data['applicationTime']; + for ( var i = 1, len = records.length; i < len; i++){ + if(depart != records[i].data['depart']){ + showResult("请选择相同科室的发货单!"); + return; + } + } + + 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,null,applicant,sendFullTime); + +} + +function batchPrintInvoices(ids, depart, printType,sendTime,sender,serialNumber,remark,applicationTime,hospitalNumber,applicant,sendFullTime){ + if(ids == null) + return; + var departBarcode = getDepartBarcodeByDepart(depart); + top.Ext.MessageBox.show({ + title:'请等待', + msg:'打印中……', + width:350, + progress:true, + closable:false + }); + Ext.Ajax.timeout=300*000; + Ext.Ajax.request({ + timeout: 300*000, + url : WWWROOT + '/disinfectSystem/invoiceAction!mergeLoadToussePrintData.do', + params : {ids : ids}, + success : function(response){ + var result = Ext.decode(response.responseText); + result.depart = depart; + result.departBarcode = departBarcode; + result.sendTime = sendTime; + result.sendFullTime = sendFullTime; + result.sender = sender; + result.serialNumber2 = serialNumber; + result.remark2 = remark; + result.applicationTime = applicationTime; + result.applicant = applicant; + if(isUndefinedOrNullOrEmpty(result.hospitalNumber) && !isUndefinedOrNullOrEmpty(hospitalNumber)){ + result.hospitalNumber = hospitalNumber; + } + var dt = new Date(); + var printDate = dt.getFullYear() + "-" + (dt.getMonth() + 1) + "-"+dt.getDate(); + result.printDate = printDate; + invoicePrintModule.batchPrintInvoices_result(result, printType); + + if (printType == 0){ + updatePrintStatus(ids); + } + + hideMessageBox(true); + }, + failure: function(response){ + showResult("打印失败!"); + hideMessageBox(true); + } + }); +} + +var loadFormData = function(grid) { + var records = grid.getSelectionModel().getSelections(); + if (records.length == 0) { + showResult("请选择发货单!"); + return false; + } + if (records.length > 1) { + showResult("一次只能修改一个发货单!"); + return false; + } + var id = records[0].data['id']; + var invoiceType = records[0].data['recyclingApplicationType']; + openInvoiceForm(id, invoiceType); + top.Ext.getCmp('recyclingApplicationWin').setTitle('发货信息'); +}; + +// 校验物品数量是否为数字 +function validGridAmount() { + // 申请的物品 + var b = true; + for ( var i = 0; i < invoiceStore.getCount(); i++) { + var record = invoiceStore.getAt(i); + var count = record.get('count'); + if (/[^0-9]/g.test(count)) { + showResult('[' + record.get('name') + '] 申请数量必须是数字,保存失败!'); + top.Ext.getCmp('recyclingGrid1').getView().getRow(i).style.backgroundColor = '#FFB5B5'; + b = false; + break; + } + } + for ( var i = 0; i < tousseInstanceStore.getCount(); i++) { + var record = tousseInstanceStore.getAt(i); + var count = record.get('count'); + if (/[^0-9]/g.test(count)) { + showResult('[' + record.get('name') + '] 申请数量必须是数字,保存失败!'); + top.Ext.getCmp('recyclingGrid2').getView().getRow(i).style.backgroundColor = '#FFB5B5'; + b = false; + break; + } + } + return b; +} + +// 校验物品是否与申请的数量相同 +function validTousseGridData() { + // 申请的物品 + var b = true; + for ( var i = 0; i < invoiceStore.getCount(); i++) { + var record = invoiceStore.getAt(i); + var count = record.get('count'); + var tempAmount = record.get('tempAmount'); + var applicationAmount = record.get('applicationAmount'); + var amount = record.get('amount'); + if (count != tempAmount) {// 实际数量要与发货数量相同 + b = false; + top.Ext.getCmp('recyclingGrid1').getView().getRow(i).style.backgroundColor = '#FFB5B5'; + showResult(record.get('showTousseName') + " 发货数量与实发数量不同!"); + } + if (Number(count) > Number(amount)) {// 发货数量不能大于待发货数量 + b = false; + top.Ext.getCmp('recyclingGrid1').getView().getRow(i).style.backgroundColor = '#FFB5B5'; + showResult(record.get('name') + " 发货数量不能大于" + amount); + } + } + // 验证发货物品和发货明细物品是否相同 + for ( var j = 0; j < tousseInstanceStore.getCount(); j++) { + var goodsRecord = tousseInstanceStore.getAt(j); + var goodsName = goodsRecord.get('showTousseName'); + var deleted = true; + for ( var i = 0; i < invoiceStore.getCount(); i++) { + var record = invoiceStore.getAt(i); + var showTousseName = record.get('showTousseName'); + if (showTousseName == goodsName) { + deleted = false; + break; + } + } + if (deleted) { + b = false; + showResult("发货物品与发货明细物品不相同!"); + break; + } + } + return b; +} + +// 校验器械包是否与外部代理灭菌申请器械包是否一样 +function validForeignTousseGridData() { + var b = false; + if (tousseInstanceStore.getCount() == invoiceStore.getCount()) { + for ( var i = 0; i < tousseInstanceStore.getCount(); i++) { + var record = tousseInstanceStore.getAt(i); + var barcode = record.get('barcode'); + if (!isBarcodeRepeatForeignProxy(barcode)) { + break; + } + } + b = true; + } + return b; +} +// 获取扫描的外部代理灭菌器械包 +function getForeignTousseGridData() { + var tousseIds = ""; + for ( var i = 0; i < tousseInstanceStore.getCount(); i++) { + var record = tousseInstanceStore.getAt(i); + if (tousseIds == null || tousseIds.length <= 0) { + tousseIds = record.get('id') + "," + record.get('barcode') + "," + + record.get('count') + "," + record.get('name'); + } else { + tousseIds = tousseIds + ";" + record.get('id') + "," + + record.get('barcode') + "," + record.get('count') + "," + + record.get('name'); + } + } + top.Ext.getCmp('tousseInstanceIds').setValue(tousseIds); + + return tousseIds; +} + +// 获取扫描的物品 +function getTousseGridData() { + var tousseIds = ""; + for ( var i = 0; i < tousseInstanceStore.getCount(); i++) { + var record = tousseInstanceStore.getAt(i); + if (tousseIds == null || tousseIds.length <= 0) { + tousseIds = record.get('id') + "#&" + record.get('barcode') + "#&" + + record.get('count') + "#&" + record.get('diposable') + + "#&" + record.get('name') + "#&" + record.get('price') + + "#&" + record.get('batchNumber') + "#&" + + record.get('fluctuationPrice'); + } else { + tousseIds = tousseIds + "#@" + record.get('id') + "#&" + + record.get('barcode') + "#&" + record.get('count') + "#&" + + record.get('diposable') + "#&" + record.get('name') + + "#&" + record.get('price') + "#&" + + record.get('batchNumber') + "#&" + + record.get('fluctuationPrice'); + } + } + top.Ext.getCmp('tousseInstanceIds').setValue(tousseIds); +} +// 获取发货单明细数据 + +var result = ""; +function getRecyclingapplicationStoreData() { + + for ( var i = 0; i < invoiceStore.getCount(); i++) { + var record = invoiceStore.getAt(i); + if (result == null || result.length <= 0) { + result = record.get('name') + "#&" + record.get('count') + "#&" + + record.get('diposable') + "#&" + record.get('amount') + + "#&" + record.get('applicationAmount'); + } else { + result = result + "#@" + record.get('name') + "#&" + + record.get('count') + "#&" + record.get('diposable') + + "#&" + record.get('amount') + "#&" + + record.get('applicationAmount'); + } + } + top.Ext.getCmp('recyclingappStoreData').setValue(result); +} + +var invoiceTypeStore = new Ext.data.SimpleStore({ + fields : [ 'id', 'value' ], + data : [ [ '0', '全部' ], [ '1', '已处理的发货单' ], [ '2', '未处理的发货单' ] ] +}); + +/** + * 修改记录 modifyRecord函数 触发modify函数调用,并传入当前列的值以及record.data对象 页面中需要定义 + * modify(v,data) 函数 + */ +function callModifyFunction() { + loadFormData(grid); +} + +function renderCallModifyFunction(v, p, record) { + return "" + v + + ""; +} + +function formartPrice(v, p, record) { + if (v != null && v != "") { + var temp = parseFloat(v); + return temp.toFixed(2); + } + return v; +} + +function renderColor(v, p, record) { + var status = record.data['status']; + var color = "white"; + if ("已发货" == status) {// 待发货 黄色 + color = "yellow"; + } else if ("未发货" == status) { // 部分发货 //已发货 红色 + color = "#F5A7FA"; + } + return "

" + v + "

"; +} +function renderPrintColor(v, p, record) { + if ("否" == v) {// 待发货 黄色 + return "

" + v + "

"; + } else { + return v; + } + +} +var chooseMonthWin; +function updateRecyclingAppTime(g) { + var records = grid.getSelectionModel().getSelections(); + if (records.length == 0) { + showResult("请选择发货单!"); + return false; + } + var updateTimeForm = new top.Ext.FormPanel({ + id : 'form', + frame : true, + labelSeparator : ':', + labelAlign : 'right', + bodyStyle : 'padding:5px 5px 0px 5px', + autoHeight : true, + autoScroll : true, + items : [ { + layout : 'column', + items : [ { + columnWidth : 0.5, + layout : 'form', + labelWidth : 60, + items : [ { + xtype : 'datefieldWithMin', + fieldLabel : '申请时间', + id : 'recyclingTime', + name : 'recyclingTime', + editable : false, + allowBlank : false, + format : 'Y-m-d H:i', + value : new Date(), + anchor : '100%' + } ] + }, { + columnWidth : 0.5, + layout : 'form', + labelWidth : 60, + items : [ { + xtype : 'datefieldWithMin', + fieldLabel : '发货时间', + id : 'sendTime', + name : 'sendTime', + editable : false, + allowBlank : false, + format : 'Y-m-d H:i', + value : new Date(), + anchor : '100%' + } ] + } ] + } ], + buttons : [ { + id : 'saveBtn', + text : '保存', + handler : updateTime + } ] + }); + + chooseMonthWin = new top.Ext.Window({ + id : 'chooseMonthWin', + layout : 'fit', + title : '修改时间 ', + width : 450, + border : false, + modal : true, + autoHeight : true, + plain : true, + items : [ updateTimeForm ] + }); + chooseMonthWin.show(); +} + +function updateTime() { + var recyclingTime = top.Ext.getCmp('recyclingTime').getRawValue(); + var sendTime = top.Ext.getCmp('sendTime').getRawValue(); + if (updateTime == "" || sendTime == "") { + showResult("请输入修改日期!"); + return false; + } + var records = grid.getSelectionModel().getSelections(); + 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']; + } + } + top.Ext.MessageBox.confirm("请确认", "是否确定要修改选中的发货单申请、发货时间?", function(button, + text) { + if ("yes" == button) { + Ext.Ajax.request({ + url : WWWROOT + + '/disinfectSystem/invoiceAction!updateDateTime.do', + params : { + ids : ids, + recyclingTime : recyclingTime, + sendTime : sendTime + }, + success : function(response, options) { + showResult("更新成功!"); + grid.dwrReload(); + chooseMonthWin.close(); + }, + failure : function(response, options) { + showResult(response.responseText); + } + }); + } + }); +} +function modifyInvoiceTime() { + var records = grid.getSelectionModel().getSelections(); + if (records.length == 0) { + showResult("请选择要修改的记录!"); + return false; + } + if (records.length > 1) { + showResult("一次只能修改一个记录!"); + return false; + } + var id = records[0].data['id']; + var invoiceTime = records[0].data['sendTime']; + if(modifyInvoiceTime_tousseInstanceWindow){ + return; + } + showModifyInvoiceTimeWindow(id,invoiceTime); +}; +var invoicePrintModule; +Ext.onReady(function() { + Ext.QuickTips.init(); + Ext.BLANK_IMAGE_URL = WWWROOT + + '/ext/resources/images/default/s.gif'; + // 记录cookies +// Ext.state.Manager.setProvider(new Ext.state.CookieProvider({ +// path : WWWROOT + '/disinfectsystem/invoice/', +// expires : new Date(new Date().getTime() + 2592000000) +// })); + diposableGooodsStore.on('load', function(){ +// Ext.getCmp('disposableGoodsType').selectAll(); + }); + diposableGooodsStore.load(); + var departGroupStore = new Ext.data.SimpleStore({ + fields : ['id', 'shift','departCode' ], + url : WWWROOT + '/disinfectSystem/invoiceDepartmentAction!loadDepartGroup.do' + }); + departGroupStore.on('load', function(){ + + ShiftDef = Ext.data.Record.create([ + {name: "id", type: "string"}, + {name: "shift", type: "string"}, + {name: "departCode", type: "string"} + ]); + var record = new ShiftDef({ + id: '', + shift: "全部", + departCode: "" + }); + + departGroupStore.insert(0, record); + }); + + var columns = [ + {header : "流水号",width : 100,dataIndex : 'serialNumber',renderer : renderCallModifyFunction}, + {header : "状态",width : 70,dataIndex : 'status',renderer : renderColor}, + {header : "已打印",width : 50,dataIndex : 'isPrint',renderer : renderPrintColor}, + {header : "申请科室",width : 120,dataIndex : 'depart'}, + {header : "申请时间",width : 120,dataIndex : 'applicationTime',renderer : myDateFormatByMinute}, + {header : "回收时间",width : 120,dataIndex : 'recyclingTime',renderer : myDateFormatByMinute}, + {header : "发货员",width : 70,dataIndex : 'sender'}, + {header : "拼音码",width : 100,dataIndex : 'spelling',hidden:true}, + {header : "五笔码",width : 100,dataIndex : 'wbCode',hidden:true}, + {header : "核对员",width : 70,dataIndex : 'assistantSender'}, + {header : "责任人",width : 70,dataIndex : 'personInCharge'}, + {header : "发货时间",width : 120,dataIndex : 'sendTime',renderer : myDateFormatByMinute}, + + {header : "类型",width : 110,dataIndex : 'invoicePlanType',sortable:false}, + {id : 'remark',header : "备注",width : 110,dataIndex : 'remark'}, + {header : "打印时间",width : 120,dataIndex : 'printTime',sortable:false,renderer : myDateFormatByMinute}, + + {header : "住院号",width : 70,dataIndex : 'hospitalNumber'}, + {header : "签收人",width : 70,dataIndex : 'receiptor'}, + {header : "签收时间",width : 120,dataIndex : 'receiptingTime',renderer : myDateFormatByMinute}, + {header : "结算科室",width : 100,dataIndex : 'settleAccountsDepart'}, + {header : "仓库",width : 100,dataIndex : 'warehouseName',id : 'warehouseName'}, + {header : "总价",width : 70,dataIndex : 'totalPrice',align : 'right',renderer : formartPrice} + ]; + + var readerDetail = [ + {name : 'id'}, + {name : 'serialNumber'}, + {name : 'depart'}, + {name : 'printTime'}, + {name : 'settleAccountsDepart'}, + {name : 'isPrint'}, + {name : 'spelling'}, + {name : 'wbCode'}, + {name : 'applicationTime'}, + {name : 'recyclingTime'}, + {name : 'sender'}, + {name : 'assistantSender'}, + {name : 'sendTime'}, + {name : 'status'}, + {name : 'totalPrice'}, + {name : 'remark'}, + {name : 'hospitalNumber'}, + {name : 'invoicePlanType'}, + {name : 'receiptor'}, + {name : 'receiptingTime'}, + {name : 'personInCharge'}, + {name : 'warehouseName'}, + {name : 'applicant'}, + {name : 'personInChargeCode'} + ]; + + var filters = new Ext.grid.GridFilters({ + filters : [ + {type : 'string',dataIndex : 'sender'}, + {type : 'string',dataIndex : 'serialNumber'}, + {type : 'string',dataIndex : 'depart'}, + {type : 'string',dataIndex : 'settleAccountsDepart'}, + {type : 'list',dataIndex : 'status',options : [ invoiceStatusNo, invoiceStatusYes,invoiceStatusSigned ],phpMode : true}, + {type : 'list',dataIndex : 'isPrint',options : [ '是', '否' ],phpMode : true}, +// {type : 'string',dataIndex : 'isPrint'}, + {type : 'date',dataIndex : 'sendTime'}, + {type : 'date',dataIndex : 'applicationTime'}, + {type : 'string',dataIndex : 'invoicePlanType'}, + {type : 'numeric',dataIndex : 'totalPrice'}, + {type : 'string',dataIndex : 'hospitalNumber'}, + {type : 'string',dataIndex : 'remark'} + ] + }); + + + + var tbar = [{ + text : '修改发货时间', + hidden : SSTS_Invoice_Update, + iconCls : 'btn_ext_application_go', + id : 'editTbar', + handler : function() { + modifyInvoiceTime(); + } + }, { + text : '刷新列表', + iconCls : 'btn_ext_refresh1', + handler : function() { + grid.dwrReload(); + } + },{ + text : '科室分组:' + },{ + xtype : 'combo', + id : 'invoiceDepartGroup', + name : 'invoiceDepartGroup', + valueField : 'departCode', + displayField : 'shift', + allowBlank : false, + editable : false, + emptyText:'请选择科室分组', + width : 120, + store : departGroupStore, + forceSelection : true, + triggerAction : 'all', + listeners : { + select : function(combo, record, index){ + refreshList(); + } + }, + anchor : '95%' + },{ + text : '物品类型:' + },{ + xtype : 'multiSelect', + id : 'tousseType', + name : 'tousseType', + valueField : 'value', + displayField : 'key', + allowBlank : true, + editable : false, + fieldLabel:'类型', + width : 150, + emptyText:'请选择物品类型', + mode:'local', + store : new Ext.data.SimpleStore({ + data:tousseTypeDataArray, + fields:['key','value'] + }), +// forceSelection : true, + triggerAction : 'all', + listeners : { + select : function(combo, record, index){ + if (record.get('value') == '全部') { + if (record.get('checked')) { + combo.selectAll() + } else { + combo.deselectAll() + } + } + grid.dwrReload(); + } + }, + anchor : '95%' + }, { + text : '一次性物品类型:', + hidden : !sstsConfig.invoicePlanExtractedView_showDisposableGoodsType + },{ + xtype : 'multiSelect', + id : 'disposableGoodsType', + name : 'disposableGoodsType', + hidden : !sstsConfig.invoicePlanExtractedView_showDisposableGoodsType, + valueField : 'typeName', + displayField : 'typeName', + allowBlank : true, + editable : false, + fieldLabel:'类型', + width : 150, + emptyText:'请选择物品类型', + mode:'local', + store : diposableGooodsStore, +// forceSelection : true, + triggerAction : 'all', + listeners : { + select : function(combo, record, index){ + grid.dwrReload(); + }, + beforeselect:function(combo, record, index){ +// var c = record.get(combo.checkField); +// if(combo.getCheckedCount() <= 1 && c){ +// return false; +// } + return true; + } + }, + anchor : '95%' + },{ + text : '申请单类型:', + hidden: !sstsConfig.accordingToApplyTypeFilter + },{ + xtype: 'multiSelect', + hidden: !sstsConfig.accordingToApplyTypeFilter, + store : new Ext.data.Store({ + proxy: new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/invoicePlanAction!getAllApplyType.do?neddCustomDeliveryType=yes', + method: 'POST' + }), + reader: new Ext.data.JsonReader({ + root: 'data', + totalProperty: 'totalCount' + }, [{name: 'applyType', mapping: 'applyType'}] + ) + }), + fieldLabel: '请单类型', + displayField: 'applyType', + valueField: 'applyType', + allowBlank : true, + editable : false, + width : 150, + emptyText:'请选择申请单类型', + triggerAction: 'all', + listWidth: 200, + mode: 'remote', + //这个要设置成false,不然多选鼠标离开之后,combo上面的值不会显示 + forceSelection : false, + listeners: { + select: function (combo, record, index) { + if (record.get('applyType') == '全部') { + if (record.get('checked')) { + combo.selectAll() + } else { + combo.deselectAll() + } + } + + var dom = document.getElementById('parm_s_applyType'); + dom.value = combo.getValue(); + grid.dwrReload(); + } + } + },{ + type : 'button', + text : '打印'+entityName, + hidden : !(sstsConfig.printInvoiceVersion==2), + iconCls : 'icon_print', + menu: new Ext.menu.Menu({ + items: [ + {text: '批量打印' + entityName, hidden: !validateIsSupplyRoomUser,handler: function (){ + invoicePrintModule.batchPrint(); + } + }, + {text: '打印一次性物品', handler:function(){ + checkPrintStatus(function(){ + var ids = getSelectedIds(); + if (ids != null && ids != false){ + top.Ext.MessageBox.confirm("请确认", "要打印所选的发货单的一次性物品吗?", + function(btn) { + if (btn == 'yes') { + invoicePrintModule.batchPrintInvoiceWithType(ids,'一次性物品'); + } + }); + } + }); + } + },{ + text: '打印器械包', + hidden:!sstsConfig.splitTousseAndDisinfectInvoiceBtn, + handler:function(){ + checkPrintStatus(function(){ + var ids = getSelectedIds(); + if (ids != null && ids != false){ + top.Ext.MessageBox.confirm("请确认", "要打印所选的发货单的器械包吗?", + function(btn) { + if (btn == 'yes') { + invoicePrintModule.batchPrintInvoiceWithType(ids,'器械包'); + } + }); + } + }); + } + + },{ + text: '打印消毒物品', + hidden:!sstsConfig.splitTousseAndDisinfectInvoiceBtn, + handler:function(){ + checkPrintStatus(function(){ + var ids = getSelectedIds(); + if (ids != null && ids != false){ + top.Ext.MessageBox.confirm("请确认", "要打印所选的发货单的消毒物品吗?", + function(btn) { + if (btn == 'yes') { + invoicePrintModule.batchPrintInvoiceWithType(ids,'消毒物品'); + } + }); + } + }); + } + + },{ + text: '打印器械包及消毒物品', + hidden:sstsConfig.splitTousseAndDisinfectInvoiceBtn, + handler: function(){ + checkPrintStatus(function(){ + var ids = getSelectedIds(); + if (ids != null && ids != false){ + top.Ext.MessageBox.confirm("请确认", "要打印所选发货单的器械包及消毒物品吗?", + function(btn) { + if (btn == 'yes') { + invoicePrintModule.batchPrintInvoiceWithType(ids,'器械包及消毒物品'); + } + }); + } + }); + } + },{text: '打印全部物品', handler: function(){ + checkPrintStatus(function(){ + var ids = getSelectedIds(); + if (ids != null && ids != false){ + top.Ext.MessageBox.confirm("请确认", "要打印所选发货单的全部物品吗?", + function(btn) { + if (btn == 'yes') { + invoicePrintModule.batchPrintInvoiceWithType(ids,'全部'); + } + }); + } + }); + } + } + ] + }) + },{ + text : '打印', + hidden : true, // TODO:待实现 + iconCls : 'icon_print', + handler : function() { + var ids = getSelectedIds(); + if (ids != null && ids != false){ + top.Ext.MessageBox.confirm("请确认", "要打印所选的发货单吗?", + function(btn) { + if (btn == 'yes') { + var idArray = ids.split(";"); + for (var i=0;i