var commonGridObj_do; var jsonCacheObj; function $(id){ return document.getElementById(id); } function createGrid(){ //header 0 1 2 3 4 5 6 7 8 var headerArgs_do = new Array("应结币别", "申请金额", "应结金额", "本次结算", "未结", "实结币别", "实结汇率", "实结金额", "出账账户"); //width var widthArgs_do = new Array("70", "80", "80", "80", "80", "80", "80", "80", "300"); //column align var colAlignArgs_do = new Array("center", "center", "center", "center", "center", "center", "center", "center", "center"); //column sort var colSortArgs_do = new Array("str", "str", "str", "str", "str", "str", "str", "str", "str"); //column type var colTypeArgs_do = new Array("ro", "ro", "ro", "ed", "ro", "co", "ed", "ed", "co"); commonGridObj_do = new TGridCommon("mygrid_container_paydo","form1",headerArgs_do,widthArgs_do,colAlignArgs_do,colSortArgs_do,colTypeArgs_do); commonGridObj_do.setResponseUrl("SettlementGridSource.aspx"); //var _billno = $("billno").value; commonGridObj_do.setResponseUrl("SettlementGridSource.aspx"); commonGridObj_do.setSourceType("json"); commonGridObj_do.setSkin("xp"); commonGridObj_do.setImageUrl("../images/"); commonGridObj_do.initGrid(); //commonGridObj_do.bind(); commonGridObj_do.getGridObj().init(); commonGridObj_do.getGridObj().enableEditEvents(true, false, true); commonGridObj_do.getGridObj().enableMultiselect(true); commonGridObj_do.getGridObj().enableKeyboardSupport(true); commonGridObj_do.getGridObj().attachEvent("onEditCell", function (stage, rId, cInd, nValue, oValue) { if (stage == 0) { return true; } if (stage == 1) { 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; } } return true; } if (stage == 2) { if (cInd == 3) { var rowIndex = commonGridObj_do.getGridObj().getRowIndex(rId); var amount = parseFloat(commonGridObj_do.getGridObj().cellByIndex(rowIndex, cInd - 1).getValue().trim()); var ctl = parseFloat(commonGridObj_do.getGridObj().cellByIndex(rowIndex, cInd).getValue().trim()); var rate2 = parseFloat(commonGridObj_do.getGridObj().cellByIndex(rowIndex, 6).getValue().trim()); //if (ctl > amount) { if (ctl == amount) { commonGridObj_do.getGridObj().cellByIndex(rowIndex, cInd).setLabel(amount); commonGridObj_do.getGridObj().cellByIndex(rowIndex, 4).setLabel("0"); } else { var tctl = amount - ctl; commonGridObj_do.getGridObj().cellByIndex(rowIndex, 4).setLabel(tctl); } var amount2 = round2(ctl * rate2, 2); commonGridObj_do.getGridObj().cellByIndex(rowIndex, 7).setLabel(amount2); $("txt_je1").value = amount2; $("h_je1").value = amount2; $("txt_je3").value = amount2; } else if (cInd == 5) { var rowIndex = commonGridObj_do.getGridObj().getRowIndex(rId); var cur2 = commonGridObj_do.getGridObj().cellByIndex(rowIndex, cInd).getValue().trim(); $("ddl_bb1").value = cur2; $("ddl_bb3").value = cur2; } else if (cInd == 6) { var rowIndex = commonGridObj_do.getGridObj().getRowIndex(rId); var cur = commonGridObj_do.getGridObj().cellByIndex(rowIndex, 0).getValue().trim(); var cur2 = commonGridObj_do.getGridObj().cellByIndex(rowIndex, 5).getValue().trim(); var ctr = parseFloat(commonGridObj_do.getGridObj().cellByIndex(rowIndex, 3).getValue().trim()); var rate2 = parseFloat(commonGridObj_do.getGridObj().cellByIndex(rowIndex, cInd).getValue().trim()); if (cur == cur2) { return false; } var amount2 = round2(ctr * rate2, 2); commonGridObj_do.getGridObj().cellByIndex(rowIndex, 7).setLabel(amount2); $("txt_je1").value = amount2; $("h_je1").value = amount2; $("txt_je3").value = amount2; } else if (cInd == 7) { var rowIndex = commonGridObj_do.getGridObj().getRowIndex(rId); var cur = commonGridObj_do.getGridObj().cellByIndex(rowIndex, 0).getValue().trim(); var ctr = parseFloat(commonGridObj_do.getGridObj().cellByIndex(rowIndex, 3).getValue().trim()); var cur2 = commonGridObj_do.getGridObj().cellByIndex(rowIndex, 5).getValue().trim(); var amount2 = parseFloat(commonGridObj_do.getGridObj().cellByIndex(rowIndex, cInd).getValue().trim()); if (cur == cur2) { return false; } // var rate2 = round2(amount2 / ctr, 4); commonGridObj_do.getGridObj().cellByIndex(rowIndex, 6).setLabel(rate2); $("txt_je1").value = amount2; $("h_je1").value = amount2; $("txt_je3").value = amount2; } return true; } }); //键盘操作事件 commonGridObj_do.getGridObj().attachEvent("onKeyPress", function (code, cFlag, sFlag) { //获取当前CellIndex(ind) var ind = commonGridObj_do.getGridObj().getSelectedCellIndex(); if (code >= 65 && code <= 90) {//如果是输入英文字符 if (ind != 4) { return false; } } return true; }); setTimeout(function(){ //获取结算信息 if($("h_settleinfo").value != ""){ var tempSettleInfo = $("h_settleinfo").value; var jsonSettleObj = null; jsonSettleObj = eval('(' + tempSettleInfo + ')'); if(jsonSettleObj.settles[0].bank.trim() != ""){ for (var k = 0; k < jsonSettleObj.settles.length; k++) { //header 0 1 2 3 4 5 6 7 8 //var headerArgs_do = new Array("应结币别", "申请金额", "应结金额", "本次结算", "未结", "实结币别", "实结费率", "实结金额", "出账账户"); commonGridObj_do.getGridObj().addRow(jsonSettleObj.settles[k].id, [jsonSettleObj.settles[k].cur, jsonSettleObj.settles[k].applyamount, jsonSettleObj.settles[k].amount, jsonSettleObj.settles[k].ctl, jsonSettleObj.settles[k].uctl, jsonSettleObj.settles[k].cur2, jsonSettleObj.settles[k].rate2, jsonSettleObj.settles[k].amount2, jsonSettleObj.settles[k].bank], 0); commonGridObj_do.bind(); } commonGridObj_do.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){ if(stage == 0){ return false; } }); } else { var settleCurrency = $("h_settlecurrency").value; var url = "SettlementGridSource.aspx?handle=bankinfo&uid="+commonGridObj_do.newGuid();//银行账号信息 var loader = dhtmlxAjax.getSync(url); var bankInfo = loader.xmlDoc.responseText; var jsonCacheObj = eval('(' + bankInfo + ')'); var isRun = false; if(commonGridObj_do.getGridObj().getRowsNum() > 0){ 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 amount) { if (ctl == amount) { commonGridObj_do.getGridObj().cellByIndex(rowIndex, cInd).setLabel(amount); commonGridObj_do.getGridObj().cellByIndex(rowIndex, 4).setLabel("0"); } else { var tctl = amount - ctl; commonGridObj_do.getGridObj().cellByIndex(rowIndex, 4).setLabel(tctl); } var amount2 = round2(ctl * rate2, 2); commonGridObj_do.getGridObj().cellByIndex(rowIndex, 7).setLabel(amount2); $("txt_je1").value = amount2; $("h_je1").value = amount2; $("txt_je3").value = amount2; } else if (cInd == 5) { var rowIndex = commonGridObj_do.getGridObj().getRowIndex(rId); var cur2 = commonGridObj_do.getGridObj().cellByIndex(rowIndex, cInd).getValue().trim(); $("ddl_bb1").value = cur2; $("ddl_bb3").value = cur2; } else if (cInd == 6) { var rowIndex = commonGridObj_do.getGridObj().getRowIndex(rId); var cur = commonGridObj_do.getGridObj().cellByIndex(rowIndex, 0).getValue().trim(); var cur2 = commonGridObj_do.getGridObj().cellByIndex(rowIndex, 5).getValue().trim(); var ctr = parseFloat(commonGridObj_do.getGridObj().cellByIndex(rowIndex, 3).getValue().trim()); var rate2 = parseFloat(commonGridObj_do.getGridObj().cellByIndex(rowIndex, cInd).getValue().trim()); if (cur == cur2) { return false; } var amount2 = round2(ctr * rate2, 2); commonGridObj_do.getGridObj().cellByIndex(rowIndex, 7).setLabel(amount2); $("txt_je1").value = amount2; $("h_je1").value = amount2; $("txt_je3").value = amount2; } else if (cInd == 7) { var rowIndex = commonGridObj_do.getGridObj().getRowIndex(rId); var cur = commonGridObj_do.getGridObj().cellByIndex(rowIndex, 0).getValue().trim(); var ctr = parseFloat(commonGridObj_do.getGridObj().cellByIndex(rowIndex, 3).getValue().trim()); var cur2 = commonGridObj_do.getGridObj().cellByIndex(rowIndex, 5).getValue().trim(); var amount2 = parseFloat(commonGridObj_do.getGridObj().cellByIndex(rowIndex, cInd).getValue().trim()); if (cur == cur2) { return false; } // var rate2 = round2(amount2 / ctr, 4); commonGridObj_do.getGridObj().cellByIndex(rowIndex, 6).setLabel(rate2); $("txt_je1").value = amount2; $("h_je1").value = amount2; $("txt_je3").value = amount2; } return true; } }); //键盘操作事件 commonGridObj_do.getGridObj().attachEvent("onKeyPress", function (code, cFlag, sFlag) { //获取当前CellIndex(ind) var ind = commonGridObj_do.getGridObj().getSelectedCellIndex(); if (code >= 65 && code <= 90) {//如果是输入英文字符 if (ind != 8) { return false; } } return true; }); //header 0 1 2 3 4 5 6 7 8 //var headerArgs_do = new Array("应结币别", "申请金额", "应结金额", "本次结算", "未结", "实结币别", "实结费率", "实结金额", "出账账户"); for (var j = 0; j < jsonSettleObj.settles.length; j++) { if(jsonSettleObj.settles[j].cur == "RMB"){ var newId = commonGridObj_do.newGuid(); commonGridObj_do.getGridObj().addRow(newId, ["RMB", jsonSettleObj.settles[j].applyamount, jsonSettleObj.settles[j].amount, jsonSettleObj.settles[j].ctl, jsonSettleObj.settles[j].uctl, "RMB", jsonSettleObj.settles[j].rate2, jsonSettleObj.settles[j].amount2, ""], 0); // var newCombo2 = commonGridObj_do.getGridObj().getCustomCombo(newId, 5); newCombo2.put("RMB", "RMB"); newCombo2.put("USD", "USD"); newCombo2.put("", ""); // //commonGridObj_do.bind(); for(var k=0;k 0){ commonGridObj_do.getGridObj().addRow(newId, ["USD", jsonSettleObj.settles[j].applyamount, jsonSettleObj.settles[j].amount, jsonSettleObj.settles[j].ctl, jsonSettleObj.settles[j].uctl, "USD", jsonSettleObj.settles[j].rate2, jsonSettleObj.settles[j].amount2, ""], 1); }else{ commonGridObj_do.getGridObj().addRow(newId, ["USD", jsonSettleObj.settles[j].applyamount, jsonSettleObj.settles[j].amount, jsonSettleObj.settles[j].ctl, jsonSettleObj.settles[j].uctl, "USD", jsonSettleObj.settles[j].rate2, jsonSettleObj.settles[j].amount2, ""], 0); } // var newCombo2 = commonGridObj_do.getGridObj().getCustomCombo(newId, 5); newCombo2.put("RMB", "RMB"); newCombo2.put("USD", "USD"); newCombo2.put("", ""); // //commonGridObj_do.bind(); for(var k=0;k 0){ if(commonGridObj_do.getGridObj().cellByIndex(i,0).getValue().trim() == "USD"){ commonGridObj_do.getGridObj().cellByIndex(i,8).setValue($("h_usdaccount").value.trim()); } } if($("h_rmbaccount").value.trim() != "" && commonGridObj_do.getGridObj().cellByIndex(i,0).getValue().length > 0){ if(commonGridObj_do.getGridObj().cellByIndex(i,0).getValue().trim() == "RMB"){ commonGridObj_do.getGridObj().cellByIndex(i,8).setValue($("h_rmbaccount").value.trim()); } } } } function postSettle(){ if (commonGridObj_do != null) { // var je1 = round2((parseFloat($("txt_je1").value.trim()) + parseFloat($("txt_je2").value.trim())), 2); // var je2 = round2((parseFloat($("txt_je3").value.trim()) + parseFloat($("txt_je4").value.trim()) + parseFloat($("txt_je5").value.trim())), 2); // if (je1 != je2) { // alert("财务科目不平衡,请重新填写!"); // return false; // } // var jsonSettleObj = null; $("h_settleinfo").value = ""; for(var i = 0;i 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; } } function 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 closeAction(){ window.parent.opener.location.href = window.parent.opener.location.href; window.close(); } function cwvouchersadd(gid) { var url = "../CW/CwVouchersChFeeSettlementListGridSource.aspx?handle=isvouchers&gids=" + gid + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(url); var jsVal = loader.xmlDoc.responseText; if (jsVal.trim() != "") { alert(jsVal); //"有已生成的凭证,不能重复生成!" return; } // var url = "../CW/CwVouchersAddDoGridSource.aspx?read=isvouchers&gids=" + gid + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(url); var jsVal = loader.xmlDoc.responseText; if (jsVal.trim() == "") { alert("生成凭证失败!"); //"有已生成的凭证,不能重复生成!" return; } // var feature = "height=500, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=0,location=no, status=no,Top= " + (screen.height / 2 - 300) + ",Left= " + (screen.width / 2 - 500); var URLs = "../CW/CwVouchersAddDo.aspx?ordno=" + jsVal; window.open(URLs, "生成结算凭证信息", feature); } 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 getonload() { createGrid(); setDiv(); } function setDiv() { if ($("h_ISADVANCE").value.trim() == "True") { document.getElementById('YFDiv').style.display = ""; } else { document.getElementById('YFDiv').style.display = "none"; } // if ($("h_cur").value.trim() == "RMB") { $("ddl_bb1").value = "RMB"; $("ddl_bb3").value = "RMB"; } else if ($("h_cur").value.trim() == "USD") { $("ddl_bb1").value = "USD"; $("ddl_bb3").value = "USD"; } $("ddl_bb2").value = "RMB"; $("ddl_bb4").value = "RMB"; $("ddl_bb5").value = "RMB"; $("txt_hl1").value = "1.0000"; $("txt_hl2").value = "1.0000"; $("txt_hl3").value = "1.0000"; $("txt_hl4").value = "1.0000"; $("txt_hl5").value = "1.0000"; $("txt_je1").value = $("h_ctl").value.trim(); $("h_je1").value = $("h_ctl").value.trim(); $("txt_je2").value = "0.00"; $("txt_je3").value = $("h_ctl").value.trim(); $("txt_je4").value = "0.00"; $("txt_je5").value = "0.00"; // txt_disabled(); } //#region js计算函数 round2 = function (str, length) { var r2 = parseFloat(str).toFixed(8); var r1 = parseFloat(r2).toFixed(parseInt(length)); return r1; } //除法函数,用来得到精确的除法结果 //说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显。这个函数返回较为精确的除法结果。 //调用:accDiv(arg1,arg2) //返回值:arg1除以arg2的精确结果 function accDiv(arg1, arg2) { var t1 = 0, t2 = 0, r1, r2; try { t1 = arg1.toString().split(".")[1].length } catch (e) { } try { t2 = arg2.toString().split(".")[1].length } catch (e) { } with (Math) { r1 = Number(arg1.toString().replace(".", "")) r2 = Number(arg2.toString().replace(".", "")) return (r1 / r2) * pow(10, t2 - t1); } } //给Number类型增加一个div方法,调用起来更加方便。 Number.prototype.div = function (arg) { return accDiv(this, arg); } //乘法函数,用来得到精确的乘法结果 //说明:javascript的乘法结果会有误差,在两个浮点数相乘的时候会比较明显。这个函数返回较为精确的乘法结果。 //调用:accMul(arg1,arg2) //返回值:arg1乘以arg2的精确结果 function accMul(arg1, arg2) { var m = 0, s1 = arg1.toString(), s2 = arg2.toString(); try { m += s1.split(".")[1].length } catch (e) { } try { m += s2.split(".")[1].length } catch (e) { } return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m) } //给Number类型增加一个mul方法,调用起来更加方便。 Number.prototype.mul = function (arg) { return accMul(arg, this); } //加法函数,用来得到精确的加法结果 //说明:javascript的加法结果会有误差,在两个浮点数相加的时候会比较明显。这个函数返回较为精确的加法结果。 //调用:accAdd(arg1,arg2) //返回值:arg1加上arg2的精确结果 function accAdd(arg1, arg2) { var r1, r2, m; try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 } try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 } m = Math.pow(10, Math.max(r1, r2)) return (arg1 * m + arg2 * m) / m } //给Number类型增加一个add方法,调用起来更加方便。 Number.prototype.add = function (arg) { return accAdd(arg, this); } //加 function Add(a, b, length) { if ((typeof (length) == undefined) || (length == null)) { length = 2; } var _r = parseFloat(a).add(parseFloat(b)).toFixed(parseInt(length)); return parseFloat(_r); } //减 function Cut(a, b, length) { if ((typeof (length) == undefined) || (length == null)) { length = 2; } var _r = parseFloat(a).add(parseFloat(0) - parseFloat(b)).toFixed(parseInt(length)); return parseFloat(_r); } //乘 function Mul(a, b, length) { if ((typeof (length) == undefined) || (length == null)) { length = 2; } var _r = parseFloat(a).mul(parseFloat(b)).toFixed(parseInt(length)); return parseFloat(_r); } //连乘 function Mul3(a, b, c, length) { if ((typeof (length) == undefined) || (length == null)) { length = 2; } var _r = (parseFloat(a).mul(parseFloat(b)).mul(parseFloat(c))).toFixed(parseInt(length)); return parseFloat(_r); } //除 function Div(a, b, length) { if ((typeof (length) == undefined) || (length == null)) { length = 2; } var _r = parseFloat(a).div(parseFloat(b)).toFixed(parseInt(length)); return parseFloat(_r); } //#endregion