var commonGirdObj_fname; var commonGridObj_fee; var comboCustomer;//委托单位 var comboBank;//开户银行 var comboAccount;//银行账户 var comboCurrency;//币别 var jsonCacheObj; function $(id){ return document.getElementById(id); } function createInfo(){ //initComboCustomer(); initComboCustomer2(); initComboBank(); initComboAccount(); initComboCurrency(); initComboInvoiceno(); createComboCurrency(); createComboBank(); createComboAccount(); createComboInvoiceno(); initFeeName(); //initFee(); initInvoice(); } function initFeeName(){ var headerArgs_fname = new Array("","类型","费用名称","费用"); //width var widthArgs_fname = new Array("30","30","140","140"); //column align var colAlignArgs_fname = new Array("center","center","center","center"); //column sort var colSortArgs_fname = new Array("na","na","na","na"); //column type var colTypeArgs_fname = new Array("ch","ro","ed","ed"); commonGirdObj_fname = new TGridCommon("mygrid_container_fname","form1",headerArgs_fname,widthArgs_fname,colAlignArgs_fname,colSortArgs_fname,colTypeArgs_fname); //commonGirdObj_fname.showHeader(true); commonGirdObj_fname.setResponseUrl(""); commonGirdObj_fname.setRequest(""); commonGirdObj_fname.setSourceType("json"); commonGirdObj_fname.setSkin("xp"); commonGirdObj_fname.setImageUrl("../images/"); commonGirdObj_fname.initGrid(); commonGirdObj_fname.getGridObj().enableEditEvents(true,false,true); commonGirdObj_fname.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){ if(stage == 0){ return true; } if(stage == 1){ var selectedId = commonGirdObj_fname.getGridObj().getSelectedRowId(); var rowIndex = commonGirdObj_fname.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(stage == 2){ var cacheName = "";//cachename if($("h_cachename").value.trim() == ""){ $("h_cachename").value = commonGirdObj_fname.newGuid(); } cacheName = "&cachename="+$("h_cachename").value; var applyCurrency = $("h_settlecurrency").value.trim() == "RMB"?1:2; var rowIndex = commonGirdObj_fname.getGridObj().getRowIndex(rId); var feeName = commonGirdObj_fname.getGridObj().cellByIndex(rowIndex,2).getValue().trim(); var money = ConvertToMoney(outputMoney(clearNoNum(commonGirdObj_fname.getGridObj().cellByIndex(rowIndex,3).getValue().toString()))); var url = "InvoiceModifyGridSource.aspx?handle=addfee&settlectype="+applyCurrency+cacheName+"&directfeeid="+rId+"&directfeename="+escape(feeName)+"&directfeeamount="+money+"&guid="+commonGirdObj_fname.newGuid(); var loader = dhtmlxAjax.getSync(url); var totalList = loader.xmlDoc.responseText; var totalListObj = eval('(' + totalList + ')'); if(totalListObj != null){ if(applyCurrency == 1 && totalListObj.total[0].finaltotal != 0){ var curCapital = convertCurrency(moneyMath(totalListObj.total[0].finaltotal).toString(),1); if(totalListObj.total[0].finaltotal < 0){ $("txt_amountcapital").value = "负"+curCapital; }else{ $("txt_amountcapital").value = curCapital; } $("txt_total").value = "RMB "+totalListObj.total[0].finaltotal }else if(applyCurrency == 2 && totalListObj.total[0].finaltotal != 0){ var curCapital = convertCurrency(moneyMath(totalListObj.total[0].finaltotal).toString(),2); if(totalListObj.total[0].finaltotal < 0){ $("txt_amountcapital").value = "负"+curCapital; }else{ $("txt_amountcapital").value = curCapital; } $("txt_total").value = "USD "+totalListObj.total[0].finaltotal }else{ $("txt_amountcapital").value = ""; $("txt_total").value = ""; } } return true; } }); // commonGirdObj_fname.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){ // if(stage == 0){ // return true; // } // if(stage == 1){ // var selectedId = commonGirdObj_fname.getGridObj().getSelectedRowId(); // var rowIndex = commonGirdObj_fname.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(stage == 2){ // if(cInd == 2){//更改费用名称 // if(nValue.trim() == ""){ // alert("费用名称不能为空"); // return false; // } // // var iCount = 0; // var rowIndex = commonGirdObj_fname.getGridObj().getRowIndex(rId); // var newName = nValue.toString(); // commonGirdObj_fname.getGridObj().cellByIndex(rowIndex,2).setValue(newName); // // var tempCache = $("h_feecache").value; // if(tempCache.trim() != ""){ // jsonCacheObj = eval('(' + tempCache + ')'); // // for(var i=0;i MAXIMUM_NUMBER) { alert("Too large a number to convert!"); return ""; } // Process the coversion from currency digits to characters: // Separate integral and decimal parts before processing coversion: parts = currencyDigits.split("."); if (parts.length > 1) { integral = parts[0]; decimal = parts[1]; // Cut down redundant decimal digits that are after the second. decimal = decimal.substr(0, 2); } else { integral = parts[0]; decimal = ""; } // Prepare the characters corresponding to the digits: digits = new Array(CN_ZERO, CN_ONE, CN_TWO, CN_THREE, CN_FOUR, CN_FIVE, CN_SIX, CN_SEVEN, CN_EIGHT, CN_NINE); radices = new Array("", CN_TEN, CN_HUNDRED, CN_THOUSAND); bigRadices = new Array("", CN_TEN_THOUSAND, CN_HUNDRED_MILLION); decimals = new Array(CN_TEN_CENT, CN_CENT); // Start processing: outputCharacters = ""; // Process integral part if it is larger than 0: if (Number(integral) > 0) { zeroCount = 0; for (i = 0; i < integral.length; i++) { p = integral.length - i - 1; d = integral.substr(i, 1); quotient = p / 4; modulus = p % 4; if (d == "0") { zeroCount++; } else { if (zeroCount > 0) { outputCharacters += digits[0]; } zeroCount = 0; outputCharacters += digits[Number(d)] + radices[modulus]; } if (modulus == 0 && zeroCount < 4) { outputCharacters += bigRadices[quotient]; zeroCount = 0; } } outputCharacters += CN_DOLLAR; } // Process decimal part if there is: if (decimal != "") { for (i = 0; i < decimal.length; i++) { d = decimal.substr(i, 1); if (d != "0") { outputCharacters += digits[Number(d)] + decimals[i]; } } } // Confirm and return the final output string: if (outputCharacters == "") { outputCharacters = CN_ZERO + CN_DOLLAR; } if (decimal == "") { outputCharacters += CN_INTEGER; } if(type == 1){ outputCharacters = CN_SYMBOL + outputCharacters; }else if(type == 2){ outputCharacters = CN_SYUSD + outputCharacters; } return outputCharacters; } function addApplication(){ $("h_action").value = 5;//添加申请 //postEnterFee(); } function deleteApplication(){ $("h_action").value = 4;//删除申请 //postEnterFee(); } function printInvoice(){ $("h_action").value = 3;//打印申请 //postEnterFee(); } function saveApplication(){ $("h_action").value = 2;//保存申请 //saveInfo(); } function makeOutInvoice(){ //$("h_action").value = 1;//开票 var handleName = $("h_handle").value.trim(); if(handleName == "import"){ $("h_enter").value = "1"; }else if(handleName == "makeout"){ $("h_enter").value = "2"; }else if(handleName == "directmake"){ $("h_enter").value = "3"; } saveInfo(); } function saveInfo(){ //提交时发票号码不能为空 var invoiceno = $("h_invoiceno").value.trim(); if (invoiceno.trim() == "") { alert("发票号码不能为空,请填写"); return; } // var jsonListObj = null; // // var cacheBuffer = ""; // for(var i = 0;i 0){ // for(var i = 0;i 0){ if(window.confirm("您确定要删除此条费用,删除后无法恢复")){ for(var j = 0;j = 0;j--){ // if(jsonCacheObj.caches[j].id == rId){ // if(jsonCacheObj.caches.length == 1){ // jsonCacheObj.caches.shift(); // $("h_list").value = ""; // initInvoice(); // break; // }else{ // jsonCacheObj.caches.splice(j,1); // $("h_list").value = JSON.stringify(jsonCacheObj); // initInvoice(); // break; // } // } // } // } // } //} function btnDisable(id){ $(id).disabled = true; } //重新加载Grid function ReLoadGrid(){ var strList = $("h_feecache").value; if(strList.trim() != ""){ jsonListObj = eval('(' + strList + ')'); //初始化Grid commonGirdObj_fname.initGrid(); var IsRename = false; for(var i=0;i= 0;j--){ // if(jsonCacheObj.caches[j].id == rId){ // if(jsonCacheObj.caches.length == 1){ // jsonCacheObj.caches.shift(); // jsonCacheObj = null; // $("h_feecache").value = ""; // break; // }else{ // if(jsonCacheObj.caches[j].orig == 3){ // commonGirdObj_fname.getGridObj().deleteRow(jsonCacheObj.caches[j].id); // jsonCacheObj.caches.splice(j,1); // // for(var z = jsonCacheObj.caches.length-1;z >= 0;z--){ // if(jsonCacheObj.caches[z].orig == 1){ // if(jsonCacheObj.caches.length == 1){ // jsonCacheObj.caches.shift(); // $("h_feecache").value = ""; // jsonCacheObj = null // }else{ // jsonCacheObj.caches.splice(z,1); // $("h_feecache").value = JSON.stringify(jsonCacheObj); // // } // } // } // }else{ // commonGirdObj_fname.getGridObj().deleteRow(jsonCacheObj.caches[j].id); // jsonCacheObj.caches.splice(j,1); // $("h_feecache").value = JSON.stringify(jsonCacheObj); // } // break; // } // } // } // iCount++; // } // } // ReLoadGrid();//重新加载Grid // GridEditHandleReload();//重新生成编辑框事件 // ReCalculate(); // } //} function GridEditHandleReload(){ commonGirdObj_fname.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){ if(stage == 0){ return true; } if(stage == 1){ var selectedId = commonGirdObj_fname.getGridObj().getSelectedRowId(); var rowIndex = commonGirdObj_fname.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(stage == 2){ if(cInd == 2){//更改费用名称 if(nValue.trim() == ""){ alert("费用名称不能为空"); return false; } var iCount = 0; var rowIndex = commonGirdObj_fname.getGridObj().getRowIndex(rId); var newName = nValue.toString(); commonGirdObj_fname.getGridObj().cellByIndex(rowIndex,2).setValue(newName); var tempCache = $("h_feecache").value;//alert(tempCache); if(tempCache.trim() != ""){ jsonCacheObj = eval('(' + tempCache + ')'); 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 = "qdsk://?comp="+companyID+"&type="+typeName+"&dbid="+strInvoiceID+"&uid="+userID;//alert(printUrl); window.location.href = window.location.href; location.href = printUrl; } }else{ alert("没有要打印的报表"); return; } } //发票明细打印 function printInvoiceDetail(){ var strBillNO = ""; var typeName = ""; strBillNO = $("h_billno").value; if(strBillNO.trim() != ""){ var printUrl = ""; var companyID = ""; var typeName = "INVOICEDETAIL"; var dbSourceID = ""; var userID = ""; var url = ""; url = "../Reports/ReportService.aspx?handle=printinvoicedetail&billno="+strBillNO+"&val="+commonGirdObj_fname.newGuid(); typeName = "INVOICEDETAIL"; var loader = dhtmlxAjax.getSync(url); var reportVal = loader.xmlDoc.responseText; var reportObj = null; if(reportVal != ""){ reportObj = eval('(' + reportVal + ')'); if(reportObj.reports.length > 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; } } var docEle = function() { return document.getElementById(arguments[0]) || false; } function openNewDiv(_id) { var m = "mask"; if (docEle(_id)) document.removeChild(docEle(_id)); if (docEle(m)) document.removeChild(docEle(m)); // 新激活图层 var newDiv = document.createElement("div"); newDiv.id = _id; newDiv.style.position = "absolute"; newDiv.style.zIndex = "9999"; newDiv.style.width = "400px"; newDiv.style.height = "120px"; newDiv.style.top = "100px"; newDiv.style.left = (parseInt(document.body.scrollWidth) - 300) / 2 + "px"; // 屏幕居中 newDiv.style.background = "#EFEFEF"; newDiv.style.border = "1px solid #860001"; newDiv.style.padding = "5px"; var urlVal = "../feecodes/CurrencyAdapter.aspx?handle=drate&val="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; loader = null; var jsonCacheObj; var rmbRate = 0.0; var usdRate = 0.0; if(loadVal.length > 0){ jsonCacheObj = eval('(' + loadVal + ')'); if(jsonCacheObj != null){ for(var i = 0;i
币别汇率转换
1 RMB =
" + "
  USD
