Index: ssts-web/src/main/webapp/disinfectsystem/invoice/invoicePlanExtractedForm.js =================================================================== diff -u -r30387 -r30441 --- ssts-web/src/main/webapp/disinfectsystem/invoice/invoicePlanExtractedForm.js (.../invoicePlanExtractedForm.js) (revision 30387) +++ ssts-web/src/main/webapp/disinfectsystem/invoice/invoicePlanExtractedForm.js (.../invoicePlanExtractedForm.js) (revision 30441) @@ -141,14 +141,16 @@ } } //删除发货扫描的物品 -function removeSendOutGoods(id){ - var rows = top.Ext.getCmp('sendOutGoods').getSelectionModel().getSelections();// 返回值为 - if (rows) { +function removeSendOutGoods(){ + //左边已扫物品的已选项 + var rows = top.Ext.getCmp('sendOutGoods').getSelectionModel().getSelections(); + if (rows && rows.length > 0) { for ( var i = 0; i < rows.length; i++) { var goods = rows[i].data; var name = rows[i].data['name']; var amount = rows[i].data['count']; var barcode = rows[i].data['barcode']; + var tousseType = rows[i].data['tousseType']; sendOutGoodsStore1.remove(rows[i]); //固定条码和批次条码判断的参数 @@ -171,12 +173,42 @@ updateAmount1(name,amount); } } - + //sendDeleteScannedGoodsLog(rows[i].data); + if(tousseType == '一次性物品'){ + recalcDisposableGoodsAmount(name); + } } } } +/** + * 修改某个一次性物品已扫数量或删除该一次性物品时,根据已扫的一次性物品名称重新计算该一次性物品的实发数量、误差数量 + * @param disposableGoodsName 一次性物品名称 + * + */ +function recalcDisposableGoodsAmount(disposableGoodsName){ + //1.遍历左边已扫物品的已选项,计算该物品的总数量 + var totalAmount = 0; + var storeCount1 = sendOutGoodsStore1.getCount(); + for(var i = 0;i < storeCount1;i++){ + var recData = sendOutGoodsStore1.getAt(i).data; + if(recData.name == disposableGoodsName){ + totalAmount+= recData.count; + } + } + //2.找到右边发货物品明细的该物品,设置其已扫数量及误差数量 + var storeCount2 = recyclingapplicationStore1.getCount(); + for(var j = 0;j < storeCount2;j++){ + var rec = recyclingapplicationStore1.getAt(j); + if(rec.data.showTousseName == disposableGoodsName){ + rec.set('tempAmount',totalAmount); + rec.set('errorAmount',parseInt(rec.data.count,10) - parseInt(totalAmount,10)); + break; + } + } +} + //删除发货明细项 function removeSendOutGoodsDetail(id){ var rows = top.Ext.getCmp('sendOutGoodsDetail').getSelectionModel().getSelections();// 返回值为 @@ -1239,6 +1271,7 @@ for ( var i = 0; i < recyclingapplicationStore1.getCount(); i++) { var record = recyclingapplicationStore1.getAt(i); var tempName = record.get('name'); + //实发数量 var tempAmount = record.get('tempAmount'); if (tempName == name) { if (tempAmount == null || tempAmount.length <= 0) { @@ -1478,7 +1511,7 @@ }) }); - var rd = new Ext.data.JsonReader( { + var recyclingapplicationRd = new Ext.data.JsonReader( { fields : [ {name : 'id'}, {name : 'barcode'}, @@ -1487,17 +1520,17 @@ {name : 'tousseItems'}, {name : 'scannedMaterialAmount'}, {name : 'showTousseName'}, - {name : 'count'}, + {name : 'count'},//待发数量 {name : 'middlePackageAmount'}, {name : 'diposable'}, {name : 'disposableGoodsId'}, {name : 'goodsType'}, {name : 'price'}, - {name : 'urgentAmount'}, - {name : 'tempAmount'}, - {name : 'errorAmount'}, - {name : 'storage'}, - {name : 'amount'}, + {name : 'urgentAmount'},//加急数量 + {name : 'tempAmount'},//实发数量 + {name : 'errorAmount'},//误差数量 + {name : 'storage'},//库存数量 + {name : 'amount'},//?未知 {name : 'scanTime'}, {name : 'sortValue'}, {name : 'applicationAmount'}, @@ -1578,7 +1611,7 @@ url : WWWROOT + '/disinfectSystem/invoicePlanAction!loadDepartApplicationAllGoodsByCondition.do', method : 'POST' }), - reader : rd, + reader : recyclingapplicationRd, listeners: { load: function(thiz,records,options){ initErrorAmount(); @@ -1696,7 +1729,7 @@ {header : "name",dataIndex : 'name',hidden : true,menuDisabled: true}, {header : "批次/灭菌日期",dataIndex : 'batchNumber',width : 110,menuDisabled: true} ]); - var cm = new Ext.grid.ColumnModel([ + var sendOutGoodsColumnModel = new Ext.grid.ColumnModel([ {header : "条码",dataIndex : 'barcode',align:'center',width :top.screen.width < 1280 ? 85 : 125 ,menuDisabled: true, renderer : function(v, p, record){ if(sstsConfig.enableUrgentFunction && record.data.urgentLevel != undefined && record.data.urgentLevel.colorCode != undefined){ @@ -2225,7 +2258,7 @@ id : 'sendOutGoods', store : sendOutGoodsStore1, columnWidth : 0.5, - cm : cm, + cm : sendOutGoodsColumnModel, width : top.screen.width < 1280 ? top.screen.width*0.57-50 : 660, height : top.screen.height < 864 ? windowH-232 : 475, autoExpandColumn : 'deleteItem', @@ -2412,7 +2445,8 @@ typeInfoOnScanned : goods.typeInfoOnScanned }); sendOutGoodsStore1.insert(0,newRecord); - updateAmount2(goods.name,goods.amount); + //updateAmount2(goods.name,goods.amount); + recalcDisposableGoodsAmount(goods.name); } } } @@ -2441,6 +2475,9 @@ afteredit :function(grid){ var id = grid.record.data['id']; var name = grid.record.data['name']; + var barcode = grid.record.data['barcode']; + var tousseType = grid.record.data['tousseType']; + //数量列 var count = grid.record.data['count']; var countInt = parseInt(count); var storage = grid.record.data['storage']; @@ -2456,12 +2493,22 @@ } } var waitDeliveryCountInt = parseInt(waitDeliveryCount); + //id=0表示为一次性物品? if(id==0){ - var maxAmountCanSend = Math.min(storageInt,waitDeliveryCountInt); + //查出该物品的其它条码的已扫数量 + var otherBarcodeSummaryAmountOfCurrentDisposableGoods = 0; + var storeCount1 = sendOutGoodsStore1.getCount(); + for(var i = 0;i < storeCount1;i++){ + var recData = sendOutGoodsStore1.getAt(i).data; + if(recData.name == name && recData.barcode != barcode){ + otherBarcodeSummaryAmountOfCurrentDisposableGoods += recData.count; + } + } + var maxAmountCanSend = Math.min(storageInt,waitDeliveryCountInt) - otherBarcodeSummaryAmountOfCurrentDisposableGoods; if(countInt > storageInt){ showResult('库存量为:' + storage + ',已超过库存量!' , null , sstsConfig.messagePauseTimeOnInvoiceplanPage); } - if(countInt > waitDeliveryCountInt){ + if((countInt + otherBarcodeSummaryAmountOfCurrentDisposableGoods) > waitDeliveryCountInt){ showResult('申请数量为:' + waitDeliveryCountInt + ',已超过申请数量!' , null , sstsConfig.messagePauseTimeOnInvoiceplanPage); } @@ -2486,6 +2533,10 @@ } } } + + if(tousseType == '一次性物品'){ + recalcDisposableGoodsAmount(name); + } } } } @@ -2756,9 +2807,9 @@ var invoicePlan_recyclingapplicationCm = new Ext.grid.ColumnModel([ {header : "申请的物品",dataIndex : 'showTousseName',width : 180,menuDisabled: true}, {header : "数量",dataIndex : 'applicationAmount',width : 50, menuDisabled: true}, - {header : "已发",dataIndex : 'sendAmount',width : 50, menuDisabled: true}, + {header : "已发",dataIndex : 'sendAmount',width : 50, menuDisabled: true}, {header : "待发",dataIndex : 'count',width : 50, menuDisabled: true} - //{header : '加急',id : 'urgentAmount',dataIndex : 'urgentAmount',width : 50,value : 0, menuDisabled: true,renderer:getDefaultAmount} + //{header : '加急',id : 'urgentAmount',dataIndex : 'urgentAmount',width : 50,value : 0, menuDisabled: true,renderer:getDefaultAmount} ]);