Index: ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationMergeInvoiceForm.js =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationMergeInvoiceForm.js (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationMergeInvoiceForm.js (revision 18344) @@ -0,0 +1,1951 @@ +var sendOutGoodsStore; +var recyclingapplicationStore; +//定义首篮筐的label变量 +var beginBarcodeLabel = '扫描条码:'; +var hiddenEndBarcode = true;//隐藏尾篮筐 +var defaultFocusedFieldOnInvoiceForm = 'scanText'; +var lastLoadWarehouseId = null; +var wareHouseStoreLoaded = false; +var recyclingapplicationStoreLoaded = false; +var postInitDataTimer = null; +var TYPE_OPERATION_RESERVATION_MERGE = "手术预约多单合并发货"; +var wareHouseStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/baseData/wareHouseAction!getWareHouseData.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + totalProperty : 'totalCount', + root : 'data' + }, [ + {name : 'id',mapping : 'id'}, + {name : 'name',mapping : 'name'}, + {name : 'orgUnitCode',mapping : 'orgUnitCode'}, + ]), + listeners : { + load : function(store,records) { + var id = top.Ext.getCmp('sourceWarehouseId').getValue(); + //var name = top.Ext.getCmp('sourceWarehouseName').getValue(); + if(records.length > 0 && (id == null || id == '')){ + //id=records[0].data.id; + //name = records[0].data.name; + var combo = top.Ext.getCmp("warehouse"); + // 触发选中事件 + combo.fireEvent('select', combo,records[0],0); + } + wareHouseStoreLoaded = true; + //top.Ext.getCmp('warehouse').setValue(id); + //top.Ext.getCmp('sourceWarehouseId').setValue(id); + //top.Ext.getCmp('sourceWarehouseName').setValue(name); + } + } +}); + +if(sstsConfig.disableLoadToVirtualBasket == false){ + beginBarcodeLabel = '条码/篮筐(首):'; + hiddenEndBarcode = false;//显示尾篮筐 +} + +//条码扫描模式(单个条码逐个扫描或首尾条码段扫描两种模式) +var currentScanMode = "single"; +if(sstsConfig.invoicePageScanMode && sstsConfig.invoicePageScanMode != null){ + currentScanMode = sstsConfig.invoicePageScanMode; +} + +function getDefaultAmount(v,p,record){ + if (v==null || v.length <= 0){ + return 0; + }else{ + return v; + } +} +function formatStorage(v,p,record){ + if (v==null || v.length <= 0){ + return ''; + }else{ + return v; + } +} +function sayGoods(record){ + if(record && record.data){ + speaker.speak(record.data.showTousseName + ",数量为" + record.data.count); + } +} +//发货单明细累减 +function updateAmount1(name,amount){ + if(name != null && name.length > 0){ + for ( var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.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(tempAmount) - Number(amount)); + updateErrorAmount(record); + refreshTotalAmount(); + } + } + } + return false; +} +//删除发货扫描的物品 +function removeSendOutGoods(id){ + var rows = top.Ext.getCmp('sendOutGoods').getSelectionModel().getSelections();// 返回值为 + if (rows) { + for ( var i = 0; i < rows.length; i++) { + var name = rows[i].data['name']; + var amount = rows[i].data['count']; + var barcode = rows[i].data['barcode']; + sendOutGoodsStore.remove(rows[i]); + +// var appRecord = rows[i].data['appRecord']; + var appRecord = extIdToAppRecordMap[rows[i].id]; + if(!isUndefinedOrNullOrEmpty(appRecord)){ + updateAmountByRecord(appRecord,-amount); + }else{ + updateAmount1(name,amount); + } + + sendDeleteScannedGoodsLog(rows[i].data); + } + } +} + +//删除发货明细项 +function removeSendOutGoodsDetail(id){ + var rows = top.Ext.getCmp('sendOutGoodsDetail').getSelectionModel().getSelections();// 返回值为 + if (rows) { + for ( var i = 0; i < rows.length; i++) { + var name = rows[i].data['name']; + var amount = rows[i].data['count']; + recyclingapplicationStore.remove(rows[i]); + } + } +} + +//删除发货明细项 +function removeSendOutTousseByBarcode(barcode){ + var record = findRecordByNameAndValueFromStore(sendOutGoodsStore,'barcode',barcode); + if(record != null){ + var name = record.data['name']; + sendOutGoodsStore.remove(record); + updateAmount1(name,1); + } +} + +//验证条码是否重复扫描 +function isBarcodeRepeat(barcode){ + if(barcode != null && barcode.length > 0){ + for ( var i = 0; i < sendOutGoodsStore.getCount(); i++) { + var record = sendOutGoodsStore.getAt(i); + var tempBarcode =record.get('barcode'); + if(barcode == tempBarcode){ + return true; + break; + } + } + } + return false; +} +function removeTousseIfNeeded(goods){ + var barcode = goods.barcode; + if(isBarcodeRepeat(barcode)){ + var name = goods.name; + for (var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.getAt(i); + var tempName = record.get('name'); + var tempAmount = record.get('tempAmount'); + if(tempName == name){ + var errorAmount = record.get('errorAmount'); + if(errorAmount < 0){ + removeSendOutTousseByBarcode(barcode); + return true; + } + } + } + } + return false; +} + +//扫描的物品是否是待发货物品 +//name不是showTousseName字段 +function isInvoiceGoods(name){ + if(name != null && name.length > 0){ + for ( var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.getAt(i); + var name1 =record.get('name'); + if(name == name1){ + return true; + break; + } + } + } + return false; +} + +//发货单明细累加 +function updateAmount(name,amount){ + if(name != null && name.length > 0){ + for (var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.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) + Number(tempAmount)); + updateErrorAmount(record); + refreshTotalAmount(); + } + } + } + return false; +} +function updateAmountByRecord(record,amount){ + var tempAmount = record.get('tempAmount'); + if(tempAmount==null || tempAmount.length <= 0){ + tempAmount = 0; + } + record.set('tempAmount',Number(amount) + Number(tempAmount)); + updateErrorAmount(record); + refreshTotalAmount(); + + return false; +} +function updateErrorAmount(record){ + var awaitSendingAmount = record.get('count'); + var sentAmount = record.get('tempAmount'); + record.set('errorAmount',awaitSendingAmount - sentAmount); +} +function initErrorAmount(){ + for ( var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.getAt(i); + var awaitSendingAmount = record.get('count'); + var sentAmount = record.get('tempAmount'); + record.set('errorAmount',awaitSendingAmount - sentAmount); + } +} +//校验物品数量是否为数字 +function validGridAmount() { + //申请的物品 + var b = true; + for ( var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.getAt(i); + var count =record.get('count'); + if(/[^0-9]/g.test(count)){ + showResult('['+record.get('name')+'] 申请数量必须是数字,保存失败!'); + top.Ext.getCmp('sendOutGoodsDetail').getView().getRow(i).style.backgroundColor = '#FFB5B5'; + b = false; + break; + } + var errorAmount = record.get('errorAmount'); + if(parseInt(errorAmount) < 0){ + showResult('['+record.get('name')+'] 误差数量不能小于0,保存失败!'); + b = false; + break; + } + } + for ( var i = 0; i < sendOutGoodsStore.getCount(); i++) { + var record = sendOutGoodsStore.getAt(i); + var count =record.get('count'); + if(/[^0-9]/g.test(count)){ + showResult('['+record.get('name')+'] 申请数量必须是数字,保存失败!'); + top.Ext.getCmp('sendOutGoods').getView().getRow(i).style.backgroundColor = '#FFB5B5'; + b = false; + break; + } + } + return b; +} + +//校验物品是否与申请的数量相同 +function validTousseGridData() { + //申请的物品 + var b = true; + for ( var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.getAt(i); + var count =record.get('count'); + var tempAmount = record.get('tempAmount'); + var applicationAmount = record.get('applicationAmount'); + if(count != tempAmount){//实际数量要与发货数量相同 + b = false; + top.Ext.getCmp('sendOutGoodsDetail').getView().getRow(i).style.backgroundColor = '#FFB5B5'; + showResult(record.get('showTousseName')+" 发货数量与实发数量不同!"); + } + if(Number(count) > Number(applicationAmount)){//发货数量不能大于待发货数量 + b = false; + top.Ext.getCmp('sendOutGoodsDetail').getView().getRow(i).style.backgroundColor = '#FFB5B5'; + showResult(record.get('name')+" 发货数量不能大于" + applicationAmount); + } + } + return b; +} + +var addGridItem = Ext.data.Record.create([ + {name : 'id'}, + {name : 'barcode'}, + {name : 'invoicePlanId'}, + {name : 'name'}, + {name : 'appRecord'}, + {name : 'tousseFixedBarcode'}, + {name : 'showTousseName'}, + {name : 'count'}, + {name : 'waitDeliveryCount'}, + {name : 'diposable'}, + {name : 'price'}, + {name : 'fluctuationPrice'}, + {name : 'storage'}, + {name : 'batchNumber'}, + {name : 'tousseType'}, + {name : 'typeInfoOnScanned'}, + {name : 'sterilizerName'}, + {name : 'frequency'}, + {name : 'isTracable'}, + {name : 'tousseDefinitionId'} + ]); + +// 根据条码获取发送项 +function getSendOutGoodsByBarcode(barcode){ + if(isUndefinedOrNullOrEmpty(barcode)){ + return null; + } + for ( var i = 0; i < sendOutGoodsStore.getCount(); i++) { + var record = sendOutGoodsStore.getAt(i); + var tempBarcode =record.get('barcode'); + if(barcode == tempBarcode){ + return record.data; + } + } + return null; +} +function getSendOutRecordByBarcode(barcode){ + if(isUndefinedOrNullOrEmpty(barcode)){ + return null; + } + for ( var i = 0; i < sendOutGoodsStore.getCount(); i++) { + var record = sendOutGoodsStore.getAt(i); + var tempBarcode = record.get('barcode'); + if(barcode == tempBarcode){ + return record; + } + } + return null; +} +// 名字到数量的map +function getTousseNameToAmountMap(scannedResult){ + var map = {}; + for(var i=0;i= storageAmount){ + return; + } + + } + if(goods.tousseFixedBarcode || (goods.diposable == '是')){ + if(notSendAmount < storageAmount){// 待发货数量小于库存 + count = notSendAmount; + }else{ + count = storageAmount; + } + } + + // 固定条码每次增加的数量不能超过包定义的扫描数量 + if(goods.tousseFixedBarcode){ + var remnantStorage = storageAmount - sendAmount; + count = Math.min(count,goods.scanAmount);// 单次增加数量不能超过每次扫描数量 + count = Math.min(count,remnantStorage);// 增加数量不能超过剩余库存 + + if(count == 0){ + return; + } + } + + var price = goods.price; + var add = true; +// if(goods.tousseFixedBarcode){ +// var existingRecord = getSendOutRecordByBarcode(goods.barcode); +// if(existingRecord != null){ +// add = false; +// var totalCount = count + existingRecord.data.count; +// existingRecord.set('count',totalCount); +// } +// } + if(add){ + var newRecord = new addGridItem({ + id : 0, + barcode : goods.barcode, + name : goods.name, + invoicePlanId: record.data.invoicePlanIDList[0], + tousseFixedBarcode : goods.tousseFixedBarcode, + showTousseName : goods.showTousseName, + count : count, + scanAmount : goods.scanAmount, + waitDeliveryCount:waitDeliveryCount, + diposable : goods.diposable, + price : price, + fluctuationPrice : goods.fluctuationPrice, + storage : storageAmount, + batchNumber : goods.batchNumber, + tousseType : goods.tousseType, + typeInfoOnScanned : goods.typeInfoOnScanned, + sterilizerName : goods.sterilizerName, + frequency : goods.frequency, + isTracable : goods.isTracable, + tousseDefinitionId : goods.tousseDefinitionId, + externalCode : goods.externalCode, + isRoutine : goods.isRoutine + }); + sendOutGoodsStore.insert(0,newRecord); + extIdToAppRecordMap[newRecord.id] = record; + speakBasket.addGoods('',goods.showTousseName,count); +// clearScanText(); + updateAmountByRecord(record,count); + } +} + +function clearScanText(){ + var barcodeEnd = top.Ext.getCmp("scanTextEnd").getValue().Trim(); + if(barcodeEnd == ''){ + if(hiddenEndBarcode || currentScanMode == 'single'){ + top.Ext.getCmp('scanText').setValue("");//如果使用虚拟篮筐机制,扫描成功后需要清除该文本内容 + }else{ + top.Ext.getCmp('scanTextEnd').focus();//否则不清除,条码/篮筐(尾)获得焦点 + } + } + if(barcodeEnd != ''){ + top.Ext.getCmp('scanText').setValue("");//尾条码输入完成,所有条码都取消,要输入确认取消条码了 + top.Ext.getCmp('scanTextEnd').setValue("");//清除尾条码,以输入确认取消条码 + top.Ext.getCmp('scanText').focus();//否则不清除,条码/篮筐(尾)获得焦点 + } +} +function getApplicationGoodsByName(goodsName){ + var record = findRecordByNameAndValueFromStore(recyclingapplicationStore,"name",goodsName); + if(record != null){ + return record.data; + } + return null; +} +function preprocessBeforeGetBarcodeInfo(){ + var barcode = top.Ext.getCmp("scanText").getValue().Trim(); + var barcodeEnd = top.Ext.getCmp("scanTextEnd").getValue().Trim(); + + clearScanText();// 清除条码 + var singleMode = true; + if(barcodeEnd != ''){ + singleMode = false; + } + var sourceWarehouseId = top.Ext.getCmp("sourceWarehouseId").getValue(); + if(isUndefinedOrNullOrEmpty(sourceWarehouseId)){ + showResult('请先选择仓库!'); + return false; + } + if(singleMode){// 判断是否已经扫描过该条码 + var goods = getSendOutGoodsByBarcode(barcode); + if(goods != null){ + if(goods.tousseFixedBarcode){ + // 固定条码允许重复扫 + return true; + } + if(goods.tousseType == '器械包'){// 目前只处理普通器械包的误差,以及删除 + var appGoods = getApplicationGoodsByName(goods.name); + if(appGoods.errorAmount >= 0){// 误差数量大于等于0时,能正常发货,此时重复扫描,按以前的逻辑处理,提示条码已存在 + showResult('条形码:'+barcode+' 已经存在!'); + return false; + }else{// 误差数量小于0时,说明扫描数量已经大于申请数量,此时重复扫描某个包,需要删除该包。 + // 删除该器械包 + removeSendOutTousseByBarcode(goods.barcode); + return false; + } + }else{ + showResult('条形码:'+barcode+' 已经存在!'); + return false; + } + } + } + return true; +} +//名字到数量的map +function getComboTousseNameToAmountMap(tousseInstancesBelongToThisComboTousse){ + var map = {}; + for(var i=0;i 1) && goods.tousseFixedBarcode){ + continue; + } + + var b = isBarcodeRepeat(goods.barcode); + if(b && (goods.diposable == '是' || !goods.tousseFixedBarcode)){// 扫描多个时,如果存在已扫描的,直接忽略,跳过 + continue; + } + // 校验是否超过待发数量,如果是,也跳过 + if(exceedAmountNames.hasOwnProperty(goods.name)){ + continue; + } + var record = findRecordByGoodsVOFromRecyclingApplicationForInvoice(goods); + + // 如果未找到,继续找下一个 + if (record == undefined){ + var msg = '['+goods.name+']不在发货计划中!'; + if(!isUndefinedOrNullOrEmpty(goods.tousseType)){ + msg = '['+goods.tousseType+']'+'['+goods.name+']不在发货计划中!'; + } + showResult(msg); + continue; + } + if((goods.tousseType == '外部代理灭菌' || goods.tousseType == '外来器械包' || goods.tousseType == '外来器械拆分小包' || goods.proxyDisinfection_id) && !goods.tousseFixedBarcode){ + var inPlan = false; + for(var i=0;i 0){ +// showResult(msg); +// } +// } + speakBasket.speakContent(); +// if(result.data.length > 0 && alreadyAddAmount == 0){ +// showResult("器械包已扫描或不在发货单中"); +// } + }, + failure : function(response, options) { + top.Ext.getCmp("sendOutGoods").getEl().unmask(); + showResult('获取条码信息失败'); + top.Ext.getCmp('scanText').setValue(""); + top.Ext.getCmp('scanTextEnd').setValue(""); + top.Ext.getCmp('scanText').focus(); + } + + }); +} + +//发货单明细修改 +function updateAmount2(record, amount) { + if (name != null && name.length > 0) { + for ( var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.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)); + updateErrorAmount(record); + refreshTotalAmount(); + } + } + } + return false; +} + +//function getTypeName(diposable){ +// if(diposable == '是'){ +// return '一次性物品'; +// } +//} +// +function findRecordByGoodsVOFromRecyclingApplication(vo) { + for ( var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.getAt(i); + var name = record.get('name'); + var diposable = record.get('diposable'); + var disposableGoodsIdSet = record.get('disposableGoodsIdSet'); + if(name == vo.name && diposable != vo.diposable){ + var msg = '待发物品['+name+']为一次性物品,请扫描一次性物品条码!'; + if(diposable != '是'){ + msg = '待发物品['+name+']为器械包,请扫描器械包条码!'; + } + showResult(msg); + return null; + } + + if(diposable == '是'){ + // 一次性物品优先根据id来匹配 + if(disposableGoodsIdSet.length > 0 && !isUndefinedOrNullOrEmpty(vo.typeInfoOnScanned)){ + var typeInfoOnScanned = JSON.parse(vo.typeInfoOnScanned); + for(var di=0;di 0 && !isUndefinedOrNullOrEmpty(vo.typeInfoOnScanned)){ + var typeInfoOnScanned = JSON.parse(vo.typeInfoOnScanned); + for(var di=0;di= appAmount1){ + continue; + }else{ + return record; + } + } + return retRecord; +} +//刷新库存 +function refreshStorage(warehouseId){ +// if(lastLoadWarehouseId != null && lastLoadWarehouseId == warehouseId){ +// return; +// } + var ids = ''; + for ( var i = 0; i < recyclingapplicationStore.getCount(); i++) { + var record = recyclingapplicationStore.getAt(i); + var data = record.data; + if(data.diposable != '是'){ + continue; + } + var disposableGoodsIdSet = data.disposableGoodsIdSet; + if(disposableGoodsIdSet.length > 0){ + for(var di=0;di 0){ + for ( var i = 0; i < storages.length; i++) { + var storage = storages[i]; + var record = findAppRecordByStorageInfo(storage); + if(record){ +// if(!isUndefinedOrNull(storage.middlePackageStorage)){ +// record.set('storage',storage.storage); +// }else{ +// record.set('storage',storage.storage); +// } + record.set('storage',storage.storage); + } + } + } +} +function findAppRecordByStorageInfo(storage){ + for(var i=0;i 0){ + return true; + } + return false; +} +/** + * 发货单窗口 + * @param orgUnitCoding 科室编码 + * @param depart 科室名称 + * @param invoicePlanId 发货计划id + */ +var invoicePlanFormOpened = false; +var g_orgUnitCoding = ''; +function addAndEditInvoicePlan(orgUnitCoding,depart,invoicePlanId) { + if(invoicePlanFormOpened){ + return; + } + g_orgUnitCoding = orgUnitCoding; + invoicePlanFormOpened = true; + lastLoadWarehouseId = null; + defaultFocusedFieldOnInvoiceForm = getStrValueFromJs('sstsConfig.defaultFocusedFieldOnInvoiceForm',defaultFocusedFieldOnInvoiceForm); + // 发货物品 + sendOutGoodsStore = new Ext.data.Store({ + reader : new Ext.data.JsonReader({ + fields : [ + {name : 'id'}, + {name : 'barcode'}, + {name : 'name'}, + {name : 'appRecord'}, + {name : 'showTousseName'}, + {name : 'count'}, + {name : 'scanAmount'}, + {name : 'waitDeliveryCount'}, + {name : 'diposable'}, + {name : 'tousseType'}, + {name : 'tousseFixedBarcode'}, + {name : 'price'}, + {name : 'fluctuationPrice'}, + {name : 'storage'}, + {name : 'batchNumber'}, + {name : 'sterilizerName'}, + {name : 'frequency'}, + {name : 'externalCode'} + ] + }) + }); + + var rd = new Ext.data.JsonReader( { + fields : [ + {name : 'id'}, + {name : 'barcode'}, + {name : 'name'}, + {name : 'consoleName'}, + {name : 'showTousseName'}, + {name : 'count'}, + {name : 'middlePackageAmount'}, + {name : 'diposable'}, + {name : 'price'}, + {name : 'urgentAmount'}, + {name : 'tempAmount'}, + {name : 'errorAmount'}, + {name : 'storage'}, + {name : 'amount'}, + {name : 'applicationAmount'}, + {name : 'batchNumber'}, + {name : 'disposableGoodsIdSet'}, + {name : 'invoicePlanIDList'}, + {name : 'invoicePlanType'} + ] + }); + //科室申请单的store + var departApplicationStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/invoicePlanAction!getInvoicePlansByOrgAndTousseType.do?departCode=' + + orgUnitCoding + '&applyDate=' + + selectedApplyDate + '&tousseType=' + + encodeURI(selectedTousseType), + method : 'POST' + }), + reader : new Ext.data.JsonReader({fields : [{name : 'id'},{name : 'typeAndserialNumber'},{name : 'remark'}]}), + listeners: { + load: function(thiz,records,options){ + + if(records.length > 0 && invoicePlanId){ + var index; + for(var index = 0; index < records.length;++index){ + if(records[index].data.id == invoicePlanId){ + break; + } + } + if(index < records.length){ + var combo = top.Ext.getCmp('invoicePlanId'); + combo.setValue(records[index].data.id); + combo.fireEvent('select', combo,records[index],index); + } + } + } + } + }); + + //申请物品 + recyclingapplicationStore = new Ext.data.Store({ + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectSystem/invoiceAction!getOperationReservationGoodsForPC.do', + method : 'POST' + }), + reader : rd, + listeners: { + load: function(thiz,records,options){ + initErrorAmount(); + var sourceWarehouseIdCmp = top.Ext.getCmp('sourceWarehouseId'); + if(sourceWarehouseIdCmp != null){ + var sourceWarehouseId = sourceWarehouseIdCmp.getValue(); + refreshTotalAmount(); + refreshStorage(sourceWarehouseId); + } + recyclingapplicationStoreLoaded = true; + } + } + }); + + recyclingapplicationStore.removeAll(); + recyclingapplicationStore.on("beforeload", function(thiz, options) { + thiz.baseParams["orgUnitCoding"] = orgUnitCoding; + recyclingapplicationStore.baseParams['invoicePlanIds'] = selectedInvoicePlanIds; + recyclingapplicationStore.baseParams['applyDate'] = selectedApplyDate; + recyclingapplicationStore.baseParams['tousseType'] = encodeURI(selectedTousseType); + }); + + recyclingapplicationStore.load(); +// sendOutGoodsStore.removeAll(); +// sendOutGoodsStore.on("beforeload", function(thiz, options) { +// thiz.baseParams["orgUnitCoding"] = orgUnitCoding; +// }); +// sendOutGoodsStore.load(); + + var recyclingapplicationCm = new Ext.grid.ColumnModel([ + {header : "手术台次",dataIndex : 'consoleName',width : 80,menuDisabled: true}, + {header : "申请的物品",dataIndex : 'showTousseName',width : 180,menuDisabled: true}, + {header : "name",dataIndex : 'name',hidden : true,menuDisabled: true}, + {header : "待发",dataIndex : 'count',width : 50, menuDisabled: true/*, + editor : new Ext.form.TextField( { + allowBlank : false, + listeners : { + focus : function(thiz){ + thiz.selectText(); + } + } + })*/ + }, + {header : '加急',id : 'urgentAmount',dataIndex : 'urgentAmount',width : 50,value : 0, menuDisabled: true,renderer:getDefaultAmount}, + {header : '实发',id : 'tempAmount',dataIndex : 'tempAmount',width : 50,value : 0, menuDisabled: true,renderer:getDefaultAmount}, + {header : '误差',id : 'errorAmount',dataIndex : 'errorAmount',width : 50,value : 0, menuDisabled: true,renderer:getDefaultAmount}, + {header : '库存',id : 'storage',dataIndex : 'storage',width : 50,value : 0, menuDisabled: true,renderer:formatStorage}, + {id : 'diposable',header : "是否一次性材料",dataIndex : 'diposable',hidden :true}, + {id :'applicationAmount',header : "最大发货数量",dataIndex : 'applicationAmount',hidden : true,width :150} +// {id : 'deleteItem',header:'删除',hidden :true,width :40,menuDisabled: true, +// renderer: function(v,p,record){ +// var str = ""; +// return str; +// }, +// dataIndex:'button' +// } + ]); + + var recyclingErrorCm = new Ext.grid.ColumnModel([ + {header : "材料名称",dataIndex : 'goodsName',width : 170,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([ + {header : "条码",dataIndex : 'barcode',width : 65,menuDisabled: true}, + {header : "物品名称",dataIndex : 'showTousseName',width : 190,menuDisabled: true}, + {header : "name",dataIndex : 'name',hidden : true,menuDisabled: true}, + {header : "批次/灭菌日期",dataIndex : 'batchNumber',width : 125,menuDisabled: true}, + {header : "灭菌炉名称",dataIndex : 'sterilizerName',width : 200,menuDisabled: true,hidden :true}, + {header : "炉次",dataIndex : 'frequency',width : 50,menuDisabled: true,hidden :true}, + {id : 'diposable',header : "是否一次性材料",dataIndex : 'diposable',hidden :true,width : 150}, + {header : "单价",dataIndex : 'fluctuationPrice',width : 50, align:'right', menuDisabled: true}, + {header : "数量",dataIndex : 'count',width : 50, align:'right', menuDisabled: true, + editor : new Ext.form.NumberField({ + allowBlank : false, + allowNegative : false, + minValue :1, + style : 'text-align: left', + allowDecimals : false, + listeners : { + focus : function(thiz){ + thiz.selectText(); + } + } + })}, + {id : 'deleteItem',header:'删除',width : 25, align:'center', menuDisabled: true, + renderer: function(v,p,record){ + var str = ""; + return str; + }, + dataIndex:'button' + }]); + function doSaveAction(){ + if (!form.getForm().isValid()) { + showResult('请正确填写表单各值'); + return false; + } + //验证发货物品表格 + if(!sendOutGoodsStore || sendOutGoodsStore.getCount() == 0){ + showResult('发货物品不能为空!'); + return false; + } + /*var b = validTousseGridData(); + if(!b){ + return false; + }*/ + var bool = validGridAmount(); + if(!bool){ + return false; + } + if(!getTousseGridData()){ + return false; + } + form.form.submit( { + //url : WWWROOT + '/disinfectSystem/invoiceAction!saveDepartInvoice.do', + url : WWWROOT + '/disinfectSystem/invoiceAction!saveInvoiceByDepartOrInvoicePlanId.do', + method : 'POST', + waitMsg : '正在保存数据,请稍候', + waitTitle : '提交表单', + success : function(form, action) { + // 一定要事务提交成功才返回发货计划列表界面 + showResult(action.result.message); + if(action.result.success){ + invoiceFormWindow.close(); + // 返回退货界面 + if(openMode == INVOICE_FORM_OPEN_MODE_CLICKRETURNRECORD){ + document.location.href = WWWROOT+'/disinfectsystem/returnGoodsRecord/returnGoodsRecordView.jsp'; + return; + } + grid.getStore().reload(); + } + }, + failure : function(form, action) { + if(!isUndefinedOrNullOrEmpty(action.result) && !isUndefinedOrNullOrEmpty(action.result.message)){ + showResult(action.result.message); + }else{ + showResult("发货超时,请稍后查看发货单以确定发货是否成功,避免重复发货!"); + invoiceFormWindow.close(); + // 返回退货界面 + if(openMode == INVOICE_FORM_OPEN_MODE_CLICKRETURNRECORD){ + document.location.href = WWWROOT+'/disinfectsystem/returnGoodsRecord/returnGoodsRecordView.jsp'; + return; + } + grid.getStore().reload(); + } + } + }); + } + var barcodeBtn = new BarcodeBtn(function(){doSaveAction();},function(){invoiceFormWindow.close();}); + var form = new top.Ext.FormPanel({ + id : 'recyclingApplicationForm', + frame : true, + labelSeparator : ':', + bodyStyle : 'padding:5px 5px 0px 5px', + width : 1020, + height : 580, + // autoHeight : true, + autoScroll : true, + labelAlign:'right', + layout : 'form', + items : [{ + xtype : "fieldset", + title : "基础数据", + layout : 'column', + style: 'padding:0px', + autoHeight : true, + items : [{ + layout : 'column', + columnWidth :1, + items:[{ + xtype : 'hidden', + name : 'id', + id : 'id' + },{ + xtype : 'hidden', + name : 'sendOutGoodsStoreData', + id : 'sendOutGoodsStoreData' + },{ + xtype :'hidden', + name : 'recyclingappStoreData', + id : 'recyclingappStoreData' + },{ + xtype :'hidden', + name : 'status', + id : 'status' + },{ + xtype :'hidden', + name : 'orgUnitCoding', + id : 'orgUnitCoding', + value:orgUnitCoding + },{ + xtype :'hidden', + name : 'applyDate', + id : 'applyDateHidden', + value:selectedApplyDate + },{ + xtype :'hidden', + name : 'tousseType', + id : 'tousseTypeHidden', + value:selectedTousseType + },{ + xtype :'hidden', + name : 'invoicePlanId', + id : 'invoicePlanIdHidden', + value:selectedInvoicePlanId + },{ + xtype : 'hidden', + name : 'invoiceType', + id : 'invoiceType', + value:TYPE_OPERATION_RESERVATION_MERGE + },{ + xtype :'hidden', + name : 'personInChargeCode', + id : 'personInChargeCode' + },{ + xtype : 'hidden', + name : 'sourceWarehouseId', + id : 'sourceWarehouseId' + },{ + xtype : 'hidden', + name : 'sourceWarehouseName', + id : 'sourceWarehouseName' + },{ + xtype : 'hidden', + name : 'warehouseID', + id : 'warehouseID' + },{ + xtype : 'hidden', + name : 'warehouseName', + id : 'warehouseName' + },{ + layout : 'form', + labelWidth :70, + columnWidth :.33, + items : [{ + xtype : 'textfield', + fieldLabel : '申请科室', + maxLength : '100', + id : 'depart2', + name : 'depart', + value : depart, + readOnly:true, + anchor : '99%', + cls:'fieldReadOnlyNoRemove' + + }] + },{ + layout : 'form', + labelWidth :70, + columnWidth :.67, + items : [{ + xtype : 'textfield', + fieldLabel : '发货员', + maxLength : '41', + id : 'deliveryPerson', + name : 'deliveryPerson', + readOnly:true, + allowBlank : false, + anchor : '99%', + value:$Id('userName').value, + cls:'fieldReadOnlyNoRemove' + }] + },{ + layout : 'form', + labelWidth :70, + columnWidth :.33, + 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.getUserNameOfCurrentLoginUserOrgsByBarcode( + 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(""); + top.Ext.getCmp('personInChargeBarcode').focus(); + }); + } + }); + } + } + }] + },{ + layout : 'form', + labelWidth :70, + columnWidth :.33, + items : [{ + xtype : 'textfield', + fieldLabel : '核对员', + maxLength : '41', + id : 'sender', + name : 'sender', + readOnly:true, + allowBlank : false, + anchor : '99%', + cls:'x-item-disabled' + }] + },{ + layout : 'form', + labelWidth :90, + columnWidth :.33, + items : [{ + xtype : 'textfield', + fieldLabel : '下送责任人条码', + maxLength : '16', + id : 'personInChargeBarcode', + name : 'personInChargeBarcode', + anchor : '99%', + listeners : { + render : function(p) { + p.getEl().on('keypress',function(e) { + if (e.getKey() == 13) {//回车键 + var barcode = top.Ext.getCmp('personInChargeBarcode').getValue(); + top.Ext.getCmp('personInChargeBarcode').setValue(""); + UserTableManager.getUserByBarcode(barcode,function(responseText){ + if(!isUndefinedOrNullOrEmpty(responseText)){ + var result = top.Ext.decode(responseText); + if(!result.success){ + result.isNotSameOrgUnit?showResult("不允许登记非本科室人员,请扫描本科室人员条码"):showResult("输入的条码有误!"); + return; + } + Ext.state.Manager.getProvider().set('cookiePersonInCharge',result.fullName); + Ext.state.Manager.getProvider().set('cookiePersonInChargeCode',result.name); + top.Ext.getCmp('personInCharge').setValue(result.fullName); + top.Ext.getCmp('personInChargeCode').setValue(result.name); + top.Ext.getCmp('scanText').focus(); + }else{ + showResult('找不到该条码所对应的人员信息'); + } + }); + } + }); + } + } + }] + },{ + layout : 'form', + labelWidth :70, + columnWidth :.33, + items : [{ + xtype : 'textfield', + fieldLabel : '下送责任人', + maxLength : '41', + id : 'personInCharge', + name : 'personInCharge', + readOnly:true, + anchor : '99%', + cls:'x-item-disabled' + }] + },{ + layout : 'form', + labelWidth :70, + columnWidth :.33, + 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', +// value:new Date(), + anchor : '99%', + listeners : { + render : function() { + setStartDate(top.Ext, 'yyyy/MM/dd HH:mm', 'sendTime'); //(设置发货时间,取服务器时间 cjr) + } + } + + }] + },{ + columnWidth : .5, + layout : 'form', + labelWidth : 90, + columnWidth :.33, + items:[{ + xtype : 'combo', + fieldLabel : '仓库', + id : 'warehouse', + name : 'warehouse', + minChars : 0, + valueField : 'id', + displayField : 'name', + store : wareHouseStore, + forceSelection : true, + lazyInit : false, + triggerAction : 'all', + hideTrigger : true, + typeAhead : false, + allowBlank : false, + anchor : '99%', + listeners : { + select : function(combo, record, index) { + top.Ext.getCmp('warehouse').setValue(record.data.name); + top.Ext.getCmp('sourceWarehouseId').setValue(record.data.id); + top.Ext.getCmp('sourceWarehouseName').setValue(record.data.name); + // 刷新库存数据 + refreshStorage(record.data.id); +// top.Ext.getCmp('remark2').focus(); + }, + specialkey : function(field, ee) { + if (ee.getKey() == Ext.EventObject.ENTER) { +// top.Ext.getCmp('remark2').focus(); + } + } + } + }] + },{ + layout : 'form', + columnWidth : 1, + labelWidth :70, + hidden: true, + items : [{ + xtype : 'textarea', + fieldLabel : '备注', + id : 'remark2', + name : 'remark', + anchor : '98.5%', + height : 40, + readOnly:true + }] + }] + }] + },{ + layout:'column', + items:[{ + layout : 'form', + columnWidth : 0.57, + items:[ + new top.Ext.grid.EditorGridPanel({ + id : 'sendOutGoods', + store : sendOutGoodsStore, + columnWidth : 0.5, + cm : cm, + width : 560, + height : 425, + autoExpandColumn : 'deleteItem', + enableHdMenu : false, + frame : false, + bodyStyle : 'border:1px solid #afd7af', + viewConfig: { + autoFit:true + }, + clicksToEdit : 1,// 设置点击几次才可编辑 + selModel : new top.Ext.grid.RowSelectionModel({ + singleSelect : false + }), + tbar : [{ + text : '扫描模式:', + hidden : hiddenEndBarcode + },{ + xtype:'combo', + id : 'scanMode', + name : 'scanMode', + hidden : hiddenEndBarcode, + fieldLabel : '扫描模式', + valueField : 'scanModeCode', + displayField : 'scanModeName', + triggerAction : 'all', + width : 80, + allowBlank : true, + editable : false, + value:currentScanMode, + store : new Ext.data.SimpleStore({ + fields : ['scanModeCode', 'scanModeName' ], + data : [['single','单个条码'],['area','首尾条码']] + }), + mode:'local', + forceSelection : true, + triggerAction : 'all', + listeners : { + select : function(combo, record, index){ + //alert(record.get("scanModeCode")); + currentScanMode = record.get("scanModeCode"); + //首尾条码全部清空,且让首条码得到焦点 + top.Ext.getCmp('scanText').setValue(""); + top.Ext.getCmp('scanTextEnd').setValue(""); + top.Ext.getCmp('scanText').focus(); + } + }, + anchor : '100%' + },{ + text : beginBarcodeLabel + },{ + xtype : 'textfield', + id : 'scanText', + name : 'scanText', + width : 90, + enableKeyEvents : true, + listeners : { + render : function(c) { + c.getEl().on('keypress',function(e) { + if (e.getKey() == 13) {// 输入;号键,grid重新加载 + if(top.Ext.getCmp("scanText").getValue() != ''){ + if(!barcodeBtn.processBarcode(top.Ext.getCmp("scanText").getValue())){ + loadGoodsByBarcode(orgUnitCoding); + } + }else{ + showResult("请扫描输入器械包/篮筐(首)条码!"); + } + } + }); + c.getEl().on('focus',function(e) { + top.Ext.getCmp('scanText').setValue(''); + }); + } + } + },{ + text : '条码/篮筐(尾):', + hidden : hiddenEndBarcode + },{ + xtype : 'textfield', + id : 'scanTextEnd', + name : 'scanTextEnd', + hidden : hiddenEndBarcode, + width : 90, + enableKeyEvents : true, + listeners : { + render : function(c) { + c.getEl().on('keypress',function(e) { + if (e.getKey() == 13) {// 输入;号键,grid重新加载 + if(top.Ext.getCmp("scanTextEnd").getValue() != ''){ + if(!barcodeBtn.processBarcode(top.Ext.getCmp("scanTextEnd").getValue())){ + loadGoodsByBarcode(orgUnitCoding); + } + }else{ + showResult("请扫描输入器械包/篮筐(尾)条码!"); + } + } + }); + c.getEl().on('focus',function(e) { + top.Ext.getCmp('scanTextEnd').setValue(''); + }); + } + } + }], + listeners : { + beforeedit : function(grid){// 只有一次性物品和固定条码才能编辑数量 + var record = grid.record; + var goods = record.data; + if(record.data.diposable == '是') { + return true; + } + if((goods.tousseType == '器械包' || goods.tousseType == '敷料包') && goods.tousseFixedBarcode){ + return true; + } + return false; + }, + afteredit :function(grid){ + var id = grid.record.data['id']; + var name = grid.record.data['name']; + var count = grid.record.data['count']; + var countInt = parseInt(count); + var storage = grid.record.data['storage']; + var storageInt = parseInt(storage); + var waitDeliveryCount = grid.record.data['waitDeliveryCount']; + var waitDeliveryCountInt = parseInt(waitDeliveryCount); + if(id==0){ + var maxAmountCanSend = Math.min(storageInt,waitDeliveryCountInt); + if(countInt > storageInt){ + showResult('库存量为:' + storage + ',已超过库存量!'); + } + if(countInt > waitDeliveryCountInt){ + showResult('申请数量为:' + waitDeliveryCountInt + ',已超过申请数量!'); + } + + if(countInt <= maxAmountCanSend){ + updateAmount2(name,countInt); + } else { + updateAmount2(name,maxAmountCanSend); +// showResult('库存量为:' + storage + ',已超过库存量!'); +// var index = recyclingapplicationStore.find("name",name); +// var tempAmount = recyclingapplicationStore.getAt(index).data['tempAmount']; + grid.record.set('count',maxAmountCanSend); + } + } else { + var record = getRecord(recyclingapplicationStore, "name", name, 0); + if(record != null) { + var tempAmount = record.data['tempAmount']; + if(parseInt(count) <= (storageInt + parseInt(tempAmount))){ + updateAmount2(name,count); + } else { + showResult('库存量为:' + storage + ',已超过库存量!'); + grid.record.set('count',tempAmount); + } + } + } + } + } + } + )] + },{ + layout : 'form', + columnWidth : 0.43, + items:[new top.Ext.grid.EditorGridPanel({ + id : 'sendOutGoodsDetail', + title : '发货单明细', + store : recyclingapplicationStore, + cm : recyclingapplicationCm, + enableHdMenu : false, + width :423, + height :425, + loadMask : true, + tbar:[{ + text:'申请单:', + hidden: true + },{ + xtype:'combo', + id : 'invoicePlanId', + name : 'invoicePlanId', + hidden: true, + valueField : 'id', + listWidth : 280, + displayField : 'typeAndserialNumber', + allowBlank : true, + editable : false, + store : departApplicationStore, + forceSelection : true, + triggerAction : 'all', + listeners : { + select : function(combo, record, index){ + //1.根据申请单号的条件重新加载发货单明细 + var id = record.get('id'); + selectedInvoicePlanId = id; + recyclingapplicationStore.baseParams['invoicePlanId'] = id; + recyclingapplicationStore.load(); + //2.清除已扫描的记录 + sendOutGoodsStore.removeAll(); + top.Ext.getCmp('sendOutGoodsStoreData').setValue(''); + //3.hidden赋值 + top.Ext.getCmp('invoicePlanIdHidden').setValue(id); + //4.已扫描的首尾器械包或篮筐条码清空 + top.Ext.getCmp('scanText').setValue(''); + top.Ext.getCmp('scanTextEnd').setValue(''); + } + }, + anchor : '95%' + },{ + text: "", + id : 'tousseAmountInfo' + }], + autoExpandColumn : 'deleteItem', + frame : false, + bodyStyle : 'border:1px solid #afd7af', + viewConfig: { + forceFit:true, + getRowClass : function(record,rowIndex,rowParams,store){ + if(record.data.errorAmount < 0){ + return 'my_row_red'; + }else if(record.data.errorAmount > 0){ + return 'my_row_yellow'; + }else{ + return 'my_row_green'; + } + } + }, + clicksToEdit:1, + selModel : new top.Ext.grid.RowSelectionModel({ + singleSelect : false + }), + listeners:{ + validateedit : function(o){ + if(!isPositiveInteger(o.value))return false; + } + } + })] + } + ] + }], + buttons : [{ + text : '保存', + id:'saveButton', + handler : function(){doSaveAction();} + }, { + text : '取消', + handler : function() { + //切记注意:按取消关闭window后,一定要把已选择的申请单号变量清空 + selectedInvoicePlanId = ""; + invoiceFormWindow.close(); + + // 返回退货界面 + if(openMode == INVOICE_FORM_OPEN_MODE_CLICKRETURNRECORD){ + document.location.href = WWWROOT+'/disinfectsystem/returnGoodsRecord/returnGoodsRecordView.jsp'; + } + } + }] + }); + +// Ext.Ajax.request({ +// url : WWWROOT + '/disinfectSystem/invoicePlanAction!loadDepartApplicationInfo.do', +// params : {orgUnitCoding : orgUnitCoding}, +// success : function(response, options) { +// var result = Ext.decode(response.responseText); +// var remark = result.remark; +// top.Ext.getCmp('remark2').setValue(remark); +// }, +// failure : function(form, action) { +// } +// }); + var cookieSender = Ext.state.Manager.getProvider().get('cookieSender'); + if(cookieSender){ + top.Ext.getCmp('sender').setValue(cookieSender); + } + var cookiePersonInCharge = Ext.state.Manager.getProvider().get('cookiePersonInCharge'); + var cookiePersonInChargeCode = Ext.state.Manager.getProvider().get('cookiePersonInChargeCode'); + if(cookiePersonInCharge){ + top.Ext.getCmp('personInCharge').setValue(cookiePersonInCharge); + } + if(cookiePersonInChargeCode){ + top.Ext.getCmp('personInChargeCode').setValue(cookiePersonInChargeCode); + } + + var invoiceFormWindow = new top.Ext.Window( { + id : 'recyclingApplicationWin', + layout : 'fit', + title : '发货单', + width : 1000, + // width : 1020, + // height : 660, + height : top.screen.height > 800 ? 660 : 500, + border : false, + modal : true, + plain : true, + items : [form] + }); + + invoiceFormWindow.on('close',function(w){ + //切记注意:按取消关闭window后,一定要把已选择的申请单号变量清空 + selectedInvoicePlanId = ""; + invoicePlanFormOpened = false; + top.getCurrentTab().focus(); + }); + + invoiceFormWindow.show(); + if(project == 'gdsy'){ + if(openMode == INVOICE_FORM_OPEN_MODE_SCANBARCODE){ + var sender = top.Ext.getCmp('sender').getValue(); + var personInCharge = top.Ext.getCmp('personInCharge').getValue(); + if(isUndefinedOrNullOrEmpty(sender)){ + top.Ext.getCmp('senderBarcode').focus(false, 100); + }else{ + if(isUndefinedOrNullOrEmpty(personInCharge)){ + top.Ext.getCmp('personInChargeBarcode').focus(false, 100); + }else{ + top.Ext.getCmp('scanText').focus(false, 100); + } + } + }else{ + top.Ext.getCmp('senderBarcode').focus(false, 100); + } + }else{ + top.Ext.getCmp(defaultFocusedFieldOnInvoiceForm).focus(false, 100); + } + +// top.Ext.getCmp('senderBarcode').focus(false, 100); + + var sendOutGoodsDetailGrid = top.Ext.getCmp('sendOutGoodsDetail'); + sendOutGoodsDetailGrid.on('rowdblclick', function(grid, index) { + var record = grid.getStore().getAt(index); + if(record.data.invoicePlanType == invoicePlanType_disinfect){ + var goodsName = record.data.name; + //显示消毒物品材料 + showDisinfectMaterial(goodsName); + } + }, this, { + buffer : 250 + }); + wareHouseStore.load(); + departApplicationStore.load(); + + if(openMode == INVOICE_FORM_OPEN_MODE_CLICKRETURNRECORD && !isUndefinedOrNullOrEmpty(returnRecordId)){ + if(postInitDataTimer != null){ + window.clearInterval(postInitDataTimer); + postInitDataTimer = null; + } + postInitDataTimer = setInterval("postInitData()", 500); + } +} + +function postInitData(){ +// alert('wareHouseStoreLoaded='+wareHouseStoreLoaded+',recyclingapplicationStoreLoaded='+recyclingapplicationStoreLoaded) + if(!wareHouseStoreLoaded || !recyclingapplicationStoreLoaded){ + return; + } + window.clearInterval(postInitDataTimer); + if(openMode == INVOICE_FORM_OPEN_MODE_CLICKRETURNRECORD && !isUndefinedOrNullOrEmpty(returnRecordId)){ + DWREngine.setAsync(false); + ReturnGoodsRecordTableManager.findToussesByReturnGoodsRecordId(returnRecordId,function(retStr){ + var tousses = top.Ext4.JSON.decode(retStr); + for(var i=0;i 1) { + showResult("一次只能修改一个发货计划单!"); + return false; + } + var departCode = records[0].data['departCoding']; + var depart = records[0].data['depart']; + var operationReservationIds = records[0].data['operationReservationIds']; + selectedInvoicePlanIds = idsArrayToString(operationReservationIds); + openMode = INVOICE_FORM_OPEN_MODE_CLICKITEM; + addAndEditInvoicePlan(departCode,depart); +} +function idsArrayToString(operationReservationIds){ + var ids = ''; + if(isUndefinedOrNull(operationReservationIds)){ + return ids; + } + for(var i=0;i" + v + ""; + } + + 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 selectModel = new Ext.grid.CheckboxSelectionModel(); + grid = new Ext.grid.GridPanel({ + store : new Ext.data.Store({ + autoLoad: false, + proxy : new Ext.data.HttpProxy({ + url : WWWROOT + '/disinfectsystem/operationReservationAction!getWaitingForDeliveryOperationReservationList.do', + method : 'POST' + }), + reader : new Ext.data.JsonReader({ + fields : [ + {name : 'departCode'}, + {name : 'departCoding'}, + {name : 'depart'}, + {name : 'operatingRoom'}, + {name : 'operationDate'}, + {name : 'operationReservationIds'}, + {name : 'urgency'} + ] + }) + , sortInfo: { + field: 'depart', + direction: 'DESC' // 'ASC'or 'DESC' + } + }), + height : 325, + width : 485, + bodyStyle : 'border:1px solid #afd7af', + sm : selectModel, + cm : new top.Ext.grid.ColumnModel([selectModel, + {id:'depart',header : "科室",width : 50,dataIndex : 'depart',menuDisabled:true,renderer : renderCallModifyFunction}, + {header : "手术间",width : 50,dataIndex : 'operatingRoom',menuDisabled:true}, + {id:'operationDate',header : "手术日期",width : 130,dataIndex : 'operationDate',menuDisabled:true} + ]), + autoExpandColumn : 'depart', + frame : false, + viewConfig: { + forceFit:true, + //是否隔行换色 + stripeRows: false, + getRowClass : function(record,rowIndex,rowParams,store){ + + } + }, + loadMask:{msg:'正在加载,请稍候...'}, + title : '发货计划列表', + tbar : [{ + text : '科室分组:', + hidden: true + },{ + xtype : 'combo', + id : 'invoiceDepartGroup', + name : 'invoiceDepartGroup', + hidden: true, + 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 : 'combo', + id : 'applyDate', + name : 'applyDate', + valueField : 'value', + displayField : 'key', + allowBlank : true, + editable : false, + width : 120, + emptyText:'请选择申请单日期', + mode:'local', + store : new Ext.data.SimpleStore({ + data: getTimeComboData(), + fields:['key','value'] + }), + forceSelection : true, + triggerAction : 'all', + listeners : { + select : function(combo, record, index){ + refreshList(true); + } + }, + anchor : '95%' + },{ + text : '开始日期:' + },{ + xtype : sstsConfig.timeSearchFmt ? 'datefieldWithMin' : 'datefield', + fieldLabel : '开始日期', + name : 'startDate', + format : sstsConfig.timeSearchFmt || 'Y-m-d', + id : 'startDate', + readOnly : false, + editable : false, + width : sstsConfig.timeSearchFmt ? 150 : 100 + },{ + text : '结束日期:' + },{ + xtype : sstsConfig.timeSearchFmt ? 'datefieldWithMin' : 'datefield', + fieldLabel : '结束日期', + name : 'endDate', + id : 'endDate', + readOnly : false, + editable : false, + // altFormats: sstsConfig.timeSearchFmt || '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 : sstsConfig.timeSearchFmt || 'Y-m-d', + width : sstsConfig.timeSearchFmt ? 150 : 100 + }, { + text : '物品类型:', + hidden: true + },{ + xtype : 'multiSelect', + id : 'tousseType', + name : 'tousseType', + hidden: true, + 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){ + refreshList(); + } + }, + anchor : '95%' + },{ + text : '刷新列表', + iconCls : 'btn_ext_refresh1', + handler : function() { + refreshList(false,true); + } + }], + listeners: { + render : function() { + var tbar2 = new Ext.Toolbar ({ + items : [{ + text : '申请单类型:', + hidden: true + }, + createAppFormCombo() + ,{ + text : '申请科室:' + }, + { + xtype : 'combo', + id : 'appDepart', + name : 'appDepart', + queryParam : 'spell', + minChars : 0, + valueField : 'departCode', + displayField : 'name', + store : appDepartJsonStore, + forceSelection : true, + lazyInit : true, + triggerAction : 'all', +// hideTrigger : true, + typeAhead : false, + allowBlank : true, +// anchor : '99%', + listeners:{ + select:function(combo, record, index){ + + refreshList(); + }, + focus : function(thiz){ + thiz.selectText(); + } + } + } + ] + }); + tbar2.render(grid.tbar); + // 自动加载列表 + Ext.getCmp('tousseType').selectAll(); + refreshList(); + } + } + + }); + + var viewport = new Ext.Viewport({ + layout:'border', + items:[{ + region:'center', + margins:'0 5 5 0', + xtype : 'panel', + autoScroll:true, + layout: 'fit', + items:grid + }] + }); + g_stopDefault = false; + globalOnKeyDown(openInvoicePlanByBarcode); + window.focus(); + + // 自动打开科室发货界面 + if(openMode == INVOICE_FORM_OPEN_MODE_CLICKRETURNRECORD && !isUndefinedOrNullOrEmpty(returnRecordId)){ + addAndEditInvoicePlan(param_departCode,param_depart); + } +}); \ No newline at end of file Index: ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/service/ServiceManagerImpl.java =================================================================== diff -u -r18314 -r18344 --- ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/service/ServiceManagerImpl.java (.../ServiceManagerImpl.java) (revision 18314) +++ ssts-webservice/src/main/java/com/forgon/disinfectsystem/webservice/service/ServiceManagerImpl.java (.../ServiceManagerImpl.java) (revision 18344) @@ -105,6 +105,7 @@ import com.forgon.disinfectsystem.recyclingapplication.service.RecyclingApplicationManager; import com.forgon.disinfectsystem.recyclingapplication.vo.ApplicationGoodsVo; import com.forgon.disinfectsystem.recyclingapplication.vo.InvoicePlanVo; +import com.forgon.disinfectsystem.recyclingapplication.vo.OperationReservationInvoiceGoodsDetail; import com.forgon.disinfectsystem.returngoodsrecord.service.ReturnGoodsRecordManager; import com.forgon.disinfectsystem.sterilizationmanager.proxydisinfection.service.ProxyDisinfectionManager; import com.forgon.disinfectsystem.sterilizationmanager.proxydisinfection.vo.TousseInstanceVo; @@ -124,7 +125,6 @@ import com.forgon.disinfectsystem.washTransition.service.WashTransitionRecordManager; import com.forgon.disinfectsystem.washanddisinfectmanager.washanddisinfectrecord.action.WashAndDisinfectRecordAction; import com.forgon.disinfectsystem.washanddisinfectmanager.washanddisinfectrecord.service.WashAndDisinfectRecordManager; -import com.forgon.disinfectsystem.webservice.operationreservation.model.OperationReservationInvoiceGoodsDetail; import com.forgon.keyvalue.service.KeyValueManager; import com.forgon.log.model.Log; import com.forgon.log.service.LogManager; @@ -1058,46 +1058,7 @@ * @return */ public String getOperationReservationGoods(JSONObject params){ - String invoicePlanIds = params.optString("invoicePlanIds"); - Collection ors = operationReservationManager.getCollection(invoicePlanIds, ";"); - List operationReservations = operationReservationManager.groupByConsoleName(ors); - if(CollectionUtils.isEmpty(operationReservations)){ - return JSONUtil.buildJsonObject(false, "手术预约单已经删除").toString(); - } - List applicationGoods = new ArrayList<>(); - for(OperationReservationGroupVo orv : operationReservations){ - if(orv == null){ - continue; - } - if(CollectionUtils.isNotEmpty(orv.getOperationReservations())){ - OperationReservationInvoiceGoodsDetail detail = CollectionUtils.find(applicationGoods, new Predicate(){ - @Override - public boolean evaluate( - OperationReservationInvoiceGoodsDetail object) { - if(object != null){ - return StringTools.equals(orv.getConsoleName(), object.getConsoleName()); - } - return false; - }}); - if(detail == null){ - detail = new OperationReservationInvoiceGoodsDetail(); - detail.setConsoleName(orv.getConsoleName()); - applicationGoods.add(detail); - } - for(InvoicePlan or : orv.getOperationReservations()){ - List ips = new ArrayList(); - ips.add(or); - Collection waitDeliverGoods = invoiceManager.getWaitDeliverGoods(ips, params.optString("applyDate",""), null); - if(CollectionUtils.isEmpty(waitDeliverGoods)){ - continue; - } - // 去除消毒物品显示名称前用中文括号包围的科室名称 - fixApplicationGoodsVoShowTousseName(waitDeliverGoods); - detail.add(or.getId(), waitDeliverGoods); - } - } - } - return JSONUtil.buildJsonObject(true,JSONArray.fromObject(applicationGoods)).toString(); + return invoiceManager.getOperationReservationGoods(params); } /** * 获取发货计划 Index: ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationMergeInvoiceView.jsp =================================================================== diff -u --- ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationMergeInvoiceView.jsp (revision 0) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/operationReservationMergeInvoiceView.jsp (revision 18344) @@ -0,0 +1,118 @@ +<%@page import="java.text.SimpleDateFormat"%> +<%@page import="com.forgon.disinfectsystem.entity.tousseitem.TousseItem"%> +<%@page import="java.util.Calendar"%> +<%@page import="com.forgon.disinfectsystem.entity.invoicemanager.InvoicePlan"%> +<%@ page contentType="text/html; charset=UTF-8"%> +<%@ include file="/common/taglibs.jsp"%> +<%@ include file="/common/includeExtJsAndCss.jsp"%> + + + +发货计划单管理 + + + + +<% + request.setAttribute("userName",AcegiHelper.getLoginUser().getUserFullName()); + + //设置日期定义 + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + Calendar cal = Calendar.getInstance(); + String today = sdf.format(cal.getTime());//今天 + pageContext.setAttribute("today", today + ";" + today); + + cal.add(Calendar.DATE, -1); + String yesterday = sdf.format(cal.getTime());//昨天 + pageContext.setAttribute("yesterday", yesterday + ";" + yesterday); + + cal.add(Calendar.DATE, -1); + String threeDaysAgo = sdf.format(cal.getTime());//前天(近三天的起始日) + pageContext.setAttribute("lastThreeDays", threeDaysAgo + ";" + today); + + cal.add(Calendar.DATE, -4); + String sixDaysAgo = sdf.format(cal.getTime());//6天前(近一周的起始日) + pageContext.setAttribute("lastSixDays", sixDaysAgo + ";" + today); + +%> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + \ No newline at end of file Index: ssts-web/src/main/webapp/homepage/menuconfigure.js =================================================================== diff -u -r18325 -r18344 --- ssts-web/src/main/webapp/homepage/menuconfigure.js (.../menuconfigure.js) (revision 18325) +++ ssts-web/src/main/webapp/homepage/menuconfigure.js (.../menuconfigure.js) (revision 18344) @@ -80,6 +80,7 @@ {hidden :SSTS_Invoice_Menu,text:"发货计划管理",href:WWWROOT+'/disinfectsystem/invoice/invoicePlanExtractedView.jsp?editMode=true',hrefTarget:linkTarget,leaf:true}, {hidden :SSTS_OperationReservationDelivery_Menu,text:"手术预约管理",href:WWWROOT+'/disinfectsystem/invoice/operationReservationView.jsp?editMode=true',hrefTarget:linkTarget,leaf:true}, {hidden :SSTS_OperationReservationDelivery_Menu,text:"手术预约发货",href:WWWROOT+'/disinfectsystem/invoice/operationReservationInvoiceView.jsp?editMode=true',hrefTarget:linkTarget,leaf:true}, + {hidden :SSTS_OperationReservationDelivery_Menu,text:"手术预约汇总发货",href:WWWROOT+'/disinfectsystem/invoice/operationReservationMergeInvoiceView.jsp?editMode=true',hrefTarget:linkTarget,leaf:true}, {hidden :SSTS_CustomDelivery_Manager,text:"自定义发货",href:WWWROOT+'/disinfectsystem/invoice/customInvoiceForm.jsp?editMode=true',hrefTarget:linkTarget,leaf:true}, {hidden :SSTS_Invoice_Menu,text:"科室发货计划设置",href:WWWROOT+'/disinfectsystem/invoice/invoiceDepartmentView.jsp?editMode=true',hrefTarget:linkTarget,leaf:true}, {hidden :SSTS_Invoice_Menu,text:"发货单管理",href:WWWROOT+'/disinfectsystem/invoice/invoiceView.jsp?editMode=true',hrefTarget:linkTarget,leaf:true},