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.
DS7/DSWeb/js/CommonRecvSettleApp.js

2852 lines
116 KiB
JavaScript

3 years ago
var commonGridObj_order;
var commonGridObj_fee;
var comboCustomer;//委托单位
var comboVessel;//船名
var comboVoyno;//航次
var comboBsType;//业务类型
var comboFeeName;//费用名称
var comboFeeType;//费用类型
var comboCurrency;//币别
var isLoad = 0;
var sel_val = new Array;
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("<input type=\"checkbox\" id=\"order_checkall\" onclick=\"orderCheckAll()\" />", "业务类别", "委托单位", "委托编号", "主提单号", "分提单号", "报关单号", "备案清单号");
//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.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 = "import_main";
openUrl = "";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
openUrl = "";
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
openUrl = "";
}
alert(oplb);
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 = "import_main";
openUrl = "";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
openUrl = "";
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
openUrl = "";
}
}else{
}
});
}
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("SettlementGridSourceApp.aspx");
var _bsno = commonGridObj_fee.$("h_bsno").value;//alert(_bsno);
var _feename = comboFeeName.getSelectedValue();
var _feetype = comboFeeType.getSelectedValue();//comboFeeType.getComboText().trim();
var _currency = comboCurrency.getSelectedValue();
var _customer = comboCustomer.getComboText().trim();
_feename = _feename == null ? "":_feename;
_feetype = _feetype == null?"":_feetype;
_currency = _currency == null?"":_currency;
var searchJson = "";
//begin
searchJson +="{";
searchJson += "[";
searchJson += "\"cus\":\""+_customer+"\","
searchJson += "\"fnm\":\""+_feename+"\","
searchJson += "\"fty\":\""+_feetype+"\",";
searchJson += "\"cur\":\""+_currency+"\"";
searchJson += "]";
searchJson +="}";//alert(searchJson);
var cacheName = "";
if($("h_cachename").value.trim() != ""){
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}
commonGridObj_fee.setRequest("SettlementGridSourceApp.aspx?handle=orderfee&bsno="+_bsno+"&fsearch="+escape(searchJson)+cacheName);
commonGridObj_fee.setSourceType("json");
commonGridObj_fee.setSkin("xp");
commonGridObj_fee.setImageUrl("../images/");
commonGridObj_fee.initGrid();
if(_bsno != ""){
commonGridObj_fee.bind();
}
commonGridObj_fee.getGridObj().enableEditEvents(true,false,true);
commonGridObj_fee.getGridObj().attachEvent("onCheckbox", function(rId,cInd,state){
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;
if(checkBox == 1){
url = "SettlementGridSourceApp.aspx?handle=checkfee&oplb=" + selectoplb + "&search=" + escape(searchJson) + cacheName + bsnoCacheName + totalCacheName + "&feeid=" + rId + "&op=check&uid=" + commonGridObj_order.newGuid() + "&do=recvsettleapp" + "&bsno=" + strBSNO;
}else{
url = "SettlementGridSourceApp.aspx?handle=checkfee&oplb=" + selectoplb + "&search=" + escape(searchJson) + cacheName + bsnoCacheName + totalCacheName + "&feeid=" + rId + "&op=uncheck&uid=" + commonGridObj_order.newGuid() + "&do=recvsettleapp" + "&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("没有权限添加费用");
}
});
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;
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 = "SettlementGridSourceApp.aspx?handle=changefee"+cacheName+bsnoCacheName+totalCacheName+"&oplb="+selectoplb+"&feeid="+rId+"&search="+escape(searchJson)+"&cstl="+cstl+"&ustl="+newStl+"&uid="+commonGridObj_fee.newGuid()+"&do=recvsettleapp"+"&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(); //币别
initComboOP(); //操作
}
function checkAll(gridObj){
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 = "SettlementGridSourceApp.aspx?handle=checkallfee&oplb="+selectoplb+"&search="+escape(searchJson)+cacheName+bsnoCacheName+totalCacheName+"&bsno="+bsnoVal+"&op=check&uid="+commonGridObj_order.newGuid()+"&do=recvsettleapp";
}else{
url = "SettlementGridSourceApp.aspx?handle=checkallfee&oplb="+selectoplb+"&search="+escape(searchJson)+cacheName+bsnoCacheName+totalCacheName+"&bsno="+bsnoVal+"&op=uncheck&uid="+commonGridObj_order.newGuid()+"&do=recvsettleapp";
}
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("没有权限添加费用");
}
// var checkBoxId = "";
//
// if(gridObj == commonGridObj_fee){
// checkBoxId = "ck_allfee";
// //如果费用全选按钮是选中状态
// if($(checkBoxId).checked){
// for(var i=0;i<gridObj.getGridObj().getRowsNum();i++){
// var cur_val = gridObj.getGridObj().cellByIndex(i,0).getValue();
// var rId = gridObj.getGridObj().getRowId(i);
// var rowIndex = i;
// var tempCache = $("h_feecache").value;
//
// if(tempCache.trim() == ""){//如果没有缓存记录
// var cacheBuffer = "";
// var result = "";
//
// cacheBuffer += "{";
// cacheBuffer += "\"id\":\""+rId+"\",";
// var rowIndex = gridObj.getGridObj().getRowIndex(rId);
// var feeType = gridObj.getGridObj().cellByIndex(rowIndex,1).getValue() == "收"?1:2;
// cacheBuffer += "\"type\":"+feeType+",";
// //cacheBuffer += "\"type\":\""+gridObj.getGridObj().cellByIndex(rowIndex,1).getValue()+"\",";
// cacheBuffer += "\"bsno\":\""+commonGridObj_order.getGridObj().getSelectedRowId()+"\",";
// cacheBuffer += "\"cus\":\""+gridObj.getGridObj().cellByIndex(rowIndex,2).getValue()+"\",";
// cacheBuffer += "\"fname\":\""+gridObj.getGridObj().cellByIndex(rowIndex,3).getValue()+"\",";
// cacheBuffer += "\"cur\":\""+gridObj.getGridObj().cellByIndex(rowIndex,4).getValue()+"\",";
// cacheBuffer += "\"stl\":\""+gridObj.getGridObj().cellByIndex(rowIndex,5).getValue()+"\",";//应结
// cacheBuffer += "\"cstl\":\""+gridObj.getGridObj().cellByIndex(rowIndex,6).getValue()+"\",";//本次结算
// cacheBuffer += "\"ustl\":\""+gridObj.getGridObj().cellByIndex(rowIndex,7).getValue()+"\"";//未结
// cacheBuffer += "}";
//
// result += "{\"caches\":[";
// result += cacheBuffer;
// result += "]}";
//
// jsonCacheObj = eval('(' + result + ')');
//
// gridObj.getGridObj().cellByIndex(i,0).setValue(1);
// $("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.getGridObj().cellByIndex(rowIndex,1).getValue() == "收"?1:2;
// newCache = {id:rId,type:feeType,bsno:rId,cus:gridObj.getGridObj().cellByIndex(rowIndex,2).getValue(),fname:gridObj.getGridObj().cellByIndex(rowIndex,3).getValue(),cur:gridObj.getGridObj().cellByIndex(rowIndex,4).getValue(),stl:gridObj.getGridObj().cellByIndex(rowIndex,5).getValue(),cstl:gridObj.getGridObj().cellByIndex(rowIndex,6).getValue(),ustl:gridObj.getGridObj().cellByIndex(rowIndex,7).getValue()};
// jsonCacheObj.caches.push(newCache);
// gridObj.getGridObj().cellByIndex(i,0).setValue(1);
// $("h_feecache").value = JSON.stringify(jsonCacheObj);
// //$("dvResult").innerHTML = JSON.stringify(jsonCacheObj);
// }
// }
// }
// Statistics();
// }else{ //如果费用全选按钮是未选中状态
// var jsonCacheObj;
// var tempCache = $("h_feecache").value;
// if(tempCache.trim() != ""){
// jsonCacheObj = eval('(' + tempCache + ')');
// for(var i=0;i<gridObj.getGridObj().getRowsNum();i++){
// var cur_val = gridObj.getGridObj().cellByIndex(i,0).getValue();
// var rId = gridObj.getGridObj().getRowId(i);
// var tempCache = $("h_feecache").value;
//
// for(var j = jsonCacheObj.caches.length-1;j >= 0;j--){
// if(jsonCacheObj.caches[j].id == rId){
// if(jsonCacheObj.caches.length == 0){
// jsonCacheObj.caches.shift();
// $("h_feecache").value = "";
// commonGridObj_fee.getGridObj().cellByIndex(i,0).setValue(0);
//
// }else{
// if(jsonCacheObj.caches.length == 1){
// jsonCacheObj.caches.shift();
// $("h_feecache").value = "";
// commonGridObj_fee.getGridObj().cellByIndex(i,0).setValue(0);
//
// }else{
// jsonCacheObj.caches.splice(j,1);
// $("h_feecache").value = JSON.stringify(jsonCacheObj);
// commonGridObj_fee.getGridObj().cellByIndex(i,0).setValue(0);
//
// break;
// }
// }
//
// }
// }
//
// //$("dvResult").innerHTML = $("h_feecache").value;
// }
// }
// Statistics();
// }
// }else if(gridObj == commonGridObj_order){
// var checkType = 0;
// if($("ck_all").checked){
// checkType = 1;
// }else{
// checkType = 0;
// }
// for(var k=0;k < commonGridObj_order.getGridObj().getRowsNum();k++){
// if(checkType == 1){
// commonGridObj_order.getGridObj().cellByIndex(k,0).setValue(1);
// }else{
// commonGridObj_order.getGridObj().cellByIndex(k,0).setValue(0);
// }
// }
// }
}
function createComboBsType(){
comboBsType = dhtmlXComboFromSelect("sel_bstype");
}
function createComboFeeName(){
comboFeeName = dhtmlXComboFromSelect("sel_feename");
comboFeeName.loadXML("../FeeCodes/FeeCodeService.aspx?mask=0&pos=0&handle=all");
comboFeeName.attachEvent("onChange", function(){
comboFeeName.setComboText($("h_feename").value);
});
comboFeeName.attachEvent("onBlur", function(){
var s1 = comboFeeName.getComboText().trim();
var s2 = s1.indexOf("|");
if(s2>0){
s2=s2+2;
}
var s3 = s1.substring(s2);
if(s2>0){
comboFeeName.setComboText(s3);
$("h_feename").value=s3;
}
else
{
comboCustomer.setComboText($("h_feename").value);
}
});
comboFeeName.setComboText($("h_feename").value);
comboFeeName.attachEvent("onKeyPressed", function(keyCode){
if(keyCode!="8"){
var arrayArg = new Array();
setTimeout(function(){
var filterCount = 0;
var is = -1;
var ishd = $("h_feename").value.trim();
if("" != comboFeeName.getComboText().trim()){
while("undefined" != typeof comboFeeName.getOptionByIndex(filterCount)){
var comboValue = comboFeeName.getOptionByIndex(filterCount).text.toUpperCase();//.value;
var enterValue = comboFeeName.getComboText().trim().toUpperCase();
$("h_feename").value = comboFeeName.getComboText().trim().toUpperCase();
if(comboValue.indexOf(enterValue) == 0){
comboFeeName.selectOption(filterCount,true,true);
is=filterCount;
break;
}
++filterCount;
}
if(is==-1){
$("h_feename").value = ishd;
alert("无此内容,请重新选择!");
}
}
},10);
}
});
comboFeeName.attachEvent("onSelectionChange", function(){
$("h_feename").value = comboFeeName.getComboText().trim();
});
}
function createComboFeeType(){
comboFeeType = dhtmlXComboFromSelect("sel_feetype");
}
function createComboCurrency(){
comboCurrency = dhtmlXComboFromSelect("sel_currency");
}
function searchOrder() {
var dg = new dialog();
dg.html = "程序正在执行,请稍等!";
//dg.html+="<input type=button onclick='new dialog().close();' value='确定'>";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
//
// //重新搜索后将缓存数据清除
// $("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 _accStartime = $("txt_AccSta").value.trim();//20130821会计期间
//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 += "\"accSta\":\"" + _accStartime + "\",";
searchJson += "\"op\":\"" + $("hd_comboOP").value.trim() + "\"";
//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("SettlementGridSourceApp.aspx?handle=ordersearch&bstype="+_bstype+"&search="+escape(searchJson)+cacheName+"&uid="+commonGridObj_order.newGuid()+"&do=recvsettleapp");
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 = "import_main";
openUrl = "";
} else if (oplb == "报关业务") {
Selectoplb = "op_apply";
openUrl = "../MvcShipping/MsOpApply/ApplyFeeView?handle=check&bsno=" + rId;
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
openUrl = "";
}
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 = "import_main";
openUrl = "";
}
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 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 = "import_main";
openUrl = "";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
}
var state = 0;
var cacheName = "";
var bsnoCacheName = "";
var totalCacheName = "";
if($("h_cachename").value.trim() != ""){
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}else{
$("h_cachename").value = commonGridObj_order.newGuid();
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}
if($("h_bsnocache").value.trim() != ""){
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}else{
$("h_bsnocache").value = commonGridObj_order.newGuid();
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}
if($("h_totalcache").value.trim() != ""){
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}else{
$("h_totalcache").value = commonGridObj_order.newGuid();
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}
var orderRowIndex = commonGridObj_order.getGridObj().getRowIndex(rId);
var checkBox = commonGridObj_order.getGridObj().cellByIndex(orderRowIndex,0).getValue();
var url = "";
if(checkBox == 1){//委托选中状态
url = "SettlementGridSourceApp.aspx?handle=checkorder&oplb="+selectoplb+"&bsno="+rId+"&op=check&search="+escape(searchJson)+cacheName+bsnoCacheName+totalCacheName+"&val="+commonGridObj_order.newGuid()+"&do=recvsettleapp";
}else{//委托取消选中状态
url = "SettlementGridSourceApp.aspx?handle=checkorder&oplb="+selectoplb+"&bsno="+rId+"&op=uncheck&search="+escape(searchJson)+cacheName+bsnoCacheName+totalCacheName+"&val="+commonGridObj_order.newGuid()+"&do=recvsettleapp";
}
//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();
}
//
setTimeout(function () {
dg.close();
}, 3000);
}
//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 doSettle(){ //"申请上述费用"
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";//按美元结算
}else{
//currency = "&currency=ALL";//分别按各自币别结算
alert("不同的币别不能同时结算,请 分别申请 或 折合成同一币别 申请!");
return;
}
validateUrl = "SettlementGridSourceApp.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;
}
else {
// var validTypeNameUrl = "SettlementGridSourceApp.aspx?handle=valiBsnoType" + bsnoCacheName + currency + "&uid=" + commonGridObj_order.newGuid();
// var loaders = dhtmlxAjax.getSync(validTypeNameUrl);
// var valibsnoValue = loaders.xmlDoc.responseText;
// if (valibsnoValue != "" && valibsnoValue == "disff") {
// 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 = "";
postSessionUrl = "SettlementGridSourceApp.aspx?handle=postpaysettle"+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=480, width=800, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " + (screen.height - 480) / 2 + ",Left= " + (screen.width - 800) / 2
var openType = "_blank";
var settleCurrency = "";
if ($("ck_rmb").checked) {
settleCurrency = "1";
} else if ($("ck_usd").checked) {
settleCurrency = "2";
} else {
settleCurrency = "3";
}
//
if (selectoplb.trim() == "") {
var checked = commonGridObj_order.getGridObj().getCheckedRows(1); //所有选中的grid的id编号
var ii = checked.indexOf(",");
var rid1 = "";
if (ii < 0) {
rid1 = checked;
}
else {
rid1 = checked.substr(0, ii);
}
var oplb = commonGridObj_order.getGridObj().cellById(rid1, 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 = "import_main";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
}
else if (oplb == "海运进口散货") {
selectoplb = "op_Seai";
}
}
//
var openUrl = "DoRecvApplication.aspx?currency=" + settleCurrency + "&oplb=" + selectoplb + "&uex=1&rex=1&obj=" + $("h_postsession").value;
$("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){
openNewDiv("dvRate");//设置汇率
var openSet = "height=450, width=800, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-450)/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=480, width=800, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-480)/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 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 = 1 / usdRate;
// var usdToRmb = usdRate;
var moduleName = "";
if($("h_mod").value != ""){
moduleName = "&mod="+$("h_mod").value;
}
var openUrl = "DoRecvApplication.aspx?currency=" + settleCurrency + "&oplb=" + selectoplb + "&uex=1&rex=1&obj=feepaysession" + moduleName;
$("h_sessionid").value = 0;
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("$#$",".");
return valObj;
}
function isObjNaN(Obj){
if(Obj.toString().toLowerCase() == "nan"){
return 0;
}else{
return Obj;
}
}
function doSettleCurrency(clickObj) {
if (clickObj == "ck_rmb") {
if ($("ck_usd").checked) {
$("ck_usd").checked = 0;
}
} else {
if ($("ck_rmb").checked) {
$("ck_rmb").checked = 0;
}
}
}
var docEle = function() {
return document.getElementById(arguments[0]) || false;
}
function openNewDiv(_id) {
var m = "mask";
if (docEle(_id)) document.removeChild(docEle(_id));
if (docEle(m)) document.removeChild(docEle(m));
// 新激活图层
var newDiv = document.createElement("div");
newDiv.id = _id;
newDiv.style.position = "absolute";
newDiv.style.zIndex = "9999";
newDiv.style.width = "400px";
newDiv.style.height = "120px";
newDiv.style.top = "100px";
newDiv.style.left = (parseInt(document.body.scrollWidth) - 300) / 2 + "px"; // 屏幕居中
newDiv.style.background = "#EFEFEF";
newDiv.style.border = "1px solid #860001";
newDiv.style.padding = "5px";
var urlVal = "../feecodes/CurrencyAdapter.aspx?handle=drate&val="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
loader = null;
var jsonCacheObj;
var rmbRate = 0.0;
var usdRate = 0.0;
if(loadVal.length > 0){
jsonCacheObj = eval('(' + loadVal + ')');
if(jsonCacheObj != null){
for(var i = 0;i<jsonCacheObj.drate.length;i++){
if(jsonCacheObj.drate[i].code == "RMB"){
rmbRate = parseFloat(jsonCacheObj.drate[i].drate);
}else if(jsonCacheObj.drate[i].code == "USD"){
usdRate = parseFloat(jsonCacheObj.drate[i].drate);
}
}
}
}
//人民币对美元汇率
var rmbToUsd = fomatFloat(1 / usdRate,5);
var usdToRmb = usdRate;
$("h_exrmbtousd").value = rmbToUsd;
$("h_exusdtormb").value = usdToRmb;
newDiv.innerHTML = "<table><tr><td colspan=\"5\" height=\"20px\"><div>币别汇率转换</div></td></tr><tr><td><div>1 RMB = </div></td><td><input type=\"hidden\" id=\"h_oldexusd\" value=\""+rmbToUsd+"\"/><input type=\"text\" id=\"txt_exusd\" width=\"40px\" value=\""+rmbToUsd+"\"/ onkeyup=\"exchangeCovert(this,txt_exrmb,1)\"></td>"
+ "<td><div>&nbsp;&nbsp;USD</div></td><td width=\"15px\"></td><td><input type=\"button\" id=\"btn_enter\" value=\"确定\" class=\"btn\" onclick=\"rateEnter()\"/><td></tr><tr><td><div>1 USD = </div></td>"
+ "<td><input type=\"hidden\" id=\"h_oldexrmb\" value=\""+usdToRmb+"\"/><input type=\"text\" id=\"txt_exrmb\" width=\"40px\" value=\""+usdToRmb+"\" onkeyup=\"exchangeCovert(this,txt_exusd,2)\"/></td><td><div>&nbsp;&nbsp;RMB</div></td><td width=\"15px\"></td><td><input type=\"button\" id=\"btn_cancel\" value=\"取消\" class=\"btn\" onclick=\"rateCancel()\"/></td></tr></table>";
document.body.appendChild(newDiv);
// mask图层
var newMask = document.createElement("div");
newMask.id = m;
newMask.style.position = "absolute";
newMask.style.zIndex = "1";
newMask.style.width = document.body.scrollWidth + "px";
newMask.style.height = document.body.scrollHeight + "px";
newMask.style.top = "0px";
newMask.style.left = "0px";
newMask.style.background = "#000";
newMask.style.filter = "alpha(opacity=40)";
newMask.style.opacity = "0.40";
document.body.appendChild(newMask);
}
//汇率设置取消
function rateCancel(){
// $("h_exrmbtousd").value = $("h_oldexusd").value;
// $("h_exusdtormb").value = $("h_oldexrmb").value;
//
// var openSet = "height=450, width=800, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-450)/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 moduleName = "";
//
// if($("h_mod").value != ""){
// moduleName = "&mod="+$("h_mod").value;
// }
// var openUrl = "DoRecvApplication.aspx?currency="+settleCurrency+"&uex="+$("h_exrmbtousd").value+"&rex="+$("txt_exrmb").value+"&obj=feepaysession" + moduleName;
// $("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 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 = "";
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;
}else{
currency = "&currency=ALL";//按各自的币别结算
}
postSessionUrl = "SettlementGridSourceApp.aspx?handle=postpaysettle"+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){
var openSet = "height=480, width=800, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-480)/2 + ",Left= "+(screen.width-800)/2
var openType = "_blank";
var settleCurrency = "";
if($("ck_rmb").checked){
settleCurrency = "1";
}else if($("ck_usd").checked){
settleCurrency = "2";
}else{
settleCurrency = "3";
}
var openUrl = "DoRecvApplication.aspx?currency=" + settleCurrency + "&oplb=" + selectoplb + "&uex=" + $("h_exrmbtousd").value + "&rex=" + $("h_exusdtormb").value + "&obj=" + $("h_postsession").value;
document.body.removeChild(docEle("dvRate"));
document.body.removeChild(docEle("mask"));
$("h_sessionid").value = 0;
window.open (openUrl,openType,openSet);
}
// $("h_exrmbtousd").value = $("txt_exusd").value;
// $("h_exusdtormb").value = $("txt_exrmb").value;
//
// var openSet = "height=450, width=800, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-450)/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 moduleName = "";
//
// if($("h_mod").value != ""){
// moduleName = "&mod="+$("h_mod").value;
// }
// var openUrl = "DoRecvApplication.aspx?currency="+settleCurrency+"&uex="+$("h_exrmbtousd").value+"&rex="+$("txt_exrmb").value+"&obj=feepaysession" + moduleName;
// $("h_sessionid").value = 0;
//
// //删除图层
// document.body.removeChild(docEle("dvRate"));
// document.body.removeChild(docEle("mask"));
// window.open (openUrl,openType,openSet);
}
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("全部");
}
//清空操作
if (comboOP != null) {
$("hd_comboOP").value = "";
comboOP.setComboText($("hd_comboOP").value);
}
$("txt_beginTime").value = "";//清空业务日期 起始时间
$("txt_endTime").value = "";//清空业务日期 结束时间
$("txt_billNO").value = "";//清空编号 文本框
//$("txt_debitno").value = "";//清空对账编号
$("h_feecache").value = "";
//初始化Grid
createOrder();
commonGridObj_fee.initGrid();
Statistics();
}
function orderCheckAll(){
if(commonGridObj_order != null){
var jsonOrderCacheObj = null;
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 += "\"op\":\"" + $("hd_comboOP").value.trim() + "\"";
//searchJson += "\"ise\":\""+_is_settled+"\"";
//searchJson += "\"fty\":\""+_feetype+"\",";
//searchJson += "\"cur\":\""+_currency+"\"";
searchJson += "]";
searchJson +="}";
var checkStatus = $("order_checkall").checked;
//如果费用全选按钮是选中状态,则将所有委托相关的数据进行缓存
if(checkStatus){
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 = "SettlementGridSourceApp.aspx?handle=cacheorder&bsnocachename=" + $("h_bsnocache").value + "&ordercachename=" + $("h_cachename").value + "&totalcachename=" + $("h_totalcache").value + "&op=check&search=" + escape(searchJson) + "&val=" + commonGridObj_order.newGuid() + "&do=recvsettleapp&bstype=" + _bstype;
var loader = dhtmlxAjax.getSync(url);
var cacheTotal = "";
var cacheTotalObj = null;
var cacheVal = loader.xmlDoc.responseText;
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("SettlementGridSourceApp.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=recvsettleapp&bstype=" + _bstype);
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 = "import_main";
openUrl = "";
} else if (oplb == "报关业务") {
Selectoplb = "op_apply";
openUrl = "../MvcShipping/MsOpApply/ApplyFeeView?handle=check&bsno=" + rId;
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
openUrl = "";
}
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 = "import_main";
openUrl = "";
}
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 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 = "import_main";
openUrl = "";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
}
var state = 0;
var cacheName = "";
var bsnoCacheName = "";
var totalCacheName = "";
if($("h_cachename").value.trim() != ""){
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}else{
$("h_cachename").value = commonGridObj_order.newGuid();
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}
if($("h_bsnocache").value.trim() != ""){
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}else{
$("h_bsnocache").value = commonGridObj_order.newGuid();
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}
if($("h_totalcache").value.trim() != ""){
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}else{
$("h_totalcache").value = commonGridObj_order.newGuid();
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}
var orderRowIndex = commonGridObj_order.getGridObj().getRowIndex(rId);
var checkBox = commonGridObj_order.getGridObj().cellByIndex(orderRowIndex,0).getValue();
var url = "";
if(checkBox == 1){//委托选中状态
url = "SettlementGridSourceApp.aspx?handle=checkorder&oplb=" + selectoplb + "&bsno=" + rId + "&op=check&search=" + escape(searchJson) + "&val=" + commonGridObj_order.newGuid() + cacheName + bsnoCacheName + totalCacheName + "&do=recvsettleapp&bstype=" + _bstype;
}else{//委托取消选中状态
url = "SettlementGridSourceApp.aspx?handle=checkorder&oplb=" + selectoplb + "&bsno=" + rId + "&op=uncheck&search=" + escape(searchJson) + "&val=" + commonGridObj_order.newGuid() + cacheName + bsnoCacheName + totalCacheName + "&do=recvsettleapp&bstype=" + _bstype;
}
//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($("h_cachename").value != ""){
}else{
$("h_cachename").value = commonGridObj_order.newGuid();
}
if($("h_bsnocache").value != ""){
}else{
$("h_bsnocache").value = commonGridObj_order.newGuid();
}
var url = "SettlementGridSourceApp.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=recvsettleapp&bstype=" + _bstype;
//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("SettlementGridSourceApp.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=recvsettleapp&bstype=" + _bstype);
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 = "import_main";
openUrl = "";
} else if (oplb == "报关业务") {
Selectoplb = "op_apply";
openUrl = "../MvcShipping/MsOpApply/ApplyFeeView?handle=check&bsno=" + rId;
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
openUrl = "";
}
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 = "import_main";
openUrl = "";
}
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 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 = "import_main";
openUrl = "";
}
else if (oplb == "报关业务") {
selectoplb = "op_apply";
}
else if (oplb == "大宗散货") {
selectoplb = "op_bulk";
}
var state = 0;
var cacheName = "";
var bsnoCacheName = "";
var totalCacheName = "";
if($("h_cachename").value.trim() != ""){
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}else{
$("h_cachename").value = commonGridObj_order.newGuid();
cacheName = "&ordercachename="+$("h_cachename").value.trim();
}
if($("h_bsnocache").value.trim() != ""){
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}else{
$("h_bsnocache").value = commonGridObj_order.newGuid();
bsnoCacheName = "&bsnocachename="+$("h_bsnocache").value.trim();
}
if($("h_totalcache").value.trim() != ""){
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}else{
$("h_totalcache").value = commonGridObj_order.newGuid();
totalCacheName = "&totalcachename="+$("h_totalcache").value.trim();
}
var orderRowIndex = commonGridObj_order.getGridObj().getRowIndex(rId);
var checkBox = commonGridObj_order.getGridObj().cellByIndex(orderRowIndex,0).getValue();
var url = "";
if(checkBox == 1){//委托选中状态
url = "SettlementGridSourceApp.aspx?handle=checkorder&oplb=" + selectoplb + "&bsno=" + rId + "&op=check&search=" + escape(searchJson) + "&val=" + commonGridObj_order.newGuid() + cacheName + bsnoCacheName + totalCacheName + "&do=recvsettleapp&bstype=" + _bstype;
}else{//委托取消选中状态
url = "SettlementGridSourceApp.aspx?handle=checkorder&oplb=" + selectoplb + "&bsno=" + rId + "&op=uncheck&search=" + escape(searchJson) + "&val=" + commonGridObj_order.newGuid() + cacheName + bsnoCacheName + totalCacheName + "&do=recvsettleapp&bstype=" + _bstype;
}
//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)+"项 未取消");
}
}
}
}
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 refreshParentDialog(){
if($("h_refreshstate").value.trim() != ""){
window.parent.opener.location.href = window.parent.opener.location.href;
//parentObj.href = newUrl;
}
}
function fomatFloat(src,pos){
return Math.round(src*Math.pow(10, pos))/Math.pow(10, pos);
}
var comboOP; //操作人员
function initComboOP()//操作人员
{
//生成
comboOP = dhtmlXComboFromSelect("ddlOP");
comboOP.loadXML("../FeeCodes/OPAdapter.aspx?mask=0&pos=0&rName=isOperator&userID=" + $("hdUserID").value);
//
comboOP.attachEvent("onChange", function () {
comboOP.setComboText($("hd_comboOP").value);
});
comboOP.attachEvent("onBlur", function () {
var s1 = comboOP.getComboText().trim();
var s2 = s1.indexOf("|");
if (s1 == "") {
$("hd_comboOP").value = "";
comboOP.setComboText($("hd_comboOP").value);
}
else {
if (s2 > 0) {
s2 = s2 + 2;
}
var s3 = s1.substring(s2);
if (s2 > 0) {
comboOP.setComboText(s3);
$("hd_comboOP").value = s3;
}
else {
comboOP.setComboText($("hd_comboOP").value);
}
}
});
comboOP.setComboText($("hd_comboOP").value);
comboOP.attachEvent("onKeyPressed", function (keyCode) {
if (keyCode != "8") {
var arrayArg = new Array();
setTimeout(function () {
var filterCount = 0;
var is = -1;
var ishd = $("hd_comboOP").value.trim();
if ("" != comboOP.getComboText().trim()) {
while ("undefined" != typeof comboOP.getOptionByIndex(filterCount)) {
var comboValue = comboOP.getOptionByIndex(filterCount).text.toUpperCase(); //.value;
var enterValue = comboOP.getComboText().trim().toUpperCase();
$("hd_comboOP").value = comboOP.getComboText().trim().toUpperCase();
if (comboValue.indexOf(enterValue) == 0) {
comboOP.selectOption(filterCount, true, true);
is = filterCount;
break;
}
++filterCount;
}
if (is == -1) {
$("hd_comboOP").value = ishd;
alert("无此内容,请重新选择!");
}
}
}, 10);
}
});
comboOP.attachEvent("onSelectionChange", function () {
$("hd_comboOP").value = comboOP.getComboText().trim();
});
}
function dialog() {
this.width = 450;
this.height = 360;
this.title_height = 20;
this.html = '';
this.title = '';
var self = this;
var bgObj, msgObj, titleObj;
this.close = function () {
document.body.removeChild(document.getElementById("bgDiv"));
document.getElementById("msgDiv").removeChild(document.getElementById("msgTitle"));
document.body.removeChild(document.getElementById("msgDiv"));
}
this.show = function () {
var msgw, msgh, bordercolor;
msgw = self.width;
msgh = self.height;
bordercolor = "#336699";
titlecolor = "#99CCFF";
var sWidth, sHeight;
sWidth = document.body.offsetWidth;
sHeight = screen.height;
bgObj = document.createElement("div");
bgObj.setAttribute('id', 'bgDiv');
bgObj.style.position = "absolute";
bgObj.style.top = "0";
bgObj.style.background = "#777";
bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
bgObj.style.opacity = "0.6";
bgObj.style.left = "0";
bgObj.style.width = sWidth + "px";
bgObj.style.height = sHeight + "px";
bgObj.style.zIndex = "10000";
document.body.appendChild(bgObj);
msgObj = document.createElement("div")
msgObj.setAttribute("id", "msgDiv");
msgObj.setAttribute("align", "center");
msgObj.style.background = "white";
msgObj.style.border = "1px solid " + bordercolor;
msgObj.style.position = "absolute";
msgObj.style.left = "50%";
msgObj.style.top = "30%";
msgObj.style.font = "12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
msgObj.style.marginLeft = "-225px";
msgObj.style.marginTop = -75 + document.documentElement.scrollTop + "px";
msgObj.style.width = msgw + "px";
msgObj.style.height = msgh + "px";
msgObj.style.textAlign = "center";
msgObj.style.lineHeight = "25px";
msgObj.style.zIndex = "10001";
titleObj = document.createElement("h4");
titleObj.setAttribute("id", "msgTitle");
titleObj.setAttribute("align", "center");
titleObj.style.margin = "0";
titleObj.style.padding = "3px";
titleObj.style.background = bordercolor;
titleObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
titleObj.style.opacity = "0.75";
titleObj.style.border = "1px solid " + bordercolor;
titleObj.style.height = self.title_height + "px";
titleObj.style.font = "12px Verdana, Geneva, Arial, Helvetica, sans-serif";
titleObj.style.color = "white";
titleObj.style.cursor = "pointer";
titleObj.innerHTML = self.title;
//titleObj.onclick=function(){self.close();}
document.body.appendChild(msgObj);
document.getElementById("msgDiv").appendChild(titleObj);
var txt = document.createElement("div");
txt.style.margin = "1em 0"
txt.setAttribute("id", "msgTxt");
txt.innerHTML = self.html;
document.getElementById("msgDiv").appendChild(txt);
}
}
function msgBox() {
var dg = new dialog();
dg.html = "程序正在提交,请稍等!";
//dg.html+="<input type=button onclick='new dialog().close();' value='确定'>";
dg.width = 200;
dg.height = 100;
dg.title = "标题";
dg.show();
}