var mygrid_recv; var page_count = 5; var column_count; var jsonFeeObj; var changeCount = 0; var authoriyStatus; var changeFeeRecvCount = 0; var newFeeRecvCount = 0; var recv_menu; var linkgid = ""; var strkeytype = ""; var cknum=0;//出库数量 var pressRecord; var quantityVal; var quantityObj; function $(id){ return document.getElementById(id); } function document.onkeydown(){ if(event.keyCode == 8){ if(document.selection){ var range = document.selection.createRange();; if(range.parentElement().name == null){ return false; }else{ return true; } } } } function initGrid(){ doInitRecvGrid(); } function doInitRecvGrid(){ mygrid_recv = new dhtmlXGridObject('mygrid_container_recv'); mygrid_recv.setImagePath("../images/"); mygrid_recv.setSkin("xp"); mygrid_recv.setHeader(",值"); mygrid_recv.setInitWidths("40,400"); mygrid_recv.setColAlign("center,center"); mygrid_recv.setColSorting("na,str"); mygrid_recv.setColTypes("ch,ed"); // strkeytype = $("ddlKEYTYPE").value; //判断委托单有无费用 var urlVal = "CrmKeyCodeSetGridSource.aspx?type=1&handle=exist&keytype=" + escape(strkeytype) + "&val=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; loader = null; if(parseInt(loadVal) == 1){ //获取海运费及附加费信息,初始化grid mygrid_recv.loadXML("CrmKeyCodeSetGridSource.aspx?type=1&handle=init&keytype=" + escape(strkeytype) + "&val=" + newGuid(), function() { ReShowLabel(mygrid_recv); }); } mygrid_recv.init(); mygrid_recv.enableEditEvents(true,false,true); mygrid_recv.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控件编辑事件,由于免费控件没有提供完整的编辑判断功能,现特此做更改 mygrid_recv.attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){ var newCheckValue = false; //初始化状态 if (stage == 0) { return true; } if(stage == 1){ var selectedId = mygrid_recv.getSelectedRowId(); var rowIndex = mygrid_recv.getRowIndex(selectedId); for(var i = 0; i < document.all.length; i++){ if(document.all(i).tagName == "TEXTAREA" && document.all(i).id != "tbREMARK"){ txtEdit = document.all(i); txtEdit.focus(); txtEdit.select(); break; } } } //如果编辑结束 if(stage == 2){ return true; } }); //键盘操作事件 mygrid_recv.attachEvent("onKeyPress", function(code, cFlag, sFlag) { //onKeyPress begin //获取当前RowID var selectedId = mygrid_recv.getSelectedRowId(); //获取当前RowIndex var rowIndex = mygrid_recv.getRowIndex(selectedId); //获取当前CellIndex(ind) var ind = mygrid_recv.getSelectedCellIndex(); //触发操作事件前获取单元值 var oldVal = mygrid_recv.cellByIndex(rowIndex, ind).getValue(); //获取编辑单元 var txtEdit; for (i = 0; i < document.all.length; i++) { if (document.all(i).tagName == "TEXTAREA" && document.all(i).id != "tbREMARK") { txtEdit = document.all(i); break; } } if (code == 13) { //Enter键 return true; } //Tab键 if (code == 9) { //code9 begin var colCount = mygrid_recv.getColumnsNum(); var rowCount = mygrid_recv.getRowsNum(); if (ind < colCount) { mygrid_recv.selectCell(rowIndex, ind + 1, true, true); mygrid_recv.editCell(); if (ind == colCount - 1) { if (rowIndex < rowCount) { mygrid_recv.editStop(true); mygrid_recv.clearSelection(); mygrid_recv.selectCell(rowIndex + 1, 1, true, true); mygrid_recv.editCell(); } else { return; } } else { return; } } //cdoe9 end } if ((code >= 65 && code <= 90) || (code >= 48 && code <= 57) || (code >= 96 && code <= 105)) {//如果是输入英文字符 return true; } //delete if (code == 8) { return true; } //向下方向键 if (code == 40) { //code40 begin var rowCount = mygrid_recv.getRowsNum(); mygrid_recv.clearSelection(); mygrid_recv.editStop(); if (rowIndex == (rowCount - 1)) { addRecvRow(); } else { mygrid_recv.selectCell(rowIndex + 1, 1, true, true); mygrid_recv.editCell(); } //code40 end } //向上箭头 if (code == 38) { //code38 begin if (rowIndex > 0) { mygrid_recv.clearSelection(); mygrid_recv.editStop(); mygrid_recv.selectCell(rowIndex - 1, 1, true, true); mygrid_recv.editCell(); var rowfeename = mygrid_recv.cellByIndex(rowIndex,1).getValue(); if (rowfeename == 0) { mygrid_recv.deleteRow(selectedId) newFeeRecvCount--; } } //code38 end } //左箭头 if (code == 37) { //code37 begin mygrid_recv.clearSelection(); mygrid_recv.editStop(); mygrid_recv.editCell(); return true; } //code37 end //右箭头 if (code == 39) { //code39 begin mygrid_recv.clearSelection(); mygrid_recv.editStop(); mygrid_recv.editCell(); return true; } //code39 end //键盘输入数字code >= 48 && code <= 57|| code >= 96 && code <= 105 || if (code >= 48 && code <= 57 || code >= 96 && code <= 105 || code == 188 || code == 110 || code == 190 || code == 229) { return true; } if (code >= 65 && code <= 90) {//如果是输入英文字符 return true; } if (code == 189 || code == 109) { return true; } //onKeyPress end }); setTimeout(function(){ },460); } function isObjNaN(Obj){ if(Obj.toString().toLowerCase() == "nan"){ return 0; }else{ return Obj; } } function addRecvRow(){ var newId = newGuid(); //获取插入新纪录位置 var rowCount = mygrid_recv.getRowsNum(); mygrid_recv.addRow(newId, [0, ""], rowCount); mygrid_recv.clearSelection(); setTimeout(function(){ mygrid_recv.editStop(true); mygrid_recv.selectCell(mygrid_recv.getRowIndex(newId),1,true,true); mygrid_recv.editCell(); },150); } function deleteRecvRow(){ var checked = mygrid_recv.getCheckedRows(0); //所有选中的grid的id编号 if(checked.length > 0){ if(window.confirm("您确定要将所选费用删除")){ var urlVal = "CrmKeyCodeSetGridSource.aspx?gids=" + checked + "&handle=delete&no=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; if (loadVal != 1) { alert("操作出错!"); } else { refreshRecv(); } } }else{ alert("未选中要操作的费用项"); } return; } //保存海运费及附加费 function saveRecvChange(){ var jsonFeeObj = null; for(var i=0;i 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } if(opStatus == 1){ //查看是否有被选中的费用项 var iCount = 0; var recvArg = new Array(); for(var i=0;i 0){ var delCount = 0; if(recvArg.length > 0){ if(window.confirm("您确定要将所选海运费及附加费放弃修改")){ while(delCount < recvArg.length){ var rowIndex = mygrid_recv.getRowIndex(recvArg[delCount]); var tid = mygrid_recv.cellByIndex(rowIndex,19).getValue(); var feeName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); var cusName = mygrid_recv.cellByIndex(rowIndex,3).getValue(); //恢复委托费用:通过费用ch_fee.gid获取ch_fee信息,返回字符串 var urlVal = "../Shipping/FeeService.aspx?gid="+recvArg[delCount]+"&handle=recover&no="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; if(!IsNum(loadVal)){ var recoverArg = new Array(); recoverArg = loadVal.split(","); var selRowIndex = mygrid_recv.getRowIndex(recvArg[delCount]); var colCount = mygrid_recv.getColumnsNum(); for(var i=2;i= 1){ jsonCacheObj.templates.splice(i,1); $("h_cachetemplate").value = JSON.stringify(jsonCacheObj); mygrid_recv.deleteRow(recvArg[delCount]); iSuccess++; tempCount++; }else{ iFailure++; } break; } } if(tempCount == 0){ mygrid_recv.deleteRow(recvArg[delCount]); iSuccess++; } }else if(cacheHistory != ""){ var jsonCacheObj = null; jsonCacheObj = eval('(' + cacheHistory + ')'); var tempCount = 0; for(var i=0;i= 1){ jsonCacheObj.history.splice(i,1); $("h_cachehistory").value = JSON.stringify(jsonCacheObj); mygrid_recv.deleteRow(recvArg[delCount]); iSuccess++; tempCount++; }else{ iFailure++; } break; } } if(tempCount == 0){ mygrid_recv.deleteRow(recvArg[delCount]); iSuccess++; } }else{ mygrid_recv.deleteRow(recvArg[delCount]); iSuccess++; } } delCount++; } } ReShowLabel(mygrid_recv); alert("提交放弃修改海运费及附加费 共 "+delCount+" 条 成功 "+iSuccess+" 条 失败 "+iFailure+" 条"); } }else{ alert("未选中要操作的费用项"); } }else{ alert("委托已退载,费用修改费用"); return; } } function print_recv(){ printMessageBox(event,1); } //输出money function outputMoney(number) { number= number.replace(/\,/g,""); if (isNaN(number)||number=="") return ""; number = Math.round( number*10000) /10000; if (number < 0) { var sdf = '-' + outputDollars(Math.floor(Math.abs(number) - 0) + '') + outputCents(Math.abs(number) - 0); return '-' + outputDollars(Math.floor(Math.abs(number) - 0) + '') + outputCents(Math.abs(number) - 0); } else { var sdf = outputDollars(Math.floor(number - 0) + '') + outputCents(number - 0); return outputDollars(Math.floor(number - 0) + '') + outputCents(number - 0); } } //输出美元 function outputDollars(number) { if (number.length<= 3) return (number == '' ? '0' : number); else { var mod = number.length%3; var output = (mod == 0 ? '' : (number.substring(0,mod))); for (i=0 ; i< Math.floor(number.length/3) ; i++) { if ((mod ==0) && (i ==0)) output+= number.substring(mod+3*i,mod+3*i+3); else output+= ',' + number.substring(mod+3*i,mod+3*i+3); } return (output); } } function outputCents(amount) { var ls = ""; amount = Math.round(((amount) - Math.floor(amount)) * 10000); if (amount < 10) { ls = '.000' + amount; } else if (amount < 100) { ls = '.00' + amount; } else if (amount < 1000) { ls = '.0' + amount; } else if (amount < 10000) { ls = '.' + amount; } //return (amount<10 ? '.000' + amount : '.' + amount); return ls; } //获取GUID function newGuid() { var guid = ""; for (var i = 1; i <= 32; i++){ var n = Math.floor(Math.random()*16.0).toString(16); guid += n; if((i==8)||(i==12)||(i==16)||(i==20)) guid += "-"; } return guid.toUpperCase(); } //对话框 function dialog() { // alert("打开dialog"); this.width=450; this.height=360; this.title_height=20; this.html=''; this.title=''; var self = this; var bgObj,msgObj,titleObj; this.close=function() { document.body.removeChild(document.getElementById("bgDiv")); document.getElementById("msgDiv").removeChild(document.getElementById("msgTitle")); document.body.removeChild(document.getElementById("msgDiv")); } this.show=function() { var msgw,msgh,bordercolor; msgw=self.width; msgh=self.height; bordercolor="#336699"; titlecolor="#99CCFF"; var sWidth,sHeight; sWidth=document.body.offsetWidth; sHeight=screen.height; bgObj=document.createElement("div"); bgObj.setAttribute('id','bgDiv'); bgObj.style.position="absolute"; bgObj.style.top="0"; bgObj.style.background="#777"; bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75"; bgObj.style.opacity="0.6"; bgObj.style.left="0"; bgObj.style.width=sWidth + "px"; bgObj.style.height=sHeight + "px"; bgObj.style.zIndex = "10000"; document.body.appendChild(bgObj); msgObj=document.createElement("div") msgObj.setAttribute("id","msgDiv"); msgObj.setAttribute("align","center"); msgObj.style.background="white"; msgObj.style.border="1px solid " + bordercolor; msgObj.style.position = "absolute"; msgObj.style.left = "50%"; msgObj.style.top = "30%"; msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif"; msgObj.style.marginLeft = "-225px" ; msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px"; msgObj.style.width = msgw + "px"; msgObj.style.height =msgh + "px"; msgObj.style.textAlign = "center"; msgObj.style.lineHeight ="25px"; msgObj.style.zIndex = "10001"; titleObj=document.createElement("h4"); titleObj.setAttribute("id","msgTitle"); titleObj.setAttribute("align","center"); titleObj.style.margin="0"; titleObj.style.padding="3px"; titleObj.style.background=bordercolor; titleObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);"; titleObj.style.opacity="0.75"; titleObj.style.border="1px solid " + bordercolor; titleObj.style.height=self.title_height+"px"; titleObj.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif"; titleObj.style.color="white"; titleObj.style.cursor="pointer"; titleObj.innerHTML=self.title; //titleObj.onclick=function(){self.close();} document.body.appendChild(msgObj); document.getElementById("msgDiv").appendChild(titleObj); var txt=document.createElement("div"); txt.style.margin="1em 0" txt.setAttribute("id","msgTxt"); txt.innerHTML=self.html; document.getElementById("msgDiv").appendChild(txt); } } //信息提示 function msgBox(){ var dg=new dialog(); dg.html="费用正在保存中,请稍等……";//""; dg.width=200; dg.height=100; dg.title=""; dg.show(); } //是否为数字 function IsNum(val){ var re = /^[-\+]?\d+(\.\d+)?$/; if (!re.test(val)){ return false; }else{ return true; } } //去除“,” function ConvertToMoney(strObj){ var result = strObj.replace(",",""); return result; } //过滤结算单位ComboCustomer的键盘 function filterComboCustomerPress(gridObj,rowID,rowIndex,colIndex,filterVal,oldVal){ var combo = gridObj.getCustomCombo(rowID,colIndex); var comboArg = combo.getKeys(); var doCount = 0; for(var i = 0;i 0){ for(var i = 0;i 0){ for(var i = 0;i 0){ if(valObj.indexOf("-") == 0){ valObj = "-"+valObj.replace(/-/g,""); }else{ valObj = valObj.replace(/-/g,""); } } return valObj; } //刷新海运费及附加费 function refreshRecv(){ if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){ if(window.confirm("费用未保存,您确定要刷新费用列表,刷新后自动放弃未保存内容")){ doInitRecvGrid(); newFeeRecvCount = 0; changeFeeRecvCount = 0; } }else{ doInitRecvGrid(); } } //检查浏览器是否是Ie var isIe=(document.all)?true:false; //设置select的可见状态 function setSelectState(state){ var objl=document.getElementsByTagName('select'); for(var i=0;i" + "" + "
"+content+"
"; var v_top=(document.body.clientHeight-mesW.clientHeight)/2; v_top+=document.documentElement.scrollTop; styleStr="top:"+(v_top-180)+"px;left:"+(document.body.clientWidth/2-mesW.clientWidth/2)+"px;position:absolute;width:600px;margin-left:-300px;left:50%;z-index:9999;"; mesW.style.cssText=styleStr; document.body.appendChild(mesW); var Container = $("dvGain"); Container.attachEvent("onresize",function(){ $("back").style.width = parseInt(document.documentElement.scrollWidth); $("back").style.height = parseInt(document.documentElement.scrollHeight); }); } //让背景渐渐变暗 function showBackground(obj,endInt){ if(isIe){ obj.filters.alpha.opacity+=5; if(obj.filters.alpha.opacity"+feeNameArg[k]+""; } var objPos = mousePosition(ev); messContent = "
" +"
" +"
" +"
" +" " +" " +"
" +"
"; showMessageBox('费用打印',messContent,objPos,350); } //鼠标移过图标变化 function mouseMoveImg(obj,type){ var imgUrl = obj.src; var urlArg = imgUrl.split("/"); if(type == 1){ if(urlArg[urlArg.length-1] == "edit_left.gif"){ var newUrl = ""; for(var i=0;i