1 USD =
" + "
  RMB
"; document.body.appendChild(newDiv); // mask图层 var newMask = document.createElement("div"); newMask.id = m; newMask.style.position = "absolute"; newMask.style.zIndex = "1"; newMask.style.width = document.body.scrollWidth + "px"; newMask.style.height = document.body.scrollHeight + "px"; newMask.style.top = "0px"; newMask.style.left = "0px"; newMask.style.background = "#000"; newMask.style.filter = "alpha(opacity=40)"; newMask.style.opacity = "0.40"; document.body.appendChild(newMask); } function fomatFloat(src,pos){ return Math.round(src*Math.pow(10, pos))/Math.pow(10, pos); } function rateEnter(){ $("h_exrmbtousd").value = $("txt_exusd").value; $("h_exusdtormb").value = $("txt_exrmb").value; rateCancel(); if($("txt_total").value.trim() != ""){ var tempTotal = parseFloat($("txt_total").value.trim().substring($("txt_total").value.trim().indexOf("USD")+4,$("txt_total").value.trim().length - $("txt_total").value.trim().indexOf("USD")+1)) var exchangeRate = parseFloat($("h_exusdtormb").value); var totalAmount = moneyMath(tempTotal*exchangeRate); $("h_printamount").value = totalAmount; var tempCapital = convertCurrency(moneyMath(totalAmount).toString(),1); $("h_printcapital").value = tempCapital; } postEnterFee(); window.opener.location.href=window.opener.location.href; } //汇率设置取消 function rateCancel(){ document.body.removeChild(docEle("dvRate")); document.body.removeChild(docEle("mask")); } function exchangeCovert(sourceObj,targetObj,type){ //RMB换算成USD if(type == 1){ var rmbVal = clearNoNum(sourceObj.value); if(rmbVal.trim() == ""){ rmbVal = 1; } var usdVal = clearNoNum(targetObj.value); if(rmbVal == 0.0){ //sourceObj.value = rmbVal; //targetObj.value = 0;//$("h_oldexusd").value; return; } targetObj.value = fomatFloat(1/(usdVal*rmbVal),5); }else if(type == 2){ //USD换算成RMB var usdVal = sourceObj.value; if(usdVal.trim() == ""){ usdVal = 0; } var rmbVal = targetObj.value; targetObj.value = fomatFloat(1/usdVal,5); } } //获取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 refresh(){ $("btn_makeout").disabled = true; $("btn_makeout").onclick = clickNull; } function clickNull(){ } 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(); }