Index: ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsApplicationForm.js =================================================================== diff -u -r27580 -r27584 --- ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsApplicationForm.js (.../goodsApplicationForm.js) (revision 27580) +++ ssts-web/src/main/webapp/disinfectsystem/recyclingApplication/goodsApplicationForm.js (.../goodsApplicationForm.js) (revision 27584) @@ -582,6 +582,29 @@ } } }]; + //求两个数字的公倍数 + var gcd = function(a,b){ + var minNum = Math.min(a,b),maxNum = Math.max(a,b),vper=0; + if(a ===0 || b===0){ + return maxNum; + } + for(var i=1;i<=maxNum;i++){ + vper = minNum * i; + if(vper % maxNum === 0){ + return vper; + break; + } + } + } + //求一个数组的最小公倍数 + var lcm = function(arr){ + var onum = 0,len = arr.length,midNum = 0; + for(var i=0;i 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 length = storeData.length; curSelectedGoods = null; @@ -625,7 +667,6 @@ 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); - afterAddItem(true); } } } @@ -929,7 +970,149 @@ //阻止按Tab,因为这里的CellEditing按了tab会有bug event.stopEvent(); } - } + }, + blur:function(field, event, eOpts){ + var data = currentRecord.data; + + if(field.lastValue == null){ + return; + } + + if(field.lastValue == field.focusLastValue){ + 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 { + 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); + }, 100); + }else { + if(data.count == 0){ + currentRecord.set('count',field.focusLastValue); + var msgBox = new top.Ext4.create('Ext.window.MessageBox', { + width : 500, + height : 200 + }); + msgBox.alert('提示信息', data.name+'被其他物品绑定,数量不能修改为0!'); + return; + } + + var result = JSON.parse(responseText); + if(result.data.length > 1){ + var storeData = leftTemplateStore.getRootNode().childNodes; + var newResultArray = []; + var k = 0; + var nameStr = ''; + for(var i=0;i 1){ + currentRecord.set('count',field.focusLastValue); + var msgBox = new top.Ext4.create('Ext.window.MessageBox', { + width : 500, + height : 200 + }); + msgBox.alert('提示信息', data.name+'同时被多个物品('+nameStr+')绑定,不允许修改'+data.name+'的数量!'); + }else { + setTimeout(function() { + updateCount(data,field); + }, 100); + } + }else { + if(result.data[0].bidirectional == true){ + setTimeout(function() { + updateCount(data,field); + }, 100); + }else { + currentRecord.set('count',field.focusLastValue); + var msgBox = new top.Ext4.create('Ext.window.MessageBox', { + width : 500, + height : 200 + }); + msgBox.alert('提示信息', data.name+'被物品('+result.data[0].name+')单向绑定,不允许修改'+data.name+'的数量!'); + } + } + } + } + }); + } + }, + 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