var commonGridObj_order;
var commonGridObj_fee;
var comboCustomer;//委托单位
var comboVessel;//船名
var comboVoyno;//航次
var comboBsType;//业务类型
var comboFeeName;//费用名称
var comboFeeType;//费用类型
var comboCurrency;//币别
var isLoad = 0;
var sel_val = new Array;
function $(id){
return document.getElementById(id);
}
function createOrder(){
previous_id = "";
//header
var headerArgs_order = new Array("", "业务类别", "委托单位", "委托编号", "主提单号", "分提单号", "报关单号", "备案清单号");
//width
var widthArgs_order = new Array("40","100","100","100","100","100","100","100");
//column align
var colAlignArgs_order = new Array("center","center","center","center","center","center","center","center");
//column sort
var colSortArgs_order = new Array("na","str","str","str","str","str","str","str");
//column type
var colTypeArgs_order = new Array("ch","ro","ro","ro","ro","ro","ro","ro");
commonGridObj_order = new TGridCommon("mygrid_container_order","form1",headerArgs_order,widthArgs_order,colAlignArgs_order,colSortArgs_order,colTypeArgs_order);
commonGridObj_order.setResponseUrl("SettlementGridSourceApp.aspx");
commonGridObj_order.setRequest("SettlementGridSourceApp.aspx?handle=orderlist");
commonGridObj_order.setSourceType("json");
commonGridObj_order.setSkin("xp");
commonGridObj_order.setImageUrl("../images/");
commonGridObj_order.initGrid();
//commonGridObj_order.bind();
//遍历当前委托信息信息,如果已经记录到缓存中,则自动将前端选择框置1
setTimeout(function(){
var tempCache = $("h_feecache").value;
var jsonCacheObj = null;
if(tempCache.trim() != ""){
jsonCacheObj = eval('(' + tempCache + ')');
for(var i=0;i 0){
// var tempCache = $("h_feecache").value;
// var jsonCacheObj;
// $("ck_allfee").checked = 1;
// for(var i = 0;i < count;i++){
// if(tempCache.trim() == ""){
// var rowId = gridObj.getRowId(i);
// var rowIndex = gridObj.getRowIndex(rowId);
// var cacheBuffer = "";
// cacheBuffer += "{";
// cacheBuffer += "\"id\":\""+rowId+"\",";
// var feeType = gridObj.cellByIndex(rowIndex,1).getValue() == "收"?1:2;
// cacheBuffer += "\"type\":"+feeType+",";
// cacheBuffer += "\"bsno\":\""+rId+"\",";
// cacheBuffer += "\"cus\":\""+gridObj.cellByIndex(rowIndex,2).getValue()+"\",";
// cacheBuffer += "\"fname\":\""+gridObj.cellByIndex(rowIndex,3).getValue()+"\",";
// cacheBuffer += "\"cur\":\""+gridObj.cellByIndex(rowIndex,4).getValue()+"\",";
// cacheBuffer += "\"stl\":\""+gridObj.cellByIndex(rowIndex,5).getValue()+"\",";//应结
// cacheBuffer += "\"cstl\":\""+gridObj.cellByIndex(rowIndex,6).getValue()+"\",";//本次结算
// cacheBuffer += "\"ustl\":\""+gridObj.cellByIndex(rowIndex,7).getValue()+"\"";//未结
// cacheBuffer += "}";
//
// var result = "";
// result += "{\"caches\":[";
// result += cacheBuffer;
// result += "]}";
//
// tempCache = result;
// jsonCacheObj = eval('(' + result + ')');
//
// gridObj.cellByIndex(i,0).setValue(1);
// }else{
//
// if(jsonCacheObj == null)
// jsonCacheObj = eval('(' + tempCache + ')');
//
// var isExist = false;
// var rowId = gridObj.getRowId(i);
// var rowIndex = gridObj.getRowIndex(rowId);
// for(var j=0;j= 0;i--){
// if(jsonCacheObj.caches[i].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;
// }
// }
// }
// }
// },20);
// Statistics();
// //$("dvResult").innerHTML = $("h_feecache").value
// }
// },100);
// });
}
function createFeeList(){
//header
var headerArgs_order = new Array("","D/C","结算单位","费用名称","币别","应结","本次结算","未结");
//width
var widthArgs_order = new Array("40","25","100","100","40","70","70","70");
//column align
var colAlignArgs_order = new Array("center","center","center","center","center","center","center","center");
//column sort
var colSortArgs_order = new Array("na","str","str","str","str","str","str","str");
//column type
var colTypeArgs_order = new Array("ch","ro","ro","ro","ro","ro","ed","ro");
commonGridObj_fee = new TGridCommon("mygrid_container_fee","form1",headerArgs_order,widthArgs_order,colAlignArgs_order,colSortArgs_order,colTypeArgs_order);
commonGridObj_fee.setResponseUrl("InvoiceApplicationGridSource.aspx");
var _bsno = commonGridObj_fee.$("h_bsno").value;//alert(_bsno);
var _feename = comboFeeName.getSelectedValue();
var _feetype = comboFeeType.getSelectedValue();//comboFeeType.getComboText().trim();
var _currency = comboCurrency.getSelectedValue();
var _customer = comboCustomer.getComboText().trim();
_feename = _feename == null ? "":_feename;
_feetype = _feetype == null?"":_feetype;
_currency = _currency == null?"":_currency;
var searchJson = "";
//begin
searchJson +="{";
searchJson += "[";
searchJson += "\"cus\":\""+_customer+"\",";
searchJson += "\"fnm\":\""+_feename+"\",";
searchJson += "\"fty\":\""+_feetype+"\",";
searchJson += "\"cur\":\"" + _currency + "\",";
searchJson += "\"amount1\":\"" + $("txt_amount1").value.trim() + "\",";
searchJson += "\"amount2\":\"" + $("txt_amount2").value.trim() + "\"";
searchJson += "]";
searchJson +="}";//alert(searchJson);
var cacheName = "";
if($("h_cachename").value.trim() != ""){
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}
commonGridObj_fee.setRequest("InvoiceApplicationGridSource.aspx?handle=orderfee&bsno="+_bsno+"&fsearch="+escape(searchJson)+cacheName);
commonGridObj_fee.setSourceType("json");
commonGridObj_fee.setSkin("xp");
commonGridObj_fee.setImageUrl("../images/");
commonGridObj_fee.initGrid();
if(_bsno != ""){
commonGridObj_fee.bind();
//遍历当前打开的费用信息,如果已经记录到缓存中,则自动将前端选择框置1
setTimeout(function(){
var tempCache = $("h_feecache").value;
var jsonCacheObj = null;
if(tempCache.trim() != ""){
jsonCacheObj = eval('(' + tempCache + ')');
for(var i=0;i 1){
cacheTotalObj = eval('(' + cacheVal.trim() + ')');
if(cacheTotalObj.totals.length > 0){
$("dvTotalRecvRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].recvrmb.toString());
$("dvTotalRecvUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].recvusd.toString());
$("dvTotalPayRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].payrmb.toString());
$("dvTotalPayUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].payusd.toString());
$("dvTotalSettleRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].totalrmb.toString());
$("dvTotalSettleUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].totalusd.toString());
$("dvTotalRecvRMBVal").style.color = "#F00";
$("dvTotalRecvUSDVal").style.color = "#F00";
$("dvTotalPayRMBVal").style.color = "#090";
$("dvTotalPayUSDVal").style.color = "#090";
state = parseInt(cacheTotalObj.totals[0].state);
}
}
if(state < 0){
commonGridObj_fee.getGridObj().cellByIndex(rowIndex,0).setValue(0);
alert("没有权限添加费用");
}
// var gridObj = commonGridObj_fee.getGridObj();
// var rowIndex = gridObj.getRowIndex(rId);
//
// var isCheck = gridObj.cellByIndex(rowIndex,0).getValue();
// var type = gridObj.cellByIndex(rowIndex,1).getValue();
// var tempCache = $("h_feecache").value;
//
// //Is Exist Same GID
// var result = "";
//
// if(isCheck == 1){
// var orderObjRowID = commonGridObj_order.getGridObj().getSelectedRowId();
// var orderObjRowIndex = commonGridObj_order.getGridObj().getRowIndex(orderObjRowID);
//
// commonGridObj_order.getGridObj().cellByIndex(orderObjRowIndex,0).setValue(1);
// var cacheBuffer = "";
// //init jsonObj
// if(tempCache.trim() == ""){
// cacheBuffer += "{";
// cacheBuffer += "\"id\":\""+rId+"\",";
// var rowIndex = gridObj.getRowIndex(rId);
// var feeType = gridObj.cellByIndex(rowIndex,1).getValue() == "收"?1:2;
// cacheBuffer += "\"type\":"+feeType+",";
// //cacheBuffer += "\"type\":\""+gridObj.cellByIndex(rowIndex,1).getValue()+"\",";
// cacheBuffer += "\"bsno\":\""+commonGridObj_order.getGridObj().getSelectedRowId()+"\",";
// cacheBuffer += "\"cus\":\""+gridObj.cellByIndex(rowIndex,2).getValue()+"\",";
// cacheBuffer += "\"fname\":\""+gridObj.cellByIndex(rowIndex,3).getValue()+"\",";
// cacheBuffer += "\"cur\":\""+gridObj.cellByIndex(rowIndex,4).getValue()+"\",";
// cacheBuffer += "\"stl\":\""+gridObj.cellByIndex(rowIndex,5).getValue()+"\",";//应结
// cacheBuffer += "\"cstl\":\""+gridObj.cellByIndex(rowIndex,6).getValue()+"\",";//本次结算
// cacheBuffer += "\"ustl\":\""+gridObj.cellByIndex(rowIndex,7).getValue()+"\",";//未结
// cacheBuffer += "\"orig\":\"1\",";//原始类型
// cacheBuffer += "\"oname\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,3).getValue()+"\",";//更改费用名称
// cacheBuffer += "\"ocstl\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,6).getValue()+"\"";//更改费用值
// cacheBuffer += "}";
//
// result += "{\"caches\":[";
// result += cacheBuffer;
// result += "]}";
//
// jsonCacheObj = eval('(' + result + ')');
//
// $("h_feecache").value = JSON.stringify(jsonCacheObj);
// //$("dvResult").innerHTML = JSON.stringify(jsonCacheObj);
// }else{
//
// jsonCacheObj = eval('(' + tempCache + ')');
//
// var isExist = false;
// for(var i=0;i= 0;i--){
//
// if(jsonCacheObj.caches[i].id == rId){
// if(jsonCacheObj.caches.length == 1){
// IsLastFeeCheckOut(jsonCacheObj.caches[i].bsno);
// jsonCacheObj.caches.shift();
// $("h_feecache").value = "";
// }else{
// jsonCacheObj.caches.splice(i,1);
// $("h_feecache").value = JSON.stringify(jsonCacheObj);
// break;
// }
// }
//
// }
//
// Statistics();
// //$("dvResult").innerHTML = $("h_feecache").value
// }
// Statistics();
});
commonGridObj_fee.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){
if(stage == 0){
return true;
}
if(stage == 1){
var selectedId = commonGridObj_fee.getGridObj().getSelectedRowId();
var rowIndex = commonGridObj_fee.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_fee.getGridObj().getSelectedRowId();
var rowIndex = commonGridObj_fee.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,5).getValue()))));
cstl = parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_fee.getGridObj().cellByIndex(rowIndex,6).getValue()))));
ustl = parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_fee.getGridObj().cellByIndex(rowIndex,7).getValue()))));
// var rustl = 0.0;
// if(cstl == ustl){
// rustl = ustl;
// }else{
//
//
// if(ustl == oldCstl){
// rustl = ustl;
// }else{
// rustl = oldCstl + ustl;
// }
// }
//
// var newStl = 0.0;
//
// newStl = rustl - cstl;
//
// if(newStl < 0 && newStl == 0){
// commonGridObj_fee.getGridObj().cellByIndex(rowIndex,7).setValue(ConvertToMoney(outputMoney(rustl.toString())));
// return false;
// }
var rustl = 0.0;
var newCstl = parseFloat(nValue);
var oldCstl = parseFloat(oValue);
if(newCstl < 0){
return false;
}else if(newCstl > oldCstl && newCstl != (oldCstl + ustl)){
return false;
}else if(newCstl == 0){
return false;
}
var newStl = 0.0;
if(oldCstl != ustl){
newStl = (ustl+oldCstl) - newCstl;
}else{
newStl = ustl - newCstl;
}
commonGridObj_fee.getGridObj().cellByIndex(rowIndex,0).setValue(1);
commonGridObj_fee.getGridObj().cellByIndex(rowIndex,6).setValue(ConvertToMoney(outputMoney(cstl.toString())));
if(newStl == 0){
newStl = cstl;
}
commonGridObj_fee.getGridObj().cellByIndex(rowIndex,7).setValue(ConvertToMoney(outputMoney(newStl.toString())));
var _customer = comboCustomer.getComboText().trim();
var _billno = $("txt_billNO").value.trim();
var _begin_time = $("txt_beginTime").value.trim();
var _end_time = $("txt_endTime").value.trim();
var _vessel = comboVessel.getComboText().trim();
var _voyno = comboVoyno.getComboText().trim();
var _bstype = comboBsType.getSelectedValue();//comboBsType.getComboText().trim();
//var _debitno = $("txt_debitno").value.trim();
var _feename = comboFeeName.getSelectedValue();
var _feetype = comboFeeType.getSelectedValue();//comboFeeType.getComboText().trim();
var _currency = comboCurrency.getSelectedValue();
//var _customer = comboCustomer.getComboText().trim();
_feename = _feename == null ? "":_feename;
_feetype = _feetype == null?"":_feetype;
_currency = _currency == null?"":_currency;
var searchJson = "";
//begin
searchJson +="{";
searchJson += "[";
searchJson += "\"cus\":\""+_customer+"\",";
searchJson += "\"bno\":\""+_billno+"\",";
searchJson += "\"bt\":\""+_begin_time+"\",";
searchJson += "\"et\":\""+_end_time+"\",";
searchJson += "\"ves\":\""+_vessel+"\",";
searchJson += "\"voy\":\""+_voyno+"\",";
searchJson += "\"bty\":\""+_bstype+"\",";
searchJson += "\"deno\":\"\",";
//searchJson += "\"cus\":\""+_customer+"\",";
searchJson += "\"fnm\":\""+_feename+"\",";
searchJson += "\"fty\":\""+_feetype+"\",";
searchJson += "\"cur\":\""+_currency+"\",";
//searchJson += "\"ise\":\""+_is_settled+"\"";
//searchJson += "\"fty\":\""+_feetype+"\",";
//searchJson += "\"cur\":\""+_currency+"\"";
searchJson += "\"amount1\":\"" + $("txt_amount1").value.trim() + "\",";
searchJson += "\"amount2\":\"" + $("txt_amount2").value.trim() + "\"";
searchJson += "]";
searchJson +="}";
var cacheName = "";
var bsnoCacheName = "";
var totalCacheName = "";
if($("h_cachename").value.trim() != ""){
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}else{
$("h_cachename").value = commonGridObj_order.newGuid();
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}
if($("h_bsnocache").value.trim() != ""){
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}else{
$("h_bsnocache").value = commonGridObj_order.newGuid();
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}
if($("h_totalcache").value.trim() != ""){
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}else{
$("h_totalcache").value = commonGridObj_order.newGuid();
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}
var url = "";
var strBSNO = "";
strBSNO = $("h_bsno").value;
var state = 0;
url = "InvoiceApplicationGridSource.aspx?handle=changefee"+cacheName+bsnoCacheName+totalCacheName+"&feeid="+rId+"&search="+escape(searchJson)+"&cstl="+cstl+"&ustl="+newStl+"&uid="+commonGridObj_fee.newGuid()+"&do=import"+"&bsno="+strBSNO;
var loader = dhtmlxAjax.getSync(url);
var cacheTotal = "";
var cacheTotalObj = null;
var cacheVal = loader.xmlDoc.responseText;//alert(opInfo);
if(cacheVal.trim().length > 1){
cacheTotalObj = eval('(' + cacheVal.trim() + ')');
if(cacheTotalObj.totals.length > 0){
$("dvTotalRecvRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].recvrmb.toString());
$("dvTotalRecvUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].recvusd.toString());
$("dvTotalPayRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].payrmb.toString());
$("dvTotalPayUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].payusd.toString());
$("dvTotalSettleRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].totalrmb.toString());
$("dvTotalSettleUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].totalusd.toString());
$("dvTotalRecvRMBVal").style.color = "#F00";
$("dvTotalRecvUSDVal").style.color = "#F00";
$("dvTotalPayRMBVal").style.color = "#090";
$("dvTotalPayUSDVal").style.color = "#090";
state = cacheTotalObj.totals[0].state;
}
}
if(state < 0){
commonGridObj_fee.getGridObj().cellByIndex(rowIndex,0).setValue(0);
alert("没有权限修改添加费用");
return false;
}else{
return true;
}
}
});
isLoad = 1;
}
function createComboCustomer(){//委托单位
comboCustomer = dhtmlXComboFromSelect("sel_customer");
comboCustomer.loadXML("../FeeCodes/WebCrmClientAdapter.aspx?mask=0");
comboCustomer.attachEvent("onChange", function(){
comboCustomer.setComboText($("h_customer").value);
});
comboCustomer.attachEvent("onBlur", function(){
var s1 = comboCustomer.getComboText().trim();
var s2 = s1.indexOf("|");
if(s2>0){
s2=s2+2;
}
var s3 = s1.substring(s2);
if(s2>0){
comboCustomer.setComboText(s3);
$("h_customer").value=s3;
}
else
{
comboCustomer.setComboText($("h_customer").value);
}
});
comboCustomer.setComboText($("h_customer").value);
comboCustomer.attachEvent("onKeyPressed", function(keyCode){
if(keyCode!="8"){
var arrayArg = new Array();
setTimeout(function(){
var filterCount = 0;
var is = -1;
var ishd = $("h_customer").value.trim();
if("" != comboCustomer.getComboText().trim()){
while("undefined" != typeof comboCustomer.getOptionByIndex(filterCount)){
var comboValue = comboCustomer.getOptionByIndex(filterCount).text.toUpperCase();//.value;
var enterValue = comboCustomer.getComboText().trim().toUpperCase();
$("h_customer").value = comboCustomer.getComboText().trim().toUpperCase();
if(comboValue.indexOf(enterValue) == 0){
comboCustomer.selectOption(filterCount,true,true);
is=filterCount;
break;
}
++filterCount;
}
if(is==-1){
$("h_customer").value = ishd;
alert("无此内容,请重新选择!");
}
}
},10);
}
});
comboCustomer.attachEvent("onSelectionChange", function(){
$("h_customer").value = comboCustomer.getComboText().trim();
});
}
function createComboVessel(){
comboVessel = dhtmlXComboFromSelect("sel_vessel");
comboVessel.loadXML("../FeeCodes/TCodeVesselAdapter.aspx?mask=0&pos=0&uid="+newGuid());
var _vessel = $("h_vessel").value;
comboVoyno = dhtmlXComboFromSelect("sel_voyno");
if(_vessel != ""){
comboVoyno.loadXML("../FeeCodes/TCodeVoynoAdapter.aspx?mask=0&pos=0&strVESSEL="+_vessel+"&uid="+newGuid());
}
comboVessel.setComboText($("h_vessel").value);
comboVessel.attachEvent("onKeyPressed", function(keyCode){
if(keyCode!="8"){
var arrayArg = new Array();
setTimeout(function(){
var filterCount = 0;
if("" != comboVessel.getComboText().trim()){
while("undefined" != typeof comboVessel.getOptionByIndex(filterCount)){
var comboValue = comboVessel.getOptionByIndex(filterCount).text.toUpperCase();//.value;
var enterValue = comboVessel.getComboText().toUpperCase();
$("h_vessel").value = comboVessel.getComboText().toUpperCase();
if(comboValue.indexOf(enterValue) == 0){
comboVessel.selectOption(filterCount,true,true);
$("h_vessel").value = comboVessel.getComboText().trim();
break;
}
++filterCount;
}
}
},10);
}
});
comboVessel.attachEvent("onBlur", function(){
$("h_vessel").value = comboVessel.getComboText().trim();
$("h_voyno").value = "";
createComboVoyno();
});
comboVessel.attachEvent("onChange", function(){
comboVessel.setComboText($("h_vessel").value);
});
comboVessel.attachEvent("onSelectionChange", function(){
$("h_vessel").value = comboVessel.getComboText().trim();
});
}
function createComboVoyno(){
var _vessel;
try
{
_vessel = comboVessel.getSelectedValue().trim();//$("hd_comboVESSEL").value;
}
catch(e)
{
_vessel="";
}
if(_vessel != ""){
comboVoyno.loadXML("../FeeCodes/TCodeVoynoAdapter.aspx?mask=0&pos=0&strVESSEL="+_vessel);
comboVoyno.setComboText($("h_voyno").value);
}
comboVoyno.attachEvent("onChange", function(){
comboVoyno.setComboText($("h_voyno").value);
});
comboVoyno.attachEvent("onKeyPressed", function(keyCode){
if(keyCode!="8"){
var arrayArg = new Array();
setTimeout(function(){
var filterCount = 0;
if("" != comboVoyno.getComboText().trim()){
while("undefined" != typeof comboVoyno.getOptionByIndex(filterCount)){
var comboValue = comboVoyno.getOptionByIndex(filterCount).text.toUpperCase();//.value;
var enterValue = comboVoyno.getComboText().trim().toUpperCase();
$("h_voyno").value = comboVoyno.getComboText().trim().toUpperCase();
if(comboValue.indexOf(enterValue) == 0){
comboVoyno.selectOption(filterCount,true,true);
break;
}
++filterCount;
}
}
},10);
}
});
comboVoyno.attachEvent("onSelectionChange", function(){
$("h_voyno").value = comboVoyno.getComboText().trim();
});
}
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
//Get Guid
var newGuid = function(){
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 initCombos(){
createComboVessel();//船名
createComboVoyno();//航次
createComboCustomer();//结算单位
createComboBsType();//业务类型
createComboFeeName();//费用名称
createComboFeeType();//费用类型
createComboCurrency();//币别
}
function checkAll(gridObj){
// var checkBoxId = "";
// var jsonCacheObj = null;
//获取缓存信息
//BSNO
var bsnoVal = $("h_bsno").value;
var _customer = comboCustomer.getComboText().trim();
var _billno = $("txt_billNO").value.trim();
var _begin_time = $("txt_beginTime").value.trim();
var _end_time = $("txt_endTime").value.trim();
var _vessel = comboVessel.getComboText().trim();
var _voyno = comboVoyno.getComboText().trim();
var _bstype = comboBsType.getSelectedValue();//comboBsType.getComboText().trim();
//var _debitno = $("txt_debitno").value.trim();
var _feename = comboFeeName.getSelectedValue();
var _feetype = comboFeeType.getSelectedValue();//comboFeeType.getComboText().trim();
var _currency = comboCurrency.getSelectedValue();
//var _customer = comboCustomer.getComboText().trim();
_feename = _feename == null ? "":_feename;
_feetype = _feetype == null?"":_feetype;
_currency = _currency == null?"":_currency;
//var _feetype = comboFeeType.getSelectedValue();//comboFeeType.getComboText().trim();
//var _currency = comboCurrency.getComboText().trim();
var searchJson = "";
//begin
searchJson +="{";
searchJson += "[";
searchJson += "\"cus\":\""+_customer+"\",";
searchJson += "\"bno\":\""+_billno+"\",";
searchJson += "\"bt\":\""+_begin_time+"\",";
searchJson += "\"et\":\""+_end_time+"\",";
searchJson += "\"ves\":\""+_vessel+"\",";
searchJson += "\"voy\":\""+_voyno+"\",";
searchJson += "\"bty\":\""+_bstype+"\",";
searchJson += "\"deno\":\"\",";
//searchJson += "\"cus\":\""+_customer+"\",";
searchJson += "\"fnm\":\""+_feename+"\",";
searchJson += "\"fty\":\""+_feetype+"\",";
searchJson += "\"cur\":\""+_currency+"\",";
//searchJson += "\"ise\":\""+_is_settled+"\"";
//searchJson += "\"fty\":\""+_feetype+"\",";
//searchJson += "\"cur\":\""+_currency+"\"";
searchJson += "\"amount1\":\"" + $("txt_amount1").value.trim() + "\",";
searchJson += "\"amount2\":\"" + $("txt_amount2").value.trim() + "\"";
searchJson += "]";
searchJson +="}";
var cacheName = "";
var bsnoCacheName = "";
var totalCacheName = "";
//先获取缓存名称,如果没有缓存名称,则自动创建新的缓存名称
if($("h_cachename").value.trim() != ""){
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}else{
$("h_cachename").value = commonGridObj_order.newGuid();
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}
if($("h_bsnocache").value.trim() != ""){
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}else{
$("h_bsnocache").value = commonGridObj_order.newGuid();
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}
if($("h_totalcache").value.trim() != ""){
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}else{
$("h_totalcache").value = commonGridObj_order.newGuid();
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}
var url = "";
// var rowIndex = commonGridObj_fee.getGridObj().getRowIndex(rId);
var checkBox = $("ck_allfee").checked;
if(checkBox == 1){
url = "InvoiceApplicationGridSource.aspx?handle=checkallfee&search="+escape(searchJson)+cacheName+bsnoCacheName+totalCacheName+"&bsno="+bsnoVal+"&op=check&uid="+commonGridObj_order.newGuid()+"&do=import";
}else{
url = "InvoiceApplicationGridSource.aspx?handle=checkallfee&search="+escape(searchJson)+cacheName+bsnoCacheName+totalCacheName+"&bsno="+bsnoVal+"&op=uncheck&uid="+commonGridObj_order.newGuid()+"&do=import";
}
var loader = dhtmlxAjax.getSync(url);
var cacheTotal = "";
var cacheTotalObj = null;
var cacheVal = loader.xmlDoc.responseText;//alert(opInfo);
if(cacheVal.trim().length > 1){
cacheTotalObj = eval('(' + cacheVal.trim() + ')');
if(cacheTotalObj.totals.length > 0){
$("dvTotalRecvRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].recvrmb.toString());
$("dvTotalRecvUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].recvusd.toString());
$("dvTotalPayRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].payrmb.toString());
$("dvTotalPayUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].payusd.toString());
$("dvTotalSettleRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].totalrmb.toString());
$("dvTotalSettleUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].totalusd.toString());
$("dvTotalRecvRMBVal").style.color = "#F00";
$("dvTotalRecvUSDVal").style.color = "#F00";
$("dvTotalPayRMBVal").style.color = "#090";
$("dvTotalPayUSDVal").style.color = "#090";
}
}
createFeeList();
$("ck_allfee").checked = checkBox;
// if(gridObj == commonGridObj_fee){
// checkBoxId = "ck_allfee";
// var checkStatus = $(checkBoxId).checked;
// //如果费用全选按钮是选中状态,则将所有费用选中并缓存
// if(checkStatus){
// //如果费用Grid不为空
// if(commonGridObj_fee.getGridObj().getRowsNum() > 0){
// for(var i=0;i 0){
// for(var j = 0;j< commonGridObj_fee.getGridObj().getRowsNum();j++){
// var feeID = commonGridObj_fee.getGridObj().getRowId(j);
// //遍历缓存数据,清除费用
// for(var i = jsonCacheObj.caches.length-1;i >= 0;i--){
// if(jsonCacheObj.caches[i].id == feeID){
// if(jsonCacheObj.caches.length == 1){
// jsonCacheObj.caches.shift();
// //费用选中状态置0
// commonGridObj_fee.getGridObj().cellByIndex(j,0).setValue(0);
// jsonCacheObj = null;
// $("h_feecache").value = "";
// }else{
// jsonCacheObj.caches.splice(i,1);
// //费用选中状态置0
// commonGridObj_fee.getGridObj().cellByIndex(j,0).setValue(0);
// $("h_feecache").value = JSON.stringify(jsonCacheObj);
// }
// break;
// }
// }
// }
// }
// Statistics();
// }
// },60);
// }
// }
}
function createComboBsType(){
comboBsType = dhtmlXComboFromSelect("sel_bstype");
}
function createComboFeeName(){
comboFeeName = dhtmlXComboFromSelect("sel_feename");
comboFeeName.loadXML("../FeeCodes/FeeCodeService.aspx?mask=0&pos=0&handle=all");
comboFeeName.attachEvent("onChange", function(){
comboFeeName.setComboText($("h_feename").value);
});
comboFeeName.attachEvent("onBlur", function(){
var s1 = comboFeeName.getComboText().trim();
var s2 = s1.indexOf("|");
if(s2>0){
s2=s2+2;
}
var s3 = s1.substring(s2);
if(s2>0){
comboFeeName.setComboText(s3);
$("h_feename").value=s3;
}
else
{
comboCustomer.setComboText($("h_feename").value);
}
});
comboFeeName.setComboText($("h_feename").value);
comboFeeName.attachEvent("onKeyPressed", function(keyCode){
if(keyCode!="8"){
var arrayArg = new Array();
setTimeout(function(){
var filterCount = 0;
var is = -1;
var ishd = $("h_feename").value.trim();
if("" != comboFeeName.getComboText().trim()){
while("undefined" != typeof comboFeeName.getOptionByIndex(filterCount)){
var comboValue = comboFeeName.getOptionByIndex(filterCount).text.toUpperCase();//.value;
var enterValue = comboFeeName.getComboText().trim().toUpperCase();
$("h_feename").value = comboFeeName.getComboText().trim().toUpperCase();
if(comboValue.indexOf(enterValue) == 0){
comboFeeName.selectOption(filterCount,true,true);
is=filterCount;
break;
}
++filterCount;
}
if(is==-1){
$("h_feename").value = ishd;
alert("无此内容,请重新选择!");
}
}
},10);
}
});
comboFeeName.attachEvent("onSelectionChange", function(){
$("h_feename").value = comboFeeName.getComboText().trim();
});
}
function createComboFeeType(){
comboFeeType = dhtmlXComboFromSelect("sel_feetype");
}
function createComboCurrency(){
comboCurrency = dhtmlXComboFromSelect("sel_currency");
}
function searchOrder(){
// //重新搜索后将缓存数据清除
// $("h_feecache").value = "";
// //并重新计算合计费用
// Statistics();
// commonGridObj_order.bind();
var _customer = comboCustomer.getComboText().trim();
var _billno = $("txt_billNO").value.trim();
var _begin_time = $("txt_beginTime").value.trim();
var _end_time = $("txt_endTime").value.trim();
var _vessel = comboVessel.getComboText().trim();
var _voyno = comboVoyno.getComboText().trim();
var _bstype = comboBsType.getSelectedValue();//comboBsType.getComboText().trim();
//var _debitno = $("txt_debitno").value.trim();
var _feename = comboFeeName.getSelectedValue();
var _feetype = comboFeeType.getSelectedValue();//comboFeeType.getComboText().trim();
var _currency = comboCurrency.getSelectedValue();
//var _customer = comboCustomer.getComboText().trim();
var _accdate = $("txt_Accdate").value.trim(); //会计期间
_feename = _feename == null ? "":_feename;
_feetype = _feetype == null?"":_feetype;
_currency = _currency == null?"":_currency;
//var _feetype = comboFeeType.getSelectedValue();//comboFeeType.getComboText().trim();
//var _currency = comboCurrency.getComboText().trim();
var borrowFee = "noPay"; //查询是否包含预付信息
var checkboxFee = document.getElementById("chec_FeeKind").checked;
if (checkboxFee == true) {
borrowFee = "borrowPay";
}
var searchJson = "";
//begin
searchJson +="{";
searchJson += "[";
searchJson += "\"cus\":\""+_customer+"\",";
searchJson += "\"bno\":\""+_billno+"\",";
searchJson += "\"bt\":\""+_begin_time+"\",";
searchJson += "\"et\":\""+_end_time+"\",";
searchJson += "\"ves\":\""+_vessel+"\",";
searchJson += "\"voy\":\""+_voyno+"\",";
searchJson += "\"bty\":\""+_bstype+"\",";
searchJson += "\"deno\":\"\",";
//searchJson += "\"cus\":\""+_customer+"\",";
searchJson += "\"fnm\":\""+_feename+"\",";
searchJson += "\"fty\":\""+_feetype+"\",";
searchJson += "\"cur\":\""+_currency+"\",";
//searchJson += "\"ise\":\""+_is_settled+"\"";
//searchJson += "\"fty\":\""+_feetype+"\",";
//searchJson += "\"cur\":\""+_currency+"\"";
searchJson += "\"amount1\":\"" + $("txt_amount1").value.trim() + "\",";
searchJson += "\"amount2\":\"" + $("txt_amount2").value.trim() + "\",";
searchJson += "\"accDate\":\""+_accdate+"\"";
searchJson += "]";
searchJson +="}";
var cacheName = "";
if($("h_cachename").value.trim() != ""){
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}
commonGridObj_order.setRequest("InvoiceApplicationGridSource.aspx?handle=ordersearch&search=" + escape(searchJson) + cacheName + "&uid=" + commonGridObj_order.newGuid() + "&do=import&BorrowFee="+borrowFee);
commonGridObj_order.initGrid();
commonGridObj_order.bind();
// //遍历当前委托信息信息,如果已经记录到缓存中,则自动将前端选择框置1
// setTimeout(function(){
// var tempCache = $("h_feecache").value;
// var jsonCacheObj = null;
// if(tempCache.trim() != ""){
// jsonCacheObj = eval('(' + tempCache + ')');
//
// for(var i=0;i 1){
cacheTotalObj = eval('(' + cacheVal.trim() + ')');
if(cacheTotalObj.totals.length > 0){
$("dvTotalRecvRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].recvrmb.toString());
$("dvTotalRecvUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].recvusd.toString());
$("dvTotalPayRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].payrmb.toString());
$("dvTotalPayUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].payusd.toString());
$("dvTotalSettleRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].totalrmb.toString());
$("dvTotalSettleUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].totalusd.toString());
$("dvTotalRecvRMBVal").style.color = "#F00";
$("dvTotalRecvUSDVal").style.color = "#F00";
$("dvTotalPayRMBVal").style.color = "#090";
$("dvTotalPayUSDVal").style.color = "#090";
state = parseInt(cacheTotalObj.totals[0].state);
}
}
createFeeList();
if(state < 0){
commonGridObj_order.getGridObj().cellByIndex(orderRowIndex,0).setValue(0);
alert("没有权限添加费用");
}
// $("h_bsno").value = rId;
// createFeeList();
//
// var orderRowIndex = commonGridObj_order.getGridObj().getRowIndex(rId);
//
// var checkBox = commonGridObj_order.getGridObj().cellByIndex(orderRowIndex,0).getValue();
// //当选中委托信息中某项选中时,自动将委托信息下的所有费用信息选中,并缓存数据
// if(checkBox == 1){
// setTimeout(function(){
// //先查看费用Grid是否已经加载完成
// if(commonGridObj_fee.getGridObj().getRowsNum() > 0){
// var jsonCacheObj = null
// //将费用Grid全选复选框
// $("ck_allfee").checked = 1;
// //遍历整个费用Grid将所有费用默认选中,并记录到页面缓存内
// for(var k=0;k 0){
// for(var j = 0;j< commonGridObj_fee.getGridObj().getRowsNum();j++){
// var feeID = commonGridObj_fee.getGridObj().getRowId(j);
// //遍历缓存数据,清除费用
// for(var i = jsonCacheObj.caches.length-1;i >= 0;i--){
// if(jsonCacheObj.caches[i].id == feeID){
// if(jsonCacheObj.caches.length == 1){
// jsonCacheObj.caches.shift();
// //费用选中状态置0
// commonGridObj_fee.getGridObj().cellByIndex(j,0).setValue(0);
// jsonCacheObj = null;
// $("h_feecache").value = "";
// }else{
// jsonCacheObj.caches.splice(i,1);
// //费用选中状态置0
// commonGridObj_fee.getGridObj().cellByIndex(j,0).setValue(0);
// $("h_feecache").value = JSON.stringify(jsonCacheObj);
// }
// break;
// }
// }
// }
// }
// Statistics();
// }
// },60);
// }
});
if(commonGridObj_fee != null){
createFeeList();
}
}
//Cache Settlement Fee
function saveSettleFee(){
var settleFee = "";
settleFee +="{";
settleFee += "[";
settleFee += "]";
settleFee +="}";
}
function saveSelectFee(gid,type){
}
function getCacheFee(){
var cacheBuffer = $("h_feecache").value;
}
function Statistics(){
var strCache = $("h_feecache").value;
if(strCache != ""){
var jsonCacheObj = eval('(' + strCache + ')');
var recvFeeRMB = 0.0;
var recvFeeUSD = 0.0;
var payFeeRMB = 0.0;
var payFeeUSD = 0.0;
var totalRMBFee = 0.0;
var totalUSDFee = 0.0;
for(var i = 0;i < jsonCacheObj.caches.length;i++){
var feeType = jsonCacheObj.caches[i].type;
var currency = jsonCacheObj.caches[i].cur;
var stl = parseFloat(jsonCacheObj.caches[i].stl);//应结
var cstl = parseFloat(jsonCacheObj.caches[i].cstl);//本次结算
var ustl = parseFloat(jsonCacheObj.caches[i].ustl);//未结
if(feeType == 1){
if(currency == "RMB"){
recvFeeRMB += cstl;
}else if(currency == "USD"){
recvFeeUSD += cstl;
}
}else{
if(currency == "RMB"){
payFeeRMB += cstl;
}else if(currency == "USD"){
payFeeUSD += cstl;
}
}
}
totalRMBFee = recvFeeRMB - payFeeRMB;
totalUSDFee = recvFeeUSD - payFeeUSD;
$("dvTotalRecvRMBVal").innerHTML = outputMoney(recvFeeRMB.toString());
$("dvTotalRecvUSDVal").innerHTML = outputMoney(recvFeeUSD.toString());
$("dvTotalPayRMBVal").innerHTML = outputMoney(payFeeRMB.toString());
$("dvTotalPayUSDVal").innerHTML = outputMoney(payFeeUSD.toString());
$("dvTotalSettleRMBVal").innerHTML = outputMoney(totalRMBFee.toString());
$("dvTotalSettleUSDVal").innerHTML = outputMoney(totalUSDFee.toString());
$("dvTotalRecvRMBVal").style.color = "#F00";
$("dvTotalRecvUSDVal").style.color = "#F00";
$("dvTotalPayRMBVal").style.color = "#090";
$("dvTotalPayUSDVal").style.color = "#090";
if(totalRMBFee <= 0){
$("dvTotalSettleRMBVal").style.color = "#090";
}else{
$("dvTotalSettleRMBVal").style.color = "#F00";
}
if(totalUSDFee <= 0){
$("dvTotalSettleUSDVal").style.color = "#090";
}else{
$("dvTotalSettleUSDVal").style.color = "#F00";
}
}
else{
$("dvTotalRecvRMBVal").innerHTML = 0;
$("dvTotalRecvUSDVal").innerHTML = 0;
$("dvTotalPayRMBVal").innerHTML = 0;
$("dvTotalPayUSDVal").innerHTML = 0;
$("dvTotalSettleRMBVal").innerHTML = 0;
$("dvTotalSettleUSDVal").innerHTML = 0;
}
}
function outputMoney(number) {
number= number.replace(/\,/g,"");
if (isNaN(number)||number=="") return "";
number = Math.round( number*100) /100;
if(number<0)
return '-'+outputDollars(Math.floor(Math.abs(number)-0) + '') + outputCents(Math.abs(number) - 0);
else
return outputDollars(Math.floor(number-0) + '') + outputCents(number - 0);
}
function outputDollars(number)
{
if (number.length<= 3)
return (number == '' ? '0' : number);
else
{
var mod = number.length%3;
var output = (mod == 0 ? '' : (number.substring(0,mod)));
for (i=0 ; i< Math.floor(number.length/3) ; i++)
{
if ((mod ==0) && (i ==0))
output+= number.substring(mod+3*i,mod+3*i+3);
else
output+= ',' + number.substring(mod+3*i,mod+3*i+3);
}
return (output);
}
}
function outputCents(amount)
{
amount = Math.round( ( (amount) - Math.floor(amount) ) *100);
return (amount<10 ? '.0' + amount : '.' + amount);
}
function postEnterFee(){
/*var myForm = document.createElement("form");
myForm.method="post" ;
myForm.action = "gridshow.aspx" ;
var myInput = document.createElement("input") ;
myInput.setAttribute("name", "abc") ;
myInput.setAttribute("value", "bbs");
myForm.appendChild(myInput) ;
document.body.appendChild(myForm) ;
myForm.submit() ;
document.body.removeChild(myForm) ;*/
var myForm = document.getElementById("form1");
myForm.submit() ;
}
function importFee(){
var cacheName = "";
var bsnoCacheName = "";
var totalCacheName = "";
//先获取缓存名称,如果没有缓存名称,则自动创建新的缓存名称
if($("h_cachename").value.trim() != ""){
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}else{
$("h_cachename").value = commonGridObj_order.newGuid();
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}
if($("h_bsnocache").value.trim() != ""){
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}else{
$("h_bsnocache").value = commonGridObj_order.newGuid();
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}
if($("h_totalcache").value.trim() != ""){
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}else{
$("h_totalcache").value = commonGridObj_order.newGuid();
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}
//先验证要提交开票申请的缓存数据
var validateUrl = "";
var ckBoxRmb = $("ck_rmb").checked;
var ckBoxUsd = $("ck_usd").checked;
var currency = "";
if(ckBoxRmb){
currency = "¤cy=RMB";//按人民币结算
}else if(ckBoxUsd){
currency = "¤cy=USD";//按美元结算
}
validateUrl = "InvoiceApplicationGridSource.aspx?handle=validatepost"+cacheName+currency+"&uid="+commonGridObj_order.newGuid();
var loader = dhtmlxAjax.getSync(validateUrl);
var validateVal = loader.xmlDoc.responseText;
var validateObj = null;
if(validateVal.trim() != ""){
validateObj = eval('(' + validateVal + ')');
if(validateObj.validates.length > 0){
var isDiffCustomerName = parseInt(validateObj.validates[0].diffcust);
if(isDiffCustomerName == 1){
alert("不能多个结算单位同时申请开票,请修改");
return;
}
var isMaxLine = parseInt(validateObj.validates[0].ismaxline);
if(isMaxLine == 1){
if($("ck_rename").checked){
if($("txt_rename").value.trim() != ""){
}else{
alert("请填写自定义名称");
return;
}
}else{
//如果超过开票最大明细则提示使用自定义名称
alert("开票明细超过发票最大行数-"+validateObj.validates[0].maxline+" 请减少开票明细或者使用自定义名称");
return;
}
}
var isDiffCurrency = parseInt(validateObj.validates[0].diffcurr);
if(isDiffCurrency == 1){
//如果存在不同的币别,则弹出汇率设置表
openNewDiv("dvRate");//设置汇率
}else if(isDiffCurrency == 0){
var postSessionName = "";
if($("h_postsession").value.trim() != ""){//alert($("h_postsession").value);
postSessionName = "&postsession="+$("h_postsession").value.trim();
}else{
$("h_postsession").value = commonGridObj_order.newGuid();
postSessionName = "&postsession="+$("h_postsession").value.trim();
}
var postSessionUrl = "";
if($("ck_rename").checked && $("txt_rename").value.trim() != ""){
var rename = "";
rename = "&rename="+escape($("txt_rename").value.trim());
postSessionUrl = "InvoiceApplicationGridSource.aspx?handle=postInvoiceApp"+cacheName+bsnoCacheName+totalCacheName+postSessionName+currency+rename+"&uid="+commonGridObj_order.newGuid();
var loader = dhtmlxAjax.getSync(postSessionUrl);
var cacheVal = loader.xmlDoc.responseText;
var postStatus = parseInt(cacheVal);
if(postStatus == 1){
var openSet = "height=460, width=800, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-440)/2 + ",Left= "+(screen.width-800)/2
var openType = "_blank";
var settleCurrency = "";
if($("ck_rmb").checked){
settleCurrency = "1";
}else if($("ck_usd").checked){
settleCurrency = "2";
}
//var includeOpInfo = $("ck_autoaddinfo").checked ? 1:0;
var ckCustNo = $("ck_custno").checked ? 1:0;
var ckVesselState = $("ck_vessel").checked ? 1:0;
var ckMblno = $("ck_mblno").checked ? 1:0;
var ckEtd = $("ck_etd").checked ? 1:0;
var ckPol = $("ck_pol").checked ? 1:0;
var ckPod = $("ck_pod").checked ? 1:0;
var detail = $("ck_detaillist").checked ? 1:0;
var txtRename = $("txt_rename").value;
var rename = $("ck_rename").checked ? txtRename:"";
var openUrl = "InvoiceMakeOutModify.aspx?currency="+settleCurrency+"&uex=1&rex=1&postsession="+$("h_postsession").value
+ "&cno="+ckCustNo+"&vel="+ckVesselState+"&mbl="+ckMblno+"&etd="+ckEtd+"&pol="+ckPol+"&pod="+ckPod
+"&rn="+rename+"&detail="+detail+"&handle=import";
$("h_sessionid").value = 0;
//window.open (openUrl,openType,openSet);
var parentObj = window.parent.opener.location;//alert(parentObj);
var oldUrl = parentObj.href;
var newUrl = oldUrl.substring(0,oldUrl.lastIndexOf("/"))+"/"+openUrl;
window.parent.opener.location.href = window.parent.opener.location.href;
parentObj.href = newUrl;
window.close();
}
}else{
postSessionUrl = "InvoiceApplicationGridSource.aspx?handle=postInvoiceApp"+cacheName+bsnoCacheName+totalCacheName+postSessionName+currency+"&uid="+commonGridObj_order.newGuid();
var loader = dhtmlxAjax.getSync(postSessionUrl);
var cacheVal = loader.xmlDoc.responseText;
var postStatus = parseInt(cacheVal);
if(postStatus == 1){
setTimeout(function(){
var openSet = "height=460, width=800, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-440)/2 + ",Left= "+(screen.width-800)/2
var openType = "_blank";
var settleCurrency = "";
if($("ck_rmb").checked){
settleCurrency = "1";
}else if($("ck_usd").checked){
settleCurrency = "2";
}
//var includeOpInfo = $("ck_autoaddinfo").checked ? 1:0;
var ckCustNo = $("ck_custno").checked ? 1:0;
var ckVesselState = $("ck_vessel").checked ? 1:0;
var ckMblno = $("ck_mblno").checked ? 1:0;
var ckEtd = $("ck_etd").checked ? 1:0;
var ckPol = $("ck_pol").checked ? 1:0;
var ckPod = $("ck_pod").checked ? 1:0;
var detail = $("ck_detaillist").checked ? 1:0;
var txtRename = $("txt_rename").value;
var rename = $("ck_rename").checked ? txtRename:"";
var openUrl = "InvoiceMakeOutModify.aspx?currency="+settleCurrency+"&uex=1&rex=1&postsession="+$("h_postsession").value//+"&opinfo="+includeOpInfo
+ "&cno="+ckCustNo+"&vel="+ckVesselState+"&mbl="+ckMblno+"&etd="+ckEtd+"&pol="+ckPol+"&pod="+ckPod
+"&rn="+rename+"&detail="+detail+"&handle=import";
$("h_sessionid").value = 0;
//window.open (openUrl,openType,openSet);
var parentObj = window.parent.opener.location;//alert(parentObj);
var oldUrl = parentObj.href;
var newUrl = oldUrl.substring(0,oldUrl.lastIndexOf("/"))+"/"+openUrl;
window.parent.opener.location.href = window.parent.opener.location.href;
parentObj.href = newUrl;
window.close();
},100);
}
}
}
}
}
}
//function openDialog(){
// var session = $("h_sessionid").value;
// var ckBoxRmb = $("ck_rmb").checked;
// var ckBoxUsd = $("ck_usd").checked;
// if(session == "1"){
// if(ckBoxRmb == 1 || ckBoxUsd == 1){
// var tempCache = $("h_feecache").value;
// jsonCacheObj = eval('(' + tempCache + ')');
//
// var iCount = 0;
// for(var i = 0;i 0){
// openNewDiv("dvRate");//设置汇率
// }else{
// var openSet = "height=440, width=1200, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-440)/2 + ",Left= "+(screen.width-1200)/2
// var openType = "_blank";
// //var feeObj_val = $("dvResult").innerHTML;
// var settleCurrency = "";
//
// if($("ck_rmb").checked){
// settleCurrency = "1";
// }else if($("ck_usd").checked){
// settleCurrency = "2";
// }
// var includeOpInfo = $("ck_autoaddinfo").checked ? 1:0;
// var detail = $("ck_detaillist").checked ? 1:0;
// var txtRename = $("txt_rename").value;
// var rename = $("ck_rename").checked ? txtRename:"";
//
// var openUrl = "InvoiceMakeOutModify.aspx?currency="+settleCurrency+"&uex=1&rex=1&obj=ivimport&opinfo="+includeOpInfo+"&rn="+rename+"&detail="+detail+"&handle=import";
// $("h_sessionid").value = 0;
// //window.open (openUrl,openType,openSet);
// //var parentObj = window.parent.location;//alert(parentObj);
// var parentObj = window.parent.opener.location;//alert(parentObj);
// var oldUrl = parentObj.href;
//
// var newUrl = oldUrl.substring(0,oldUrl.lastIndexOf("/"))+"/"+openUrl;
//
// window.parent.opener.location.href = window.parent.opener.location.href;
// parentObj.href = newUrl;
// setTimeout(function(){
// window.close();
// },200);
// }
//// var openSet = "height=460, width=1024, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-710)/2 + ",Left= "+(screen.width-800)/2
//// var openType = "_blank";
//// //var feeObj_val = $("dvResult").innerHTML;
//// var settleCurrency = "";
////
//// if($("ck_rmb").checked){
//// settleCurrency = "1";
//// }else if($("ck_usd").checked){
//// settleCurrency = "2";
//// }else{
//// settleCurrency = "3";
//// }
// //var openUrl = "DoSettlement.aspx?currency="+settleCurrency+"&uex="+$("h_exrmbtousd").value+"&rex="+$("txt_exrmb").value+"&obj=feesession";
// }else{
// var openSet = "height=440, width=1200, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-440)/2 + ",Left= "+(screen.width-1200)/2
// var openType = "_blank";
// var feeObj_val = $("dvResult").innerHTML;
// var settleCurrency = "";
//
// if($("ck_rmb").checked){
// settleCurrency = "1";
// }else if($("ck_usd").checked){
// settleCurrency = "2";
// }else{
// settleCurrency = "3";
// }
// var includeOpInfo = $("ck_autoaddinfo").checked ? 1:0;
// var detail = $("ck_detaillist").checked ? 1:0;
// var txtRename = $("txt_rename").value;
// var rename = $("ck_rename").checked ? txtRename:"";
//
// var openUrl = "InvoiceMakeOutModify.aspx?currency="+settleCurrency+"&uex=1&rex=1&obj=ivappsession&opinfo="+includeOpInfo+"&rn="+rename+"&detail="+detail;
// $("h_sessionid").value = 0;//alert(openUrl);
// //window.open (openUrl,openType,openSet);
//
// //alert(window.parent.opener.location.href);
// var parentObj = window.parent.opener.location;//alert(parentObj);
// var oldUrl = parentObj.href;
//
// var newUrl = oldUrl.substring(0,oldUrl.lastIndexOf("/"))+"/"+openUrl;
//
// window.parent.opener.location.href = window.parent.opener.location.href;
// parentObj.href = newUrl;
// setTimeout(function(){
// window.close();
// },200);
// }
// }
//}
function ConvertToMoney(strObj){
var result = strObj.replace(",","");
return result;
}
function clearNoNum(valObj)
{
//先把非数字的都替换掉,除了数字和.
valObj = valObj.replace(/[^\d.]/g,"");
//必须保证第一个为数字而不是.
valObj = valObj.replace(/^\./g,"");
//保证只有出现一个.而没有多个.
valObj = valObj.replace(/\.{2,}/g,".");
//保证.只出现一次,而不能出现两次以上
valObj = valObj.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
return valObj;
}
function isObjNaN(Obj){
if(Obj.toString().toLowerCase() == "nan"){
return 0;
}else{
return Obj;
}
}
function doCheck(clickObj,otherObj){
if($(clickObj).checked){
$(otherObj).checked = 0;
}else{
$(otherObj).checked = 1;
}
if(clickObj == "ck_rename" && $(clickObj).checked){
var url = "../FeeCodes/AttributeService.aspx?handle=getinvoicerename&guid="+commonGridObj_order.newGuid();;
var loader = dhtmlxAjax.getSync(url);
var cacheVal = loader.xmlDoc.responseText;
$("txt_rename").value = cacheVal;
}else{
$("txt_rename").value = "";
}
}
var docEle = function() {
return document.getElementById(arguments[0]) || false;
}
function openNewDiv(_id) {
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 rateCancel(){
// $("h_exrmbtousd").value = $("h_oldexusd").value;
// $("h_exusdtormb").value = $("h_oldexrmb").value;
//
// var openSet = "height=440, width=1200, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-440)/2 + ",Left= "+(screen.width-1200)/2
// var openType = "_blank";
// //var feeObj_val = $("dvResult").innerHTML;
// var settleCurrency = "";
//
// if($("ck_rmb").checked){
// settleCurrency = "1";
// }else if($("ck_usd").checked){
// settleCurrency = "2";
// }else{
// settleCurrency = "3";
// }
//
// document.body.removeChild(docEle("dvRate"));
// document.body.removeChild(docEle("mask"));
//
// setTimeout(function(){
// var includeOpInfo = $("ck_autoaddinfo").checked ? 1:0;
// var detail = $("ck_detaillist").checked ? 1:0;
// var txtRename = $("txt_rename").value;
// var rename = $("ck_rename").checked ? txtRename:"";
//
//
// var openUrl = "InvoiceMakeOutModify.aspx?currency="+settleCurrency+"&uex="+$("h_exrmbtousd").value+"&rex="+$("txt_exrmb").value+"&obj=ivimport&opinfo="+includeOpInfo+"&rn="+rename+"&detail="+detail+"&handle=import";
// $("h_sessionid").value = 0;
//
// var parentObj = window.parent.opener.location;//alert(parentObj);
// var oldUrl = parentObj.href;
//
// var newUrl = oldUrl.substring(0,oldUrl.lastIndexOf("/"))+"/"+openUrl;
//
// window.parent.opener.location.href = window.parent.opener.location.href;
// parentObj.href = newUrl;
// window.close();
// },50);
// window.open (openUrl,openType,openSet);
document.body.removeChild(docEle("dvRate"));
document.body.removeChild(docEle("mask"));
}
//汇率设置确定
function rateEnter(){
$("h_exrmbtousd").value = $("txt_exusd").value;
$("h_exusdtormb").value = $("txt_exrmb").value;
// var openSet = "height=440, width=800, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-440)/2 + ",Left= "+(screen.width-800)/2
// var openType = "_blank";
// //var feeObj_val = $("dvResult").innerHTML;
// var settleCurrency = "";
//
// if($("ck_rmb").checked){
// settleCurrency = "1";
// }else if($("ck_usd").checked){
// settleCurrency = "2";
// }else{
// settleCurrency = "3";
// }
//
// var includeOpInfo = $("ck_autoaddinfo").checked ? 1:0;
// var detail = $("ck_detaillist").checked ? 1:0;
// var txtRename = $("txt_rename").value;
// var rename = $("ck_rename").checked ? txtRename:"";
//
// var openUrl = "InvoiceApplicationModify.aspx?currency="+settleCurrency+"&uex="+$("h_exrmbtousd").value+"&rex="+$("txt_exrmb").value+"&obj=ivappsession&opinfo="+includeOpInfo+"&rn="+rename+"&detail="+detail;
// $("h_sessionid").value = 0;
//
// //删除图层
// document.body.removeChild(docEle("dvRate"));
// document.body.removeChild(docEle("mask"));
// window.open (openUrl,openType,openSet);
var postSessionName = "";
if($("h_postsession").value.trim() != ""){//alert($("h_postsession").value);
postSessionName = "&postsession="+$("h_postsession").value.trim();
}else{
$("h_postsession").value = commonGridObj_order.newGuid();
postSessionName = "&postsession="+$("h_postsession").value.trim();
}
var cacheName = "";
var bsnoCacheName = "";
var totalCacheName = "";
//先获取缓存名称,如果没有缓存名称,则自动创建新的缓存名称
if($("h_cachename").value.trim() != ""){
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}else{
$("h_cachename").value = commonGridObj_order.newGuid();
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}
if($("h_bsnocache").value.trim() != ""){
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}else{
$("h_bsnocache").value = commonGridObj_order.newGuid();
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}
if($("h_totalcache").value.trim() != ""){
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}else{
$("h_totalcache").value = commonGridObj_order.newGuid();
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}
var ckBoxRmb = $("ck_rmb").checked;
var ckBoxUsd = $("ck_usd").checked;
var postSessionUrl = "";
if($("ck_rename").checked && $("txt_rename").value.trim() != ""){
var rename = "";
rename = "&rename="+escape($("txt_rename").value.trim());
var currency = "";
var change = "";
if(ckBoxRmb){
currency = "¤cy=RMB";//按人民币结算
change = "&exchange="+$("h_exusdtormb").value;
}else if(ckBoxUsd){
currency = "¤cy=USD";//按美元结算
change = "&exchange="+$("h_exrmbtousd").value;
}
postSessionUrl = "InvoiceApplicationGridSource.aspx?handle=postInvoiceApp"+cacheName+bsnoCacheName+totalCacheName+postSessionName+currency+change+rename+"&uid="+commonGridObj_order.newGuid();
var loader = dhtmlxAjax.getSync(postSessionUrl);
var cacheVal = loader.xmlDoc.responseText;
var postStatus = parseInt(cacheVal);
if(postStatus == 1){
// var openSet = "height=460, width=800, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-440)/2 + ",Left= "+(screen.width-800)/2
// var openType = "_blank";
var settleCurrency = "";
if($("ck_rmb").checked){
settleCurrency = "1";
}else if($("ck_usd").checked){
settleCurrency = "2";
}
//var includeOpInfo = $("ck_autoaddinfo").checked ? 1:0;
var ckCustNo = $("ck_custno").checked ? 1:0;
var ckVesselState = $("ck_vessel").checked ? 1:0;
var ckMblno = $("ck_mblno").checked ? 1:0;
var ckEtd = $("ck_etd").checked ? 1:0;
var ckPol = $("ck_pol").checked ? 1:0;
var ckPod = $("ck_pod").checked ? 1:0;
var detail = $("ck_detaillist").checked ? 1:0;
var txtRename = $("txt_rename").value;
var rename = $("ck_rename").checked ? txtRename:"";
var openUrl = "InvoiceMakeOutModify.aspx?currency="+settleCurrency+"&uex="+$("h_exrmbtousd").value+"&rex="+$("h_exusdtormb").value+"&postsession="+$("h_postsession").value
+ "&cno="+ckCustNo+"&vel="+ckVesselState+"&mbl="+ckMblno+"&etd="+ckEtd+"&pol="+ckPol+"&pod="+ckPod//+"&opinfo="+includeOpInfo
+"&rn="+rename+"&detail="+detail+"&handle=import";;
document.body.removeChild(docEle("dvRate"));
document.body.removeChild(docEle("mask"));
$("h_sessionid").value = 0;
//window.open (openUrl,openType,openSet);
var parentObj = window.parent.opener.location;//alert(parentObj);
var oldUrl = parentObj.href;
var newUrl = oldUrl.substring(0,oldUrl.lastIndexOf("/"))+"/"+openUrl;
window.parent.opener.location.href = window.parent.opener.location.href;
parentObj.href = newUrl;
window.close();
}
}else{
var rename = "";
var currency = "";
var change = "";
if(ckBoxRmb){
currency = "¤cy=RMB";//按人民币结算
change = "&exchange="+$("h_exusdtormb").value;
}else if(ckBoxUsd){
currency = "¤cy=USD";//按美元结算
change = "&exchange="+$("h_exrmbtousd").value;
}
postSessionUrl = "InvoiceApplicationGridSource.aspx?handle=postInvoiceApp"+cacheName+bsnoCacheName+totalCacheName+postSessionName+currency+change+"&uid="+commonGridObj_order.newGuid();
var loader = dhtmlxAjax.getSync(postSessionUrl);
var cacheVal = loader.xmlDoc.responseText;
var postStatus = parseInt(cacheVal);
if(postStatus == 1){
setTimeout(function(){
// var openSet = "height=460, width=800, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-440)/2 + ",Left= "+(screen.width-800)/2
// var openType = "_blank";
var settleCurrency = "";
if($("ck_rmb").checked){
settleCurrency = "1";
}else if($("ck_usd").checked){
settleCurrency = "2";
}
//var includeOpInfo = $("ck_autoaddinfo").checked ? 1:0;
var ckCustNo = $("ck_custno").checked ? 1:0;
var ckVesselState = $("ck_vessel").checked ? 1:0;
var ckMblno = $("ck_mblno").checked ? 1:0;
var ckEtd = $("ck_etd").checked ? 1:0;
var ckPol = $("ck_pol").checked ? 1:0;
var ckPod = $("ck_pod").checked ? 1:0;
var detail = $("ck_detaillist").checked ? 1:0;
var txtRename = $("txt_rename").value;
var rename = $("ck_rename").checked ? txtRename:"";
var openUrl = "InvoiceMakeOutModify.aspx?currency="+settleCurrency+"&uex="+$("h_exrmbtousd").value+"&rex="+$("h_exusdtormb").value+"&postsession="+$("h_postsession").value
+ "&cno="+ckCustNo+"&vel="+ckVesselState+"&mbl="+ckMblno+"&etd="+ckEtd+"&pol="+ckPol+"&pod="+ckPod//+"&opinfo="+includeOpInfo
+"&rn="+rename+"&detail="+detail+"&handle=import";;
document.body.removeChild(docEle("dvRate"));
document.body.removeChild(docEle("mask"));
$("h_sessionid").value = 0;
//window.open (openUrl,openType,openSet);
var parentObj = window.parent.opener.location;//alert(parentObj);
var oldUrl = parentObj.href;
var newUrl = oldUrl.substring(0,oldUrl.lastIndexOf("/"))+"/"+openUrl;
window.parent.opener.location.href = window.parent.opener.location.href;
parentObj.href = newUrl;
window.close();
},100);
}
}
}
function IsLastFeeCheckOut(bsno){
if(commonGridObj_order != null){
for(var i=0;i< commonGridObj_order.getGridObj().getRowsNum();i++){
if(commonGridObj_order.getGridObj().getRowId(i) == bsno){
commonGridObj_order.getGridObj().cellByIndex(i,0).setValue(0);
break;
}
}
//commonGridObj_order.bind();
}
}
//放弃引入
function rejectImport(){
window.close();
}
//function finishImport(){
// window.parent.opener.location.href = window.parent.opener.location.href;
// parentObj.href = newUrl+"handle=edit&id="+strBSNO;
// window.close();
//}
//清空查询信息
function initSearch(){
//清空船名
if(comboVessel != null){
$("h_vessel").value = "";
comboVessel.setComboText($("h_vessel").value);
}
//清空结算单位
if(comboCustomer != null){
$("h_customer").value = "";
comboCustomer.setComboText($("h_customer").value);
}
//清空航次
if(comboVoyno != null){
$("h_voyno").value = "";
comboVoyno.setComboText($("h_voyno").value);
}
//清空费用名称
if(comboFeeName != null){
$("h_feename").value = "";
comboFeeName.setComboText($("h_feename").value);
}
//清空币别
if(comboCurrency != null){
comboCurrency.setComboText("全部");
}
//清空费用类型
if(comboFeeType != null){
comboFeeType.setComboText("全部");
}
//清空业务类型
if(comboBsType != null){
comboBsType.setComboText("全部");
}
$("txt_beginTime").value = "";//清空业务日期 起始时间
$("txt_endTime").value = "";//清空业务日期 结束时间
$("txt_billNO").value = "";//清空编号 文本框
//$("txt_debitno").value = "";//清空对账编号
$("txt_amount1").value = "";
$("txt_amount2").value = "";
$("h_feecache").value = "";
//初始化Grid
createOrder();
commonGridObj_fee.initGrid();
Statistics();
}
function orderCheckAll(){
if(commonGridObj_order != null){
var state = 0;
var jsonOrderCacheObj = null;
var _customer = comboCustomer.getComboText().trim();
//查询条件
var _billno = $("txt_billNO").value.trim();
var _begin_time = $("txt_beginTime").value.trim();
var _end_time = $("txt_endTime").value.trim();
var _vessel = comboVessel.getComboText().trim();
var _voyno = comboVoyno.getComboText().trim();
var _bstype = comboBsType.getSelectedValue();//comboBsType.getComboText().trim();
//var _debitno = $("txt_debitno").value.trim();
var _feename = comboFeeName.getSelectedValue();
var _feetype = comboFeeType.getSelectedValue();//comboFeeType.getComboText().trim();
var _currency = comboCurrency.getSelectedValue();
//var _customer = comboCustomer.getComboText().trim();
_feename = _feename == null ? "":_feename;
_feetype = _feetype == null?"":_feetype;
_currency = _currency == null?"":_currency;
//var _feetype = comboFeeType.getSelectedValue();//comboFeeType.getComboText().trim();
//var _currency = comboCurrency.getComboText().trim();
var searchJson = "";
//begin
searchJson +="{";
searchJson += "[";
searchJson += "\"cus\":\""+_customer+"\",";
searchJson += "\"bno\":\""+_billno+"\",";
searchJson += "\"bt\":\""+_begin_time+"\",";
searchJson += "\"et\":\""+_end_time+"\",";
searchJson += "\"ves\":\""+_vessel+"\",";
searchJson += "\"voy\":\""+_voyno+"\",";
searchJson += "\"bty\":\""+_bstype+"\",";
searchJson += "\"deno\":\"\",";
//searchJson += "\"cus\":\""+_customer+"\",";
searchJson += "\"fnm\":\""+_feename+"\",";
searchJson += "\"fty\":\""+_feetype+"\",";
searchJson += "\"cur\":\""+_currency+"\",";
//searchJson += "\"ise\":\""+_is_settled+"\"";
//searchJson += "\"fty\":\""+_feetype+"\",";
//searchJson += "\"cur\":\""+_currency+"\"";
searchJson += "\"amount1\":\"" + $("txt_amount1").value.trim() + "\",";
searchJson += "\"amount2\":\"" + $("txt_amount2").value.trim() + "\"";
searchJson += "]";
searchJson +="}";
var checkStatus = $("order_checkall").checked;
//如果费用全选按钮是选中状态,则将所有委托相关的数据进行缓存
if(checkStatus){
// //如果费用Grid不为空
// if(commonGridObj_order.getGridObj().getRowsNum() > 0){//alert(commonGridObj_order.getGridObj().getRowsNum());
// var tempOrderCache = "";
// var iCount = commonGridObj_order.getGridObj().getRowsNum();
// for(var i=0;i < iCount;i++){
// //获取费用ID值
// var rowID = commonGridObj_order.getGridObj().getRowId(i);
//
// if(i == 0){
// //初次加载先生称新的缓存对象
// var orderResult = "";
// var orderCacheBuffer = "";
//
// orderCacheBuffer += "{";
// orderCacheBuffer += "\"bsno\":\""+rowID+"\"";
// orderCacheBuffer += "}";
//
// orderResult += "{\"orders\":[";
// orderResult += orderCacheBuffer;
// orderResult += "]}";
// //选择框置选中状态
// commonGridObj_order.getGridObj().cellByIndex(i,0).setValue(1);
//
// jsonOrderCacheObj = eval('(' + orderResult + ')');//生成对象
//
// if(iCount == 1){
// $("h_ordercache").value = JSON.stringify(jsonOrderCacheObj);
// }
// }else{
// if(jsonOrderCacheObj != null){
// var newCache = jsonOrderCacheObj.orders;
// newCache = {bsno:rowID};
// jsonOrderCacheObj.orders.push(newCache);
// commonGridObj_order.getGridObj().cellByIndex(i,0).setValue(1);
// if(i == iCount - 1){
// $("h_ordercache").value = JSON.stringify(jsonOrderCacheObj);
// }
// }
// }
// }
// }
if($("h_cachename").value != ""){
}else{
$("h_cachename").value = commonGridObj_order.newGuid();
}
if($("h_bsnocache").value != ""){
}else{
$("h_bsnocache").value = commonGridObj_order.newGuid();
}
if($("h_totalcache").value != ""){
}else{
$("h_totalcache").value = commonGridObj_order.newGuid();
}
var bankObj = null;
//var url = "InvoiceApplicationGridSource.aspx?handle=cacheorder&selectedorder="+$("h_ordercache").value+"&ordercachename="+$("h_cachename").value+"&op=check&search="+escape(searchJson)+"&val="+commonGridObj_order.newGuid()+"&do=app";
var url = "InvoiceApplicationGridSource.aspx?handle=cacheorder&bsnocachename="+$("h_bsnocache").value+"&ordercachename="+$("h_cachename").value+"&op=check&search="+escape(searchJson)+"&val="+commonGridObj_order.newGuid()+"&do=import";
var loader = dhtmlxAjax.getSync(url);
var cacheTotal = "";
var cacheTotalObj = null;
var cacheVal = loader.xmlDoc.responseText;//alert(opInfo);
if(cacheVal.trim().length > 1){
cacheTotalObj = eval('(' + cacheVal.trim() + ')');
if(cacheTotalObj.totals.length > 0){
$("dvTotalRecvRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].recvrmb.toString());
$("dvTotalRecvUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].recvusd.toString());
$("dvTotalPayRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].payrmb.toString());
$("dvTotalPayUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].payusd.toString());
$("dvTotalSettleRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].totalrmb.toString());
$("dvTotalSettleUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].totalusd.toString());
$("dvTotalRecvRMBVal").style.color = "#F00";
$("dvTotalRecvUSDVal").style.color = "#F00";
$("dvTotalPayRMBVal").style.color = "#090";
$("dvTotalPayUSDVal").style.color = "#090";
state = parseInt(cacheTotalObj.totals[0].state);
}
}
commonGridObj_order.setRequest("InvoiceApplicationGridSource.aspx?handle=refreshorder&bsnocachename="+$("h_bsnocache").value+"&ordercachename="+$("h_cachename").value+"&totalcachename="+$("h_totalcache").value+"&op=check&search="+escape(searchJson)+"&uid="+commonGridObj_order.newGuid()+"&do=import");
commonGridObj_order.initGrid();
commonGridObj_order.bind();
commonGridObj_order.getGridObj().enableHeaderImages(true);
commonGridObj_order.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=700, width=1024, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " +(screen.height-750)/2 + ",Left= "+(screen.width-1100)/2
var openType = "_blank";
var openUrl = "../baseinfo/opseaebaseinfo.aspx?handle=check&bsno="+rId;
window.open (openUrl,openType,openSet);
});
commonGridObj_order.getGridObj().attachEvent("onRowSelect", function(id,ind){
$("h_bsno").value = id;
createFeeList();
});
commonGridObj_order.getGridObj().attachEvent("onCheckbox", function(rId,cInd,state){
$("h_bsno").value = rId;
var state = 0;
var cacheName = "";
var bsnoCacheName = "";
var totalCacheName = "";
if($("h_cachename").value.trim() != ""){
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}else{
$("h_cachename").value = commonGridObj_order.newGuid();
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}
if($("h_bsnocache").value.trim() != ""){
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}else{
$("h_bsnocache").value = commonGridObj_order.newGuid();
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}
if($("h_totalcache").value.trim() != ""){
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}else{
$("h_totalcache").value = commonGridObj_order.newGuid();
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}
var orderRowIndex = commonGridObj_order.getGridObj().getRowIndex(rId);
var checkBox = commonGridObj_order.getGridObj().cellByIndex(orderRowIndex,0).getValue();
var url = "";
if(checkBox == 1){//委托选中状态
url = "InvoiceApplicationGridSource.aspx?handle=checkorder&bsno="+rId+"&op=check&search="+escape(searchJson)+"&val="+commonGridObj_order.newGuid()+cacheName+bsnoCacheName+totalCacheName+"&do=import";
}else{//委托取消选中状态
url = "InvoiceApplicationGridSource.aspx?handle=checkorder&bsno="+rId+"&op=uncheck&search="+escape(searchJson)+"&val="+commonGridObj_order.newGuid()+cacheName+bsnoCacheName+totalCacheName+"&do=import";
}
//alert(url);
var loader = dhtmlxAjax.getSync(url);
var cacheTotal = "";
var cacheTotalObj = null;
var cacheVal = loader.xmlDoc.responseText;//alert(opInfo);
//alert(cacheVal);
if(cacheVal.trim().length > 1){
cacheTotalObj = eval('(' + cacheVal.trim() + ')');
if(cacheTotalObj.totals.length > 0){
$("dvTotalRecvRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].recvrmb.toString());
$("dvTotalRecvUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].recvusd.toString());
$("dvTotalPayRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].payrmb.toString());
$("dvTotalPayUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].payusd.toString());
$("dvTotalSettleRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].totalrmb.toString());
$("dvTotalSettleUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].totalusd.toString());
$("dvTotalRecvRMBVal").style.color = "#F00";
$("dvTotalRecvUSDVal").style.color = "#F00";
$("dvTotalPayRMBVal").style.color = "#090";
$("dvTotalPayUSDVal").style.color = "#090";
state = parseInt(cacheTotalObj.totals[0].state);
}
}
createFeeList();
if(state < 0){
commonGridObj_order.getGridObj().cellByIndex(orderRowIndex,0).setValue(0);
alert("没有权限添加费用");
}
});
createFeeList();
$("order_checkall").checked = true;
if(state < 0){
alert("没有权限添加委托费用 共计"+(0-state)+"项 未添加");
}
}else{
// //如果费用Grid不为空
// if(commonGridObj_order.getGridObj().getRowsNum() > 0){
// var tempOrderCache = "";
// var iCount = commonGridObj_order.getGridObj().getRowsNum();
// for(var i=0;i < iCount;i++){
// //获取费用ID值
// var rowID = commonGridObj_order.getGridObj().getRowId(i);
//
// if(i == 0){
// //初次加载先生称新的缓存对象
// var orderResult = "";
// var orderCacheBuffer = "";
//
// orderCacheBuffer += "{";
// orderCacheBuffer += "\"bsno\":\""+rowID+"\"";
// orderCacheBuffer += "}";
//
// orderResult += "{\"orders\":[";
// orderResult += orderCacheBuffer;
// orderResult += "]}";
// //选择框置选中状态
// commonGridObj_order.getGridObj().cellByIndex(i,0).setValue(0);
//
// jsonOrderCacheObj = eval('(' + orderResult + ')');//生成对象
// }else{
// if(jsonOrderCacheObj != null){
// var newCache = jsonOrderCacheObj.orders;
// newCache = {bsno:rowID};
// jsonOrderCacheObj.orders.push(newCache);
// commonGridObj_order.getGridObj().cellByIndex(i,0).setValue(0);
// if(i == iCount - 1){
// $("h_ordercache").value = JSON.stringify(jsonOrderCacheObj);
// }
// }
// }
// }
// }
if($("h_cachename").value != ""){
}else{
$("h_cachename").value = commonGridObj_order.newGuid();
}
if($("h_bsnocache").value != ""){
}else{
$("h_bsnocache").value = commonGridObj_order.newGuid();
}
var url = "InvoiceApplicationGridSource.aspx?handle=cacheorder&bsnocachename="+$("h_bsnocache").value+"&ordercachename="+$("h_cachename").value+"&totalcachename="+$("h_totalcache").value+"&op=uncheck&search="+escape(searchJson)+"&val="+commonGridObj_order.newGuid()+"&do=import";
//alert(url);
var loader = dhtmlxAjax.getSync(url);
var cacheTotal = "";
var cacheTotalObj = null;
var cacheVal = loader.xmlDoc.responseText;//alert(opInfo);
//alert(cacheVal);
if(cacheVal.trim().length > 1){
cacheTotalObj = eval('(' + cacheVal.trim() + ')');
if(cacheTotalObj.totals.length > 0){
$("dvTotalRecvRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].recvrmb.toString());
$("dvTotalRecvUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].recvusd.toString());
$("dvTotalPayRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].payrmb.toString());
$("dvTotalPayUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].payusd.toString());
$("dvTotalSettleRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].totalrmb.toString());
$("dvTotalSettleUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].totalusd.toString());
$("dvTotalRecvRMBVal").style.color = "#F00";
$("dvTotalRecvUSDVal").style.color = "#F00";
$("dvTotalPayRMBVal").style.color = "#090";
$("dvTotalPayUSDVal").style.color = "#090";
state = parseInt(cacheTotalObj.totals[0].state);
}
}
commonGridObj_order.setRequest("InvoiceApplicationGridSource.aspx?handle=refreshorder&bsnocachename="+$("h_bsnocache").value+"&ordercachename="+$("h_cachename").value+"&totalcachename="+$("h_totalcache").value+"&op=uncheck&search="+escape(searchJson)+"&uid="+commonGridObj_order.newGuid()+"&do=import");
commonGridObj_order.initGrid();
commonGridObj_order.bind();
commonGridObj_order.getGridObj().enableHeaderImages(true);
commonGridObj_order.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
var openSet = "height=700, width=1024, toolbar=no, menubar=no,scrollbars=1, resizable=1,location=no, status=no,Top= " +(screen.height-750)/2 + ",Left= "+(screen.width-1100)/2
var openType = "_blank";
var openUrl = "../baseinfo/opseaebaseinfo.aspx?handle=check&bsno="+rId;
window.open (openUrl,openType,openSet);
});
commonGridObj_order.getGridObj().attachEvent("onRowSelect", function(id,ind){
$("h_bsno").value = id;
createFeeList();
});
commonGridObj_order.getGridObj().attachEvent("onCheckbox", function(rId,cInd,state){
$("h_bsno").value = rId;
var state = 0;
var cacheName = "";
var bsnoCacheName = "";
var totalCacheName = "";
if($("h_cachename").value.trim() != ""){
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}else{
$("h_cachename").value = commonGridObj_order.newGuid();
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}
if($("h_bsnocache").value.trim() != ""){
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}else{
$("h_bsnocache").value = commonGridObj_order.newGuid();
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}
if($("h_totalcache").value.trim() != ""){
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}else{
$("h_totalcache").value = commonGridObj_order.newGuid();
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}
var orderRowIndex = commonGridObj_order.getGridObj().getRowIndex(rId);
var checkBox = commonGridObj_order.getGridObj().cellByIndex(orderRowIndex,0).getValue();
var url = "";
if(checkBox == 1){//委托选中状态
url = "InvoiceApplicationGridSource.aspx?handle=checkorder&bsno="+rId+"&op=check&search="+escape(searchJson)+"&val="+commonGridObj_order.newGuid()+cacheName+bsnoCacheName+totalCacheName+"&do=import";
}else{//委托取消选中状态
url = "InvoiceApplicationGridSource.aspx?handle=checkorder&bsno="+rId+"&op=uncheck&search="+escape(searchJson)+"&val="+commonGridObj_order.newGuid()+cacheName+bsnoCacheName+totalCacheName+"&do=import";
}
//alert(url);
var loader = dhtmlxAjax.getSync(url);
var cacheTotal = "";
var cacheTotalObj = null;
var cacheVal = loader.xmlDoc.responseText;//alert(opInfo);
//alert(cacheVal);
if(cacheVal.trim().length > 1){
cacheTotalObj = eval('(' + cacheVal.trim() + ')');
if(cacheTotalObj.totals.length > 0){
$("dvTotalRecvRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].recvrmb.toString());
$("dvTotalRecvUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].recvusd.toString());
$("dvTotalPayRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].payrmb.toString());
$("dvTotalPayUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].payusd.toString());
$("dvTotalSettleRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].totalrmb.toString());
$("dvTotalSettleUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].totalusd.toString());
$("dvTotalRecvRMBVal").style.color = "#F00";
$("dvTotalRecvUSDVal").style.color = "#F00";
$("dvTotalPayRMBVal").style.color = "#090";
$("dvTotalPayUSDVal").style.color = "#090";
state = parseInt(cacheTotalObj.totals[0].state);
}
}
createFeeList();
if(state < 0){
commonGridObj_order.getGridObj().cellByIndex(orderRowIndex,0).setValue(0);
alert("没有权限添加费用");
}
});
createFeeList();
$("order_checkall").checked = false;
if(state < 0){
alert("没有权限添加委托费用 共计"+(0-state)+"项 未取消");
}
}
// if(commonGridObj_fee != null){
// if(commonGridObj_fee.getGridObj().getRowsNum() > 0){
// createFeeList();
// }
// }
}
}
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);
}
}
function fomatFloat(src,pos){
return Math.round(src*Math.pow(10, pos))/Math.pow(10, pos);
}
//是否为数字,且数值格式是否正确
function IsNumFormat(val) {
var re = /^[-\+]?\d+(\.\d+)?$/;
if (!re.test(val)) {
return false;
}
else {
if (val.toString().indexOf(".") > 0) {
val.toString().replace("-", "");
val.toString().replace("+", "");
if (val.toString().substr(0, 1) == "0" && val.toString().substr(0, 2) != "0.") {
return false;
}
}
else {
var re1 = /^[-\+]+[1-9]+[0-9]*]*$/;
if (!re1.test(val)) {
re1 = /^[1-9]+[0-9]*]*$/;
if (!re1.test(val)) {
return false;
}
}
}
return true;
}
}
//
function getIsNum(x) {
var str = x.value.trim();
if (str == "0") {
return;
}
else if (str == "") {
return;
// str = 0;
// x.value = 0;
}
else {
var bl = IsNumFormat(str);
if (!bl) {
alert("数值格式错误!");
x.focus();
x.select();
}
}
}