You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
D7QUANTAI/DSWeb/js/InvoiceMakeOutEdit.js

424 lines
16 KiB
JavaScript

10 months ago
var commonGridObj_invoiceedit;
var comboCustomer;//委托单位
var comboBank;//开户银行
var comboAccount;//银行账户
var comboCurrency;//币别
function $(id){
return document.getElementById(id);
}
function getObj(strClassName){
var tagArgs=document.getElementsByTagName("div");
var resultObj = null;
for(var i = 0;i<tagArgs.length;i++){
if(tagArgs[i].className == strClassName){
resultObj = tagArgs[i];
break;
}
}
return resultObj;
}
function createInfo(){
initComboCustomer();
initComboBank();
initComboAccount();
initComboCurrency();
createComboCurrency();
createComboBank();
createComboAccount();
createComboCustomer();
createOpSeae();
}
function showFee(){
createGrid();
}
function pushAction(obj){
if(obj.innerHTML == "+"){
obj.innerHTML = "-";
var parentObj = obj.parentElement;
var bsno = "";
//查看已经选中的行
var selectedObj = getObj("row_select");
if(selectedObj != null){
selectedObj.className = "row";
}
parentObj.className = "row_select";
var nodeObj = parentObj.getElementsByTagName("div");
if(nodeObj.length > 0){
for(var i=0;i<nodeObj.length;i++){
if(nodeObj[i].className == "row_id"){
$("h_bsno").value = nodeObj[i].innerHTML;//alert($("h_bsno").value);
}
}
}
$("dvFee").style.display = "";
createGrid();
}else{
obj.innerHTML = "+";
$("dvFee").style.display = "none";
}
}
function createOpSeae(){
var result = "";
//header
result += "<div class=\"head\">";
result += "<div class=\"head_begin\"></div>";
result += "<div>委托方式</div>";
result += "<div>主提单号</div>";
result += "<div>分提单号</div>";
result += "<div>委托编号</div>";
result += "<div>录入人</div>";
result += "<div class=\"head_end\">录入时间</div></div>";
var jsonCacheObj = null;
var tempCache = "";
tempCache = $("h_opcache").value;
//var dvOpSeae = getObj("row");
//var dvBottom = getObj("row lastrow");
var dvTable = getObj("table");
//var result = "";
//var bottomResult = "";
if(tempCache != null){
jsonCacheObj = eval('(' + tempCache + ')');
if(jsonCacheObj.opinfo.length){
if(jsonCacheObj.opinfo.length == 1){
result += "<div class=\"row lastrow\">"
result += "<div class=\"row_begin\" onclick=\"pushAction(this);\">+</div>";
result += "<div class=\"row_id\">"+jsonCacheObj.opinfo[0].bsno+"</div>";
result += "<div>"+jsonCacheObj.opinfo[0].bsstatus+"</div>";
result += "<div>"+jsonCacheObj.opinfo[0].mblno+"</div>";
result += "<div>"+jsonCacheObj.opinfo[0].hblno+"</div>";
result += "<div>"+jsonCacheObj.opinfo[0].custno+"</div>";
result += "<div>"+jsonCacheObj.opinfo[0].inputby+"</div>";
result += "<div class=\"row_end\">"+jsonCacheObj.opinfo[0].ctime+"</div>";
result += "</div>";
// dvOpSeae.style.display = "none";
// dvBottom.innerHTML = bottomResult;
}else{
for(var i = 0;i<jsonCacheObj.opinfo.length;i++){
if(i == jsonCacheObj.opinfo.length - 1){
result += "<div class=\"row lastrow\">"
result += "<div class=\"row_begin\" onclick=\"pushAction(this);\">+</div>";
result += "<div class=\"row_id\">"+jsonCacheObj.opinfo[i].bsno+"</div>";
result += "<div>"+jsonCacheObj.opinfo[i].bsstatus+"</div>";
result += "<div>"+jsonCacheObj.opinfo[i].mblno+"</div>";
result += "<div>"+jsonCacheObj.opinfo[i].hblno+"</div>";
result += "<div>"+jsonCacheObj.opinfo[i].custno+"</div>";
result += "<div>"+jsonCacheObj.opinfo[i].inputby+"</div>";
result += "<div class=\"row_end\">"+jsonCacheObj.opinfo[i].ctime+"</div>";
result += "</div>";
}else{
result += "<div class=\"row\">"
result += "<div class=\"row_begin\" onclick=\"pushAction(this);\">+</div>";
result += "<div class=\"row_id\">"+jsonCacheObj.opinfo[i].bsno+"</div>";
result += "<div>"+jsonCacheObj.opinfo[i].bsstatus+"</div>";
result += "<div>"+jsonCacheObj.opinfo[i].mblno+"</div>";
result += "<div>"+jsonCacheObj.opinfo[i].hblno+"</div>";
result += "<div>"+jsonCacheObj.opinfo[i].custno+"</div>";
result += "<div>"+jsonCacheObj.opinfo[i].inputby+"</div>";
result += "<div class=\"row_end\">"+jsonCacheObj.opinfo[i].ctime+"</div>";
result += "</div>";
}
}
//dvOpSeae.innerHTML = result;
}
//result += "</div>";
dvTable.innerHTML = result;
}
}
}
function createGrid(){
//header
var headerArgs_invoiceedit = new Array("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkAll(commonGridObj_invoiceedit)\" />","收/付","费用名称","结算单位","计费标准","单价","数量","金额","币别","汇率","开票金额","未开票金额");
//width
var widthArgs_invoiceedit = new Array("40","40","120","120","70","80","80","80","70","70","80","80");
//column align
var colAlignArgs_invoiceedit = new Array("center","center","center","center","center","center","center","center","center","center","center","center");
//column sort
var colSortArgs_invoiceedit = new Array("na","str","str","str","str","str","str","str","str","str","str","str");
//column type
var colTypeArgs_invoiceedit = new Array("ch","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro","ro");
commonGridObj_invoiceedit = new TGridCommon("mygrid_container_fee","form1",headerArgs_invoiceedit,widthArgs_invoiceedit,colAlignArgs_invoiceedit,colSortArgs_invoiceedit,colTypeArgs_invoiceedit);
commonGridObj_invoiceedit.setResponseUrl("InvoiceApplicationGridSource.aspx");
var invoiceGID = $("h_invoiceid").value;
var invoiceBSNO = $("h_bsno").value;
commonGridObj_invoiceedit.setRequest("InvoiceApplicationGridSource.aspx?handle=invoiceeditfee&invoiceid="+invoiceGID+"&bsno="+invoiceBSNO);
commonGridObj_invoiceedit.setSourceType("json");
commonGridObj_invoiceedit.setSkin("xp");
commonGridObj_invoiceedit.setImageUrl("../images/");
commonGridObj_invoiceedit.initGrid();
commonGridObj_invoiceedit.bind();
commonGridObj_invoiceedit.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){
if(stage == 0){
if(cInd == 2 || cInd == 3){
return false;
}else{
return true;
}
}
});
}
function initComboCustomer(){
comboCustomer = dhtmlXComboFromSelect("sel_customer");
}
function initComboBank(){
comboBank = dhtmlXComboFromSelect("sel_bank");
}
function initComboAccount(){
comboAccount = dhtmlXComboFromSelect("sel_account");
}
function initComboCurrency(){
comboCurrency = dhtmlXComboFromSelect("sel_currency");
}
function createComboCurrency(){
if($("h_currency").value.trim() != ""){
comboCurrency.setComboText($("h_currency").value);
comboCurrency.disable(true);
}
}
function createComboBank(){
if($("h_bank").value.trim() != ""){
comboBank.setComboText($("h_bank").value);
comboBank.disable(true);
}
}
function createComboAccount(){
if($("h_account").value.trim() != ""){
comboAccount.setComboText($("h_account").value);
comboAccount.disable(true);
}
}
function createComboCustomer(){
if($("h_invoicecus").value.trim() != ""){
comboCustomer.setComboText($("h_invoicecus").value);
comboCustomer.disable(true);
}
}
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
//生成税控
function invoiceAdapter(){
var strInvoiceID = "";
var typeName = "";
strInvoiceID = $("h_invoiceid").value;
var printUrl = ""; var companyID = ""; var typeName = "QDSK"; var dbSourceID = ""; var userID = "";
var url = "";
url = "../Reports/ReportService.aspx?handle=printinvoice&invoiceid="+strInvoiceID+"&val="+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 = "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="+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;
}
}
//获取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();
}
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<jsonCacheObj.drate.length;i++){
if(jsonCacheObj.drate[i].code == "RMB"){
rmbRate = parseFloat(jsonCacheObj.drate[i].drate);
}else if(jsonCacheObj.drate[i].code == "USD"){
usdRate = parseFloat(jsonCacheObj.drate[i].drate);
}
}
}
}
//人民币对美元汇率
var rmbToUsd = fomatFloat(1 / usdRate,5);
var usdToRmb = usdRate;
$("h_exrmbtousd").value = rmbToUsd;
$("h_exusdtormb").value = usdToRmb;
newDiv.innerHTML = "<table><tr><td colspan=\"5\" height=\"20px\"><div>币别汇率转换</div></td></tr><tr><td><div>1 RMB = </div></td><td><input type=\"hidden\" id=\"h_oldexusd\" value=\""+rmbToUsd+"\"/><input type=\"text\" id=\"txt_exusd\" width=\"40px\" value=\""+rmbToUsd+"\" onkeyup=\"exchangeCovert(this,txt_exrmb,1)\"/></td>"
+ "<td><div>&nbsp;&nbsp;USD</div></td><td width=\"15px\"></td><td><input type=\"button\" id=\"btn_enter\" value=\"确定\" class=\"btn\" onclick=\"rateEnter()\"/><td></tr><tr><td><div>1 USD = </div></td>"
+ "<td><input type=\"hidden\" id=\"h_oldexrmb\" value=\""+usdToRmb+"\"/><input type=\"text\" id=\"txt_exrmb\" width=\"40px\" value=\""+usdToRmb+"\" onkeyup=\"exchangeCovert(this,txt_exusd,2)\"/></td><td><div>&nbsp;&nbsp;RMB</div></td><td width=\"15px\"></td><td><input type=\"button\" id=\"btn_cancel\" value=\"取消\" class=\"btn\" onclick=\"rateCancel()\"/></td></tr></table>";
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 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);
}
}