var commonGridObj_fee; var addCount = 0; var pressRecord; function $(id){ return document.getElementById(id); } function refreshList(){ createGrid(); } function createGrid(){ //header var headerArgs_fee = new Array("","单价","备注","创建人","创建时间"); //width var widthArgs_fee= new Array("40","100","100","100","100"); //column align var colAlignArgs_fee = new Array("center","center","center","center","center"); //column sort var colSortArgs_fee = new Array("na","str","str","str","str"); //column type var colTypeArgs_fee = new Array("ch","ed","ed","ro","ro"); commonGridObj_fee = new TGridCommon("mygrid_container_fee","form1",headerArgs_fee,widthArgs_fee,colAlignArgs_fee,colSortArgs_fee,colTypeArgs_fee); commonGridObj_fee.setResponseUrl("../SeaiFee/WmsRateGridSource.aspx"); var templateID = $("h_templateid").value; commonGridObj_fee.setRequest("../SeaiFee/WmsRateGridSource.aspx?handle=wmsfeecodelist&show_page=15&cur_page=1&bsno="+escape($("h_bsno").value)+"&uid="+commonGridObj_fee.newGuid()); commonGridObj_fee.setSourceType("json"); commonGridObj_fee.setSkin("xp"); commonGridObj_fee.setImageUrl("../images/"); commonGridObj_fee.initGrid(); commonGridObj_fee.bind(); // commonGridObj_fee.initPageByGID("wmsfeecodelist","&cus="+$("h_cusname").value); commonGridObj_fee.getGridObj().enableEditEvents(true,false,true); commonGridObj_fee.getGridObj().enableKeyboardSupport(true); var pushVal = ""; var pressRecord = ""; var pressRowIndex = -1; var pressCellIndex = -1; var pressCount = 0; var isExchange = false; var shiftCount = 0; var isDelete = 0; var flagFilter = 0; var flagTab = 0; var flagEnter = 0; var flagDelete = 0; //手动编写Grid控件编辑事件,由于免费控件没有提供完整的编辑判断功能,现特此做更改 commonGridObj_fee.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){ var newCheckValue = false; //初始化状态 if(stage == 0){ return true; } var txtEdit; if(stage == 1){ for(i = 0; i < document.all.length; i++){ if(document.all(i).tagName == "TEXTAREA"){ txtEdit = document.all(i); txtEdit.focus(); txtEdit.select(); break; } } } //如果编辑结束 if(stage == 2){ if(oValue==null || oValue=="" || oValue=="0"){ return true; } if( cInd == 1 ){ commonGridObj_fee.getGridObj().cellById(rId,cInd).setValue(nValue); } else if(cInd==2) { commonGridObj_fee.getGridObj().cellById(rId,cInd).setValue(nValue); } } });//end onEditCell //键盘操作事件+ commonGridObj_fee.getGridObj().attachEvent("onKeyPress", function(code,cFlag,sFlag){ //onKeyPress begin //获取当前RowID var selectedId = commonGridObj_fee.getGridObj().getSelectedRowId(); //获取当前RowIndex var rowIndex = commonGridObj_fee.getGridObj().getRowIndex(selectedId); //获取当前CellIndex(ind) var ind = commonGridObj_fee.getGridObj().getSelectedCellIndex(); //触发操作事件前获取单元值 var oldVal = commonGridObj_fee.getGridObj().cellByIndex(rowIndex,ind).getValue(); //获取编辑单元 var txtEdit; for(i = 0; i < document.all.length; i++){ if(document.all(i).tagName == "TEXTAREA"){ txtEdit = document.all(i); break; } } //enter 键 if(code == 13){ if(ind == 1 || ind == 2 ){ if(ind==1){ commonGridObj_fee.getGridObj().cellByIndex(rowIndex,ind).setValue(oldVal); }else if(ind==2){ commonGridObj_fee.getGridObj().cellByIndex(rowIndex,ind).setValue(oldVal); } return true; } }//enter 键 end //Tab键 if(code == 9){ //code9 begin setTimeout(function(){ if(ind==1){ commonGridObj_fee.getGridObj().editStop(true); commonGridObj_fee.getGridObj().cellByIndex(rowIndex,ind).setValue(oldVal); commonGridObj_fee.getGridObj().selectCell(rowIndex,2,true,true); commonGridObj_fee.getGridObj().editCell(); } else if(ind==2){ commonGridObj_fee.getGridObj().editStop(true); commonGridObj_fee.getGridObj().cellByIndex(rowIndex,ind).setValue(oldVal); commonGridObj_fee.getGridObj().selectCell(rowIndex,1,true,true); commonGridObj_fee.getGridObj().editCell(); } },150); } //cdoe9 end //左箭头 if(code == 37){ //code37 begin setTimeout(function(){ if(ind == 1){ commonGridObj_fee.getGridObj().editStop(true); commonGridObj_fee.getGridObj().cellByIndex(rowIndex,ind).setValue(oldVal); commonGridObj_fee.getGridObj().selectCell(rowIndex,2,true,true); commonGridObj_fee.getGridObj().editCell(); } else if(ind == 2){ commonGridObj_fee.getGridObj().cellByIndex(rowIndex,ind).setValue(oldVal); commonGridObj_fee.getGridObj().selectCell(rowIndex,1,true,true); commonGridObj_fee.getGridObj().editCell(); } },150); }//code37 end //右箭头 if(code == 39){ //code39 begin setTimeout(function(){ if(ind == 1){ commonGridObj_fee.getGridObj().editStop(true); commonGridObj_fee.getGridObj().cellByIndex(rowIndex,ind).setValue(oldVal); commonGridObj_fee.getGridObj().selectCell(rowIndex,2,true,true); commonGridObj_fee.getGridObj().editCell(); } else if(ind == 2){ commonGridObj_fee.getGridObj().cellByIndex(rowIndex,ind).setValue(oldVal); commonGridObj_fee.getGridObj().selectCell(rowIndex,1,true,true); commonGridObj_fee.getGridObj().editCell(); } },150); }//code39 end //键盘输入数字 if(code >= 48 && code <= 57|| code >= 96 && code <= 105 || code == 188|| code == 110|| code == 190 || code == 229){ if( ind == 1 || ind == 2){ return true; } } if (code >= 65 && code <= 90) {//如果是输入英文字符 if( ind == 1 || ind==2 ){ return true; } } if(code == 8){ //code8 begin if(ind == 1 || ind == 2 ){ var start=0; var end=0; if(document.selection){ var range = document.selection.createRange(); if(range.parentElement().className == txtEdit.className){ var range_all = document.body.createTextRange(); range_all.moveToElementText(txtEdit); for (start=0; range_all.compareEndPoints("StartToStart", range) < 0; start++){ range_all.moveStart('character', 1); } for (var i = 0; i <= start; i ++){ if (txtEdit.value.charAt(i) == '\n') start++; } var range_all = document.body.createTextRange(); range_all.moveToElementText(txtEdit); for (end = 0; range_all.compareEndPoints('StartToEnd', range) < 0; end ++) range_all.moveStart('character', 1); for (var i = 0; i <= end; i ++){ if (txtEdit.value.charAt(i) == '\n') end ++; } } } // alert(start);alert(end); //未选中多个字符 if(start == end){ if(start != 0){ if(pressRecord!=null){ var firstVal = pressRecord.substring(0,start - 1); var endVal = pressRecord.substring(start + 1,txtEdit.value.length - 1); pressRecord = firstVal; } } } //选中多个字符 if(start != end){ if(pressRecord!=null){ var firstVal = pressRecord.substring(0,start); var endVal = pressRecord.substring(end - 1,txtEdit.value.length - 1); pressRecord = firstVal+endVal; } } setTimeout(function(){ if(pressRecord!=null){ if(pressRecord.trim().length > 0){ var combo = commonGridObj_fee.getCustomCombo(selectedId,ind); var comboArg = combo.getKeys(); var count = 0; for(var i = 0;i 0){ for(var i = 0;i < jsonCacheObj.drate.length;i++){ obj.put(jsonCacheObj.drate[i].code,jsonCacheObj.drate[i].code); } } } function setFeeLbCombo(obj){//FeeLbCombo obj.put("收费","收费"); obj.put("付费","付费"); } function setCustomerCombo(obj){ var customerInfo = ""; if($("h_custcache").value.trim() != ""){ customerInfo = $("h_custcache").value.trim(); }else{ var url = "../FeeCodes/CRMClientInfo.aspx?handle=client&uid="+newGuid(); var loader = dhtmlxAjax.getSync(url); customerInfo = loader.xmlDoc.responseText; } var jsonCacheObj = eval('(' + customerInfo + ')'); if(jsonCacheObj.customer.length > 0){ for(var i = 0;i < jsonCacheObj.customer.length;i++){ obj.put(jsonCacheObj.customer[i].name,jsonCacheObj.customer[i].code + ' '+jsonCacheObj.customer[i].name); } } } function setFeeNameCombo(obj){ var feeCodeInfo = ""; if($("h_feenamecache").value.trim() != ""){ feeCodeInfo = $("h_feenamecache").value.trim(); }else{ var url = "../FeeCodes/FeeCodeService.aspx?handle=feecode&uid="+newGuid(); var loader = dhtmlxAjax.getSync(url); feeCodeInfo = loader.xmlDoc.responseText; } var jsonCacheObj = eval('(' + feeCodeInfo + ')'); if(jsonCacheObj.feecode.length > 0){ for(var i = 0;i < jsonCacheObj.feecode.length;i++){ obj.put(jsonCacheObj.feecode[i].name,jsonCacheObj.feecode[i].code); } } } function setUnitCombo(obj) { obj.put("单票", "单票"); obj.put("重量", "重量"); //obj.put("净重", "净重"); obj.put("尺码", "尺码"); obj.put("TEU", "TEU"); obj.put("箱型", "箱型"); obj.put("CBM", "CBM"); obj.put("BILL", "BILL"); var feeCodeCtnObj = null; var url = "../FeeCodes/FeeCodeCtnService.aspx?handle=getallctn&uid="+commonGridObj_fee.newGuid(); var loader = dhtmlxAjax.getSync(url); var ctnInfo = loader.xmlDoc.responseText; if(ctnInfo.trim() != ""){ feeCodeCtnObj = eval('(' + ctnInfo + ')'); if(feeCodeCtnObj.ctns.length > 0){ for(var i=0;i 0){ var jsonCacheObj = null; for(var i=0;i