Index: ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsApplicationForm.js =================================================================== diff -u -r27584 -r27585 --- ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsApplicationForm.js (.../goodsApplicationForm.js) (revision 27584) +++ ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsApplicationForm.js (.../goodsApplicationForm.js) (revision 27585) @@ -605,7 +605,7 @@ } return midNum; } - var updateCount = function(data,field){ + var updateCount = function(data,field,type){ var params = { bindCount: data.count || '', goodId: data.tousseDefinitionID, @@ -615,7 +615,8 @@ settleAccountsDepartCoding: top.Ext4.getCmp('settleAccountsDepartCoding').getValue(), urgentAmount:data.urgentAmount, urgentLevel:data.urgentLevel, - urgentLevelId:data.urgentLevelId + urgentLevelId:data.urgentLevelId, + returnGoodsWithCountZero:true } if (params.bindCount && params.goodId) { Ext.Ajax.request({ @@ -629,6 +630,10 @@ if (result.success) { var records = result.data; var lcmArr = []; + var isMaxApplyAmountTrue = false; + var isMinApplyAmountTrue = false; + var showName = ''; + var showMinApplyAmount = 0; for(var i=0,j=0;i maxApplyAmount){ + isMaxApplyAmountTrue = true; + showName = records[i].name; + showMaxApplyAmount = maxApplyAmount; + } } - if(lcm(lcmArr) > 0 && (params.bindCount%lcm(lcmArr)) !== 0){ + + if(isMinApplyAmountTrue && showMinApplyAmount > 0){ currentRecord.set('count',field.focusLastValue); var msgBox = new top.Ext4.create('Ext.window.MessageBox', { width : 500, height : 200 }); + msgBox.alert('提示信息', showName+'的数量必须为最小申请数量('+showMinApplyAmount+')的倍数'); + return; + } + + if(isMaxApplyAmountTrue && showMaxApplyAmount > 0){ + currentRecord.set('count',field.focusLastValue); + var msgBox = new top.Ext4.create('Ext.window.MessageBox', { + width : 500, + height : 200 + }); + msgBox.alert('提示信息', showName+'的数量必须小于最大申请数量('+showMaxApplyAmount+')'); + return; + } + + if(lcmArr.length > 0 && lcm(lcmArr) > 0 && (params.bindCount%lcm(lcmArr)) !== 0){ + currentRecord.set('count',field.focusLastValue); + var msgBox = new top.Ext4.create('Ext.window.MessageBox', { + width : 500, + height : 200 + }); msgBox.alert('提示信息', params.goodName+'的数量必须为'+lcm(lcmArr)+'的倍数'); return; } - var storeData = leftTemplateStore.getRootNode().childNodes; + var storeData; + var diposable; + if(type == 'left'){ + storeData = leftTemplateStore.getRootNode().childNodes; + diposable = '否'; + }else { + storeData = rightTemplateStore.getRootNode().childNodes; + diposable = '是'; + } var length = storeData.length; curSelectedGoods = null; var idsArr = []; @@ -658,15 +707,22 @@ var data = records[i]; if(idsArr.indexOf(data.id) >= 0){ var idsIndex = idsArr.indexOf(data.id); - var oldValue = field.oldValue || 0; - var sumCount = storeData[idsIndex].data.count - oldValue; - var newCount = sumCount+records[i].count; - storeData[idsIndex].set('count',newCount); + var lastValue = field.lastValue || 0; + var focusLastValue = field.focusLastValue || 0; + if(records[i].goodType == 'MAIN'){ + var newCount = records[i].count; + storeData[idsIndex].set('count',newCount); + }else { + var count = records[i].secondaryCount; + var sumCount = storeData[idsIndex].data.count - (focusLastValue*count); + var newCount = sumCount+records[i].count; + storeData[idsIndex].set('count',newCount); + } }else { curSelectedGoods = data; var materials = data.materials || ''; materials = (materials == '')?'':JSON.stringify(materials); - addItems(data.id,data.name,data.count,'否',data.isApplyEntireTousse,'',data.price,null,null,data.tousseType,materials,data.unit,null,null,null,null,null,null,{},data.expressInvoice); + addItems(data.id,data.name,data.count,diposable,data.isApplyEntireTousse,data.originalPrice,data.price,data.externalCode,data.amount,data.tousseType,materials,data.unit,data.packageSpec,data.minApplyAmount,data.maxApplyAmount,data.urgentAmount,data.urgentLevel,data.urgentLevelId,{},data.expressInvoice); } } } @@ -704,7 +760,6 @@ }, blur:function(field, event, eOpts){ var data = currentRecord.data; - if(field.lastValue == null){ return; } @@ -713,22 +768,15 @@ return; } - if(field.lastValue == 0){ - currentRecord.set('count',field.focusLastValue); - var msgBox = new top.Ext4.create('Ext.window.MessageBox', { - width : 500, - height : 200 - }); - msgBox.alert('提示信息', '数量不能修改为0!'); - }else { + if(field.lastValue > 0){ Ext.Ajax.request({ url : WWWROOT + '/disinfectSystem/baseData/tousseDefinitionAction!getMainBindGoods.do?', params : {goodId : data.tousseDefinitionID}, success : function(response, options) { var responseText = response.responseText || ''; if(responseText == ''){ setTimeout(function() { - updateCount(data,field); + updateCount(data,field,'left'); }, 100); }else { if(data.count == 0){ @@ -766,13 +814,13 @@ msgBox.alert('提示信息', data.name+'同时被多个物品('+nameStr+')绑定,不允许修改'+data.name+'的数量!'); }else { setTimeout(function() { - updateCount(data,field); + updateCount(data,field,'left'); }, 100); } }else { if(result.data[0].bidirectional == true){ setTimeout(function() { - updateCount(data,field); + updateCount(data,field,'left'); }, 100); }else { currentRecord.set('count',field.focusLastValue); @@ -792,57 +840,6 @@ var data = currentRecord.data; var focusLastValue = field.lastValue || ''; field.focusLastValue = focusLastValue; - - setTimeout(function() { - var params = { - bindCount: data.count || '', - goodId: data.tousseDefinitionID, - goodName: data.name, - goodType: data.tousseType, - handleDepartCode: top.Ext4.getCmp('handleDepartCoding').getValue(), - settleAccountsDepartCoding: top.Ext4.getCmp('settleAccountsDepartCoding').getValue(), - urgentAmount:data.urgentAmount, - urgentLevel:data.urgentLevel, - urgentLevelId:data.urgentLevelId - } - if (params.bindCount && params.goodId) { - Ext.Ajax.request({ - url: WWWROOT + '/disinfectSystem/baseData/tousseDefinitionAction!getBindGoods.do', - params: params, - timeout: 600000, - method: 'POST', - success: function (response, options) { - try { - var result = Ext.decode(response.responseText); - - if (!isUndefinedOrNullOrEmpty(result)) { - if (result.success) { - var records = result.data; - - if (records.length > 0) { - var storeData = leftTemplateStore.getRootNode().childNodes; - var length = storeData.length; - - for(var i=0;i 0) { Ext.Ajax.request({ url : WWWROOT + '/disinfectSystem/baseData/tousseDefinitionAction!getMainBindGoods.do?', params : {goodId : data.tousseDefinitionID}, success : function(response, options) { var responseText = response.responseText || ''; if(responseText == ''){ setTimeout(function() { - updateCount(data,field); + updateCount(data,field,'right'); }, 100); }else { if(data.count == 0){ @@ -1035,13 +1025,13 @@ msgBox.alert('提示信息', data.name+'同时被多个物品('+nameStr+')绑定,不允许修改'+data.name+'的数量!'); }else { setTimeout(function() { - updateCount(data,field); + updateCount(data,field,'right'); }, 100); } }else { if(result.data[0].bidirectional == true){ setTimeout(function() { - updateCount(data,field); + updateCount(data,field,'right'); }, 100); }else { currentRecord.set('count',field.focusLastValue); @@ -1058,60 +1048,8 @@ } }, focus:function(field, event, eOpts){ - var data = currentRecord.data; var focusLastValue = field.lastValue || ''; field.focusLastValue = focusLastValue; - - setTimeout(function() { - var params = { - bindCount: data.count || '', - goodId: data.tousseDefinitionID, - goodName: data.name, - goodType: data.tousseType, - handleDepartCode: top.Ext4.getCmp('handleDepartCoding').getValue(), - settleAccountsDepartCoding: top.Ext4.getCmp('settleAccountsDepartCoding').getValue(), - urgentAmount:data.urgentAmount, - urgentLevel:data.urgentLevel, - urgentLevelId:data.urgentLevelId - } - if (params.bindCount && params.goodId) { - Ext.Ajax.request({ - url: WWWROOT + '/disinfectSystem/baseData/tousseDefinitionAction!getBindGoods.do', - params: params, - timeout: 600000, - method: 'POST', - success: function (response, options) { - try { - var result = Ext.decode(response.responseText); - - if (!isUndefinedOrNullOrEmpty(result)) { - if (result.success) { - var records = result.data; - - if (records.length > 0) { - var storeData = leftTemplateStore.getRootNode().childNodes; - var length = storeData.length; - - for(var i=0;i