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.
JiCangHai/PingTai/DSWeb/js/CommonInvoiceApplication.js

3213 lines
133 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

var commonGridObj_order;
var commonGridObj_fee;
var comboCustomer;//委托单位
var comboVessel;//船名
var comboVoyno;//航次
var comboBsType;//业务类型
var comboFeeName;//费用名称
var comboFeeType;//费用类型
var comboCurrency;//币别
var isLoad = 0;
var borrowFee = ""; //查询是否包含预付信息
var sel_val = new Array;
var selectoplb;//选中行的业务类别
function $(id){
return document.getElementById(id);
}
function createOrder(){
//header
//new Array("<input type=\"checkbox\" id=\"order_checkall\" onclick=\"orderCheckAll()\" />","业务类别","委托单位","委托编号","主提单号","分提单号");
var headerArgs_order = new Array("", "业务类别", "委托单位", "委托编号", "主提单号", "分提单号", "报关单号", "备案清单号");
//width
var widthArgs_order = new Array("40", "60", "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.setResponseUrl("InvoiceApplicationGridSource.aspx");
commonGridObj_order.setRequest("InvoiceApplicationGridSource.aspx?handle=orderlist");
commonGridObj_order.setSourceType("json");
commonGridObj_order.setSkin("xp");
commonGridObj_order.setImageUrl("../images/");
commonGridObj_order.initGrid();
//commonGridObj_order.bind();
commonGridObj_order.getGridObj().enableHeaderImages(true);
commonGridObj_order.getGridObj().attachEvent("onSelectStateChanged", function(id){
commonGridObj_order.$("h_bsno").value = id;
var oplb=commonGridObj_order.getGridObj().cellById(id,1).getValue();
if(oplb=="海运出口")
{
selectoplb="op_Seae";
}
else if(oplb=="海运进口")
{
selectoplb="op_Seai";
}
else if (oplb == "仓储费") {
selectoplb = "wms_fee";
}
else if (oplb == "仓储入库") {
selectoplb = "wms";
}
else if (oplb == "仓储出库") {
selectoplb = "wms_out";
}
else if (oplb == "陆运托运") {
selectoplb = "tmswlbshead";
}
else if (oplb == "陆运派车") {
selectoplb = "tmswlpchead";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
}
createFeeList();
});
commonGridObj_order.getGridObj().attachEvent("onCheckbox", function(rId,cInd,state){
commonGridObj_order.$("h_bsno").value = rId;
var orderRowIndex = commonGridObj_order.getGridObj().getRowIndex(rId);
var checkBox = commonGridObj_order.getGridObj().cellByIndex(orderRowIndex,0).getValue();
if(checkBox == 1){
var oplb=commonGridObj_order.getGridObj().cellById(rId,1).getValue();
if(oplb=="海运出口")
{
selectoplb="op_Seae";
}
else if(oplb=="海运进口")
{
selectoplb="op_Seai";
}
else if (oplb == "仓储费") {
selectoplb = "wms_fee";
}
else if (oplb == "仓储入库") {
selectoplb = "wms";
}
else if (oplb == "仓储出库") {
selectoplb = "wms_out";
}
else if (oplb == "陆运托运") {
selectoplb = "tmswlbshead";
}
else if (oplb == "陆运派车") {
selectoplb = "tmswlpchead";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
}
}else{
}
});
// previous_id = "";
// //header
// var headerArgs_order = new Array("<input type=\"checkbox\" id=\"order_checkall\" onclick=\"orderCheckAll()\" />","委托单位","委托编号","主提单号","分提单号");
// //width
// var widthArgs_order = new Array("40","100","100","100","100");
// //column align
// var colAlignArgs_order = new Array("center","center","center","center","center");
// //column sort
// var colSortArgs_order = new Array("na","str","str","str","str");
// //column type
// var colTypeArgs_order = new Array("ch","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 != ""){
// jsonCacheObj = eval('(' + tempCache + ')');
//
// for(var i=0;i<jsonCacheObj.caches.length;i++){
// for(var j=0;j<commonGridObj_order.getGridObj().getRowsNum();j++){
// var rowId = "";
// rowId = commonGridObj_order.getGridObj().getRowId(j);
// if(jsonCacheObj.caches[i].bsno == rowId){
// commonGridObj_order.getGridObj().cellByIndex(j,0).setValue(1);
//
// break;
// }
// }
// }
//
// Statistics();
// }
// },300);
//
// commonGridObj_order.getGridObj().enableHeaderImages(true);
//
// commonGridObj_order.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
//
//
// });
//
//// commonGridObj_order.getGridObj().attachEvent("onSelectStateChanged", function(id){
//// commonGridObj_order.$("h_bsno").value = id;
//// createFeeList();
//// });
//
// 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;
// createFeeList();
//
// setTimeout(function(){
// 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<commonGridObj_fee.getGridObj().getRowsNum();k++){
// var tempCache = $("h_feecache").value;
// var rowId = commonGridObj_fee.getGridObj().getRowId(i);
// var rowIndex = commonGridObj_fee.getGridObj().getRowIndex(rowId);
// //查看缓存内是否有数据,如果没有数据,则自动创建数据格式
// if(tempCache.trim() != ""){
// //加载缓存对象
// jsonCacheObj = eval('(' + tempCache + ')');
// //先判断当前缓存数据内是否已经有相同的值,如果有相同的值则不进行插入操作,如果没有相同的值,则插入新的值
// var isExist = false;
// //开始遍历对象
// for(var j=0;j<jsonCacheObj.caches.length;j++){
// if(jsonCacheObj.caches[j].id == rowId){
// isExist = true;
// break;
// }
// }
// //如果没有重复的值,则自动插入到缓存内
// if(!isExist){
// //获取费用类型
// var feeType = commonGridObj_fee.getGridObj().cellByIndex(rowIndex,1).getValue() == "收"?1:2;
// //将当前费用选中
// commonGridObj_fee.getGridObj().cellByIndex(rowIndex,0).setValue(1);
//
// var newCache = jsonCacheObj.caches;
// newCache = {id:rowId,type:feeType,bsno:rId,cus:gridObj.cellByIndex(rowIndex,2).getValue().toString(),
// fname:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,3).getValue(),cur:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,4).getValue(),
// cstl:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,6).getValue(),ustl:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,7).getValue(),
// orig:"1",oname:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,3).getValue(),ocstl:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,6).getValue()};
// //alert(newCache);
// jsonCacheObj.caches.push(newCache);
// //缓存数据
// $("h_feecache").value = JSON.stringify(jsonCacheObj);
// }
//
// }else{//缓存内没有数据创建新的数据
// var cacheBuffer = "";
// cacheBuffer += "{";
// cacheBuffer += "\"id\":\""+rowId+"\",";
// var feeType = commonGridObj_fee.getGridObj().cellByIndex(rowIndex,1).getValue() == "收"?1:2;
// cacheBuffer += "\"type\":"+feeType+",";
// cacheBuffer += "\"bsno\":\""+rId+"\",";
// cacheBuffer += "\"cus\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,2).getValue()+"\",";
// cacheBuffer += "\"fname\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,3).getValue()+"\",";
// cacheBuffer += "\"cur\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,4).getValue()+"\",";
// cacheBuffer += "\"stl\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,5).getValue()+"\",";//应结
// cacheBuffer += "\"cstl\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,6).getValue()+"\",";//本次结算
// cacheBuffer += "\"ustl\":\""+commonGridObj_fee.getGridObj().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 += "}";
//
// var result = "";
// result += "{\"caches\":[";
// result += cacheBuffer;
// result += "]}";
// //生成新的缓存数据对象
// jsonCacheObj = eval('(' + result + ')');
// //每插入一条新记录,就快速记录到缓存数据内
// //缓存数据
// $("h_feecache").value = JSON.stringify(jsonCacheObj);
// }
// }
// //遍历完费用列表后,重新计算显示合计费用信息
// Statistics();
// }
// },50);
// }else{
// //如果委托信息某项选中状态改为不选中,则自动将此委托信息下的费用数据从缓存数据内删除
// setTimeout(function(){
// //获取缓存信息
// var tempCache = $("h_feecache").value;
// //查看是否有缓存数据,如果有缓存数据则遍历缓存数据,费用信息表下的所有费用信息从缓存中清除
// if(tempCache.trim() != ""){
// jsonCacheObj = eval('(' + tempCache + ')');
// //查看费用Grid是否已经加载完毕
// if(commonGridObj_fee.getGridObj().getRowsNum() > 0){
// for(var j = 0;j< commonGridObj_fee.getGridObj().getRowsNum();j++){
// var feeID = gridObj.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;
// }
// }
// }
// }
// }
// },60);
// }
// });
// },100);
}
function createFeeList(){
//header
var headerArgs_order = new Array("<input type=\"checkbox\" id=\"ck_allfee\" onclick=\"checkAll(commonGridObj_fee)\" />", "D/C", "结算单位", "费用名称", "币别", "应结", "本次结算", "未结", "备注");
//width
var widthArgs_order = new Array("40", "25", "100", "100", "40", "70", "70", "70", "300");
//column align
var colAlignArgs_order = new Array("center", "center", "center", "center", "center", "center", "center", "center", "center");
//column sort
var colSortArgs_order = new Array("na", "str", "str", "str", "str", "str", "str", "str", "str");
//column type
var colTypeArgs_order = new Array("ch", "ro", "ro", "ro", "ro", "ro", "ed", "ro", "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();
var checkboxFee = document.getElementById("chec_FeeKind").checked;
if (checkboxFee == true) {
borrowFee = "borrowPay";
}
else {
borrowFee = "noPay";
}
_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 += "]";
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 + "&BorrowFee="+borrowFee);
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<jsonCacheObj.caches.length;i++){
for(var j=0;j<commonGridObj_fee.getGridObj().getRowsNum();j++){
var rowId = "";
rowId = commonGridObj_fee.getGridObj().getRowId(j);
if(jsonCacheObj.caches[i].id == rowId){
commonGridObj_fee.getGridObj().cellByIndex(j,0).setValue(1);
var cstlMoney = ConvertToMoney(outputMoney(jsonCacheObj.caches[i].cstl.toString()));
commonGridObj_fee.getGridObj().cellByIndex(j,6).setValue(cstlMoney);
var ustlMoney = ConvertToMoney(outputMoney(jsonCacheObj.caches[i].ustl.toString()));
commonGridObj_fee.getGridObj().cellByIndex(j,7).setValue(ustlMoney);
break;
}
}
}
}
},300);
}
commonGridObj_fee.getGridObj().enableEditEvents(true,false,true);
commonGridObj_fee.getGridObj().attachEvent("onCheckbox", function(rId,cInd,state){
//commonGridObj_order.bind();
var state = 0;
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 += "]";
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();
}
//$("dvResult").innerHTML += "#"+cacheName+"#";
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 = commonGridObj_fee.getGridObj().cellByIndex(rowIndex,0).getValue();
var strBSNO = $("h_bsno").value;
var selectedId = commonGridObj_order.getGridObj().getSelectedRowId();
var oplb=commonGridObj_order.getGridObj().cellById(selectedId,1).getValue();
var stroplb="";
if(oplb=="海运出口")
{
stroplb="op_Seae";
}
else if(oplb=="海运进口")
{
stroplb="op_Seai";
}
else if (oplb == "仓储费") {
selectoplb = "wms_fee";
}
else if (oplb == "仓储入库") {
selectoplb = "wms";
}
else if (oplb == "仓储出库") {
selectoplb = "wms_out";
}
else if (oplb == "陆运托运") {
selectoplb = "tmswlbshead";
}
else if (oplb == "陆运派车") {
selectoplb = "tmswlpchead";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
}
if(checkBox == 1){
url = "InvoiceApplicationGridSource.aspx?handle=checkfee&oplb="+stroplb+"&search="+escape(searchJson)+cacheName+bsnoCacheName+totalCacheName+"&feeid="+rId+"&op=check&uid="+commonGridObj_order.newGuid()+"&do=app"+"&bsno="+strBSNO;
}else{
url = "InvoiceApplicationGridSource.aspx?handle=checkfee&oplb="+stroplb+"&search="+escape(searchJson)+cacheName+bsnoCacheName+totalCacheName+"&feeid="+rId+"&op=uncheck&uid="+commonGridObj_order.newGuid()+"&do=app"+"&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 = 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<jsonCacheObj.caches.length;i++){
// if(jsonCacheObj.caches[i].id == rId){
// isExist = true;
// break;
// }
// }
//
// if(!isExist){
// var newCache = jsonCacheObj.caches;
// var feeType = gridObj.cellByIndex(rowIndex,1).getValue() == "收"?1:2;
// newCache = {id:rId,type:feeType,bsno:rId,cus:gridObj.cellByIndex(rowIndex,2).getValue().toString(),fname:gridObj.cellByIndex(rowIndex,3).getValue(),
// cur:gridObj.cellByIndex(rowIndex,4).getValue(),stl:gridObj.cellByIndex(rowIndex,5).getValue(),cstl:gridObj.cellByIndex(rowIndex,6).getValue(),
// ustl:gridObj.cellByIndex(rowIndex,7).getValue(),orig:"1",oname:gridObj.cellByIndex(rowIndex,3).getValue(),ocstl:gridObj.cellByIndex(rowIndex,6).getValue()};
// jsonCacheObj.caches.push(newCache);
// $("h_feecache").value = JSON.stringify(jsonCacheObj);
// //$("dvResult").innerHTML = JSON.stringify(jsonCacheObj);
// }
// }
// }else{
// jsonCacheObj = eval('(' + tempCache + ')');
//
//
// for(var i = jsonCacheObj.caches.length-1;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 += "]";
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+"&oplb="+selectoplb+"&feeid="+rId+"&search="+escape(searchJson)+"&cstl="+cstl+"&ustl="+newStl+"&uid="+commonGridObj_fee.newGuid()+"&do=app"+"&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&pos=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 state = 0;
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 += "]";
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&oplb="+selectoplb+"&search="+escape(searchJson)+cacheName+bsnoCacheName+totalCacheName+"&bsno="+bsnoVal+"&op=check&uid="+commonGridObj_order.newGuid()+"&do=app";
}else{
url = "InvoiceApplicationGridSource.aspx?handle=checkallfee&oplb="+selectoplb+"&search="+escape(searchJson)+cacheName+bsnoCacheName+totalCacheName+"&bsno="+bsnoVal+"&op=uncheck&uid="+commonGridObj_order.newGuid()+"&do=app";
}
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);
}
}
createFeeList();
$("ck_allfee").checked = checkBox;
if(state < 0){
$("ck_allfee").checked = 0;
alert("没有权限添加费用");
}
// 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<commonGridObj_fee.getGridObj().getRowsNum();i++){
// //获取费用ID值
// var rowID = commonGridObj_fee.getGridObj().getRowId(i);
// var rowIndex = commonGridObj_fee.getGridObj().getRowIndex(rowID);
// //收付类型
// var feeType = commonGridObj_fee.getGridObj().cellByIndex(rowIndex,1).getValue() == "收"?1:2;
// var tempCache = $("h_feecache").value;
// //如果缓存记录不为空,则先判断缓存数据内是否已经有相同的数据了
// if(tempCache.trim() != ""){
// //加载缓存对象
// jsonCacheObj = eval('(' + tempCache + ')');
// //先判断是否有相同值
// var isExist = false;
// for(var k=0;k<jsonCacheObj.caches.length;k++){
// if(jsonCacheObj.caches[k].id == rowID){
// isExist = true;
// break;
// }
// }
// //如果不存在相同值,则将费用写入缓存
// if(!isExist){
// var newCache = jsonCacheObj.caches;
// newCache = {id:rowID,type:feeType,bsno:bsnoVal,cus:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,2).getValue(),
// fname:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,3).getValue(),
// cur:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,4).getValue(),
// stl:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,5).getValue(),
// cstl:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,6).getValue(),
// ustl:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,7).getValue(),
// orig:"1",oname:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,3).getValue(),ocstl:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,6).getValue()};
// jsonCacheObj.caches.push(newCache);
// //选中
// commonGridObj_fee.getGridObj().cellByIndex(i,0).setValue(1);
//
// $("h_feecache").value = JSON.stringify(jsonCacheObj);
// }
//
// }else{//如果缓存信息为空,则新创建缓存信息
// var cacheBuffer = "";
// var result = "";
//
// cacheBuffer += "{";
// cacheBuffer += "\"id\":\""+rowID+"\",";
// cacheBuffer += "\"type\":"+feeType+",";
// cacheBuffer += "\"bsno\":\""+bsnoVal+"\",";
// cacheBuffer += "\"cus\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,2).getValue()+"\",";
// cacheBuffer += "\"fname\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,3).getValue()+"\",";
// cacheBuffer += "\"cur\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,4).getValue()+"\",";
// cacheBuffer += "\"stl\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,5).getValue()+"\",";//应结
// cacheBuffer += "\"cstl\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,6).getValue()+"\",";//本次结算
// cacheBuffer += "\"ustl\":\""+commonGridObj_fee.getGridObj().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 += "]}";
// //选中
// commonGridObj_fee.getGridObj().cellByIndex(i,0).setValue(1);
// jsonCacheObj = eval('(' + result + ')');
// $("h_feecache").value = JSON.stringify(jsonCacheObj);
// }
// }
// }
// Statistics();
// }else{
// //如果委托信息某项选中状态改为不选中,则自动将此委托信息下的费用数据从缓存数据内删除
// setTimeout(function(){
// //获取缓存信息
// var tempCache = $("h_feecache").value;
// $("ck_allfee").checked = 0;
// //查看是否有缓存数据,如果有缓存数据则遍历缓存数据,费用信息表下的所有费用信息从缓存中清除
// if(tempCache.trim() != ""){
// jsonCacheObj = eval('(' + tempCache + ')');
// //查看费用Grid是否已经加载完毕
// if(commonGridObj_fee.getGridObj().getRowsNum() > 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");
}
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
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 checkboxFee = document.getElementById("chec_FeeKind").checked;
if (checkboxFee == true) {
borrowFee = "borrowPay";
}
else {
borrowFee = "noPay";
}
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 += "\"accDate\":\""+_accdate+"\"";
//searchJson += "\"ise\":\""+_is_settled+"\"";
//searchJson += "\"fty\":\""+_feetype+"\",";
//searchJson += "\"cur\":\""+_currency+"\"";
searchJson += "]";
searchJson +="}";
var cacheName = "";
if($("h_cachename").value.trim() != ""){
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}
commonGridObj_order.setRequest("InvoiceApplicationGridSource.aspx?handle=ordersearch&bstype="+_bstype+"&search="+escape(searchJson)+cacheName+"&uid="+commonGridObj_order.newGuid()+"&do=app&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<jsonCacheObj.caches.length;i++){
// for(var j=0;j<commonGridObj_order.getGridObj().getRowsNum();j++){
// var rowId = "";
// rowId = commonGridObj_order.getGridObj().getRowId(j);
// if(jsonCacheObj.caches[i].bsno == rowId){
// commonGridObj_order.getGridObj().cellByIndex(j,0).setValue(1);
// break;
// }
// }
// }
// }
//
// },100);
$("dvTotalRecvRMBVal").innerHTML = "0";
$("dvTotalRecvUSDVal").innerHTML = "0";
$("dvTotalPayRMBVal").innerHTML = "0";
$("dvTotalPayUSDVal").innerHTML = "0";
$("dvTotalSettleRMBVal").innerHTML = "0";
$("dvTotalSettleUSDVal").innerHTML = "0";
$("dvTotalRecvRMBVal").style.color = "#F00";
$("dvTotalRecvUSDVal").style.color = "#F00";
$("dvTotalPayRMBVal").style.color = "#090";
$("dvTotalPayUSDVal").style.color = "#090";
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="";
var oplb=commonGridObj_order.getGridObj().cellById(rId,1).getValue();
if(oplb=="海运出口")
{
selectoplb="op_Seae";
openUrl = "../BaseInfo/OpSeaeBaseInfo.aspx?handle=check&bsno="+rId;
}
else if(oplb=="海运进口")
{
selectoplb="op_Seai";
openUrl = "../BaseInfo/OpSeaiBaseInfo.aspx?handle=check&bsno="+rId;
}
else if (oplb == "仓储费") {
selectoplb = "wms_fee";
openUrl = "";
}
else if (oplb == "仓储入库") {
selectoplb = "wms";
openUrl = "";
}
else if (oplb == "仓储出库") {
selectoplb = "wms_out";
openUrl = "";
}
else if (oplb == "陆运托运") {
selectoplb = "tmswlbshead";
openUrl = "";
}
else if (oplb == "陆运派车") {
selectoplb = "tmswlpchead";
openUrl = "";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
openUrl = "../MvcShipping/MsOpApply/ApplyFeeView?handle=check&bsno=" + rId;
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
openUrl = "../MvcShipping/MsOpBulk/BulkFeeView?handle=check&bsno=" + rId;
}
window.open (openUrl,openType,openSet);
});
commonGridObj_order.getGridObj().attachEvent("onRowSelect", function(id,ind){
$("h_bsno").value = id;
var oplb=commonGridObj_order.getGridObj().cellById(id,1).getValue();
if(oplb=="海运出口")
{
selectoplb="op_Seae";
}
else if(oplb=="海运进口")
{
selectoplb="op_Seai";
}
else if (oplb == "仓储费") {
selectoplb = "wms_fee";
}
else if (oplb == "仓储入库") {
selectoplb = "wms";
}
else if (oplb == "仓储出库") {
selectoplb = "wms_out";
}
else if (oplb == "陆运托运") {
selectoplb = "tmswlbshead";
}
else if (oplb == "陆运派车") {
selectoplb = "tmswlpchead";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
}
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 = "";
var oplb=commonGridObj_order.getGridObj().cellById(rId,1).getValue();
if(oplb=="海运出口")
{
selectoplb="op_Seae";
}
else if(oplb=="海运进口")
{
selectoplb="op_Seai";
}
else if (oplb == "仓储费") {
selectoplb = "wms_fee";
}
else if (oplb == "仓储入库") {
selectoplb = "wms";
}
else if (oplb == "仓储出库") {
selectoplb = "wms_out";
}
else if (oplb == "陆运托运") {
selectoplb = "tmswlbshead";
}
else if (oplb == "陆运派车") {
selectoplb = "tmswlpchead";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
}
if(checkBox == 1){//委托选中状态
url = "InvoiceApplicationGridSource.aspx?handle=checkorder&oplb="+selectoplb +"&bsno="+rId+"&op=check&search="+escape(searchJson)+"&val="+commonGridObj_order.newGuid()+cacheName+bsnoCacheName+totalCacheName+"&do=app";
}else{//委托取消选中状态
url = "InvoiceApplicationGridSource.aspx?handle=checkorder&oplb="+selectoplb+"&bsno="+rId+"&op=uncheck&search="+escape(searchJson)+"&val="+commonGridObj_order.newGuid()+cacheName+bsnoCacheName+totalCacheName+"&do=app";
}
//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("没有权限添加费用");
}
// $("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<commonGridObj_fee.getGridObj().getRowsNum();k++){
// var tempCache = $("h_feecache").value;
// var rowId = commonGridObj_fee.getGridObj().getRowId(k);
// var rowIndex = commonGridObj_fee.getGridObj().getRowIndex(rowId);
// //查看缓存内是否有数据,如果没有数据,则自动创建数据格式
// if(tempCache.trim() != ""){
// //加载缓存对象
// jsonCacheObj = eval('(' + tempCache + ')');
// //先判断当前缓存数据内是否已经有相同的值,如果有相同的值则不进行插入操作,如果没有相同的值,则插入新的值
// var isExist = false;
// //开始遍历对象
// for(var j=0;j<jsonCacheObj.caches.length;j++){
// if(jsonCacheObj.caches[j].id == rowId){
// isExist = true;
// break;
// }
// }
// //如果没有重复的值,则自动插入到缓存内
// if(!isExist){
// //获取费用类型
// var feeType = commonGridObj_fee.getGridObj().cellByIndex(rowIndex,1).getValue() == "收"?1:2;
// //将当前费用选中
// commonGridObj_fee.getGridObj().cellByIndex(rowIndex,0).setValue(1);
//
// var newCache = jsonCacheObj.caches;
// newCache = {id:rowId,type:feeType,bsno:rId,cus:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,2).getValue().toString(),
// fname:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,3).getValue(),
// cur:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,4).getValue(),
// stl:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,5).getValue(),
// cstl:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,6).getValue(),
// ustl:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,7).getValue(),orig:"1",
// oname:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,3).getValue(),ocstl:commonGridObj_fee.getGridObj().cellByIndex(rowIndex,6).getValue()};
// //alert(newCache);
// jsonCacheObj.caches.push(newCache);
// //缓存数据
// $("h_feecache").value = JSON.stringify(jsonCacheObj);
// }
//
// }else{//缓存内没有数据创建新的数据
// var cacheBuffer = "";
// cacheBuffer += "{";
// cacheBuffer += "\"id\":\""+rowId+"\",";
// var feeType = commonGridObj_fee.getGridObj().cellByIndex(rowIndex,1).getValue() == "收"?1:2;
// cacheBuffer += "\"type\":"+feeType+",";
// cacheBuffer += "\"bsno\":\""+rId+"\",";
// cacheBuffer += "\"cus\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,2).getValue()+"\",";
// cacheBuffer += "\"fname\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,3).getValue()+"\",";
// cacheBuffer += "\"cur\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,4).getValue()+"\",";
// cacheBuffer += "\"stl\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,5).getValue()+"\",";//应结
// cacheBuffer += "\"cstl\":\""+commonGridObj_fee.getGridObj().cellByIndex(rowIndex,6).getValue()+"\",";//本次结算
// cacheBuffer += "\"ustl\":\""+commonGridObj_fee.getGridObj().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 += "}";
//
// var result = "";
// result += "{\"caches\":[";
// result += cacheBuffer;
// result += "]}";
// //生成新的缓存数据对象
// jsonCacheObj = eval('(' + result + ')');
// //每插入一条新记录,就快速记录到缓存数据内
// //缓存数据
// $("h_feecache").value = JSON.stringify(jsonCacheObj);
// }
// }
// //遍历完费用列表后,重新计算显示合计费用信息
// Statistics();
// }
// },50);
// }else{
// //如果委托信息某项选中状态改为不选中,则自动将此委托信息下的费用数据从缓存数据内删除
// setTimeout(function(){
// //获取缓存信息
// var tempCache = $("h_feecache").value;
// $("ck_allfee").checked = 0;
// //查看是否有缓存数据,如果有缓存数据则遍历缓存数据,费用信息表下的所有费用信息从缓存中清除
// if(tempCache.trim() != ""){
// jsonCacheObj = eval('(' + tempCache + ')');
// //查看费用Grid是否已经加载完毕
// if(commonGridObj_fee.getGridObj().getRowsNum() > 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 jsonCacheObj = null;
var strCache = $("h_feecache").value;
if(strCache.trim() != ""){
jsonCacheObj = eval('(' + strCache + ')');
var recvFeeRMB = 0.0;//应收人民币合计
var recvFeeUSD = 0.0;//应收美元合计
var recvFeeOTHER = 0.0;//应收其他币别
var payFeeRMB = 0.0;//应付人民币
var payFeeUSD = 0.0;//应付美元
var payFeeOTHER = 0.0;//应付其他币别
var totalRMBFee = 0.0;//人民币合计
var totalUSDFee = 0.0;//美元合计
var totalOTHERFee = 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{
recvFeeOTHER += cstl;
}
}else{
if(currency == "RMB"){
payFeeRMB += cstl;
}else if(currency == "USD"){
payFeeUSD += cstl;
}else{
payFeeOTHER += cstl;
}
}
}
totalRMBFee = recvFeeRMB - payFeeRMB;
totalUSDFee = recvFeeUSD - payFeeUSD;
totalOTHERFee = recvFeeOTHER - payFeeOTHER;
$("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 doApplicationInvoice(){
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 = "&currency=RMB";//按人民币结算
}else if(ckBoxUsd){
currency = "&currency=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 = "InvoiceApplicationModify.aspx?currency="+settleCurrency+"&uex=1&rex=1&cachename="+$("h_postsession").value
var openUrl = "InvoiceApplicationModify.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="+escape(rename)+"&detail="+detail+"&oplb="+selectoplb;
$("h_sessionid").value = 0;
window.open (openUrl,openType,openSet);
}
}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 = "InvoiceApplicationModify.aspx?currency="+settleCurrency+"&uex=1&rex=1&cachename="+$("h_postsession").value//+"&opinfo="+includeOpInfo
var openUrl = "InvoiceApplicationModify.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="+escape(rename)+"&detail="+detail+"&oplb="+selectoplb;
$("h_sessionid").value = 0;
window.open (openUrl,openType,openSet);
},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<jsonCacheObj.caches.length;i++){
// var strCurrency = jsonCacheObj.caches[i].cur;//获取币别信息
//
// if(strCurrency == "RMB" && ckBoxUsd){
// iCount++;
// break;
// }else if(strCurrency == "USD" && ckBoxRmb){
// iCount++;
// break;
// }
// }
// if(iCount > 0){
// openNewDiv("dvRate");//设置汇率
// }else{
// 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";
// }
// 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=1&rex=1&obj=ivappsession&opinfo="+includeOpInfo+"&rn="+rename+"&detail="+detail;
// $("h_sessionid").value = 0;
// window.open (openUrl,openType,openSet);
// }
//// var openSet = "height=460, width=800, toolbar=no, menubar=no,scrollbars=no, resizable=no,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=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=1&rex=1&obj=ivappsession&opinfo="+includeOpInfo+"&rn="+rename+"&detail="+detail;
// $("h_sessionid").value = 0;//alert(openUrl);
// window.open (openUrl,openType,openSet);
// }
// }
//}
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("$#$",".");
if(valObj.indexOf(".") == valObj.length-1){
valObj += "0";
}
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 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>";
setTimeout(function(){
document.body.appendChild(newDiv);
},30);
// 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";
setTimeout(function(){
document.body.appendChild(newMask);
},30);
}
//汇率设置取消
function rateCancel(){
// $("h_exrmbtousd").value = $("h_oldexusd").value;
// $("h_exusdtormb").value = $("h_oldexrmb").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";
// }
//
// document.body.removeChild(docEle("dvRate"));
// document.body.removeChild(docEle("mask"));
//
//
// 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;
// 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 = "&currency=RMB";//按人民币结算
change = "&exchange="+$("h_exusdtormb").value;
}else if(ckBoxUsd){
currency = "&currency=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 = "InvoiceApplicationModify.aspx?currency="+settleCurrency+"&uex="+$("h_exrmbtousd").value+"&rex="+$("h_exusdtormb").value+postSessionName
//+"&opinfo="+includeOpInfo
+ "&cno="+ckCustNo+"&vel="+ckVesselState+"&mbl="+ckMblno+"&etd="+ckEtd+"&pol="+ckPol+"&pod="+ckPod
+"&rn="+escape(rename)+"&detail="+detail+"&oplb="+selectoplb;
document.body.removeChild(docEle("dvRate"));
document.body.removeChild(docEle("mask"));
$("h_sessionid").value = 0;
window.open (openUrl,openType,openSet);
}
}else{
var rename = "";
var currency = "";
var change = "";
if(ckBoxRmb){
currency = "&currency=RMB";//按人民币结算
change = "&exchange="+$("h_exusdtormb").value;
}else if(ckBoxUsd){
currency = "&currency=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 = "InvoiceApplicationModify.aspx?currency="+settleCurrency+"&uex="+$("h_exrmbtousd").value+"&rex="+$("h_exusdtormb").value+postSessionName
//+"&opinfo="+includeOpInfo
+ "&cno="+ckCustNo+"&vel="+ckVesselState+"&mbl="+ckMblno+"&etd="+ckEtd+"&pol="+ckPol+"&pod="+ckPod
+"&rn="+escape(rename)+"&detail="+detail+"&oplb="+selectoplb;
document.body.removeChild(docEle("dvRate"));
document.body.removeChild(docEle("mask"));
$("h_sessionid").value = 0;
window.open (openUrl,openType,openSet);
},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 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_Accdate").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 += "]";
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=app";
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=app");
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 ="";
var oplb=commonGridObj_order.getGridObj().cellById(rId,1).getValue();
if(oplb=="海运出口")
{
selectoplb="op_Seae";
openUrl = "../baseinfo/opseaebaseinfo.aspx?handle=check&bsno="+rId;
}
else if(oplb=="海运进口")
{
selectoplb="op_Seai";
openUrl = "../baseinfo/opseaibaseinfo.aspx?handle=check&bsno="+rId;
}
else if (oplb == "仓储费") {
selectoplb = "wms_fee";
openUrl = "";
}
else if (oplb == "仓储入库") {
selectoplb = "wms";
openUrl = "";
}
else if (oplb == "仓储出库") {
selectoplb = "wms_out";
openUrl = "";
}
else if (oplb == "陆运托运") {
selectoplb = "tmswlbshead";
openUrl = "";
}
else if (oplb == "陆运派车") {
selectoplb = "tmswlpchead";
openUrl = "";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
openUrl = "../MvcShipping/MsOpApply/ApplyFeeView?handle=check&bsno=" + rId;
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
openUrl = "../MvcShipping/MsOpBulk/BulkFeeView?handle=check&bsno=" + rId;
}
window.open (openUrl,openType,openSet);
});
commonGridObj_order.getGridObj().attachEvent("onRowSelect", function(id,ind){
$("h_bsno").value = id;
var oplb=commonGridObj_order.getGridObj().cellById(id,1).getValue();
if(oplb=="海运出口")
{
selectoplb="op_Seae";
}
else if(oplb=="海运进口")
{
selectoplb="op_Seai";
}
else if (oplb == "仓储费") {
selectoplb = "wms_fee";
}
else if (oplb == "仓储入库") {
selectoplb = "wms";
}
else if (oplb == "仓储出库") {
selectoplb = "wms_out";
}
else if (oplb == "陆运托运") {
selectoplb = "tmswlbshead";
}
else if (oplb == "陆运派车") {
selectoplb = "tmswlpchead";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
}
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 = "";
var oplb=commonGridObj_order.getGridObj().cellById(rId,1).getValue();
if(oplb=="海运出口")
{
selectoplb="op_Seae";
}
else if(oplb=="海运进口")
{
selectoplb="op_Seai";
}
else if (oplb == "仓储费") {
selectoplb = "wms_fee";
}
else if (oplb == "仓储入库") {
selectoplb = "wms";
}
else if (oplb == "仓储出库") {
selectoplb = "wms_out";
}
else if (oplb == "陆运托运") {
selectoplb = "tmswlbshead";
}
else if (oplb == "陆运派车") {
selectoplb = "tmswlpchead";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
}
if(checkBox == 1){//委托选中状态
url = "InvoiceApplicationGridSource.aspx?handle=checkorder&oplb="+selectoplb+"&bsno="+rId+"&op=check&search="+escape(searchJson)+"&val="+commonGridObj_order.newGuid()+cacheName+bsnoCacheName+totalCacheName+"&do=app";
}else{//委托取消选中状态
url = "InvoiceApplicationGridSource.aspx?handle=checkorder&oplb="+selectoplb+"&bsno="+rId+"&op=uncheck&search="+escape(searchJson)+"&val="+commonGridObj_order.newGuid()+cacheName+bsnoCacheName+totalCacheName+"&do=app";
}
//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=app";
//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=paysettleapp");
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 = "";
var oplb=commonGridObj_order.getGridObj().cellById(rId,1).getValue();
if(oplb=="海运出口")
{
selectoplb="op_Seae";
openUrl = "../baseinfo/opseaebaseinfo.aspx?handle=check&bsno="+rId;
}
else if(oplb=="海运进口")
{
selectoplb="op_Seai";
openUrl = "../baseinfo/opseaibaseinfo.aspx?handle=check&bsno="+rId;
}
else if (oplb == "仓储费") {
selectoplb = "wms_fee";
openUrl = "";
}
else if (oplb == "仓储入库") {
selectoplb = "wms";
openUrl = "";
}
else if (oplb == "仓储出库") {
selectoplb = "wms_out";
openUrl = "";
}
else if (oplb == "陆运托运") {
selectoplb = "tmswlbshead";
openUrl = "";
}
else if (oplb == "陆运派车") {
selectoplb = "tmswlpchead";
openUrl = "";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
openUrl = "../MvcShipping/MsOpApply/ApplyFeeView?handle=check&bsno=" + rId;
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
openUrl = "../MvcShipping/MsOpBulk/BulkFeeView?handle=check&bsno=" + rId;
}
window.open (openUrl,openType,openSet);
});
commonGridObj_order.getGridObj().attachEvent("onRowSelect", function(id,ind){
$("h_bsno").value = id;
var oplb=commonGridObj_order.getGridObj().cellById(id,1).getValue();
if(oplb=="海运出口")
{
selectoplb="op_Seae";
}
else if(oplb=="海运进口")
{
selectoplb="op_Seai";
}
else if (oplb == "仓储费") {
selectoplb = "wms_fee";
}
else if (oplb == "仓储入库") {
selectoplb = "wms";
}
else if (oplb == "仓储出库") {
selectoplb = "wms_out";
}
else if (oplb == "陆运托运") {
selectoplb = "tmswlbshead";
}
else if (oplb == "陆运派车") {
selectoplb = "tmswlpchead";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
}
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 = "";
var oplb=commonGridObj_order.getGridObj().cellById(rId,1).getValue();
if(oplb=="海运出口")
{
selectoplb="op_Seae";
}
else if(oplb=="海运进口")
{
selectoplb="op_Seai";
}
else if (oplb == "仓储费") {
selectoplb = "wms_fee";
}
else if (oplb == "仓储入库") {
selectoplb = "wms";
}
else if (oplb == "仓储出库") {
selectoplb = "wms_out";
}
else if (oplb == "陆运托运") {
selectoplb = "tmswlbshead";
}
else if (oplb == "陆运派车") {
selectoplb = "tmswlpchead";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
}
if(checkBox == 1){//委托选中状态
url = "InvoiceApplicationGridSource.aspx?handle=checkorder&oplb="+selectoplb+"&bsno="+rId+"&op=check&search="+escape(searchJson)+"&val="+commonGridObj_order.newGuid()+cacheName+bsnoCacheName+totalCacheName+"&do=paysettleapp";
}else{//委托取消选中状态
url = "InvoiceApplicationGridSource.aspx?handle=checkorder&oplb="+selectoplb+"&bsno="+rId+"&op=uncheck&search="+escape(searchJson)+"&val="+commonGridObj_order.newGuid()+cacheName+bsnoCacheName+totalCacheName+"&do=paysettleapp";
}
//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);
}