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.

6951 lines
306 KiB
JavaScript

This file contains ambiguous Unicode characters!

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

var mygrid_recv;
var mygrid_pay;
var page_count = 5;
var column_count;
var jsonFeeObj;
var jsonPayObj;
var changeCount = 0;
var authoriyStatus;
var changeFeeRecvCount = 0;
var changeFeePayCount = 0;
var newFeeRecvCount = 0;
var newFeePayCount = 0;
var recv_menu;
var pay_menu;
var stroplb="";
var wmsoutbsno="";
var cknum=0;//出库数量
var RowOutBsno="";//wms_out.bsno
var pressRecord;
var quantityVal;
var quantityObj;
function $(id){
return document.getElementById(id);
}
function document.onkeydown(){
if(event.keyCode == 8){
if(document.selection){
var range = document.selection.createRange();
if(range.parentElement().name == null){
return false;
return true;
}else{
}
}
}
}
function initGrid(){
stroplb = $("h_oplb").value;
wmsoutbsno =$("h_wmsoutbsno").value;
doInitRecvGrid();
// setTimeout(doInitPayGrid,200);
// setTimeout(totalDynamicFeeGain,700);
//setTimeout(doInitPayGrid,100000);
}
function clickNull(){
}
function doInitRecvGrid(){
enableAction();
mygrid_recv = new dhtmlXGridObject('mygrid_container_recv');
mygrid_recv.setImagePath("../images/");
mygrid_recv.setSkin("xp");
// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
mygrid_recv.setHeader("<input type=\"checkbox\" id=\"ck_all_recv\" onclick=\"checkAll('recv')\" />,费用状态,应收费用名称,结算单位,计费标准,单价,数量,佣金比例,金额,币别,汇率,FRT,费用备注,是否垫付,结算金额,开票金额,发票号码,录入人,录入时间,TID,WMSOUTBSNO,行号");
mygrid_recv.setInitWidths("40,70,110,150,70,80,80,90,90,50,70,70,250,70,70,70,120,80,120,0,0,0");
mygrid_recv.setColAlign("center,center,right,right,right,right,right,right,right,right,right,right,center,center,center,center,center,center,center,center,center,center");
// mygrid_recv.setSkin("light");
mygrid_recv.setColSorting("na,str,str,str,int,int,int,int,int,int,int,int,int,str,int,int,str,str,str,str,str,str");
mygrid_recv.setColTypes("ch,ro,co,co,co,ed,ed,ed,ed,co,ed,co,ed,ch,ro,ro,ro,ro,ro,ro,ro,ro");
var bsno = $("h_bsno").value;
//判断委托单有无应收费用
var urlVal = "../Shipping/feegridsource.aspx?type=1&read=exist&showcount=1&oplb="+stroplb+"&wmsoutbsno="+wmsoutbsno+"&bsno="+bsno+"&val="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
loader = null;
if(parseInt(loadVal) == 1){
//获取应收费用信息初始化grid
mygrid_recv.loadXML("../Shipping/feegridsource.aspx?type=1&read=init&showcount=1&oplb="+stroplb+"&wmsoutbsno="+wmsoutbsno+"&bsno="+bsno,function(){
ReShowLabel(mygrid_recv);
doInitPayGrid();
// finishLoading();
});
}else{
doInitPayGrid();
}
mygrid_recv.init();
mygrid_recv.enableEditEvents(true,false,true);
mygrid_recv.enableKeyboardSupport(true);
setTimeout(function(){
//initLoading();
//调用缓存信息
var cacheTemplate = $("h_cachetemplate").value;
var importType = parseInt($("h_importtype").value);
if(cacheTemplate != ""){
var jsonCacheObj = null;
jsonCacheObj = eval('(' + cacheTemplate + ')');
var delAry = new Array();
for(var i=0;i<jsonCacheObj.templates.length;i++){
var newId = newGuid();
//获取插入新纪录位置
//初始化变量
var rowCount = mygrid_recv.getRowsNum();
var tid = "";
var feeName = "";
var customerName = "";
var unit = "";
var unitprice = 0;
var quantity = 0;
var currency = "";
var exchangeRate = 1;
var remark = "";
var isAdvancePay = false;
var client = "";
if(jsonCacheObj.templates[i].type == 1){
tid = jsonCacheObj.templates[i].tid;
feeName = jsonCacheObj.templates[i].fname;
customerName = jsonCacheObj.templates[i].cust;
unit = jsonCacheObj.templates[i].unit;
unitprice = jsonCacheObj.templates[i].uprice;
currency = jsonCacheObj.templates[i].cur;
exchangeRate = jsonCacheObj.templates[i].exrate == 0?1:jsonCacheObj.templates[i].exrate;
remark = jsonCacheObj.templates[i].remark;
client = jsonCacheObj.templates[i].client;
var rId = newId;
var linenum = rowCount + 1;
mygrid_recv.addRow(newId, [0, "录入状态", feeName, customerName, unit, unitprice, 0, 0, 0, currency, exchangeRate, "PP", remark, isAdvancePay, 0, 0, '', '', '', tid, wmsoutbsno, linenum], rowCount);
var rowIndex = mygrid_recv.getRowIndex(newId);
//赋值
if(feeName != ""){
var url = "";
var feeCodeObj = null;
if(feeName != ""){
//通过费用名称获取费用代码表code_fee币别汇率信息
url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb="+stroplb+"&feename="+escape(feeName)+"&uid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var feeCodeInfo = loader.xmlDoc.responseText;
feeCodeObj = eval('(' + feeCodeInfo + ')');
if(feeCodeObj.feecode.length > 0){
if(feeCodeObj.feecode[0].cur.trim() != ""){
var urlVal = "";
//获取委托op_Seae/op_Seai费用1汇率
if(currency == ""){
mygrid_recv.cellByIndex(rowIndex,9).setValue(feeCodeObj.feecode[0].cur);
urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb="+stroplb+"&bsno="+bsno+"&type=1&currency="+feeCodeObj.feecode[0].cur+"&uid="+newGuid();
}else{
mygrid_recv.cellByIndex(rowIndex,9).setValue(currency);
urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb="+stroplb+"&bsno="+bsno+"&type=1&currency="+currency+"&uid="+newGuid();
}
var bsno = $("h_bsno").value;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
//设置应收费用汇率
mygrid_recv.cellByIndex(rowIndex,10).setValue(loadVal);
//获取计费标准和数量
if(unit == ""){
if(feeCodeObj.feecode[0].unit != 0){
//获取委托op_seai费用计费标准信息返回JSON数据
quantityObj = getUnitType(feeCodeObj.feecode[0].unit);
if(quantityObj.quantity.length > 0){
if(quantityObj.quantity[0].value > 0){
mygrid_recv.cellByIndex(rowIndex,4).setValue(quantityObj.quantity[0].name);
mygrid_recv.cellByIndex(rowIndex,6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
//计算应收费用“金额”
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString()));
}
}
}else{
//mygrid_recv.cellByIndex(rowIndex,4).setValue("");
mygrid_recv.cellByIndex(rowIndex,6).setValue(1);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue())));
var quantityCount = 1;
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString()));
}
}else{
var quantityObj = null;
//unit转换汉字标识
cknum=mygrid_recv.cellByIndex(rowIndex,6).getValue();
quantityObj = getTypeNameQuantity(unit,cknum);
if(quantityObj.quantity.length > 0){
if(quantityObj.quantity[0].value > 0){
//获取委托op_seai费用计费标准信息返回JSON数据
mygrid_recv.cellByIndex(rowIndex,4).setValue(quantityObj.quantity[0].name);
mygrid_recv.cellByIndex(rowIndex,6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString()));
}else{
//mygrid_recv.cellByIndex(rowIndex,4).setValue("");
if(getTypeNum(unit) >= 1){
mygrid_recv.cellByIndex(rowIndex,6).setValue(0);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue())));
var quantityCount = 0;//clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString()));
}else{
delAry.push(rId);
alert("请先录入委托的对应箱型,在引入计费标准是箱型的费用!");
//mygrid_recv.deleteRow(rId);rowCount = 0;
}
}
}
}
}
//结算单位设置 备注debit应收金额
if(feeCodeObj.feecode[0].debit > 0){
var debitObj = null;
//获取委托信息(op_seae)默认收费客户信息返回JSON数据源
debitObj = getDebitType(feeCodeObj.feecode[0].debit);
if(debitObj.debit.length > 0){
if(debitObj.debit[0].value.trim() != ""){
//mygrid_recv.cellByIndex(rowIndex,3).setLabel(debitObj.debit[0].value);
if(customerName.trim() != ""){
mygrid_recv.cellByIndex(rowIndex,3).setValue(customerName.trim());
}else{
mygrid_recv.cellByIndex(rowIndex,3).setValue(debitObj.debit[0].value);
}
}
}
}
if(delAry.length > 0){
for(var k=0;k<delAry.length;k++){
mygrid_recv.deleteRow(delAry[k]);
}
}
//刷新label
ReShowLabel(mygrid_recv);
//动态计算费用利润信息
totalDynamicFeeGain();
}
}
}
}
}
}
var cacheHistory = $("h_cachehistory").value;
var historyType = parseInt($("h_historytype").value);
var opType = parseInt($("h_historyoptype").value);
if(cacheHistory != ""){
var jsonCacheObj = null;
jsonCacheObj = eval('(' + cacheHistory + ')');
var delAry = new Array();
for(var i=0;i<jsonCacheObj.history.length;i++){
var newId = newGuid();
//获取插入新纪录位置
//初始化变量
var rowCount = mygrid_recv.getRowsNum();
var tid = "";
var feeName = "";
var customerName = "";
var unit = "";
var unitprice = 0;
var quantity = 0;
var currency = "";
var exchangeRate = 1;
var remark = "";
var isAdvancePay = false;
var client = "";
var frt = "";
var isAdv = "";
if(jsonCacheObj.history[i].type == 1){
tid = jsonCacheObj.history[i].tid;
feeName = jsonCacheObj.history[i].fname;
customerName = jsonCacheObj.history[i].cust;
unit = jsonCacheObj.history[i].unit;
unitprice = jsonCacheObj.history[i].uprice;
currency = jsonCacheObj.history[i].cur;
exchangeRate = jsonCacheObj.history[i].exrate == 0?1:jsonCacheObj.history[i].exrate;
remark = jsonCacheObj.history[i].remark;
client = jsonCacheObj.history[i].client;
frt = jsonCacheObj.history[i].frt;
isAdvancePay = jsonCacheObj.history[i].isadv;
var rId = newId;
var linenum = rowCount + 1;
mygrid_recv.addRow(newId, [0, "录入状态", feeName, customerName, unit, unitprice, 0, 0, 0, currency, exchangeRate, frt, remark, isAdvancePay, 0, 0, '', '', '', tid, wmsoutbsno, linenum], rowCount);
var rowIndex = mygrid_recv.getRowIndex(newId);
//赋值
if(feeName != ""){
var url = "";
var feeCodeObj = null;
if(feeName != ""){
//通过费用名称获取费用代码表code_fee币别汇率信息
url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb="+stroplb+"&feename="+escape(feeName)+"&uid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var feeCodeInfo = loader.xmlDoc.responseText;
feeCodeObj = eval('(' + feeCodeInfo + ')');
if(feeCodeObj.feecode.length > 0){
if(feeCodeObj.feecode[0].cur.trim() != ""){
var urlVal = "";
//获取委托op_seae费用1汇率
if(currency == ""){
mygrid_recv.cellByIndex(rowIndex,9).setValue(feeCodeObj.feecode[0].cur);
urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb="+stroplb+"&bsno="+bsno+"&type=1&currency="+feeCodeObj.feecode[0].cur+"&uid="+newGuid();
}else{
mygrid_recv.cellByIndex(rowIndex,9).setValue(currency);
urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb="+stroplb+"&bsno="+bsno+"&type=1&currency="+currency+"&uid="+newGuid();
}
var bsno = $("h_bsno").value;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
mygrid_recv.cellByIndex(rowIndex,10).setValue(loadVal);
if(unit == ""){
if(feeCodeObj.feecode[0].unit != 0){
quantityObj = getUnitType(feeCodeObj.feecode[0].unit);
if(quantityObj.quantity.length > 0){
if(quantityObj.quantity[0].value > 0){
mygrid_recv.cellByIndex(rowIndex,4).setValue(quantityObj.quantity[0].name);
mygrid_recv.cellByIndex(rowIndex,6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString()));
}
}
}else{
//mygrid_recv.cellByIndex(rowIndex,4).setValue("");
mygrid_recv.cellByIndex(rowIndex,6).setValue(1);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue())));
var quantityCount = 1;
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString()));
}
}else{
var quantityObj = null;
cknum=mygrid_recv.cellByIndex(rowIndex,6).getValue();
quantityObj = getTypeNameQuantity(unit,cknum);
if(quantityObj.quantity.length > 0){
if(quantityObj.quantity[0].value > 0){
mygrid_recv.cellByIndex(rowIndex,4).setValue(quantityObj.quantity[0].name);
mygrid_recv.cellByIndex(rowIndex,6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString()));
}else{
//mygrid_recv.cellByIndex(rowIndex,4).setValue("");
if(getTypeNum(unit) >= 1){
mygrid_recv.cellByIndex(rowIndex,6).setValue(0);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue())));
var quantityCount = 0;//clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString()));
}else{
//delAry.push(rId);
//mygrid_recv.deleteRow(rId);rowCount = 0;
}
}
}
}
}
if(feeCodeObj.feecode[0].debit > 0){
var debitObj = null;
debitObj = getDebitType(feeCodeObj.feecode[0].debit);
if(debitObj.debit.length > 0){
if(debitObj.debit[0].value.trim() != ""){
//mygrid_recv.cellByIndex(rowIndex,3).setLabel(debitObj.debit[0].value);
if(opType == 1){
mygrid_recv.cellByIndex(rowIndex,3).setValue(customerName.trim());
}else{
mygrid_recv.cellByIndex(rowIndex,3).setValue(debitObj.debit[0].value);
}
}
}
}
ReShowLabel(mygrid_recv);
totalDynamicFeeGain();
}
}
}
}
}
}
//finishLoading();
},240);
var pushVal = "";
var pressRecord = "";
var pressRowIndex = -1;
var pressCellIndex = -1;
var pressCount = 0;
var isExchange = false;
var shiftCount = 0;
var isDelete = 0;
var flagFilter = 0;
var flagTab = 0;
var flagEnter = 0;
var flagDelete = 0;
mygrid_recv.attachEvent("onSelectStateChanged", function(id){
RowOutBsno=mygrid_recv.cellById(id,20).getValue();
if($("h_enable").value == "1"){
var rowIndex = mygrid_recv.getRowIndex(id);
if(rowIndex >= 0){
var stateVal = mygrid_recv.cellByIndex(rowIndex,1).getValue().trim();
if(stateVal == "录入状态"|| stateVal == "驳回提交"){
var combo_currency;
combo_currency = mygrid_recv.getCustomCombo(id,9);
if(combo_currency.getKeys.length <= 1){
setCurrencyCombo(combo_currency);
}
var combo_feename;
combo_feename = mygrid_recv.getCustomCombo(id,2);
if(combo_feename.getKeys.length <= 1){
setFeeNameCombo(combo_feename);
}
var combo_cust;
combo_cust = mygrid_recv.getCustomCombo(id,3);
if(combo_cust.getKeys.length <= 1){
setCustomerCombo(combo_cust,id);
}
var combo_unit;
combo_unit = mygrid_recv.getCustomCombo(id,4);
if(combo_unit.getKeys.length <= 1){
setUnitCombo(combo_unit);
}
var combo_frt;
combo_frt = mygrid_recv.getCustomCombo(id,11);
if(combo_frt.getKeys.length <= 1){
setFrtCombo(combo_frt);
}
return true;
}else{
return false;
}
}
}
});
//手动编写Grid控件编辑事件,由于免费控件没有提供完整的编辑判断功能,现特此做更改
mygrid_recv.attachEvent("onEditCell", function (stage, rId, cInd, nValue, oValue) {
RowOutBsno = mygrid_recv.cellById(rId, 20).getValue();
var newCheckValue = false;
//初始化状态
if (stage == 0) {
var rowIndex = mygrid_recv.getRowIndex(rId);
var oldVal = mygrid_recv.cellByIndex(rowIndex, 1).getValue().trim();
if (oldVal == "录入状态" || oldVal == "驳回提交") {
if ($("h_enable").value == "0") {
if (cInd == 0) {
//if(parseInt($("h_recvauthority").value) > 0){
//检查用户的模块权限信息
if (validOperatePower(rId, 1)) {
return true;
} else {
alert("对不起,你没有此权限");
return false;
}
}
return false;
} else {
if (validOperatePower(rId, 1)) {
return true;
} else {
alert("对不起,你没有此权限");
return false;
}
}
} else {
if (validOperatePower(rId, 1)) {
if (cInd == 0) {
return true;
} else {
alert("对不起,你没有此权限");
return false;
}
} else {
alert("对不起,你没有此权限");
return false;
}
}
}
if (stage == 1) {
var selectedId = mygrid_recv.getSelectedRowId();
var rowIndex = mygrid_recv.getRowIndex(selectedId);
for (var 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) {
if (oValue == null || oValue == "" || oValue == "0") {
if (cInd != 5 && cInd != 6 && cInd != 8) {
if (nValue == null || nValue == "" || nValue == "0") {
return true;
}
}
}
changeFeeRecvCount++;
if (cInd == 5) {
var rowIndex = mygrid_recv.getRowIndex(rId);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 6).getValue())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex, 5).setValue(outputMoney(unitPrice.toString()));
//mygrid_recv.cellByIndex(rowIndex,6).setValue(outputMoney(quantityCount.toString()));
mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
totalDynamicFeeGain();
return true;
} else if (cInd == 6) {
var rowIndex = mygrid_recv.getRowIndex(rId);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 6).getValue())));
var amount = unitPrice * quantityCount;
//mygrid_recv.cellByIndex(rowIndex,5).setValue(outputMoney(unitPrice.toString()));
var dd = outputMoney(quantityCount.toString());
mygrid_recv.cellByIndex(rowIndex, 6).setValue(outputMoney(quantityCount.toString()));
mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
totalDynamicFeeGain();
return true;
} else if (cInd == 8) {
var rowIndex = mygrid_recv.getRowIndex(rId);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 6).getValue())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
totalDynamicFeeGain();
return true;
} else if (cInd == 9) {
var rowIndex = mygrid_recv.getRowIndex(rId);
//filterComboCustomerPress(mygrid_recv,rId,rowIndex,9,nValue,oValue);
var curValue = mygrid_recv.cellByIndex(rowIndex, 9).getValue(); //alert(curValue);
//获取海运进口委托op_seai费用1汇率
var bsno = $("h_bsno").value;
var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1&currency=" + curValue + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
mygrid_recv.cellByIndex(rowIndex, 10).setValue(loadVal);
totalDynamicFeeGain();
loader == null;
return true;
} else if (cInd == 10) {
var rowIndex = mygrid_recv.getRowIndex(rId);
var currency = mygrid_recv.cellByIndex(rowIndex, 9).getValue();
var rate = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 10).getValue())));
if (currency == "RMB") {
if (rate != 1) {
return false;
}
} else if (currency == "USD") {
if (rate <= 1) {
return false;
}
}
totalDynamicFeeGain();
return true;
} else if (cInd == 4) {
var rowIndex = mygrid_recv.getRowIndex(rId);
var unitVal = mygrid_recv.cellByIndex(rowIndex, 4).getValue();
cknum = mygrid_recv.cellByIndex(rowIndex, 6).getValue();
var quantityObj = null;
quantityObj = getTypeNameQuantity(unitVal, cknum);
if (quantityObj.quantity.length > 0) {
if (quantityObj.quantity[0].value > 0) {
mygrid_recv.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name);
mygrid_recv.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
} else {
//mygrid_recv.cellByIndex(rowIndex,4).setValue("");
mygrid_recv.cellByIndex(rowIndex, 6).setValue(1);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = 1; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
}
//重新计算利润
totalDynamicFeeGain();
return true;
}
else if (cInd == 2 || cInd == 3) {
var rowIndex = mygrid_recv.getRowIndex(rId);
if (pressCount == 1) {
if (flagFilter == 1) {
//mygrid_recv.editStop();
mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(oValue); //alert(oValue);
//alert(mygrid_recv.cellByIndex(rowIndex,cInd).getValue());
return true;
}
else {
//if(pressRowIndex == rowIndex && pressCellIndex == cInd){
var cellVal = mygrid_recv.cellByIndex(rowIndex, cInd).getValue();
var combo = mygrid_recv.getCustomCombo(rId, cInd);
var comboArg = combo.getKeys();
//
var tempCount = 0;
if (cellVal.indexOf(" ") > 0 && cellVal.indexOf(" ") < cellVal.length) {
//cellVal = cellVal.substring(0, cellVal.indexOf(" "));
for (var i = 0; i < comboArg.length; i++) {
var skf = comboArg[i];
var skdjf = combo.get(comboArg[i]).trim();
if (combo.get(comboArg[i]).trim().indexOf(cellVal) == 0 || comboArg[i].trim().indexOf(cellVal) == 0) {
mygrid_recv.cellByIndex(rowIndex, cInd).setValue(comboArg[i]);
mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]);
tempCount++;
break;
}
}
}
else {
for (var i = 0; i < comboArg.length; i++) {
if (comboArg[i] == cellVal) {
//var fgff = combo.get(comboArg[i]).trim().indexOf(cellVal);
//if (combo.get(comboArg[i]).trim().indexOf(cellVal) >= 0) {
mygrid_recv.cellByIndex(rowIndex, cInd).setValue(comboArg[i]);
mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]);
tempCount++;
break;
//}
}
}
} //alert(tempCount)
if (tempCount == 0) {
mygrid_recv.cellByIndex(rowIndex, cInd).setValue("");
mygrid_recv.cellByIndex(rowIndex, cInd).setLabel("");
}
isExchange = false;
pressRecord = "";
pressRowIndex = -1;
pressCellIndex = -1;
pressCount = 0;
flagFilter = 0;
totalDynamicFeeGain();
return true;
}
}
else if (pressCount == 2) {
if (flagFilter == 1) {
mygrid_recv.editStop();
mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(oValue);
}
else {
if (pressRowIndex != rowIndex && pressCellIndex != cInd) {
//alert(mygrid_recv.cellByIndex(rowIndex,cInd).getValue());
return true;
}
else {
isExchange = false;
pressRecord = "";
pressRowIndex = -1;
pressCellIndex = -1;
pressCount = 0;
flagFilter = 0;
var cellVal = mygrid_recv.cellByIndex(rowIndex, cInd).getValue().trim();
var combo = mygrid_recv.getCustomCombo(rId, cInd);
var comboArg = combo.getKeys();
//
var tempCount = 0;
if (cellVal.indexOf(" ") > 0 && cellVal.indexOf(" ") < cellVal.length) {
//cellVal = cellVal.substring(0, cellVal.indexOf(" "));
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).trim().indexOf(cellVal) == 0 || comboArg[i].trim().indexOf(cellVal) == 0) {
mygrid_recv.cellByIndex(rowIndex, cInd).setValue(comboArg[i]);
mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]);
tempCount++;
break;
}
}
}
if (tempCount == 0) {
mygrid_recv.cellByIndex(rowIndex, cInd).setValue("");
mygrid_recv.cellByIndex(rowIndex, cInd).setLabel("");
}
//alert(mygrid_recv.cellByIndex(rowIndex,cInd).getValue());
return true;
}
}
}
else {
var cellVal = mygrid_recv.cellByIndex(rowIndex, cInd).getValue();
var combo = mygrid_recv.getCustomCombo(rId, cInd);
var comboArg = combo.getKeys();
var tempCount = 0;
if (cellVal.indexOf(" ") > 0 && cellVal.indexOf(" ") < cellVal.length) {
//cellVal = cellVal.substring(0, cellVal.indexOf(" "));
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).trim().indexOf(cellVal) == 0 || comboArg[i].trim().indexOf(cellVal) == 0) {
mygrid_recv.cellByIndex(rowIndex, cInd).setValue(comboArg[i]);
mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]);
tempCount++;
break;
}
}
}
else {
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).trim().indexOf(cellVal) == 0 || comboArg[i].toString().trim().indexOf(cellVal) == 0) {
mygrid_recv.cellByIndex(rowIndex, cInd).setValue(comboArg[i]);
mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]);
tempCount++;
break;
}
}
}
if (tempCount == 0) {
mygrid_recv.cellByIndex(rowIndex, cInd).setValue("");
mygrid_recv.cellByIndex(rowIndex, cInd).setLabel("");
}
//
if (cInd == 2) {
var url = "";
var feeCodeObj = null;
var feeName = mygrid_recv.cellByIndex(rowIndex, 2).getValue().trim();
if (feeName != "") {
//通过费用名称获取费用代码表code_fee币别汇率信息
url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb=" + stroplb + "&feename=" + escape(feeName) + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(url);
var feeCodeInfo = loader.xmlDoc.responseText;
feeCodeObj = eval('(' + feeCodeInfo + ')');
if (feeCodeObj.feecode.length > 0) {
if (feeCodeObj.feecode[0].cur.trim() != "") {
mygrid_recv.cellByIndex(rowIndex, 9).setValue(feeCodeObj.feecode[0].cur);
//获取委托op_seai费用1汇率
var bsno = $("h_bsno").value;
var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1&currency=" + feeCodeObj.feecode[0].cur + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
mygrid_recv.cellByIndex(rowIndex, 10).setValue(loadVal);
if (feeCodeObj.feecode[0].unit != 0) {
quantityObj = getUnitType(feeCodeObj.feecode[0].unit);
if (quantityObj.quantity.length > 0) {
if (quantityObj.quantity[0].value > 0) {
mygrid_recv.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name);
mygrid_recv.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
}
}
else {
//mygrid_recv.cellByIndex(rowIndex,4).setValue("");
mygrid_recv.cellByIndex(rowIndex, 6).setValue(1);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = 1;
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
}
if (feeCodeObj.feecode[0].debit > 0) {
var debitObj = null;
debitObj = getDebitType(feeCodeObj.feecode[0].debit);
if (debitObj.debit.length > 0) {
if (debitObj.debit[0].value.trim() != "") {
//mygrid_recv.cellByIndex(rowIndex,3).setLabel(debitObj.debit[0].value);
mygrid_recv.cellByIndex(rowIndex, 3).setValue(debitObj.debit[0].value);
}
}
}
ReShowLabel(mygrid_recv);
}
}
}
totalDynamicFeeGain();
return true;
}
}
else {
return true;
}
}
else {
return true;
}
});
mygrid_recv.attachEvent("onSelectStateChanged", function(id){
RowOutBsno=mygrid_recv.cellById(id,20).getValue();
var rowIndex = mygrid_recv.getRowIndex(id);
var checkState = mygrid_recv.cellByIndex(rowIndex,0).getValue();
if(checkState == 0){
if(!validOperatePower(id,1,"select")){
alert("权限不足,请重新选择");
return;
}
//mygrid_recv.cellByIndex(rowIndex,0).setValue(1);
}else{
//mygrid_recv.cellByIndex(rowIndex,0).setValue(0);
}
});
//键盘操作事件
mygrid_recv.attachEvent("onKeyPress", function (code, cFlag, sFlag) {
//onKeyPress begin
//获取当前RowID
var selectedId = mygrid_recv.getSelectedRowId();
//获取当前RowIndex
var rowIndex = mygrid_recv.getRowIndex(selectedId);
//获取当前CellIndex(ind)
var ind = mygrid_recv.getSelectedCellIndex();
RowOutBsno = mygrid_recv.cellById(selectedId, 20).getValue();
//触发操作事件前获取单元值
var oldVal = mygrid_recv.cellByIndex(rowIndex, ind).getValue();
//获取编辑单元
var txtEdit;
for (i = 0; i < document.all.length; i++) {
if (document.all(i).tagName == "TEXTAREA") {
txtEdit = document.all(i);
oldVal = txtEdit.innerHTML;
break;
}
}
if (code == 13) {
//Enter键
if (ind == 5) {
//var rowIndex = mygrid_recv.getRowIndex(selectedId);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 6).getValue())));
var amount = unitPrice * quantityCount;
//mygrid_recv.cellByIndex(rowIndex,5).setValue(outputMoney(unitPrice.toString()));
mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
totalDynamicFeeGain();
return true;
}
if (ind == 2 || ind == 3 || ind == 4 || ind == 9 || ind == 11) {
//如果是检索失败,
if (pressCount == 2) {
mygrid_recv.editStop();
//将value写入cell(触发 stage2)
mygrid_recv.cellByIndex(rowIndex, ind).setValue(oldVal);
//重新打开cell(触发stage0 stage1)
mygrid_recv.selectCell(rowIndex, ind, true, true);
mygrid_recv.cellByIndex(rowIndex, ind).setLabel(oldVal);
mygrid_recv.editCell();
return true;
} else {
var combo = mygrid_recv.getCustomCombo(selectedId, ind);
var comboArg = combo.getKeys();
var tempCount = 0;
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).toLowerCase().trim().indexOf(oldVal) == 0) {
var oldVal = comboArg[i];
var oldLab = combo.get(comboArg[i]);
//记录状态值 检索到数据项
pressCount = 1;
flagFilter = 1;
tempCount++; ;
//关闭编辑
//mygrid_recv.editStop();
//将value写入cell(触发 stage2)
mygrid_recv.cellByIndex(rowIndex, ind).setValue(oldVal);
mygrid_recv.cellByIndex(rowIndex, ind).setLabel(oldLab);
flagFilter = 0;
//重新打开cell(触发stage0 stage1)
mygrid_recv.selectCell(rowIndex, ind, true, true);
mygrid_recv.editCell();
break;
}
}
//
if (tempCount == 0) {
mygrid_recv.cellByIndex(rowIndex, ind).setValue("");
mygrid_recv.cellByIndex(rowIndex, ind).setLabel("");
}
}
if (ind == 2) {
var url = "";
var feeCodeObj = null;
var feeName = mygrid_recv.cellByIndex(rowIndex, 2).getValue().trim();
if (feeName != "") {
//通过费用名称获取费用代码表code_fee币别汇率信息
url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb=" + stroplb + "&feename=" + escape(feeName) + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(url);
var feeCodeInfo = loader.xmlDoc.responseText;
feeCodeObj = eval('(' + feeCodeInfo + ')');
if (feeCodeObj.feecode.length > 0) {
if (feeCodeObj.feecode[0].cur.trim() != "") {
mygrid_recv.cellByIndex(rowIndex, 9).setValue(feeCodeObj.feecode[0].cur);
//获取海运出口委托op_seai费用汇率
var bsno = $("h_bsno").value;
var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1&currency=" + feeCodeObj.feecode[0].cur + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
mygrid_recv.cellByIndex(rowIndex, 10).setValue(loadVal);
if (feeCodeObj.feecode[0].unit != 0) {
quantityObj = getUnitType(feeCodeObj.feecode[0].unit);
if (quantityObj.quantity.length > 0) {
if (quantityObj.quantity[0].value > 0) {
mygrid_recv.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name);
mygrid_recv.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
}
} else {
//mygrid_recv.cellByIndex(rowIndex,4).setValue("");
mygrid_recv.cellByIndex(rowIndex, 6).setValue(1);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = 1;
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
}
if (feeCodeObj.feecode[0].debit > 0) {
var debitObj = null;
debitObj = getDebitType(feeCodeObj.feecode[0].debit);
if (debitObj.debit.length > 0) {
if (debitObj.debit[0].value.trim() != "") {
//mygrid_recv.cellByIndex(rowIndex,2).setLabel(debitObj.debit[0].value);
mygrid_recv.cellByIndex(rowIndex, 3).setValue(debitObj.debit[0].value);
}
}
}
ReShowLabelForEnter(mygrid_recv);
}
}
totalDynamicFeeGain();
return true;
}
return true;
} else {
return true;
}
}
else if (code == 9) {//Tab键
//code9 begin
var colCount = mygrid_recv.getColumnsNum();
var rowCount = mygrid_recv.getRowsNum();
if (ind < colCount) {
isExchange = false;
pressRecord = "";
pressRowIndex = -1;
pressCellIndex = -1;
mygrid_recv.editStop(true);
mygrid_recv.cellByIndex(rowIndex, ind).setLabel(oldVal);
var cInd = ind;
var rId = selectedId;
if (cInd == 5) {
mygrid_recv.cellByIndex(rowIndex, ind).setLabel(oldVal);
var rowIndex = mygrid_recv.getRowIndex(rId);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 6).getValue())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex, 5).setValue(outputMoney(unitPrice.toString()));
mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
totalDynamicFeeGain();
}
else if (cInd == 6) {
var rowIndex = mygrid_recv.getRowIndex(rId);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 6).getValue())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex, 6).setValue(outputMoney(quantityCount.toString()));
mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
totalDynamicFeeGain();
}
else if (cInd == 9) {
var rowIndex = mygrid_recv.getRowIndex(rId);
var curValue = mygrid_recv.cellByIndex(rowIndex, 9).getValue();
//获取海运出口委托op_seai费用汇率
var bsno = $("h_bsno").value;
var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1&currency=" + curValue + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
mygrid_recv.cellByIndex(rowIndex, 10).setValue(loadVal);
totalDynamicFeeGain();
loader == null;
}
else if (cInd == 12) {
mygrid_recv.cellByIndex(rowIndex, 12).setValue(oldVal);
}
else if (cInd == 4 || cInd == 9 || cInd == 11) {
var combo = mygrid_recv.getCustomCombo(rId, cInd);
var comboArg = combo.getKeys();
var tempCount = 0;
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).toUpperCase().trim().indexOf(oldVal) == 0) {
var oldVal = comboArg[i];
var oldLab = combo.get(comboArg[i]);
//记录状态值 检索到数据项
pressCount = 1;
flagFilter = 1;
tempCount++; ;
//关闭编辑
//mygrid_recv.editStop();
//将value写入cell(触发 stage2)
mygrid_recv.cellByIndex(rowIndex, cInd).setValue(oldVal);
mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(oldLab);
flagFilter = 0;
//重新打开cell(触发stage0 stage1)
mygrid_recv.selectCell(rowIndex, cInd, true, true);
mygrid_recv.editCell();
break;
}
}
if (tempCount == 0) {
mygrid_recv.cellByIndex(rowIndex, cInd).setValue("");
mygrid_recv.cellByIndex(rowIndex, cInd).setLabel("");
}
}
else if (cInd == 2 || cInd == 3) {
var combo = mygrid_recv.getCustomCombo(rId, cInd);
var comboArg = combo.getKeys();
var tempCount = 0;
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).toLowerCase().trim().indexOf(oldVal) == 0) {
var oldVal = comboArg[i];
var oldLab = combo.get(comboArg[i]);
//记录状态值 检索到数据项
pressCount = 1;
flagFilter = 1;
tempCount++; ;
//关闭编辑
//mygrid_recv.editStop();
//将value写入cell(触发 stage2)
mygrid_recv.cellByIndex(rowIndex, cInd).setValue(oldVal);
mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(oldLab);
flagFilter = 0;
//重新打开cell(触发stage0 stage1)
mygrid_recv.selectCell(rowIndex, cInd, true, true);
mygrid_recv.editCell();
break;
}
}
if (tempCount == 0) {
mygrid_recv.cellByIndex(rowIndex, cInd).setValue("");
mygrid_recv.cellByIndex(rowIndex, cInd).setLabel("");
}
//
var url = "";
var feeCodeObj = null;
if (cInd == 2) {
var feeName = mygrid_recv.cellByIndex(rowIndex, 2).getValue().trim();
if (feeName != "") {
//通过费用名称获取费用代码表code_fee币别汇率信息
url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb=" + stroplb + "&feename=" + escape(feeName) + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(url);
var feeCodeInfo = loader.xmlDoc.responseText;
feeCodeObj = eval('(' + feeCodeInfo + ')');
if (feeCodeObj.feecode.length > 0) {
mygrid_recv.cellByIndex(rowIndex, 9).setValue(feeCodeObj.feecode[0].cur);
//获取海运出口委托op_seai费用汇率
var bsno = $("h_bsno").value;
var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1&currency=" + feeCodeObj.feecode[0].cur + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
mygrid_recv.cellByIndex(rowIndex, 10).setValue(loadVal);
if (feeCodeObj.feecode[0].unit != 0) {
quantityObj = getUnitType(feeCodeObj.feecode[0].unit);
if (quantityObj.quantity.length > 0) {
if (quantityObj.quantity[0].value > 0) {
mygrid_recv.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name);
mygrid_recv.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex, 7).setValue(outputMoney(amount.toString()));
}
}
} else {
//mygrid_recv.cellByIndex(rowIndex,4).setValue("");
mygrid_recv.cellByIndex(rowIndex, 6).setValue(1);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = 1; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
totalDynamicFeeGain();
if (feeCodeObj.feecode[0].debit > 0) {
var debitObj = null;
debitObj = getDebitType(feeCodeObj.feecode[0].debit);
if (debitObj.debit.length > 0) {
if (debitObj.debit[0].value.trim() != "") {
//mygrid_recv.cellByIndex(rowIndex,3).setLabel(debitObj.debit[0].value);
mygrid_recv.cellByIndex(rowIndex, 3).setValue(debitObj.debit[0].value);
}
}
}
}
}
}
} //end
mygrid_recv.selectCell(rowIndex, ind + 1, true, true);
mygrid_recv.editCell();
if (ind == colCount - 2) {
if (rowIndex < rowCount) {
mygrid_recv.editStop(true);
mygrid_recv.clearSelection();
mygrid_recv.selectCell(rowIndex + 1, 1, true, true);
mygrid_recv.editCell();
} else {
return;
}
}
}
//cdoe9 end
}
else if ((code >= 65 && code <= 90) || (code >= 48 && code <= 57) || (code >= 96 && code <= 105)) {//如果是输入英文字符
if (ind == 2 || ind == 3 || ind == 4 || ind == 11 || ind == 12) {
return true;
}
if ((code >= 48 && code <= 57) || (code >= 96 && code <= 105)) {
if (ind == 5 || ind == 6 || ind == 7 || ind == 10 || ind == 12) {
return true;
}
}
}
//delete
else if (code == 8) {
//code8 begin
if (ind == 2 || ind == 3 || ind == 4 || ind == 9 || ind == 11) {
var start = 0;
var end = 0;
if (document.selection) {
var range = document.selection.createRange();
if (range.parentElement().className == txtEdit.className) {
var range_all = document.body.createTextRange();
range_all.moveToElementText(txtEdit);
for (start = 0; range_all.compareEndPoints("StartToStart", range) < 0; start++) {
range_all.moveStart('character', 1);
}
for (var i = 0; i <= start; i++) {
if (txtEdit.value.charAt(i) == '\n')
start++;
}
var range_all = document.body.createTextRange();
range_all.moveToElementText(txtEdit);
for (end = 0; range_all.compareEndPoints('StartToEnd', range) < 0; end++)
range_all.moveStart('character', 1);
for (var i = 0; i <= end; i++) {
if (txtEdit.value.charAt(i) == '\n')
end++;
}
}
}
// alert(start);alert(end);
//未选中多个字符
if (start == end) {
if (pressRecord != null) {
if (start != 0) {
var firstVal = pressRecord.substring(0, start - 1);
var endVal = pressRecord.substring(start + 1, txtEdit.value.length - 1);
pressRecord = firstVal;
}
}
}
//选中多个字符
if (start != end) {
if (pressRecord != null) {
var firstVal = pressRecord.substring(0, start);
var endVal = pressRecord.substring(end - 1, txtEdit.value.length - 1);
pressRecord = firstVal + endVal;
}
}
setTimeout(function () {
if (pressRecord != null) {
if (pressRecord.trim().length > 0) {
var combo = mygrid_recv.getCustomCombo(selectedId, ind);
var comboArg = combo.getKeys();
var count = 0;
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).toLowerCase().trim().indexOf(pressRecord) == 0) {
count++;
var oldVal = comboArg[i];
var oldLab = combo.get(comboArg[i]);
pressCount = 3;
mygrid_recv.editStop();
mygrid_recv.cellByIndex(rowIndex, ind).setValue(oldVal);
mygrid_recv.selectCell(rowIndex, ind, true, true);
mygrid_recv.editCell();
var old_length = oldLab.length;
for (i = 0; i < document.all.length; i++) {
if (document.all(i).tagName == "TEXTAREA") {
txtEdit = document.all(i);
var rt = txtEdit.createTextRange();
rt.collapse();
rt.select(); //光标置最前
var r = document.selection.createRange();
r.collapse(false);
r.moveStart("character", pressRecord.length); //从m位开始
r.moveEnd("character", old_length); //选取n位
//txtEdit.focus();
r.select();
}
}
break;
}
}
}
}
}, 1000);
return true;
} else {
return true;
}
//code8 end
}
//向下方向键
else if (code == 40) {
//code40 begin
if (ind == 1 || ind == 13 || ind == 5 || ind == 6 || ind == 7 || ind == 8 || ind == 10) {
var rowCount = mygrid_recv.getRowsNum();
mygrid_recv.clearSelection();
mygrid_recv.editStop();
if (rowIndex == (rowCount - 1)) {
addRecvRow();
} else {
mygrid_recv.selectCell(rowIndex + 1, 2, true, true);
mygrid_recv.editCell();
}
} else {
pressCount = 0;
return true;
}
//code40 end
}
//向上箭头
else if (code == 38) {
//code38 begin
if (ind == 1 || ind == 13 || ind == 5 || ind == 6 || ind == 7 || ind == 8 || ind == 10) {
if (rowIndex > 0) {
mygrid_recv.clearSelection();
mygrid_recv.editStop();
mygrid_recv.selectCell(rowIndex - 1, 1, true, true);
mygrid_recv.editCell();
var rowfeename = mygrid_recv.cellByIndex(rowIndex, 5).getValue();
if (rowfeename == 0) {
mygrid_recv.deleteRow(selectedId)
newFeeRecvCount--;
}
}
} else {
pressCount = 0;
return true;
}
//code38 end
}
//左箭头
else if (code == 37) {
//code37 begin
mygrid_recv.clearSelection();
mygrid_recv.editStop();
if (ind == 0) {
mygrid_recv.selectCell(rowIndex, 12, true);
}
else {
mygrid_recv.selectCell(rowIndex, ind - 1, true);
}
mygrid_recv.editCell();
return true;
} //code37 end
//右箭头
else if (code == 39) {
//code39 begin
mygrid_recv.clearSelection();
mygrid_recv.editStop();
if (ind == 12) {
mygrid_recv.selectCell(rowIndex, 0, true);
}
else {
mygrid_recv.selectCell(rowIndex, ind + 1, true);
}
mygrid_recv.editCell();
return true;
} //code39 end
//空格
else if (code == 32) {
if (ind == 12) {
return true;
}
}
else {
return true;
}
//onKeyPress end
});
// var pressVal = "";
// var pressColIndex = 0;
// var pressRowIndex = 0;
// var pressGridType = 1;//recv
setTimeout(function(){
markStatusColor(mygrid_recv);
},460);
}
//返回小键盘的对应数字
function getCode(code) {
var pressVal = String.fromCharCode(code);
if (code == 96) pressVal = 0;
if (code == 97) pressVal = 1;
if (code == 98) pressVal = 2;
if (code == 99) pressVal = 3;
if (code == 100) pressVal = 4;
if (code == 101) pressVal = 5;
if (code == 102) pressVal = 6;
if (code == 103) pressVal = 7;
if (code == 104) pressVal = 8;
if (code == 105) pressVal = 9;
if (code == 106) pressVal = "*";
if (code == 107) pressVal = "+";
if (code == 109) pressVal = "-";
if (code == 111) pressVal = "/";
return pressVal;
}
//讲下拉列表Combo所有生成Array数组
function setComboByArray(gridNewObj,comboObj,rowGID,colIndex){
//var comboTxt_arg = new Array();
var comboVal_arg = new Array();
comboVal_arg = comboObj.getKeys();
var newCombo = gridNewObj.getCustomCombo(rowGID,colIndex);
for(var i = 0;i < comboVal_arg.length;i++){
var txtValue = comboObj.get(comboVal_arg[i]);
newCombo.put(comboVal_arg[i],txtValue);
}
}
function spliceBuffer(arrayRow){
var strBuffer = "";
for(var i = 0;i<arrayRow.length;++i){
strBuffer = strBuffer + arrayRow[i];
if(i != arrayRow.length - 1){
strBuffer = strBuffer + ",";
}
}
//alert(strBuffer);
}
//将整行值暂存到数组中
function getGridRowArray(arrayRow,gridObj,RowID){
var arg = new Array();
var columnCount = gridObj.getColumnsNum();
var rowCount = gridObj.getRowsNum();
//alert(columnCount);alert(rowCount);
for(var i = 0;i < columnCount;i++){
//alert(i);
var cellObj = gridObj.cellById(RowID, i);
//alert(cellObj);
//if(i==5){alert("kill");}
var cell = gridObj.cellById(RowID,i);
//if(i==5){alert("kill");}
var rowValue = cell.getValue();
//if(i==5){alert("kill");}
if(i == columnCount - 1){
arg.push(rowValue == 1?true:false);
break;
}
//校验获取的值是否为数字,如果是数字记录时不加引号,如果是字符增加引号
var re = /^[-\+]?\d+(\.\d+)?$/;
if (!re.test(rowValue)){
switch(i){
case 4:
case 5:
case 6:
case 9:
alert("请正确输入数字");
return;
break;
case 8://如果是币别 则根据value值获取text值
var curCombo = gridObj.getCustomCombo(RowID,i);
arg.push(curCombo.get(rowValue));
break;
default:
arg.push(rowValue);
break;
}
}else{
if(i == 7){
//获取单价
var unitPrice = isObjNaN(parseFloat(gridObj.cellById(RowID,4).getValue()).toFixed(2));
//获取数量
var quantityCount = isObjNaN(parseFloat(gridObj.cellById(RowID,5).getValue()).toFixed(4));
//金额
var amount = unitPrice * quantityCount;
arg.push(outputMoney(amount.toString()));
}else{
arg.push(outputMoney(isObjNaN(parseFloat(rowValue)).toString()));
}
}
}
//alert(arg);
return arg;
}
function isObjNaN(Obj){
if(Obj.toString().toLowerCase() == "nan"){
return 0;
}else{
return Obj;
}
}
function doInitPayGrid(){
//initLoading();
mygrid_pay = new dhtmlXGridObject('mygrid_container_pay');
mygrid_pay.setImagePath("../images/");
mygrid_pay.setSkin("xp");
// 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
mygrid_pay.setHeader("<input type=\"checkbox\" id=\"ck_all_pay\" onclick=\"checkAll('pay')\" />,费用状态,应付费用名称,结算单位,计费标准,单价,数量,佣金比例,金额,币别,汇率,FRT,费用备注,是否垫付,结算金额,申请金额,支票号码,录入人,录入时间,TID,WMSOUTBSNO,行号");
mygrid_pay.setInitWidths("40,70,110,150,70,80,80,90,90,50,70,70,250,70,70,70,120,80,120,0,0,0");
mygrid_pay.setColAlign("center,center,right,right,right,right,right,right,right,right,right,right,right,center,center,center,center,center,center,center,center,center");
// mygrid_pay.setSkin("light");
mygrid_pay.setColSorting("na,str,str,str,int,int,int,int,int,int,int,int,int,str,str,str,str,str,str,str,str,str");
mygrid_pay.setColTypes("ch,ro,co,co,co,ed,ed,ed,ed,co,ed,co,ed,ch,ro,ro,ro,ro,ro,ro,ro,ro");
var bsno = $("h_bsno").value;
////判断委托单有无应付费用
var urlVal = "../Shipping/feegridsource.aspx?type=2&read=exist&showcount=1&oplb="+stroplb+"&wmsoutbsno="+wmsoutbsno+"&bsno="+bsno+"&val="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
loader = null;
if(parseInt(loadVal) == 1){
//获取委托单应付信息初始化grid
mygrid_pay.loadXML("../Shipping/feegridsource.aspx?type=2&read=init&showcount=1&oplb="+stroplb+"&wmsoutbsno="+wmsoutbsno+"&bsno="+bsno,function(){
ReShowLabel(mygrid_pay);
//totalDynamicFeeGain();
//获取利润信息
getFeeProfit(bsno);
//finishLoading();
});
}else{
getFeeProfit(bsno);
}
mygrid_pay.init();
mygrid_pay.enableEditEvents(true,false,true);
mygrid_pay.enableMultiselect(true);
//mygrid_pay.setTabOrder("1,2,3,4,5,6,7,8,9,10,11,12");
//mygrid_pay.enableLightMouseNavigation(true);
mygrid_pay.enableKeyboardSupport(true);
var cacheTemplate = $("h_cachetemplate").value;
var importType = parseInt($("h_importtype").value);
setTimeout(function () {
var cacheTemplate = $("h_cachetemplate").value;
var importType = parseInt($("h_importtype").value);
if (cacheTemplate != "") {
var jsonCacheObj = null;
jsonCacheObj = eval('(' + cacheTemplate + ')');
var delAry = new Array();
for (var i = 0; i < jsonCacheObj.templates.length; i++) {
var newId = newGuid();
//获取插入新纪录位置
//初始化变量
var rowCount = mygrid_pay.getRowsNum();
var tid = "";
var feeName = "";
var customerName = "";
var unit = "";
var unitprice = 0;
var quantity = 0;
var currency = "";
var exchangeRate = 1;
var remark = "";
var isAdvancePay = false;
var client = "";
if (jsonCacheObj.templates[i].type == 2) {
tid = jsonCacheObj.templates[i].tid;
feeName = jsonCacheObj.templates[i].fname;
customerName = jsonCacheObj.templates[i].cust;
unit = jsonCacheObj.templates[i].unit;
unitprice = jsonCacheObj.templates[i].uprice;
currency = jsonCacheObj.templates[i].cur;
exchangeRate = jsonCacheObj.templates[i].exrate == 0 ? 1 : jsonCacheObj.templates[i].exrate;
remark = jsonCacheObj.templates[i].remark;
client = jsonCacheObj.templates[i].client;
var rId = newId;
var linenum = rowCount + 1;
mygrid_pay.addRow(newId, [0, "录入状态", feeName, customerName, unit, unitprice, 0, 0, 0, currency, exchangeRate, "PP", remark, isAdvancePay, 0, 0, '', '', '', tid, wmsoutbsno, linenum], rowCount);
var rowIndex = mygrid_pay.getRowIndex(newId);
if (feeName != "") {
var url = "";
var feeCodeObj = null;
var feeName = mygrid_pay.cellByIndex(rowIndex, 2).getValue().trim();
if (feeName != "") {//通过费用名称获取费用代码表code_fee币别汇率信息
url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb=" + stroplb + "&feename=" + escape(feeName) + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(url);
var feeCodeInfo = loader.xmlDoc.responseText;
feeCodeObj = eval('(' + feeCodeInfo + ')');
if (feeCodeObj.feecode.length > 0) {
if (feeCodeObj.feecode[0].cur.trim() != "") {
//获取委托op_seai费用1汇率
var urlVal = "";
if (currency == "") {
mygrid_pay.cellByIndex(rowIndex, 9).setValue(feeCodeObj.feecode[0].cur);
urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1&currency=" + feeCodeObj.feecode[0].cur + "&uid=" + newGuid();
} else {
mygrid_pay.cellByIndex(rowIndex, 9).setValue(currency);
urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1&currency=" + currency + "&uid=" + newGuid();
}
var bsno = $("h_bsno").value;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
mygrid_pay.cellByIndex(rowIndex, 10).setValue(loadVal);
if (unit == "") {
if (feeCodeObj.feecode[0].unit != 0) {
quantityObj = getUnitType(feeCodeObj.feecode[0].unit);
if (quantityObj.quantity.length > 0) {
if (quantityObj.quantity[0].value > 0) {
mygrid_pay.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name);
mygrid_pay.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
}
} else {
//mygrid_pay.cellByIndex(rowIndex,4).setValue("");
mygrid_pay.cellByIndex(rowIndex, 6).setValue(1);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = 1; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
} else {
var quantityObj = null;
cknum = mygrid_pay.cellByIndex(rowIndex, 6).getValue();
quantityObj = getTypeNameQuantity(unit, cknum);
if (quantityObj.quantity.length > 0) {
if (quantityObj.quantity[0].value > 0) {
mygrid_pay.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name);
mygrid_pay.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
} else {
//mygrid_recv.cellByIndex(rowIndex,4).setValue("");
if (getTypeNum(unit) >= 1) {
mygrid_pay.cellByIndex(rowIndex, 6).setValue(0);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = 0; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
} else {
delAry.push(rId);
alert("请先录入委托的对应箱型,在引入计费标准是箱型的费用!");
//mygrid_recv.deleteRow(rId);rowCount = 0;
}
}
}
}
}
if (feeCodeObj.feecode[0].credit > 0) {
var debitObj = null;
debitObj = getDebitType(feeCodeObj.feecode[0].credit);
if (debitObj.debit.length > 0) {
if (debitObj.debit[0].value.trim() != "") {
if (customerName.trim() != "") {
mygrid_pay.cellByIndex(rowIndex, 3).setValue(customerName.trim());
} else {
mygrid_pay.cellByIndex(rowIndex, 3).setValue(debitObj.debit[0].value);
}
}
}
}
if (delAry.length > 0) {
for (var k = 0; k < delAry.length; k++) {
mygrid_pay.deleteRow(delAry[k]);
}
}
ReShowLabel(mygrid_pay);
totalDynamicFeeGain();
}
}
}
}
}
}
var cacheHistory = $("h_cachehistory").value;
var historyType = parseInt($("h_historytype").value);
var opType = parseInt($("h_historyoptype").value);
if (cacheHistory != "") {
var jsonCacheObj = null;
jsonCacheObj = eval('(' + cacheHistory + ')');
var delAry = new Array();
for (var i = 0; i < jsonCacheObj.history.length; i++) {
var newId = newGuid();
//获取插入新纪录位置
//初始化变量
var rowCount = mygrid_pay.getRowsNum();
var tid = "";
var feeName = "";
var customerName = "";
var unit = "";
var unitprice = 0;
var quantity = 0;
var currency = "";
var exchangeRate = 1;
var remark = "";
var isAdvancePay = false;
var client = "";
var frt = "";
var isAdv = "";
if (jsonCacheObj.history[i].type == 2) {
tid = jsonCacheObj.history[i].tid;
feeName = jsonCacheObj.history[i].fname;
customerName = jsonCacheObj.history[i].cust;
unit = jsonCacheObj.history[i].unit;
unitprice = jsonCacheObj.history[i].uprice;
currency = jsonCacheObj.history[i].cur;
exchangeRate = jsonCacheObj.history[i].exrate == 0 ? 1 : jsonCacheObj.history[i].exrate;
remark = jsonCacheObj.history[i].remark;
client = jsonCacheObj.history[i].client;
frt = jsonCacheObj.history[i].frt;
isAdvancePay = jsonCacheObj.history[i].isadv;
var rId = newId;
var linenum = rowCount + 1;
mygrid_pay.addRow(newId, [0, "录入状态", feeName, customerName, unit, unitprice, 0, 0, 0, currency, exchangeRate, frt, remark, isAdvancePay, 0, 0, '', '', '', tid, wmsoutbsno, linenum], rowCount);
var rowIndex = mygrid_pay.getRowIndex(newId);
if (feeName != "") {
var url = "";
var feeCodeObj = null;
var feeName = mygrid_pay.cellByIndex(rowIndex, 2).getValue().trim();
if (feeName != "") {//通过费用名称获取费用代码表code_fee币别汇率信息
url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb=" + stroplb + "&feename=" + escape(feeName) + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(url);
var feeCodeInfo = loader.xmlDoc.responseText;
feeCodeObj = eval('(' + feeCodeInfo + ')');
if (feeCodeObj.feecode.length > 0) {
if (feeCodeObj.feecode[0].cur.trim() != "") {
var urlVal = "";
if (currency == "") {//获取委托op_seai费用1汇率
mygrid_pay.cellByIndex(rowIndex, 9).setValue(feeCodeObj.feecode[0].cur);
urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1&currency=" + feeCodeObj.feecode[0].cur + "&uid=" + newGuid();
} else {
mygrid_pay.cellByIndex(rowIndex, 9).setValue(currency);
urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1&currency=" + currency + "&uid=" + newGuid();
}
var bsno = $("h_bsno").value;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
mygrid_pay.cellByIndex(rowIndex, 10).setValue(loadVal);
if (unit == "") {
if (feeCodeObj.feecode[0].unit != 0) {
quantityObj = getUnitType(feeCodeObj.feecode[0].unit);
if (quantityObj.quantity.length > 0) {
if (quantityObj.quantity[0].value > 0) {
mygrid_pay.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name);
mygrid_pay.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
}
} else {
mygrid_pay.cellByIndex(rowIndex, 6).setValue(1);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = 1; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
} else {
var quantityObj = null;
cknum = mygrid_pay.cellByIndex(rowIndex, 6).getValue();
quantityObj = getTypeNameQuantity(unit, cknum);
if (quantityObj.quantity.length > 0) {
if (quantityObj.quantity[0].value > 0) {
mygrid_pay.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name);
mygrid_pay.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
} else {
//mygrid_recv.cellByIndex(rowIndex,4).setValue("");
if (getTypeNum(unit) >= 1) {
mygrid_pay.cellByIndex(rowIndex, 6).setValue(0);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = 0; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
}
}
}
}
if (feeCodeObj.feecode[0].credit > 0) {
var debitObj = null;
debitObj = getDebitType(feeCodeObj.feecode[0].credit);
if (debitObj.debit.length > 0) {
if (debitObj.debit[0].value.trim() != "") {
if (opType == 1) {
mygrid_pay.cellByIndex(rowIndex, 3).setValue(customerName.trim());
} else {
mygrid_pay.cellByIndex(rowIndex, 3).setValue(debitObj.debit[0].value);
}
}
}
}
ReShowLabel(mygrid_pay);
totalDynamicFeeGain();
}
}
}
}
}
}
}, 240);
var pushVal = "";
var pressRecord = "";
var pressRowIndex = -1;
var pressCellIndex = -1;
var pressCount = 0;
var isExchange = false;
var shiftCount = 0;
var isDelete = 0;
var flagFilter = 0;
var flagTab = 0;
var flagEnter = 0;
var flagDelete = 0;
mygrid_pay.attachEvent("onSelectStateChanged", function(id){
RowOutBsno=mygrid_pay.cellById(id,20).getValue();
if($("h_enable").value == "1"){
var rowIndex = mygrid_pay.getRowIndex(id);
if(rowIndex >= 0){
var stateVal = mygrid_pay.cellByIndex(rowIndex,1).getValue().trim();
if(stateVal == "录入状态"|| stateVal == "驳回提交"){
var combo_currency;
combo_currency = mygrid_pay.getCustomCombo(id,9);
if(combo_currency.getKeys.length <= 1){
setCurrencyCombo(combo_currency);
}
var combo_feename;
combo_feename = mygrid_pay.getCustomCombo(id,2);
if(combo_feename.getKeys.length <= 1){
setFeeNameCombo(combo_feename);
}
var combo_cust;
combo_cust = mygrid_pay.getCustomCombo(id,3);
if(combo_cust.getKeys.length <= 1){
setCustomerCombo(combo_cust,id);
}
var combo_unit;
combo_unit = mygrid_pay.getCustomCombo(id,4);
if(combo_unit.getKeys.length <= 1){
setUnitCombo(combo_unit);
}
var combo_frt;
combo_frt = mygrid_pay.getCustomCombo(id,11);
if(combo_frt.getKeys.length <= 1){
setFrtCombo(combo_frt);
}
return true;
}else{
return false;
}
}
}
});
//手动编写Grid控件编辑事件,由于免费控件没有提供完整的编辑判断功能,现特此做更改
mygrid_pay.attachEvent("onEditCell", function (stage, rId, cInd, nValue, oValue) {
RowOutBsno = mygrid_pay.cellById(rId, 20).getValue();
var newCheckValue = false;
//初始化状态
if (stage == 0) {
var rowIndex = mygrid_pay.getRowIndex(rId);
var oldVal = mygrid_pay.cellByIndex(rowIndex, 1).getValue().trim();
if (oldVal == "录入状态" || oldVal == "驳回提交") {
if ($("h_enable").value == "0") {
if (cInd == 0) {
if (validOperatePower(rId, 2)) {
return true;
} else {
return false;
}
}
return false;
} else {
if (validOperatePower(rId, 2)) {
return true;
} else {
return false;
}
}
} else {
if (validOperatePower(rId, 2)) {
if (cInd == 0) {
return true;
} else {
return false;
}
} else {
return false;
}
}
}
if (stage == 1) {
var selectedId = mygrid_pay.getSelectedRowId();
var rowIndex = mygrid_pay.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) {
if (oValue == null || oValue == "" || oValue == "0") {
if (cInd != 5 && cInd != 6 && cInd != 8) {
if (nValue == null || nValue == "" || nValue == "0") {
return true;
}
}
}
changeFeePayCount++;
if (cInd == 5) {
var rowIndex = mygrid_pay.getRowIndex(rId);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 6).getValue())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 5).setValue(outputMoney(unitPrice.toString()));
//mygrid_pay.cellByIndex(rowIndex,6).setValue(outputMoney(quantityCount.toString()));
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
totalDynamicFeeGain();
return true;
} else if (cInd == 6) {
var rowIndex = mygrid_pay.getRowIndex(rId);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 6).getValue())));
var amount = unitPrice * quantityCount;
//mygrid_pay.cellByIndex(rowIndex,5).setValue(outputMoney(unitPrice.toString()));
mygrid_pay.cellByIndex(rowIndex, 6).setValue(outputMoney(quantityCount.toString()));
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
totalDynamicFeeGain();
return true;
} else if (cInd == 8) {
var rowIndex = mygrid_pay.getRowIndex(rId);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 6).getValue())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
totalDynamicFeeGain();
return true;
} else if (cInd == 9) {
var rowIndex = mygrid_pay.getRowIndex(rId);
var curValue = mygrid_pay.cellByIndex(rowIndex, 9).getValue();
var bsno = $("h_bsno").value;
//获取海运进口委托op_seai费用1汇率
var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1&currency=" + curValue + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
mygrid_pay.cellByIndex(rowIndex, 10).setValue(loadVal);
totalDynamicFeeGain();
loader == null;
return true;
} else if (cInd == 10) {
var rowIndex = mygrid_pay.getRowIndex(rId);
var currency = mygrid_pay.cellByIndex(rowIndex, 9).getValue();
var rate = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 10).getValue())));
if (currency == "RMB") {
if (rate != 1) {
return false;
}
} else if (currency == "USD") {
if (rate <= 1) {
return false;
}
}
totalDynamicFeeGain();
return true;
} else if (cInd == 4) {
var rowIndex = mygrid_pay.getRowIndex(rId);
var unitVal = mygrid_pay.cellByIndex(rowIndex, 4).getValue();
var quantityObj = null;
cknum = mygrid_pay.cellByIndex(rowIndex, 6).getValue();
quantityObj = getTypeNameQuantity(unitVal, cknum);
if (quantityObj.quantity.length > 0) {
if (quantityObj.quantity[0].value > 0) {
mygrid_pay.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name);
mygrid_pay.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
} else {
//mygrid_pay.cellByIndex(rowIndex,4).setValue("");
mygrid_pay.cellByIndex(rowIndex, 6).setValue(0);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
}
//重新计算利润
totalDynamicFeeGain();
return true;
} else if (cInd == 2 || cInd == 3) {
var rowIndex = mygrid_pay.getRowIndex(rId);
if (pressCount == 1) {
if (flagFilter == 1) {
//mygrid_recv.editStop();
mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(oValue);
return true;
} else {
// if(pressRowIndex == rowIndex && pressCellIndex == cInd){
var cellVal = mygrid_pay.cellByIndex(rowIndex, cInd).getValue();
var combo = mygrid_pay.getCustomCombo(rId, cInd);
var comboArg = combo.getKeys();
var tempCount = 0;
if (cellVal.indexOf(" ") > 0 && cellVal.indexOf(" ") < cellVal.length) {
//cellVal = cellVal.substring(0, cellVal.indexOf(" "));
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).trim().indexOf(cellVal) == 0 || comboArg[i].trim().indexOf(cellVal) == 0) {
mygrid_pay.cellByIndex(rowIndex, cInd).setValue(comboArg[i]);
mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]);
tempCount++;
break;
}
}
} else {
for (var i = 0; i < comboArg.length; i++) {
if (comboArg[i] == cellVal) {
//if (combo.get(comboArg[i]).trim().indexOf(cellVal) >= 0) {
mygrid_pay.cellByIndex(rowIndex, cInd).setValue(comboArg[i]);
mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]);
tempCount++;
break;
//}
}
}
}
//
if (tempCount == 0) {
mygrid_pay.cellByIndex(rowIndex, cInd).setValue("");
mygrid_pay.cellByIndex(rowIndex, cInd).setLabel("");
}
isExchange = false;
pressRecord = "";
pressRowIndex = -1;
pressCellIndex = -1;
pressCount = 0;
flagFilter = 0;
return true;
}
} else if (pressCount == 2) {
if (flagFilter == 1) {
mygrid_pay.editStop();
mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(oValue);
} else {
if (pressRowIndex != rowIndex && pressCellIndex != cInd) {//alert(11)
return true;
} else {
isExchange = false;
pressRecord = "";
pressRowIndex = -1;
pressCellIndex = -1;
pressCount = 0;
flagFilter = 0;
var cellVal = mygrid_pay.cellByIndex(rowIndex, cInd).getValue(); //alert(cellVal)
var combo = mygrid_pay.getCustomCombo(rId, cInd);
var comboArg = combo.getKeys();
var tempCount = 0;
if (cellVal.indexOf(" ") > 0 && cellVal.indexOf(" ") < cellVal.length) {
cellVal = cellVal.substring(0, cellVal.indexOf(" "));
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).trim().indexOf(cellVal) == 0 || comboArg[i].trim().indexOf(cellVal) == 0) {
mygrid_pay.cellByIndex(rowIndex, cInd).setValue(comboArg[i]);
mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]);
tempCount++;
break;
}
}
}
//
if (tempCount == 0) {
mygrid_pay.cellByIndex(rowIndex, cInd).setValue("");
mygrid_pay.cellByIndex(rowIndex, cInd).setLabel("");
}
return true;
}
}
} else {
var cellVal = mygrid_pay.cellByIndex(rowIndex, cInd).getValue();
var combo = mygrid_pay.getCustomCombo(rId, cInd);
var comboArg = combo.getKeys();
var tempCount = 0;
if (cellVal.indexOf(" ") > 0 && cellVal.indexOf(" ") < cellVal.length) {
//cellVal = cellVal.substring(0, cellVal.indexOf(" "));
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).trim().indexOf(cellVal) == 0 || comboArg[i].trim().indexOf(cellVal) == 0) {
mygrid_pay.cellByIndex(rowIndex, cInd).setValue(comboArg[i]);
mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]);
tempCount++;
break;
}
}
} else {
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).trim().indexOf(cellVal) == 0 || comboArg[i].toString().trim().indexOf(cellVal) == 0) {
mygrid_pay.cellByIndex(rowIndex, cInd).setValue(comboArg[i]);
mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]);
tempCount++;
break;
}
}
}
//
if (tempCount == 0) {
mygrid_pay.cellByIndex(rowIndex, cInd).setValue("");
mygrid_pay.cellByIndex(rowIndex, cInd).setLabel("");
}
//
if (cInd == 2) {
var url = "";
var feeCodeObj = null;
var feeName = mygrid_pay.cellByIndex(rowIndex, 2).getValue().trim();
if (feeName != "") {//通过费用名称获取费用代码表code_fee币别汇率信息
url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb=" + stroplb + "&feename=" + escape(feeName) + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(url);
var feeCodeInfo = loader.xmlDoc.responseText;
feeCodeObj = eval('(' + feeCodeInfo + ')');
if (feeCodeObj.feecode.length > 0) {
if (feeCodeObj.feecode[0].cur.trim() != "") {
mygrid_pay.cellByIndex(rowIndex, 9).setValue(feeCodeObj.feecode[0].cur);
//获取委托op_seai费用1汇率
var bsno = $("h_bsno").value;
var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1&currency=" + feeCodeObj.feecode[0].cur + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
mygrid_pay.cellByIndex(rowIndex, 10).setValue(loadVal);
if (feeCodeObj.feecode[0].unit != 0) {
quantityObj = getUnitType(feeCodeObj.feecode[0].unit);
if (quantityObj.quantity.length > 0) {
if (quantityObj.quantity[0].value > 0) {
mygrid_pay.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name);
mygrid_pay.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
}
} else {
//mygrid_pay.cellByIndex(rowIndex,4).setValue("");
mygrid_pay.cellByIndex(rowIndex, 6).setValue(1);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = 1; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
}
if (feeCodeObj.feecode[0].credit > 0) {
var debitObj = null;
debitObj = getDebitType(feeCodeObj.feecode[0].credit);
if (debitObj.debit.length > 0) {
if (debitObj.debit[0].value.trim() != "") {
mygrid_pay.cellByIndex(rowIndex, 3).setValue(debitObj.debit[0].value);
}
}
}
ReShowLabel(mygrid_pay);
}
}
}
totalDynamicFeeGain();
return true;
}
} else {
return true;
}
} else {
return true;
}
});
mygrid_pay.attachEvent("onSelectStateChanged", function(id){
RowOutBsno=mygrid_pay.cellById(id,20).getValue();
var rowIndex = mygrid_pay.getRowIndex(id);
var checkState = mygrid_pay.cellByIndex(rowIndex,0).getValue();
if(checkState == 0){
if(!validOperatePower(id,2,"select")){
alert("权限不足,请重新选择");
return;
}
//mygrid_pay.cellByIndex(rowIndex,0).setValue(1);
}else{
//mygrid_pay.cellByIndex(rowIndex,0).setValue(0);
}
});
//键盘操作事件
mygrid_pay.attachEvent("onKeyPress", function (code, cFlag, sFlag) {
//onKeyPress begin
//获取当前RowID
var selectedId = mygrid_pay.getSelectedRowId();
//获取当前RowIndex
var rowIndex = mygrid_pay.getRowIndex(selectedId);
//获取当前CellIndex(ind)
var ind = mygrid_pay.getSelectedCellIndex();
RowOutBsno = mygrid_pay.cellById(selectedId, 20).getValue();
//触发操作事件前获取单元值
var oldVal = mygrid_pay.cellByIndex(rowIndex, ind).getValue();
//获取编辑单元
var txtEdit;
for (i = 0; i < document.all.length; i++) {
if (document.all(i).tagName == "TEXTAREA") {
txtEdit = document.all(i);
oldVal = txtEdit.innerHTML;
break;
}
}
if (code == 13) {
if (ind == 5) {
//var rowIndex = mygrid_recv.getRowIndex(selectedId);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 6).getValue())));
var amount = unitPrice * quantityCount;
//mygrid_recv.cellByIndex(rowIndex,5).setValue(outputMoney(unitPrice.toString()));
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
totalDynamicFeeGain();
return true;
}
if (ind == 2 || ind == 3 || ind == 4 || ind == 9 || ind == 11) {
//如果是检索失败,
if (pressCount == 2) {
mygrid_pay.editStop();
//将value写入cell(触发 stage2)
mygrid_pay.cellByIndex(rowIndex, ind).setValue(oldVal);
//重新打开cell(触发stage0 stage1)
mygrid_pay.selectCell(rowIndex, ind, true, true);
mygrid_pay.cellByIndex(rowIndex, ind).setLabel(oldVal);
mygrid_pay.editCell();
return true;
} else {
var combo = mygrid_pay.getCustomCombo(selectedId, ind);
var comboArg = combo.getKeys();
var tempCount = 0;
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).toLowerCase().trim().indexOf(oldVal) == 0) {
var oldVal = comboArg[i];
var oldLab = combo.get(comboArg[i]);
//记录状态值 检索到数据项
pressCount = 1;
flagFilter = 1;
tempCount++;
//关闭编辑
//mygrid_pay.editStop();
//将value写入cell(触发 stage2)
mygrid_pay.cellByIndex(rowIndex, ind).setValue(oldVal);
mygrid_pay.cellByIndex(rowIndex, ind).setLabel(oldLab);
flagFilter = 0;
//重新打开cell(触发stage0 stage1)
mygrid_pay.selectCell(rowIndex, ind, true, true);
mygrid_pay.editCell();
break;
}
}
//
if (tempCount == 0) {
mygrid_pay.cellByIndex(rowIndex, ind).setValue("");
mygrid_pay.cellByIndex(rowIndex, ind).setLabel("");
}
}
if (ind == 2) {
var url = "";
var feeCodeObj = null;
var feeName = mygrid_pay.cellByIndex(rowIndex, 2).getValue().trim();
if (feeName != "") {//通过费用名称获取费用代码表code_fee币别汇率信息
url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb=" + stroplb + "&feename=" + escape(feeName) + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(url);
var feeCodeInfo = loader.xmlDoc.responseText;
feeCodeObj = eval('(' + feeCodeInfo + ')');
if (feeCodeObj.feecode.length > 0) {
if (feeCodeObj.feecode[0].cur.trim() != "") {
mygrid_pay.cellByIndex(rowIndex, 9).setValue(feeCodeObj.feecode[0].cur);
//获取委托op_seai费用1汇率
var bsno = $("h_bsno").value;
var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1&currency=" + feeCodeObj.feecode[0].cur + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
mygrid_pay.cellByIndex(rowIndex, 10).setValue(loadVal);
if (feeCodeObj.feecode[0].unit != 0) {
quantityObj = getUnitType(feeCodeObj.feecode[0].unit);
if (quantityObj.quantity.length > 0) {
if (quantityObj.quantity[0].value > 0) {
mygrid_pay.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name);
mygrid_pay.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
}
} else {
//mygrid_pay.cellByIndex(rowIndex,4).setValue("");
mygrid_pay.cellByIndex(rowIndex, 6).setValue(1);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = 1; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
}
if (feeCodeObj.feecode[0].credit > 0) {
var debitObj = null;
debitObj = getDebitType(feeCodeObj.feecode[0].credit);
if (debitObj.debit.length > 0) {
if (debitObj.debit[0].value.trim() != "") {
mygrid_pay.cellByIndex(rowIndex, 3).setValue(debitObj.debit[0].value);
}
}
}
ReShowLabelForEnter(mygrid_pay);
}
}
totalDynamicFeeGain();
return true;
}
return true;
} else {
return true;
}
}
//Tab键
else if (code == 9) {
//code9 begin
var colCount = mygrid_pay.getColumnsNum();
var rowCount = mygrid_pay.getRowsNum();
if (ind < colCount) {
isExchange = false;
pressRecord = "";
pressRowIndex = -1;
pressCellIndex = -1;
mygrid_pay.editStop(true);
mygrid_pay.cellByIndex(rowIndex, ind).setLabel(oldVal);
var cInd = ind;
var rId = selectedId;
if (cInd == 5) {
var rowIndex = mygrid_pay.getRowIndex(rId);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 6).getValue())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 5).setValue(outputMoney(unitPrice.toString()));
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
totalDynamicFeeGain();
} else if (cInd == 6) {
var rowIndex = mygrid_pay.getRowIndex(rId);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 6).getValue())));
var amount = unitPrice * quantityCount;
//mygrid_recv.cellByIndex(rowIndex,5).setValue(outputMoney(unitPrice.toString()));
mygrid_pay.cellByIndex(rowIndex, 6).setValue(outputMoney(quantityCount.toString()));
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
totalDynamicFeeGain();
} else if (cInd == 9) {
var rowIndex = mygrid_pay.getRowIndex(rId);
var curValue = mygrid_pay.cellByIndex(rowIndex, 9).getValue();
//获取海运进口委托op_seai费用1汇率
var bsno = $("h_bsno").value;
var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1&currency=" + curValue + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
mygrid_pay.cellByIndex(rowIndex, 10).setValue(loadVal);
totalDynamicFeeGain();
loader == null;
} else if (cInd == 12) {
mygrid_pay.cellByIndex(rowIndex, 12).setValue(oldVal);
}
else if (cInd == 4 || cInd == 9 || cInd == 11) {
var combo = mygrid_pay.getCustomCombo(rId, cInd);
var comboArg = combo.getKeys();
var tempCount = 0;
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).toUpperCase().trim().indexOf(oldVal) == 0) {
var oldVal = comboArg[i];
var oldLab = combo.get(comboArg[i]);
//记录状态值 检索到数据项
pressCount = 1;
flagFilter = 1;
tempCount++; ;
//关闭编辑
//mygrid_pay.editStop();
//将value写入cell(触发 stage2)
mygrid_pay.cellByIndex(rowIndex, cInd).setValue(oldVal);
mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(oldLab);
flagFilter = 0;
//重新打开cell(触发stage0 stage1)
mygrid_pay.selectCell(rowIndex, cInd, true, true);
mygrid_pay.editCell();
break;
}
}
if (tempCount == 0) {
mygrid_pay.cellByIndex(rowIndex, cInd).setValue("");
mygrid_pay.cellByIndex(rowIndex, cInd).setLabel("");
}
}
else if (cInd == 2 || cInd == 3) {
var combo = mygrid_pay.getCustomCombo(rId, cInd);
var comboArg = combo.getKeys();
var tempCount = 0;
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).toLowerCase().trim().indexOf(oldVal) == 0) {
var oldVal = comboArg[i];
var oldLab = combo.get(comboArg[i]);
//记录状态值 检索到数据项
pressCount = 1;
flagFilter = 1;
tempCount++; ;
//关闭编辑
//mygrid_pay.editStop();
//将value写入cell(触发 stage2)
mygrid_pay.cellByIndex(rowIndex, cInd).setValue(oldVal);
mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(oldLab);
flagFilter = 0;
//重新打开cell(触发stage0 stage1)
mygrid_pay.selectCell(rowIndex, cInd, true, true);
mygrid_pay.editCell();
break;
}
}
if (tempCount == 0) {
mygrid_pay.cellByIndex(rowIndex, cInd).setValue("");
mygrid_pay.cellByIndex(rowIndex, cInd).setLabel("");
}
//
if (cInd == 2) {
var url = "";
var feeCodeObj = null;
var feeName = mygrid_pay.cellByIndex(rowIndex, 2).getValue().trim();
if (feeName != "") {//通过费用名称获取费用代码表code_fee币别汇率信息
url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb=" + stroplb + "&feename=" + escape(feeName) + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(url);
var feeCodeInfo = loader.xmlDoc.responseText;
feeCodeObj = eval('(' + feeCodeInfo + ')');
if (feeCodeObj.feecode.length > 0) {
mygrid_pay.cellByIndex(rowIndex, 9).setValue(feeCodeObj.feecode[0].cur);
//获取委托op_seai费用1汇率
var bsno = $("h_bsno").value;
var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1&currency=" + feeCodeObj.feecode[0].cur + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
mygrid_pay.cellByIndex(rowIndex, 10).setValue(loadVal);
if (feeCodeObj.feecode[0].unit != 0) {
quantityObj = getUnitType(feeCodeObj.feecode[0].unit);
if (quantityObj.quantity.length > 0) {
if (quantityObj.quantity[0].value > 0) {
mygrid_pay.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name);
mygrid_pay.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
}
} else {
//mygrid_pay.cellByIndex(rowIndex,4).setValue("");
mygrid_pay.cellByIndex(rowIndex, 6).setValue(1);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue())));
var quantityCount = 1; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString()));
}
totalDynamicFeeGain();
if (feeCodeObj.feecode[0].credit > 0) {
var debitObj = null;
debitObj = getDebitType(feeCodeObj.feecode[0].credit);
if (debitObj.debit.length > 0) {
if (debitObj.debit[0].value.trim() != "") {
mygrid_pay.cellByIndex(rowIndex, 3).setValue(debitObj.debit[0].value);
}
}
}
}
}
}
}
mygrid_pay.selectCell(rowIndex, ind + 1, true, true);
mygrid_pay.editCell();
if (ind == colCount - 2) {
if (rowIndex < rowCount) {
mygrid_pay.editStop(true);
mygrid_pay.clearSelection();
mygrid_pay.selectCell(rowIndex + 1, 1, true, true);
mygrid_pay.editCell();
} else {
return;
}
}
}
//cdoe9 end
}
else if ((code >= 65 && code <= 90) || (code >= 48 && code <= 57) || (code >= 96 && code <= 105)) {//如果是输入英文字符
if (ind == 2 || ind == 3 || ind == 4 || ind == 11 || ind == 12) {
return true;
}
if ((code >= 48 && code <= 57) || (code >= 96 && code <= 105)) {
if (ind == 5 || ind == 6 || ind == 7 || ind == 10 || ind == 12) {
return true;
}
}
}
//delete
else if (code == 8) {
//code8 begin
if (ind == 2 || ind == 3 || ind == 4 || ind == 9 || ind == 11) {
var start = 0;
var end = 0;
if (document.selection) {
var range = document.selection.createRange();
if (range.parentElement().className == txtEdit.className) {
var range_all = document.body.createTextRange();
range_all.moveToElementText(txtEdit);
for (start = 0; range_all.compareEndPoints("StartToStart", range) < 0; start++) {
range_all.moveStart('character', 1);
}
for (var i = 0; i <= start; i++) {
if (txtEdit.value.charAt(i) == '\n')
start++;
}
var range_all = document.body.createTextRange();
range_all.moveToElementText(txtEdit);
for (end = 0; range_all.compareEndPoints('StartToEnd', range) < 0; end++)
range_all.moveStart('character', 1);
for (var i = 0; i <= end; i++) {
if (txtEdit.value.charAt(i) == '\n')
end++;
}
}
}
//未选中多个字符
if (start == end) {
if (start != 0) {
var firstVal = pressRecord.substring(0, start - 1);
var endVal = pressRecord.substring(start + 1, txtEdit.value.length - 1);
pressRecord = firstVal;
}
}
//选中多个字符
if (start != end) {
var firstVal = pressRecord.substring(0, start);
var endVal = pressRecord.substring(end - 1, txtEdit.value.length - 1);
pressRecord = firstVal + endVal;
}
setTimeout(function () {
if (pressRecord != null) {
if (pressRecord.trim().length > 0) {
var combo = mygrid_pay.getCustomCombo(selectedId, ind);
var comboArg = combo.getKeys();
var count = 0;
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).toLowerCase().trim().indexOf(pressRecord) == 0) {
count++;
var oldVal = comboArg[i];
var oldLab = combo.get(comboArg[i]);
pressCount = 3;
mygrid_pay.editStop();
mygrid_pay.cellByIndex(rowIndex, ind).setValue(oldVal);
mygrid_pay.selectCell(rowIndex, ind, true, true);
mygrid_pay.editCell();
var old_length = oldLab.length;
for (i = 0; i < document.all.length; i++) {
if (document.all(i).tagName == "TEXTAREA") {
txtEdit = document.all(i);
var rt = txtEdit.createTextRange();
rt.collapse();
rt.select(); //光标置最前
var r = document.selection.createRange();
r.collapse(false);
r.moveStart("character", pressRecord.length); //从m位开始
r.moveEnd("character", old_length); //选取n位
//txtEdit.focus();
r.select();
}
}
break;
}
}
}
}
}, 500);
return true;
} else {
return true;
}
//code8 end
}
//向下方向键
else if (code == 40) {
//code40 begin
if (ind == 1 || ind == 13 || ind == 5 || ind == 6 || ind == 7 || ind == 8 || ind == 10) {
var rowCount = mygrid_pay.getRowsNum();
mygrid_pay.clearSelection();
mygrid_pay.editStop();
if (rowIndex == (rowCount - 1)) {
addPayRow();
} else {
mygrid_pay.selectCell(rowIndex + 1, 1, true, true);
mygrid_pay.editCell();
}
} else {
pressCount = 0;
return true;
}
//code40 end
}
//向上箭头
else if (code == 38) {
//code38 begin
if (ind == 1 || ind == 13 || ind == 5 || ind == 6 || ind == 7 || ind == 8 || ind == 10) {
if (rowIndex > 0) {
mygrid_pay.clearSelection();
mygrid_pay.editStop();
mygrid_pay.selectCell(rowIndex - 1, 1, true, true);
mygrid_pay.editCell();
var rowfeename = mygrid_pay.cellByIndex(rowIndex, 5).getValue();
if (rowfeename == 0) {
mygrid_pay.deleteRow(selectedId)
newFeePayCount--;
}
}
} else {
pressCount = 0;
return true;
}
//code38 end
}
//左箭头
else if (code == 37) {
//code37 begin
mygrid_pay.clearSelection();
mygrid_pay.editStop();
if (ind == 0) {
mygrid_pay.selectCell(rowIndex, 12, true);
}
else {
mygrid_pay.selectCell(rowIndex, ind - 1, true);
}
mygrid_pay.editCell();
return true;
} //code37 end
//右箭头
else if (code == 39) {
//code39 begin
mygrid_pay.clearSelection();
mygrid_pay.editStop();
if (ind == 12) {
mygrid_pay.selectCell(rowIndex, 0, true);
}
else {
mygrid_pay.selectCell(rowIndex, ind + 1, true);
}
mygrid_pay.editCell();
return true;
} //code39 end
//空格
else if (code == 32) {
if (ind == 12) {
return true;
}
}
else {
return true;
}
//onKeyPress end
});
setTimeout(function(){
markStatusColor(mygrid_pay);
},460);
var pressVal = "";
var pressColIndex = 0;
var pressRowIndex = 0;
var pressGridType = 1;//recv
}
function addRecvRow(){
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
if(!validOperatePower("",1,"add")){
return;
}
if(opStatus == 1){
var newId = newGuid();
//获取插入新纪录位置
var rowCount = mygrid_recv.getRowsNum();
var linenum = rowCount + 1;
mygrid_recv.addRow(newId, [0, "录入状态", "", "", "", 0, 0, 0, 0, "RMB", 1, "PP", "", false, 0, 0, '', '', '', '0', wmsoutbsno, linenum], rowCount);
mygrid_recv.clearSelection();
var rId = mygrid_recv.getRowId(rowCount-1);
// var combo_name;
// var combo_customer;
// var combo_unit;
// var combo_currency;
// var combo_frt;
//
// combo_name = mygrid_recv.getCustomCombo(rId,1);
// combo_customer = mygrid_recv.getCustomCombo(rId,2);
// combo_unit = mygrid_recv.getCustomCombo(rId,3);
// combo_currency = mygrid_recv.getCustomCombo(rId,8);
// combo_frt = mygrid_recv.getCustomCombo(rId,10);
//
// //重新加载应收费用名称
// setComboByArray(mygrid_recv,combo_name,newId,1);
// //重新加载结算单位
// setComboByArray(mygrid_recv,combo_customer,newId,2);
// //重新加载计费标准
// setComboByArray(mygrid_recv,combo_unit,newId,3);
// //重新加载币别
// setComboByArray(mygrid_recv,combo_currency,newId,8);
// //重新加载FRT
// setComboByArray(mygrid_recv,combo_frt,newId,10);
var combo_currency;
combo_currency = mygrid_recv.getCustomCombo(newId,9);
setCurrencyCombo(combo_currency);
var combo_feename;
combo_feename = mygrid_recv.getCustomCombo(newId,2);
setFeeNameCombo(combo_feename);
var combo_cust;
combo_cust = mygrid_recv.getCustomCombo(newId,3);
setCustomerCombo(combo_cust,newId);
var combo_unit;
combo_unit = mygrid_recv.getCustomCombo(newId,4);
setUnitCombo(combo_unit);
var combo_frt;
combo_frt = mygrid_recv.getCustomCombo(newId,11);
//初始化
setFrtCombo(combo_frt);
newFeeRecvCount++;
setTimeout(function(){
mygrid_recv.editStop(true);
mygrid_recv.selectCell(mygrid_recv.getRowIndex(newId),2,true,true);
mygrid_recv.editCell();
},150);
}else{
alert("委托已退载,费用不能添加");
return;
}
}
function addPayRow(){
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
if(!validOperatePower("",2,"add")){
return;
}
if(opStatus == 1){
var newId = newGuid();
//获取插入新纪录位置
var rowCount = mygrid_pay.getRowsNum();
var linenum = rowCount + 1;
mygrid_pay.addRow(newId, [0, "录入状态", "", "", "", 0, 0, 0, 0, "RMB", 1, "PP", "", false, 0, 0, '', '', '', '0', wmsoutbsno, linenum], rowCount);
mygrid_pay.clearSelection();
var rId = mygrid_pay.getRowId(rowCount-1);
// var combo_name;
// var combo_customer;
// var combo_unit;
// var combo_currency;
//
// combo_name = mygrid_pay.getCustomCombo(rId,1);
// combo_customer = mygrid_pay.getCustomCombo(rId,2);
// combo_unit = mygrid_pay.getCustomCombo(rId,3);
// combo_currency = mygrid_pay.getCustomCombo(rId,8);
//
// //重新加载应收费用名称
// setComboByArray(mygrid_pay,combo_name,newId,1);
// //重新加载结算单位
// setComboByArray(mygrid_pay,combo_customer,newId,2);
// //重新加载计费标准
// setComboByArray(mygrid_pay,combo_unit,newId,3);
// //重新加载币别
// setComboByArray(mygrid_pay,combo_currency,newId,8);
var combo_currency;
combo_currency = mygrid_pay.getCustomCombo(newId,9);
setCurrencyCombo(combo_currency);
var combo_feename;
combo_feename = mygrid_pay.getCustomCombo(newId,2);
setFeeNameCombo(combo_feename);
var combo_cust;
combo_cust = mygrid_pay.getCustomCombo(newId,3);
setCustomerCombo(combo_cust,newId);
var combo_unit;
combo_unit = mygrid_pay.getCustomCombo(newId,4);
setUnitCombo(combo_unit);
var combo_frt;
combo_frt = mygrid_pay.getCustomCombo(newId,11);
setFrtCombo(combo_frt);
newFeePayCount++;
setTimeout(function(){
mygrid_pay.editStop(true);
mygrid_pay.selectCell(mygrid_pay.getRowIndex(newId),2,true,true);
mygrid_pay.editCell();
},150);
}else{
alert("委托已退载,费用不能添加");
return;
}
}
function deleteRecvRow(){
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
var iSuccess = 0;
var iFailure = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
if(opStatus == 1){
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_recv.getRowsNum();i++){
var checkState = mygrid_recv.cellByIndex(i,0).getValue();
var feeState = mygrid_recv.cellByIndex(i,1).getValue();
var rowID = mygrid_recv.getRowId(i);
if(checkState == 1){
if(!validOperatePower(rowID,1)){
alert("权限不足,请重新选择");
return;
}
if(feeState != "录入状态" && feeState != "驳回提交"){
alert("只能删除状态为录入状态和驳回提交状态的应收费用");
return;
}
recvArg.push(rowID);
iCount++;
}
}
if(iCount > 0){
var delCount = 0;
if(recvArg.length > 0){
if(window.confirm("您确定要将所选应收费用删除")){
while(delCount < recvArg.length){
var rowIndex = mygrid_recv.getRowIndex(recvArg[delCount]);
var tid = mygrid_recv.cellByIndex(rowIndex,19).getValue();
var feeName = mygrid_recv.cellByIndex(rowIndex,2).getValue();
var cusName = mygrid_recv.cellByIndex(rowIndex,3).getValue();
//删除委托业务内的费用当ch_fee.feestatus=1或6时通过费用GID删除ch_fee单条费用更新fee_gain重算利润并返回删除操作结果
var urlVal = "../Shipping/FeeService.aspx?gid="+recvArg[delCount]+"&handle=delete&oplb="+stroplb+"&no="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if(loadVal == 1 ){
mygrid_recv.deleteRow(recvArg[delCount]);
}else{
var cacheTemplate = $("h_cachetemplate").value;
var importType = parseInt($("h_importtype").value);
var cacheHistory = $("h_cachehistory").value;
if(cacheTemplate != ""){
var jsonCacheObj = null;
jsonCacheObj = eval('(' + cacheTemplate + ')');
var tempCount = 0;
for(var i=0;i<jsonCacheObj.templates.length;i++){
if(jsonCacheObj.templates[i].tid == tid){
var templateCacheName = $("h_cachename").value;
//从引入费用模板缓存中移除单费用模板返回值1表示移除成功 值2表示未获取到缓存
var RemoveVal = "../Shipping/FeeService.aspx?tid="+tid+"&handle=removeimport&oplb="+stroplb+"&tempcache="+templateCacheName+"&no="+newGuid();
var RemoveLoader = dhtmlxAjax.getSync(RemoveVal);
var RemoveloadVal = RemoveLoader.xmlDoc.responseText;
if(RemoveloadVal >= 1){
jsonCacheObj.templates.splice(i,1);
$("h_cachetemplate").value = JSON.stringify(jsonCacheObj);
mygrid_recv.deleteRow(recvArg[delCount]);
iSuccess++;
tempCount++;
}else{
iFailure++;
}
break;
}
}
if(tempCount == 0){
mygrid_recv.deleteRow(recvArg[delCount]);
iSuccess++;
}
}else if(cacheHistory != ""){
var jsonCacheObj = null;
jsonCacheObj = eval('(' + cacheHistory + ')');
var tempCount = 0;
for(var i=0;i<jsonCacheObj.history.length;i++){
if(jsonCacheObj.history[i].tid == tid){
var templateCacheName = $("h_historycachename").value;
//从引入费用模板缓存中移除单费用模板返回值1表示移除成功 值2表示未获取到缓存
var RemoveVal = "../Shipping/FeeService.aspx?tid="+tid+"&handle=removeimport&oplb="+stroplb+"&tempcache="+templateCacheName+"&no="+newGuid();
var RemoveLoader = dhtmlxAjax.getSync(RemoveVal);
var RemoveloadVal = RemoveLoader.xmlDoc.responseText;
if(RemoveloadVal >= 1){
jsonCacheObj.history.splice(i,1);
$("h_cachehistory").value = JSON.stringify(jsonCacheObj);
mygrid_recv.deleteRow(recvArg[delCount]);
iSuccess++;
tempCount++;
}else{
iFailure++;
}
break;
}
}
if(tempCount == 0){
mygrid_recv.deleteRow(recvArg[delCount]);
iSuccess++;
}
}else{
mygrid_recv.deleteRow(recvArg[delCount]);
iSuccess++;
}
}
delCount++;
}
getFeeProfit(bsno);
}
}
}else{
alert("未选中要操作的费用项");
}
}else{
alert("委托已退载,费用不能修改");
return;
}
}
function deletePayRow(id){
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
var iSuccess = 0;
var iFailure = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
if(opStatus == 1){
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_pay.getRowsNum();i++){
var checkState = mygrid_pay.cellByIndex(i,0).getValue();
var feeState = mygrid_pay.cellByIndex(i,1).getValue();
var rowID = mygrid_pay.getRowId(i);
if(checkState == 1){
if(!validOperatePower(rowID,2)){
alert("权限不足,请重新选择");
return;
}
if(feeState != "录入状态" && feeState != "驳回提交"){
alert("只能删除状态为录入状态和驳回提交状态的应付费用");
return;
}
recvArg.push(rowID);
iCount++;
}
}
if(iCount > 0){
var delCount = 0;
if(recvArg.length > 0){
if(window.confirm("您确定要将所选应付费用删除")){
while(delCount < recvArg.length){
var rowIndex = mygrid_pay.getRowIndex(recvArg[delCount]);
var tid = mygrid_pay.cellByIndex(rowIndex,19).getValue();
var feeName = mygrid_pay.cellByIndex(rowIndex,2).getValue();
var cusName = mygrid_pay.cellByIndex(rowIndex,3).getValue();
//删除委托业务内的费用当ch_fee.feestatus=1或6时通过费用GID删除ch_fee单条费用更新fee_gain重算利润并返回删除操作结果
var urlVal = "../Shipping/FeeService.aspx?gid="+recvArg[delCount]+"&handle=delete&oplb="+stroplb+"&no="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if(loadVal == 1 ){
mygrid_pay.deleteRow(recvArg[delCount]);
}else{
var cacheTemplate = $("h_cachetemplate").value;
var importType = parseInt($("h_importtype").value);
var cacheHistory = $("h_cachehistory").value;
if(cacheTemplate != ""){
var jsonCacheObj = null;
jsonCacheObj = eval('(' + cacheTemplate + ')');
var tempCount = 0;
for(var i=0;i<jsonCacheObj.templates.length;i++){
if(jsonCacheObj.templates[i].tid == tid){
var templateCacheName = $("h_cachename").value;
//从引入费用模板缓存中移除单费用模板返回值1表示移除成功 值2表示未获取到缓存
var RemoveVal = "../Shipping/FeeService.aspx?tid="+tid+"&handle=removeimport&oplb="+stroplb+"&tempcache="+templateCacheName+"&no="+newGuid();
var RemoveLoader = dhtmlxAjax.getSync(RemoveVal);
var RemoveloadVal = RemoveLoader.xmlDoc.responseText;
if(RemoveloadVal >= 1){
jsonCacheObj.templates.splice(i,1);
$("h_cachetemplate").value = JSON.stringify(jsonCacheObj);
mygrid_pay.deleteRow(recvArg[delCount]);
iSuccess++;
tempCount++;
}else{
iFailure++;
}
break;
}
}
if(tempCount == 0){
mygrid_pay.deleteRow(recvArg[delCount]);
iSuccess++;
}
}else if(cacheHistory != ""){
var jsonCacheObj = null;
jsonCacheObj = eval('(' + cacheHistory + ')');
var tempCount = 0;
for(var i=0;i<jsonCacheObj.history.length;i++){
if(jsonCacheObj.history[i].tid == tid){
var templateCacheName = $("h_historycachename").value;
//从引入费用模板缓存中移除单费用模板返回值1表示移除成功 值2表示未获取到缓存
var RemoveVal = "../Shipping/FeeService.aspx?tid="+tid+"&handle=removeimport&oplb="+stroplb+"&tempcache="+templateCacheName+"&no="+newGuid();
var RemoveLoader = dhtmlxAjax.getSync(RemoveVal);
var RemoveloadVal = RemoveLoader.xmlDoc.responseText;
if(RemoveloadVal >= 1){
jsonCacheObj.history.splice(i,1);
$("h_cachehistory").value = JSON.stringify(jsonCacheObj);
mygrid_pay.deleteRow(recvArg[delCount]);
iSuccess++;
tempCount++;
}else{
iFailure++;
}
break;
}
}
if(tempCount == 0){
mygrid_pay.deleteRow(recvArg[delCount]);
iSuccess++;
}
}else{
mygrid_pay.deleteRow(recvArg[delCount]);
iSuccess++;
}
}
delCount++;
}
getFeeProfit(bsno);
}
}
}else{
alert("未选中要操作的费用项");
}
}else{
alert("委托已退载,费用不能修改");
return;
}
}
//保存应收费用
function saveRecvChange(){
var bsno = $("h_bsno").value;
var jsonFeeObj = null;
for(var i=0;i<mygrid_recv.getRowsNum();i++){
var rowId = mygrid_recv.getRowId(i);
var rowIndex = mygrid_recv.getRowIndex(rowId);
var status = mygrid_recv.cellByIndex(i,1).getValue();
var fname = mygrid_recv.cellByIndex(i,2).getValue();
if(fname.trim() == ""){
$("recvContainer").value="";
alert("费用名称不能为空");
return -1;
}
var cust = mygrid_recv.cellByIndex(i,3).getValue();
if(cust.trim() == ""){
$("recvContainer").value="";
alert("结算单位不能为空");
return -1;
}
var unit = mygrid_recv.cellByIndex(i,4).getValue();
if(unit == ""){
$("recvContainer").value="";
}
var price = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue())));
var tempPrice = parseFloat(price).toFixed(2);
if(tempPrice == 0){
$("recvContainer").value="";
alert("单价不能为零");
return -1;
}
var quantity = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,6).getValue())));
var tempQuantity = parseFloat(quantity).toFixed(4);
if(tempQuantity == 0){
$("recvContainer").value="";
alert("数量不能为零");
return -1;
}
var currency = mygrid_recv.cellByIndex(i, 9).getValue();
if (currency.trim() == "") {
$("recvContainer").value = "";
alert("币别不能为空");
return -1;
}
var rate = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(i, 10).getValue())));
var tempRate = parseFloat(rate);
if (tempRate == 0 || rate.trim() == "") {
$("recvContainer").value = "";
alert("汇率不能为零");
return -1;
}
var commission = mygrid_recv.cellByIndex(i,7).getValue();
var amount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(i,8).getValue())));
var tempAmount = parseFloat(amount).toFixed(2);
var frt = mygrid_recv.cellByIndex(i,11).getValue();
var remark = mygrid_recv.cellByIndex(i,12).getValue();
var isAdvance = mygrid_recv.cellByIndex(i,13).getValue();
var linenum = mygrid_recv.cellByIndex(i, 21).getValue();
var outbsno="";
if($("h_outbsno").value!=null && $("h_outbsno").value!=""){
outbsno=$("h_outbsno").value;
}
if(jsonFeeObj == null){
var cacheBuffer = "";
cacheBuffer += "{";
cacheBuffer += "\"id\":\""+rowId+"\",";
cacheBuffer += "\"type\":\"1\",";
cacheBuffer += "\"bsno\":\""+bsno+"\",";
cacheBuffer += "\"outbsno\":\""+outbsno+"\",";
cacheBuffer += "\"status\":\""+status+"\",";
cacheBuffer += "\"fname\":\""+fname+"\",";
cacheBuffer += "\"cust\":\""+cust+"\",";
cacheBuffer += "\"unit\":\""+unit+"\",";
cacheBuffer += "\"price\":\""+price+"\",";
cacheBuffer += "\"quant\":\""+quantity+"\",";
cacheBuffer += "\"com\":\""+commission+"\",";
cacheBuffer += "\"amount\":\""+amount+"\",";
cacheBuffer += "\"cur\":\""+currency+"\",";
cacheBuffer += "\"rate\":\"" + tempRate + "\",";
cacheBuffer += "\"frt\":\""+frt+"\",";
cacheBuffer += "\"remark\":\""+remark+"\",";
cacheBuffer += "\"isadv\":\""+isAdvance+"\",";
cacheBuffer += "\"linenum\":\"" + linenum + "\"";
cacheBuffer += "}";
var result = "";
result += "{\"fees\":[";
result += cacheBuffer;
result += "]}";
jsonFeeObj = eval('(' + result + ')');
}else{
var newFeeRow = jsonFeeObj.fees;
newFeeRow = {id:rowId,type:"1",bsno:bsno,outbsno:outbsno,status:status,fname:fname,
cust:cust,unit:unit,price:tempPrice,quant:tempQuantity,com:commission,
amount: tempAmount, cur: currency, rate: tempRate, frt: frt, remark: remark, isadv: isAdvance, linenum: linenum
};
jsonFeeObj.fees.push(newFeeRow);
}
}
$("recvContainer").value = JSON.stringify(jsonFeeObj);
return 1;
}
function saveAction(){
var RowCount=0;
var unitPrice = 0;
var quantityCount = 0;
var amount = 0;
var stateVal = "";
var id = "";
RowCount=mygrid_recv.getRowsNum();
for(var i=0;i<mygrid_recv.getRowsNum();i++){
unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(i,5).getValue())));
quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(i,6).getValue())));
amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(i,8).setLabel(outputMoney(amount.toString()));
stateVal = mygrid_recv.cellByIndex(i,1).getValue().trim();
}
RowCount=mygrid_pay.getRowsNum();
for(var i=0;i<mygrid_pay.getRowsNum();i++){
unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(i,5).getValue())));
quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(i,6).getValue())));
amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(i,8).setLabel(outputMoney(amount.toString()));
stateVal = mygrid_pay.cellByIndex(i,1).getValue().trim();
}
totalDynamicFeeGain();
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
var recvState = 0;
var payState = 0;
if(opStatus == 1){
recvState = saveRecvChange();//保存应收费用
payState = savePayChange();//保存应付费用
if($("recvContainer").value.trim() == "" && $("payContainer").value.trim() == ""){
return;
}
if(recvState == 1 && payState == 1){
GetGainArg();
msgBox();
//定时发送数据
setTimeout(postEnterFee,200);
newFeeRecvCount = 0;
changeFeeRecvCount = 0;
$("h_post").value = 1;
}
else{
// initGrid();
}
}else{
alert("委托已退载,费用不能修改");
return;
}
}//saveAction 完成
//保存应付费用
function savePayChange(){
var bsno = $("h_bsno").value;
var jsonFeeObj = null;
for(var i=0;i<mygrid_pay.getRowsNum();i++){
var rowId = mygrid_pay.getRowId(i);
var rowIndex = mygrid_pay.getRowIndex(rowId);
var status = mygrid_pay.cellByIndex(i,1).getValue();
var fname = mygrid_pay.cellByIndex(i,2).getValue();
if(fname.trim() == ""){
$("payContainer").value="";
alert("费用名称不能为空");
return -1;
}
var cust = mygrid_pay.cellByIndex(i,3).getValue();
if(cust.trim() == ""){
$("payContainer").value="";
alert("结算单位不能为空");
return -1;
}
var unit = mygrid_pay.cellByIndex(i,4).getValue();
if(unit == ""){
$("payContainer").value="";
}
var price = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,5).getValue())));
var tempPrice = parseFloat(price).toFixed(2);
if(tempPrice == 0){
$("payContainer").value="";
alert("单价不能为零");
return -1;
}
var quantity = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,6).getValue())));
var tempQuantity = parseFloat(quantity).toFixed(4);
if(tempQuantity == 0){
$("payContainer").value="";
alert("数量不能为零");
return -1;
}
var currency = mygrid_pay.cellByIndex(i,9).getValue();
if (currency.trim() == "") {
$("payContainer").value = "";
alert("币别不能为空");
return -1;
}
var rate = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(i,10).getValue())));
var tempRate = parseFloat(rate);
if (tempRate == 0 || rate.trim() == "") {
$("payContainer").value = "";
alert("汇率不能为零");
return -1;
}
var commission = mygrid_pay.cellByIndex(i,7).getValue();
var amount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(i,8).getValue())));
var tempAmount = parseFloat(amount).toFixed(2);
var frt = mygrid_pay.cellByIndex(i,11).getValue();
var remark = mygrid_pay.cellByIndex(i,12).getValue();
var isAdvance = mygrid_pay.cellByIndex(i, 13).getValue();
var linenum = mygrid_pay.cellByIndex(i, 21).getValue();
var outbsno="";
if($("h_outbsno").value!=null && $("h_outbsno").value!=""){
outbsno=$("h_outbsno").value;
}
if(jsonFeeObj == null){
var cacheBuffer = "";
cacheBuffer += "{";
cacheBuffer += "\"id\":\""+rowId+"\",";
cacheBuffer += "\"type\":\"2\",";
cacheBuffer += "\"bsno\":\""+bsno+"\",";
cacheBuffer += "\"outbsno\":\""+outbsno+"\",";
cacheBuffer += "\"status\":\""+status+"\",";
cacheBuffer += "\"fname\":\""+fname+"\",";
cacheBuffer += "\"cust\":\""+cust+"\",";
cacheBuffer += "\"unit\":\""+unit+"\",";
cacheBuffer += "\"price\":\""+price+"\",";
cacheBuffer += "\"quant\":\""+quantity+"\",";
cacheBuffer += "\"com\":\""+commission+"\",";
cacheBuffer += "\"amount\":\""+amount+"\",";
cacheBuffer += "\"cur\":\""+currency+"\",";
cacheBuffer += "\"rate\":\""+rate+"\",";
cacheBuffer += "\"frt\":\""+frt+"\",";
cacheBuffer += "\"remark\":\""+remark+"\",";
cacheBuffer += "\"isadv\":\"" + isAdvance + "\",";
cacheBuffer += "\"linenum\":\"" + linenum + "\"";
cacheBuffer += "}";
var result = "";
result += "{\"fees\":[";
result += cacheBuffer;
result += "]}";
jsonFeeObj = eval('(' + result + ')');
}else{
var newFeeRow = jsonFeeObj.fees;
newFeeRow = {id:rowId,type:"2",bsno:bsno,status:status,fname:fname,
cust:cust,unit:unit,price:tempPrice,quant:tempQuantity,com:commission,
amount: tempAmount, cur: currency, rate: tempRate, frt: frt, remark: remark, isadv: isAdvance, linenum: linenum
};
jsonFeeObj.fees.push(newFeeRow);
}
}
$("payContainer").value = JSON.stringify(jsonFeeObj);
return 1;
}
function doOnRowSelected(rowID,celInd){
alert("Selected row ID is "+rowID+"\nUser clicked cell with index "+celInd);
}
function getValue(){
var colLabel=mygrid_recv.getColumnLabel(0);
var colLabel2=mygrid_recv.getColumnLabel(0,1);
}
//post数据
function postEnterFee(){
var myForm = document.getElementById("form1");
myForm.submit() ;
}
function findRow(){
var colNum = mygrid.getColumnsNum();
var count = mygrid.getRowsNum();
}
//放弃应收费用修改 重新加载页面
function recoverRecvChange(){
var iSuccess = 0;
var iFailure = 0;
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
if(opStatus == 1){
//查看是否有被选中的费用项
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_recv.getRowsNum();i++){
var checkState = mygrid_recv.cellByIndex(i,0).getValue();
var feeState = mygrid_recv.cellByIndex(i,1).getValue();
var rowID = mygrid_recv.getRowId(i);
if(checkState == 1){
if(!validOperatePower(rowID,1)){
return;
}
if(feeState != "录入状态"){
alert("只能对状态为录入状态应收费用进行放弃修改操作");
return;
}
recvArg.push(rowID);
iCount++;
}
}
if(iCount > 0){
var delCount = 0;
if(recvArg.length > 0){
if(window.confirm("您确定要将所选应收费用放弃修改")){
while(delCount < recvArg.length){
var rowIndex = mygrid_recv.getRowIndex(recvArg[delCount]);
var tid = mygrid_recv.cellByIndex(rowIndex,19).getValue();
var feeName = mygrid_recv.cellByIndex(rowIndex,2).getValue();
var cusName = mygrid_recv.cellByIndex(rowIndex,3).getValue();
//恢复委托费用通过费用ch_fee.gid获取ch_fee信息返回字符串
var urlVal = "../Shipping/FeeService.aspx?gid="+recvArg[delCount]+"&handle=recover&oplb="+stroplb+"&no="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if(!IsNum(loadVal)){
var recoverArg = new Array();
recoverArg = loadVal.split(",");
var selRowIndex = mygrid_recv.getRowIndex(recvArg[delCount]);
var colCount = mygrid_recv.getColumnsNum();
for(var i=2;i<colCount-5;i++){
mygrid_recv.cellByIndex(selRowIndex,i).setValue(recoverArg[i]);
}
iSuccess++;
}else{
var cacheTemplate = $("h_cachetemplate").value;
var importType = parseInt($("h_importtype").value);
var cacheHistory = $("h_cachehistory").value;
if(cacheTemplate != ""){
var jsonCacheObj = null;
jsonCacheObj = eval('(' + cacheTemplate + ')');
var tempCount = 0;
for(var i=0;i<jsonCacheObj.templates.length;i++){
if(jsonCacheObj.templates[i].tid == tid){
var templateCacheName = $("h_cachename").value;
//从引入费用模板缓存中移除单费用模板返回值1表示移除成功 值2表示未获取到缓存
var RemoveVal = "../Shipping/FeeService.aspx?tid="+tid+"&handle=removeimport&oplb="+stroplb+"&tempcache="+templateCacheName+"&no="+newGuid();
var RemoveLoader = dhtmlxAjax.getSync(RemoveVal);
var RemoveloadVal = RemoveLoader.xmlDoc.responseText;
if(RemoveloadVal >= 1){
jsonCacheObj.templates.splice(i,1);
$("h_cachetemplate").value = JSON.stringify(jsonCacheObj);
mygrid_recv.deleteRow(recvArg[delCount]);
iSuccess++;
tempCount++;
}else{
iFailure++;
}
break;
}
}
if(tempCount == 0){
mygrid_recv.deleteRow(recvArg[delCount]);
iSuccess++;
}
}else if(cacheHistory != ""){
var jsonCacheObj = null;
jsonCacheObj = eval('(' + cacheHistory + ')');
var tempCount = 0;
for(var i=0;i<jsonCacheObj.history.length;i++){
if(jsonCacheObj.history[i].tid == tid){
var templateCacheName = $("h_historycachename").value;
//从引入费用模板缓存中移除单费用模板返回值1表示移除成功 值2表示未获取到缓存
var RemoveVal = "../Shipping/FeeService.aspx?tid="+tid+"&handle=removeimport&oplb="+stroplb+"&tempcache="+templateCacheName+"&no="+newGuid();
var RemoveLoader = dhtmlxAjax.getSync(RemoveVal);
var RemoveloadVal = RemoveLoader.xmlDoc.responseText;
if(RemoveloadVal >= 1){
jsonCacheObj.history.splice(i,1);
$("h_cachehistory").value = JSON.stringify(jsonCacheObj);
mygrid_recv.deleteRow(recvArg[delCount]);
iSuccess++;
tempCount++;
}else{
iFailure++;
}
break;
}
}
if(tempCount == 0){
mygrid_recv.deleteRow(recvArg[delCount]);
iSuccess++;
}
}else{
mygrid_recv.deleteRow(recvArg[delCount]);
iSuccess++;
}
}
delCount++;
}
}
ReShowLabel(mygrid_recv);
totalDynamicFeeGain();
alert("提交放弃修改应收费用 共 "+delCount+" 条 成功 "+iSuccess+" 条 失败 "+iFailure+" 条");
}
}else{
alert("未选中要操作的费用项");
}
}else{
alert("委托已退载,费用修改费用");
return;
}
}
//放弃应付费用修改 重新加载页面
function recoverPayChange(){
var iSuccess = 0;
var iFailure = 0;
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
if(opStatus == 1){
//查看是否有被选中的费用项
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_pay.getRowsNum();i++){
var checkState = mygrid_pay.cellByIndex(i,0).getValue();
var feeState = mygrid_pay.cellByIndex(i,1).getValue();
var rowID = mygrid_pay.getRowId(i);
if(checkState == 1){
if(!validOperatePower(rowID,2)){
alert("权限不足,请重新选择");
return;
}
if(feeState != "录入状态"){
alert("只能对状态为录入状态应付费用进行放弃修改操作");
return;
}
recvArg.push(rowID);
iCount++;
}
}
if(iCount > 0){
var delCount = 0;
if(recvArg.length > 0){
if(window.confirm("您确定要将所选应付费用放弃修改")){
while(delCount < recvArg.length){
var rowIndex = mygrid_pay.getRowIndex(recvArg[delCount]);
var tid = mygrid_pay.cellByIndex(rowIndex,19).getValue();
var feeName = mygrid_pay.cellByIndex(rowIndex,2).getValue();
var cusName = mygrid_pay.cellByIndex(rowIndex,3).getValue();
//恢复委托费用通过费用ch_fee.gid获取ch_fee信息返回字符串
var urlVal = "../Shipping/FeeService.aspx?gid="+recvArg[delCount]+"&handle=recover&oplb="+stroplb+"&no="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if(!IsNum(loadVal)){
var recoverArg = new Array();
recoverArg = loadVal.split(",");
var selRowIndex = mygrid_pay.getRowIndex(recvArg[delCount]);
var colCount = mygrid_pay.getColumnsNum();
for(var i=2;i<colCount-5;i++){
mygrid_pay.cellByIndex(selRowIndex,i).setValue(recoverArg[i]);
}
iSuccess++;
}else{
var cacheTemplate = $("h_cachetemplate").value;
var importType = parseInt($("h_importtype").value);
var cacheHistory = $("h_cachehistory").value;
if(cacheTemplate != ""){
var jsonCacheObj = null;
jsonCacheObj = eval('(' + cacheTemplate + ')');
var tempCount = 0;
for(var i=0;i<jsonCacheObj.templates.length;i++){
if(jsonCacheObj.templates[i].tid == tid){
var templateCacheName = $("h_cachename").value;
//从引入费用模板缓存中移除单费用模板返回值1表示移除成功 值2表示未获取到缓存
var RemoveVal = "../Shipping/FeeService.aspx?tid="+tid+"&handle=removeimport&oplb="+stroplb+"&tempcache="+templateCacheName+"&no="+newGuid();
var RemoveLoader = dhtmlxAjax.getSync(RemoveVal);
var RemoveloadVal = RemoveLoader.xmlDoc.responseText;
if(RemoveloadVal >= 1){
jsonCacheObj.templates.splice(i,1);
$("h_cachetemplate").value = JSON.stringify(jsonCacheObj);
mygrid_pay.deleteRow(recvArg[delCount]);
iSuccess++;
tempCount++;
}else{
iFailure++;
}
break;
}
}
if(tempCount == 0){
mygrid_pay.deleteRow(recvArg[delCount]);
iSuccess++;
}
}else if(cacheHistory != ""){
var jsonCacheObj = null;
jsonCacheObj = eval('(' + cacheHistory + ')');
var tempCount = 0;
for(var i=0;i<jsonCacheObj.history.length;i++){
if(jsonCacheObj.history[i].tid == tid){
var templateCacheName = $("h_historycachename").value;
//从引入费用模板缓存中移除单费用模板返回值1表示移除成功 值2表示未获取到缓存
var RemoveVal = "../Shipping/FeeService.aspx?tid="+tid+"&handle=removeimport&oplb="+stroplb+"&tempcache="+templateCacheName+"&no="+newGuid();
var RemoveLoader = dhtmlxAjax.getSync(RemoveVal);
var RemoveloadVal = RemoveLoader.xmlDoc.responseText;
if(RemoveloadVal >= 1){
jsonCacheObj.history.splice(i,1);
$("h_cachehistory").value = JSON.stringify(jsonCacheObj);
mygrid_pay.deleteRow(recvArg[delCount]);
iSuccess++;
tempCount++;
}else{
iFailure++;
}
break;
}
}
if(tempCount == 0){
mygrid_pay.deleteRow(recvArg[delCount]);
iSuccess++;
}
}else{
mygrid_pay.deleteRow(recvArg[delCount]);
iSuccess++;
}
}
delCount++;
}
}
ReShowLabel(mygrid_pay);
totalDynamicFeeGain();
alert("提交放弃修改应收费用 共 "+delCount+" 条 成功 "+iSuccess+" 条 失败 "+iFailure+" 条");
}
}else{
alert("未选中要操作的费用项");
}
}else{
alert("委托已退载,费用修改费用");
return;
}
}
//动态计算费用利润信息
function totalDynamicFeeGain(){
//获取应收费用列表行数
var rowCount_recv = mygrid_recv.getRowsNum();
var usdSum_recv = 0.0;//美元合计-应收
var rmbSum_recv = 0.0;//人民币合计-应收
var otherSum_recv = 0.0;//其他币别合计-应收
var totalAmount_recv = 0.0//应收合计-包括除人民币以外其他币别折合成人民币
var usdSum_pay = 0.0;//美元合计-应付
var rmbSum_pay = 0.0;//人民币合计-应付
var otherSum_pay = 0.0;//其他币别合计-应付
var totalAmount_pay = 0.0//应付合计-包括除人民币以外其他币别折合成人民币
var usdGain = 0.0//美元利润
var rmbGain = 0.0//人民币利润
var otherGain = 0.0//其他币别利润
var totalGain = 0.0//合计利润
var gainRate = 0.0//利润比率
//计算应收费用
for(var i = 0;i<rowCount_recv;i++){
//获取Row GID
var rId = mygrid_recv.getRowId(i);
//费用名称
var sfeename = mygrid_recv.cellById(rId, 2);
sfeename = sfeename.getValue();
var uv = "../Shipping/feegridsource.aspx?read=isfeename&feename="+escape(sfeename)+"&val=" + newGuid();
var ld = dhtmlxAjax.getSync(uv);
var lv = ld.xmlDoc.responseText;
if (lv.trim() != "0") {
continue;
}
//定位币别单元位置
var cell = mygrid_recv.cellById(rId,9);
//获取当前行币别类型
var value = cell.getValue().toLowerCase();
//获取总金额
var amount = parseFloat(ConvertToMoney(mygrid_recv.cellById(rId,8).getValue())).toFixed(2);
if(amount.toString().toLowerCase() == "nan"){
amount = 0.0;
}
var exchangeRate_recv = 0.0;//当前对应汇率比率
exchangeRate_recv = parseFloat(mygrid_recv.cellById(rId,10).getValue());
switch(value){
case "usd":
usdSum_recv = usdSum_recv + parseFloat(amount);
totalAmount_recv += ( parseFloat(amount) * (exchangeRate_recv > 0 ? exchangeRate_recv : 1));
break;
case "rmb":
rmbSum_recv = rmbSum_recv + parseFloat(amount);
totalAmount_recv += parseFloat(amount);
break;
default:
otherSum_recv = otherSum_recv + parseFloat(amount);
totalAmount_recv += (parseFloat(amount) * (exchangeRate_recv > 0 ? exchangeRate_recv : 1));
break;
}
}
$("dvUSRecvVal").innerHTML = outputMoney(usdSum_recv.toString());
$("dvRecvRMBVal").innerHTML = outputMoney(rmbSum_recv.toString());
$("dvOtherCurrencyRecvVal").innerHTML = outputMoney(otherSum_recv.toString());
$("dvRecvTotalVal").innerHTML = outputMoney(totalAmount_recv.toString());
//获取应付费用列表行数
var rowCount_pay = mygrid_pay.getRowsNum();
//计算应收费用
for(var j = 0;j<rowCount_pay;j++){
//获取Row GID
var rowID = mygrid_pay.getRowId(j);
//费用名称
var sfeename = mygrid_pay.cellById(rowID, 2);
sfeename = sfeename.getValue();
var uv = "../Shipping/feegridsource.aspx?read=isfeename&feename=" + escape(sfeename) + "&val=" + newGuid();
var ld = dhtmlxAjax.getSync(uv);
var lv = ld.xmlDoc.responseText;
if (lv.trim() != "0") {
continue;
}
//定位币别单元位置
var cell_pay = mygrid_pay.cellById(rowID,9);
//获取当前行币别类型
var pay_value = cell_pay.getValue().toLowerCase();
//获取总金额
var amount = parseFloat(ConvertToMoney(mygrid_pay.cellById(rowID,8).getValue())).toFixed(2);
if(amount.toString().toLowerCase() == "nan"){
amount = 0.0;
}
var exchangeRate_pay = 0.0;//当前对应汇率比率
exchangeRate_pay = parseFloat(mygrid_pay.cellById(rowID,10).getValue());
switch(pay_value){
case "usd":
usdSum_pay = parseFloat(usdSum_pay) + parseFloat(amount);
totalAmount_pay += ( parseFloat(amount) * (exchangeRate_pay > 0 ? exchangeRate_pay : 1));
break;
case "rmb":
rmbSum_pay = parseFloat(rmbSum_pay) + parseFloat(amount);
totalAmount_pay += parseFloat(amount);
break;
default:
otherSum_pay = otherSum_pay + parseFloat(amount);
totalAmount_pay += (parseFloat(amount) * (exchangeRate_pay > 0 ? exchangeRate_pay : 1));
break;
}
}
//alert(usdSum_pay);alert(rmbSum_pay);alert(otherSum_pay);alert(totalAmount_pay);
$("dvUSPayVal").innerHTML = outputMoney(usdSum_pay.toString());
$("dvPayRMBVal").innerHTML = outputMoney(rmbSum_pay.toString());
$("dvOtherCurrencyPayVal").innerHTML = outputMoney(otherSum_pay.toString());
$("dvPaySumVal").innerHTML = outputMoney(totalAmount_pay.toString());
//计算利润
usdGain = usdSum_recv - usdSum_pay;//美元利润
rmbGain = rmbSum_recv - rmbSum_pay;//人民币利润
otherGain = otherSum_recv - otherSum_pay;//其他币别利润
totalGain = totalAmount_recv - totalAmount_pay;//利润合计
$("dvUSProfitVal").innerHTML = outputMoney(usdGain.toString());
if(usdGain < 0 || usdGain == 0){
$("dvUSProfitVal").style.color = "#007F00";
}
$("dvRMBProfitVal").innerHTML = outputMoney(rmbGain.toString());
if(rmbGain < 0 || rmbGain == 0){
$("dvRMBProfitVal").style.color = "#007F00";
}
$("dvOtherCurrencyProfitVal").innerHTML = outputMoney(otherGain.toString());
if(otherGain < 0 || otherGain == 0){
$("dvOtherCurrencyProfitVal").style.color = '#007F00';
}
$("dvProfitTotalVal").innerHTML = outputMoney(totalGain.toString());
if(totalGain < 0 || totalGain == 0){
$("dvProfitTotalVal").style.color = "#007F00";
}
if(totalAmount_recv == 0){
$("dvProfitRateVal").innerHTML = "0%";
$("dvProfitRateVal").style.color = "#007F00";
}else{
//利润合计除以应付费用
gainRate = (totalGain / totalAmount_recv) * 100;
var percentage = gainRate.toFixed(2);
$("dvProfitRateVal").innerHTML = percentage.toString() + "%";
}
}
function amountSum(gridName){//未调用、未完成
if(gridName == "recv"){
//计算应收
mygrid_recv
}else{
//计算应付
}
}
//输出money
function outputMoney(number) {
number= number.replace(/\,/g,"");
if (isNaN(number)||number=="") return "";
number = Math.round( number*10000) /10000;
if (number < 0) {
var sdf = '-' + outputDollars(Math.floor(Math.abs(number) - 0) + '') + outputCents(Math.abs(number) - 0);
return '-' + outputDollars(Math.floor(Math.abs(number) - 0) + '') + outputCents(Math.abs(number) - 0);
}
else {
var sdf = outputDollars(Math.floor(number - 0) + '') + outputCents(number - 0);
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) {
var ls = "";
amount = Math.round(((amount) - Math.floor(amount)) * 10000);
if (amount < 10) {
ls = '.000' + amount;
}
else if (amount < 100) {
ls = '.00' + amount;
}
else if (amount < 1000) {
ls = '.0' + amount;
}
else if (amount < 10000) {
ls = '.' + amount;
}
//return (amount<10 ? '.000' + amount : '.' + amount);
return ls;
}
//获取GUID
function newGuid()
{
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 dialog()
{
// alert("打开dialog");
this.width=450;
this.height=360;
this.title_height=20;
this.html='';
this.title='';
var self = this;
var bgObj,msgObj,titleObj;
this.close=function()
{
document.body.removeChild(document.getElementById("bgDiv"));
document.getElementById("msgDiv").removeChild(document.getElementById("msgTitle"));
document.body.removeChild(document.getElementById("msgDiv"));
}
this.show=function()
{
var msgw,msgh,bordercolor;
msgw=self.width;
msgh=self.height;
bordercolor="#336699";
titlecolor="#99CCFF";
var sWidth,sHeight;
sWidth=document.body.offsetWidth;
sHeight=screen.height;
bgObj=document.createElement("div");
bgObj.setAttribute('id','bgDiv');
bgObj.style.position="absolute";
bgObj.style.top="0";
bgObj.style.background="#777";
bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
bgObj.style.opacity="0.6";
bgObj.style.left="0";
bgObj.style.width=sWidth + "px";
bgObj.style.height=sHeight + "px";
bgObj.style.zIndex = "10000";
document.body.appendChild(bgObj);
msgObj=document.createElement("div")
msgObj.setAttribute("id","msgDiv");
msgObj.setAttribute("align","center");
msgObj.style.background="white";
msgObj.style.border="1px solid " + bordercolor;
msgObj.style.position = "absolute";
msgObj.style.left = "50%";
msgObj.style.top = "30%";
msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
msgObj.style.marginLeft = "-225px" ;
msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px";
msgObj.style.width = msgw + "px";
msgObj.style.height =msgh + "px";
msgObj.style.textAlign = "center";
msgObj.style.lineHeight ="25px";
msgObj.style.zIndex = "10001";
titleObj=document.createElement("h4");
titleObj.setAttribute("id","msgTitle");
titleObj.setAttribute("align","center");
titleObj.style.margin="0";
titleObj.style.padding="3px";
titleObj.style.background=bordercolor;
titleObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);";
titleObj.style.opacity="0.75";
titleObj.style.border="1px solid " + bordercolor;
titleObj.style.height=self.title_height+"px";
titleObj.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif";
titleObj.style.color="white";
titleObj.style.cursor="pointer";
titleObj.innerHTML=self.title;
//titleObj.onclick=function(){self.close();}
document.body.appendChild(msgObj);
document.getElementById("msgDiv").appendChild(titleObj);
var txt=document.createElement("div");
txt.style.margin="1em 0"
txt.setAttribute("id","msgTxt");
txt.innerHTML=self.html;
document.getElementById("msgDiv").appendChild(txt);
}
}
//信息提示
function msgBox(){
var dg=new dialog();
dg.html="费用正在保存中,请稍等……";//"<input type=button onclick='new dialog().close();' value='确定'>";
dg.width=200;
dg.height=100;
dg.title="";
dg.show();
}
//是否为数字
function IsNum(val){
var re = /^[-\+]?\d+(\.\d+)?$/;
if (!re.test(val)){
return false;
}else{
return true;
}
}
//去除“,”
function ConvertToMoney(strObj){
var result = strObj.replace(",","");
return result;
}
//将页面利润信息存入变量gainContainer
function GetGainArg(){
var gainArg = new Array();
var ls = "";
if ($("dvRecvRMBVal").innerHTML.trim() == "" || $("dvRecvRMBVal").innerHTML.trim() == "NaN") {
ls = "0";
}
else {
ls = $("dvRecvRMBVal").innerHTML.trim();
}
gainArg.push(ConvertToMoney(ls));
if ($("dvUSRecvVal").innerHTML.trim() == "" || $("dvUSRecvVal").innerHTML.trim() == "NaN") {
ls = "0";
}
else {
ls = $("dvUSRecvVal").innerHTML.trim();
}
gainArg.push(ConvertToMoney(ls));
if ($("dvOtherCurrencyRecvVal").innerHTML.trim() == "" || $("dvOtherCurrencyRecvVal").innerHTML.trim() == "NaN") {
ls = "0";
}
else {
ls = $("dvOtherCurrencyRecvVal").innerHTML.trim();
}
gainArg.push(ConvertToMoney(ls));
if ($("dvPayRMBVal").innerHTML.trim() == "" || $("dvPayRMBVal").innerHTML.trim() == "NaN") {
ls = "0";
}
else {
ls = $("dvPayRMBVal").innerHTML.trim();
}
gainArg.push(ConvertToMoney(ls));
if ($("dvUSPayVal").innerHTML.trim() == "" || $("dvUSPayVal").innerHTML.trim() == "NaN") {
ls = "0";
}
else {
ls = $("dvUSPayVal").innerHTML.trim();
}
gainArg.push(ConvertToMoney(ls));
if ($("dvOtherCurrencyPayVal").innerHTML.trim() == "" || $("dvOtherCurrencyPayVal").innerHTML.trim() == "NaN") {
ls = "0";
}
else {
ls = $("dvOtherCurrencyPayVal").innerHTML.trim();
}
gainArg.push(ConvertToMoney(ls));
if ($("dvRecvTotalVal").innerHTML.trim() == "" || $("dvRecvTotalVal").innerHTML.trim() == "NaN") {
ls = "0";
}
else {
ls = $("dvRecvTotalVal").innerHTML.trim();
}
gainArg.push(ConvertToMoney(ls));
if ($("dvPaySumVal").innerHTML.trim() == "" || $("dvPaySumVal").innerHTML.trim() == "NaN") {
ls = "0";
}
else {
ls = $("dvPaySumVal").innerHTML.trim();
}
gainArg.push(ConvertToMoney(ls));
if ($("dvRMBProfitVal").innerHTML.trim() == "" || $("dvRMBProfitVal").innerHTML.trim() == "NaN") {
ls = "0";
}
else {
ls = $("dvRMBProfitVal").innerHTML.trim();
}
gainArg.push(ConvertToMoney(ls));
if ($("dvUSProfitVal").innerHTML.trim() == "" || $("dvUSProfitVal").innerHTML.trim() == "NaN") {
ls = "0";
}
else {
ls = $("dvUSProfitVal").innerHTML.trim();
}
gainArg.push(ConvertToMoney(ls));
if ($("dvOtherCurrencyProfitVal").innerHTML.trim() == "" || $("dvOtherCurrencyProfitVal").innerHTML.trim() == "NaN") {
ls = "0";
}
else {
ls = $("dvOtherCurrencyProfitVal").innerHTML.trim();
}
gainArg.push(ConvertToMoney(ls));
if ($("dvProfitTotalVal").innerHTML.trim() == "" || $("dvProfitTotalVal").innerHTML.trim() == "NaN") {
ls = "0";
}
else {
ls = $("dvProfitTotalVal").innerHTML.trim();
}
gainArg.push(ConvertToMoney(ls));
if ($("dvProfitRateVal").innerHTML.trim() == "" || $("dvProfitRateVal").innerHTML.trim() == "NaN") {
ls = "0%";
}
else {
ls = $("dvProfitRateVal").innerHTML.trim();
}
gainArg.push(ConvertToMoney(ls));
//
// gainArg.push(ConvertToMoney($("dvRecvRMBVal").innerHTML));
// gainArg.push(ConvertToMoney($("dvUSRecvVal").innerHTML));
// gainArg.push(ConvertToMoney($("dvOtherCurrencyRecvVal").innerHTML));
//
// gainArg.push(ConvertToMoney($("dvPayRMBVal").innerHTML));
// gainArg.push(ConvertToMoney($("dvUSPayVal").innerHTML));
// gainArg.push(ConvertToMoney($("dvOtherCurrencyPayVal").innerHTML));
//
// gainArg.push(ConvertToMoney($("dvRecvTotalVal").innerHTML));
// gainArg.push(ConvertToMoney($("dvPaySumVal").innerHTML));
//
// gainArg.push(ConvertToMoney($("dvRMBProfitVal").innerHTML));
// gainArg.push(ConvertToMoney($("dvUSProfitVal").innerHTML));
// gainArg.push(ConvertToMoney($("dvOtherCurrencyProfitVal").innerHTML));
// gainArg.push(ConvertToMoney($("dvProfitTotalVal").innerHTML));
// gainArg.push($("dvProfitRateVal").innerHTML);
$("gainContainer").value = gainArg;
}
//过滤结算单位ComboCustomer的键盘
function filterComboCustomerPress(gridObj,rowID,rowIndex,colIndex,filterVal,oldVal){
var combo = gridObj.getCustomCombo(rowID,colIndex);
var comboArg = combo.getKeys();
var doCount = 0;
for(var i = 0;i<comboArg.length;i++){
if(combo.get(comboArg[i]).toLowerCase().trim().indexOf(filterVal.toLowerCase()) == 0){
//gridObj.cellByIndex(rowIndex,colIndex).setValue(comboArg[i]);
gridObj.cellByIndex(rowIndex,colIndex).setValue(combo.get(comboArg[i]));
//combo.selectOption(3,true,true);
//gridObj.editStop();
gridObj.selectCell(rowIndex,colIndex,true,true,true,true);
doCount = 1;
break;
}
}
// if(doCount == 0){
// gridObj.cellByIndex(rowIndex,colIndex).setValue(oldVal);
// }
}//end filterComboCustomerPress
//两端去空格函数
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
//应收费用提交审核
function orderRecvAudit(){
var iSuccess = 0;
var iFailure = 0;
var postBillNO = "";
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
// //if(parseInt($("h_recvauthority").value) <= 0){
// if(!validOperatePower(rId,1)){
// return;
// }
if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){
alert("应付费用未保存,请先保存应付费用");
return;
}
if(opStatus == 1){
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_recv.getRowsNum();i++){
var checkState = mygrid_recv.cellByIndex(i,0).getValue();
var feeState = mygrid_recv.cellByIndex(i,1).getValue();
var rowID = mygrid_recv.getRowId(i);
if(checkState == 1){
if(!validOperatePower(rowID,1)){
alert("权限不足,请重新选择");
return;
}
if(feeState != "录入状态" && feeState != "驳回提交"){
alert("只能提交录入状态和驳回提交状态的应收费用进行审核");
return;
}
recvArg.push(rowID);
iCount++;
}
}
if(iCount > 0){
if(recvArg.length > 0){
if(window.confirm("您确定将所选应收费用提交审核")){
var delCount = 0;
var loadVal = 0;
while(delCount < recvArg.length){
var rowIndex = mygrid_recv.getRowIndex(recvArg[delCount]);
var feeName = mygrid_recv.cellByIndex(rowIndex,2).getValue();
var cusName = mygrid_recv.cellByIndex(rowIndex,3).getValue();
//更新费用信息ch_fee.feestatus和工作流运行表WorkFlowDo信息,返回操作结果
var urlVal = "../AuditProcess/AuditService.aspx?handle=audit&oplb="+stroplb+"&id="+recvArg[delCount]+"&val="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
loadVal = loader.xmlDoc.responseText;
if(loadVal > 0){
iSuccess++;
if(iSuccess == 1){
postBillNO = recvArg[delCount];
}
}else{
iFailure++;
}
delCount++;
}
if(delCount > 0){
if (loadVal != 10 && loadVal > 0) {
//向审核人发送申请消息
var postUrlVal = "../message/messageservice.aspx?billno="+postBillNO+"&type=1&oplb="+stroplb+"&handle=postmessage&bsno="+bsno+"&uid="+newGuid();;
var loader = dhtmlxAjax.getSync(postUrlVal);
var loadVal = loader.xmlDoc.responseText;
}
alert("提交应收费用审核 "+delCount+" 条 成功 "+iSuccess+" 条 失败 "+iFailure+" 条");
}
doInitRecvGrid();
}
}
}else{
alert("未选中要操作的费用项");
}
}else{
alert("委托已退载,费用不能添加");
return;
}
}
//应付费用提交审核
function orderPayAudit(){
var iSuccess = 0;
var iFailure = 0;
var postBillNO = "";
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
// if(parseInt($("h_payauthority").value) <= 0){
// return;
// }
if(newFeePayCount > 0 || changeFeePayCount > 0){
alert("应收费用未保存,请先将应收费用保存,提交应付费用-提交审核");
return false;
}
if(opStatus == 1){
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_pay.getRowsNum();i++){
var checkState = mygrid_pay.cellByIndex(i,0).getValue();
var feeState = mygrid_pay.cellByIndex(i,1).getValue();
var rowID = mygrid_pay.getRowId(i);
if(checkState == 1){
if(!validOperatePower(rowID,2)){
alert("权限不足,请重新选择");
return;
}
if(feeState != "录入状态" && feeState != "驳回提交"){
alert("只能提交录入状态和驳回提交状态的应付费用进行审核");
return;
}
recvArg.push(rowID);
iCount++;
}
}
if(iCount > 0){
if(recvArg.length > 0){
if(window.confirm("您确定将所选应付费用提交审核")){
var delCount = 0;
var loadVal = 0;
while(delCount < recvArg.length){
var rowIndex = mygrid_pay.getRowIndex(recvArg[delCount]);
var feeName = mygrid_pay.cellByIndex(rowIndex,2).getValue();
var cusName = mygrid_pay.cellByIndex(rowIndex,3).getValue();
//更新费用信息ch_fee.feestatus和工作流运行表WorkFlowDo信息,返回操作结果
var urlVal = "../AuditProcess/AuditService.aspx?handle=audit&oplb=" + stroplb + "&id=" + recvArg[delCount] + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
loadVal = loader.xmlDoc.responseText;
if (loadVal > 0) {
iSuccess++;
if(iSuccess == 1){
postBillNO = recvArg[delCount];
}
}else{
iFailure++;
}
delCount++;
}
if (delCount > 0) {
if (loadVal != 10 && loadVal > 0) {
//向审核人发送申请消息
var postUrlVal = "../message/messageservice.aspx?billno=" + postBillNO + "&type=1&oplb=" + stroplb + "&handle=postmessage&bsno="+bsno+ "&uid=" + newGuid(); ;
var loader = dhtmlxAjax.getSync(postUrlVal);
var loadVal = loader.xmlDoc.responseText;
}
alert("提交应付费用审核 "+delCount+" 条 成功 "+iSuccess+" 条 失败 "+iFailure+" 条");
}
doInitPayGrid();
}
}
}else{
alert("未选中要操作的费用项");
}
}else{
alert("委托已退载,费用不能添加");
return;
}
}
//应收费用申请修改
function orderRecvModify(){
var iSuccess = 0;
var iFailure = 0;
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
//if(parseInt($("h_recvauthority").value) <= 0){
//return;
// }
if(opStatus == 1){
if(newFeePayCount > 0 || changeFeePayCount > 0){
alert("应付费用未保存,先保存应付费用再进行应收费用--申请修改");
return;
}
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_recv.getRowsNum();i++){
var checkState = mygrid_recv.cellByIndex(i,0).getValue();
var feeState = mygrid_recv.cellByIndex(i,1).getValue();
var rowID = mygrid_recv.getRowId(i);
if(checkState == 1){
if(!validOperatePower(rowID,1)){
alert("权限不足,请重新选择");
return;
}
if(feeState == "申请修改"){
alert("不能重复申请修改,如要查看申请信息请点-历史申请-查看");
return;
}
if(feeState == "申请删除"){
alert("不能申请删除,如要查看申请信息请点-历史申请-查看");
return;
}
if(feeState == "录入状态"){
alert("录入状态-不能申请修改");
return;
}
if(feeState == "提交审核"){
alert("提交审核-不能申请修改");
return;
}
if(feeState == "结算完毕"){
alert("结算完毕-不能申请修改");
return;
}
if(feeState == "部分结算"){
alert("部分结算-不能申请修改");
return;
}
recvArg.push(rowID);
iCount++;
}
}
if(iCount == 1){
var rowIndex = mygrid_recv.getRowIndex(recvArg[0]);
var statusName = mygrid_recv.cellByIndex(rowIndex,1).getValue();
var feeName = mygrid_recv.cellByIndex(rowIndex,2).getValue();
var cusName = mygrid_recv.cellByIndex(rowIndex,3).getValue();
var bsno = $("h_bsno").value;
if(window.confirm("您确定要将 应收费用("+feeName+") 提交申请修改")){
var openUrl = "../Shipping/FeeModify.aspx?id="+recvArg[0]+"&oplb="+stroplb+"&type=1&bsno="+bsno+"&handle=1";
window.open (openUrl, "_blank", "height=470, width=900, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-470)/2 + ",Left= "+(screen.width-900)/2);
}
}else if(iCount > 1){
alert("每次只能申请修改一条费用信息");
}else{
alert("未选中要操作的费用项");
}
}else{
alert("委托已退载,费用不能添加");
return;
}
}
//应付费用申请修改
function orderPayModify(){
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
// if(parseInt($("h_payauthority").value) <= 0){
// return;
// }
if(opStatus == 1){
if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){
alert("应收费用未保存,请先将应收费用保存,再提交应付费用-申请修改");
return false;
}
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_pay.getRowsNum();i++){
var checkState = mygrid_pay.cellByIndex(i,0).getValue();
var feeState = mygrid_pay.cellByIndex(i,1).getValue();
var rowID = mygrid_pay.getRowId(i);
if(checkState == 1){
if(!validOperatePower(rowID,2)){
alert("权限不足,请重新选择");
return;
}
if(feeState == "申请修改"){
alert("不能重复申请修改,如要查看申请信息请点-历史申请-查看");
return;
}
if(feeState == "申请删除"){
alert("不能申请删除,如要查看申请信息请点-历史申请-查看");
return;
}
if(feeState == "录入状态"){
alert("录入状态-不能申请修改");
return;
}
if(feeState == "提交审核"){
alert("提交审核-不能申请修改");
return;
}
if(feeState == "结算完毕"){
alert("结算完毕-不能申请修改");
return;
}
if(feeState == "部分结算"){
alert("部分结算-不能申请修改");
return;
}
recvArg.push(rowID);
iCount++;
}
}
if(iCount == 1){
var rowIndex = mygrid_pay.getRowIndex(recvArg[0]);
var statusName = mygrid_pay.cellByIndex(rowIndex,1).getValue();
var feeName = mygrid_pay.cellByIndex(rowIndex,2).getValue();
var cusName = mygrid_pay.cellByIndex(rowIndex,3).getValue();
var bsno = $("h_bsno").value;
if(window.confirm("您确定要将 应付费用("+feeName+") 提交申请修改")){
var openUrl = "../Shipping/FeeModify.aspx?id="+recvArg[0]+"&oplb="+stroplb+"&type=2&bsno="+bsno+"&handle=1";
window.open (openUrl, "_blank", "height=470, width=900, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-470)/2 + ",Left= "+(screen.width-900)/2);
}
}else if(iCount > 1){
alert("每次只能申请修改一条费用信息");
}else{
alert("未选中要操作的费用项");
}
}else{
alert("委托已退载,费用不能添加");
return;
}
}
//应收费用申请删除
function orderRecvDelete(){
var iSuccess = 0;
var iFailure = 0;
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
// if(parseInt($("h_recvauthority").value) <= 0){
// return;
// }
if(opStatus == 1){
if(newFeePayCount > 0 || changeFeePayCount > 0){
alert("应付费用未保存,先保存应付费用再进行应收费用-申请删除操作");
return;
}
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_recv.getRowsNum();i++){
var checkState = mygrid_recv.cellByIndex(i,0).getValue();
var feeState = mygrid_recv.cellByIndex(i,1).getValue();
var rowID = mygrid_recv.getRowId(i);
if(checkState == 1){
if(!validOperatePower(rowID,1)){
alert("权限不足,请重新选择");
return;
}
if(feeState == "录入状态"){
alert("只能提交录入状态的应收费用进行审核");
return;
}
if(feeState == "申请修改"){
alert("申请修改-不能申请删除");
return;
}
recvArg.push(rowID);
iCount++;
}
}
if(iCount == 1){
var rowIndex = mygrid_recv.getRowIndex(recvArg[0]);
var statusName = mygrid_recv.cellByIndex(rowIndex,1).getValue();
var feeName = mygrid_recv.cellByIndex(rowIndex,2).getValue();
var cusName = mygrid_recv.cellByIndex(rowIndex,3).getValue();
if(window.confirm("您确定要将 应收费用("+feeName+") 提交申请删除")){
//打开费用删除页面
var openUrl = "../Shipping/FeeDelete.aspx?id="+recvArg[0]+"&handle=1&oplb="+stroplb+"&type=1";
window.open (openUrl, "_blank", "height=100, width=400, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-100)/2 + ",Left= "+(screen.width-400)/2);
}
}else if(iCount > 1){
alert("每次只能申请删除一条费用信息");
}else{
alert("未选中要操作的费用项");
}
}else{
alert("委托已退载,费用不能添加");
return;
}
}
//应付费用申请删除
function orderPayDelete(){
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
// if(parseInt($("h_payauthority").value) <= 0){
// return;
// }
if(opStatus == 1){
// if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){
// alert("应收费用未保存,请先将应收费用保存,再提交应付费用-申请删除");
// return false;
// }
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_pay.getRowsNum();i++){
var checkState = mygrid_pay.cellByIndex(i,0).getValue();
var feeState = mygrid_pay.cellByIndex(i,1).getValue();
var rowID = mygrid_pay.getRowId(i);
if(checkState == 1){
if(!validOperatePower(rowID,2)){
alert("权限不足,请重新选择");
return;
}
if(feeState == "录入状态"){
alert("只能提交录入状态的应收费用进行审核");
return;
}
if(feeState == "申请修改"){
alert("申请修改-不能申请删除");
return;
}
recvArg.push(rowID);
iCount++;
}
}
if(iCount == 1){
var rowIndex = mygrid_pay.getRowIndex(recvArg[0]);
var statusName = mygrid_pay.cellByIndex(rowIndex,1).getValue();
var feeName = mygrid_pay.cellByIndex(rowIndex,2).getValue();
var cusName = mygrid_pay.cellByIndex(rowIndex,3).getValue();
if(window.confirm("您确定要将 应付费用("+feeName+") 提交申请删除")){
//打开费用删除页面
var openUrl = "../Shipping/FeeDelete.aspx?id="+recvArg[0]+"&handle=1&oplb="+stroplb+"&type=2";
window.open (openUrl, "_blank", "height=100, width=400, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-100)/2 + ",Left= "+(screen.width-400)/2);
}
}else if(iCount > 1){
alert("每次只能申请删除一条费用信息");
}else{
alert("未选中要操作的费用项");
}
}else{
alert("委托已退载,费用不能添加");
return;
}
}
//应收费用历史申请
function applyRecvHistory(){
// if(parseInt($("h_recvauthority").value) <= 0){
// return;
// }
// if(newFeePayCount > 0 || changeFeePayCount > 0){
// alert("应收费用未保存,请先将应收费用保存,再查看历史申请");
// return;
// }
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_recv.getRowsNum();i++){
var checkState = mygrid_recv.cellByIndex(i,0).getValue();
var feeState = mygrid_recv.cellByIndex(i,1).getValue();
var rowID = mygrid_recv.getRowId(i);
if(checkState == 1){
if(!validOperatePower(rowID,1)){
alert("权限不足,请重新选择");
return;
}
recvArg.push(rowID);
iCount++;
}
}
if(iCount == 1){
var rowIndex = mygrid_recv.getRowIndex(recvArg[0]);
var status = mygrid_recv.cellByIndex(rowIndex,1).getValue();
var feeName = mygrid_recv.cellByIndex(rowIndex,2).getValue();
var cusName = mygrid_recv.cellByIndex(rowIndex,3).getValue();
var bsno = $("h_bsno").value;
if(status.trim() == "申请修改" || status.trim() == "驳回申请" || status.trim() == "申请通过"){
//打开费用修改页面
var openUrl = "../Shipping/FeeModify.aspx?id="+recvArg[0]+"&oplb="+stroplb+"&bsno="+bsno+"&handle=2";
window.open (openUrl, "_blank", "height=470, width=900, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-470)/2 + ",Left= "+(screen.width-900)/2);
}else{//查看是否有费用申请历史记录ch_fee_modify(费用申请修改表)
var urlVal = "../auditprocess/AuditService.aspx?handle=existmodify&oplb="+stroplb+"&id="+recvArg[0]+"&val="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
loader = null;
if(parseInt(loadVal) == 1){//打开费用修改页面
var openUrl = "../Shipping/FeeModify.aspx?id="+recvArg[0]+"&oplb="+stroplb+"&bsno="+bsno+"&handle=2";
window.open (openUrl, "_blank", "height=470, width=900, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-470)/2 + ",Left= "+(screen.width-900)/2);
}else{
alert("没有申请历史记录");
}
}
}else if(iCount > 1){
alert("每次只能查看一项费用信息");
}else{
alert("未选中要操作的费用项");
}
}
//应付费用历史申请
function applyPayHistory(){
// if(parseInt($("h_payauthority").value) <= 0){
// return;
// }
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_pay.getRowsNum();i++){
var checkState = mygrid_pay.cellByIndex(i,0).getValue();
var feeState = mygrid_pay.cellByIndex(i,1).getValue();
var rowID = mygrid_pay.getRowId(i);
if(checkState == 1){
if(!validOperatePower(rowID,2)){
alert("权限不足,请重新选择");
return;
}
recvArg.push(rowID);
iCount++;
}
}
if(iCount == 1){
var rowIndex = mygrid_pay.getRowIndex(recvArg[0]);
var status = mygrid_pay.cellByIndex(rowIndex,1).getValue();
var feeName = mygrid_pay.cellByIndex(rowIndex,2).getValue();
var cusName = mygrid_pay.cellByIndex(rowIndex,3).getValue();
var bsno = $("h_bsno").value;
if(status.trim() == "申请修改" || status.trim() == "驳回申请" || status.trim() == "申请通过"){//打开费用修改页面FeeModify.aspx
var openUrl = "../Shipping/FeeModify.aspx?id="+recvArg[0]+"&oplb="+stroplb+"&bsno="+bsno+"&handle=2";
window.open (openUrl, "_blank", "height=470, width=900, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-470)/2 + ",Left= "+(screen.width-900)/2);
}else{//查看是否有费用申请历史记录ch_fee_modify(费用申请修改表)
var urlVal = "../auditprocess/AuditService.aspx?handle=existmodify&oplb="+stroplb+"&id="+recvArg[0]+"&val="+newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
loader = null;
if(parseInt(loadVal) == 1){//打开费用修改页面FeeModify.aspx
var openUrl = "../Shipping/FeeModify.aspx?id="+recvArg[0]+"&oplb="+stroplb+"&bsno="+bsno+"&handle=2";
window.open (openUrl, "_blank", "height=470, width=900, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-470)/2 + ",Left= "+(screen.width-900)/2);
}else{
alert("没有申请历史记录");
}
}
}else if(iCount > 1){
alert("每次只能查看一项费用信息");
}else{
alert("未选中要操作的费用项");
}
}
//刷新grid的Label
function ReShowLabel(gridObj){
var columnCount = gridObj.getColumnsNum();
var rowCount = gridObj.getRowsNum();
if(rowCount > 0){
for(var i = 0;i<rowCount;i++){
for(var j = 0;j<columnCount;j++){
if(j == 2 || j == 3){
var cellCurVal = gridObj.cellByIndex(i,j).getValue();
gridObj.cellByIndex(i,j).setLabel(cellCurVal);
}
}
}
}
}
//刷新grid的Label
function ReShowLabelForEnter(gridObj){
var columnCount = gridObj.getColumnsNum();
var rowCount = gridObj.getRowsNum();
if(rowCount > 0){
for(var i = 0;i<rowCount;i++){
for(var j = 0;j<columnCount;j++){
if(j == 3){
var cellCurVal = gridObj.cellByIndex(i,j).getValue();
gridObj.cellByIndex(i,j).setLabel(cellCurVal);
}
}
}
}
}
//转换为数字
function clearNoNum(valObj)
{
//先把非数字的都替换掉,除了数字和.
valObj = valObj.replace(/[^\d.|-]/g,"");
//必须保证第一个为数字而不是.
valObj = valObj.replace(/^\./g,"");
//保证只有出现一个.而没有多个.
valObj = valObj.replace(/\.{2,}/g,".");
valObj = valObj.replace(/\-{2,}/g,"-");
//保证.只出现一次,而不能出现两次以上
valObj = valObj.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
if(valObj.lastIndexOf("-") > 0){
if(valObj.indexOf("-") == 0){
valObj = "-"+valObj.replace(/-/g,"");
}else{
valObj = valObj.replace(/-/g,"");
}
}
return valObj;
}
//依据费用状态设置对应行的背景颜色
function markStatusColor(gridObj){
var count = gridObj.getRowsNum();
for(var i = 0;i<count;i++){
var status = gridObj.cellByIndex(i,1).getValue();
var rowId = gridObj.getRowId(i);
switch(status){
case "审核通过":
gridObj.setRowColor(rowId,"#7FDF00");
break;
case "提交审核":
case "申请修改":
gridObj.setRowColor(rowId,"#ebf48a");
break;
case "驳回申请":
gridObj.setRowColor(rowId,"#f53939");
break;
case "申请删除":
gridObj.setRowColor(rowId,"#9f9e9e");
break;
case "驳回提交":
gridObj.setRowColor(rowId,"#f53939");
default:
break;
}
}
}
//刷新应收费用
function refreshRecv(){
if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){
if(window.confirm("应收费用未保存,您确定要刷新应收费用列表,刷新后自动放弃未保存内容")){
doInitRecvGrid();
newFeeRecvCount = 0;
changeFeeRecvCount = 0;
}
}else{
doInitRecvGrid();
}
}
//刷新应付费用
function refreshPay(){
if(newFeePayCount > 0 || changeFeePayCount > 0){
if(window.confirm("应付费用未保存,您确定要刷新应付费用列表,刷新后自动放弃未保存内容")){
doInitPayGrid();
newFeePayCount = 0;
changeFeePayCount = 0;
}
}else{
doInitPayGrid();
}
}
//应收费用查看信息
function checkRecvHistory(){
// var iCount = 0;
// var recvArg = new Array();
//
// for(var i=0;i<mygrid_recv.getRowsNum();i++){
// var checkState = mygrid_recv.cellByIndex(i,0).getValue();
// var feeState = mygrid_recv.cellByIndex(i,1).getValue();
// var rowID = mygrid_recv.getRowId(i);
// if(checkState == 1){
// recvArg.push(rowID);
// iCount++;
// }
// }
// if(iCount > 1){
//
// }else{
// alert("未选中要操作的费用项");
// }
var strBSNO = $("h_bsno").value;
var openSet = "height=540, width=890, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-540)/2 + ",Left= "+(screen.width-890)/2
var openType = "_blank";
//打开费用“历史信息查询”页面
var openUrl = "../Shipping/FeeHistory.aspx?bsno="+strBSNO+"&oplb="+stroplb+"&type=1";
window.open (openUrl,openType,openSet);
}
//应付费用查看信息
function checkPayHistory(){
// var iCount = 0;
// var recvArg = new Array();
//
// for(var i=0;i<mygrid_pay.getRowsNum();i++){
// var checkState = mygrid_pay.cellByIndex(i,0).getValue();
// var feeState = mygrid_pay.cellByIndex(i,1).getValue();
// var rowID = mygrid_pay.getRowId(i);
// if(checkState == 1){
// recvArg.push(rowID);
// iCount++;
// }
// }
//
// if(iCount == 1){
// }else{
// alert("未选中要操作的费用项");
// }
var strBSNO = $("h_bsno").value;
var openSet = "height=540, width=890, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-540)/2 + ",Left= "+(screen.width-890)/2
var openType = "_blank";
//打开费用“历史信息查询”页面
var openUrl = "../Shipping/FeeHistory.aspx?bsno="+strBSNO+"&oplb="+stroplb+"&type=2";
window.open (openUrl,openType,openSet);
}
//引入应收费用模板
function importRecvTemplate(){
if(!validOperatePower("",1,"import")){
alert("没有权限操作数据");
return;
}
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
if(opStatus == 1){
if(newFeePayCount > 0 || changeFeePayCount > 0){
alert("应付费用未保存,先保存应付费用,再操作应收费用-引入费用模板");
return;
}
var openSet = "height=700, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top=10,Left= " + (screen.width - 900) / 2;
var openType = "_blank";
//打开应收费用“引入费用模板”页面
var openUrl = "../Shipping/ImportFeeTemplate.aspx?handle=import&oplb="+stroplb+"&type=1";
window.open (openUrl,openType,openSet);
}else{
alert("委托已退载,不能引入费用");
return;
}
}
//打开应付费用模板
function importPayTemplate(){
if(!validOperatePower("",2,"import")){
alert("没有权限操作数据");
return;
}
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
if(opStatus == 1){
if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){
alert("应收费用未保存,先保存应收费用,再操作应付费用-引入费用模板");
return;
}
var openSet = "height=700, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top=10,Left= " + (screen.width - 900) / 2;
var openType = "_blank";
//打开应付费用“引入费用模板”页面
var openUrl = "../Shipping/ImportFeeTemplate.aspx?handle=import&oplb="+stroplb+"&type=2";
window.open (openUrl,openType,openSet);
}else{
alert("委托已退载,不能引入费用");
return;
}
}
//检查浏览器是否是Ie
var isIe=(document.all)?true:false;
//设置select的可见状态
function setSelectState(state){
var objl=document.getElementsByTagName('select');
for(var i=0;i<objl.length;i++)
{
objl[i].style.visibility=state;
}
}
//获得鼠标位置
function mousePosition(ev){
if(ev.pageX || ev.pageY)
{
return {x:ev.pageX, y:ev.pageY};
}
return {
x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,y:ev.clientY + document.body.scrollTop - document.body.clientTop
};
}
//弹出方法消息提示框
function showMessageBox(wTitle,content,pos,wWidth){
closeWindow();
var bWidth=parseInt(document.documentElement.scrollWidth);
var bHeight=parseInt(document.documentElement.scrollHeight);
if(isIe){
setSelectState('hidden');}
var back=document.createElement("div");
back.id="back";
var styleStr="top:0px;left:0px;position:absolute;background:#666;width:"+bWidth+"px;height:"+bHeight+"px;";
styleStr+=(isIe)?"filter:alpha(opacity=0);":"opacity:0;";
back.style.cssText=styleStr;
document.body.appendChild(back);
showBackground(back,50);
var mesW=document.createElement("div");
mesW.id="mesWindow";
mesW.className="mesWindow";
mesW.innerHTML = "<div class='mesWindowTop'><table width='100%' height='100%'><tr><td>"+wTitle+"</td><td style='width:1px;'>"
+ "<input type='button' onclick='closeWindow();' title='关闭窗口' class='close' value='关闭' style='width:60px;'/></td></tr></table></div>"
+ "<div class='mesWindowContent' id='mesWindowContent'>"+content+"</div><div class='mesWindowBottom'></div>";
var v_top=(document.body.clientHeight-mesW.clientHeight)/2;
v_top+=document.documentElement.scrollTop;
styleStr="top:"+(v_top-180)+"px;left:"+(document.body.clientWidth/2-mesW.clientWidth/2)+"px;position:absolute;width:600px;margin-left:-300px;left:50%;z-index:9999;";
mesW.style.cssText=styleStr;
document.body.appendChild(mesW);
var Container = $("dvGain");
Container.attachEvent("onresize",function(){
$("back").style.width = parseInt(document.documentElement.scrollWidth);
$("back").style.height = parseInt(document.documentElement.scrollHeight);
});
}
//让背景渐渐变暗
function showBackground(obj,endInt){
if(isIe){
obj.filters.alpha.opacity+=5;
if(obj.filters.alpha.opacity<endInt){
setTimeout(function(){showBackground(obj,endInt)},5);
}
}else{
var al=parseFloat(obj.style.opacity);al+=0.05;
obj.style.opacity=al;
if(al<(endInt/100)){
setTimeout(function(){showBackground(obj,endInt)},5);}
}
}
//关闭窗口
function closeWindow(){
if(document.getElementById('back')!=null){
document.getElementById('back').parentNode.removeChild(document.getElementById('back'));
}
if(document.getElementById('mesWindow')!=null){
document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));
}
if(isIe){
setSelectState('');
}
}
function print_recv() {
var strBSNO = "";
strBSNO = $("h_bsno").value;
if (strBSNO == "") {
return;
}
if (!validOperatePower("", 1, "print")) {
alert("没有权限");
return;
}
//应收GID
$("h_checked").value = mygrid_recv.getCheckedRows(0); //所有选中的grid的id编号
if ($("h_checked").value.trim() == "") {
$("h_checked").value = mygrid_recv.getAllRowIds(); //所有的grid的id编号
}
//
printMessageBox(event, 1);
}
function print_pay() {
var strBSNO = "";
strBSNO = $("h_bsno").value;
if (strBSNO == "") {
return;
}
if (!validOperatePower("", 2, "print")) {
alert("没有权限");
return;
}
//应付GID
$("h_checked").value = mygrid_pay.getCheckedRows(0); //所有选中的grid的id编号
if ($("h_checked").value.trim() == "") {
$("h_checked").value = mygrid_pay.getAllRowIds(); //所有的grid的id编号
}
//
printMessageBox(event, 2);
}
//测试弹出
function printMessageBox(ev,type)
{
var checked = $("h_checked").value.trim();
var selectCustomerOptions = "";
var feeNameArg = new Array();
var checkedArg = new Array();
checkedArg = checked.toString().trim().split(","); //将各参数分离形成参数数组
if(type == 1){
if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){
alert("应收费用未保存,请先保存之后再打印");
return;
}
for (var j = 0; j < checkedArg.length; j++) {
var rowIndex = mygrid_recv.getRowIndex(checkedArg[j]);
var customerName = mygrid_recv.cellByIndex(rowIndex, 3).getValue().trim();
var iCount = 0;
for(var i=0;i<feeNameArg.length;i++){
if(feeNameArg[i] == customerName){
iCount++;
break;
}
}
if(iCount == 0){
feeNameArg.push(customerName);
}
}
}else{
if(newFeePayCount > 0 || changeFeePayCount > 0){
alert("应付费用未保存,请先保存之后再打印");
return;
}
for (var j = 0; j < checkedArg.length; j++) {
var rowIndex = mygrid_pay.getRowIndex(checkedArg[j]);
var customerName = mygrid_pay.cellByIndex(rowIndex, 3).getValue().trim();
var iCount = 0;
for(var i=0;i<feeNameArg.length;i++){
if(feeNameArg[i] == customerName){
iCount++;
break;
}
}
if(iCount == 0){
feeNameArg.push(customerName);
}
}
}
for(var k=0;k<feeNameArg.length;k++){
selectCustomerOptions += "<option value=\""+feeNameArg[k]+"\">"+feeNameArg[k]+"</options>";
}
var objPos = mousePosition(ev);
messContent = "<div style=\"padding:20px 0 20px 0;text-align:center\">"
+"<div style=\"float:left;width:100%\"><select id=\"reportType\" onchange=\"onReportTypeChange('reportType')\"><option value=\"1\">打印应收费用报表</option><option value=\"2\">打印应付费用报表</option> "
+ "<option value=\"3\">打印利润报表</option><option value=\"4\">打印海运利润报表</option><option value=\"5\">打印仓储利润报表</option></select></div> "
// +"<div style=\"float:left;width:100%;text-align:center;display:none;\" id=\"dvGainCheck\"><div style=\"float:left\"><input type=\"radio\" id=\"ra_recv\" name=\"gain\" title=\"打印应收利润\"/>应收利润</div> "
// +"<div style=\"float:left\"><input type=\"radio\" id=\"ra_recv\" name=\"gain\" title=\"打印应付利润\"/>应付利润</div><div style=\"float:left\"> "
// +"<input type=\"radio\" id=\"ra_recv\" name=\"gain\" title=\"打印利润\"/>利润</div></div> "
+"<div style=\"float:left;width:100%;padding-left:80px;\"> "
+"<table style=\"width:350px;\"><tr><td><select id=\"sel_customer\" multiple style=\"width:150px; height:60px;\">"+selectCustomerOptions+"</select></td><td> "
+"<table style=\"height:60px; width:20px;\"><tr><td height=\"20px\"><div id=\"dvRemove\"><img src=\"../images/icons/edit_left.gif\" "
+"onmouseover=\"mouseMoveImg(this,1)\" onmouseout=\"mouseMoveImg(this,1)\" title=\"移除\" onclick=\"removeCustomer()\"/></div></td> "
+"</tr><tr><td height=\"20px\"><div id=\"dvAdd\"><img src=\"../images/icons/edit_right.gif\" onmouseover=\"mouseMoveImg(this,2)\" "
+"onmouseout=\"mouseMoveImg(this,2)\" title=\"添加\" onclick=\"addCustomer()\"/></div></td> "
+"</tr></table></td><td><select id=\"sel_print\" multiple style=\"width:150px; height:60px;\" class=\"select\"></select></td></tr></table></div>"
+"<input type=\"button\" id=\"btn_print_report\" value=\"打印\" class=\"btn\" onclick=\"printReport()\"/></div> ";
showMessageBox('费用打印',messContent,objPos,350);
}
//打印报表
function printReport(){
var strBSNO = "";
var typeName = "";
strBSNO = $("h_bsno").value;
var printUrl = "";
var companyID = "";
var typeName = "SEAOPFEE";
var dbSourceID = "";
var userID = "";
var selectObj = $("reportType");
var selVal = parseInt(selectObj.options[selectObj.selectedIndex].value);
var url = "";
var searchCustomer = "";
var selectedObj = $("sel_print");
//
for(var j=0;j<selectedObj.options.length;j++){
if(j == selectedObj.options.length - 1){
searchCustomer += "'"+selectedObj.options[j].value+"'";
}else{
searchCustomer += "'"+selectedObj.options[j].value+"',";
}
}
//应收应付GID
var checked = $("h_checked").value.trim();
var checkedArg = new Array();
checkedArg = checked.toString().trim().split(","); //将各参数分离形成参数数组
checked = "";
for (var j = 0; j < checkedArg.length; j++) {
if (j == checkedArg.length - 1) {
checked += "'" + checkedArg[j] + "'";
} else {
checked += "'" + checkedArg[j] + "',";
}
}
//
if(selVal == 1){//打印委托op_seai应收费用报表返回JSON对象
url = "../Reports/ReportService.aspx?handle=printseaopfee&bsno=" + strBSNO + "&oplb=" + stroplb + "&search=" + escape(searchCustomer) + "&feegids=" + checked + "&feetype=1&val=" + newGuid();
typeName = "SEAOPFEEDR";
}
else if(selVal == 2){//打印委托op_seai应付费用报表返回JSON对象
url = "../Reports/ReportService.aspx?handle=printseaopfee&bsno=" + strBSNO + "&oplb=" + stroplb + "&search=" + escape(searchCustomer) + "&feegids=" + checked + "&feetype=2&val=" + newGuid();
typeName = "SEAOPFEECR";
}
else if(selVal == 3){//打印委托op_seai利润报表返回JSON对象
typeName = "SEAOPGAIN";
url = "../Reports/ReportService.aspx?handle=printseaopgain&oplb="+stroplb+"&bsno="+strBSNO+"&val="+newGuid();
}
else if(selVal == 4){//打印海运利润报表
typeName = "SEAOPGAIN";
var gaintype = "sea";
url = "../Reports/ReportService.aspx?handle=printseaopgain&oplb=" + stroplb + "&bsno=" + strBSNO + "&gaintype=" + gaintype + "&val=" + newGuid();
}
else if(selVal == 5){//打印仓储利润报表
typeName = "SEAOPGAIN";
var gaintype = "wms";
url = "../Reports/ReportService.aspx?handle=printseaopgain&oplb=" + stroplb + "&bsno=" + strBSNO + "&gaintype=" + gaintype + "&val=" + newGuid();
}
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+"&oplb="+stroplb+"&uid="+userID;//alert(printUrl);
window.location.href = window.location.href; //本页面跳转
location.href = printUrl; //跳转到打印页面
}
}else{
alert("没有要打印的报表");
return;
}
}
//打印应收费用报表
function onReportTypeChange(id){
var selectObj = $(id);
var selVal = parseInt(selectObj.options[selectObj.selectedIndex].value);
if(selVal == 3){
$("sel_customer").disabled = 1;
$("sel_print").disabled = 1;
$("dvRemove").disabled = 1;
$("dvAdd").disabled = 1;
}
pageShowCount = selVal;
}
//鼠标移过图标变化
function mouseMoveImg(obj,type){
var imgUrl = obj.src;
var urlArg = imgUrl.split("/");
if(type == 1){
if(urlArg[urlArg.length-1] == "edit_left.gif"){
var newUrl = "";
for(var i=0;i<urlArg.length;i++){
if(i == urlArg.length - 1){
newUrl += "edit_lefthover.gif";
}else{
newUrl += urlArg[i]+"/";
}
}
obj.src = newUrl;
}else{
var newUrl = "";
for(var i=0;i<urlArg.length;i++){
if(i == urlArg.length - 1){
newUrl += "edit_left.gif";
}else{
newUrl += urlArg[i]+"/";
}
}
obj.src = newUrl;
}
}else{
if(urlArg[urlArg.length-1] == "edit_right.gif"){
var newUrl = "";
for(var i=0;i<urlArg.length;i++){
if(i == urlArg.length - 1){
newUrl += "edit_righthover.gif";
}else{
newUrl += urlArg[i]+"/";
}
}
obj.src = newUrl;
}else{
var newUrl = "";
for(var i=0;i<urlArg.length;i++){
if(i == urlArg.length - 1){
newUrl += "edit_right.gif";
}else{
newUrl += urlArg[i]+"/";
}
}
obj.src = newUrl;
}
}
}
//移除结算单位
function removeCustomer(){
var selectedObj = $("sel_print");
var selectedCount = selectedObj.options.length;
for(var j=0;j<selectedCount;j++){
if(selectedObj[j].selected){
selectedObj.options.remove(j);
if(selectedCount == 1){
break;
}
j=-1;
continue;
}
}
}
//添加结算单位
function addCustomer(){
var customerObj = $("sel_customer");
var selectedObj = $("sel_print");
for(var i=0;i<customerObj.options.length;i++){
if(customerObj[i].selected){
var sameCount = 0;
var selectedCount = selectedObj.options.length;
for(var j=0;j<selectedCount;j++){
if(selectedObj.options[j].value.trim() == customerObj.options[i].value.trim()){
sameCount++;
break;
}
}
if(sameCount == 0){
var varItem = new Option(customerObj.options[i].value.trim(), customerObj.options[i].value.trim());
selectedObj.options.add(varItem);
}
}
}
}
var h_UnitType="";
function getUnitType(typeID){//获取委托op_seai费用计费标准信息
var strBSNO = "";
strBSNO = $("h_bsno").value;
//获取委托op_seai费用计费标准信息返回JSON数据
var url = "";
url = "../FeeCodes/FeeUnitService.aspx?handle=quantity&oplb="+stroplb+"&bsno="+strBSNO+"&unittype="+typeID+"&type=1&val="+newGuid();
var loader = dhtmlxAjax.getSync(url);
quantityVal = loader.xmlDoc.responseText;
quantityObj = null;
quantityObj = eval('(' + quantityVal + ')');
return quantityObj;
}
function getTypeNum(typeName){//将汉字标识的计费标准转换为数字标识
var unitType = 0;
switch(typeName){
case "单票"://1
unitType = 1;
break;
case "重量": //2毛重
unitType = 2;
break;
case "尺码"://3
unitType = 3;
break;
case "计费吨"://4
unitType = 4;
break;
case "TEU"://5
unitType = 5;
break;
// case "净重"://6
// unitType = 6;
// break;
case "总价"://7
unitType = 7;
break;
case "计价重量"://8
unitType = 8;
break;
case "箱型":
unitType = 9;//
break;
case "CBM":
unitType = 10; //
break;
case "BILL":
unitType = 11; //
break;
default://默认是根据CTN型号获取
unitType = 0;//
break;
}
return unitType;
}
function getTypeNameQuantity(typeName,zlvalue){//将汉字标识的计费标准转换为数字标识
var unitType = 0;
switch(typeName){
case "单票"://1
unitType = 1;
break;
case "重量": //2毛重
unitType = 2;
break;
case "尺码"://3
unitType = 3;
break;
case "计费吨"://4
unitType = 4;
break;
case "TEU"://5
unitType = 5;
break;
// case "净重"://6
// unitType = 6;
// break;
case "总价"://7
unitType = 7;
break;
case "计价重量"://8
unitType = 8;
break;
case "箱型":
unitType = 9;//
break;
case "CBM":
unitType = 10;//
break;
case "BILL":
unitType = 11;//
break;
default://默认是根据CTN型号获取
unitType = 0;//
break;
}
var strBSNO = "";
strBSNO = $("h_bsno").value;
var url = "";
var loader="" ;
quantityVal="";
quantityObj = null;
if(RowOutBsno=="" || RowOutBsno==null ){
//获取委托op_seai费用计费标准信息返回JSON数据
if(unitType == 0){
url = "../FeeCodes/FeeUnitService.aspx?handle=quantity&oplb="+stroplb+"&bsno="+strBSNO+"&unittype="+unitType+"&type=1&ctn="+typeName+"&val="+newGuid();
}else{
url = "../FeeCodes/FeeUnitService.aspx?handle=quantity&oplb="+stroplb+"&bsno="+strBSNO+"&unittype="+unitType+"&type=1&val="+newGuid();
}
loader = dhtmlxAjax.getSync(url);
quantityVal = loader.xmlDoc.responseText;
quantityObj = null;
quantityObj = eval('(' + quantityVal + ')');
}
else{
typeName = "重量"; //毛重
var cacheBuffer = "";
cacheBuffer += "{";
cacheBuffer += "\"value\":\""+zlvalue+"\",";
cacheBuffer += "\"name\":\""+typeName+"\"";
cacheBuffer += "}";
var result = "";
result += "{\"quantity\":[";
result += cacheBuffer;
result += "]}";
quantityObj = eval('(' + result + ')');
}
return quantityObj;
}
var h_Debit="";
function getDebitType(typeID){//获取委托信息(op_seai)默认收费客户信息
var strBSNO = "";
strBSNO = $("h_bsno").value;
//获取委托信息(op_seai)默认收费客户信息返回JSON数据源
var url = "";
url = "../FeeCodes/FeeDebitService.aspx?handle=debit&oplb="+stroplb+"&bsno="+strBSNO+"&debittype="+typeID+"&type=1&val="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var debitVal = loader.xmlDoc.responseText;
var debitObj = null;
debitObj = eval('(' + debitVal + ')');
return debitObj;
}
var h_Currency="";
function setCurrencyCombo(obj){//返回币别code_currency汇率JSON字符串
var url = "../FeeCodes/CurrencyAdapter.aspx?handle=drate&oplb="+stroplb+"&uid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var currencyInfo = loader.xmlDoc.responseText;
var jsonCacheObj = eval('(' + currencyInfo + ')');
if(jsonCacheObj.drate.length > 0){
for(var i = 0;i < jsonCacheObj.drate.length;i++){
obj.put(jsonCacheObj.drate[i].code,jsonCacheObj.drate[i].code);
}
}
}
var h_Feename="";
function setFeeNameCombo(obj){
var feeCodeInfo = "";
if($("h_feecache").value.trim() != ""){
feeCodeInfo = $("h_feecache").value.trim();
}else{//返回code_fee费用信息的JSON字符串
var url = "../FeeCodes/FeeCodeService.aspx?handle=feecode&oplb="+stroplb+"&uid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
feeCodeInfo = loader.xmlDoc.responseText;
}
var jsonCacheObj = eval('(' + feeCodeInfo + ')');
if(jsonCacheObj.feecode.length > 0){
for (var i = 0; i < jsonCacheObj.feecode.length; i++) {
obj.put(jsonCacheObj.feecode[i].name, jsonCacheObj.feecode[i].code.toString().toLowerCase());
}
}
}
var h_Unit="";
function setUnitCombo(obj){//初始化计费标准Combo
obj.put("单票","单票");
obj.put("重量", "重量"); //毛重
//obj.put("净重", "净重");
obj.put("尺码","尺码");
obj.put("TEU","TEU");
obj.put("箱型", "箱型");
obj.put("CBM", "CBM");
obj.put("BILL", "BILL");
var feeCodeCtnObj = null;
var bsno = $("h_bsno").value;
//根据BSNO获取海运出口委托集装箱(op_ctn)信息返回JSON数据源
var url = "../FeeCodes/FeeCodeCtnService.aspx?handle=getctnunit&oplb="+stroplb+"&bsno="+bsno+"&uid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var ctnInfo = loader.xmlDoc.responseText;
if(ctnInfo.trim() != ""){
feeCodeCtnObj = eval('(' + ctnInfo + ')');
if(feeCodeCtnObj.ctns.length > 0){
for(var i=0;i<feeCodeCtnObj.ctns.length;i++){
if(feeCodeCtnObj.ctns[i].name.trim() != ""){
obj.put(feeCodeCtnObj.ctns[i].name,feeCodeCtnObj.ctns[i].name);
}
}
}
}
}
var h_Frt="";
function setFrtCombo(obj){//初始化FRTCombo
obj.put("PP","PP");
obj.put("CC","CC");
}
function copyAddRecv(){//应收费用复制添加
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_recv.getRowsNum();i++){
var checkState = mygrid_recv.cellByIndex(i,0).getValue();
var feeState = mygrid_recv.cellByIndex(i,1).getValue();
var rowID = mygrid_recv.getRowId(i);
if(checkState == 1){
if(!validOperatePower(rowID,1)){
alert("权限不足,请重新选择");
return;
}
recvArg.push(rowID);
iCount++;
}
}
if(iCount > 0){
var delCount = 0;
if(recvArg.length > 0){
while(delCount < recvArg.length){
var newId = newGuid();
//获取插入新纪录位置
var rowCount = mygrid_recv.getRowsNum();
var rowIndex = mygrid_recv.getRowIndex(recvArg[delCount]);
//var feeStatus = mygrid_recv.cellByIndex(rowIndex,1).getValue();
var feeName = mygrid_recv.cellByIndex(rowIndex,2).getValue();
var custName = mygrid_recv.cellByIndex(rowIndex,3).getValue();
var unit = mygrid_recv.cellByIndex(rowIndex,4).getValue();
var unitprice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue())));
var quantity = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,6).getValue())));
var comm = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,7).getValue())));
var amount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,8).getValue())));
var currency = mygrid_recv.cellByIndex(rowIndex,9).getValue();
var rate = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,10).getValue())));
var frt = mygrid_recv.cellByIndex(rowIndex,11).getValue();
var remark = mygrid_recv.cellByIndex(rowIndex,12).getValue();
var isadvance = mygrid_recv.cellByIndex(rowIndex,13).getValue();
var linenum = rowCount + 1;
mygrid_recv.addRow(newId, [0, "录入状态", feeName, custName, unit, unitprice, quantity, comm, amount, currency, rate, frt, remark, isadvance, 0, 0, '', '', '', '', wmsoutbsno, linenum], rowCount);
delCount++;
var combo_currency;
combo_currency = mygrid_recv.getCustomCombo(newId,9);
setCurrencyCombo(combo_currency);
var combo_feename;
combo_feename = mygrid_recv.getCustomCombo(newId,2);
setFeeNameCombo(combo_feename);
var combo_cust;
combo_cust = mygrid_recv.getCustomCombo(newId,3);
setCustomerCombo(combo_cust,newId);
var combo_unit;
combo_unit = mygrid_recv.getCustomCombo(newId,4);
setUnitCombo(combo_unit);
var combo_frt;
combo_frt = mygrid_recv.getCustomCombo(newId,11);
setFrtCombo(combo_frt);
}
totalDynamicFeeGain();
}
}else{
alert("未选中要操作的费用项");
}
// //查看是否有被选中的费用项
// if(selGroup.length > 0){
// for(var i=0;i<selGroup.length;i++){
// var selectedRowID = selGroup[i];
// var newId = newGuid();
// //获取插入新纪录位置
// var rowCount = mygrid_recv.getRowsNum();
// var rowIndex = mygrid_recv.getRowIndex(selectedRowID);
// var feeName = mygrid_recv.cellByIndex(rowIndex,1).getValue();
// var custName = mygrid_recv.cellByIndex(rowIndex,2).getValue();
// var unit = mygrid_recv.cellByIndex(rowIndex,3).getValue();
// var unitprice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,4).getValue())));
// var quantity = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue())));
// var comm = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,6).getValue())));
// var amount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,7).getValue())));
// var currency = mygrid_recv.cellByIndex(rowIndex,8).getValue();
// var rate = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,9).getValue())));
// var frt = mygrid_recv.cellByIndex(rowIndex,10).getValue();
// var remark = mygrid_recv.cellByIndex(rowIndex,11).getValue();
// var isadvance = mygrid_recv.cellByIndex(rowIndex,12).getValue();
//
// mygrid_recv.addRow(newId,[0,"录入状态",feeName,custName,unit,unitprice,quantity,comm,amount,currency,rate,frt,remark,isadvance,'0',wmsoutbsno],rowCount);
//
// mygrid_recv.clearSelection();
//
// var rId = mygrid_recv.getRowId(rowCount-1);
// var combo_name;
// var combo_customer;
// var combo_unit;
// var combo_currency;
// var combo_frt;
//
// combo_name = mygrid_recv.getCustomCombo(rId,1);
// combo_customer = mygrid_recv.getCustomCombo(rId,2);
// combo_unit = mygrid_recv.getCustomCombo(rId,3);
// combo_currency = mygrid_recv.getCustomCombo(rId,8);
// combo_frt = mygrid_recv.getCustomCombo(rId,10);
//
// //重新加载应收费用名称
// setComboByArray(mygrid_recv,combo_name,newId,1);
// //重新加载结算单位
// setComboByArray(mygrid_recv,combo_customer,newId,2);
// //重新加载计费标准
// setComboByArray(mygrid_recv,combo_unit,newId,3);
// //重新加载币别
// setComboByArray(mygrid_recv,combo_currency,newId,8);
// //重新加载FRT
// setComboByArray(mygrid_recv,combo_frt,newId,10);
//
// newFeeRecvCount++;
// }
// }else{
// alert("没有选择要复制的应收费用信息");
// }
}
//应付费用复制添加
function copyAddPay(){
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_pay.getRowsNum();i++){
var checkState = mygrid_pay.cellByIndex(i,0).getValue();
var feeState = mygrid_pay.cellByIndex(i,1).getValue();
var rowID = mygrid_pay.getRowId(i);
if(checkState == 1){
if(!validOperatePower(rowID,2)){
alert("权限不足,请重新选择");
return;
}
recvArg.push(rowID);
iCount++;
}
}
if(iCount > 0){
var delCount = 0;
if(recvArg.length > 0){
while(delCount < recvArg.length){
var newId = newGuid();
//获取插入新纪录位置
var rowCount = mygrid_pay.getRowsNum();
var rowIndex = mygrid_pay.getRowIndex(recvArg[delCount]);
//var feeStatus = mygrid_recv.cellByIndex(rowIndex,1).getValue();
var feeName = mygrid_pay.cellByIndex(rowIndex,2).getValue();
var custName = mygrid_pay.cellByIndex(rowIndex,3).getValue();
var unit = mygrid_pay.cellByIndex(rowIndex,4).getValue();
var unitprice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,5).getValue())));
var quantity = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,6).getValue())));
var comm = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,7).getValue())));
var amount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,8).getValue())));
var currency = mygrid_pay.cellByIndex(rowIndex,9).getValue();
var rate = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,10).getValue())));
var frt = mygrid_pay.cellByIndex(rowIndex,11).getValue();
var remark = mygrid_pay.cellByIndex(rowIndex,12).getValue();
var isadvance = mygrid_pay.cellByIndex(rowIndex,13).getValue();
var linenum = rowCount + 1;
mygrid_pay.addRow(newId, [0, "录入状态", feeName, custName, unit, unitprice, quantity, comm, amount, currency, rate, frt, remark, isadvance, 0, 0, '', '', '', '', wmsoutbsno, linenum], rowCount);
delCount++;
}
totalDynamicFeeGain();
}
}else{
alert("未选中要操作的费用项");
}
}
function checkAll(id){//全选
if(id == "recv"){
for(var i=0;i<mygrid_recv.getRowsNum();i++){
var rId = mygrid_recv.getRowId(i);
if($("ck_all_recv").checked){
if(validOperatePower(rId,1)){
mygrid_recv.cellByIndex(i,0).setValue(1)
}
}else{
mygrid_recv.cellByIndex(i,0).setValue(0)
}
}
}else if(id == "pay"){
for(var i=0;i<mygrid_pay.getRowsNum();i++){
var rId = mygrid_pay.getRowId(i);
if($("ck_all_pay").checked){
if(validOperatePower(rId,2)){
mygrid_pay.cellByIndex(i,0).setValue(1)
}
}else{
mygrid_pay.cellByIndex(i,0).setValue(0)
}
}
}
}
//获取利润信息
function getFeeProfit(strBSNO){
if(strBSNO.trim() != ""){//根据委托表op_seai.BSNO读取费用利润信息fee_gain返回json数据
var urlVal = "../AuditProcess/FeeAuditGridSource.aspx?type=4&oplb="+stroplb+"&bsno="+strBSNO+"&val="+newGuid();
var loader = "";
loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var jsonProfitObj = loadVal;
if(IsNum(jsonProfitObj)){
jsonPageObj = null;
$("dvRecvRMBVal").innerHTML = "";
$("dvPayRMBVal").innerHTML = "";
$("dvRMBProfitVal").innerHTML = "";
$("dvUSRecvVal").innerHTML = "";
$("dvUSPayVal").innerHTML = "";
$("dvUSProfitVal").innerHTML = "";
$("dvOtherCurrencyRecvVal").innerHTML = "";
$("dvOtherCurrencyPayVal").innerHTML = "";
$("dvOtherCurrencyProfitVal").innerHTML = "";
$("dvRecvTotalVal").innerHTML = "";
$("dvPaySumVal").innerHTML = "";
$("dvProfitTotalVal").innerHTML = "";
$("dvProfitRateVal").innerHTML = "";
}else{
//if(parseInt($("h_recvauthority").value) <= 0 || parseInt($("h_payauthority").value) <= 0){
if( !validOperatePower("",1,"gain") || !validOperatePower("",2,"gain")){
$("dvRecvRMBVal").innerHTML = "0";
$("dvPayRMBVal").innerHTML = "0";
$("dvRMBProfitVal").innerHTML = "0";
$("dvUSRecvVal").innerHTML = "0";
$("dvUSPayVal").innerHTML = "0";
$("dvUSProfitVal").innerHTML = "0";
$("dvOtherCurrencyRecvVal").innerHTML = "0";
$("dvOtherCurrencyPayVal").innerHTML = "0";
$("dvOtherCurrencyProfitVal").innerHTML = "0";
$("dvRecvTotalVal").innerHTML = "0";
$("dvPaySumVal").innerHTML = "0";
$("dvProfitTotalVal").innerHTML = "0";
$("dvProfitRateVal").innerHTML = "0";
}else{
jsonProfitObj = eval('(' + loadVal + ')');
$("dvRecvRMBVal").innerHTML = jsonProfitObj.columns[0].rmbdr;
$("dvPayRMBVal").innerHTML = jsonProfitObj.columns[0].rmbcr;
$("dvRMBProfitVal").innerHTML = jsonProfitObj.columns[0].rmbprofit;
$("dvUSRecvVal").innerHTML = jsonProfitObj.columns[0].usddr;
$("dvUSPayVal").innerHTML = jsonProfitObj.columns[0].usdcr;
$("dvUSProfitVal").innerHTML = jsonProfitObj.columns[0].usdprofit;
$("dvOtherCurrencyRecvVal").innerHTML = jsonProfitObj.columns[0].otdr;
$("dvOtherCurrencyPayVal").innerHTML = jsonProfitObj.columns[0].otcr;
$("dvOtherCurrencyProfitVal").innerHTML = jsonProfitObj.columns[0].otprofit;
$("dvRecvTotalVal").innerHTML = jsonProfitObj.columns[0].drttl;
$("dvPaySumVal").innerHTML = jsonProfitObj.columns[0].crttl;
$("dvProfitTotalVal").innerHTML = jsonProfitObj.columns[0].ttlprofit;
$("dvProfitRateVal").innerHTML = jsonProfitObj.columns[0].profitrate;
}
}
}else{
$("dvRecvRMBVal").innerHTML = "";
$("dvPayRMBVal").innerHTML = "";
$("dvRMBProfitVal").innerHTML = "";
$("dvUSRecvVal").innerHTML = "";
$("dvUSPayVal").innerHTML = "";
$("dvUSProfitVal").innerHTML = "";
$("dvOtherCurrencyRecvVal").innerHTML = "";
$("dvOtherCurrencyPayVal").innerHTML = "";
$("dvOtherCurrencyProfitVal").innerHTML = "";
$("dvRecvTotalVal").innerHTML = "";
$("dvPaySumVal").innerHTML = "";
$("dvProfitTotalVal").innerHTML = "";
$("dvProfitRateVal").innerHTML = "";
}
}
function enableAction(){//屏蔽onclick事件
if($("h_enable").value == "0"){
//recv
$("btn_recvadd").onclick = clickNull;
//$("btn_recvadd").style.display = "none";
// $("btn_recvcopy").onclick = clickNull;
//$("btn_recvcopy").style.display = "none";
$("btn_recvsave").onclick = clickNull;
// $("btn_recvsave").style.display = "none";
$("btn_recvdel").onclick = clickNull;
// $("btn_recvdel").style.display = "none";
$("btn_recvcover").onclick = clickNull;
//$("btn_recvcover").style.display = "none";
$("btn_recvrefresh").onclick = clickNull;
//$("btn_recvrefresh").style.display = "none";
//打印不屏蔽
//$("btn_recvprint").onclick = clickNull;
//$("btn_recvprint").style.display = "none";
$("btn_recvaudit").onclick = clickNull;
//$("btn_recvaudit").style.display = "none";
$("btn_recvmodify").onclick = clickNull;
//$("btn_recvmodify").style.display = "none";
$("btn_recvorderdel").onclick = clickNull;
//$("btn_recvorderdel").style.display = "none";
// $("btn_recvimport").onclick = clickNull;
// $("btn_recvimport").style.display = "none";
//pay
$("btn_payadd").onclick = clickNull;
//$("btn_payadd").style.display = "none";
// $("btn_paycopy").onclick = clickNull;
// $("btn_paycopy").style.display = "none";
$("btn_paysave").onclick = clickNull;
// $("btn_paysave").style.display = "none";
$("btn_paydel").onclick = clickNull;
//$("btn_paydel").style.display = "none";
$("btn_paycover").onclick = clickNull;
//$("btn_paycover").style.display = "none";
$("btn_payrefresh").onclick = clickNull;
//$("btn_payrefresh").style.display = "none";
//打印不屏蔽
//$("btn_payprint").onclick = clickNull;
//$("btn_payprint").style.display = "none";
$("btn_payaudit").onclick = clickNull;
//$("btn_payaudit").style.display = "none";
$("btn_paymodify").onclick = clickNull;
//$("btn_paymodify").style.display = "none";
$("btn_payorderdel").onclick = clickNull;
//$("btn_payorderdel").style.display = "none";
//$("btn_payimport").onclick = clickNull;
//$("btn_payimport").style.display = "none";
}
}
function validOperatePower(feeid,feetype,opname){//获取用户的模块权限信息
var url = "";
var tempOpName = "";
if("undefined" != typeof opname){
tempOpName = opname;
}else{
tempOpName = "";
}
var bsno = $("h_bsno").value;
//获取用户的模块权限信息返回UserAuthorityRangeEntity
url = "../Shipping/FeeService.aspx?handle=validateop&oplb="+stroplb+"&gid="+feeid+"&feetype="+feetype+"&opname="+tempOpName+"&bsno="+bsno+"&uid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var validState = loader.xmlDoc.responseText;
if(validState > 0){
return true;
}else{
return false;
}
}
function initDownFeeName(){//返回code_fee费用信息的JSON字符串
var url = "../FeeCodes/FeeCodeService.aspx?handle=feecode&oplb="+stroplb+"&uid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var feeCodeInfo = loader.xmlDoc.responseText;
//var jsonCacheObj = eval('(' + feeCodeInfo + ')');
if($("h_feecache").value.trim() == ""){
$("h_feecache").value = feeCodeInfo;
}
var url = "../FeeCodes/CRMClientInfo.aspx?handle=client&oplb="+stroplb+"&uid="+newGuid();//返回info_client结算单位JSON字符串
var loader = dhtmlxAjax.getSync(url);
var customerInfo = loader.xmlDoc.responseText;
if($("h_custcache").value.trim() == ""){
$("h_custcache").value = customerInfo;
}
// if(jsonCacheObj.feecode.length > 0){
// for(var i = 0;i < jsonCacheObj.feecode.length;i++){
// obj.put(jsonCacheObj.feecode[i].name,jsonCacheObj.feecode[i].code);
// }
// }
}
//function initLoading(){
// $("progressBar").style.display = "";
//}
//function finishLoading(){
// $("progressBar").style.display = "none";
//}
function initMenu(){//初始化菜单
initRecvMenu();
initPayMenu();
}
function initRecvMenu(){//初始化应收费用菜单“引入费用”
// recv_menu = new dhtmlXMenuObject("recvMenuObj");
recv_menu=new dhtmlXMenuObject("recvMenuObj");
recv_menu.setIconsPath("../images/");
recv_menu.addNewSibling(null, "master", "引入费用");
recv_menu.addNewChild("master", 0, "history", "历史引入", false);
recv_menu.addNewChild("master", 1, "establishpay", "生成应付", false);
recv_menu.addNewChild("master", 1, "template", "引入费用模板", false);
recv_menu.addNewChild("establishpay", 1, "importpayselect", "所选生成", false);
recv_menu.addNewChild("establishpay", 1, "importpayvall", "所有生成", false);
if($("h_enable").value == "0"){
return;
}
recv_menu.attachEvent("onClick", function(id, zoneId, casState){
switch(id){
case "history":
importRecvHistory();
break;
case "establishpay":
break;
case "template":
importRecvTemplate();
break;
case "importpayselect":
establishPay(1);
break;
case "importpayvall":
establishPay(2);
break;
}
});
}
function initPayMenu(){//初始化应付费用菜单“引入费用”
pay_menu = new dhtmlXMenuObject("payMenuObj");
pay_menu.setIconsPath("../images/");
pay_menu.addNewSibling(null, "master", "引入费用");
pay_menu.addNewChild("master", 0, "history", "历史引入", false);
pay_menu.addNewChild("master", 1, "establishrecv", "生成应收", false);
pay_menu.addNewChild("master", 1, "template", "引入费用模板", false);
pay_menu.addNewChild("establishrecv", 1, "importrecvselect", "所选生成", false);
pay_menu.addNewChild("establishrecv", 1, "importrecvall", "所有生成", false);
if($("h_enable").value == "0"){
return;
}
pay_menu.attachEvent("onClick", function(id, zoneId, casState){
switch(id){
case "history":
importPayHistory();
break;
case "establishpay":
break;
case "template":
importPayTemplate();
break;
case "importrecvselect":
establishRecv(1);
break;
case "importrecvall":
establishRecv(2);
break;
}
});
}
function equalInput(type){
if(type == 1){
}else if(type == 2){
}
}
function importRecvHistory(){//应收费用菜单“历史引入”
if(!validOperatePower("",1,"import")){
alert("没有权限操作数据");
return;
}
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
if(opStatus == 1){
if(newFeePayCount > 0 || changeFeePayCount > 0){
alert("应付费用未保存,先保存应付费用,再操作应收费用-引入历史");
return;
}
var openSet = "height=600, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-600)/2 + ",Left= "+(screen.width-900)/2
var openType = "_blank";
//打开应收费用“历史引入”页面
var openUrl = "../Shipping/ImportFeeHistory.aspx?handle=import&oplb="+stroplb+"&historytype=1";
window.open (openUrl,openType,openSet);
}else{
alert("委托已退载,不能引入费用");
return;
}
}
function importPayHistory(){//应付费用菜单“历史引入”
if(!validOperatePower("",2,"import")){
alert("没有权限操作数据");
return;
}
var bsno = $("h_bsno").value;
if(bsno == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();;
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
var validStatusObj = eval('(' + loadVal + ')');
var opStatus = 0;
var feeStatus = 0;
if(validStatusObj.valid.length > 0){
opStatus = parseInt(validStatusObj.valid[0].opstatus);
feeStatus = parseInt(validStatusObj.valid[0].feestatus);
}
if(feeStatus < 1){
alert("委托业务已锁定,不能编辑费用信息");
return;
}
if(opStatus == 1){
if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){
alert("应收费用未保存,先保存应收费用,再操作应付费用-引入历史");
return;
}
var openSet = "height=600, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-600)/2 + ",Left= "+(screen.width-900)/2
var openType = "_blank";
//打开应付费用“历史引入”页面
var openUrl = "../Shipping/ImportFeeHistory.aspx?handle=import&oplb="+stroplb+"&historytype=2";
window.open (openUrl,openType,openSet);
}else{
alert("委托已退载,不能引入费用");
return;
}
}
function establishPay(type){//type=1 只复制算选的费用到应付 type=2复制所有到应付
for(var i=0;i<mygrid_recv.getRowsNum();i++){
var rowId = mygrid_recv.getRowId(i);
var rowRecvIndex = mygrid_recv.getRowIndex(rowId);
var checkState = mygrid_recv.cellByIndex(i,0).getValue();
if((type == 1 && checkState == 1) || type == 2){
var status = mygrid_recv.cellByIndex(i,1).getValue();
var feeName = mygrid_recv.cellByIndex(i,2).getValue();
var customerName = mygrid_recv.cellByIndex(i,3).getValue();
var unit = mygrid_recv.cellByIndex(i,4).getValue();
var price = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(i,5).getValue())));
var unitprice = parseFloat(price).toFixed(2);
var quantity = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(i,6).getValue())));
var tempQuantity = parseFloat(quantity).toFixed(4);
var commission = mygrid_recv.cellByIndex(i,7).getValue();
var amount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(i,8).getValue())));
var tempAmount = parseFloat(amount).toFixed(2);
var currency = mygrid_recv.cellByIndex(i,9).getValue();
var rate = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(i,10).getValue())));
var exchangeRate = parseFloat(rate);
var frt = mygrid_recv.cellByIndex(i,11).getValue();
var remark = mygrid_recv.cellByIndex(i,12).getValue();
var isAdvancePay = mygrid_recv.cellByIndex(i,13).getValue();
RowOutBsno=mygrid_recv.cellByIndex(i,20).getValue();
var newId = newGuid();
var rowCount = mygrid_pay.getRowsNum();
var linenum = rowCount + 1;
mygrid_pay.addRow(newId, [0, "录入状态", feeName, customerName, unit, unitprice, quantity, 0, 0, currency, exchangeRate, frt, remark, isAdvancePay, 0, 0, '', '', '', '', wmsoutbsno, linenum], rowCount);
var rowIndex = mygrid_pay.getRowIndex(newId);
if(feeName != ""){
var url = "";
var feeCodeObj = null;
var feeName = mygrid_pay.cellByIndex(rowIndex,2).getValue().trim();
if(feeName != ""){//通过费用名称获取费用代码表code_fee币别汇率信息
url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb="+stroplb+"&feename="+escape(feeName)+"&uid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var feeCodeInfo = loader.xmlDoc.responseText;
feeCodeObj = eval('(' + feeCodeInfo + ')');
if(feeCodeObj.feecode.length > 0){
if(feeCodeObj.feecode[0].cur.trim() != ""){
var bsno = $("h_bsno").value;
var urlVal = "";
if(currency == ""){//获取委托op_seai费用1汇率
mygrid_pay.cellByIndex(rowIndex,9).setValue(feeCodeObj.feecode[0].cur);
urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb="+stroplb+"&bsno="+bsno+"&type=1&currency="+feeCodeObj.feecode[0].cur+"&uid="+newGuid();
}else{
mygrid_pay.cellByIndex(rowIndex,9).setValue(currency);
urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb="+stroplb+"&bsno="+bsno+"&type=1&currency="+currency+"&uid="+newGuid();
}
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
mygrid_pay.cellByIndex(rowIndex,10).setValue(loadVal);
if(unit == ""){
if(feeCodeObj.feecode[0].unit != 0){
quantityObj = getUnitType(feeCodeObj.feecode[0].unit);
if(quantityObj.quantity.length > 0){
if(quantityObj.quantity[0].value > 0){
mygrid_pay.cellByIndex(rowIndex,4).setValue(quantityObj.quantity[0].name);
mygrid_pay.cellByIndex(rowIndex,6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString()));
}
}
}else{
mygrid_pay.cellByIndex(rowIndex,6).setValue(1);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,5).getValue())));
var quantityCount = 1;//clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString()));
}
}else{
var quantityObj = null;
cknum=mygrid_pay.cellByIndex(rowIndex,6).getValue();
quantityObj = getTypeNameQuantity(unit,cknum);
if(quantityObj.quantity.length > 0){
if(quantityObj.quantity[0].value > 0){
mygrid_pay.cellByIndex(rowIndex,4).setValue(quantityObj.quantity[0].name);
mygrid_pay.cellByIndex(rowIndex,6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString()));
}else{
if(getTypeNum(unit) >= 1){
mygrid_pay.cellByIndex(rowIndex,6).setValue(0);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,5).getValue())));
var quantityCount = 0;//clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_pay.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString()));
}
}
}
}
}
if(feeCodeObj.feecode[0].credit > 0){
var debitObj = null;
debitObj = getDebitType(feeCodeObj.feecode[0].credit);
if(debitObj.debit.length > 0){
if(debitObj.debit[0].value.trim() != ""){
mygrid_pay.cellByIndex(rowIndex,3).setValue(debitObj.debit[0].value);
}
}
}
ReShowLabel(mygrid_pay);
totalDynamicFeeGain();
}
}
}
}
}
}
function establishRecv(type){//type=1 只复制算选的费用到应收 type=2复制所有到应收
for(var i=0;i<mygrid_pay.getRowsNum();i++){
var rowId = mygrid_pay.getRowId(i);
var rowPayIndex = mygrid_pay.getRowIndex(rowId);
var checkState = mygrid_pay.cellByIndex(i,0).getValue();
if((type == 1 && checkState == 1) || type == 2){
var status = mygrid_pay.cellByIndex(i,1).getValue();
var feeName = mygrid_pay.cellByIndex(i,2).getValue();
var customerName = mygrid_pay.cellByIndex(i,3).getValue();
var unit = mygrid_pay.cellByIndex(i,4).getValue();
var price = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(i,5).getValue())));
var unitprice = parseFloat(price).toFixed(2);
var quantity = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(i,6).getValue())));
var tempQuantity = parseFloat(quantity).toFixed(4);
var commission = mygrid_pay.cellByIndex(i,7).getValue();
var amount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(i,8).getValue())));
var tempAmount = parseFloat(amount).toFixed(2);
var currency = mygrid_pay.cellByIndex(i,9).getValue();
var rate = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(i,10).getValue())));
var exchangeRate = parseFloat(rate);
var frt = mygrid_pay.cellByIndex(i,11).getValue();
var remark = mygrid_pay.cellByIndex(i,12).getValue();
var isAdvancePay = mygrid_pay.cellByIndex(i,13).getValue();
RowOutBsno = mygrid_pay.cellByIndex(i, 20).getValue();
var newId = newGuid();
var rowCount = mygrid_recv.getRowsNum();
var linenum = rowCount + 1;
mygrid_recv.addRow(newId, [0, "录入状态", feeName, customerName, unit, unitprice, tempQuantity, 0, 0, currency, exchangeRate, frt, remark, isAdvancePay, 0, 0, '', '', '', '', wmsoutbsno, linenum], rowCount);
var rowIndex = mygrid_recv.getRowIndex(newId);
if(feeName != ""){
var url = "";
var feeCodeObj = null;
if(feeName != ""){//通过费用名称获取费用代码表code_fee币别汇率信息
url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb="+stroplb+"&feename="+escape(feeName)+"&uid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var feeCodeInfo = loader.xmlDoc.responseText;
feeCodeObj = eval('(' + feeCodeInfo + ')');
if(feeCodeObj.feecode.length > 0){
if(feeCodeObj.feecode[0].cur.trim() != ""){
var urlVal = "";
var bsno = $("h_bsno").value;
if(currency == ""){//获取委托op_seai费用1汇率
mygrid_recv.cellByIndex(rowIndex,9).setValue(feeCodeObj.feecode[0].cur);
urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb="+stroplb+"&bsno="+bsno+"&type=1&currency="+feeCodeObj.feecode[0].cur+"&uid="+newGuid();
}else{
mygrid_recv.cellByIndex(rowIndex,9).setValue(currency);
urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb="+stroplb+"&bsno="+bsno+"&type=1&currency="+currency+"&uid="+newGuid();
}
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
mygrid_recv.cellByIndex(rowIndex,10).setValue(loadVal);
if(unit == ""){
if(feeCodeObj.feecode[0].unit != 0){
quantityObj = getUnitType(feeCodeObj.feecode[0].unit);
if(quantityObj.quantity.length > 0){
if(quantityObj.quantity[0].value > 0){
mygrid_recv.cellByIndex(rowIndex,4).setValue(quantityObj.quantity[0].name);
mygrid_recv.cellByIndex(rowIndex,6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString()));
}
}
}else{
mygrid_recv.cellByIndex(rowIndex,6).setValue(1);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue())));
var quantityCount = 1;
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString()));
}
}else{
var quantityObj = null;
cknum=mygrid_recv.cellByIndex(rowIndex,6).getValue();
quantityObj = getTypeNameQuantity(unit,cknum);
if(quantityObj.quantity.length > 0){
if(quantityObj.quantity[0].value > 0){
mygrid_recv.cellByIndex(rowIndex,4).setValue(quantityObj.quantity[0].name);
mygrid_recv.cellByIndex(rowIndex,6).setValue(quantityObj.quantity[0].value);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue())));
var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString()));
}else{
if(getTypeNum(unit) >= 1){
mygrid_recv.cellByIndex(rowIndex,6).setValue(0);
var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue())));
var quantityCount = 0;//clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString())));
var amount = unitPrice * quantityCount;
mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString()));
}
}
}
}
}
if(feeCodeObj.feecode[0].debit > 0){
var debitObj = null;
debitObj = getDebitType(feeCodeObj.feecode[0].debit);
if(debitObj.debit.length > 0){
if(debitObj.debit[0].value.trim() != ""){
mygrid_recv.cellByIndex(rowIndex,3).setValue(debitObj.debit[0].value);
}
}
}
ReShowLabel(mygrid_recv);
totalDynamicFeeGain();
}
}
}
}
}
}
var h_Customer = "";
function setCustomerCombo(obj, id) {//返回info_client结算单位
var customerInfo = "";
if ($("h_custcache").value.trim() != "") {
customerInfo = $("h_custcache").value.trim();
} else {//返回info_client结算单位JSON字符串
var url = "../FeeCodes/CRMClientInfo.aspx?handle=client&oplb=" + stroplb + "&uid=" + newGuid();
var loader = dhtmlxAjax.getSync(url);
customerInfo = loader.xmlDoc.responseText;
}
var jsonCacheObj = eval('(' + customerInfo + ')');
if (jsonCacheObj.customer.length > 0) {
for (var i = 0; i < jsonCacheObj.customer.length; i++) {
obj.put(jsonCacheObj.customer[i].name, jsonCacheObj.customer[i].code.toString().toLowerCase() + ' ' + jsonCacheObj.customer[i].name);
}
}
}
function getGain() {
var url = "../Shipping/feegridsource.aspx?read=getgain&oplb=" + stroplb + "&bsno=" + $("h_bsno").value.trim() + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(url);
var ls = loader.xmlDoc.responseText;
}