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.
HENGCHENG/DSWeb/js/CommonPayApplicationSettlem...

1065 lines
42 KiB
JavaScript

var commonGridObj_order;
var commonGridObj_fee;
var commonGridObj_total;
var comboCustomer;//委托单位
var comboVessel;//船名
var comboVoyno;//航次
var comboBsType;//业务类型
var comboFeeName;//费用名称
var comboFeeType;//费用类型
var comboCurrency;//币别
var isLoad = 0;
var sel_val = new Array;
function $(id){
return document.getElementById(id);
}
function createTotal(){
var headerArgs_total = new Array("币别", "应结金额", "本次应结金额");
//width
var widthArgs_total = new Array("80", "150", "150");
//column align
var colAlignArgs_total = new Array("center", "center", "center");
//column sort
var colSortArgs_total = new Array("str", "str", "str");
//column type
var colTypeArgs_total = new Array("ro", "ro", "ro");
commonGridObj_total = new TGridCommon("mygrid_container_total","form1",headerArgs_total,widthArgs_total,colAlignArgs_total,colSortArgs_total,colTypeArgs_total);
commonGridObj_total.setResponseUrl("PayAppAuditGridSource.aspx");
commonGridObj_total.setRequest("PayAppAuditGridSource.aspx?handle=orderlist");
commonGridObj_total.setSourceType("json");
commonGridObj_total.setSkin("xp");
commonGridObj_total.setImageUrl("../images/");
commonGridObj_total.initGrid();
setTimeout(function(){
var jsonTotalObj = null;
if($("h_total").value != ""){
var tempTotal = $("h_total").value;
jsonTotalObj = eval('(' + tempTotal + ')');
}else{
var id = $("h_id").value;
var urlVal = "PayAppAuditGridSource.aspx?handle=payapptotal&payappid="+id+"&val="+commonGridObj_total.newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
loader = null;
if(loadVal != null){
$("h_total").value = loadVal;
jsonTotalObj = eval('(' + loadVal + ')');
var i = 0;
if(parseFloat(jsonTotalObj.total[0].rmb) != 0){
commonGridObj_total.getGridObj().addRow(commonGridObj_total.newGuid(), ["RMB", outputMoney(jsonTotalObj.total[0].rmb), outputMoney(jsonTotalObj.total[0].rmbsettle)], i);
i++;
}
if (parseFloat(jsonTotalObj.total[0].usd) != 0) {
commonGridObj_total.getGridObj().addRow(commonGridObj_total.newGuid(), ["USD", outputMoney(jsonTotalObj.total[0].usd), outputMoney(jsonTotalObj.total[0].usdsettle)], i);
}
}
}
},50);
}
function createOrder(){
previous_id = "";
//header
var headerArgs_order = new Array("<input type=\"checkbox\" id=\"ck_all\" onclick=\"checkAll(commonGridObj_order)\" />","委托单位","委托编号","主提单号","分提单号");
//width
var widthArgs_order = new Array("40","100","120","100","100");
//column align
var colAlignArgs_order = new Array("center","center","center","center","center");
//column sort
var colSortArgs_order = new Array("na","str","str","str","str");
//column type
var colTypeArgs_order = new Array("ch","ro","ro","ro","ro");
commonGridObj_order = new TGridCommon("mygrid_container_order","form1",headerArgs_order,widthArgs_order,colAlignArgs_order,colSortArgs_order,colTypeArgs_order);
commonGridObj_order.setResponseUrl("PayApplicationGridSource.aspx");
var billNOVal = $("h_billno").value;
commonGridObj_order.setRequest("PayApplicationGridSource.aspx?handle=payapporderlist&billno=" + billNOVal);
commonGridObj_order.setSourceType("json");
commonGridObj_order.setSkin("xp");
commonGridObj_order.setImageUrl("../images/");
commonGridObj_order.initGrid();
commonGridObj_order.bind();
//遍历当前委托信息信息,如果已经记录到缓存中,则自动将前端选择框置1
setTimeout(function () {
var tempCache = $("h_feecache").value;
if (tempCache.trim() != "") {
var jsonCacheObj = null;
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;
}
}
}
}
}, 300);
commonGridObj_order.getGridObj().enableHeaderImages(true);
commonGridObj_order.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
});
// commonGridObj_order.getGridObj().attachEvent("onSelectStateChanged", function(id){
// commonGridObj_order.$("h_bsno").value = id;
// createFeeList();
// });
commonGridObj_order.getGridObj().attachEvent("onRowSelect", function(id,ind){
commonGridObj_order.$("h_bsno").value = id;
createFeeList();
});
commonGridObj_order.getGridObj().attachEvent("onCheckbox", function(rId,cInd,state){
commonGridObj_order.$("h_bsno").value = rId;
createFeeList();
});
}
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", "150", "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", "ro", "ro", "ro");
commonGridObj_fee = new TGridCommon("mygrid_container_fee","form1",headerArgs_order,widthArgs_order,colAlignArgs_order,colSortArgs_order,colTypeArgs_order);
commonGridObj_fee.setResponseUrl("PayApplicationGridSource.aspx");
var _bsno = commonGridObj_fee.$("h_bsno").value;//alert(_bsno);
var billNOVal = $("h_billno").value;
commonGridObj_fee.setRequest("PayApplicationGridSource.aspx?handle=payappfeelist&bsno="+_bsno+"&billno="+billNOVal);
commonGridObj_fee.setSourceType("json");
commonGridObj_fee.setSkin("xp");
commonGridObj_fee.setImageUrl("../images/");
commonGridObj_fee.initGrid();
if(_bsno != ""){
commonGridObj_fee.bind();
//遍历当前打开的费用信息,如果已经记录到缓存中,则自动将前端选择框置1
setTimeout(function () {
var tempCache = $("h_feecache").value;
if (tempCache.trim() != "") {
var jsonCacheObj = null;
jsonCacheObj = eval('(' + tempCache + ')');
for (var i = 0; i < jsonCacheObj.caches.length; i++) {
for (var j = 0; j < commonGridObj_fee.getGridObj().getRowsNum(); j++) {
var rowId = "";
rowId = commonGridObj_fee.getGridObj().getRowId(j);
if (jsonCacheObj.caches[i].id == rowId) {
commonGridObj_fee.getGridObj().cellByIndex(j, 0).setValue(1);
var cstlMoney = ConvertToMoney(outputMoney(jsonCacheObj.caches[i].cstl.toString()));
commonGridObj_fee.getGridObj().cellByIndex(j, 6).setValue(cstlMoney);
var ustlMoney = ConvertToMoney(outputMoney(jsonCacheObj.caches[i].ustl.toString()));
commonGridObj_fee.getGridObj().cellByIndex(j, 7).setValue(ustlMoney);
break;
}
}
}
}
}, 300);
}
commonGridObj_fee.getGridObj().enableEditEvents(true,false,true);
commonGridObj_fee.getGridObj().attachEvent("onCheckbox", function(rId,cInd,state){
var gridObj = commonGridObj_fee.getGridObj();
var rowIndex = gridObj.getRowIndex(rId);
var isCheck = gridObj.cellByIndex(rowIndex,0).getValue();
var type = gridObj.cellByIndex(rowIndex,1).getValue();
var tempCache = $("h_feecache").value;
//Is Exist Same GID
var result = "";
if(isCheck == 1){
var orderObjRowID = commonGridObj_order.getGridObj().getSelectedRowId();
var orderObjRowIndex = commonGridObj_order.getGridObj().getRowIndex(orderObjRowID);
commonGridObj_order.getGridObj().cellByIndex(orderObjRowIndex,0).setValue(1);
var cacheBuffer = "";
//init jsonObj
if(tempCache.trim() == ""){
cacheBuffer += "{";
cacheBuffer += "\"id\":\""+rId+"\",";
var rowIndex = gridObj.getRowIndex(rId);
var feeType = gridObj.cellByIndex(rowIndex,1).getValue() == "收"?1:2;
cacheBuffer += "\"type\":"+feeType+",";
//cacheBuffer += "\"type\":\""+gridObj.cellByIndex(rowIndex,1).getValue()+"\",";
cacheBuffer += "\"bsno\":\""+commonGridObj_order.getGridObj().getSelectedRowId()+"\",";
cacheBuffer += "\"cus\":\""+gridObj.cellByIndex(rowIndex,2).getValue()+"\",";
cacheBuffer += "\"fname\":\""+gridObj.cellByIndex(rowIndex,3).getValue()+"\",";
cacheBuffer += "\"cur\":\""+gridObj.cellByIndex(rowIndex,4).getValue()+"\",";
cacheBuffer += "\"stl\":\""+gridObj.cellByIndex(rowIndex,5).getValue()+"\",";//应结
cacheBuffer += "\"cstl\":\""+gridObj.cellByIndex(rowIndex,6).getValue()+"\",";//本次结算
cacheBuffer += "\"ustl\":\""+gridObj.cellByIndex(rowIndex,7).getValue()+"\"";//未结
cacheBuffer += "}";
result += "{\"caches\":[";
result += cacheBuffer;
result += "]}";
jsonCacheObj = eval('(' + result + ')');
$("h_feecache").value = JSON.stringify(jsonCacheObj);
//$("dvResult").innerHTML = JSON.stringify(jsonCacheObj);
}else{
jsonCacheObj = eval('(' + tempCache + ')');
var isExist = false;
for(var i=0;i<jsonCacheObj.caches.length;i++){
if(jsonCacheObj.caches[i].id == rId){
isExist = true;
break;
}
}
if(!isExist){
var newCache = jsonCacheObj.caches;
var feeType = gridObj.cellByIndex(rowIndex,1).getValue() == "收"?1:2;
newCache = {id:rId,type:feeType,bsno:rId,cus:gridObj.cellByIndex(rowIndex,2).getValue().toString(),fname:gridObj.cellByIndex(rowIndex,3).getValue(),cur:gridObj.cellByIndex(rowIndex,4).getValue(),stl:gridObj.cellByIndex(rowIndex,5).getValue(),cstl:gridObj.cellByIndex(rowIndex,6).getValue(),ustl:gridObj.cellByIndex(rowIndex,7).getValue()};
jsonCacheObj.caches.push(newCache);
$("h_feecache").value = JSON.stringify(jsonCacheObj);
//$("dvResult").innerHTML = JSON.stringify(jsonCacheObj);
}
}
}else{
jsonCacheObj = eval('(' + tempCache + ')');
for(var i = jsonCacheObj.caches.length-1;i >= 0;i--){
if(jsonCacheObj.caches[i].id == rId){
if(jsonCacheObj.caches.length == 1){
IsLastFeeCheckOut(jsonCacheObj.caches[i].bsno);
jsonCacheObj.caches.shift();
$("h_feecache").value = "";
}else{
jsonCacheObj.caches.splice(i,1);
$("h_feecache").value = JSON.stringify(jsonCacheObj);
break;
}
}
}
//$("dvResult").innerHTML = $("h_feecache").value
}
});
commonGridObj_fee.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){
if(stage == 0){
return true;
}
if(stage == 1){
var selectedId = commonGridObj_fee.getGridObj().getSelectedRowId();
var rowIndex = commonGridObj_fee.getGridObj().getRowIndex(selectedId);
var txtEdit
for(i = 0; i < document.all.length; i++){
if(document.all(i).tagName == "TEXTAREA"){
txtEdit = document.all(i);
txtEdit.focus();
txtEdit.select();
break;
}
}
if(cInd == 1 || cInd == 2){
if(flagFilter == 0){
//alert(txtEdit.value);
}
}
}
if(stage == 2){
var selectedId = commonGridObj_fee.getGridObj().getSelectedRowId();
var rowIndex = commonGridObj_fee.getGridObj().getRowIndex(selectedId);
var stl = 0.0;
var cstl = 0.0;
var ustl = 0.0;
stl = parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_fee.getGridObj().cellByIndex(rowIndex,5).getValue()))));
cstl = parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_fee.getGridObj().cellByIndex(rowIndex,6).getValue()))));
ustl = parseFloat(clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_fee.getGridObj().cellByIndex(rowIndex,7).getValue()))));
var rustl = 0.0;
if(cstl == ustl){
rustl = ustl;
}else{
var newCstl = parseFloat(nValue);
var oldCstl = parseFloat(oValue);
if(ustl == oldCstl){
rustl = ustl;
}else{
rustl = oldCstl + ustl;
}
}
var newStl = 0.0;
newStl = rustl - cstl;
if(newStl < 0){
commonGridObj_fee.getGridObj().cellByIndex(rowIndex,7).setValue(ConvertToMoney(outputMoney(rustl.toString())));
return false;
}
commonGridObj_fee.getGridObj().cellByIndex(rowIndex,6).setValue(ConvertToMoney(outputMoney(cstl.toString())));
commonGridObj_fee.getGridObj().cellByIndex(rowIndex,7).setValue(ConvertToMoney(outputMoney(newStl.toString())));
var tempCache = $("h_feecache").value;
if(tempCache.trim() != ""){//如果有缓存记录
var jsonCacheObj = eval('(' + tempCache + ')');
for(var i=0;i<jsonCacheObj.caches.length;i++){
if(jsonCacheObj.caches[i].id == selectedId){
jsonCacheObj.caches[i].cstl = cstl;
jsonCacheObj.caches[i].ustl = newStl;
$("h_feecache").value = JSON.stringify(jsonCacheObj);
//$("dvResult").innerHTML = JSON.stringify(jsonCacheObj);
break;
}
}
}
return true;
}
});
isLoad = 1;
}
function createComboCustomer(){//委托单位
comboCustomer = dhtmlXComboFromSelect("sel_customer");
comboCustomer.loadXML("../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0");
comboCustomer.attachEvent("onChange", function(){
comboCustomer.setComboText($("h_customer").value);
});
comboCustomer.attachEvent("onBlur", function(){
var s1 = comboCustomer.getComboText().trim();
var s2 = s1.indexOf("|");
if(s2>0){
s2=s2+2;
}
var s3 = s1.substring(s2);
if(s2>0){
comboCustomer.setComboText(s3);
$("h_customer").value=s3;
}
else
{
comboCustomer.setComboText($("h_customer").value);
}
});
comboCustomer.setComboText($("h_customer").value);
comboCustomer.attachEvent("onKeyPressed", function(keyCode){
if(keyCode!="8"){
var arrayArg = new Array();
setTimeout(function(){
var filterCount = 0;
var is = -1;
var ishd = $("h_customer").value.trim();
if("" != comboCustomer.getComboText().trim()){
while("undefined" != typeof comboCustomer.getOptionByIndex(filterCount)){
var comboValue = comboCustomer.getOptionByIndex(filterCount).text.toUpperCase();//.value;
var enterValue = comboCustomer.getComboText().trim().toUpperCase();
$("h_customer").value = comboCustomer.getComboText().trim().toUpperCase();
if(comboValue.indexOf(enterValue) == 0){
comboCustomer.selectOption(filterCount,true,true);
is=filterCount;
break;
}
++filterCount;
}
if(is==-1){
$("h_customer").value = ishd;
alert("无此内容,请重新选择!");
}
}
},10);
}
});
comboCustomer.attachEvent("onSelectionChange", function(){
$("h_customer").value = comboCustomer.getComboText().trim();
});
}
function createComboVessel(){
comboVessel = dhtmlXComboFromSelect("sel_vessel");
comboVessel.loadXML("../FeeCodes/TCodeVesselAdapter.aspx?mask=0&pos=0&uid="+newGuid());
var _vessel = $("h_vessel").value;
comboVoyno = dhtmlXComboFromSelect("sel_voyno");
if(_vessel != ""){
comboVoyno.loadXML("../FeeCodes/TCodeVoynoAdapter.aspx?mask=0&pos=0&strVESSEL="+_vessel+"&uid="+newGuid());
}
comboVessel.setComboText($("h_vessel").value);
comboVessel.attachEvent("onKeyPressed", function(keyCode){
if(keyCode!="8"){
var arrayArg = new Array();
setTimeout(function(){
var filterCount = 0;
if("" != comboVessel.getComboText().trim()){
while("undefined" != typeof comboVessel.getOptionByIndex(filterCount)){
var comboValue = comboVessel.getOptionByIndex(filterCount).text.toUpperCase();//.value;
var enterValue = comboVessel.getComboText().toUpperCase();
$("h_vessel").value = comboVessel.getComboText().toUpperCase();
if(comboValue.indexOf(enterValue) == 0){
comboVessel.selectOption(filterCount,true,true);
$("h_vessel").value = comboVessel.getComboText().trim();
break;
}
++filterCount;
}
}
},10);
}
});
comboVessel.attachEvent("onBlur", function(){
$("h_vessel").value = comboVessel.getComboText().trim();
$("h_voyno").value = "";
createComboVoyno();
});
comboVessel.attachEvent("onChange", function(){
comboVessel.setComboText($("h_vessel").value);
});
comboVessel.attachEvent("onSelectionChange", function(){
$("h_vessel").value = comboVessel.getComboText().trim();
});
}
function createComboVoyno(){
var _vessel;
try
{
_vessel = comboVessel.getSelectedValue().trim();//$("hd_comboVESSEL").value;
}
catch(e)
{
_vessel="";
}
if(_vessel != ""){
comboVoyno.loadXML("../FeeCodes/TCodeVoynoAdapter.aspx?mask=0&pos=0&strVESSEL="+_vessel);
comboVoyno.setComboText($("h_voyno").value);
}
comboVoyno.attachEvent("onChange", function(){
comboVoyno.setComboText($("h_voyno").value);
});
comboVoyno.attachEvent("onKeyPressed", function(keyCode){
if(keyCode!="8"){
var arrayArg = new Array();
setTimeout(function(){
var filterCount = 0;
if("" != comboVoyno.getComboText().trim()){
while("undefined" != typeof comboVoyno.getOptionByIndex(filterCount)){
var comboValue = comboVoyno.getOptionByIndex(filterCount).text.toUpperCase();//.value;
var enterValue = comboVoyno.getComboText().trim().toUpperCase();
$("h_voyno").value = comboVoyno.getComboText().trim().toUpperCase();
if(comboValue.indexOf(enterValue) == 0){
comboVoyno.selectOption(filterCount,true,true);
break;
}
++filterCount;
}
}
},10);
}
});
comboVoyno.attachEvent("onSelectionChange", function(){
$("h_voyno").value = comboVoyno.getComboText().trim();
});
}
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
//Get Guid
var newGuid = function(){
var guid = "";
for (var i = 1; i <= 32; i++){
var n = Math.floor(Math.random()*16.0).toString(16);
guid += n;
if((i==8)||(i==12)||(i==16)||(i==20))
guid += "-";
}
return guid.toUpperCase();
};
function initCombos(){
createComboVessel();//船名
createComboVoyno();//航次
createComboCustomer();//结算单位
createComboBsType();//业务类型
createComboFeeName();//费用名称
createComboFeeType();//费用类型
createComboCurrency();//币别
}
function checkAll(gridObj){
var checkBoxId = "";
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);
}
}
}
}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;
}
}
}
}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 _customer = comboCustomer.getComboText().trim();
var _searchbillno = $("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 _id = "";
_id = $("h_id").value;
var _billno = "";
_billno = $("h_billno").value;
var _user = "";
_user = $("h_user").value;
//var _feetype = comboFeeType.getSelectedValue();//comboFeeType.getComboText().trim();
//var _currency = comboCurrency.getComboText().trim();
var searchJson = "";
//begin
searchJson +="{";
searchJson += "[";
searchJson += "\"cus\":\""+_customer+"\",";
searchJson += "\"bno\":\""+_searchbillno+"\",";
searchJson += "\"bt\":\""+_begin_time+"\",";
searchJson += "\"et\":\""+_end_time+"\",";
searchJson += "\"ves\":\""+_vessel+"\",";
searchJson += "\"voy\":\""+_voyno+"\",";
searchJson += "\"bty\":\""+_bstype+"\",";
searchJson += "\"deno\":\""+_debitno+"\",";
searchJson += "\"id\":\""+_id+"\",";
searchJson += "\"billno\":\""+_billno+"\",";
searchJson += "\"user\":\""+_user+"\"";
//searchJson += "\"ise\":\""+_is_settled+"\"";
//searchJson += "\"fty\":\""+_feetype+"\",";
//searchJson += "\"cur\":\""+_currency+"\"";
searchJson += "]";
searchJson +="}";
//end
//alert(searchJson);//return;
commonGridObj_order.setRequest("PayAppAuditGridSource.aspx?handle=ordersearch&search="+escape(searchJson)+"&uid="+commonGridObj_order.newGuid());
commonGridObj_order.initGrid();
commonGridObj_order.bind();
//遍历当前委托信息信息,如果已经记录到缓存中,则自动将前端选择框置1
setTimeout(function () {
var tempCache = $("h_feecache").value;
if (tempCache.trim() != "") {
var jsonCacheObj = null;
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);
commonGridObj_order.getGridObj().enableHeaderImages(true);
commonGridObj_order.getGridObj().attachEvent("onRowDblClicked", function(rId,cInd){
});
commonGridObj_order.getGridObj().attachEvent("onRowSelect", function(id,ind){
commonGridObj_order.$("h_bsno").value = id;
createFeeList();
});
commonGridObj_order.getGridObj().attachEvent("onCheckbox", function (rId, cInd, state) {
commonGridObj_order.$("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 () {
var gridObj = commonGridObj_fee.getGridObj();
var count = gridObj.getRowsNum();
if (count > 0) {
var tempCache = $("h_feecache").value;
var jsonCacheObj;
$("ck_allfee").checked = 1;
for (var i = 0; i < count; i++) {
if (tempCache.trim() == "") {
var rowId = gridObj.getRowId(i);
var rowIndex = gridObj.getRowIndex(rowId);
var cacheBuffer = "";
cacheBuffer += "{";
cacheBuffer += "\"id\":\"" + rowId + "\",";
var feeType = gridObj.cellByIndex(rowIndex, 1).getValue() == "收" ? 1 : 2;
cacheBuffer += "\"type\":" + feeType + ",";
cacheBuffer += "\"bsno\":\"" + rId + "\",";
cacheBuffer += "\"cus\":\"" + gridObj.cellByIndex(rowIndex, 2).getValue() + "\",";
cacheBuffer += "\"fname\":\"" + gridObj.cellByIndex(rowIndex, 3).getValue() + "\",";
cacheBuffer += "\"cur\":\"" + gridObj.cellByIndex(rowIndex, 4).getValue() + "\",";
cacheBuffer += "\"stl\":\"" + gridObj.cellByIndex(rowIndex, 5).getValue() + "\","; //应结
cacheBuffer += "\"cstl\":\"" + gridObj.cellByIndex(rowIndex, 6).getValue() + "\","; //本次结算
cacheBuffer += "\"ustl\":\"" + gridObj.cellByIndex(rowIndex, 7).getValue() + "\""; //未结
cacheBuffer += "}";
var result = "";
result += "{\"caches\":[";
result += cacheBuffer;
result += "]}";
tempCache = result;
jsonCacheObj = eval('(' + result + ')');
gridObj.cellByIndex(i, 0).setValue(1);
} else {
if (jsonCacheObj == null)
jsonCacheObj = eval('(' + tempCache + ')');
var isExist = false;
var rowId = gridObj.getRowId(i);
var rowIndex = gridObj.getRowIndex(rowId);
for (var j = 0; j < jsonCacheObj.caches.length; j++) {
if (jsonCacheObj.caches[j].id == rowId) {
isExist = true;
break;
}
}
if (!isExist) {
var feeType = gridObj.cellByIndex(rowIndex, 1).getValue() == "收" ? 1 : 2;
gridObj.cellByIndex(rowIndex, 0).setValue(1);
var newCache = jsonCacheObj.caches;
newCache = { id: rowId, type: feeType, bsno: rId, cus: gridObj.cellByIndex(rowIndex, 2).getValue().toString(), fname: gridObj.cellByIndex(rowIndex, 3).getValue(), cur: gridObj.cellByIndex(rowIndex, 4).getValue(), stl: gridObj.cellByIndex(rowIndex, 5).getValue(), cstl: gridObj.cellByIndex(rowIndex, 6).getValue(), ustl: gridObj.cellByIndex(rowIndex, 7).getValue() };
//alert(newCache);
jsonCacheObj.caches.push(newCache);
}
}
}
$("h_feecache").value = JSON.stringify(jsonCacheObj);
//$("dvResult").innerHTML = JSON.stringify(jsonCacheObj);
}
}, 50);
} else {
setTimeout(function () {
var jsonCacheObj = null;
var tempCache = $("h_feecache").value;
if (tempCache.trim() != "") {
jsonCacheObj = eval('(' + tempCache + ')');
var gridObj = commonGridObj_fee.getGridObj();
for (var j = 0; j < gridObj.getRowsNum(); j++) {
var rId = gridObj.getRowId(j);
for (var i = jsonCacheObj.caches.length - 1; i >= 0; i--) {
if (jsonCacheObj.caches[i].id == rId) {
if (jsonCacheObj.caches.length == 1) {
jsonCacheObj.caches.shift();
gridObj.cellByIndex(j, 0).setValue(0);
$("h_feecache").value = "";
//$("dvResult").innerHTML = "";
} else {
jsonCacheObj.caches.splice(i, 1);
gridObj.cellByIndex(j, 0).setValue(0);
$("h_feecache").value = JSON.stringify(jsonCacheObj);
//$("dvResult").innerHTML = JSON.stringify(jsonCacheObj);
break;
}
}
}
}
}
}, 60);
//$("dvResult").innerHTML = $("h_feecache").value
}
});
if(commonGridObj_fee != null){
createFeeList();
}
}
//Cache Settlement Fee
function saveSettleFee(){
var settleFee = "";
settleFee +="{";
settleFee += "[";
settleFee += "]";
settleFee +="}";
}
function saveSelectFee(gid,type){
}
function getCacheFee(){
var cacheBuffer = $("h_feecache").value;
}
function postEnterFee(){
var myForm = document.getElementById("form1");
myForm.submit() ;
}
function doSettle(){
var jsonCacheObj = null;
var tempCache = $("h_feecache").value;
if (tempCache.trim() != "") {
jsonCacheObj = eval('(' + tempCache + ')');
if (jsonCacheObj.caches.length > 0) {
var tempCustomerName = jsonCacheObj.caches[0].cus;
var tempEqualCount = 0;
for (var i = 1; i < jsonCacheObj.caches.length; i++) {
//如果有不同的结算单位名称,则不允许客户提交,提示不能多结算单位同时结算
if (tempCustomerName != jsonCacheObj.caches[i].cus) {
tempEqualCount++;
break;
}
}
if (tempEqualCount > 0) {
alert("不能多个结算单位同时申请付费结算,请修改");
return;
} else {
postEnterFee();
}
} else {
alert("申请付费结算单位不能为空");
return;
}
}
}
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;
}
}
}
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 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 moneyMath(original){
var result = Math.round(original*100)/100;
return result;
}
function settleAction(){
// $("h_settle").value = 1;
// postEnterFee();
var strBillNO = $("h_billno").value;
var openSet = "height=600, width=950, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-710)/2 + ",Left= "+(screen.width-800)/2
var openType = "_blank";
var openUrl = "DoPayApplicationSettlement.aspx?billno=" + strBillNO;
window.open (openUrl,openType,openSet);
}