var commonGirdObj_fname; var commonGridObj_fee; var comboCustomer;//委托单位 var jsonCacheObj; var jsonLinkObj;//自定义名称关联关系 function $(id){ return document.getElementById(id); } function createInfo(){ initFeeName(); initComboCustomer(); initInvoice(); createComboCustomer(); } function initFeeName(){ var headerArgs_fname = new Array("","类型","费用名称","费用","type"); //width var widthArgs_fname = new Array("30","30","140","140","0"); //column align var colAlignArgs_fname = new Array("center","center","center","center","center"); //column sort var colSortArgs_fname = new Array("na","na","na","na","na"); //column type var colTypeArgs_fname = new Array("ch","ro","ed","ed","ro"); 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) { 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 < jsonCacheObj.caches.length; i++) { if (jsonCacheObj.caches[i].id == rId) { jsonCacheObj.caches[i].fname = nValue.trim(); iCount++; break; } } } //如果没有匹配的值,表示值是手动添加的,orig = 2 // if(iCount == 0){ // var newCache = jsonCacheObj.caches; // var currency = $("txt_currency").value.trim(); // var rowIndex = commonGirdObj_fname.getGridObj().getRowIndex(rId); // var money = ConvertToMoney(outputMoney(clearNoNum(commonGirdObj_fname.getGridObj().cellByIndex(rowIndex,3).getValue().toString()))); // newCache = {id:rId,type:"",bsno:"",cus:"",fname:newName,cur:currency,stl:money,cstl:money,ustl:0,orig:"2",oname:newName,ocstl:money}; // // jsonCacheObj.caches.push(newCache); // // $("h_feecache").value = JSON.stringify(jsonCacheObj); // } //alert(JSON.stringify(jsonCacheObj)); } else if (cInd == 3) { if (nValue.trim() == "") { alert("费用不能为空"); return false; } var iCount = 0; var rowIndex = commonGirdObj_fname.getGridObj().getRowIndex(rId); var money = ConvertToMoney(outputMoney(clearNoNum(nValue.toString()))); commonGirdObj_fname.getGridObj().cellByIndex(rowIndex, 3).setValue(money); var tempCache = $("h_feecache").value; if (tempCache.trim() != "") { jsonCacheObj = eval('(' + tempCache + ')'); for (var i = 0; i < jsonCacheObj.caches.length; i++) { if (jsonCacheObj.caches[i].id == rId) { jsonCacheObj.caches[i].cstl = nValue; iCount++; break; } } //如果没有匹配的值,表示值是手动添加的,orig = 2 // if(iCount == 0){//alert(JSON.stringify(jsonCacheObj)); // var newCache = jsonCacheObj.caches; // var currency = $("txt_currency").value.trim(); // var rowIndex = commonGirdObj_fname.getGridObj().getRowIndex(rId); // var newName = commonGirdObj_fname.getGridObj().cellByIndex(rowIndex,2).getValue().trim(); // newCache = {id:rId,type:"",bsno:"",cus:"",fname:newName,cur:currency,stl:money,cstl:money,ustl:0,orig:"2",oname:newName,ocstl:money}; // // jsonCacheObj.caches.push(newCache); // // $("h_feecache").value = JSON.stringify(jsonCacheObj); // } $("h_feecache").value = JSON.stringify(jsonCacheObj); } ReCalculate(); } //$("h_feecache").value = JSON.stringify(jsonCacheObj); return true; } }); commonGirdObj_fname.getGridObj().attachEvent("onCheckbox", function(rId,cInd,state){ for(var i=0;i 0){ // if(isVesselState == 1){ // $("txt_vesselvoyage").value = opSeaeObj.opinfo[0].vessel; // } // if(isCustnoState == 1){ // $("txt_custno").value = opSeaeObj.opinfo[0].custno; // } // if(isMoblnoState == 1){ // $("txt_mblno").value = opSeaeObj.opinfo[0].mblno; // } // if(isEteState == 1){ // $("txt_etd").value = opSeaeObj.opinfo[0].etd; // } // if(isPolState == 1){ // $("txt_pol").value = opSeaeObj.opinfo[0].pol; // } // if(isPodState == 1){ // $("txt_pod").value = opSeaeObj.opinfo[0].pod; // } // } // } //} function initInvoice(){ //折算币别 var applyCurrency = parseInt($("h_currency").value); //美元对人民币折算汇率 var usdToRMB = parseFloat($("h_usdtormb").value); //人民币对美元折算汇率 var rmbToUSD = parseFloat($("h_rmbtousd").value); //汇率 var rate = 0; if(applyCurrency == 1){ rate = usdToRMB; }else{ rate = rmbToUSD; } var cacheName = "";//cachename cacheName = "&cachename="+$("h_cachename").value; //获取发票合计数 var url = "InvoiceModifyGridSource.aspx?handle=getinvoiceapptotal&settlectype="+applyCurrency+"&rate="+rate+cacheName+"&guid="+commonGirdObj_fname.newGuid(); var loader = dhtmlxAjax.getSync(url); var totalList = loader.xmlDoc.responseText; var totalListObj = eval('(' + totalList + ')'); if(totalListObj != null){ if(applyCurrency == 1){ 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){ 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 } } var _customer = $("h_customername").value; getPayableName(_customer); } function getPayableName(customer){ var url = "InvoiceApplicationGridSource.aspx?handle=cuspayable&customer="+escape(customer)+"&guid="+commonGirdObj_fname.newGuid(); var loader = dhtmlxAjax.getSync(url); var clientInfo = loader.xmlDoc.responseText; var clientObj = eval('(' + clientInfo + ')'); if(clientObj.clients.length > 0){ if(clientObj.clients[0].pay1.trim() != ""){ $("h_payable").value = clientObj.clients[0].pay1; }else{ $("h_payable").value = clientObj.clients[0].pay2; } comboCustomer.setComboText($("h_payable").value); } } //function initInvoice(){ // //初始化值 // var jsonCacheObj = null; // var totalFee = 0.0; // var customerName = ""; // // var totalRmbFee = 0;//RMB费用合计 // var totalUsdFee = 0;//USD费用合计 // var totalOtherFee = 0;//其他费用合计 // var totalCutRmbFee = 0;//应付人民币费用 // var totalCutUsdFee = 0;//应付美元费用 // var totalMegerRmbFee = 0;//自定义名称人民币费用 // var totalMegerCutRmb = 0; // var totalMegerUsdFee = 0;//自定义名称美元费用 // var totalMegerCutUsd = 0; // // //折算币别 // var applyCurrency = parseInt($("h_currency").value); // //美元对人民币折算汇率 // var usdToRMB = parseFloat($("h_usdtormb").value); // //人民币对美元折算汇率 // var rmbToUSD = parseFloat($("h_rmbtousd").value); // //获取缓存数据 // var tempCache = $("h_feecache").value; // //是否有自定义名称 // var rename = $("h_rename").value.trim(); // //如果缓存内有数据,则进行操作 // if($("h_posted").value.trim() != ""){ // $("txt_custno").value = $("h_custno").value; // $("txt_vesselvoyage").value = $("h_vesselvoyage").value; // $("txt_mblno").value = $("h_mblno").value; // $("txt_etd").value = $("h_etd").value; // $("txt_pol").value = $("h_pol").value; // $("txt_pod").value = $("h_pod").value; // } // if($("h_posted").value.trim() == ""){ // if(tempCache != ""){//alert(tempCache); // jsonCacheObj = eval('(' + tempCache + ')'); // if(jsonCacheObj.caches.length > 0){ // var iCount = 0; // //如果是自定义名称,则只计算orig=3的值 // for(var i=0;i=1){ // url = "InvoiceApplicationGridSource.aspx?handle=opseae&bsno="+jsonCacheObj.caches[0].bsno; // }else{ // url = "InvoiceApplicationGridSource.aspx?handle=opseae&bsno="+jsonCacheObj.caches[i+1].bsno; // } // // var loader = dhtmlxAjax.getSync(url); // // var opInfo = loader.xmlDoc.responseText;//alert(opInfo); // var opSeaeObj = eval('(' + opInfo + ')'); // // if(opSeaeObj.opinfo.length > 0){ // if(isVesselState == 1){ // $("txt_vesselvoyage").value = opSeaeObj.opinfo[0].vessel; // } // if(isCustnoState == 1){ // $("txt_custno").value = opSeaeObj.opinfo[0].custno; // } // if(isMoblnoState == 1){ // $("txt_mblno").value = opSeaeObj.opinfo[0].mblno; // } // if(isEteState == 1){ // $("txt_etd").value = opSeaeObj.opinfo[0].etd; // } // if(isPolState == 1){ // $("txt_pol").value = opSeaeObj.opinfo[0].pol; // } // if(isPodState == 1){ // $("txt_pod").value = opSeaeObj.opinfo[0].pod; // } // } // } // // var tempCustomerName = ""; // if(i>=1){ // tempCustomerName = jsonCacheObj.caches[0].cus; // }else{ // tempCustomerName = jsonCacheObj.caches[i+1].cus; // } // // var clientObj = null; // if(tempCustomerName.trim() != ""){ // var url = "InvoiceApplicationGridSource.aspx?handle=cuspayable&customer="+escape(tempCustomerName); // var loader = dhtmlxAjax.getSync(url); // // var clientInfo = loader.xmlDoc.responseText; // var clientObj = eval('(' + clientInfo + ')'); // // if(clientObj.clients.length > 0){ // if(clientObj.clients[0].pay1.trim() != ""){ // $("h_payable").value = clientObj.clients[0].pay1; // }else{ // $("h_payable").value = clientObj.clients[0].pay2; // } // // comboCustomer.setComboText($("h_payable").value); // } // } // // if(applyCurrency == 1){ // var tempTotal = 0; // tempTotal = totalFee < 0 ? (totalFee * -1):totalFee; // var curCapital = convertCurrency(moneyMath(tempTotal).toString(),1); // // if(totalRmbFee < 0){ // $("txt_amountcapital").value = "负"+curCapital; // }else{ // $("txt_amountcapital").value = curCapital; // } // // var ShowTotal = ConvertToMoney(outputMoney(moneyMath(totalFee).toString())); // $("txt_total").value = "RMB "+ShowTotal; // // commonGirdObj_fname.getGridObj().addRow(jsonCacheObj.caches[i].id,["0","",jsonCacheObj.caches[i].fname,jsonCacheObj.caches[i].cstl],0); // return; // }else if(applyCurrency == 2){ // var tempTotal = 0; // tempTotal = totalFee < 0 ? (totalFee * -1):totalFee; // var curCapital = convertCurrency(moneyMath(tempTotal).toString(),2); // // if(totalRmbFee < 0){ // $("txt_amountcapital").value = "负"+curCapital; // }else{ // $("txt_amountcapital").value = curCapital; // } // // var ShowTotal = ConvertToMoney(outputMoney(moneyMath(totalFee).toString())); // $("txt_total").value = "USD "+ShowTotal; // // commonGirdObj_fname.getGridObj().addRow(jsonCacheObj.caches[i].id,["0","",jsonCacheObj.caches[i].fname,jsonCacheObj.caches[i].cstl],0); // return; // } // } // } // for(var i=0;i 0){ //// $("txt_vesselvoyage").value = opSeaeObj.opinfo[0].vessel; //// $("txt_custno").value = opSeaeObj.opinfo[0].custno; //// $("txt_mblno").value = opSeaeObj.opinfo[0].mblno; //// $("txt_etd").value = opSeaeObj.opinfo[0].etd; //// $("txt_pol").value = opSeaeObj.opinfo[0].pol; //// $("txt_pod").value = opSeaeObj.opinfo[0].pod; //// } // if(opSeaeObj.opinfo.length > 0){ // if(isVesselState == 1){ // $("txt_vesselvoyage").value = opSeaeObj.opinfo[0].vessel; // } // if(isCustnoState == 1){ // $("txt_custno").value = opSeaeObj.opinfo[0].custno; // } // if(isMoblnoState == 1){ // $("txt_mblno").value = opSeaeObj.opinfo[0].mblno; // } // if(isEteState == 1){ // $("txt_etd").value = opSeaeObj.opinfo[0].etd; // } // if(isPolState == 1){ // $("txt_pol").value = opSeaeObj.opinfo[0].pol; // } // if(isPodState == 1){ // $("txt_pod").value = opSeaeObj.opinfo[0].pod; // } // } // } // // var tempCustomerName = jsonCacheObj.caches[i].cus; // var clientObj = null; // if(tempCustomerName.trim() != ""){ // var url = "InvoiceApplicationGridSource.aspx?handle=cuspayable&customer="+escape(tempCustomerName); // var loader = dhtmlxAjax.getSync(url); // // var clientInfo = loader.xmlDoc.responseText; // var clientObj = eval('(' + clientInfo + ')'); // // if(clientObj.clients.length > 0){ // if(clientObj.clients[0].pay1.trim() != ""){ // $("h_payable").value = clientObj.clients[0].pay1; // }else{ // $("h_payable").value = clientObj.clients[0].pay2; // } // // comboCustomer.setComboText($("h_payable").value); // } // } // // } // // feeType = parseInt(jsonCacheObj.caches[i].type); // var cstl = 0; // //结算金额 // cstl = parseFloat(jsonCacheObj.caches[i].cstl);//alert(cstl); // //币别 // var cur = jsonCacheObj.caches[i].cur; // //如果自定义名称为空 表示显示费用明细 // if(rename == ""){ // if(feeType == 1){//应收费用 // var tempWorkOut = 0; // if(cur == "RMB"){ // if(applyCurrency == 2){ // tempWorkOut = moneyMath(cstl * rmbToUSD); // totalUsdFee += parseFloat(tempWorkOut);//美元累加 // }else{ // tempWorkOut = cstl; // totalRmbFee += parseFloat(tempWorkOut);//人民币累加 // } // }else if(cur == "USD"){ // if(applyCurrency == 1){ // tempWorkOut = moneyMath(cstl * usdToRMB); // totalRmbFee += parseFloat(tempWorkOut);//人民币累加 // }else{ // tempWorkOut = cstl.toString(); // totalUsdFee += parseFloat(tempWorkOut);//美元累加 // } // } // var ShowMoney = ConvertToMoney(outputMoney(tempWorkOut.toString())); // commonGirdObj_fname.getGridObj().addRow(jsonCacheObj.caches[i].id,["0","收",jsonCacheObj.caches[i].fname,ShowMoney],i); // //写入缓存 // jsonCacheObj.caches[i].cstl = tempWorkOut; // }else if(feeType == 2){//应付费用 // var tempWorkOut = 0; // if(cur == "RMB"){ // if(applyCurrency == 2){ // tempWorkOut = moneyMath(cstl * rmbToUSD); // totalCutUsdFee += parseFloat(tempWorkOut);//美元累减 // }else{ // tempWorkOut = cstl; // totalCutRmbFee += tempWorkOut;//人民币累减 // } // }else if(cur == "USD"){ // if(applyCurrency == 1){ // tempWorkOut = moneyMath(cstl * usdToRMB); // totalCutRmbFee += parseFloat(tempWorkOut);//人民币累减 // }else{ // tempWorkOut = cstl; // totalCutUsdFee += tempWorkOut;//美元累减 // } // } // var ShowMoney = ConvertToMoney(outputMoney(tempWorkOut.toString()));//alert(tempWorkOut); // commonGirdObj_fname.getGridObj().addRow(jsonCacheObj.caches[i].id,["0","付",jsonCacheObj.caches[i].fname,ShowMoney],i); // //写入缓存 // jsonCacheObj.caches[i].cstl = tempWorkOut; // } // }else{//有自定义名称,则将应收、应付置累加统计,然后合并到自定义名称费用内 // if(feeType == 1){//应收费用 // // // var tempWorkOut = 0; // if(cur == "RMB"){ // if(applyCurrency == 2){ // tempWorkOut = moneyMath(cstl * rmbToUSD); // totalUsdFee += parseFloat(tempWorkOut);//美元累加 // totalMegerUsdFee += parseFloat(tempWorkOut); // }else{ // tempWorkOut = cstl; // totalRmbFee += parseFloat(tempWorkOut);//人民币累加 // totalMegerRmbFee += parseFloat(tempWorkOut); // } // jsonCacheObj.caches[i].cstl = tempWorkOut; // }else if(cur == "USD"){ // if(applyCurrency == 1){ // tempWorkOut = moneyMath(cstl * usdToRMB); // totalRmbFee += parseFloat(tempWorkOut);//人民币累加 // totalMegerRmbFee += parseFloat(tempWorkOut); // }else{ // tempWorkOut = cstl.toString(); // totalUsdFee += parseFloat(tempWorkOut);//美元累加 // totalMegerUsdFee += parseFloat(tempWorkOut); // } // jsonCacheObj.caches[i].cstl = tempWorkOut; // } //// //写入缓存 //// jsonCacheObj.caches[i].cstl = tempWorkOut; // }else if(feeType == 2){//应付费用 // var tempWorkOut = 0; // if(cur == "RMB"){ // if(applyCurrency == 2){ // tempWorkOut = moneyMath(cstl * rmbToUSD); // totalCutUsdFee += parseFloat(tempWorkOut);//美元累减 // totalMegerCutUsd += parseFloat(tempWorkOut); // }else{ // tempWorkOut = cstl; // totalCutRmbFee += parseFloat(tempWorkOut);//人民币累减 // totalMegerCutRmb += parseFloat(tempWorkOut); // } // jsonCacheObj.caches[i].cstl = tempWorkOut; // }else if(cur == "USD"){ // if(applyCurrency == 1){ // tempWorkOut = moneyMath(cstl * usdToRMB); // totalCutRmbFee += parseFloat(tempWorkOut);//人民币累减 // totalMegerCutRmb += parseFloat(tempWorkOut); // }else{ // tempWorkOut = cstl; // totalCutUsdFee += parseFloat(tempWorkOut);//美元累减 // totalMegerCutUsd += parseFloat(tempWorkOut); // } // jsonCacheObj.caches[i].cstl = tempWorkOut; // } //// //写入缓存 //// jsonCacheObj.caches[i].cstl = tempWorkOut; // } // } // } // $("h_feecache").value = JSON.stringify(jsonCacheObj); // //循环遍历完成,统计数据信息 // if(applyCurrency == 1){ // //累加费用 // totalFee = (totalRmbFee - totalCutRmbFee); // // var tempTotal = 0; // tempTotal = totalFee < 0 ? (totalFee * -1):totalFee; // var curCapital = convertCurrency(moneyMath(tempTotal).toString(),1); // // if(totalFee < 0){ // $("txt_amountcapital").value = "负"+curCapital; // }else{ // $("txt_amountcapital").value = curCapital; // } // // var ShowTotal = ConvertToMoney(outputMoney(moneyMath(totalFee).toString())); // $("txt_total").value = "RMB "+ShowTotal; // // totalMegerRmbFee = (totalMegerRmbFee - totalMegerCutRmb); // if(totalMegerRmbFee != 0){ // var newCache = jsonCacheObj.caches; // var newCacheGuid = commonGirdObj_fname.newGuid(); // newCache = {id:newCacheGuid,type:"",bsno:"",cus:"",fname:rename,cur:"RMB", // stl:totalMegerRmbFee,cstl:totalMegerRmbFee,ustl:0,orig:"3",oname:rename,ocstl:totalMegerRmbFee}; // //缓存数据 // jsonCacheObj.caches.push(newCache); // $("h_feecache").value = JSON.stringify(jsonCacheObj); // var ShowMoney = ConvertToMoney(outputMoney(totalMegerRmbFee.toString())); // commonGirdObj_fname.getGridObj().addRow(newCacheGuid,["0","",rename,ShowMoney],0); // } // }else{ // //累加费用 // totalFee = (totalUsdFee - totalCutUsdFee); // // var tempTotal = 0; // tempTotal = totalFee < 0 ? (totalFee * -1):totalFee; // var curCapital = convertCurrency(moneyMath(tempTotal).toString(),2); // // if(totalFee < 0){ // $("txt_amountcapital").value = "负"+curCapital; // }else{ // $("txt_amountcapital").value = curCapital; // } // // var ShowTotal = ConvertToMoney(outputMoney(moneyMath(totalFee).toString())); // $("txt_total").value = "USD "+ShowTotal; // // var newCache = jsonCacheObj.caches; // totalMegerUsdFee = (totalMegerUsdFee - totalMegerCutUsd); // if(totalMegerUsdFee != 0){ // var newCache = jsonCacheObj.caches; // var newCacheGuid = commonGirdObj_fname.newGuid(); // newCache = {id:newCacheGuid,type:"",bsno:"",cus:"",fname:rename,cur:"USD",stl:totalMegerUsdFee,cstl:totalMegerUsdFee,ustl:0,orig:"3",oname:rename,ocstl:totalMegerUsdFee}; // //缓存数据 // jsonCacheObj.caches.push(newCache); // $("h_feecache").value = JSON.stringify(jsonCacheObj); // var ShowMoney = ConvertToMoney(outputMoney(totalMegerUsdFee.toString())); // commonGirdObj_fname.getGridObj().addRow(newCacheGuid,["0","",rename,ShowMoney],0); // } // } // } // }else{ // //如果缓存没有记录,则不进行Grid加载和费用统计操作 // } // }else{//如果是已经提交过申请了 // var jsonCacheObj = null;//alert(tempCache); // var tempCache = $("h_feecache").value; // if(tempCache.trim() != ""){ // jsonCacheObj = eval('(' + tempCache + ')'); // } // // var iCount = 0; // for(var q = 0;q 0){ // for(var q = 0;q 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(){ var strBSNO = ""; strBSNO = $("h_invoiceappid").value; var printUrl = ""; var companyID = ""; var typeName = "PrintInvoiceApplicationReport"; var dbSourceID = ""; var userID = ""; var url = "../Reports/ReportService.aspx?handle=printinvoiceapplication&invoiceid=" + strBSNO + "&val=" + commonGirdObj_fname.newGuid(); 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; var dfg = ""; } } else { alert("没有要打印的报表"); return; } } function saveApplication(){ $("h_action").value = 2;//保存申请 saveInfo(); } function postApplication(){ // $("h_action").value = 1;//提交申请 // // //提交申请以前先根据申请编号查看是否是已经保存的开票申请,如果是则自动将申请信息更新为已提交状态,否则继续执行提交申请操作 // if($("h_billno").value.trim() != ""){ // var strBillNO = $("h_billno").value.trim(); // var url = "InvoiceApplicationGridSource.aspx?billno="+strBillNO+"&handle=postapplybillno&uid="+commonGirdObj_fname.newGuid(); // var loader = dhtmlxAjax.getSync(url); // var postStatus = loader.xmlDoc.responseText; // // var status = parseInt(postStatus); // switch(status){ // case 1: // alert("开票申请提交成功"); // $("btn_apply").disabled = true;//提交申请按钮置灰不能点击 // $("txt_invoiceno").disabled = true;//发票号码不能填写 // $("txt_paycustomer").disabled = true;//付款单位不能填写 // break; // case -1: // saveInfo(); // break; // case -2: // alert("开票申请已提交,不能重复提交"); // break; // case -3: // alert("开票申请提交异常"); // break; // } // }else{ // saveInfo(); // } msgBox(); $("h_total").value = $("txt_total").value; $("h_etd").value = $("txt_etd").value; $("h_pod").value = $("txt_pod").value; $("h_pol").value = $("txt_pol").value; $("h_mblno").value = $("txt_mblno").value; $("h_custno").value = $("txt_custno").value; $("h_vesselvoyage").value = $("txt_vesselvoyage").value; $("h_payable").value = comboCustomer.getComboText().trim(); $("h_total").value = $("txt_total").value;//alert($("h_total").value); $("h_capitial").value = $("txt_amountcapital").value; $("h_enter").value = 1;//提交申请 postEnterFee(); } function saveInfo(){ //提交时发票号码不能为空 // if($("txt_invoiceno").value.trim() == ""){ // alert("发票号码不能为空,请填写"); // return; // } // //提交时付款单位不能为空 // if($("txt_invoiceno").value.trim() == ""){ // alert("付款单位不能为空,请填写"); // return; // } // var jsonListObj = null; // // var cacheBuffer = ""; // for(var i = 0;i 0){ // for(var i = 0;i = 0; j--) { if (jsonCacheObj.caches[j].id == rId) { if (jsonCacheObj.caches.length == 1) { jsonCacheObj.caches.shift(); gridObj.cellByIndex(j, 0).setValue(0); $("h_feecache").value = ""; //$("dvResult").innerHTML = ""; } else { jsonCacheObj.caches.splice(i, 1); gridObj.cellByIndex(j, 0).setValue(0); $("h_feecache").value = JSON.stringify(jsonCacheObj); //$("dvResult").innerHTML = JSON.stringify(jsonCacheObj); break; } } } iCount++; } } } } } function createNewCacheItem(cacheObj,typeName,tempValue,ObjGuid){ var tempCache = ""; //获取费用缓存数据 tempCache = $("h_list").value; if(tempCache.trim() == ""){ tempCache = $("h_feecache").value; } if (tempCache.trim() != "") { jsonCacheObj = eval('(' + tempCache + ')'); //遍历缓存数据 var iCount = 0; for(var i=0;i 360&&event.clientY <0||event.altKey) // { // return showConfirm(); // } //} //function showConfirm(){ // if(window.confirm("您确定要关闭")){ // return true; // }else{ // return false; // } //} function hasClass(ele,cls) { return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)')); } function addClass(ele,cls) { if (!this.hasClass(ele,cls)) ele.className += " "+cls; } function removeClass(ele,cls) { if (hasClass(ele,cls)) { var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)'); ele.className=ele.className.replace(reg,' '); } } function initComboCustomer(){ comboCustomer = dhtmlXComboFromSelect("sel_customer"); if($("h_payable").value.trim() != ""){ comboCustomer.setComboText($("h_payable").value); } if($("h_posted").value.trim() != ""){ if(parseInt($("h_posted").value.trim()) == 1){ comboCustomer.disable(true); } } } function createComboCustomer(){//委托单位 var jsonCacheObj = null; var tempCache = $("h_feecache").value;//alert(tempCache); if(tempCache.trim() != ""){ jsonCacheObj = eval('(' + tempCache + ')'); var customer = ""; customer = jsonCacheObj.caches[0].cus;//alert(customer); $("h_customer").value = customer;//alert($("h_customer").value); if(comboCustomer != null){ comboCustomer.loadXML("../FeeCodes/CRMClientInfo.aspx?mask=0&pos=0&name="+escape(customer)+"&type=1"); }else{ initComboCustomer(); comboCustomer.loadXML("../FeeCodes/CRMClientInfo.aspx?mask=0&pos=0&name="+escape(customer)+"&type=1"); } if($("h_payable").value != ""){ comboCustomer.setComboText($("h_payable").value); } //获取客户信息 comboCustomer.attachEvent("onSelectionChange", function(){ $("h_payable").value = comboCustomer.getComboText().trim();//alert($("h_customer").value); }); } // comboCustomer.attachEvent("onChange", function(){ // $("h_customer").value = comboCustomer.getComboText().trim();//alert($("h_customer").value); // }); } 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); } //让背景渐渐变暗 function showBackground(obj,endInt){ if(isIe){ obj.filters.alpha.opacity+=5; if(obj.filters.alpha.opacity" +"
" +"
" +"
" +" " +" " +"
" +" "; showMessageBox('消息接收人',messContent,objPos,350); } isFinish = true; return isFinish; } function saveApplication(){ $("h_enter").value = "1"; msgBox(); postEnterFee(); } 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 refresh(){ $("btn_apply").onclick = clickNull; } function clickNull(){ }