You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HENGCHENG/DSWeb/js/jsGridCRMClientQuotationInf...

4078 lines
160 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 linkgid = "";
var clientgid = "";
var cknum=0;//出库数量
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;
// }else{
// return true;
// }
// }
// }
//}
function initGrid(){
doInitRecvGrid();
}
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
//mygrid_recv.setHeader("<input type=\"checkbox\" id=\"ck_all_recv\" onclick=\"checkAll('recv')\" />,费用状态,海运费及附加费名称,结算单位,计费标准,单价,数量,佣金比例,金额,币别,汇率,FRT,费用备注,是否垫付,结算金额,开票金额,发票号码,录入人,录入时间,TID,linkgid");
// 1 2 3 4 5
mygrid_recv.setHeader("<input type=\"checkbox\" id=\"ck_all_recv\" onclick=\"checkAll('recv')\" />,费用名称,船公司,箱型,报价,备注");
mygrid_recv.setInitWidths("40,120,120,120,120,280");
mygrid_recv.setColAlign("center,center,center,center,center,center");
mygrid_recv.setColSorting("na,str,str,str,int,str");
mygrid_recv.setColTypes("ch,co,co,co,ed,ed");
//
clientgid = $("hdCLIENTGID").value;
linkgid = $("hdGID").value;
//判断委托单有无费用
var urlVal = "CRMClientQuotationListGridSource.aspx?type=1&handle=exist&linkgid=" + linkgid + "&clientgid=" + clientgid + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
loader = null;
if(parseInt(loadVal) == 1){
//获取海运费及附加费信息初始化grid
mygrid_recv.loadXML("CRMClientQuotationListGridSource.aspx?type=1&handle=init&linkgid=" + linkgid + "&clientgid=" + clientgid, function() {
ReShowLabel(mygrid_recv);
doInitPayGrid();
});
}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 remark = "";
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;
remark = jsonCacheObj.templates[i].remark;
mygrid_recv.addRow(newId,[0,"录入状态",feeName,customerName,unit,unitprice,remark],rowCount);
}
}
}
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 remark = "";
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;
remark = jsonCacheObj.history[i].remark;
mygrid_recv.addRow(newId,[0,"录入状态",feeName,customerName,unit,unitprice,remark],rowCount);
}
}
}
},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){
if($("hdEnabled").value == "1"){
var rowIndex = mygrid_recv.getRowIndex(id);
if(rowIndex >= 0){
var combo_feename;
combo_feename = mygrid_recv.getCustomCombo(id,1);
if(combo_feename.getKeys.length <= 1){
setFeeNameCombo(combo_feename);
}
var combo_cust;
combo_cust = mygrid_recv.getCustomCombo(id,2);
if(combo_cust.getKeys.length <= 1){
setCustomerCombo(combo_cust,id);
}
var combo_unit;
combo_unit = mygrid_recv.getCustomCombo(id,3);
if(combo_unit.getKeys.length <= 1){
setUnitCombo(combo_unit);
}
return true;
}
}
});
//手动编写Grid控件编辑事件,由于免费控件没有提供完整的编辑判断功能,现特此做更改
mygrid_recv.attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){
var newCheckValue = false;
//初始化状态
if (stage == 0) {
return true;
}
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" && document.all(i).id != "tbREMARK"){
txtEdit = document.all(i);
txtEdit.focus();
txtEdit.select();
break;
}
}
}
//如果编辑结束
if(stage == 2){
if(oValue==null || oValue=="" || oValue=="0"){
return true;
}
changeFeeRecvCount++;
if(cInd == 1 || cInd == 2)
{
var rowIndex = mygrid_recv.getRowIndex(rId);
if(pressCount == 1)
{
if(flagFilter == 1)
{
mygrid_recv.cellByIndex(rowIndex,cInd).setLabel(oValue);//alert(oValue);
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){
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){
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;
}
}
}
}
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;
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)
{
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){
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("");
}
return true;
}
}
}
else
{
var cellVal = mygrid_recv.cellByIndex(rowIndex,cInd).getValue();
var combo = mygrid_recv.getCustomCombo(rId,cInd);
var comboArg = combo.getKeys();
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)
{
mygrid_recv.cellByIndex(rowIndex,cInd).setValue(comboArg[i]);
mygrid_recv.cellByIndex(rowIndex,cInd).setLabel(comboArg[i]);
break;
}
}
}
else
{
for(var i = 0;i<comboArg.length;i++)
{
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]);
break;
}
}
}
return true;
}
}
else
{
return true;
}
}
});
//键盘操作事件
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();
//触发操作事件前获取单元值
var oldVal = mygrid_recv.cellByIndex(rowIndex, ind).getValue();
//获取编辑单元
var txtEdit;
for (i = 0; i < document.all.length; i++) {
if (document.all(i).tagName == "TEXTAREA" && document.all(i).id != "tbREMARK") {
txtEdit = document.all(i);
break;
}
}
if (code == 13) {
//Enter键
if (ind == 1 || ind == 2 || ind == 3) {
//如果是检索失败,
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 {
return true;
}
} else {
return true;
}
}
//Tab键
if (code == 9) {
//code9 begin
var colCount = mygrid_recv.getColumnsNum();
var rowCount = mygrid_recv.getRowsNum();
if (ind < colCount) {
mygrid_recv.selectCell(rowIndex, ind + 1, true, true);
mygrid_recv.editCell();
if (ind == colCount - 1) {
if (rowIndex < rowCount) {
mygrid_recv.editStop(true);
mygrid_recv.clearSelection();
mygrid_recv.selectCell(rowIndex + 1, 1, true, true);
mygrid_recv.editCell();
}
else {
return;
}
}
else {
return;
}
}
//cdoe9 end
}
if ((code >= 65 && code <= 90) || (code >= 48 && code <= 57) || (code >= 96 && code <= 105)) {//如果是输入英文字符
if (ind == 1 || ind == 2 || ind == 3) {
//获取键盘输入字符
var pressVal = String.fromCharCode(code);
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 (rowIndex == pressRowIndex && ind == pressCellIndex) {
//未选中多个字符
if (start == end) {
if (pressRecord != null) {
if (start != pressRecord.length) {
if (start != 0) {
var firstVal = pressRecord.substring(0, start - 1);
var endVal = pressRecord.substring(start + 1, txtEdit.value.length - 1);
pressRecord = firstVal + pressVal + endVal;
}
} else {
pressRecord = pressRecord + pressVal;
}
}
}
//选中多个字符
if (start != end) {
if (pressRecord != null) {
var firstVal = pressRecord.substring(0, start);
var endVal = pressRecord.substring(end - 1, txtEdit.value.length - 1);
pressRecord = firstVal + pressVal + endVal;
}
}
} else {
pressRecord = pressVal;
pressRowIndex = rowIndex;
pressCellIndex = ind;
}
//获取combo下拉列表
var combo = mygrid_recv.getCustomCombo(selectedId, ind);
var comboArg = combo.getKeys();
var count = 0;
//开始遍历检索
//如果检索成功 状态pressCount=1 如果不成功应为pressCount=2
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).toUpperCase().trim().indexOf(pressRecord) == 0) {
//计数
count++;
//获取value
var oldVal = comboArg[i];
//获取label
var oldLab = combo.get(comboArg[i]);
//记录状态值 检索到数据项
pressCount = 1;
flagFilter = 1;
//关闭编辑
mygrid_recv.editStop();
//将value写入cell(触发 stage2)
mygrid_recv.cellByIndex(rowIndex, ind).setValue(oldVal);
flagFilter = 0;
//重新打开cell(触发stage0 stage1)
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" && document.all(i).id != "tbREMARK") {
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位
r.select();
break;
}
}
break;
}
}
//如果检索不能成功 pressCount=2
if (count == 0) {
pressCount = 2;
txtEdit.value = pressRecord;
for (i = 0; i < document.all.length; i++) {
if (document.all(i).tagName == "TEXTAREA" && document.all(i).id != "tbREMARK") {
txtEdit = document.all(i);
var rt = txtEdit.createTextRange();
rt.collapse();
rt.select(); //光标置最前
var r = document.selection.createRange();
r.collapse(true);
r.moveStart("character", pressRecord.length); //从m位开始
r.moveEnd("character", pressRecord.length); //选取n位
r.select();
break;
}
}
}
}
if ((code >= 48 && code <= 57) || (code >= 96 && code <= 105)) {
if (ind == 4 || ind == 5) {
return true;
}
}
}
//delete
if (code == 8) {
//code8 begin
if (ind == 1 || ind == 2 || ind == 3) {
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]).toUpperCase().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" && document.all(i).id != "tbREMARK") {
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
}
//向下方向键
if (code == 40) {
//code40 begin
if (ind == 5 || ind == 4) {
var rowCount = mygrid_recv.getRowsNum();
mygrid_recv.clearSelection();
mygrid_recv.editStop();
if (rowIndex == (rowCount - 1)) {
addRecvRow();
} else {
mygrid_recv.selectCell(rowIndex + 1, 1, true, true);
mygrid_recv.editCell();
}
} else {
pressCount = 0;
return true;
}
//code40 end
}
//向上箭头
if (code == 38) {
//code38 begin
if (ind == 5 || ind == 4) {
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,1).getValue();
if (rowfeename == 0) {
mygrid_recv.deleteRow(selectedId)
newFeeRecvCount--;
}
}
} else {
pressCount = 0;
return true;
}
//code38 end
}
//左箭头
if (code == 37) {
//code37 begin
mygrid_recv.clearSelection();
mygrid_recv.editStop();
mygrid_recv.editCell();
return true;
} //code37 end
//右箭头
if (code == 39) {
//code39 begin
mygrid_recv.clearSelection();
mygrid_recv.editStop();
mygrid_recv.editCell();
return true;
} //code39 end
//键盘输入数字code >= 48 && code <= 57|| code >= 96 && code <= 105 ||
if (code >= 48 && code <= 57 || code >= 96 && code <= 105 || code == 188 || code == 110 || code == 190 || code == 229) {
if (ind == 2 || ind == 3 || ind == 4 || ind == 5 || ind == 1) {
return true;
}
}
if (code >= 65 && code <= 90) {//如果是输入英文字符
if (ind == 2 || ind == 3 || ind == 5 || ind == 1) {
return true;
}
}
if (code == 189 || code == 109) {
if (ind == 4) {
return true;
}
}
//onKeyPress end
});
setTimeout(function(){
},460);
}
//讲下拉列表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();
for(var i = 0;i < columnCount;i++){
var cellObj = gridObj.cellById(RowID, i);
var cell = gridObj.cellById(RowID,i);
var rowValue = cell.getValue();
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()));
}
}
}
return arg;
}
function isObjNaN(Obj){
if(Obj.toString().toLowerCase() == "nan"){
return 0;
}else{
return Obj;
}
}
function doInitPayGrid(){
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
//mygrid_pay.setHeader("<input type=\"checkbox\" id=\"ck_all_pay\" onclick=\"checkAll('pay')\" />,费用状态,人民币费用名称,结算单位,计费标准,单价,数量,佣金比例,金额,币别,汇率,FRT,费用备注,是否垫付,结算金额,申请金额,支票号码,录入人,录入时间,TID,linkgid");
// 1 2 3 4
mygrid_pay.setHeader("<input type=\"checkbox\" id=\"ck_all_pay\" onclick=\"checkAll('pay')\" />,费用名称,箱型,报价,备注");
mygrid_pay.setInitWidths("40,120,120,120,400");
mygrid_pay.setColAlign("center,center,center,center,center");
mygrid_pay.setColSorting("na,str,str,int,str");
mygrid_pay.setColTypes("ch,co,co,ed,ed");
//
clientgid = $("hdCLIENTGID").value;
linkgid = $("hdGID").value;
////判断委托单有无人民币费用
var urlVal = "CRMClientQuotationListGridSource.aspx?type=2&handle=exist&linkgid=" + linkgid + "&clientgid=" + clientgid + "&val=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
loader = null;
if(parseInt(loadVal) == 1){
//获取委托单人民币信息初始化grid
mygrid_pay.loadXML("CRMClientQuotationListGridSource.aspx?type=2&handle=init&linkgid=" + linkgid + "&clientgid=" + clientgid, function() {
ReShowLabel(mygrid_pay);
});
}
else{}
mygrid_pay.init();
mygrid_pay.enableEditEvents(true,false,true);
mygrid_pay.enableMultiselect(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 unit = "";
var unitprice = 0;
var remark = "";
if(jsonCacheObj.templates[i].type == 2){
tid = jsonCacheObj.templates[i].tid;
feeName = jsonCacheObj.templates[i].fname;
unit = jsonCacheObj.templates[i].unit;
unitprice = jsonCacheObj.templates[i].uprice;
remark = jsonCacheObj.templates[i].remark;
var rId = newId;
mygrid_pay.addRow(newId,[0,feeName,unit,unitprice,remark],rowCount);
}
}
}
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 unit = "";
var unitprice = 0;
var remark = "";
if(jsonCacheObj.history[i].type == 2){
tid = jsonCacheObj.history[i].tid;
feeName = jsonCacheObj.history[i].fname;
unit = jsonCacheObj.history[i].unit;
unitprice = jsonCacheObj.history[i].uprice;
remark = jsonCacheObj.history[i].remark;
var rId = newId;
mygrid_pay.addRow(newId,[0,feeName,unit,unitprice,remark],rowCount);
}
}
}
},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){
if($("hdEnabled").value == "1"){
var rowIndex = mygrid_pay.getRowIndex(id);
if(rowIndex >= 0){
var combo_feename;
combo_feename = mygrid_pay.getCustomCombo(id,1);
if(combo_feename.getKeys.length <= 1){
setFeeNameCombo(combo_feename);
}
var combo_unit;
combo_unit = mygrid_pay.getCustomCombo(id,2);
if(combo_unit.getKeys.length <= 1){
setUnitCombo(combo_unit);
}
return true;
}
}
});
//手动编写Grid控件编辑事件,由于免费控件没有提供完整的编辑判断功能,现特此做更改
mygrid_pay.attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){
var newCheckValue = false;
//初始化状态
if (stage == 0) {
return true;
}
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" && document.all(i).id != "tbREMARK"){
txtEdit = document.all(i);
txtEdit.focus();
txtEdit.select();
break;
}
}
}
//如果编辑结束
if(stage == 2){
if(oValue==null || oValue=="" || oValue=="0"){
return true;
}
changeFeePayCount++;
if(cInd == 1){
var rowIndex = mygrid_pay.getRowIndex(rId);
if(pressCount == 1){
if(flagFilter == 1){
mygrid_pay.cellByIndex(rowIndex,cInd).setLabel(oValue);
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){
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;
}
}
}
}//alert(tempCount)
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){
mygrid_pay.cellByIndex(rowIndex,cInd).setValue(comboArg[i]);
mygrid_pay.cellByIndex(rowIndex,cInd).setLabel(comboArg[i]);
tempCount++;
break;
}
}
}//alert(tempCount)
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();
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){
mygrid_pay.cellByIndex(rowIndex,cInd).setValue(comboArg[i]);
mygrid_pay.cellByIndex(rowIndex,cInd).setLabel(comboArg[i]);
break;
}
}
}else{
for(var i = 0;i<comboArg.length;i++){
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]);
break;
}
}
}
return true;
}
}else{
return true;
}
}
});
//键盘操作事件
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();
//触发操作事件前获取单元值
var oldVal = mygrid_pay.cellByIndex(rowIndex, ind).getValue();
//获取编辑单元
var txtEdit;
for (i = 0; i < document.all.length; i++) {
if (document.all(i).tagName == "TEXTAREA" && document.all(i).id != "tbREMARK") {
txtEdit = document.all(i);
break;
}
}
if (code == 13) {
if (ind == 1 || ind == 2) {
//如果是检索失败,
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 {
return true;
}
} else {
return true;
}
}
//Tab键
if (code == 9) {
//code9 begin
var colCount = mygrid_pay.getColumnsNum();
var rowCount = mygrid_pay.getRowsNum();
if (ind < colCount) {
mygrid_pay.selectCell(rowIndex, ind + 1, true, true);
mygrid_pay.editCell();
if (ind == colCount - 1) {
if (rowIndex < rowCount) {
mygrid_pay.editStop(true);
mygrid_pay.clearSelection();
mygrid_pay.selectCell(rowIndex + 1, 1, true, true);
mygrid_pay.editCell();
}
else {
return;
}
}
else {
return;
}
}
//cdoe9 end
}
if ((code >= 65 && code <= 90) || (code >= 48 && code <= 57) || (code >= 96 && code <= 105)) {//如果是输入英文字符
if (ind == 1 || ind == 2) {
//获取键盘输入字符
var pressVal = String.fromCharCode(code);
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 (rowIndex == pressRowIndex && ind == pressCellIndex) {
//未选中多个字符
if (start == end) {
if (start != pressRecord.length) {
if (start != 0) {
var firstVal = pressRecord.substring(0, start - 1);
var endVal = pressRecord.substring(start + 1, txtEdit.value.length - 1);
pressRecord = firstVal + pressVal + endVal;
}
} else {
pressRecord = pressRecord + pressVal;
}
}
//选中多个字符
if (start != end) {
var firstVal = pressRecord.substring(0, start);
var endVal = pressRecord.substring(end - 1, txtEdit.value.length - 1);
pressRecord = firstVal + pressVal + endVal;
}
} else {
pressRecord = pressVal;
pressRowIndex = rowIndex;
pressCellIndex = ind;
}
//获取combo下拉列表
var combo = mygrid_pay.getCustomCombo(selectedId, ind);
var comboArg = combo.getKeys();
var count = 0;
//开始遍历检索
//如果检索成功 状态pressCount=1 如果不成功应为pressCount=2
for (var i = 0; i < comboArg.length; i++) {
if (combo.get(comboArg[i]).toUpperCase().trim().indexOf(pressRecord) == 0) {
//计数
count++;
//获取value
var oldVal = comboArg[i];
//获取label
var oldLab = combo.get(comboArg[i]);
//记录状态值 检索到数据项
pressCount = 1;
flagFilter = 1;
//关闭编辑
mygrid_pay.editStop();
//将value写入cell(触发 stage2)
mygrid_pay.cellByIndex(rowIndex, ind).setValue(oldVal);
flagFilter = 0;
//重新打开cell(触发stage0 stage1)
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" && document.all(i).id != "tbREMARK") {
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位
r.select();
break;
}
}
break;
}
}
//如果检索不能成功 pressCount=2
if (count == 0) {
pressCount = 2;
txtEdit.value = pressRecord;
for (i = 0; i < document.all.length; i++) {
if (document.all(i).tagName == "TEXTAREA" && document.all(i).id != "tbREMARK") {
txtEdit = document.all(i);
var rt = txtEdit.createTextRange();
rt.collapse();
rt.select(); //光标置最前
var r = document.selection.createRange();
r.collapse(true);
r.moveStart("character", pressRecord.length); //从m位开始
r.moveEnd("character", pressRecord.length); //选取n位
r.select();
break;
}
}
}
}
if ((code >= 48 && code <= 57) || (code >= 96 && code <= 105)) {
if (ind == 3) {
return true;
}
}
}
//delete
if (code == 8) {
//code8 begin
if (ind == 1 || ind == 2) {
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]).toUpperCase().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" && document.all(i).id != "tbREMARK") {
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
}
//向下方向键
if (code == 40) {
//code40 begin
if (ind == 3 || ind == 4) {
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
}
//向上箭头
if (code == 38) {
//code38 begin
if (ind == 3 || ind == 4) {
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, 1).getValue();
if (rowfeename == 0) {
mygrid_pay.deleteRow(selectedId)
newFeePayCount--;
}
}
} else {
pressCount = 0;
return true;
}
//code38 end
}
//左箭头
if (code == 37) {
//code37 begin
mygrid_pay.clearSelection();
mygrid_pay.editStop();
mygrid_pay.editCell();
return true;
} //code37 end
//右箭头
if (code == 39) {
//code39 begin
mygrid_pay.clearSelection();
mygrid_pay.editStop();
mygrid_pay.editCell();
return true;
} //code39 end
//键盘输入数字code >= 48 && code <= 57|| code >= 96 && code <= 105 ||
if (code >= 48 && code <= 57 || code >= 96 && code <= 105 || code == 188 || code == 110 || code == 190 || code == 229) {
if (ind == 1 || ind == 2 || ind == 3 || ind == 4) {
return true;
}
}
if (code >= 65 && code <= 90) {//如果是输入英文字符
if (ind == 2 || ind == 1 || ind == 4) {
return true;
}
}
if (code == 189 || code == 109) {
if (ind == 3) {
return true;
}
}
//onKeyPress end
});
setTimeout(function(){
},460);
var pressVal = "";
var pressColIndex = 0;
var pressRowIndex = 0;
var pressGridType = 1;//recv
}
function addRecvRow(){
var clientgid = $("hdCLIENTGID").value;
var newId = newGuid();
//获取插入新纪录位置
var rowCount = mygrid_recv.getRowsNum();
mygrid_recv.addRow(newId, [0, "", $("hd_comboCARRIER").value.trim(), "", 0.00, ""], rowCount);
mygrid_recv.clearSelection();
var rId = mygrid_recv.getRowId(rowCount - 1);
var combo_feename;
combo_feename = mygrid_recv.getCustomCombo(newId,1);
setFeeNameCombo(combo_feename);
var combo_cust;
combo_cust = mygrid_recv.getCustomCombo(newId,2);
setCustomerCombo(combo_cust,newId);
var combo_unit;
combo_unit = mygrid_recv.getCustomCombo(newId,3);
setUnitCombo(combo_unit);
newFeeRecvCount++;
setTimeout(function(){
mygrid_recv.editStop(true);
mygrid_recv.selectCell(mygrid_recv.getRowIndex(newId),1,true,true);
mygrid_recv.editCell();
},150);
}
function addPayRow(){
var clientgid = $("hdCLIENTGID").value;
var newId = newGuid();
//获取插入新纪录位置
var rowCount = mygrid_pay.getRowsNum();
mygrid_pay.addRow(newId,[0,"","",0.00,""],rowCount);
mygrid_pay.clearSelection();
var rId = mygrid_pay.getRowId(rowCount - 1);
var combo_feename;
combo_feename = mygrid_pay.getCustomCombo(newId,1);
setFeeNameCombo(combo_feename);
var combo_unit;
combo_unit = mygrid_pay.getCustomCombo(newId,2);
setUnitCombo(combo_unit);
newFeePayCount++;
setTimeout(function(){
mygrid_pay.editStop(true);
mygrid_pay.selectCell(mygrid_pay.getRowIndex(newId),1,true,true);
mygrid_pay.editCell();
},150);
}
function deleteRecvRow(){
var clientgid = $("hdCLIENTGID").value;
var iSuccess = 0;
var iFailure = 0;
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_recv.getRowsNum();i++){
var rowID = mygrid_recv.getRowId(i);
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]);
//删除委托业务内的费用当ch_fee.feestatus=1或6时通过费用GID删除ch_fee单条费用更新fee_gain重算利润并返回删除操作结果
var urlVal = "CRMClientQuotationListGridSource.aspx?feegid=" + recvArg[delCount] + "&handle=delete&no=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if(loadVal == 1 ){
mygrid_recv.deleteRow(recvArg[delCount]);
}else{
}
delCount++;
}
}
}
}else{
alert("未选中要操作的费用项");
}
}
function deletePayRow(id){
var clientgid = $("hdCLIENTGID").value;
var iSuccess = 0;
var iFailure = 0;
var iCount = 0;
var recvArg = new Array();
for(var i=0;i<mygrid_pay.getRowsNum();i++){
var rowID = mygrid_pay.getRowId(i);
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]);
//删除委托业务内的费用当ch_fee.feestatus=1或6时通过费用GID删除ch_fee单条费用更新fee_gain重算利润并返回删除操作结果
var urlVal = "CRMClientQuotationListGridSource.aspx?feegid=" + recvArg[delCount] + "&handle=delete&no=" + newGuid();
var loader = dhtmlxAjax.getSync(urlVal);
var loadVal = loader.xmlDoc.responseText;
if(loadVal == 1 ){
mygrid_pay.deleteRow(recvArg[delCount]);
}else{
}
delCount++;
}
}
}
}else{
alert("未选中要操作的费用项");
}
}
//保存海运费及附加费
function saveRecvChange(){
var clientgid = $("hdCLIENTGID").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 fname = mygrid_recv.cellByIndex(i,1).getValue();
if(fname.trim() == ""){
$("recvContainer").value="";
alert("费用名称不能为空");
return -1;
}
var cust = mygrid_recv.cellByIndex(i,2).getValue();
if(cust.trim() == ""){
$("recvContainer").value="";
alert("船公司不能为空");
return -1;
}
var unit = mygrid_recv.cellByIndex(i,3).getValue();
if(unit == ""){
$("recvContainer").value = "";
alert("箱型不能为空");
return -1;
}
var price = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,4).getValue())));
var tempPrice = parseFloat(price).toFixed(2);
if(tempPrice == 0){
$("recvContainer").value="";
alert("报价不能为零");
return -1;
}
var remark = mygrid_recv.cellByIndex(i,5).getValue();
if(jsonFeeObj == null){
var cacheBuffer = "";
cacheBuffer += "{";
cacheBuffer += "\"id\":\""+rowId+"\",";
cacheBuffer += "\"fname\":\""+fname+"\",";
cacheBuffer += "\"cust\":\""+cust+"\",";
cacheBuffer += "\"unit\":\""+unit+"\",";
cacheBuffer += "\"price\":\"" + tempPrice + "\",";
cacheBuffer += "\"remark\":\""+remark+"\"";
cacheBuffer += "}";
var result = "";
result += "{\"fees\":[";
result += cacheBuffer;
result += "]}";
jsonFeeObj = eval('(' + result + ')');
}else{
var newFeeRow = jsonFeeObj.fees;
newFeeRow = { id: rowId, fname: fname, cust: cust, unit: unit, price: tempPrice, remark: remark };
jsonFeeObj.fees.push(newFeeRow);
}
}
$("recvContainer").value = JSON.stringify(jsonFeeObj);
return 1;
}
function saveAction(){
var recvState = 0;
var payState = 0;
recvState = saveRecvChange();//保存海运费及附加费
payState = savePayChange(); //保存人民币费用
var dd = $("recvContainer").value.trim();
var dvvd = $("payContainer").value.trim();
if($("recvContainer").value.trim() == "" && $("payContainer").value.trim() == ""){
return;
}
if(recvState == 1 && payState == 1){
msgBox();
//定时发送数据
setTimeout(postEnterFee,200);
newFeeRecvCount = 0;
changeFeeRecvCount = 0;
$("h_post").value = 1;
}
else{
// initGrid();
}
}//saveAction 完成
//保存人民币费用
function savePayChange(){
var clientgid = $("hdCLIENTGID").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 fname = mygrid_pay.cellByIndex(i,1).getValue();
if(fname.trim() == ""){
$("payContainer").value="";
alert("费用名称不能为空");
return -1;
}
var unit = mygrid_pay.cellByIndex(i,2).getValue();
if(unit == ""){
$("payContainer").value = "";
alert("箱型不能为空");
return -1;
}
var price = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,3).getValue())));
var tempPrice = parseFloat(price).toFixed(2);
if(tempPrice == 0){
$("payContainer").value="";
alert("单价不能为零");
return -1;
}
var remark = mygrid_pay.cellByIndex(i, 4).getValue();
if(jsonFeeObj == null){
var cacheBuffer = "";
cacheBuffer += "{";
cacheBuffer += "\"id\":\""+rowId+"\",";
cacheBuffer += "\"fname\":\""+fname+"\",";
cacheBuffer += "\"unit\":\""+unit+"\",";
cacheBuffer += "\"price\":\"" + tempPrice + "\",";
cacheBuffer += "\"remark\":\"" + remark + "\"";
cacheBuffer += "}";
var result = "";
result += "{\"fees\":[";
result += cacheBuffer;
result += "]}";
jsonFeeObj = eval('(' + result + ')');
}else{
var newFeeRow = jsonFeeObj.fees;
newFeeRow = { id: rowId, fname: fname, unit: unit, price: tempPrice, remark: remark };
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 clientgid = $("hdCLIENTGID").value;
if(clientgid == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?clientgid="+clientgid+"&handle=checkopstatus&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&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&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&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);
alert("提交放弃修改海运费及附加费 共 "+delCount+" 条 成功 "+iSuccess+" 条 失败 "+iFailure+" 条");
}
}else{
alert("未选中要操作的费用项");
}
}else{
alert("委托已退载,费用修改费用");
return;
}
}
//放弃人民币费用修改 重新加载页面
function recoverPayChange(){
var iSuccess = 0;
var iFailure = 0;
var clientgid = $("hdCLIENTGID").value;
if(clientgid == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?clientgid="+clientgid+"&handle=checkopstatus&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&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&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&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);
alert("提交放弃修改海运费及附加费 共 "+delCount+" 条 成功 "+iSuccess+" 条 失败 "+iFailure+" 条");
}
}else{
alert("未选中要操作的费用项");
}
}else{
alert("委托已退载,费用修改费用");
return;
}
}
function print_recv(){
printMessageBox(event,1);
}
function print_pay(){
printMessageBox(event,2);
}
//输出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;
}
//过滤结算单位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]).toUpperCase().trim().indexOf(filterVal.toUpperCase()) == 0){
gridObj.cellByIndex(rowIndex,colIndex).setValue(combo.get(comboArg[i]));
gridObj.selectCell(rowIndex,colIndex,true,true,true,true);
doCount = 1;
break;
}
}
}//end filterComboCustomerPress
//两端去空格函数
String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g,""); }
//刷新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 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 checkPayHistory(){
var strclientgid = $("hdCLIENTGID").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?clientgid="+strclientgid+"&type=2";
window.open (openUrl,openType,openSet);
}
//引入海运费及附加费模板
function importRecvTemplate(){
if(!validOperatePower("",1,"import")){
alert("没有权限操作数据");
return;
}
var clientgid = $("hdCLIENTGID").value;
if(clientgid == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?clientgid="+clientgid+"&handle=checkopstatus&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&type=3"; //海运费及附加费
window.open (openUrl,openType,openSet);
}else{
alert("委托已退载,不能引入费用");
return;
}
}
//打开人民币费用模板
function importPayTemplate() {
if ($("hdHandle").value.trim() != "edit") {
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&type=4"; //人民币杂费
window.open (openUrl,openType,openSet);
}
//检查浏览器是否是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 printMessageBox(ev,type)
{
var selectCustomerOptions = "";
var feeNameArg = new Array();
if(type == 1){
if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){
alert("海运费及附加费未保存,请先保存之后再打印");
return;
}
for(var j=0;j<mygrid_recv.getRowsNum();j++){
var customerName = mygrid_recv.cellByIndex(j,3).getValue();
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<mygrid_pay.getRowsNum();j++){
var customerName = mygrid_pay.cellByIndex(j,3).getValue();
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></select></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 strclientgid = "";
var typeName = "";
strclientgid = $("hdCLIENTGID").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+"',";
}
}
if(selVal == 1){//打印委托op_seai海运费及附加费报表返回JSON对象
url = "../Reports/ReportService.aspx?handle=printseaopfee&clientgid="+strclientgid+"&search="+escape(searchCustomer)+"&feetype=1&val="+newGuid();
typeName = "SEAOPFEEDR";
}else if(selVal == 2){//打印委托op_seai人民币费用报表返回JSON对象
url = "../Reports/ReportService.aspx?handle=printseaopfee&clientgid="+strclientgid+"&search="+escape(searchCustomer)+"&feetype=2&val="+newGuid();
typeName = "SEAOPFEECR";
}else if(selVal == 3){//打印委托op_seai利润报表返回JSON对象
typeName = "SEAOPGAIN";
url = "../Reports/ReportService.aspx?handle=printseaopgain&clientgid="+strclientgid+"&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+"&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 strclientgid = "";
strclientgid = $("hdCLIENTGID").value;
//获取委托op_seai费用计费标准信息返回JSON数据
var url = "";
url = "../FeeCodes/FeeUnitService.aspx?handle=quantity&clientgid="+strclientgid+"&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;
}
var h_Debit="";
function getDebitType(typeID){//获取委托信息(op_seai)默认收费客户信息
var strclientgid = "";
strclientgid = $("hdCLIENTGID").value;
//获取委托信息(op_seai)默认收费客户信息返回JSON数据源
var url = "";
url = "../FeeCodes/FeeDebitService.aspx?handle=debit&clientgid="+strclientgid+"&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_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&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 + ' '+jsonCacheObj.customer[i].name);
}
}
}
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&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);
}
}
}
var h_Unit="";
function setUnitCombo(obj){//初始化计费标准Combo
var feeCodeCtnObj = null;
var clientgid = $("hdCLIENTGID").value;
//集装箱(op_ctn)信息返回JSON数据源
var url = "CRMClientQuotationListGridSource.aspx?handle=getctn&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);
}
}
}
}
}
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){
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){
mygrid_pay.cellByIndex(i,0).setValue(1)
}else{
mygrid_pay.cellByIndex(i,0).setValue(0)
}
}
}
}
function enableAction(){//屏蔽onclick事件
if($("hdEnabled").value == "0"){
//recv
$("btn_recvadd").onclick = clickNull;
$("btn_recvsave").onclick = clickNull;
$("btn_recvdel").onclick = clickNull;
$("btn_recvcover").onclick = clickNull;
$("btn_recvrefresh").onclick = clickNull;
$("btn_recvprint").onclick = clickNull;
$("btn_recvaudit").onclick = clickNull;
$("btn_recvmodify").onclick = clickNull;
$("btn_recvorderdel").onclick = clickNull;
//pay
$("btn_payadd").onclick = clickNull;
$("btn_paysave").onclick = clickNull;
$("btn_paydel").onclick = clickNull;
$("btn_paycover").onclick = clickNull;
$("btn_payrefresh").onclick = clickNull;
$("btn_payprint").onclick = clickNull;
$("btn_payaudit").onclick = clickNull;
$("btn_paymodify").onclick = clickNull;
$("btn_payorderdel").onclick = clickNull;
}
}
function validOperatePower(feeid,feetype,opname){//获取用户的模块权限信息
var url = "";
var tempOpName = "";
if("undefined" != typeof opname){
tempOpName = opname;
}else{
tempOpName = "";
}
var clientgid = $("hdCLIENTGID").value;
//获取用户的模块权限信息返回UserAuthorityRangeEntity
url = "../Shipping/FeeService.aspx?handle=validateop&gid="+feeid+"&feetype="+feetype+"&opname="+tempOpName+"&clientgid="+clientgid+"&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&uid="+newGuid();
var loader = dhtmlxAjax.getSync(url);
var feeCodeInfo = loader.xmlDoc.responseText;
if($("h_feecache").value.trim() == ""){
$("h_feecache").value = feeCodeInfo;
}
var url = "../FeeCodes/CRMClientInfo.aspx?handle=client&uid="+newGuid();//返回info_client结算单位JSON字符串
var loader = dhtmlxAjax.getSync(url);
var customerInfo = loader.xmlDoc.responseText;
if($("h_custcache").value.trim() == ""){
$("h_custcache").value = customerInfo;
}
}
//function initLoading(){
// $("progressBar").style.display = "";
//}
//function finishLoading(){
// $("progressBar").style.display = "none";
//}
function initMenu(){//初始化菜单
initRecvMenu();
initPayMenu();
}
function initRecvMenu(){//初始化海运费及附加费菜单“引入费用”
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($("hdEnabled").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", 1, "template", "引入费用模板", false);
// pay_menu.addNewChild("master", 0, "history", "历史引入", false);
// pay_menu.addNewChild("master", 1, "establishrecv", "生成应收", false);
// pay_menu.addNewChild("establishrecv", 1, "importrecvselect", "所选生成", false);
// pay_menu.addNewChild("establishrecv", 1, "importrecvall", "所有生成", false);
if($("hdEnabled").value == "0"){
return;
}
pay_menu.attachEvent("onClick", function(id, zoneId, casState){
switch(id){
case "template":
importPayTemplate();
break;
// case "history":
// importPayHistory();
// break;
// case "establishpay":
// 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 clientgid = $("hdCLIENTGID").value;
if(clientgid == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?clientgid="+clientgid+"&handle=checkopstatus&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&historytype=1";
window.open (openUrl,openType,openSet);
}else{
alert("委托已退载,不能引入费用");
return;
}
}
function importPayHistory(){//人民币费用菜单“历史引入”
if(!validOperatePower("",2,"import")){
alert("没有权限操作数据");
return;
}
var clientgid = $("hdCLIENTGID").value;
if(clientgid == ""){
return;
}
//验证委托状态是否为退舱状态(op_status和 op_seai)返回json值
var urlVal = "../Shipping/FeeService.aspx?clientgid="+clientgid+"&handle=checkopstatus&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&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();
var newId = newGuid();
var rowCount = mygrid_pay.getRowsNum();
mygrid_pay.addRow(newId,[0,"录入状态",feeName,customerName,unit,unitprice,quantity,0,0,currency,exchangeRate,frt,remark,isAdvancePay,0,0,'','','','',linkgid],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&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 clientgid = $("hdCLIENTGID").value;
var urlVal = "";
if(currency == ""){//获取委托op_seai费用1汇率
mygrid_pay.cellByIndex(rowIndex,9).setValue(feeCodeObj.feecode[0].cur);
urlVal = "../FeeCodes/CurrencyCodeService.aspx?clientgid="+clientgid+"&type=1&currency="+feeCodeObj.feecode[0].cur+"&uid="+newGuid();
}else{
mygrid_pay.cellByIndex(rowIndex,9).setValue(currency);
urlVal = "../FeeCodes/CurrencyCodeService.aspx?clientgid="+clientgid+"&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()));
}
}
}
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);
}
}
}
}
}
}
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();
var newId = newGuid();
var rowCount = mygrid_recv.getRowsNum();
mygrid_recv.addRow(newId,[0,"录入状态",feeName,customerName,unit,unitprice,tempQuantity,0,0,currency,exchangeRate,frt,remark,isAdvancePay,0,0,'','','','',linkgid],rowCount);
var rowIndex = mygrid_recv.getRowIndex(newId);
if(feeName != ""){
var url = "";
var feeCodeObj = null;
if(feeName != ""){//通过费用名称获取费用代码表code_fee币别汇率信息
url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&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 clientgid = $("hdCLIENTGID").value;
if(currency == ""){//获取委托op_seai费用1汇率
mygrid_recv.cellByIndex(rowIndex,9).setValue(feeCodeObj.feecode[0].cur);
urlVal = "../FeeCodes/CurrencyCodeService.aspx?clientgid="+clientgid+"&type=1&currency="+feeCodeObj.feecode[0].cur+"&uid="+newGuid();
}else{
mygrid_recv.cellByIndex(rowIndex,9).setValue(currency);
urlVal = "../FeeCodes/CurrencyCodeService.aspx?clientgid="+clientgid+"&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()));
}
}
}
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);
}
}
}
}
}
}
//-----------------------------------------------------------------------------------------------------------------------------------------
function getonload() {
initComboSHORTNAME2();
initComboCONTACTNAME2();
initComboSALE2();
initComboPORTLOAD2();
initComboPORTDISCHARGE2();
initComboENTREPORT2();
initComboLANE2();
initComboCARRIER2();
initPayMenu();
}
var comboSHORTNAME; //潜在客户
var comboCONTACTNAME; //潜在客户联系人
var comboSALE; //揽货人
var comboPORTLOAD; //启运港
var comboPORTDISCHARGE; //卸货港交货地
var comboENTREPORT; //中转港
var comboLANE; //航线
var comboCARRIER; //船公司
//initComboPORTLOAD2();initComboPORTDISCHARGE2();
//initComboSHORTNAME(); initComboSALE();
function initComboSHORTNAME()//潜在客户
{
comboSHORTNAME = dhtmlXComboFromSelect("ddlSHORTNAME");
comboSHORTNAME.loadXML("CRMClientVisitListGridSource.aspx?handle=getshortname");
//comboSHORTNAME.loadXML("CRMClientQuotationListGridSource.aspx?handle=getshortname");
}
function initComboSHORTNAME2()//潜在客户
{
if ($("hdEnabled").value == "0" || $("hdISCLIENTGID").value == "1") {
comboSHORTNAME.disable(true);
}
//
comboSHORTNAME.setOptionWidth(200);
comboSHORTNAME.attachEvent("onChange", function() {
comboSHORTNAME.setComboText($("hd_comboSHORTNAME").value);
});
comboSHORTNAME.attachEvent("onBlur", function() {
var s1 = comboSHORTNAME.getComboText().trim();
var s2 = s1.indexOf("|");
if (s1 == "") {
$("hd_comboSHORTNAME").value = "";
comboSHORTNAME.setComboText($("hd_comboSHORTNAME").value);
}
else {
if (s2 > 0) {
s2 = s2 + 2;
}
var s3 = s1.substring(s2);
if (s2 > 0) {
comboSHORTNAME.setComboText(s3);
$("hd_comboSHORTNAME").value = s3;
}
else {
comboSHORTNAME.setComboText($("hd_comboSHORTNAME").value);
}
}
initComboCONTACTNAME3();
});
comboSHORTNAME.setComboText($("hd_comboSHORTNAME").value);
comboSHORTNAME.attachEvent("onKeyPressed", function(keyCode) {
if (keyCode != "8") {
var arrayArg = new Array();
setTimeout(function() {
var filterCount = 0;
var is = -1;
var ishd = $("hd_comboSHORTNAME").value.trim();
if ("" != comboSHORTNAME.getComboText().trim()) {
while ("undefined" != typeof comboSHORTNAME.getOptionByIndex(filterCount)) {
var comboValue = comboSHORTNAME.getOptionByIndex(filterCount).text.toUpperCase(); //.value;
var enterValue = comboSHORTNAME.getComboText().trim().toUpperCase();
$("hd_comboSHORTNAME").value = comboSHORTNAME.getComboText().trim().toUpperCase();
if (comboValue.indexOf(enterValue) == 0) {
comboSHORTNAME.selectOption(filterCount, true, true);
is = filterCount;
break;
}
++filterCount;
}
if (is == -1) {
$("hd_comboSHORTNAME").value = ishd;
alert("无此内容,请重新选择!");
}
}
}, 10);
}
});
comboSHORTNAME.attachEvent("onSelectionChange", function() {
$("hd_comboSHORTNAME").value = comboSHORTNAME.getComboText().trim();
});
}
function initComboCONTACTNAME()//潜在客户联系人
{
//生成
comboCONTACTNAME = dhtmlXComboFromSelect("ddlCONTACTNAME");
comboCONTACTNAME.loadXML("CRMClientQuotationListGridSource.aspx?handle=getcontactname&clientname=" + escape($("hd_comboSHORTNAME").value));
}
function initComboCONTACTNAME3()//潜在客户联系人
{
comboCONTACTNAME.loadXML("CRMClientQuotationListGridSource.aspx?handle=getcontactname&clientname=" + escape($("hd_comboSHORTNAME").value));
}
function initComboCONTACTNAME2()//潜在客户联系人
{
if ($("hdEnabled").value == "0") {
comboCONTACTNAME.disable(true);
}
//
comboCONTACTNAME.setOptionWidth(200);
comboCONTACTNAME.attachEvent("onChange", function () {
comboCONTACTNAME.setComboText($("hd_comboCONTACTNAME").value);
});
comboCONTACTNAME.attachEvent("onBlur", function () {
var s1 = comboCONTACTNAME.getComboText();
var s2 = s1.indexOf("|");
if (s1 == "") {
$("hd_comboCONTACTNAME").value = "";
comboCONTACTNAME.setComboText($("hd_comboCONTACTNAME").value);
}
else {
if (s2 > 0) {
s2 = s2 + 2;
}
var s3 = s1.substring(s2);
if (s2 > 0) {
comboCONTACTNAME.setComboText(s3);
$("hd_comboCONTACTNAME").value = s3;
}
else {
comboCONTACTNAME.setComboText($("hd_comboCONTACTNAME").value);
}
}
});
comboCONTACTNAME.setComboText($("hd_comboCONTACTNAME").value);
comboCONTACTNAME.attachEvent("onKeyPressed", function (keyCode) {
if (keyCode != "8") {
var arrayArg = new Array();
setTimeout(function () {
var filterCount = 0;
var is = -1;
var ishd = $("hd_comboCONTACTNAME").value;
if ("" != comboCONTACTNAME.getComboText()) {
while ("undefined" != typeof comboCONTACTNAME.getOptionByIndex(filterCount)) {
var comboValue = comboCONTACTNAME.getOptionByIndex(filterCount).text.toUpperCase(); //.value;
var enterValue = comboCONTACTNAME.getComboText().toUpperCase();
$("hd_comboCONTACTNAME").value = comboCONTACTNAME.getComboText().toUpperCase();
if (comboValue.indexOf(enterValue) == 0) {
comboCONTACTNAME.selectOption(filterCount, true, true);
is = filterCount;
break;
}
++filterCount;
}
if (is == -1) {
$("hd_comboCONTACTNAME").value = ishd;
alert("无此内容,请重新选择!");
}
}
}, 10);
}
});
comboCONTACTNAME.attachEvent("onSelectionChange", function () {
$("hd_comboCONTACTNAME").value = comboCONTACTNAME.getComboText();
});
}
function initComboSALE()//揽货人
{
//生成
comboSALE = dhtmlXComboFromSelect("ddlSALE");
comboSALE.loadXML("CRMClientAssignListGridSource.aspx?handle=issaleman");
}
function initComboSALE2()//揽货人
{
if ($("hdEnabled").value == "0") {
comboSALE.disable(true);
}
//
comboSALE.setOptionWidth(200);
comboSALE.attachEvent("onChange", function() {
comboSALE.setComboText($("hd_comboSALE").value);
});
comboSALE.attachEvent("onBlur", function() {
var s1 = comboSALE.getComboText();
var s2 = s1.indexOf("|");
if (s1 == "") {
$("hd_comboSALE").value = "";
comboSALE.setComboText($("hd_comboSALE").value);
}
else {
if (s2 > 0) {
s2 = s2 + 2;
}
var s3 = s1.substring(s2);
if (s2 > 0) {
comboSALE.setComboText(s3);
$("hd_comboSALE").value = s3;
}
else {
comboSALE.setComboText($("hd_comboSALE").value);
}
}
});
comboSALE.setComboText($("hd_comboSALE").value);
comboSALE.attachEvent("onKeyPressed", function(keyCode) {
if (keyCode != "8") {
var arrayArg = new Array();
setTimeout(function() {
var filterCount = 0;
var is = -1;
var ishd = $("hd_comboSALE").value;
if ("" != comboSALE.getComboText()) {
while ("undefined" != typeof comboSALE.getOptionByIndex(filterCount)) {
var comboValue = comboSALE.getOptionByIndex(filterCount).text.toUpperCase(); //.value;
var enterValue = comboSALE.getComboText().toUpperCase();
$("hd_comboSALE").value = comboSALE.getComboText().toUpperCase();
if (comboValue.indexOf(enterValue) == 0) {
comboSALE.selectOption(filterCount, true, true);
is = filterCount;
break;
}
++filterCount;
}
if (is == -1) {
$("hd_comboSALE").value = ishd;
alert("无此内容,请重新选择!");
}
}
}, 10);
}
});
comboSALE.attachEvent("onSelectionChange", function() {
$("hd_comboSALE").value = comboSALE.getComboText();
});
}
function initComboPORTLOAD()//启运港==装货港
{
comboPORTLOAD = dhtmlXComboFromSelect("ddlPORTLOAD");
comboPORTLOAD.loadXML("../FeeCodes/TCodeLoadportAdapter.aspx?mask=0&pos=0");
}
function initComboPORTLOAD2()//启运港==装货港
{
if ($("hdEnabled").value == "0") {
comboPORTLOAD.disable(true);
}
//
comboPORTLOAD.setOptionWidth(200);
comboPORTLOAD.attachEvent("onChange", function() {
comboPORTLOAD.setComboText($("hd_comboPORTLOAD").value);
});
comboPORTLOAD.attachEvent("onBlur", function() {
comboPORTLOAD.setComboText($("hd_comboPORTLOAD").value);
});
comboPORTLOAD.setComboText($("hd_comboPORTLOAD").value);
comboPORTLOAD.attachEvent("onKeyPressed", function(keyCode) {
if (keyCode != "8") {
var arrayArg = new Array();
setTimeout(function() {
var filterCount = 0;
var is = -1;
var ishd = $("hd_comboPORTLOAD").value.trim();
if ("" != comboPORTLOAD.getComboText().trim()) {
while ("undefined" != typeof comboPORTLOAD.getOptionByIndex(filterCount)) {
var comboValue = comboPORTLOAD.getOptionByIndex(filterCount).text.toUpperCase(); //.value;
var enterValue = comboPORTLOAD.getComboText().trim().toUpperCase();
$("hd_comboPORTLOAD").value = comboPORTLOAD.getComboText().trim().toUpperCase();
if (comboValue.indexOf(enterValue) == 0) {
comboPORTLOAD.selectOption(filterCount, true, true);
is = filterCount;
break;
}
++filterCount;
}
if (is == -1) {
$("hd_comboPORTLOAD").value = ishd;
alert("无此内容,请重新选择!");
}
}
}, 10);
}
});
comboPORTLOAD.attachEvent("onSelectionChange", function() {
$("hd_comboPORTLOAD").value = comboPORTLOAD.getComboText().trim();
});
}
function initComboPORTDISCHARGE()//卸货港
{
comboPORTDISCHARGE = dhtmlXComboFromSelect("ddlPORTDISCHARGE");
}
function initComboPORTDISCHARGE2()//卸货港
{
if ($("hdEnabled").value == "0") {
comboPORTDISCHARGE.disable(true);
}
//
comboPORTDISCHARGE.setOptionWidth(200);
comboPORTDISCHARGE.attachEvent("onOpen", function() {
if (comboPORTDISCHARGE.getOptionByIndex(0) == null) {
comboPORTDISCHARGE.loadXML("../FeeCodes/TCodeDisportAdapter.aspx?mask=0&pos=0&strSel=");
}
});
comboPORTDISCHARGE.attachEvent("onChange", function() {
$("hd_comboPORTDISCHARGE").value = comboPORTDISCHARGE.getComboText().trim().toUpperCase(); //comboPORTDISCHARGE.getSelectedText();
comboPORTDISCHARGE.setComboText($("hd_comboPORTDISCHARGE").value);
});
comboPORTDISCHARGE.attachEvent("onBlur", function() {
comboPORTDISCHARGE.setComboText($("hd_comboPORTDISCHARGE").value);
});
comboPORTDISCHARGE.setComboText($("hd_comboPORTDISCHARGE").value);
//检索
//comboPORTDISCHARGE.enableFilteringMode(true);
comboPORTDISCHARGE.attachEvent("onKeyPressed", function(keyCode) {
var arrayArg = new Array();
setTimeout(function() {
var filterCount = 0;
if ("" != comboPORTDISCHARGE.getComboText().trim()) {
var enterValue = comboPORTDISCHARGE.getComboText().toUpperCase();
comboPORTDISCHARGE.loadXML("../FeeCodes/TCodeDisportAdapter.aspx?mask=0&pos=0&strSel=" + enterValue);
}
}, 10);
});
comboPORTDISCHARGE.attachEvent("onSelectionChange", function() {
$("hd_comboPORTDISCHARGE").value = comboPORTDISCHARGE.getComboText().trim();
});
}
function initComboENTREPORT()//中转港
{
comboENTREPORT = dhtmlXComboFromSelect("ddlENTREPORT");
}
function initComboENTREPORT2()//中转港
{
if ($("hdEnabled").value == "0") {
comboENTREPORT.disable(true);
}
//
comboENTREPORT.setOptionWidth(200);
comboENTREPORT.attachEvent("onOpen", function() {
if (comboENTREPORT.getOptionByIndex(0) == null) {
comboENTREPORT.loadXML("../FeeCodes/TCodeDisportAdapter.aspx?mask=0&pos=0&strSel=");
}
});
comboENTREPORT.attachEvent("onChange", function() {
$("hd_comboENTREPORT").value = comboENTREPORT.getComboText().trim().toUpperCase(); //comboENTREPORT.getSelectedText();
comboENTREPORT.setComboText($("hd_comboENTREPORT").value);
});
comboENTREPORT.attachEvent("onBlur", function() {
comboENTREPORT.setComboText($("hd_comboENTREPORT").value);
});
comboENTREPORT.setComboText($("hd_comboENTREPORT").value);
//检索
//comboENTREPORT.enableFilteringMode(true);
comboENTREPORT.attachEvent("onKeyPressed", function(keyCode) {
var arrayArg = new Array();
setTimeout(function() {
var filterCount = 0;
if ("" != comboENTREPORT.getComboText().trim()) {
var enterValue = comboENTREPORT.getComboText().toUpperCase();
comboENTREPORT.loadXML("../FeeCodes/TCodeDisportAdapter.aspx?mask=0&pos=0&strSel=" + enterValue);
}
}, 10);
});
comboENTREPORT.attachEvent("onSelectionChange", function() {
$("hd_comboENTREPORT").value = comboENTREPORT.getComboText().trim();
});
}
function initComboLANE()//航线
{
comboLANE = dhtmlXComboFromSelect("ddlLANE");
comboLANE.loadXML("../FeeCodes/TCodeLanesAdapter.aspx?mask=0&pos=0");
}
function initComboLANE3()//航线
{
comboLANE.loadXML("../FeeCodes/TCodeLanesAdapter.aspx?mask=0&pos=0");
}
function initComboLANE2()//航线
{
if ($("hdEnabled").value == "0") {
comboLANE.disable(true);
}
//
comboLANE.setOptionWidth(200);
comboLANE.attachEvent("onChange", function() {
comboLANE.setComboText($("hd_comboLANE").value);
});
comboLANE.attachEvent("onBlur", function() {
var s1 = comboLANE.getComboText().trim();
var s2 = s1.indexOf("|");
if (s1 == "") {
$("hd_comboLANE").value = "";
comboLANE.setComboText($("hd_comboLANE").value);
}
else {
if (s2 > 0) {
s2 = s2 + 2;
}
var s3 = s1.substring(s2);
if (s2 > 0) {
comboLANE.setComboText(s3);
$("hd_comboLANE").value = s3;
}
else {
comboLANE.setComboText($("hd_comboLANE").value);
}
}
});
comboLANE.setComboText($("hd_comboLANE").value);
comboLANE.attachEvent("onKeyPressed", function(keyCode) {
if (keyCode != "8") {
var arrayArg = new Array();
setTimeout(function() {
var filterCount = 0;
var is = -1;
var ishd = $("hd_comboLANE").value.trim();
if ("" != comboLANE.getComboText().trim()) {
while ("undefined" != typeof comboLANE.getOptionByIndex(filterCount)) {
var comboValue = comboLANE.getOptionByIndex(filterCount).text.toUpperCase(); //.value;
var enterValue = comboLANE.getComboText().trim().toUpperCase();
$("hd_comboLANE").value = comboLANE.getComboText().trim().toUpperCase();
if (comboValue.indexOf(enterValue) == 0) {
comboLANE.selectOption(filterCount, true, true);
is = filterCount;
break;
}
++filterCount;
}
if (is == -1) {
$("hd_comboLANE").value = ishd;
alert("无此内容,请重新选择!");
}
}
}, 10);
}
});
comboLANE.attachEvent("onSelectionChange", function() {
$("hd_comboLANE").value = comboLANE.getComboText().trim();
});
}
function initComboLANE()//航线
{
comboLANE = dhtmlXComboFromSelect("ddlLANE");
comboLANE.loadXML("../FeeCodes/TCodeLanesAdapter.aspx?mask=0&pos=0");
}
function initComboLANE3()//航线
{
comboLANE.loadXML("../FeeCodes/TCodeLanesAdapter.aspx?mask=0&pos=0");
}
function initComboLANE2()//航线
{
if ($("hdEnabled").value == "0") {
comboLANE.disable(true);
}
//
comboLANE.setOptionWidth(200);
comboLANE.attachEvent("onChange", function() {
comboLANE.setComboText($("hd_comboLANE").value);
});
comboLANE.attachEvent("onBlur", function() {
var s1 = comboLANE.getComboText().trim();
var s2 = s1.indexOf("|");
if (s1 == "") {
$("hd_comboLANE").value = "";
comboLANE.setComboText($("hd_comboLANE").value);
}
else {
if (s2 > 0) {
s2 = s2 + 2;
}
var s3 = s1.substring(s2);
if (s2 > 0) {
comboLANE.setComboText(s3);
$("hd_comboLANE").value = s3;
}
else {
comboLANE.setComboText($("hd_comboLANE").value);
}
}
});
comboLANE.setComboText($("hd_comboLANE").value);
comboLANE.attachEvent("onKeyPressed", function(keyCode) {
if (keyCode != "8") {
var arrayArg = new Array();
setTimeout(function() {
var filterCount = 0;
var is = -1;
var ishd = $("hd_comboLANE").value.trim();
if ("" != comboLANE.getComboText().trim()) {
while ("undefined" != typeof comboLANE.getOptionByIndex(filterCount)) {
var comboValue = comboLANE.getOptionByIndex(filterCount).text.toUpperCase(); //.value;
var enterValue = comboLANE.getComboText().trim().toUpperCase();
$("hd_comboLANE").value = comboLANE.getComboText().trim().toUpperCase();
if (comboValue.indexOf(enterValue) == 0) {
comboLANE.selectOption(filterCount, true, true);
is = filterCount;
break;
}
++filterCount;
}
if (is == -1) {
$("hd_comboLANE").value = ishd;
alert("无此内容,请重新选择!");
}
}
}, 10);
}
});
comboLANE.attachEvent("onSelectionChange", function() {
$("hd_comboLANE").value = comboLANE.getComboText().trim();
});
}
function initComboCARRIER()//船公司
{
comboCARRIER = dhtmlXComboFromSelect("ddlCARRIER");
comboCARRIER.loadXML("../FeeCodes/WebCrmClientAdapter.aspx?mask=0&pos=0&strIS=ISCARRIER");
}
function initComboCARRIER2()//船公司
{
if ($("hdEnabled").value == "0") {
comboCARRIER.disable(true);
}
//
comboCARRIER.setOptionWidth(200);
comboCARRIER.attachEvent("onChange", function() { comboCARRIER.setComboText($("hd_comboCARRIER").value); });
comboCARRIER.attachEvent("onBlur", function() {
var s1 = comboCARRIER.getComboText().trim();
var s2 = s1.indexOf("|");
if (s1 == "") {
$("hd_comboCARRIER").value = "";
comboCARRIER.setComboText($("hd_comboCARRIER").value);
}
else {
if (s2 > 0) {
s2 = s2 + 2;
}
var s3 = s1.substring(s2);
if (s2 > 0) {
comboCARRIER.setComboText(s3);
$("hd_comboCARRIER").value = s3;
}
else {
comboCARRIER.setComboText($("hd_comboCARRIER").value);
}
}
});
comboCARRIER.setComboText($("hd_comboCARRIER").value);
comboCARRIER.attachEvent("onKeyPressed", function(keyCode) {
if (keyCode != "8") {
var arrayArg = new Array();
setTimeout(function() {
var is = -1;
var ishd = $("hd_comboCARRIER").value.trim();
var filterCount = 0;
if ("" != comboCARRIER.getComboText().trim()) {
while ("undefined" != typeof comboCARRIER.getOptionByIndex(filterCount)) {
var comboValue = comboCARRIER.getOptionByIndex(filterCount).text.toUpperCase(); //.value;
var enterValue = comboCARRIER.getComboText().trim().toUpperCase();
$("hd_comboCARRIER").value = comboCARRIER.getComboText().trim().toUpperCase();
if (comboValue.indexOf(enterValue) == 0) {
comboCARRIER.selectOption(filterCount, true, true);
is = filterCount;
break;
}
++filterCount;
}
if (is == -1) {
$("hd_comboCARRIER").value = ishd;
alert("无此内容,请重新选择!");
}
}
}, 10);
}
});
comboCARRIER.attachEvent("onSelectionChange", function() {
$("hd_comboCARRIER").value = comboCARRIER.getComboText().trim();
});
}
function printAction() {
var strBSNO = "";
strBSNO = $("hdGID").value;
var printUrl = "";
var companyID = "";
var typeName = "QuotationReport";
var dbSourceID = "";
var userID = "";
var url = "../Reports/ReportService.aspx?handle=printquotation&bsno=" + strBSNO + "&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+"&uid="+userID;//alert(printUrl);
window.location.href = window.location.href;
location.href = printUrl;
}
}else{
alert("没有要打印的报表");
return;
}
}
function setWEEK() {
var sdate = $("tbETD").value.trim();
//判断日期是否正确
var bl = verifyDate(sdate);
if (bl) {
//var year = 2011, month = 6, date = 23;
// month=6表示7月
var sdate = $("tbETD").value;
var irqI = sdate.indexOf("-");
var irqL = sdate.lastIndexOf("-");
var syear = sdate.substr(0, irqI);
var smonth = sdate.substr(irqI + 1, irqL - irqI - 1);
var sday = sdate.substr(irqL + 1);
smonth = parseInt(smonth, 10) - 1;
var dt = new Date(syear, smonth, sday);
var weekDay = ["星期天", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"];
var sdkj = weekDay[dt.getDay()];
$("lbWEEK").value = sdkj;
}
}