Index: ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsApplicationForm.js =================================================================== diff -u -r20397 -r20408 --- ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsApplicationForm.js (.../goodsApplicationForm.js) (revision 20397) +++ ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsApplicationForm.js (.../goodsApplicationForm.js) (revision 20408) @@ -629,66 +629,70 @@ } }, edit:function(editor, context, eOpts){ + var totalPrice; + var originalValue = context.originalValue; var record = context.record; var isDiposableGoods = record.get("diposable"); - var totalPrice; - if (isDiposableGoods == '是' && context.value != null && context.value != ''){ - if (handleAmountEvent(context)){ - return; - } - totalPrice = reCalculateTotalPriceAndSetUnitCount(record,context); - } + var count = record.get('count'); var depth = record.getDepth(); var isLeaf = record.get('leaf'); var tousseType = record.get('tousseType'); var isApplyEntireTousse = record.get('isApplyEntireTousse'); var urgentAmount = record.get('urgentAmount'); + + if (isDiposableGoods == '是'){ + if (checkDisposableGoodsAmountEvent(context)){ + return; + } + totalPrice = reCalculateTotalPriceAndSetUnitCount(record, context); + } - //如果是清洗包拆包编辑的是第一层的时候只需要判断加急数量是否大于1,因为拆包的数量不能编辑 + //如果是拆包申请的消毒物品的第一层的时候不能编辑申请数量,但是允许填写加急数量,但是不允许大于1, if (!isLeaf && depth == 1 && isApplyEntireTousse == '否'){ - if (handleUrgentAmount.handleApplyEntireTousse(tousseType,isApplyEntireTousse,urgentAmount)){ - record.set("urgentAmount", ""); + if (handleUrgentAmount.handleApplyEntireTousse(tousseType, isApplyEntireTousse, urgentAmount)){ + record.set("urgentAmount", originalValue); } }else{ - if (handleUrgentAmount.handleUaAndCount(urgentAmount,record.get('count'))){ - record.set("urgentAmount", ""); + if (handleUrgentAmount.handleUaAndCount(urgentAmount, count)){ + record.set("urgentAmount", originalValue); } - if (handleUrgentAmount.handleApplyEntireTousse(tousseType,isApplyEntireTousse,urgentAmount)){ - record.set("urgentAmount", ""); + if (handleUrgentAmount.handleApplyEntireTousse(tousseType, isApplyEntireTousse, urgentAmount)){ + record.set("urgentAmount", originalValue); } } if (isInterveneAmount) { //干预申请数量的操作,改后的数量不能大于原来申请的数量 - if (!record.get('count')) { - record.set('count', context.originalValue); + if (!count) { + record.set('count', originalValue); showResult('数量必须大于0!'); return; } - if (record.get('count') > record.get('countBackup')) { - record.set('count', context.originalValue); + if (count > record.get('countBackup')) { + record.set('count', originalValue); showResult('数量不能大于之前申请的数量'); return; } } else if (isDiposableGoods == '是') { if (type == diposableGoodsApplicationForm && top.Ext4.getCmp("deliverStatus").getValue() == statusArr[1]) { - if (record.get('count') < record.get('sendOutAmount')) { - record.set('count', context.originalValue); + var unitCount = record.get('unitCount'); + if ((!isUndefinedOrNullOrEmpty(unitCount) ? unitCount : count) < record.get('sendOutAmount')) { + record.set('count', originalValue); showResult('修改后的数量不能小于已经发货的数量!'); return; } } else { var bindGoodVo = { goodName: record.get('name'), - bindCount: record.get('count'), + bindCount: count, goodId: record.get('tousseDefinitionID'), - goodType: record.get('tousseType') + goodType: tousseType }; var goodsBindHandler = new GoodsBindHandler(); goodsBindHandler.handleBindGood(bindGoodVo); } } - record.set("totalPrice", isUndefinedOrNullOrEmpty(totalPrice) ? roundValue(context.value * record.get("price")):totalPrice); + record.set("totalPrice", isUndefinedOrNullOrEmpty(totalPrice) ? roundValue(count * record.get("price")) : totalPrice); if (context.value == 0){ record.set("count", ""); } @@ -932,32 +936,6 @@ tbar : diposableTreeGridTbar }); - /** - * 加急数量的的工具类 - */ - var handleUrgentAmount = { - /** - * 判断加急数量是否大于申请数量 - */ - handleUaAndCount: function (urgentAmount,count) { - if (count < urgentAmount){ - showResult("加急数量不能大于申请数量!"); - return true; - } - return false; - }, - /** - * 判断消毒物品不拆包加急数量是否大于1 - */ - handleApplyEntireTousse: function (tousseType,isApplyEntireTousse,urgentAmount) { - if (tousseType == '消毒物品' && isApplyEntireTousse == '否' && urgentAmount > 1){ - showResult("消毒物品拆包清洗加急数量不能大于1!"); - return true; - } - return false; - } - } - var form = new top.Ext4.form.Panel({ id : 'recyclingApplicationForm', frame : true, @@ -1565,7 +1543,89 @@ } } + /** + * 加急数量的的工具类. + */ +var handleUrgentAmount = { + /** + * 判断加急数量是否大于申请数量 + * @param urgentAmount 加急数量 + * @param count 申请数量 + */ + handleUaAndCount: function (urgentAmount, count) { + if (count < urgentAmount){ + showResult("加急数量不能大于申请数量!"); + return true; + } + return false; + }, + /** + * 判断拆包申请的消毒物品的加急数量是否大于1 + * @param tousseType 器械包类型 + * @param isApplyEntireTousse 申请数量 + * @param urgentAmount 加急数量 + */ + handleApplyEntireTousse: function (tousseType, isApplyEntireTousse, urgentAmount) { + if (tousseType == '消毒物品' && isApplyEntireTousse == '否' && urgentAmount > 1){ + showResult("消毒物品拆包清洗加急数量不能大于1!"); + return true; + } + return false; + } +} + +/** + * 校验在申领模板中直接输入一次性物品的申请数量(即:1、申请的数量不能大于库存(这个有配置项) 2、申请数量必须为最小申请数量的倍数 3、申请数量大于最大申请数量事需要提示). + * @param context + * return 如果验证不通过则返回true,反之返回false + */ +function checkDisposableGoodsAmountEvent(context) { + var record = context.record; + var minApplyAmount = record.get("minApplyAmount"); + var maxApplyAmount = record.get("maxApplyAmount"); + var count = record.get('count'); + if ("urgentAmount" != context.field || !count) { + var tousseDefinitionID = record.get('tousseDefinitionID'); + var storage = 0; + //如果配置了该选项,直接从服务器找 + if (sstsConfig.storageUseStorageSubtractWaitDeliver){ + storage = findStorageByDisposeIdAndHandleDepartCode(tousseDefinitionID); + } else { + storage = record.get("storage"); + if (storage == 0) { + //如果库存是0,则从store中去找,如果找不到(因为分页了),则从服务器中找 + var findRecord = null; + comboGoodsStore.filterBy(function (re) { + if (re.get('id') == tousseDefinitionID && re.get('tousseType') == '一次性物品') { + findRecord = re; + return false; + } + }); + //如果找不到,则从服务器取找 + storage = Ext.isEmpty(findRecord) ? findStorageByDisposeIdAndHandleDepartCode(tousseDefinitionID) : findRecord.get('amount');; + } + } + var checkCount = getMiddleAmount(count); + if (parseInt(checkCount, 10) > storage && !allowApplyDisposableGoodsWhenUnderstock) { + showResult("申请数量不能大于库存数量!"); + record.set("count", context.originalValue); + return true; + } + if (!isValidDiposableAmount(minApplyAmount, checkCount)) { + showResult("该一次性物品最小申请数量为" + minApplyAmount + ",所填数量必须是" + minApplyAmount + "的倍数。"); + record.set("count", context.originalValue); + return true; + } + if (!isUndefinedOrNullOrEmpty(maxApplyAmount) && maxApplyAmount < checkCount) { + top.Ext4.Msg.alert("提示消息", "申请数量大于最大可申请数量"); + } + } + return false; +} + + +/** * 转换records,因为Ext4的combo的select事件有点小bug,第二个参数records在API写的是一个数组类型,但是在某种情况下他是一个对象(即:手动输入一个Store存在的数据时),因此写下此函数,转换一下 * @param records * @returns Index: ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsApplicationView.js =================================================================== diff -u -r20397 -r20408 --- ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsApplicationView.js (.../goodsApplicationView.js) (revision 20397) +++ ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsApplicationView.js (.../goodsApplicationView.js) (revision 20408) @@ -1287,54 +1287,6 @@ } /** - * 校验一次性物品的申请数量(即:1、申请的数量不能大于库存(这个有配置项) 2、申请数量必须为最小申请数量的倍数 3、申请数量大于最大申请数量事需要提示). - * @param context - */ -function handleAmountEvent(context) { - var record = context.record; - var minApplyAmount = record.get("minApplyAmount"); - var maxApplyAmount = record.get("maxApplyAmount"); - if ("urgentAmount" != context.field) { - var tousseDefinitionID = record.get('tousseDefinitionID'); - var storage = 0; - //如果配置了该选项,直接从服务器找 - if (sstsConfig.storageUseStorageSubtractWaitDeliver){ - storage = findStorageByDisposeIdAndHandleDepartCode(tousseDefinitionID); - } - else { - storage = record.get("storage"); - if (storage == 0) { - //如果库存是0,则从store中去找,如果找不到(因为分页了),则从服务器中找 - var findRecord = null; - comboGoodsStore.filterBy(function (re) { - if (re.get('id') == tousseDefinitionID && re.get('tousseType') == '一次性物品') { - findRecord = re; - return false; - } - }); - //如果找不到,则从服务器取找 - storage = Ext.isEmpty(findRecord) ? findStorageByDisposeIdAndHandleDepartCode(tousseDefinitionID) : findRecord.get('amount');; - } - } - var checkCount = getMiddleAmount(context.value); - if (parseInt(checkCount, 10) > storage && !allowApplyDisposableGoodsWhenUnderstock) { - showResult("申请数量不能大于库存数量!"); - resetCountAndPrice(record); - return true; - } - if (!isValidDiposableAmount(minApplyAmount, checkCount)) { - showResult("该一次性物品最小申请数量为" + minApplyAmount + ",所填数量必须是" + minApplyAmount + "的倍数。"); - resetCountAndPrice(record); - return true; - } - if (!isUndefinedOrNullOrEmpty(maxApplyAmount) && maxApplyAmount < checkCount) { - top.Ext4.Msg.alert("提示消息", "申请数量大于最大可申请数量"); - } - } - return false; -} - -/** * 获取一次性物品总价格 */ function getDisposableGoodTotalAmount(store){ @@ -1346,15 +1298,15 @@ return totalPrice; } -/** - * 把数量设置成空,总价设置成0,一次性物品总价格设置成0.00 - * @param record 该行的记录 - */ -function resetCountAndPrice(record) { - record.set("count", ""); - record.set("totalPrice", 0); - top.Ext4.getCmp('disposableGoodTotalAmount').setValue("0.00"); -} +///** +// * 把数量设置成空,总价设置成0,一次性物品总价格设置成0.00 +// * @param record 该行的记录 +// */ +//function resetCountAndPrice(record) { +// record.set("count", ""); +// record.set("totalPrice", 0); +// top.Ext4.getCmp('disposableGoodTotalAmount').setValue("0.00"); +//} /** * 设置一次性物品总价格.