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.

2428 lines
102 KiB
JavaScript

12 months 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
//var headerArgs_order = 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", "120", "130", "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 = "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 = "";
}
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="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 = "";
}
}
});
}
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 +="}";
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();
var _feename = comboFeeName.getSelectedValue();
var _feetype = comboFeeType.getSelectedValue();
var _currency = comboCurrency.getSelectedValue();
_feename = _feename == null ? "" : _feename;
_feetype = _feetype == null ? "" : _feetype;
_currency = _currency == null ? "" : _currency;
var searchJson = "";
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 += "\"fnm\":\"" + _feename + "\",";
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 = 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=paysettleapp" + "&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=paysettleapp" + "&bsno=" + strBSNO;
}
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 = cacheTotalObj.totals[0].state;
}
}
if (state < 0) {
commonGridObj_fee.getGridObj().cellByIndex(rowIndex, 0).setValue(0);
alert("没有权限添加费用");
}
// //动态计算当前选中行的人民币、美元应收应付合计金额
// var rIds = commonGridObj_fee.getGridObj().getCheckedRows(0); //所有选中的grid的id编号
// url = "SettlementGridSourceApp.aspx?handle=getchecksumfeejson&do=paysettleapp&feeid=" + rIds + "&uid=" + commonGridObj_order.newGuid();
// loader = dhtmlxAjax.getSync(url);
// cacheVal = loader.xmlDoc.responseText;
// if (cacheVal.trim().length > 1) {
// cacheTotalObj = eval('(' + cacheVal.trim() + ')');
// if (cacheTotalObj.totals.length > 0) {
// $("dvTotalRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].rmb.toString());
// $("dvTotalUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].usd.toString());
// }
// }
//
});
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(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();
var _feename = comboFeeName.getSelectedValue();
var _feetype = comboFeeType.getSelectedValue();
var _currency = comboCurrency.getSelectedValue();
_feename = _feename == null ? "":_feename;
_feetype = _feetype == null?"":_feetype;
_currency = _currency == null ? "" : _currency;
var searchJson = "";
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 += "\"fnm\":\""+_feename+"\",";
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=paysettleapp"+"&bsno="+strBSNO;
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 = cacheTotalObj.totals[0].state;
}
}
if(state < 0){
commonGridObj_fee.getGridObj().cellByIndex(rowIndex,0).setValue(0);
alert("没有权限修改添加费用");
return false;
} else {
// //动态计算当前选中行的人民币、美元应收应付合计金额
// var rIds = commonGridObj_fee.getGridObj().getCheckedRows(0); //所有选中的grid的id编号
// url = "SettlementGridSourceApp.aspx?handle=getchecksumfeejson&do=paysettleapp&feeid=" + rIds + "&uid=" + commonGridObj_order.newGuid();
// loader = dhtmlxAjax.getSync(url);
// cacheVal = loader.xmlDoc.responseText;
// if (cacheVal.trim().length > 1) {
// cacheTotalObj = eval('(' + cacheVal.trim() + ')');
// if (cacheTotalObj.totals.length > 0) {
// $("dvTotalRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].rmb.toString());
// $("dvTotalUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].usd.toString());
// }
// }
//
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();
var _feename = comboFeeName.getSelectedValue();
var _feetype = comboFeeType.getSelectedValue();
var _currency = comboCurrency.getSelectedValue();
_feename = _feename == null ? "":_feename;
_feetype = _feetype == null?"":_feetype;
_currency = _currency == null?"":_currency;
var searchJson = "";
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 += "\"fnm\":\""+_feename+"\",";
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 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=paysettleapp";
}else{
url = "SettlementGridSourceApp.aspx?handle=checkallfee&oplb="+selectoplb+"&search="+escape(searchJson)+cacheName+bsnoCacheName+totalCacheName+"&bsno="+bsnoVal+"&op=uncheck&uid="+commonGridObj_order.newGuid()+"&do=paysettleapp";
}
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);
}
}
createFeeList();
$("ck_allfee").checked = checkBox;
if(state < 0){
$("ck_allfee").checked = 0;
alert("没有权限添加费用");
}
}
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();
//
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();
var _feename = comboFeeName.getSelectedValue();
var _feetype = comboFeeType.getSelectedValue();
var _currency = comboCurrency.getSelectedValue();
_feename = _feename == null ? "":_feename;
_feetype = _feetype == null?"":_feetype;
_currency = _currency == null ? "" : _currency;
var _accStartime = $("txt_AccSta").value.trim(); //20130821会计期间
var searchJson = "";
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 += "\"fnm\":\""+_feename+"\",";
searchJson += "\"fty\":\""+_feetype+"\",";
searchJson += "\"cur\":\"" + _currency + "\",";
searchJson += "\"accSta\":\"" + _accStartime + "\",";
searchJson += "\"op\":\"" + $("hd_comboOP").value.trim() + "\"";
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=paysettleapp");
commonGridObj_order.initGrid();
commonGridObj_order.bind();
// $("dvTotalRMBVal").innerHTML = "0";
// $("dvTotalUSDVal").innerHTML = "0";
$("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="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="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";
}
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="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";
}
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=paysettleapp";
}else{//委托取消选中状态
url = "SettlementGridSourceApp.aspx?handle=checkorder&oplb="+selectoplb+"&bsno="+rId+"&op=uncheck&search="+escape(searchJson)+cacheName+bsnoCacheName+totalCacheName+"&val="+commonGridObj_order.newGuid()+"&do=paysettleapp";
}
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("没有权限添加费用");
}
// //动态计算当前选中行的人民币、美元应收应付合计金额
// var rIds = commonGridObj_fee.getGridObj().getCheckedRows(0); //所有选中的grid的id编号
// url = "SettlementGridSourceApp.aspx?handle=getchecksumfeejson&do=paysettleapp&feeid=" + rIds + "&uid=" + commonGridObj_order.newGuid();
// loader = dhtmlxAjax.getSync(url);
// cacheVal = loader.xmlDoc.responseText;
// if (cacheVal.trim().length > 1) {
// cacheTotalObj = eval('(' + cacheVal.trim() + ')');
// if (cacheTotalObj.totals.length > 0) {
// $("dvTotalRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].rmb.toString());
// $("dvTotalUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].usd.toString());
// }
// }
//
});
if(commonGridObj_fee != null){
createFeeList();
}
//
setTimeout(function () {
dg.close();
}, 3000);
}
function saveSettleFee(){
var settleFee = "";
settleFee +="{";
settleFee += "[";
settleFee += "]";
settleFee +="}";
}
function getCacheFee(){
var cacheBuffer = $("h_feecache").value;
}
//统计合计费用信息
function Statistics(){
var jsonCacheObj = null;
var strCache = $("h_feecache").value;
if(strCache.trim() != ""){
jsonCacheObj = eval('(' + strCache + ')');
var FeeRMB = 0.0; //应收人民币合计
var FeeUSD = 0.0; //应收美元合计
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 {
// $("dvTotalRMBVal").innerHTML = 0;
// $("dvTotalUSDVal").innerHTML = 0;
$("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.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;
}
var isDiffCurrency = parseInt(validateObj.validates[0].diffcurr);
if(isDiffCurrency == 1){
openNewDiv("dvRate");//设置汇率,如果存在不同的币别,则弹出汇率设置表
}else if(isDiffCurrency == 0){
var postSessionName = "";
if($("h_postsession").value.trim() != ""){
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 = checked;
if (ii > -1) {
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 = "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";
}
}
//
var openUrl = "DoApplication.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 settleCurrency = "";
if($("ck_rmb").checked){
settleCurrency = "1";
}else if($("ck_usd").checked){
settleCurrency = "2";
}else{
settleCurrency = "3";
}
}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 moduleName = "";
if($("h_mod").value != ""){
moduleName = "&mod="+$("h_mod").value;
}
var openUrl = "DoApplication.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(){
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 = "DoApplication.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);
}
}
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;
}
}
}
}
//清空查询信息
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 = "";//清空编号 文本框
$("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();
var _feename = comboFeeName.getSelectedValue();
var _feetype = comboFeeType.getSelectedValue();//comboFeeType.getComboText().trim();
var _currency = comboCurrency.getSelectedValue();
_feename = _feename == null ? "":_feename;
_feetype = _feetype == null?"":_feetype;
_currency = _currency == null?"":_currency;
var searchJson = "";
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 += "\"fnm\":\""+_feename+"\",";
searchJson += "\"fty\":\""+_feetype+"\",";
searchJson += "\"cur\":\""+_currency+"\",";
searchJson += "\"op\":\"" + $("hd_comboOP").value.trim() + "\"";
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=paysettleapp&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);
}
}
// //动态计算当前选中行的人民币、美元应收应付合计金额
// var rIds = commonGridObj_fee.getGridObj().getCheckedRows(0); //所有选中的grid的id编号
// url = "SettlementGridSourceApp.aspx?handle=getchecksumfeejson&do=paysettleapp&feeid=" + rIds + "&uid=" + commonGridObj_order.newGuid();
// loader = dhtmlxAjax.getSync(url);
// cacheVal = loader.xmlDoc.responseText;
// if (cacheVal.trim().length > 1) {
// cacheTotalObj = eval('(' + cacheVal.trim() + ')');
// if (cacheTotalObj.totals.length > 0) {
// $("dvTotalRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].rmb.toString());
// $("dvTotalUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].usd.toString());
// }
// }
//
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=paysettleapp&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="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="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";
}
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="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=paysettleapp&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=paysettleapp&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("没有权限添加费用");
}
// //动态计算当前选中行的人民币、美元应收应付合计金额
// var rIds = commonGridObj_fee.getGridObj().getCheckedRows(0); //所有选中的grid的id编号
// url = "SettlementGridSourceApp.aspx?handle=getchecksumfeejson&do=paysettleapp&feeid=" + rIds + "&uid=" + commonGridObj_order.newGuid();
// loader = dhtmlxAjax.getSync(url);
// cacheVal = loader.xmlDoc.responseText;
// if (cacheVal.trim().length > 1) {
// cacheTotalObj = eval('(' + cacheVal.trim() + ')');
// if (cacheTotalObj.totals.length > 0) {
// $("dvTotalRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].rmb.toString());
// $("dvTotalUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].usd.toString());
// }
// }
//
});
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=paysettleapp&bstype=" + _bstype;
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);
}
}
// //动态计算当前选中行的人民币、美元应收应付合计金额
// var rIds = commonGridObj_fee.getGridObj().getCheckedRows(0); //所有选中的grid的id编号
// url = "SettlementGridSourceApp.aspx?handle=getchecksumfeejson&do=paysettleapp&feeid=" + rIds + "&uid=" + commonGridObj_order.newGuid();
// loader = dhtmlxAjax.getSync(url);
// cacheVal = loader.xmlDoc.responseText;
// if (cacheVal.trim().length > 1) {
// cacheTotalObj = eval('(' + cacheVal.trim() + ')');
// if (cacheTotalObj.totals.length > 0) {
// $("dvTotalRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].rmb.toString());
// $("dvTotalUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].usd.toString());
// }
// }
//
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=paysettleapp&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="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;
}
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="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";
}
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="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";
}
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=paysettleapp&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=paysettleapp&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("没有权限添加费用");
}
// //动态计算当前选中行的人民币、美元应收应付合计金额
// var rIds = commonGridObj_fee.getGridObj().getCheckedRows(0); //所有选中的grid的id编号
// url = "SettlementGridSourceApp.aspx?handle=getchecksumfeejson&do=paysettleapp&feeid=" + rIds + "&uid=" + commonGridObj_order.newGuid();
// loader = dhtmlxAjax.getSync(url);
// cacheVal = loader.xmlDoc.responseText;
// if (cacheVal.trim().length > 1) {
// cacheTotalObj = eval('(' + cacheVal.trim() + ')');
// if (cacheTotalObj.totals.length > 0) {
// $("dvTotalRMBVal").innerHTML = outputMoney(cacheTotalObj.totals[0].rmb.toString());
// $("dvTotalUSDVal").innerHTML = outputMoney(cacheTotalObj.totals[0].usd.toString());
// }
// }
//
});
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){
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;
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();
}