DS7/DSWeb/js/CommonPayApplicationAudit.js

1696 lines
65 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;
var SelectRowOplb="";//选中行的业务类别
function $(id){
return document.getElementById(id);
}
function createTotal(){
var headerArgs_total = new Array("币别","金额");
//width
var widthArgs_total = new Array("120","150");
//column align
var colAlignArgs_total = new Array("center","center");
//column sort
var colSortArgs_total = new Array("str","str");
//column type
var colTypeArgs_total = new Array("ro","ro");
commonGridObj_total = new TGridCommon("mygrid_container_total","form1",headerArgs_total,widthArgs_total,colAlignArgs_total,colSortArgs_total,colTypeArgs_total);
commonGridObj_total.setResponseUrl("");
commonGridObj_total.setRequest("");
commonGridObj_total.setSourceType("json");
commonGridObj_total.setSkin("xp");
commonGridObj_total.setImageUrl("../images/");
commonGridObj_total.initGrid();
setTimeout(function(){
var jsonTotalObj = null;
//alert($("h_total").value);
var i = 0;
if($("h_total").value != ""){
var tempTotal = $("h_total").value;
jsonTotalObj = eval('(' + tempTotal + ')');
if(parseFloat(jsonTotalObj.total[0].rmb) != 0){
commonGridObj_total.getGridObj().addRow(commonGridObj_total.newGuid(),["RMB",outputMoney(jsonTotalObj.total[0].rmb)],i);
i++;
}
if(parseFloat(jsonTotalObj.total[0].usd) != 0){
commonGridObj_total.getGridObj().addRow(commonGridObj_total.newGuid(),["USD",outputMoney(jsonTotalObj.total[0].usd)],i);
}
}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 + ')');
if(parseFloat(jsonTotalObj.total[0].rmb) != 0){
commonGridObj_total.getGridObj().addRow(commonGridObj_total.newGuid(),["RMB",outputMoney(jsonTotalObj.total[0].rmb)],i);
i++;
}
if(parseFloat(jsonTotalObj.total[0].usd) != 0){
commonGridObj_total.getGridObj().addRow(commonGridObj_total.newGuid(),["USD",outputMoney(jsonTotalObj.total[0].usd)],i);
}
}
}
},50);
}
function createOrder(){
previous_id = "";
//header
var headerArgs_order = new Array("", '业务类别', "委托单位", "主提单号", "RMB", "USD", "报关单号", "备案清单号", "委托编号", "分提单号");
//width
var widthArgs_order = new Array("40", "60", "100", "120", "80", "80", "100", "100", "100", "100");
//column align
var colAlignArgs_order = new Array("center", "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", "str");
//column type
var colTypeArgs_order = new Array("ch", "ro", "ro", "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");
var _customer = comboCustomer.getComboText().trim();
var billNO = $("h_billno").value.trim();
var _billno = $("txt_billNO").value.trim();
var _begin_time = $("txt_beginTime").value.trim();
var _end_time = $("txt_endTime").value.trim();
var _vessel = comboVessel.getComboText().trim();
var _voyno = comboVoyno.getComboText().trim();
var _bstype = comboBsType.getSelectedValue();//comboBsType.getComboText().trim();
//var _debitno = $("txt_debitno").value.trim();
var _feename = comboFeeName.getSelectedValue();
var _feetype = comboFeeType.getSelectedValue();//comboFeeType.getComboText().trim();
var _currency = comboCurrency.getSelectedValue();
//var _customer = comboCustomer.getComboText().trim();
_feename = _feename == null ? "":_feename;
_feetype = _feetype == null?"":_feetype;
_currency = _currency == null?"":_currency;
//var _feetype = comboFeeType.getSelectedValue();//comboFeeType.getComboText().trim();
//var _currency = comboCurrency.getComboText().trim();
var searchJson = "";
//begin
searchJson +="{";
searchJson += "[";
searchJson += "\"cus\":\""+_customer+"\",";
searchJson += "\"bno\":\""+_billno+"\",";
searchJson += "\"bt\":\""+_begin_time+"\",";
searchJson += "\"et\":\""+_end_time+"\",";
searchJson += "\"ves\":\""+_vessel+"\",";
searchJson += "\"voy\":\""+_voyno+"\",";
searchJson += "\"bty\":\""+_bstype+"\",";
searchJson += "\"deno\":\"\",";
//searchJson += "\"cus\":\""+_customer+"\",";
searchJson += "\"fnm\":\""+_feename+"\",";
searchJson += "\"fty\":\""+_feetype+"\",";
searchJson += "\"cur\":\""+_currency+"\"";
//searchJson += "\"ise\":\""+_is_settled+"\"";
//searchJson += "\"fty\":\""+_feetype+"\",";
//searchJson += "\"cur\":\""+_currency+"\"";
searchJson += "]";
searchJson +="}";
//end
commonGridObj_order.setRequest("SettlementGridSourceApp.aspx?handle=payauditorderlist&billno="+billNO+"&search="+escape(searchJson)+"&uid="+commonGridObj_order.newGuid());
//commonGridObj_order.setRequest("SettlementGridSourceApp.aspx?handle=payauditorderlist&billno="+billno);
commonGridObj_order.setSourceType("json");
commonGridObj_order.setSkin("xp");
commonGridObj_order.setImageUrl("../images/");
commonGridObj_order.initGrid();
commonGridObj_order.bind();
// //遍历当前委托信息信息,如果已经记录到缓存中,则自动将前端选择框置1
// setTimeout(function(){
// var tempCache = $("h_feecache").value;
// var jsonCacheObj = null;
// 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);
// 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();
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();
var strhandle="";
if (oplb == "海运出口") {
strhandle = "op_Seae";
openUrl = "../baseinfo/opseaebaseinfo.aspx?handle=check&bsno=" + rId;
}
else if (oplb == "海运进口") {
strhandle = "op_Seai";
openUrl = "../baseinfo/opseaibaseinfo.aspx?handle=check&bsno=" + rId;
}
else if (oplb == "仓储费") {
strhandle = "wms_fee";
openUrl = "";
}
else if (oplb == "仓储入库") {
strhandle = "wms";
openUrl = "";
}
else if (oplb == "仓储出库") {
strhandle = "wms_out";
openUrl = "";
}
else if (oplb == "陆运托运") {
strhandle = "tmswlbshead";
openUrl = "";
}
else if (oplb == "陆运派车") {
strhandle = "tmswlpchead";
openUrl = "";
}
else if (oplb == "报关业务") {
strhandle = "op_apply";
openUrl = "../MvcShipping/MsOpApply/ApplyFeeView?handle=check&bsno=" + rId;
}
SelectRowOplb=strhandle;//选中行的业务类别
window.open (openUrl,openType,openSet);
});
// commonGridObj_order.getGridObj().attachEvent("onSelectStateChanged", function(id){
// commonGridObj_order.$("h_bsno").value = id;
// createFeeList();
// });
commonGridObj_order.getGridObj().attachEvent("onRowSelect", function(rId, ind) {
commonGridObj_order.$("h_bsno").value = rId;
var oplb = commonGridObj_order.getGridObj().cellById(rId, 1).getValue();
var strhandle="";
if (oplb == "海运出口") {
strhandle = "op_Seae";
}
else if (oplb == "海运进口") {
strhandle = "op_Seai";
}
else if (oplb == "仓储费") {
strhandle = "wms_fee";
}
else if (oplb == "仓储入库") {
strhandle = "wms";
}
else if (oplb == "仓储出库") {
strhandle = "wms_out";
}
else if (oplb == "陆运托运") {
strhandle = "tmswlbshead";
}
else if (oplb == "陆运派车") {
strhandle = "tmswlpchead";
}
else if (oplb == "报关业务") {
strhandle = "op_apply";
}
SelectRowOplb=strhandle;//选中行的业务类别
createFeeList();
});
commonGridObj_order.getGridObj().attachEvent("onCheckbox", function(rId, cInd, state) {
commonGridObj_order.$("h_bsno").value = rId;
var rowIndex = commonGridObj_order.getGridObj().getRowIndex(rId);
var oplb = commonGridObj_order.getGridObj().cellByIndex(rowIndex, 1).getValue();
var strhandle = "";
if (oplb == "海运出口") {
strhandle = "op_Seae";
}
else if (oplb == "海运进口") {
strhandle = "op_Seai";
}
else if (oplb == "仓储费") {
strhandle = "wms_fee";
}
else if (oplb == "仓储入库") {
strhandle = "wms";
}
else if (oplb == "仓储出库") {
strhandle = "wms_out";
}
else if (oplb == "陆运托运") {
strhandle = "tmswlbshead";
}
else if (oplb == "陆运派车") {
strhandle = "tmswlpchead";
}
else if (oplb == "报关业务") {
strhandle = "op_apply";
}
SelectRowOplb = strhandle; //选中行的业务类别
//
createFeeList();
setTimeout(function() {
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);
}
}, 20);
} else {
setTimeout(function() {
var jsonCacheObj = null;
var tempCache = $("h_feecache").value;
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;
}
}
}
}
}, 20);
//$("dvResult").innerHTML = $("h_feecache").value
}
}, 100);
});
}
function IsLastFeeCheckOut(bsno) {
if (commonGridObj_order != null) {
for (var i = 0; i < commonGridObj_order.getGridObj().getRowsNum(); i++) {
if (commonGridObj_order.getGridObj().getRowId(i) == bsno) {
commonGridObj_order.getGridObj().cellByIndex(i, 0).setValue(0);
break;
}
}
//commonGridObj_order.bind();
}
}
function 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", "120", "100", "40", "70", "70", "70", "0", "300");
//column align
var colAlignArgs_order = new Array("center", "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", "str");
//column type
var colTypeArgs_order = new Array("ch", "ro", "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("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 _billno = "";
var _user = "";
_feename = _feename == null ? "":_feename;
_feetype = _feetype == null?"":_feetype;
_currency = _currency == null?"":_currency;
_billno = $("h_billno").value;
_user = $("h_user").value;
var searchJson = "";
//begin
searchJson +="{";
searchJson += "[";
searchJson += "\"fnm\":\""+_feename+"\","
searchJson += "\"fty\":\""+_feetype+"\",";
searchJson += "\"cur\":\""+_currency+"\",";
searchJson += "\"billno\":\""+_billno+"\",";
searchJson += "\"user\":\""+_user+"\"";
searchJson += "]";
searchJson +="}";//alert(searchJson);
commonGridObj_fee.setRequest("SettlementGridSourceApp.aspx?handle=payauditfeelist&bsno="+_bsno+"&fsearch="+escape(searchJson));
commonGridObj_fee.setSourceType("json");
commonGridObj_fee.setSkin("xp");
commonGridObj_fee.setImageUrl("../images/");
commonGridObj_fee.initGrid();
commonGridObj_fee.bind();
// if(_bsno != ""){
// commonGridObj_fee.bind();
//
// //遍历当前打开的费用信息,如果已经记录到缓存中,则自动将前端选择框置1
// setTimeout(function(){
// var tempCache = $("h_feecache").value;
// 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 oplb = commonGridObj_order.getGridObj().cellByIndex(orderObjRowIndex, 1).getValue();
var strhandle = "";
if (oplb == "海运出口") {
strhandle = "op_Seae";
}
else if (oplb == "海运进口") {
strhandle = "op_Seai";
}
else if (oplb == "仓储费") {
strhandle = "wms_fee";
}
else if (oplb == "仓储入库") {
strhandle = "wms";
}
else if (oplb == "仓储出库") {
strhandle = "wms_out";
}
else if (oplb == "陆运托运") {
strhandle = "tmswlbshead";
}
else if (oplb == "陆运派车") {
strhandle = "tmswlpchead";
}
else if (oplb == "报关业务") {
strhandle = "op_apply";
}
SelectRowOplb = strhandle; //选中行的业务类别
//
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();
});
if ($("h_settlecustomer").value.trim() != "") {
comboCustomer.setComboText($("h_settlecustomer").value.trim());
comboCustomer.disable(false);
}
}
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;
// 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){
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 rowIndex = commonGridObj_order.getGridObj().getRowIndex(id);
var oplb=commonGridObj_order.getGridObj().cellByIndex(rowIndex,1).getValue();
var strhandle="";
if (oplb == "海运出口") {
strhandle = "op_Seae";
openUrl = "../baseinfo/opseaebaseinfo.aspx?handle=check&bsno=" + rId;
}
else if (oplb == "海运进口") {
strhandle = "op_Seai";
openUrl = "../baseinfo/opseaibaseinfo.aspx?handle=check&bsno=" + rId;
}
else if (oplb == "仓储费") {
strhandle = "wms_fee";
openUrl = "";
}
else if (oplb == "仓储入库") {
strhandle = "wms";
openUrl = "";
}
else if (oplb == "仓储出库") {
strhandle = "wms_out";
openUrl = "";
}
else if (oplb == "陆运托运") {
strhandle = "tmswlbshead";
openUrl = "";
}
else if (oplb == "陆运派车") {
strhandle = "tmswlpchead";
openUrl = "";
}
else if (oplb == "报关业务") {
strhandle = "op_apply";
openUrl = "../MvcShipping/MsOpApply/ApplyFeeView?handle=check&bsno=" + rId;
}
SelectRowOplb=strhandle;//选中行的业务类别
window.open (openUrl,openType,openSet);
});
commonGridObj_order.getGridObj().attachEvent("onRowSelect", function(id,ind){
commonGridObj_order.$("h_bsno").value = id;
var rowIndex = commonGridObj_order.getGridObj().getRowIndex(id);
var oplb=commonGridObj_order.getGridObj().cellByIndex(rowIndex,1).getValue();
var strhandle="";
if (oplb == "海运出口") {
strhandle = "op_Seae";
}
else if (oplb == "海运进口") {
strhandle = "op_Seai";
}
else if (oplb == "仓储费") {
strhandle = "wms_fee";
}
else if (oplb == "仓储入库") {
strhandle = "wms";
}
else if (oplb == "仓储出库") {
strhandle = "wms_out";
}
else if (oplb == "陆运托运") {
strhandle = "tmswlbshead";
}
else if (oplb == "陆运派车") {
strhandle = "tmswlpchead";
}
else if (oplb == "报关业务") {
strhandle = "op_apply";
}
SelectRowOplb=strhandle;//选中行的业务类别
createFeeList();
});
commonGridObj_order.getGridObj().attachEvent("onCheckbox", function(rId,cInd,state){
commonGridObj_order.$("h_bsno").value = rId;
var rowIndex = commonGridObj_order.getGridObj().getRowIndex(id);
var oplb = commonGridObj_order.getGridObj().cellByIndex(rowIndex, 1).getValue();
var strhandle="";
if (oplb == "海运出口") {
strhandle="op_Seae";
}
else if (oplb == "海运进口") {
strhandle="op_Seai";
}
else if (oplb == "仓储费") {
strhandle = "wms_fee";
}
else if (oplb == "仓储入库") {
strhandle = "wms";
}
else if (oplb == "仓储出库") {
strhandle = "wms_out";
}
else if (oplb == "陆运托运") {
strhandle = "tmswlbshead";
}
else if (oplb == "陆运派车") {
strhandle = "tmswlpchead";
}
else if (oplb == "报关业务") {
strhandle = "op_apply";
}
SelectRowOplb=strhandle;//选中行的业务类别
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;
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(){
postEnterFee();
}
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 financialAudit(){
}
//批准支付
function acceptApplyPay(){
$("h_audit").value = 1;
postEnterFee();
}
////驳回申请
//function rejectApply(){
//// $("h_audit").value = 2;
//// postEnterFee();
//}
function auditReject() {
var iCount = 0;
var strBillNo = $("h_billno").value;
//异步执行操作
var url = "FeePayAuditService.aspx?billno="+strBillNo+"&handle=auditreject&oplb="+SelectRowOplb+"&uid="+commonGridObj_total.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
switch(status){
case 1:
alert("驳回申请操作完成");
break;
case -1:
alert("驳回操作失败");
break;
case -2:
alert("您没有权限审核付费申请");
break;
case -3:
alert("审核已经进入下一步,不能执行驳回操作");
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("全部");
}
$("txt_beginTime").value = "";//清空业务日期 起始时间
$("txt_endTime").value = "";//清空业务日期 结束时间
$("txt_billNO").value = "";//清空编号 文本框
//$("txt_debitno").value = "";//清空对账编号
createOrder();
}
function auditPass(){
var iCount = 0;
var isOrderPay = false;
var isRun = false;
var stlName = "";
var clientName = $("h_settlecustomer").value.trim();
//验证结算单位是否是月结或者是半月结
var url = "../FeeCodes/CRMClientInfo.aspx?handle=clientstl&name="+escape(clientName)+"&uid="+commonGridObj_total.newGuid();
var loader = dhtmlxAjax.getSync(url);
var stlVal = loader.xmlDoc.responseText;
var stlObj = null;
stlObj = eval('(' + stlVal + ')');
if(stlObj.customer.length > 0){
var stlType = parseInt(stlObj.customer[0].stl);
switch(stlType){
case 1:
isOrderPay = true;
stlName = "票结";
break;
case 2:
stlName = "半月结";
isOrderPay = false;
break;
case 3:
stlName = "月结";
isOrderPay = false;
break;
}
}else{
isOrderPay = true;
}
var strBhhhillNo = $("h_billno").value;
if (!isOrderPay) {
if (stlName.trim() == "") {
isRun = true;
}
else {
if (window.confirm("当前结算单位为 " + stlName + " 您确定要提交付费申请")) {
isRun = true;
} else {
isRun = false;
}
}
}
if(isRun){
var strBillNo = $("h_billno").value;
//异步执行操作
var url = "FeePayAuditService.aspx?billno="+strBillNo+"&handle=auditpass&oplb="+SelectRowOplb+"&uid="+commonGridObj_total.newGuid();
var loader = dhtmlxAjax.getSync(url);
var postStatus = loader.xmlDoc.responseText;
var status = parseInt(postStatus);
switch(status){
case 1:
alert("批准支付操作完成");
window.parent.opener.location.href = window.parent.opener.location.href;
window.close();
break;
case -1:
case -2:
alert("审核操作异常");
break;
case -3:
alert("您没有权限审核付费申请");
break;
case -4:
alert("付费审核步骤已经完成,不能重复审核");
break;
}
}
}
function printInvoice(){
var id = "";
id = $("h_id").value;
var printUrl = "";
var companyID = "";
var typeName = "PayFeeAuditReport";
var dbSourceID = "";
var userID = "";
var url = "../Reports/ReportService.aspx?handle=printpayfeeauditreport&bsno="+id +"&val="+commonGridObj_total.newGuid();
typeName = "PayFeeAuditReport";
var loader = dhtmlxAjax.getSync(url);
var reportVal = loader.xmlDoc.responseText;
var reportObj = null;
if(reportVal != ""){
reportObj = eval('(' + reportVal + ')');
if(reportObj.reports.length > 0){
if(reportObj.reports[0].compid != ""){
companyID = reportObj.reports[0].compid;
}
if(reportObj.reports[0].sourceid != ""){
dbSourceID = reportObj.reports[0].sourceid;
}
if(reportObj.reports[0].compid != ""){
userID = reportObj.reports[0].userid;
}
printUrl = "print://?comp="+companyID+"&type="+typeName+"&dbid="+dbSourceID+"&uid="+userID;//alert(printUrl);
window.location.href = window.location.href;
location.href = printUrl;
}
}else{
alert("没有要打印的报表");
return;
}
}