var commonGridObj_do; var commonGridObj_recv; var jsonCacheObj; function $(id){ return document.getElementById(id); } function createRecvGrid(){ //header var headerArgs_recv = new Array("","付款单位","币别","结算金额","未结金额"); //width var widthArgs_recv = new Array("40","110","60","80","80"); //column align var colAlignArgs_recv = new Array("center","center","center","center","center"); //column sort var colSortArgs_recv = new Array("str","str","str","str","str"); //column type var colTypeArgs_recv = new Array("ch","ro","ro","ed","ro"); commonGridObj_recv = new TGridCommon("mygrid_container_recv","form1",headerArgs_recv,widthArgs_recv,colAlignArgs_recv,colSortArgs_recv,colTypeArgs_recv); commonGridObj_recv.setResponseUrl("SettlementGridSourceApp.aspx"); var _verifycacheName = $("h_verifycache").value; commonGridObj_recv.setRequest("SettlementGridSourceApp.aspx?handle=getverifycache&verifycachename="+_verifycacheName+"&uid="+commonGridObj_recv.newGuid()); commonGridObj_recv.setSourceType("json"); commonGridObj_recv.setSkin("xp"); commonGridObj_recv.setImageUrl("../images/"); commonGridObj_recv.initGrid(); commonGridObj_recv.bind(); commonGridObj_recv.getGridObj().enableEditEvents(true,false,true); commonGridObj_recv.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){ if(stage == 0){ return true; } if(stage == 1){ var selectedId = commonGridObj_recv.getGridObj().getSelectedRowId(); var rowIndex = commonGridObj_recv.getGridObj().getRowIndex(selectedId); var txtEdit for(i = 0; i < document.all.length; i++){ if(document.all(i).tagName == "TEXTAREA"){ txtEdit = document.all(i); txtEdit.focus(); txtEdit.select(); break; } } if(cInd == 1 || cInd == 2){ if(flagFilter == 0){ //alert(txtEdit.value); } } } if(stage == 2){ var selectedId = commonGridObj_recv.getGridObj().getSelectedRowId(); var rowIndex = commonGridObj_recv.getGridObj().getRowIndex(selectedId); var stl = 0.0; var cstl = 0.0; var ustl = 0.0; //stl = parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_fee.getGridObj().cellByIndex(rowIndex,3).getValue())))); cstl = parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_recv.getGridObj().cellByIndex(rowIndex,3).getValue())))); ustl = parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_recv.getGridObj().cellByIndex(rowIndex,4).getValue())))); var tempCstl = 0.0; var tempUstl = 0.0; var totalCstl = 0.0; var oldValue = parseFloat(oValue); var newValue = parseFloat(nValue); if(oldValue > 0){ if(ustl == 0){ if(cstl > (ustl+oldValue)){ return false; }else{ totalCstl = oldValue+ustl; tempUstl = totalCstl - newValue; tempCstl = newValue; } }else if(oldValue == ustl){ if(newValue > oldValue){ return false; } totalCstl = oldValue; tempUstl = totalCstl - newValue; tempCstl = newValue; }else if(oldValue != ustl){ if(newValue > (oldValue+ustl)){ return false; } totalCstl = oldValue+ustl; tempUstl = totalCstl - newValue; tempCstl = newValue; } }else{ return false; } commonGridObj_recv.getGridObj().cellByIndex(rowIndex,3).setValue(ConvertToMoney(outputMoney(tempCstl.toString()))); if(tempUstl == 0 && tempCstl > 0){ commonGridObj_recv.getGridObj().cellByIndex(rowIndex,4).setValue(ConvertToMoney(outputMoney(tempCstl.toString()))); }else{ commonGridObj_recv.getGridObj().cellByIndex(rowIndex,4).setValue(ConvertToMoney(outputMoney(tempUstl.toString()))); } return true; } }); commonGridObj_recv.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){ var openSet = "height=450, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-450)/2 + ",Left= "+(screen.width-1000)/2 var openType = "_blank"; var openUrl = "ReceiveAmountEdit.aspx?handle=edit&id="+rId; var tempWin = window.open ("about:blank",openType,openSet); tempWin.location = openUrl; }); } function createGrid(){ //header var headerArgs_do = new Array("币别","金额","入账账户"); //width var widthArgs_do = new Array("70","80","200"); //column align var colAlignArgs_do = new Array("center","center","center"); //column sort var colSortArgs_do = new Array("str","str","str"); //column type var colTypeArgs_do = new Array("ro","ro","co"); commonGridObj_do = new TGridCommon("mygrid_container_do","form1",headerArgs_do,widthArgs_do,colAlignArgs_do,colSortArgs_do,colTypeArgs_do); commonGridObj_do.setResponseUrl("SettlementGridSourceApp.aspx"); //var _billno = $("billno").value; commonGridObj_do.setRequest("SettlementGridSourceApp.aspx?handle=billlist&billno="+1); commonGridObj_do.setSourceType("json"); commonGridObj_do.setSkin("xp"); commonGridObj_do.setImageUrl("../images/"); commonGridObj_do.initGrid(); commonGridObj_do.bind(); setTimeout(function(){ if($("h_settleinfo").value != ""){ var tempSettleInfo = $("h_settleinfo").value; jsonSettleObj = eval('(' + tempSettleInfo + ')'); var isRun = false; for(var i=0;i < commonGridObj_do.getGridObj().getRowsNum();i++){ var rowId = commonGridObj_do.getGridObj().getRowId(i); var rowIndex = commonGridObj_do.getGridObj().getRowIndex(rowId); for(var j = 0;j 0){ for(var i=0;i recvRmbTotal){ if(window.confirm("收费结算RMB费用大于实收RMB费用 只能做部分收费结算 是否继续进行部分结算")){ if($("h_feecache").value.trim() != ""){ var feeCache = $("h_feecache").value var jsonFeeObj = eval('(' + feeCache + ')'); if(jsonFeeObj != null){ var isFull = false; var mixFlag = false; var isFinish = false; var tempVal = 0; var breakNum = 0; for(var i = 0;i = recvRmbTotal){ if(jsonFeeObj.caches[i].cur != jsonFeeObj.caches[i].ocurr){ var settleCurrency = $("h_settlecurrency").value; var usdToRmbRate = parseFloat($("h_usdtormb").value); var rmbToUsdRate = parseFloat($("h_rmbtousd").value); if(settleCurrency == 1){ if(jsonFeeObj.caches[i].ocurr == "USD"){ jsonFeeObj.caches[i].ocstl = moneyMath(recvRmbTotal * rmbToUsdRate); }if(jsonFeeObj.caches[i].ocurr == "RMB"){ jsonFeeObj.caches[i].ocstl = recvRmbTotal; } }else if(settleCurrency == 2){ if(jsonFeeObj.caches[i].ocurr == "RMB"){ jsonFeeObj.caches[i].ocstl = moneyMath(recvUsdTotal * usdToRmbRate); }if(jsonFeeObj.caches[i].ocurr == "USD"){ jsonFeeObj.caches[i].ocstl = recvRmbTotal; } } } jsonFeeObj.caches[i].ustl = jsonFeeObj.caches[i].cstl - recvRmbTotal; jsonFeeObj.caches[i].cstl = recvRmbTotal;//alert(JSON.stringify(jsonFeeObj)); isFull = true; break; } if(i == jsonFeeObj.caches.length - 1){ //如果没有单个结算没有大于等于实收费用则取最顶端结算费用组合全部或部分结算 if(!isFull){ i = -1; mixFlag = true; tempVal = 0; continue; } } }else{ tempVal += jsonFeeObj.caches[i].cstl; if(tempVal >= recvRmbTotal){ if(jsonFeeObj.caches[i].cur != jsonFeeObj.caches[i].ocurr){ var settleCurrency = $("h_settlecurrency").value; var usdToRmbRate = parseFloat($("h_usdtormb").value); var rmbToUsdRate = parseFloat($("h_rmbtousd").value); if(settleCurrency == 1){ if(jsonFeeObj.caches[i].ocurr == "USD"){ jsonFeeObj.caches[i].ocstl = moneyMath((jsonFeeObj.caches[i].cstl - (tempVal - recvRmbTotal)) * rmbToUsdRate); }if(jsonFeeObj.caches[i].ocurr == "RMB"){ jsonFeeObj.caches[i].ocstl = jsonFeeObj.caches[i].cstl - ((tempVal - recvRmbTotal)); } }else if(settleCurrency == 2){ if(jsonFeeObj.caches[i].ocurr == "RMB"){ jsonFeeObj.caches[i].ocstl = moneyMath(jsonFeeObj.caches[i].cstl - ((tempVal - recvUsdTotal)) * usdToRmbRate); }if(jsonFeeObj.caches[i].ocurr == "USD"){ jsonFeeObj.caches[i].ocstl = jsonFeeObj.caches[i].cstl - ((tempVal - recvUsdTotal)); } } }else{ jsonFeeObj.caches[i].ocstl = jsonFeeObj.caches[i].cstl - ((tempVal - recvRmbTotal)); } jsonFeeObj.caches[i].ustl = tempVal - recvRmbTotal; jsonFeeObj.caches[i].cstl = jsonFeeObj.caches[i].cstl - ((tempVal - recvRmbTotal)); breakNum = i+1; break; } } } } $("h_feecache").value = JSON.stringify(jsonFeeObj);//alert($("h_feecache").value); //$("h_settleinfo").value = ""; createGrid(); var tempSettleInfo = $("h_settleinfo").value; var tempSettleObj = eval('(' + tempSettleInfo + ')'); if(tempSettleObj != null){ tempSettleObj.settles[0].amount = recvRmbTotal; $("h_settleinfo").value = JSON.stringify(tempSettleObj); } } isDoRmb = true; //return; }else{ return; } } if(usdTotal > recvUsdTotal){ if(window.confirm("收费结算USD费用大于实收USD费用 只能做部分收费结算 是否继续进行部分结算")){ if($("h_feecache").value.trim() != ""){ var feeCache = $("h_feecache").value var jsonFeeObj = eval('(' + feeCache + ')'); if(jsonFeeObj != null){ var isFull = false; var mixFlag = false; var isFinish = false; var tempVal = 0; var breakNum = 0; for(var i = 0;i = recvUsdTotal){ if(jsonFeeObj.caches[i].cur != jsonFeeObj.caches[i].ocurr){ var settleCurrency = $("h_settlecurrency").value; var usdToRmbRate = parseFloat($("h_usdtormb").value); var rmbToUsdRate = parseFloat($("h_rmbtousd").value); if(settleCurrency == 1){ if(jsonFeeObj.caches[i].ocurr == "USD"){ jsonFeeObj.caches[i].ocstl = moneyMath(recvRmbTotal * rmbToUsdRate); }if(jsonFeeObj.caches[i].ocurr == "RMB"){ jsonFeeObj.caches[i].ocstl = recvRmbTotal; } }else if(settleCurrency == 2){ if(jsonFeeObj.caches[i].ocurr == "RMB"){ jsonFeeObj.caches[i].ocstl = moneyMath(recvUsdTotal * usdToRmbRate); }if(jsonFeeObj.caches[i].ocurr == "USD"){ jsonFeeObj.caches[i].ocstl = recvUsdTotal; } } } jsonFeeObj.caches[i].ustl = jsonFeeObj.caches[i].cstl - recvUsdTotal; jsonFeeObj.caches[i].cstl = recvUsdTotal; isFull = true; break; } if(i == jsonFeeObj.caches.length - 1){ //如果没有单个结算没有大于等于实收费用则取最顶端结算费用组合全部或部分结算 if(!isFull){ i = -1; mixFlag = true; tempVal = 0; continue; } } }else{ tempVal += moneyMath(jsonFeeObj.caches[i].cstl); tempVal = moneyMath(tempVal); if(tempVal >= recvUsdTotal){ if(jsonFeeObj.caches[i].cur != jsonFeeObj.caches[i].ocurr){ var settleCurrency = $("h_settlecurrency").value; var usdToRmbRate = parseFloat($("h_usdtormb").value); var rmbToUsdRate = parseFloat($("h_rmbtousd").value); if(settleCurrency == 1){ if(jsonFeeObj.caches[i].ocurr == "USD"){ jsonFeeObj.caches[i].ocstl = moneyMath((jsonFeeObj.caches[i].cstl - (tempVal - recvUsdTotal)) * rmbToUsdRate); }if(jsonFeeObj.caches[i].ocurr == "RMB"){ jsonFeeObj.caches[i].ocstl = recvRmbTotal; } }else if(settleCurrency == 2){ if(jsonFeeObj.caches[i].ocurr == "RMB"){ jsonFeeObj.caches[i].ocstl = moneyMath((jsonFeeObj.caches[i].cstl - (tempVal - recvRmbTotal)) * usdToRmbRate); }if(jsonFeeObj.caches[i].ocurr == "USD"){ jsonFeeObj.caches[i].ocstl = moneyMath(jsonFeeObj.caches[i].cstl - (tempVal - recvUsdTotal)); } } }else{ jsonFeeObj.caches[i].ocstl = moneyMath(jsonFeeObj.caches[i].cstl - (tempVal - recvUsdTotal)); } jsonFeeObj.caches[i].ustl = moneyMath(tempVal - recvUsdTotal); jsonFeeObj.caches[i].cstl = moneyMath(jsonFeeObj.caches[i].cstl - (tempVal - recvUsdTotal)); breakNum = i+1; break; } } } } if(breakNum < jsonFeeObj.caches.length - 1){ for(var j = jsonFeeObj.caches.length-1;j >= 0;j--){ jsonCacheObj.caches.splice(breakNum,1); break; } } $("h_feecache").value = JSON.stringify(jsonFeeObj); //$("h_settleinfo").value = ""; createGrid(); var tempSettleInfo = $("h_settleinfo").value; var tempSettleObj = eval('(' + tempSettleInfo + ')'); if(tempSettleObj != null){ tempSettleObj.settles[0].amount = recvUsdTotal; $("h_settleinfo").value = JSON.stringify(tempSettleObj); } } isDoUsd = true; //return; }else{ return; } } if(recvRmbTotal > rmbTotal){ if(recvRmbCount > 1){ alert("多笔实收费用需指定结算金额"); return; }else{ for(var j = 0;j 0){ if(ustl == 0){ if(cstl > (ustl+oldValue)){ return false; }else{ totalCstl = oldValue+ustl; tempUstl = totalCstl - newValue; tempCstl = newValue; } }else if(oldValue != ustl){ totalCstl = oldValue+ustl; tempUstl = totalCstl - newValue; tempCstl = newValue; }else if(oldValue == ustl){ totalCstl = oldValue; tempUstl = totalCstl - newValue; tempCstl = newValue; } } commonGridObj_recv.getGridObj().cellByIndex(rowIndex,3).setValue(ConvertToMoney(outputMoney(tempCstl.toString()))); commonGridObj_recv.getGridObj().cellByIndex(rowIndex,4).setValue(ConvertToMoney(outputMoney(tempUstl.toString()))); var tempRecvAmount = $("h_recvamount").value; jsonRecvAmountObj = eval('(' + tempRecvAmount + ')'); for(var k=0;k usdTotal){ if(recvUsdCount > 1){ alert("多笔实收费用需指定结算金额"); return; }else{ for(var j = 0;j 0){ if(ustl == 0){ if(cstl > (ustl+oldValue)){ return false; }else{ totalCstl = oldValue+ustl; tempUstl = totalCstl - newValue; tempCstl = newValue; } }else if(oldValue != ustl){ totalCstl = oldValue+ustl; tempUstl = totalCstl - newValue; tempCstl = newValue; }else if(oldValue == ustl){ totalCstl = oldValue; tempUstl = totalCstl - newValue; tempCstl = newValue; } } commonGridObj_recv.getGridObj().cellByIndex(rowIndex,3).setValue(ConvertToMoney(outputMoney(tempCstl.toString()))); commonGridObj_recv.getGridObj().cellByIndex(rowIndex,4).setValue(ConvertToMoney(outputMoney(tempUstl.toString()))); var tempRecvAmount = $("h_recvamount").value; jsonRecvAmountObj = eval('(' + tempRecvAmount + ')'); for(var k=0;k 0){ if(reportObj.reports[0].compid != ""){ companyID = reportObj.reports[0].compid; } if(reportObj.reports[0].sourceid != ""){ dbSourceID = reportObj.reports[0].sourceid; } if(reportObj.reports[0].compid != ""){ userID = reportObj.reports[0].userid; } printUrl = "print://?comp="+companyID+"&type="+typeName+"&dbid="+dbSourceID+"&uid="+userID;//alert(printUrl); window.location.href = window.location.href; location.href = printUrl; } }else{ alert("没有要打印的报表"); return; } }else{ alert("费用未结算不能打印"); return; } } String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); } function recvAll(){ if(commonGridObj_recv != null){ } }