Index: ssts-web/src/main/webapp/disinfectsystem/consumptiveMaterial/consumptiveMaterialContainer/form.js =================================================================== diff -u -r34048 -r34056 --- ssts-web/src/main/webapp/disinfectsystem/consumptiveMaterial/consumptiveMaterialContainer/form.js (.../form.js) (revision 34048) +++ ssts-web/src/main/webapp/disinfectsystem/consumptiveMaterial/consumptiveMaterialContainer/form.js (.../form.js) (revision 34056) @@ -170,7 +170,8 @@ { name: 'showName', mapping: 'showName' }, { name: 'displayName', mapping: 'displayName' }, { name: 'consumptiveMaterialVolume', mapping: 'consumptiveMaterialVolume' }, - { name: 'consumptiveMaterialUnit', mapping: 'consumptiveMaterialUnit' } + { name: 'consumptiveMaterialUnit', mapping: 'consumptiveMaterialUnit' }, + { name: 'unitForDisplay', mapping: 'unitForDisplay' } ], listeners: { beforeload: function (store, option) { @@ -250,7 +251,17 @@ anchor: '95%', name: "amount", id: "amount", - value: 1 + value: 1, + listeners: { + change: function (field, event, eOpts) { + var amount = top.Ext4.getCmp('amount').getValue() || 0; + var hiddenConsumptiveMaterialVolume = top.Ext4.getCmp('hiddenConsumptiveMaterialVolume').getValue(); + var hiddenUnitForDisplay = top.Ext4.getCmp('hiddenUnitForDisplay').getValue(); + var hiddenConsumptiveMaterialUnit = top.Ext4.getCmp('hiddenConsumptiveMaterialUnit').getValue(); + var sum = amount * hiddenConsumptiveMaterialVolume; + top.Ext4.getCmp('displayConsumptiveMaterialVolume').setValue(' ' + hiddenUnitForDisplay + ' = ' + sum + hiddenConsumptiveMaterialUnit); + } + } }] }, { layout: 'form', @@ -296,13 +307,25 @@ id: 'hiddenConsumptiveMaterialVolume', name: 'hiddenConsumptiveMaterialVolume' }, { + xtype: 'hidden', + id: 'hiddenConsumptiveMaterialUnit', + name: 'hiddenConsumptiveMaterialUnit' + }, { + xtype: 'hidden', + id: 'hiddenUnitForDisplay', + name: 'hiddenUnitForDisplay' + }, { + xtype: 'hidden', + id: 'storage', + name: 'storage' + }, { xtype: 'combo', fieldLabel: '耗材名称', id: 'diposableGoodsName', name: 'diposableGoodsName', minChars: 0, valueField: 'id', - displayField: 'displayName', + displayField: 'showName', store: disposableGoodsStore, forceSelection: true, lazyInit: false, @@ -316,8 +339,11 @@ top.Ext4.getCmp('diposableGoodsID').setValue(item.data.id); var consumptiveMaterialVolume = item.data.consumptiveMaterialVolume; var consumptiveMaterialUnit = item.data.consumptiveMaterialUnit; - top.Ext4.getCmp('displayConsumptiveMaterialVolume').setValue(' 瓶 = ' + consumptiveMaterialVolume + consumptiveMaterialUnit); + var unitForDisplay = item.data.unitForDisplay; + top.Ext4.getCmp('displayConsumptiveMaterialVolume').setValue(' ' + unitForDisplay + ' = ' + consumptiveMaterialVolume + consumptiveMaterialUnit); top.Ext4.getCmp('hiddenConsumptiveMaterialVolume').setValue(consumptiveMaterialVolume); + top.Ext4.getCmp('hiddenUnitForDisplay').setValue(unitForDisplay); + top.Ext4.getCmp('hiddenConsumptiveMaterialUnit').setValue(consumptiveMaterialUnit); diposableGoodsBatchNumStore.load(); } } @@ -348,9 +374,19 @@ select: function (combo, record, index) { var item = record[0] || record; var storage = item.data.storage; + var unitForDisplay = top.Ext4.getCmp('hiddenUnitForDisplay').getValue(); + var amount = 0; + for (var i = 0; i < receiveRecordItems.length; i++) { + var disposableGoodsBatchStockId = receiveRecordItems[i].disposableGoodsBatchStockId; + if (disposableGoodsBatchStockId == item.data.disposableGoodsBatchStockId) { + amount += parseInt(receiveRecordItems[i].amount); + } + } + var sum = (storage - amount) > 0 ? (storage - amount) : 0; top.Ext4.getCmp('disposableGoodsBatchStockId').setValue(item.data.id); + top.Ext4.getCmp('storage').setValue(sum); top.Ext4.getCmp('dispalyLabelBox').show(); - top.Ext4.getCmp('dispalyLabel').el.dom.innerText = '(当前批次号库存剩余 ' + storage + ' 瓶)'; + top.Ext4.getCmp('dispalyLabel').el.dom.innerText = '(当前批次号库存剩余 ' + sum + ' ' + unitForDisplay + ')'; } } }] @@ -375,10 +411,19 @@ handler: function () { var warehouseId = top.Ext4.getCmp('cssdWareHouse').getValue(); var warehouseName = top.Ext4.getCmp('cssdWareHouse').getRawValue(); - var amount = top.Ext4.getCmp('amount').getValue(); + var amount = top.Ext4.getCmp('amount').getValue() || ''; var diposableGoodsID = top.Ext4.getCmp('diposableGoodsID').getValue(); var disposableGoodsBatchStockId = top.Ext4.getCmp('disposableGoodsBatchStockId').getValue(); var consumptiveMaterialVolume = top.Ext4.getCmp('hiddenConsumptiveMaterialVolume').getValue(); + var storage = top.Ext4.getCmp('storage').getValue(); + if (amount > storage) { + showResult('该批次数量不足,请重新选择或修改补充数量!'); + return; + } + if (amount == '' || amount == 0) { + showResult('数量不能为空或0!'); + return; + } var item = { warehouseId: warehouseId, warehouseName: warehouseName,