var mygrid_recv; var mygrid_pay; var page_count = 5; var column_count; var jsonFeeObj; var jsonPayObj; var changeCount = 0; var authoriyStatus; var changeFeeRecvCount = 0; var changeFeePayCount = 0; var newFeeRecvCount = 0; var newFeePayCount = 0; var recv_menu; var pay_menu; var stroplb=""; var wmsoutbsno=""; var cknum=0;//出库数量 var RowOutBsno="";//wms_out.bsno var pressRecord; var quantityVal; var quantityObj; function $(id){ return document.getElementById(id); } function document.onkeydown(){ if(event.keyCode == 8){ if(document.selection){ var range = document.selection.createRange(); if(range.parentElement().name == null){ return false; return true; }else{ } } } } function initGrid(){ stroplb = $("h_oplb").value; //wmsoutbsno =$("h_wmsoutbsno").value; wmsoutbsno = $("h_outgid").value; doInitRecvGrid(); // setTimeout(doInitPayGrid,200); // setTimeout(totalDynamicFeeGain,700); // setTimeout(doInitPayGrid,100000); } function clickNull(){} function doInitRecvGrid(){ enableAction(); mygrid_recv = new dhtmlXGridObject('mygrid_container_recv'); mygrid_recv.setImagePath("../images/"); mygrid_recv.setSkin("xp"); // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 mygrid_recv.setHeader(",费用状态,应收费用名称,结算单位,计费标准,单价,数量,佣金比例,金额,币别,汇率,FRT,费用备注,是否垫付,结算金额,开票金额,发票号码,录入人,录入时间,TID,WMSOUTBSNO,行号"); mygrid_recv.setInitWidths("40,70,110,150,70,80,80,90,90,50,70,70,250,70,70,70,120,80,120,0,0,0"); mygrid_recv.setColAlign("center,center,right,right,right,right,right,right,right,right,right,right,center,center,center,center,center,center,center,center,center,center"); // mygrid_recv.setSkin("light"); mygrid_recv.setColSorting("na,str,str,str,int,int,int,int,int,int,int,int,int,str,int,int,str,str,str,str,str,str"); mygrid_recv.setColTypes("ch,ro,co,co,co,ed,ed,ed,ed,co,ed,co,ed,ch,ro,ro,ro,ro,ro,ro,ro,ro"); var bsno = $("h_bsno").value; //判断委托单有无应收费用 var urlVal = "../Shipping/feegridsource.aspx?type=1&read=exist&showcount=1&oplb="+stroplb+"&wmsoutbsno="+wmsoutbsno+"&bsno="+bsno+"&val="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; loader = null; if(parseInt(loadVal) == 1){ //获取应收费用信息,初始化grid mygrid_recv.loadXML("../Shipping/feegridsource.aspx?type=1&read=init&showcount=1&oplb="+stroplb+"&wmsoutbsno="+wmsoutbsno+"&bsno="+bsno,function(){ ReShowLabel(mygrid_recv); doInitPayGrid(); // finishLoading(); }); }else{ doInitPayGrid(); } mygrid_recv.init(); mygrid_recv.enableEditEvents(true,false,true); mygrid_recv.enableKeyboardSupport(true); setTimeout(function(){ //initLoading(); //调用缓存信息 var cacheTemplate = $("h_cachetemplate").value; var importType = parseInt($("h_importtype").value); if(cacheTemplate != ""){ var jsonCacheObj = null; jsonCacheObj = eval('(' + cacheTemplate + ')'); var delAry = new Array(); for(var i=0;i 0){ if(quantityObj.quantity[0].value > 0){ mygrid_recv.cellByIndex(rowIndex,4).setValue(quantityObj.quantity[0].name); mygrid_recv.cellByIndex(rowIndex,6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); //计算应收费用“金额” var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString())); } } }else{ //mygrid_recv.cellByIndex(rowIndex,4).setValue(""); mygrid_recv.cellByIndex(rowIndex,6).setValue(1); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue()))); var quantityCount = 1; var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString())); } }else{ var quantityObj = null; //unit转换汉字标识 cknum=mygrid_recv.cellByIndex(rowIndex,6).getValue(); quantityObj = getTypeNameQuantity(unit,cknum); if(quantityObj.quantity.length > 0){ if(quantityObj.quantity[0].value > 0){ //获取委托(op_seai)费用计费标准信息,返回JSON数据 mygrid_recv.cellByIndex(rowIndex,4).setValue(quantityObj.quantity[0].name); mygrid_recv.cellByIndex(rowIndex,6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString())); }else{ //mygrid_recv.cellByIndex(rowIndex,4).setValue(""); if(getTypeNum(unit) >= 1){ mygrid_recv.cellByIndex(rowIndex,6).setValue(0); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue()))); var quantityCount = 0;//clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString())); }else{ delAry.push(rId); alert("请先录入委托的对应箱型,在引入计费标准是箱型的费用!"); //mygrid_recv.deleteRow(rId);rowCount = 0; } } } } } //结算单位设置 (备注:debit应收金额) if(feeCodeObj.feecode[0].debit > 0){ var debitObj = null; //获取委托信息(op_seae)默认收费客户信息,返回JSON数据源 debitObj = getDebitType(feeCodeObj.feecode[0].debit); if(debitObj.debit.length > 0){ if(debitObj.debit[0].value.trim() != ""){ //mygrid_recv.cellByIndex(rowIndex,3).setLabel(debitObj.debit[0].value); if(customerName.trim() != ""){ mygrid_recv.cellByIndex(rowIndex,3).setValue(customerName.trim()); }else{ mygrid_recv.cellByIndex(rowIndex,3).setValue(debitObj.debit[0].value); } } } } if(delAry.length > 0){ for(var k=0;k 0){ if(quantityObj.quantity[0].value > 0){ mygrid_recv.cellByIndex(rowIndex,4).setValue(quantityObj.quantity[0].name); mygrid_recv.cellByIndex(rowIndex,6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString())); } } }else{ //mygrid_recv.cellByIndex(rowIndex,4).setValue(""); mygrid_recv.cellByIndex(rowIndex,6).setValue(1); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue()))); var quantityCount = 1; var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString())); } }else{ var quantityObj = null; cknum=mygrid_recv.cellByIndex(rowIndex,6).getValue(); quantityObj = getTypeNameQuantity(unit,cknum); if(quantityObj.quantity.length > 0){ if(quantityObj.quantity[0].value > 0){ mygrid_recv.cellByIndex(rowIndex,4).setValue(quantityObj.quantity[0].name); mygrid_recv.cellByIndex(rowIndex,6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString())); }else{ //mygrid_recv.cellByIndex(rowIndex,4).setValue(""); if(getTypeNum(unit) >= 1){ mygrid_recv.cellByIndex(rowIndex,6).setValue(0); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue()))); var quantityCount = 0;//clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString())); }else{ //delAry.push(rId); //mygrid_recv.deleteRow(rId);rowCount = 0; } } } } } if(feeCodeObj.feecode[0].debit > 0){ var debitObj = null; debitObj = getDebitType(feeCodeObj.feecode[0].debit); if(debitObj.debit.length > 0){ if(debitObj.debit[0].value.trim() != ""){ //mygrid_recv.cellByIndex(rowIndex,3).setLabel(debitObj.debit[0].value); if(opType == 1){ mygrid_recv.cellByIndex(rowIndex,3).setValue(customerName.trim()); }else{ mygrid_recv.cellByIndex(rowIndex,3).setValue(debitObj.debit[0].value); } } } } ReShowLabel(mygrid_recv); //totalDynamicFeeGain(); } } } } } } //finishLoading(); },240); var pushVal = ""; var pressRecord = ""; var pressRowIndex = -1; var pressCellIndex = -1; var pressCount = 0; var isExchange = false; var shiftCount = 0; var isDelete = 0; var flagFilter = 0; var flagTab = 0; var flagEnter = 0; var flagDelete = 0; mygrid_recv.attachEvent("onSelectStateChanged", function(id){ RowOutBsno=mygrid_recv.cellById(id,20).getValue(); if($("h_enable").value == "1"){ var rowIndex = mygrid_recv.getRowIndex(id); if(rowIndex >= 0){ var stateVal = mygrid_recv.cellByIndex(rowIndex,1).getValue().trim(); if(stateVal == "录入状态"|| stateVal == "驳回提交"){ var combo_currency; combo_currency = mygrid_recv.getCustomCombo(id,9); if(combo_currency.getKeys.length <= 1){ setCurrencyCombo(combo_currency); } var combo_feename; combo_feename = mygrid_recv.getCustomCombo(id,2); if(combo_feename.getKeys.length <= 1){ setFeeNameCombo(combo_feename); } var combo_cust; combo_cust = mygrid_recv.getCustomCombo(id,3); if(combo_cust.getKeys.length <= 1){ setCustomerCombo(combo_cust,id); } var combo_unit; combo_unit = mygrid_recv.getCustomCombo(id,4); if(combo_unit.getKeys.length <= 1){ setUnitCombo(combo_unit); } var combo_frt; combo_frt = mygrid_recv.getCustomCombo(id,11); if(combo_frt.getKeys.length <= 1){ setFrtCombo(combo_frt); } return true; }else{ return false; } } } }); //手动编写Grid控件编辑事件,由于免费控件没有提供完整的编辑判断功能,现特此做更改 mygrid_recv.attachEvent("onEditCell", function (stage, rId, cInd, nValue, oValue) { RowOutBsno = mygrid_recv.cellById(rId, 20).getValue(); var newCheckValue = false; //初始化状态 if (stage == 0) { var rowIndex = mygrid_recv.getRowIndex(rId); var oldVal = mygrid_recv.cellByIndex(rowIndex, 1).getValue().trim(); if (oldVal == "录入状态" || oldVal == "驳回提交") { if ($("h_enable").value == "0") { if (cInd == 0) { //if(parseInt($("h_recvauthority").value) > 0){ //检查用户的模块权限信息 if (validOperatePower(rId, 1)) { return true; } else { alert("对不起,你没有此权限"); return false; } } return false; } else { if (validOperatePower(rId, 1)) { return true; } else { alert("对不起,你没有此权限"); return false; } } } else { if (validOperatePower(rId, 1)) { if (cInd == 0) { return true; } else { alert("对不起,你没有此权限"); return false; } } else { alert("对不起,你没有此权限"); return false; } } } if (stage == 1) { var selectedId = mygrid_recv.getSelectedRowId(); var rowIndex = mygrid_recv.getRowIndex(selectedId); for (var i = 0; i < document.all.length; i++) { if (document.all(i).tagName == "TEXTAREA") { txtEdit = document.all(i); txtEdit.focus(); txtEdit.select(); break; } } } //如果编辑结束 if (stage == 2) { if (oValue == null || oValue == "" || oValue == "0") { if (cInd != 5 && cInd != 6 && cInd != 8) { if (nValue == null || nValue == "" || nValue == "0") { return true; } } } changeFeeRecvCount++; if (cInd == 5) { var rowIndex = mygrid_recv.getRowIndex(rId); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 6).getValue()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex, 5).setValue(outputMoney(unitPrice.toString())); //mygrid_recv.cellByIndex(rowIndex,6).setValue(outputMoney(quantityCount.toString())); mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); //totalDynamicFeeGain(); return true; } else if (cInd == 6) { var rowIndex = mygrid_recv.getRowIndex(rId); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 6).getValue()))); var amount = unitPrice * quantityCount; //mygrid_recv.cellByIndex(rowIndex,5).setValue(outputMoney(unitPrice.toString())); var dd = outputMoney(quantityCount.toString()); mygrid_recv.cellByIndex(rowIndex, 6).setValue(outputMoney(quantityCount.toString())); mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); //totalDynamicFeeGain(); return true; } else if (cInd == 8) { var rowIndex = mygrid_recv.getRowIndex(rId); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 6).getValue()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); //totalDynamicFeeGain(); return true; } else if (cInd == 9) { var rowIndex = mygrid_recv.getRowIndex(rId); //filterComboCustomerPress(mygrid_recv,rId,rowIndex,9,nValue,oValue); var curValue = mygrid_recv.cellByIndex(rowIndex, 9).getValue(); //alert(curValue); //获取海运进口委托(op_seai)费用1汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1¤cy=" + curValue + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; mygrid_recv.cellByIndex(rowIndex, 10).setValue(loadVal); //totalDynamicFeeGain(); loader == null; return true; } else if (cInd == 10) { var rowIndex = mygrid_recv.getRowIndex(rId); var currency = mygrid_recv.cellByIndex(rowIndex, 9).getValue(); var rate = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 10).getValue()))); if (currency == "RMB") { if (rate != 1) { return false; } } else if (currency == "USD") { if (rate <= 1) { return false; } } //totalDynamicFeeGain(); return true; } else if (cInd == 4) { var rowIndex = mygrid_recv.getRowIndex(rId); var unitVal = mygrid_recv.cellByIndex(rowIndex, 4).getValue(); cknum = mygrid_recv.cellByIndex(rowIndex, 6).getValue(); var quantityObj = null; quantityObj = getTypeNameQuantity(unitVal, cknum); if (quantityObj.quantity.length > 0) { if (quantityObj.quantity[0].value > 0) { mygrid_recv.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name); mygrid_recv.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } else { //mygrid_recv.cellByIndex(rowIndex,4).setValue(""); mygrid_recv.cellByIndex(rowIndex, 6).setValue(1); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = 1; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } } //重新计算利润 //totalDynamicFeeGain(); return true; } else if (cInd == 2 || cInd == 3) { var rowIndex = mygrid_recv.getRowIndex(rId); if (pressCount == 1) { if (flagFilter == 1) { //mygrid_recv.editStop(); mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(oValue); //alert(oValue); //alert(mygrid_recv.cellByIndex(rowIndex,cInd).getValue()); return true; } else { //if(pressRowIndex == rowIndex && pressCellIndex == cInd){ var cellVal = mygrid_recv.cellByIndex(rowIndex, cInd).getValue(); var combo = mygrid_recv.getCustomCombo(rId, cInd); var comboArg = combo.getKeys(); // var tempCount = 0; if (cellVal.indexOf(" ") > 0 && cellVal.indexOf(" ") < cellVal.length) { cellVal = cellVal.substring(0, cellVal.indexOf(" ")); for (var i = 0; i < comboArg.length; i++) { 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) { var fgff = combo.get(comboArg[i]).trim().indexOf(cellVal); if (combo.get(comboArg[i]).trim().indexOf(cellVal) >= 0) { mygrid_recv.cellByIndex(rowIndex, cInd).setValue(comboArg[i]); mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]); tempCount++; break; } } } } //alert(tempCount) if (tempCount == 0) { mygrid_recv.cellByIndex(rowIndex, cInd).setValue(""); mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(""); } isExchange = false; pressRecord = ""; pressRowIndex = -1; pressCellIndex = -1; pressCount = 0; flagFilter = 0; //totalDynamicFeeGain(); return true; } } else if (pressCount == 2) { if (flagFilter == 1) { mygrid_recv.editStop(); mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(oValue); } else { if (pressRowIndex != rowIndex && pressCellIndex != cInd) { //alert(mygrid_recv.cellByIndex(rowIndex,cInd).getValue()); return true; } else { isExchange = false; pressRecord = ""; pressRowIndex = -1; pressCellIndex = -1; pressCount = 0; flagFilter = 0; var cellVal = mygrid_recv.cellByIndex(rowIndex, cInd).getValue().trim(); var combo = mygrid_recv.getCustomCombo(rId, cInd); var comboArg = combo.getKeys(); // var tempCount = 0; if (cellVal.indexOf(" ") > 0 && cellVal.indexOf(" ") < cellVal.length) { cellVal = cellVal.substring(0, cellVal.indexOf(" ")); for (var i = 0; i < comboArg.length; i++) { if (combo.get(comboArg[i]).trim().indexOf(cellVal) == 0) { mygrid_recv.cellByIndex(rowIndex, cInd).setValue(comboArg[i]); mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]); tempCount++; break; } } } if (tempCount == 0) { mygrid_recv.cellByIndex(rowIndex, cInd).setValue(""); mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(""); } //alert(mygrid_recv.cellByIndex(rowIndex,cInd).getValue()); return true; } } } else { var cellVal = mygrid_recv.cellByIndex(rowIndex, cInd).getValue(); var combo = mygrid_recv.getCustomCombo(rId, cInd); var comboArg = combo.getKeys(); var tempCount = 0; if (cellVal.indexOf(" ") > 0 && cellVal.indexOf(" ") < cellVal.length) { cellVal = cellVal.substring(0, cellVal.indexOf(" ")); for (var i = 0; i < comboArg.length; i++) { if (combo.get(comboArg[i]).trim().indexOf(cellVal) == 0) { mygrid_recv.cellByIndex(rowIndex, cInd).setValue(comboArg[i]); mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]); tempCount++; break; } } } else { for (var i = 0; i < comboArg.length; i++) { if (combo.get(comboArg[i]).trim().indexOf(cellVal) == 0 || comboArg[i].toString().trim().indexOf(cellVal) == 0) { mygrid_recv.cellByIndex(rowIndex, cInd).setValue(comboArg[i]); mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]); tempCount++; break; } } } if (tempCount == 0) { mygrid_recv.cellByIndex(rowIndex, cInd).setValue(""); mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(""); } // if (cInd == 2) { var url = ""; var feeCodeObj = null; var feeName = mygrid_recv.cellByIndex(rowIndex, 2).getValue().trim(); if (feeName != "") { //通过费用名称获取费用代码表(code_fee)币别汇率信息 url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb=" + stroplb + "&feename=" + escape(feeName) + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(url); var feeCodeInfo = loader.xmlDoc.responseText; feeCodeObj = eval('(' + feeCodeInfo + ')'); if (feeCodeObj.feecode.length > 0) { if (feeCodeObj.feecode[0].cur.trim() != "") { mygrid_recv.cellByIndex(rowIndex, 9).setValue(feeCodeObj.feecode[0].cur); //获取委托(op_seai)费用1汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1¤cy=" + feeCodeObj.feecode[0].cur + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; mygrid_recv.cellByIndex(rowIndex, 10).setValue(loadVal); if (feeCodeObj.feecode[0].unit != 0) { quantityObj = getUnitType(feeCodeObj.feecode[0].unit); if (quantityObj.quantity.length > 0) { if (quantityObj.quantity[0].value > 0) { mygrid_recv.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name); mygrid_recv.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } } } else { //mygrid_recv.cellByIndex(rowIndex,4).setValue(""); mygrid_recv.cellByIndex(rowIndex, 6).setValue(1); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = 1; var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } } if (feeCodeObj.feecode[0].debit > 0) { var debitObj = null; debitObj = getDebitType(feeCodeObj.feecode[0].debit); if (debitObj.debit.length > 0) { if (debitObj.debit[0].value.trim() != "") { //mygrid_recv.cellByIndex(rowIndex,3).setLabel(debitObj.debit[0].value); mygrid_recv.cellByIndex(rowIndex, 3).setValue(debitObj.debit[0].value); } } } ReShowLabel(mygrid_recv); } } } //totalDynamicFeeGain(); return true; } } else { return true; } } else { return true; } }); mygrid_recv.attachEvent("onSelectStateChanged", function(id){ RowOutBsno=mygrid_recv.cellById(id,20).getValue(); var rowIndex = mygrid_recv.getRowIndex(id); var checkState = mygrid_recv.cellByIndex(rowIndex,0).getValue(); if(checkState == 0){ if(!validOperatePower(id,1,"select")){ alert("权限不足,请重新选择"); return; } //mygrid_recv.cellByIndex(rowIndex,0).setValue(1); }else{ //mygrid_recv.cellByIndex(rowIndex,0).setValue(0); } }); //键盘操作事件 mygrid_recv.attachEvent("onKeyPress", function (code, cFlag, sFlag) { //onKeyPress begin //获取当前RowID var selectedId = mygrid_recv.getSelectedRowId(); //获取当前RowIndex var rowIndex = mygrid_recv.getRowIndex(selectedId); //获取当前CellIndex(ind) var ind = mygrid_recv.getSelectedCellIndex(); RowOutBsno = mygrid_recv.cellById(selectedId, 20).getValue(); //触发操作事件前获取单元值 var oldVal = mygrid_recv.cellByIndex(rowIndex, ind).getValue(); //获取编辑单元 var txtEdit; for (i = 0; i < document.all.length; i++) { if (document.all(i).tagName == "TEXTAREA") { txtEdit = document.all(i); oldVal = txtEdit.innerHTML; break; } } if (code == 13) { //Enter键 if (ind == 5) { //var rowIndex = mygrid_recv.getRowIndex(selectedId); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 6).getValue()))); var amount = unitPrice * quantityCount; //mygrid_recv.cellByIndex(rowIndex,5).setValue(outputMoney(unitPrice.toString())); mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); //totalDynamicFeeGain(); return true; } if (ind == 2 || ind == 3 || ind == 4 || ind == 9 || ind == 11) { //如果是检索失败, if (pressCount == 2) { mygrid_recv.editStop(); //将value写入cell(触发 stage2) mygrid_recv.cellByIndex(rowIndex, ind).setValue(oldVal); //重新打开cell(触发stage0 stage1) mygrid_recv.selectCell(rowIndex, ind, true, true); mygrid_recv.cellByIndex(rowIndex, ind).setLabel(oldVal); mygrid_recv.editCell(); return true; } else { var combo = mygrid_recv.getCustomCombo(selectedId, ind); var comboArg = combo.getKeys(); var tempCount = 0; for (var i = 0; i < comboArg.length; i++) { if (combo.get(comboArg[i]).toLowerCase().trim().indexOf(oldVal) == 0) { var oldVal = comboArg[i]; var oldLab = combo.get(comboArg[i]); //记录状态值 检索到数据项 pressCount = 1; flagFilter = 1; tempCount++; ; //关闭编辑 //mygrid_recv.editStop(); //将value写入cell(触发 stage2) mygrid_recv.cellByIndex(rowIndex, ind).setValue(oldVal); mygrid_recv.cellByIndex(rowIndex, ind).setLabel(oldLab); flagFilter = 0; //重新打开cell(触发stage0 stage1) mygrid_recv.selectCell(rowIndex, ind, true, true); mygrid_recv.editCell(); break; } } // if (tempCount == 0) { mygrid_recv.cellByIndex(rowIndex, ind).setValue(""); mygrid_recv.cellByIndex(rowIndex, ind).setLabel(""); } } if (ind == 2) { var url = ""; var feeCodeObj = null; var feeName = mygrid_recv.cellByIndex(rowIndex, 2).getValue().trim(); if (feeName != "") { //通过费用名称获取费用代码表(code_fee)币别汇率信息 url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb=" + stroplb + "&feename=" + escape(feeName) + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(url); var feeCodeInfo = loader.xmlDoc.responseText; feeCodeObj = eval('(' + feeCodeInfo + ')'); if (feeCodeObj.feecode.length > 0) { if (feeCodeObj.feecode[0].cur.trim() != "") { mygrid_recv.cellByIndex(rowIndex, 9).setValue(feeCodeObj.feecode[0].cur); //获取海运出口委托(op_seai)费用汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1¤cy=" + feeCodeObj.feecode[0].cur + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; mygrid_recv.cellByIndex(rowIndex, 10).setValue(loadVal); if (feeCodeObj.feecode[0].unit != 0) { quantityObj = getUnitType(feeCodeObj.feecode[0].unit); if (quantityObj.quantity.length > 0) { if (quantityObj.quantity[0].value > 0) { mygrid_recv.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name); mygrid_recv.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } } } else { //mygrid_recv.cellByIndex(rowIndex,4).setValue(""); mygrid_recv.cellByIndex(rowIndex, 6).setValue(1); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = 1; var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } } if (feeCodeObj.feecode[0].debit > 0) { var debitObj = null; debitObj = getDebitType(feeCodeObj.feecode[0].debit); if (debitObj.debit.length > 0) { if (debitObj.debit[0].value.trim() != "") { //mygrid_recv.cellByIndex(rowIndex,2).setLabel(debitObj.debit[0].value); mygrid_recv.cellByIndex(rowIndex, 3).setValue(debitObj.debit[0].value); } } } ReShowLabelForEnter(mygrid_recv); } } //totalDynamicFeeGain(); return true; } return true; } else { return true; } } else if (code == 9) {//Tab键 //code9 begin var colCount = mygrid_recv.getColumnsNum(); var rowCount = mygrid_recv.getRowsNum(); if (ind < colCount) { isExchange = false; pressRecord = ""; pressRowIndex = -1; pressCellIndex = -1; mygrid_recv.editStop(true); mygrid_recv.cellByIndex(rowIndex, ind).setLabel(oldVal); var cInd = ind; var rId = selectedId; if (cInd == 5) { mygrid_recv.cellByIndex(rowIndex, ind).setLabel(oldVal); var rowIndex = mygrid_recv.getRowIndex(rId); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 6).getValue()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex, 5).setValue(outputMoney(unitPrice.toString())); mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); //totalDynamicFeeGain(); } else if (cInd == 6) { var rowIndex = mygrid_recv.getRowIndex(rId); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 6).getValue()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex, 6).setValue(outputMoney(quantityCount.toString())); mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); //totalDynamicFeeGain(); } else if (cInd == 9) { var rowIndex = mygrid_recv.getRowIndex(rId); var curValue = mygrid_recv.cellByIndex(rowIndex, 9).getValue(); //获取海运出口委托(op_seai)费用汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1¤cy=" + curValue + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; mygrid_recv.cellByIndex(rowIndex, 10).setValue(loadVal); //totalDynamicFeeGain(); loader == null; } else if (cInd == 12) { mygrid_recv.cellByIndex(rowIndex, 12).setValue(oldVal); } else if (cInd == 4 || cInd == 9 || cInd == 11) { var combo = mygrid_recv.getCustomCombo(rId, cInd); var comboArg = combo.getKeys(); var tempCount = 0; for (var i = 0; i < comboArg.length; i++) { if (combo.get(comboArg[i]).toUpperCase().trim().indexOf(oldVal) == 0) { var oldVal = comboArg[i]; var oldLab = combo.get(comboArg[i]); //记录状态值 检索到数据项 pressCount = 1; flagFilter = 1; tempCount++; ; //关闭编辑 //mygrid_recv.editStop(); //将value写入cell(触发 stage2) mygrid_recv.cellByIndex(rowIndex, cInd).setValue(oldVal); mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(oldLab); flagFilter = 0; //重新打开cell(触发stage0 stage1) mygrid_recv.selectCell(rowIndex, cInd, true, true); mygrid_recv.editCell(); break; } } if (tempCount == 0) { mygrid_recv.cellByIndex(rowIndex, cInd).setValue(""); mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(""); } } else if (cInd == 2 || cInd == 3) { var combo = mygrid_recv.getCustomCombo(rId, cInd); var comboArg = combo.getKeys(); var tempCount = 0; for (var i = 0; i < comboArg.length; i++) { if (combo.get(comboArg[i]).toLowerCase().trim().indexOf(oldVal) == 0) { var oldVal = comboArg[i]; var oldLab = combo.get(comboArg[i]); //记录状态值 检索到数据项 pressCount = 1; flagFilter = 1; tempCount++; ; //关闭编辑 //mygrid_recv.editStop(); //将value写入cell(触发 stage2) mygrid_recv.cellByIndex(rowIndex, cInd).setValue(oldVal); mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(oldLab); flagFilter = 0; //重新打开cell(触发stage0 stage1) mygrid_recv.selectCell(rowIndex, cInd, true, true); mygrid_recv.editCell(); break; } } if (tempCount == 0) { mygrid_recv.cellByIndex(rowIndex, cInd).setValue(""); mygrid_recv.cellByIndex(rowIndex, cInd).setLabel(""); } // var url = ""; var feeCodeObj = null; if (cInd == 2) { var feeName = mygrid_recv.cellByIndex(rowIndex, 2).getValue().trim(); if (feeName != "") { //通过费用名称获取费用代码表(code_fee)币别汇率信息 url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb=" + stroplb + "&feename=" + escape(feeName) + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(url); var feeCodeInfo = loader.xmlDoc.responseText; feeCodeObj = eval('(' + feeCodeInfo + ')'); if (feeCodeObj.feecode.length > 0) { mygrid_recv.cellByIndex(rowIndex, 9).setValue(feeCodeObj.feecode[0].cur); //获取海运出口委托(op_seai)费用汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1¤cy=" + feeCodeObj.feecode[0].cur + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; mygrid_recv.cellByIndex(rowIndex, 10).setValue(loadVal); if (feeCodeObj.feecode[0].unit != 0) { quantityObj = getUnitType(feeCodeObj.feecode[0].unit); if (quantityObj.quantity.length > 0) { if (quantityObj.quantity[0].value > 0) { mygrid_recv.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name); mygrid_recv.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex, 7).setValue(outputMoney(amount.toString())); } } } else { //mygrid_recv.cellByIndex(rowIndex,4).setValue(""); mygrid_recv.cellByIndex(rowIndex, 6).setValue(1); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = 1; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } //totalDynamicFeeGain(); if (feeCodeObj.feecode[0].debit > 0) { var debitObj = null; debitObj = getDebitType(feeCodeObj.feecode[0].debit); if (debitObj.debit.length > 0) { if (debitObj.debit[0].value.trim() != "") { //mygrid_recv.cellByIndex(rowIndex,3).setLabel(debitObj.debit[0].value); mygrid_recv.cellByIndex(rowIndex, 3).setValue(debitObj.debit[0].value); } } } } } } } //end mygrid_recv.selectCell(rowIndex, ind + 1, true, true); mygrid_recv.editCell(); if (ind == colCount - 2) { if (rowIndex < rowCount) { mygrid_recv.editStop(true); mygrid_recv.clearSelection(); mygrid_recv.selectCell(rowIndex + 1, 1, true, true); mygrid_recv.editCell(); } else { return; } } } //cdoe9 end } else if ((code >= 65 && code <= 90) || (code >= 48 && code <= 57) || (code >= 96 && code <= 105)) {//如果是输入英文字符 if (ind == 2 || ind == 3 || ind == 4 || ind == 11 || ind == 12) { return true; } if ((code >= 48 && code <= 57) || (code >= 96 && code <= 105)) { if (ind == 5 || ind == 6 || ind == 7 || ind == 10 || ind == 12) { return true; } } } //delete else if (code == 8) { //code8 begin if (ind == 2 || ind == 3 || ind == 4 || ind == 9 || ind == 11) { var start = 0; var end = 0; if (document.selection) { var range = document.selection.createRange(); if (range.parentElement().className == txtEdit.className) { var range_all = document.body.createTextRange(); range_all.moveToElementText(txtEdit); for (start = 0; range_all.compareEndPoints("StartToStart", range) < 0; start++) { range_all.moveStart('character', 1); } for (var i = 0; i <= start; i++) { if (txtEdit.value.charAt(i) == '\n') start++; } var range_all = document.body.createTextRange(); range_all.moveToElementText(txtEdit); for (end = 0; range_all.compareEndPoints('StartToEnd', range) < 0; end++) range_all.moveStart('character', 1); for (var i = 0; i <= end; i++) { if (txtEdit.value.charAt(i) == '\n') end++; } } } // alert(start);alert(end); //未选中多个字符 if (start == end) { if (pressRecord != null) { if (start != 0) { var firstVal = pressRecord.substring(0, start - 1); var endVal = pressRecord.substring(start + 1, txtEdit.value.length - 1); pressRecord = firstVal; } } } //选中多个字符 if (start != end) { if (pressRecord != null) { var firstVal = pressRecord.substring(0, start); var endVal = pressRecord.substring(end - 1, txtEdit.value.length - 1); pressRecord = firstVal + endVal; } } setTimeout(function () { if (pressRecord != null) { if (pressRecord.trim().length > 0) { var combo = mygrid_recv.getCustomCombo(selectedId, ind); var comboArg = combo.getKeys(); var count = 0; for (var i = 0; i < comboArg.length; i++) { if (combo.get(comboArg[i]).toLowerCase().trim().indexOf(pressRecord) == 0) { count++; var oldVal = comboArg[i]; var oldLab = combo.get(comboArg[i]); pressCount = 3; mygrid_recv.editStop(); mygrid_recv.cellByIndex(rowIndex, ind).setValue(oldVal); mygrid_recv.selectCell(rowIndex, ind, true, true); mygrid_recv.editCell(); var old_length = oldLab.length; for (i = 0; i < document.all.length; i++) { if (document.all(i).tagName == "TEXTAREA") { txtEdit = document.all(i); var rt = txtEdit.createTextRange(); rt.collapse(); rt.select(); //光标置最前 var r = document.selection.createRange(); r.collapse(false); r.moveStart("character", pressRecord.length); //从m位开始 r.moveEnd("character", old_length); //选取n位 //txtEdit.focus(); r.select(); } } break; } } } } }, 1000); return true; } else { return true; } //code8 end } //向下方向键 else if (code == 40) { //code40 begin if (ind == 1 || ind == 13 || ind == 5 || ind == 6 || ind == 7 || ind == 8 || ind == 10) { var rowCount = mygrid_recv.getRowsNum(); mygrid_recv.clearSelection(); mygrid_recv.editStop(); if (rowIndex == (rowCount - 1)) { addRecvRow(); } else { mygrid_recv.selectCell(rowIndex + 1, 2, true, true); mygrid_recv.editCell(); } } else { pressCount = 0; return true; } //code40 end } //向上箭头 else if (code == 38) { //code38 begin if (ind == 1 || ind == 13 || ind == 5 || ind == 6 || ind == 7 || ind == 8 || ind == 10) { if (rowIndex > 0) { mygrid_recv.clearSelection(); mygrid_recv.editStop(); mygrid_recv.selectCell(rowIndex - 1, 1, true, true); mygrid_recv.editCell(); var rowfeename = mygrid_recv.cellByIndex(rowIndex, 5).getValue(); if (rowfeename == 0) { mygrid_recv.deleteRow(selectedId) newFeeRecvCount--; } } } else { pressCount = 0; return true; } //code38 end } //左箭头 else if (code == 37) { //code37 begin mygrid_recv.clearSelection(); mygrid_recv.editStop(); if (ind == 0) { mygrid_recv.selectCell(rowIndex, 12, true); } else { mygrid_recv.selectCell(rowIndex, ind - 1, true); } mygrid_recv.editCell(); return true; } //code37 end //右箭头 else if (code == 39) { //code39 begin mygrid_recv.clearSelection(); mygrid_recv.editStop(); if (ind == 12) { mygrid_recv.selectCell(rowIndex, 0, true); } else { mygrid_recv.selectCell(rowIndex, ind + 1, true); } mygrid_recv.editCell(); return true; } //code39 end //空格 else if (code == 32) { if (ind == 12) { return true; } } else { return true; } //onKeyPress end }); // var pressVal = ""; // var pressColIndex = 0; // var pressRowIndex = 0; // var pressGridType = 1;//recv setTimeout(function(){ markStatusColor(mygrid_recv); },460); } //返回小键盘的对应数字 function getCode(code) { var pressVal = String.fromCharCode(code); if (code == 96) pressVal = 0; if (code == 97) pressVal = 1; if (code == 98) pressVal = 2; if (code == 99) pressVal = 3; if (code == 100) pressVal = 4; if (code == 101) pressVal = 5; if (code == 102) pressVal = 6; if (code == 103) pressVal = 7; if (code == 104) pressVal = 8; if (code == 105) pressVal = 9; if (code == 106) pressVal = "*"; if (code == 107) pressVal = "+"; if (code == 109) pressVal = "-"; if (code == 111) pressVal = "/"; return pressVal; } //讲下拉列表Combo所有生成Array数组 function setComboByArray(gridNewObj,comboObj,rowGID,colIndex){ //var comboTxt_arg = new Array(); var comboVal_arg = new Array(); comboVal_arg = comboObj.getKeys(); var newCombo = gridNewObj.getCustomCombo(rowGID,colIndex); for(var i = 0;i < comboVal_arg.length;i++){ var txtValue = comboObj.get(comboVal_arg[i]); newCombo.put(comboVal_arg[i],txtValue); } } function spliceBuffer(arrayRow){ var strBuffer = ""; for(var i = 0;i,费用状态,应付费用名称,结算单位,计费标准,单价,数量,佣金比例,金额,币别,汇率,FRT,费用备注,是否垫付,结算金额,申请金额,支票号码,录入人,录入时间,TID,WMSOUTBSNO,行号"); mygrid_pay.setInitWidths("40,70,110,150,70,80,80,90,90,50,70,70,250,70,70,70,120,80,120,0,0,0"); mygrid_pay.setColAlign("center,center,right,right,right,right,right,right,right,right,right,right,right,center,center,center,center,center,center,center,center,center"); // mygrid_pay.setSkin("light"); mygrid_pay.setColSorting("na,str,str,str,int,int,int,int,int,int,int,int,int,str,str,str,str,str,str,str,str,str"); mygrid_pay.setColTypes("ch,ro,co,co,co,ed,ed,ed,ed,co,ed,co,ed,ch,ro,ro,ro,ro,ro,ro,ro,ro"); var bsno = $("h_bsno").value; ////判断委托单有无应付费用 var urlVal = "../Shipping/feegridsource.aspx?type=2&read=exist&showcount=1&oplb="+stroplb+"&wmsoutbsno="+wmsoutbsno+"&bsno="+bsno+"&val="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; loader = null; if(parseInt(loadVal) == 1){ //获取委托单应付信息,初始化grid mygrid_pay.loadXML("../Shipping/feegridsource.aspx?type=2&read=init&showcount=1&oplb="+stroplb+"&wmsoutbsno="+wmsoutbsno+"&bsno="+bsno,function(){ ReShowLabel(mygrid_pay); ////totalDynamicFeeGain(); //获取利润信息 //getFeeProfit(bsno); //finishLoading(); }); }else{ //getFeeProfit(bsno); } mygrid_pay.init(); mygrid_pay.enableEditEvents(true,false,true); mygrid_pay.enableMultiselect(true); //mygrid_pay.setTabOrder("1,2,3,4,5,6,7,8,9,10,11,12"); //mygrid_pay.enableLightMouseNavigation(true); mygrid_pay.enableKeyboardSupport(true); var cacheTemplate = $("h_cachetemplate").value; var importType = parseInt($("h_importtype").value); setTimeout(function () { var cacheTemplate = $("h_cachetemplate").value; var importType = parseInt($("h_importtype").value); if (cacheTemplate != "") { var jsonCacheObj = null; jsonCacheObj = eval('(' + cacheTemplate + ')'); var delAry = new Array(); for (var i = 0; i < jsonCacheObj.templates.length; i++) { var newId = newGuid(); //获取插入新纪录位置 //初始化变量 var rowCount = mygrid_pay.getRowsNum(); var tid = ""; var feeName = ""; var customerName = ""; var unit = ""; var unitprice = 0; var quantity = 0; var currency = ""; var exchangeRate = 1; var remark = ""; var isAdvancePay = false; var client = ""; if (jsonCacheObj.templates[i].type == 2) { tid = jsonCacheObj.templates[i].tid; feeName = jsonCacheObj.templates[i].fname; customerName = jsonCacheObj.templates[i].cust; unit = jsonCacheObj.templates[i].unit; unitprice = jsonCacheObj.templates[i].uprice; currency = jsonCacheObj.templates[i].cur; exchangeRate = jsonCacheObj.templates[i].exrate == 0 ? 1 : jsonCacheObj.templates[i].exrate; remark = jsonCacheObj.templates[i].remark; client = jsonCacheObj.templates[i].client; var rId = newId; var linenum = rowCount + 101; mygrid_pay.addRow(newId, [0, "录入状态", feeName, customerName, unit, unitprice, 0, 0, 0, currency, exchangeRate, "PP", remark, isAdvancePay, 0, 0, '', '', '', tid, wmsoutbsno, linenum], rowCount); var rowIndex = mygrid_pay.getRowIndex(newId); if (feeName != "") { var url = ""; var feeCodeObj = null; var feeName = mygrid_pay.cellByIndex(rowIndex, 2).getValue().trim(); if (feeName != "") {//通过费用名称获取费用代码表(code_fee)币别汇率信息 url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb=" + stroplb + "&feename=" + escape(feeName) + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(url); var feeCodeInfo = loader.xmlDoc.responseText; feeCodeObj = eval('(' + feeCodeInfo + ')'); if (feeCodeObj.feecode.length > 0) { if (feeCodeObj.feecode[0].cur.trim() != "") { //获取委托(op_seai)费用1汇率 var urlVal = ""; if (currency == "") { mygrid_pay.cellByIndex(rowIndex, 9).setValue(feeCodeObj.feecode[0].cur); urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1¤cy=" + feeCodeObj.feecode[0].cur + "&uid=" + newGuid(); } else { mygrid_pay.cellByIndex(rowIndex, 9).setValue(currency); urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1¤cy=" + currency + "&uid=" + newGuid(); } var bsno = $("h_bsno").value; var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; mygrid_pay.cellByIndex(rowIndex, 10).setValue(loadVal); if (unit == "") { if (feeCodeObj.feecode[0].unit != 0) { quantityObj = getUnitType(feeCodeObj.feecode[0].unit); if (quantityObj.quantity.length > 0) { if (quantityObj.quantity[0].value > 0) { mygrid_pay.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name); mygrid_pay.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } } } else { //mygrid_pay.cellByIndex(rowIndex,4).setValue(""); mygrid_pay.cellByIndex(rowIndex, 6).setValue(1); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = 1; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } } else { var quantityObj = null; cknum = mygrid_pay.cellByIndex(rowIndex, 6).getValue(); quantityObj = getTypeNameQuantity(unit, cknum); if (quantityObj.quantity.length > 0) { if (quantityObj.quantity[0].value > 0) { mygrid_pay.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name); mygrid_pay.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } else { //mygrid_recv.cellByIndex(rowIndex,4).setValue(""); if (getTypeNum(unit) >= 1) { mygrid_pay.cellByIndex(rowIndex, 6).setValue(0); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = 0; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } else { delAry.push(rId); alert("请先录入委托的对应箱型,在引入计费标准是箱型的费用!"); //mygrid_recv.deleteRow(rId);rowCount = 0; } } } } } if (feeCodeObj.feecode[0].credit > 0) { var debitObj = null; debitObj = getDebitType(feeCodeObj.feecode[0].credit); if (debitObj.debit.length > 0) { if (debitObj.debit[0].value.trim() != "") { if (customerName.trim() != "") { mygrid_pay.cellByIndex(rowIndex, 3).setValue(customerName.trim()); } else { mygrid_pay.cellByIndex(rowIndex, 3).setValue(debitObj.debit[0].value); } } } } if (delAry.length > 0) { for (var k = 0; k < delAry.length; k++) { mygrid_pay.deleteRow(delAry[k]); } } ReShowLabel(mygrid_pay); //totalDynamicFeeGain(); } } } } } } var cacheHistory = $("h_cachehistory").value; var historyType = parseInt($("h_historytype").value); var opType = parseInt($("h_historyoptype").value); if (cacheHistory != "") { var jsonCacheObj = null; jsonCacheObj = eval('(' + cacheHistory + ')'); var delAry = new Array(); for (var i = 0; i < jsonCacheObj.history.length; i++) { var newId = newGuid(); //获取插入新纪录位置 //初始化变量 var rowCount = mygrid_pay.getRowsNum(); var tid = ""; var feeName = ""; var customerName = ""; var unit = ""; var unitprice = 0; var quantity = 0; var currency = ""; var exchangeRate = 1; var remark = ""; var isAdvancePay = false; var client = ""; var frt = ""; var isAdv = ""; if (jsonCacheObj.history[i].type == 2) { tid = jsonCacheObj.history[i].tid; feeName = jsonCacheObj.history[i].fname; customerName = jsonCacheObj.history[i].cust; unit = jsonCacheObj.history[i].unit; unitprice = jsonCacheObj.history[i].uprice; currency = jsonCacheObj.history[i].cur; exchangeRate = jsonCacheObj.history[i].exrate == 0 ? 1 : jsonCacheObj.history[i].exrate; remark = jsonCacheObj.history[i].remark; client = jsonCacheObj.history[i].client; frt = jsonCacheObj.history[i].frt; isAdvancePay = jsonCacheObj.history[i].isadv; var rId = newId; var linenum = rowCount + 101; mygrid_pay.addRow(newId, [0, "录入状态", feeName, customerName, unit, unitprice, 0, 0, 0, currency, exchangeRate, frt, remark, isAdvancePay, 0, 0, '', '', '', tid, wmsoutbsno, linenum], rowCount); var rowIndex = mygrid_pay.getRowIndex(newId); if (feeName != "") { var url = ""; var feeCodeObj = null; var feeName = mygrid_pay.cellByIndex(rowIndex, 2).getValue().trim(); if (feeName != "") {//通过费用名称获取费用代码表(code_fee)币别汇率信息 url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb=" + stroplb + "&feename=" + escape(feeName) + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(url); var feeCodeInfo = loader.xmlDoc.responseText; feeCodeObj = eval('(' + feeCodeInfo + ')'); if (feeCodeObj.feecode.length > 0) { if (feeCodeObj.feecode[0].cur.trim() != "") { var urlVal = ""; if (currency == "") {//获取委托(op_seai)费用1汇率 mygrid_pay.cellByIndex(rowIndex, 9).setValue(feeCodeObj.feecode[0].cur); urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1¤cy=" + feeCodeObj.feecode[0].cur + "&uid=" + newGuid(); } else { mygrid_pay.cellByIndex(rowIndex, 9).setValue(currency); urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1¤cy=" + currency + "&uid=" + newGuid(); } var bsno = $("h_bsno").value; var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; mygrid_pay.cellByIndex(rowIndex, 10).setValue(loadVal); if (unit == "") { if (feeCodeObj.feecode[0].unit != 0) { quantityObj = getUnitType(feeCodeObj.feecode[0].unit); if (quantityObj.quantity.length > 0) { if (quantityObj.quantity[0].value > 0) { mygrid_pay.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name); mygrid_pay.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } } } else { mygrid_pay.cellByIndex(rowIndex, 6).setValue(1); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = 1; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } } else { var quantityObj = null; cknum = mygrid_pay.cellByIndex(rowIndex, 6).getValue(); quantityObj = getTypeNameQuantity(unit, cknum); if (quantityObj.quantity.length > 0) { if (quantityObj.quantity[0].value > 0) { mygrid_pay.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name); mygrid_pay.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } else { //mygrid_recv.cellByIndex(rowIndex,4).setValue(""); if (getTypeNum(unit) >= 1) { mygrid_pay.cellByIndex(rowIndex, 6).setValue(0); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = 0; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } } } } } if (feeCodeObj.feecode[0].credit > 0) { var debitObj = null; debitObj = getDebitType(feeCodeObj.feecode[0].credit); if (debitObj.debit.length > 0) { if (debitObj.debit[0].value.trim() != "") { if (opType == 1) { mygrid_pay.cellByIndex(rowIndex, 3).setValue(customerName.trim()); } else { mygrid_pay.cellByIndex(rowIndex, 3).setValue(debitObj.debit[0].value); } } } } ReShowLabel(mygrid_pay); //totalDynamicFeeGain(); } } } } } } }, 240); var pushVal = ""; var pressRecord = ""; var pressRowIndex = -1; var pressCellIndex = -1; var pressCount = 0; var isExchange = false; var shiftCount = 0; var isDelete = 0; var flagFilter = 0; var flagTab = 0; var flagEnter = 0; var flagDelete = 0; mygrid_pay.attachEvent("onSelectStateChanged", function(id){ RowOutBsno=mygrid_pay.cellById(id,20).getValue(); if($("h_enable").value == "1"){ var rowIndex = mygrid_pay.getRowIndex(id); if(rowIndex >= 0){ var stateVal = mygrid_pay.cellByIndex(rowIndex,1).getValue().trim(); if(stateVal == "录入状态"|| stateVal == "驳回提交"){ var combo_currency; combo_currency = mygrid_pay.getCustomCombo(id,9); if(combo_currency.getKeys.length <= 1){ setCurrencyCombo(combo_currency); } var combo_feename; combo_feename = mygrid_pay.getCustomCombo(id,2); if(combo_feename.getKeys.length <= 1){ setFeeNameCombo(combo_feename); } var combo_cust; combo_cust = mygrid_pay.getCustomCombo(id,3); if(combo_cust.getKeys.length <= 1){ setCustomerCombo(combo_cust,id); } var combo_unit; combo_unit = mygrid_pay.getCustomCombo(id,4); if(combo_unit.getKeys.length <= 1){ setUnitCombo(combo_unit); } var combo_frt; combo_frt = mygrid_pay.getCustomCombo(id,11); if(combo_frt.getKeys.length <= 1){ setFrtCombo(combo_frt); } return true; }else{ return false; } } } }); //手动编写Grid控件编辑事件,由于免费控件没有提供完整的编辑判断功能,现特此做更改 mygrid_pay.attachEvent("onEditCell", function (stage, rId, cInd, nValue, oValue) { RowOutBsno = mygrid_pay.cellById(rId, 20).getValue(); var newCheckValue = false; //初始化状态 if (stage == 0) { var rowIndex = mygrid_pay.getRowIndex(rId); var oldVal = mygrid_pay.cellByIndex(rowIndex, 1).getValue().trim(); if (oldVal == "录入状态" || oldVal == "驳回提交") { if ($("h_enable").value == "0") { if (cInd == 0) { if (validOperatePower(rId, 2)) { return true; } else { return false; } } return false; } else { if (validOperatePower(rId, 2)) { return true; } else { return false; } } } else { if (validOperatePower(rId, 2)) { if (cInd == 0) { return true; } else { return false; } } else { return false; } } } if (stage == 1) { var selectedId = mygrid_pay.getSelectedRowId(); var rowIndex = mygrid_pay.getRowIndex(selectedId); var txtEdit; for (i = 0; i < document.all.length; i++) { if (document.all(i).tagName == "TEXTAREA") { txtEdit = document.all(i); txtEdit.focus(); txtEdit.select(); break; } } } //如果编辑结束 if (stage == 2) { if (oValue == null || oValue == "" || oValue == "0") { if (cInd != 5 && cInd != 6 && cInd != 8) { if (nValue == null || nValue == "" || nValue == "0") { return true; } } } changeFeePayCount++; if (cInd == 5) { var rowIndex = mygrid_pay.getRowIndex(rId); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 6).getValue()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 5).setValue(outputMoney(unitPrice.toString())); //mygrid_pay.cellByIndex(rowIndex,6).setValue(outputMoney(quantityCount.toString())); mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); //totalDynamicFeeGain(); return true; } else if (cInd == 6) { var rowIndex = mygrid_pay.getRowIndex(rId); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 6).getValue()))); var amount = unitPrice * quantityCount; //mygrid_pay.cellByIndex(rowIndex,5).setValue(outputMoney(unitPrice.toString())); mygrid_pay.cellByIndex(rowIndex, 6).setValue(outputMoney(quantityCount.toString())); mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); //totalDynamicFeeGain(); return true; } else if (cInd == 8) { var rowIndex = mygrid_pay.getRowIndex(rId); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 6).getValue()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); //totalDynamicFeeGain(); return true; } else if (cInd == 9) { var rowIndex = mygrid_pay.getRowIndex(rId); var curValue = mygrid_pay.cellByIndex(rowIndex, 9).getValue(); var bsno = $("h_bsno").value; //获取海运进口委托(op_seai)费用1汇率 var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1¤cy=" + curValue + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; mygrid_pay.cellByIndex(rowIndex, 10).setValue(loadVal); //totalDynamicFeeGain(); loader == null; return true; } else if (cInd == 10) { var rowIndex = mygrid_pay.getRowIndex(rId); var currency = mygrid_pay.cellByIndex(rowIndex, 9).getValue(); var rate = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 10).getValue()))); if (currency == "RMB") { if (rate != 1) { return false; } } else if (currency == "USD") { if (rate <= 1) { return false; } } //totalDynamicFeeGain(); return true; } else if (cInd == 4) { var rowIndex = mygrid_pay.getRowIndex(rId); var unitVal = mygrid_pay.cellByIndex(rowIndex, 4).getValue(); var quantityObj = null; cknum = mygrid_pay.cellByIndex(rowIndex, 6).getValue(); quantityObj = getTypeNameQuantity(unitVal, cknum); if (quantityObj.quantity.length > 0) { if (quantityObj.quantity[0].value > 0) { mygrid_pay.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name); mygrid_pay.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } else { //mygrid_pay.cellByIndex(rowIndex,4).setValue(""); mygrid_pay.cellByIndex(rowIndex, 6).setValue(0); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } } //重新计算利润 //totalDynamicFeeGain(); return true; } else if (cInd == 2 || cInd == 3) { var rowIndex = mygrid_pay.getRowIndex(rId); if (pressCount == 1) { if (flagFilter == 1) { //mygrid_recv.editStop(); mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(oValue); return true; } else { // if(pressRowIndex == rowIndex && pressCellIndex == cInd){ var cellVal = mygrid_pay.cellByIndex(rowIndex, cInd).getValue(); var combo = mygrid_pay.getCustomCombo(rId, cInd); var comboArg = combo.getKeys(); var tempCount = 0; if (cellVal.indexOf(" ") > 0 && cellVal.indexOf(" ") < cellVal.length) { cellVal = cellVal.substring(0, cellVal.indexOf(" ")); for (var i = 0; i < comboArg.length; i++) { if (combo.get(comboArg[i]).trim().indexOf(cellVal) == 0) { mygrid_pay.cellByIndex(rowIndex, cInd).setValue(comboArg[i]); mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]); tempCount++; break; } } } else { for (var i = 0; i < comboArg.length; i++) { if (comboArg[i] == cellVal) { if (combo.get(comboArg[i]).trim().indexOf(cellVal) >= 0) { mygrid_pay.cellByIndex(rowIndex, cInd).setValue(comboArg[i]); mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]); tempCount++; break; } } } } // if (tempCount == 0) { mygrid_pay.cellByIndex(rowIndex, cInd).setValue(""); mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(""); } isExchange = false; pressRecord = ""; pressRowIndex = -1; pressCellIndex = -1; pressCount = 0; flagFilter = 0; return true; } } else if (pressCount == 2) { if (flagFilter == 1) { mygrid_pay.editStop(); mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(oValue); } else { if (pressRowIndex != rowIndex && pressCellIndex != cInd) {//alert(11) return true; } else { isExchange = false; pressRecord = ""; pressRowIndex = -1; pressCellIndex = -1; pressCount = 0; flagFilter = 0; var cellVal = mygrid_pay.cellByIndex(rowIndex, cInd).getValue(); //alert(cellVal) var combo = mygrid_pay.getCustomCombo(rId, cInd); var comboArg = combo.getKeys(); var tempCount = 0; if (cellVal.indexOf(" ") > 0 && cellVal.indexOf(" ") < cellVal.length) { cellVal = cellVal.substring(0, cellVal.indexOf(" ")); for (var i = 0; i < comboArg.length; i++) { if (combo.get(comboArg[i]).trim().indexOf(cellVal) == 0) { mygrid_pay.cellByIndex(rowIndex, cInd).setValue(comboArg[i]); mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]); tempCount++; break; } } } // if (tempCount == 0) { mygrid_pay.cellByIndex(rowIndex, cInd).setValue(""); mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(""); } return true; } } } else { var cellVal = mygrid_pay.cellByIndex(rowIndex, cInd).getValue(); var combo = mygrid_pay.getCustomCombo(rId, cInd); var comboArg = combo.getKeys(); var tempCount = 0; if (cellVal.indexOf(" ") > 0 && cellVal.indexOf(" ") < cellVal.length) { cellVal = cellVal.substring(0, cellVal.indexOf(" ")); for (var i = 0; i < comboArg.length; i++) { if (combo.get(comboArg[i]).trim().indexOf(cellVal) == 0) { mygrid_pay.cellByIndex(rowIndex, cInd).setValue(comboArg[i]); mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]); tempCount++; break; } } } else { for (var i = 0; i < comboArg.length; i++) { if (combo.get(comboArg[i]).trim().indexOf(cellVal) == 0 || comboArg[i].toString().trim().indexOf(cellVal) == 0) { mygrid_pay.cellByIndex(rowIndex, cInd).setValue(comboArg[i]); mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(comboArg[i]); tempCount++; break; } } } // if (tempCount == 0) { mygrid_pay.cellByIndex(rowIndex, cInd).setValue(""); mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(""); } // if (cInd == 2) { var url = ""; var feeCodeObj = null; var feeName = mygrid_pay.cellByIndex(rowIndex, 2).getValue().trim(); if (feeName != "") {//通过费用名称获取费用代码表(code_fee)币别汇率信息 url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb=" + stroplb + "&feename=" + escape(feeName) + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(url); var feeCodeInfo = loader.xmlDoc.responseText; feeCodeObj = eval('(' + feeCodeInfo + ')'); if (feeCodeObj.feecode.length > 0) { if (feeCodeObj.feecode[0].cur.trim() != "") { mygrid_pay.cellByIndex(rowIndex, 9).setValue(feeCodeObj.feecode[0].cur); //获取委托(op_seai)费用1汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1¤cy=" + feeCodeObj.feecode[0].cur + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; mygrid_pay.cellByIndex(rowIndex, 10).setValue(loadVal); if (feeCodeObj.feecode[0].unit != 0) { quantityObj = getUnitType(feeCodeObj.feecode[0].unit); if (quantityObj.quantity.length > 0) { if (quantityObj.quantity[0].value > 0) { mygrid_pay.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name); mygrid_pay.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } } } else { //mygrid_pay.cellByIndex(rowIndex,4).setValue(""); mygrid_pay.cellByIndex(rowIndex, 6).setValue(1); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = 1; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } } if (feeCodeObj.feecode[0].credit > 0) { var debitObj = null; debitObj = getDebitType(feeCodeObj.feecode[0].credit); if (debitObj.debit.length > 0) { if (debitObj.debit[0].value.trim() != "") { mygrid_pay.cellByIndex(rowIndex, 3).setValue(debitObj.debit[0].value); } } } ReShowLabel(mygrid_pay); } } } //totalDynamicFeeGain(); return true; } } else { return true; } } else { return true; } }); mygrid_pay.attachEvent("onSelectStateChanged", function(id){ RowOutBsno=mygrid_pay.cellById(id,20).getValue(); var rowIndex = mygrid_pay.getRowIndex(id); var checkState = mygrid_pay.cellByIndex(rowIndex,0).getValue(); if(checkState == 0){ if(!validOperatePower(id,2,"select")){ alert("权限不足,请重新选择"); return; } //mygrid_pay.cellByIndex(rowIndex,0).setValue(1); }else{ //mygrid_pay.cellByIndex(rowIndex,0).setValue(0); } }); //键盘操作事件 mygrid_pay.attachEvent("onKeyPress", function (code, cFlag, sFlag) { //onKeyPress begin //获取当前RowID var selectedId = mygrid_pay.getSelectedRowId(); //获取当前RowIndex var rowIndex = mygrid_pay.getRowIndex(selectedId); //获取当前CellIndex(ind) var ind = mygrid_pay.getSelectedCellIndex(); RowOutBsno = mygrid_pay.cellById(selectedId, 20).getValue(); //触发操作事件前获取单元值 var oldVal = mygrid_pay.cellByIndex(rowIndex, ind).getValue(); //获取编辑单元 var txtEdit; for (i = 0; i < document.all.length; i++) { if (document.all(i).tagName == "TEXTAREA") { txtEdit = document.all(i); oldVal = txtEdit.innerHTML; break; } } if (code == 13) { if (ind == 5) { //var rowIndex = mygrid_recv.getRowIndex(selectedId); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 6).getValue()))); var amount = unitPrice * quantityCount; //mygrid_recv.cellByIndex(rowIndex,5).setValue(outputMoney(unitPrice.toString())); mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); //totalDynamicFeeGain(); return true; } if (ind == 2 || ind == 3 || ind == 4 || ind == 9 || ind == 11) { //如果是检索失败, if (pressCount == 2) { mygrid_pay.editStop(); //将value写入cell(触发 stage2) mygrid_pay.cellByIndex(rowIndex, ind).setValue(oldVal); //重新打开cell(触发stage0 stage1) mygrid_pay.selectCell(rowIndex, ind, true, true); mygrid_pay.cellByIndex(rowIndex, ind).setLabel(oldVal); mygrid_pay.editCell(); return true; } else { var combo = mygrid_pay.getCustomCombo(selectedId, ind); var comboArg = combo.getKeys(); var tempCount = 0; for (var i = 0; i < comboArg.length; i++) { if (combo.get(comboArg[i]).toLowerCase().trim().indexOf(oldVal) == 0) { var oldVal = comboArg[i]; var oldLab = combo.get(comboArg[i]); //记录状态值 检索到数据项 pressCount = 1; flagFilter = 1; tempCount++; //关闭编辑 //mygrid_pay.editStop(); //将value写入cell(触发 stage2) mygrid_pay.cellByIndex(rowIndex, ind).setValue(oldVal); mygrid_pay.cellByIndex(rowIndex, ind).setLabel(oldLab); flagFilter = 0; //重新打开cell(触发stage0 stage1) mygrid_pay.selectCell(rowIndex, ind, true, true); mygrid_pay.editCell(); break; } } // if (tempCount == 0) { mygrid_pay.cellByIndex(rowIndex, ind).setValue(""); mygrid_pay.cellByIndex(rowIndex, ind).setLabel(""); } } if (ind == 2) { var url = ""; var feeCodeObj = null; var feeName = mygrid_pay.cellByIndex(rowIndex, 2).getValue().trim(); if (feeName != "") {//通过费用名称获取费用代码表(code_fee)币别汇率信息 url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb=" + stroplb + "&feename=" + escape(feeName) + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(url); var feeCodeInfo = loader.xmlDoc.responseText; feeCodeObj = eval('(' + feeCodeInfo + ')'); if (feeCodeObj.feecode.length > 0) { if (feeCodeObj.feecode[0].cur.trim() != "") { mygrid_pay.cellByIndex(rowIndex, 9).setValue(feeCodeObj.feecode[0].cur); //获取委托(op_seai)费用1汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1¤cy=" + feeCodeObj.feecode[0].cur + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; mygrid_pay.cellByIndex(rowIndex, 10).setValue(loadVal); if (feeCodeObj.feecode[0].unit != 0) { quantityObj = getUnitType(feeCodeObj.feecode[0].unit); if (quantityObj.quantity.length > 0) { if (quantityObj.quantity[0].value > 0) { mygrid_pay.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name); mygrid_pay.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } } } else { //mygrid_pay.cellByIndex(rowIndex,4).setValue(""); mygrid_pay.cellByIndex(rowIndex, 6).setValue(1); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = 1; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } } if (feeCodeObj.feecode[0].credit > 0) { var debitObj = null; debitObj = getDebitType(feeCodeObj.feecode[0].credit); if (debitObj.debit.length > 0) { if (debitObj.debit[0].value.trim() != "") { mygrid_pay.cellByIndex(rowIndex, 3).setValue(debitObj.debit[0].value); } } } ReShowLabelForEnter(mygrid_pay); } } //totalDynamicFeeGain(); return true; } return true; } else { return true; } } //Tab键 else if (code == 9) { //code9 begin var colCount = mygrid_pay.getColumnsNum(); var rowCount = mygrid_pay.getRowsNum(); if (ind < colCount) { isExchange = false; pressRecord = ""; pressRowIndex = -1; pressCellIndex = -1; mygrid_pay.editStop(true); mygrid_pay.cellByIndex(rowIndex, ind).setLabel(oldVal); var cInd = ind; var rId = selectedId; if (cInd == 5) { var rowIndex = mygrid_pay.getRowIndex(rId); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 6).getValue()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 5).setValue(outputMoney(unitPrice.toString())); mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); //totalDynamicFeeGain(); } else if (cInd == 6) { var rowIndex = mygrid_pay.getRowIndex(rId); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 6).getValue()))); var amount = unitPrice * quantityCount; //mygrid_recv.cellByIndex(rowIndex,5).setValue(outputMoney(unitPrice.toString())); mygrid_pay.cellByIndex(rowIndex, 6).setValue(outputMoney(quantityCount.toString())); mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); //totalDynamicFeeGain(); } else if (cInd == 9) { var rowIndex = mygrid_pay.getRowIndex(rId); var curValue = mygrid_pay.cellByIndex(rowIndex, 9).getValue(); //获取海运进口委托(op_seai)费用1汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1¤cy=" + curValue + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; mygrid_pay.cellByIndex(rowIndex, 10).setValue(loadVal); //totalDynamicFeeGain(); loader == null; } else if (cInd == 12) { mygrid_pay.cellByIndex(rowIndex, 12).setValue(oldVal); } else if (cInd == 4 || cInd == 9 || cInd == 11) { var combo = mygrid_pay.getCustomCombo(rId, cInd); var comboArg = combo.getKeys(); var tempCount = 0; for (var i = 0; i < comboArg.length; i++) { if (combo.get(comboArg[i]).toUpperCase().trim().indexOf(oldVal) == 0) { var oldVal = comboArg[i]; var oldLab = combo.get(comboArg[i]); //记录状态值 检索到数据项 pressCount = 1; flagFilter = 1; tempCount++; ; //关闭编辑 //mygrid_pay.editStop(); //将value写入cell(触发 stage2) mygrid_pay.cellByIndex(rowIndex, cInd).setValue(oldVal); mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(oldLab); flagFilter = 0; //重新打开cell(触发stage0 stage1) mygrid_pay.selectCell(rowIndex, cInd, true, true); mygrid_pay.editCell(); break; } } if (tempCount == 0) { mygrid_pay.cellByIndex(rowIndex, cInd).setValue(""); mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(""); } } else if (cInd == 2 || cInd == 3) { var combo = mygrid_pay.getCustomCombo(rId, cInd); var comboArg = combo.getKeys(); var tempCount = 0; for (var i = 0; i < comboArg.length; i++) { if (combo.get(comboArg[i]).toLowerCase().trim().indexOf(oldVal) == 0) { var oldVal = comboArg[i]; var oldLab = combo.get(comboArg[i]); //记录状态值 检索到数据项 pressCount = 1; flagFilter = 1; tempCount++; ; //关闭编辑 //mygrid_pay.editStop(); //将value写入cell(触发 stage2) mygrid_pay.cellByIndex(rowIndex, cInd).setValue(oldVal); mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(oldLab); flagFilter = 0; //重新打开cell(触发stage0 stage1) mygrid_pay.selectCell(rowIndex, cInd, true, true); mygrid_pay.editCell(); break; } } if (tempCount == 0) { mygrid_pay.cellByIndex(rowIndex, cInd).setValue(""); mygrid_pay.cellByIndex(rowIndex, cInd).setLabel(""); } // if (cInd == 2) { var url = ""; var feeCodeObj = null; var feeName = mygrid_pay.cellByIndex(rowIndex, 2).getValue().trim(); if (feeName != "") {//通过费用名称获取费用代码表(code_fee)币别汇率信息 url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&oplb=" + stroplb + "&feename=" + escape(feeName) + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(url); var feeCodeInfo = loader.xmlDoc.responseText; feeCodeObj = eval('(' + feeCodeInfo + ')'); if (feeCodeObj.feecode.length > 0) { mygrid_pay.cellByIndex(rowIndex, 9).setValue(feeCodeObj.feecode[0].cur); //获取委托(op_seai)费用1汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?oplb=" + stroplb + "&bsno=" + bsno + "&type=1¤cy=" + feeCodeObj.feecode[0].cur + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; mygrid_pay.cellByIndex(rowIndex, 10).setValue(loadVal); if (feeCodeObj.feecode[0].unit != 0) { quantityObj = getUnitType(feeCodeObj.feecode[0].unit); if (quantityObj.quantity.length > 0) { if (quantityObj.quantity[0].value > 0) { mygrid_pay.cellByIndex(rowIndex, 4).setValue(quantityObj.quantity[0].name); mygrid_pay.cellByIndex(rowIndex, 6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } } } else { //mygrid_pay.cellByIndex(rowIndex,4).setValue(""); mygrid_pay.cellByIndex(rowIndex, 6).setValue(1); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex, 5).getValue()))); var quantityCount = 1; //clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex, 8).setValue(outputMoney(amount.toString())); } //totalDynamicFeeGain(); if (feeCodeObj.feecode[0].credit > 0) { var debitObj = null; debitObj = getDebitType(feeCodeObj.feecode[0].credit); if (debitObj.debit.length > 0) { if (debitObj.debit[0].value.trim() != "") { mygrid_pay.cellByIndex(rowIndex, 3).setValue(debitObj.debit[0].value); } } } } } } } mygrid_pay.selectCell(rowIndex, ind + 1, true, true); mygrid_pay.editCell(); if (ind == colCount - 2) { if (rowIndex < rowCount) { mygrid_pay.editStop(true); mygrid_pay.clearSelection(); mygrid_pay.selectCell(rowIndex + 1, 1, true, true); mygrid_pay.editCell(); } else { return; } } } //cdoe9 end } else if ((code >= 65 && code <= 90) || (code >= 48 && code <= 57) || (code >= 96 && code <= 105)) {//如果是输入英文字符 if (ind == 2 || ind == 3 || ind == 4 || ind == 11 || ind == 12) { return true; } if ((code >= 48 && code <= 57) || (code >= 96 && code <= 105)) { if (ind == 5 || ind == 6 || ind == 7 || ind == 10 || ind == 12) { return true; } } } //delete else if (code == 8) { //code8 begin if (ind == 2 || ind == 3 || ind == 4 || ind == 9 || ind == 11) { var start = 0; var end = 0; if (document.selection) { var range = document.selection.createRange(); if (range.parentElement().className == txtEdit.className) { var range_all = document.body.createTextRange(); range_all.moveToElementText(txtEdit); for (start = 0; range_all.compareEndPoints("StartToStart", range) < 0; start++) { range_all.moveStart('character', 1); } for (var i = 0; i <= start; i++) { if (txtEdit.value.charAt(i) == '\n') start++; } var range_all = document.body.createTextRange(); range_all.moveToElementText(txtEdit); for (end = 0; range_all.compareEndPoints('StartToEnd', range) < 0; end++) range_all.moveStart('character', 1); for (var i = 0; i <= end; i++) { if (txtEdit.value.charAt(i) == '\n') end++; } } } //未选中多个字符 if (start == end) { if (start != 0) { var firstVal = pressRecord.substring(0, start - 1); var endVal = pressRecord.substring(start + 1, txtEdit.value.length - 1); pressRecord = firstVal; } } //选中多个字符 if (start != end) { var firstVal = pressRecord.substring(0, start); var endVal = pressRecord.substring(end - 1, txtEdit.value.length - 1); pressRecord = firstVal + endVal; } setTimeout(function () { if (pressRecord != null) { if (pressRecord.trim().length > 0) { var combo = mygrid_pay.getCustomCombo(selectedId, ind); var comboArg = combo.getKeys(); var count = 0; for (var i = 0; i < comboArg.length; i++) { if (combo.get(comboArg[i]).toLowerCase().trim().indexOf(pressRecord) == 0) { count++; var oldVal = comboArg[i]; var oldLab = combo.get(comboArg[i]); pressCount = 3; mygrid_pay.editStop(); mygrid_pay.cellByIndex(rowIndex, ind).setValue(oldVal); mygrid_pay.selectCell(rowIndex, ind, true, true); mygrid_pay.editCell(); var old_length = oldLab.length; for (i = 0; i < document.all.length; i++) { if (document.all(i).tagName == "TEXTAREA") { txtEdit = document.all(i); var rt = txtEdit.createTextRange(); rt.collapse(); rt.select(); //光标置最前 var r = document.selection.createRange(); r.collapse(false); r.moveStart("character", pressRecord.length); //从m位开始 r.moveEnd("character", old_length); //选取n位 //txtEdit.focus(); r.select(); } } break; } } } } }, 500); return true; } else { return true; } //code8 end } //向下方向键 else if (code == 40) { //code40 begin if (ind == 1 || ind == 13 || ind == 5 || ind == 6 || ind == 7 || ind == 8 || ind == 10) { var rowCount = mygrid_pay.getRowsNum(); mygrid_pay.clearSelection(); mygrid_pay.editStop(); if (rowIndex == (rowCount - 1)) { addPayRow(); } else { mygrid_pay.selectCell(rowIndex + 1, 1, true, true); mygrid_pay.editCell(); } } else { pressCount = 0; return true; } //code40 end } //向上箭头 else if (code == 38) { //code38 begin if (ind == 1 || ind == 13 || ind == 5 || ind == 6 || ind == 7 || ind == 8 || ind == 10) { if (rowIndex > 0) { mygrid_pay.clearSelection(); mygrid_pay.editStop(); mygrid_pay.selectCell(rowIndex - 1, 1, true, true); mygrid_pay.editCell(); var rowfeename = mygrid_pay.cellByIndex(rowIndex, 5).getValue(); if (rowfeename == 0) { mygrid_pay.deleteRow(selectedId) newFeePayCount--; } } } else { pressCount = 0; return true; } //code38 end } //左箭头 else if (code == 37) { //code37 begin mygrid_pay.clearSelection(); mygrid_pay.editStop(); if (ind == 0) { mygrid_pay.selectCell(rowIndex, 12, true); } else { mygrid_pay.selectCell(rowIndex, ind - 1, true); } mygrid_pay.editCell(); return true; } //code37 end //右箭头 else if (code == 39) { //code39 begin mygrid_pay.clearSelection(); mygrid_pay.editStop(); if (ind == 12) { mygrid_pay.selectCell(rowIndex, 0, true); } else { mygrid_pay.selectCell(rowIndex, ind + 1, true); } mygrid_pay.editCell(); return true; } //code39 end //空格 else if (code == 32) { if (ind == 12) { return true; } } else { return true; } //onKeyPress end }); setTimeout(function(){ markStatusColor(mygrid_pay); },460); var pressVal = ""; var pressColIndex = 0; var pressRowIndex = 0; var pressGridType = 1;//recv } function addRecvRow(){ var bsno = $("h_bsno").value; if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; var validStatusObj = eval('(' + loadVal + ')'); var opStatus = 0; var feeStatus = 0; if(validStatusObj.valid.length > 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } if(!validOperatePower("",1,"add")){ return; } if(opStatus == 1){ var newId = newGuid(); //获取插入新纪录位置 var rowCount = mygrid_recv.getRowsNum(); var linenum = rowCount + 101; mygrid_recv.addRow(newId, [0, "录入状态", "", "", "", 0, 0, 0, 0, "RMB", 1, "PP", "", false, 0, 0, '', '', '', '0', wmsoutbsno, linenum], rowCount); mygrid_recv.clearSelection(); var rId = mygrid_recv.getRowId(rowCount-1); // var combo_name; // var combo_customer; // var combo_unit; // var combo_currency; // var combo_frt; // // combo_name = mygrid_recv.getCustomCombo(rId,1); // combo_customer = mygrid_recv.getCustomCombo(rId,2); // combo_unit = mygrid_recv.getCustomCombo(rId,3); // combo_currency = mygrid_recv.getCustomCombo(rId,8); // combo_frt = mygrid_recv.getCustomCombo(rId,10); // // //重新加载应收费用名称 // setComboByArray(mygrid_recv,combo_name,newId,1); // //重新加载结算单位 // setComboByArray(mygrid_recv,combo_customer,newId,2); // //重新加载计费标准 // setComboByArray(mygrid_recv,combo_unit,newId,3); // //重新加载币别 // setComboByArray(mygrid_recv,combo_currency,newId,8); // //重新加载FRT // setComboByArray(mygrid_recv,combo_frt,newId,10); var combo_currency; combo_currency = mygrid_recv.getCustomCombo(newId,9); setCurrencyCombo(combo_currency); var combo_feename; combo_feename = mygrid_recv.getCustomCombo(newId,2); setFeeNameCombo(combo_feename); var combo_cust; combo_cust = mygrid_recv.getCustomCombo(newId,3); setCustomerCombo(combo_cust,newId); var combo_unit; combo_unit = mygrid_recv.getCustomCombo(newId,4); setUnitCombo(combo_unit); var combo_frt; combo_frt = mygrid_recv.getCustomCombo(newId,11); //初始化 setFrtCombo(combo_frt); newFeeRecvCount++; setTimeout(function(){ mygrid_recv.editStop(true); mygrid_recv.selectCell(mygrid_recv.getRowIndex(newId),2,true,true); mygrid_recv.editCell(); },150); }else{ alert("委托已退载,费用不能添加"); return; } } function addPayRow(){ var bsno = $("h_bsno").value; if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();; var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; var validStatusObj = eval('(' + loadVal + ')'); var opStatus = 0; var feeStatus = 0; if(validStatusObj.valid.length > 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } if(!validOperatePower("",2,"add")){ return; } if(opStatus == 1){ var newId = newGuid(); //获取插入新纪录位置 var rowCount = mygrid_pay.getRowsNum(); var linenum = rowCount + 101; mygrid_pay.addRow(newId, [0, "录入状态", "", "", "", 0, 0, 0, 0, "RMB", 1, "PP", "", false, 0, 0, '', '', '', '0', wmsoutbsno, linenum], rowCount); mygrid_pay.clearSelection(); var rId = mygrid_pay.getRowId(rowCount-1); // var combo_name; // var combo_customer; // var combo_unit; // var combo_currency; // // combo_name = mygrid_pay.getCustomCombo(rId,1); // combo_customer = mygrid_pay.getCustomCombo(rId,2); // combo_unit = mygrid_pay.getCustomCombo(rId,3); // combo_currency = mygrid_pay.getCustomCombo(rId,8); // // //重新加载应收费用名称 // setComboByArray(mygrid_pay,combo_name,newId,1); // //重新加载结算单位 // setComboByArray(mygrid_pay,combo_customer,newId,2); // //重新加载计费标准 // setComboByArray(mygrid_pay,combo_unit,newId,3); // //重新加载币别 // setComboByArray(mygrid_pay,combo_currency,newId,8); var combo_currency; combo_currency = mygrid_pay.getCustomCombo(newId,9); setCurrencyCombo(combo_currency); var combo_feename; combo_feename = mygrid_pay.getCustomCombo(newId,2); setFeeNameCombo(combo_feename); var combo_cust; combo_cust = mygrid_pay.getCustomCombo(newId,3); setCustomerCombo(combo_cust,newId); var combo_unit; combo_unit = mygrid_pay.getCustomCombo(newId,4); setUnitCombo(combo_unit); var combo_frt; combo_frt = mygrid_pay.getCustomCombo(newId,11); setFrtCombo(combo_frt); newFeePayCount++; setTimeout(function(){ mygrid_pay.editStop(true); mygrid_pay.selectCell(mygrid_pay.getRowIndex(newId),2,true,true); mygrid_pay.editCell(); },150); }else{ alert("委托已退载,费用不能添加"); return; } } function deleteRecvRow(){ var bsno = $("h_bsno").value; if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();; var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; var validStatusObj = eval('(' + loadVal + ')'); var opStatus = 0; var feeStatus = 0; var iSuccess = 0; var iFailure = 0; if(validStatusObj.valid.length > 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } if(opStatus == 1){ var iCount = 0; var recvArg = new Array(); for(var i=0;i 0){ var delCount = 0; if(recvArg.length > 0){ if(window.confirm("您确定要将所选应收费用删除")){ while(delCount < recvArg.length){ var rowIndex = mygrid_recv.getRowIndex(recvArg[delCount]); var tid = mygrid_recv.cellByIndex(rowIndex,19).getValue(); var feeName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); var cusName = mygrid_recv.cellByIndex(rowIndex,3).getValue(); //删除委托业务内的费用,当ch_fee.feestatus=1或6时,通过费用GID删除(ch_fee)单条费用,更新(fee_gain)重算利润,并返回删除操作结果 var urlVal = "../Shipping/FeeService.aspx?gid="+recvArg[delCount]+"&handle=delete&oplb="+stroplb+"&no="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; if(loadVal == 1 ){ mygrid_recv.deleteRow(recvArg[delCount]); }else{ var cacheTemplate = $("h_cachetemplate").value; var importType = parseInt($("h_importtype").value); var cacheHistory = $("h_cachehistory").value; if(cacheTemplate != ""){ var jsonCacheObj = null; jsonCacheObj = eval('(' + cacheTemplate + ')'); var tempCount = 0; for(var i=0;i= 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= 1){ jsonCacheObj.history.splice(i,1); $("h_cachehistory").value = JSON.stringify(jsonCacheObj); mygrid_recv.deleteRow(recvArg[delCount]); iSuccess++; tempCount++; }else{ iFailure++; } break; } } if(tempCount == 0){ mygrid_recv.deleteRow(recvArg[delCount]); iSuccess++; } }else{ mygrid_recv.deleteRow(recvArg[delCount]); iSuccess++; } } delCount++; } //getFeeProfit(bsno); } } }else{ alert("未选中要操作的费用项"); } }else{ alert("委托已退载,费用不能修改"); return; } } function deletePayRow(id){ var bsno = $("h_bsno").value; if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; var validStatusObj = eval('(' + loadVal + ')'); var opStatus = 0; var feeStatus = 0; var iSuccess = 0; var iFailure = 0; if(validStatusObj.valid.length > 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } if(opStatus == 1){ var iCount = 0; var recvArg = new Array(); for(var i=0;i 0){ var delCount = 0; if(recvArg.length > 0){ if(window.confirm("您确定要将所选应付费用删除")){ while(delCount < recvArg.length){ var rowIndex = mygrid_pay.getRowIndex(recvArg[delCount]); var tid = mygrid_pay.cellByIndex(rowIndex,19).getValue(); var feeName = mygrid_pay.cellByIndex(rowIndex,2).getValue(); var cusName = mygrid_pay.cellByIndex(rowIndex,3).getValue(); //删除委托业务内的费用,当ch_fee.feestatus=1或6时,通过费用GID删除(ch_fee)单条费用,更新(fee_gain)重算利润,并返回删除操作结果 var urlVal = "../Shipping/FeeService.aspx?gid="+recvArg[delCount]+"&handle=delete&oplb="+stroplb+"&no="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; if(loadVal == 1 ){ mygrid_pay.deleteRow(recvArg[delCount]); }else{ var cacheTemplate = $("h_cachetemplate").value; var importType = parseInt($("h_importtype").value); var cacheHistory = $("h_cachehistory").value; if(cacheTemplate != ""){ var jsonCacheObj = null; jsonCacheObj = eval('(' + cacheTemplate + ')'); var tempCount = 0; for(var i=0;i= 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= 1){ jsonCacheObj.history.splice(i,1); $("h_cachehistory").value = JSON.stringify(jsonCacheObj); mygrid_pay.deleteRow(recvArg[delCount]); iSuccess++; tempCount++; }else{ iFailure++; } break; } } if(tempCount == 0){ mygrid_pay.deleteRow(recvArg[delCount]); iSuccess++; } }else{ mygrid_pay.deleteRow(recvArg[delCount]); iSuccess++; } } delCount++; } //getFeeProfit(bsno); } } }else{ alert("未选中要操作的费用项"); } }else{ alert("委托已退载,费用不能修改"); return; } } //保存应收费用 function saveRecvChange(){ var bsno = $("h_bsno").value; var jsonFeeObj = null; for(var i=0;i 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } var recvState = 0; var payState = 0; if(opStatus == 1){ recvState = saveRecvChange();//保存应收费用 payState = savePayChange();//保存应付费用 if($("recvContainer").value.trim() == "" && $("payContainer").value.trim() == ""){ return; } if(recvState == 1 && payState == 1){ //GetGainArg(); msgBox(); //定时发送数据 setTimeout(postEnterFee,200); newFeeRecvCount = 0; changeFeeRecvCount = 0; $("h_post").value = 1; //出库和费率信息清空 $("h_post_2").value = "1"; $("recvContainer_2").value = ""; $("recvContainer_3").value = ""; $("WoContainer").value = ""; $("WoDetailContainer").value = ""; } else{ // initGrid(); } }else{ alert("委托已退载,费用不能修改"); return; } }//saveAction 完成 //保存应付费用 function savePayChange(){ var bsno = $("h_bsno").value; var jsonFeeObj = null; for(var i=0;i 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 0){ var delCount = 0; if(recvArg.length > 0){ if(window.confirm("您确定要将所选应收费用放弃修改")){ while(delCount < recvArg.length){ var rowIndex = mygrid_recv.getRowIndex(recvArg[delCount]); var tid = mygrid_recv.cellByIndex(rowIndex,19).getValue(); var feeName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); var cusName = mygrid_recv.cellByIndex(rowIndex,3).getValue(); //恢复委托费用:通过费用ch_fee.gid获取ch_fee信息,返回字符串 var urlVal = "../Shipping/FeeService.aspx?gid="+recvArg[delCount]+"&handle=recover&oplb="+stroplb+"&no="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; if(!IsNum(loadVal)){ var recoverArg = new Array(); recoverArg = loadVal.split(","); var selRowIndex = mygrid_recv.getRowIndex(recvArg[delCount]); var colCount = mygrid_recv.getColumnsNum(); for(var i=2;i= 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= 1){ jsonCacheObj.history.splice(i,1); $("h_cachehistory").value = JSON.stringify(jsonCacheObj); mygrid_recv.deleteRow(recvArg[delCount]); iSuccess++; tempCount++; }else{ iFailure++; } break; } } if(tempCount == 0){ mygrid_recv.deleteRow(recvArg[delCount]); iSuccess++; } }else{ mygrid_recv.deleteRow(recvArg[delCount]); iSuccess++; } } delCount++; } } ReShowLabel(mygrid_recv); //totalDynamicFeeGain(); alert("提交放弃修改应收费用 共 "+delCount+" 条 成功 "+iSuccess+" 条 失败 "+iFailure+" 条"); } }else{ alert("未选中要操作的费用项"); } }else{ alert("委托已退载,费用修改费用"); return; } } //放弃应付费用修改 重新加载页面 function recoverPayChange(){ var iSuccess = 0; var iFailure = 0; var bsno = $("h_bsno").value; if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; var validStatusObj = eval('(' + loadVal + ')'); var opStatus = 0; var feeStatus = 0; if(validStatusObj.valid.length > 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } if(opStatus == 1){ //查看是否有被选中的费用项 var iCount = 0; var recvArg = new Array(); for(var i=0;i 0){ var delCount = 0; if(recvArg.length > 0){ if(window.confirm("您确定要将所选应付费用放弃修改")){ while(delCount < recvArg.length){ var rowIndex = mygrid_pay.getRowIndex(recvArg[delCount]); var tid = mygrid_pay.cellByIndex(rowIndex,19).getValue(); var feeName = mygrid_pay.cellByIndex(rowIndex,2).getValue(); var cusName = mygrid_pay.cellByIndex(rowIndex,3).getValue(); //恢复委托费用:通过费用ch_fee.gid获取ch_fee信息,返回字符串 var urlVal = "../Shipping/FeeService.aspx?gid="+recvArg[delCount]+"&handle=recover&oplb="+stroplb+"&no="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; if(!IsNum(loadVal)){ var recoverArg = new Array(); recoverArg = loadVal.split(","); var selRowIndex = mygrid_pay.getRowIndex(recvArg[delCount]); var colCount = mygrid_pay.getColumnsNum(); for(var i=2;i= 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= 1){ jsonCacheObj.history.splice(i,1); $("h_cachehistory").value = JSON.stringify(jsonCacheObj); mygrid_pay.deleteRow(recvArg[delCount]); iSuccess++; tempCount++; }else{ iFailure++; } break; } } if(tempCount == 0){ mygrid_pay.deleteRow(recvArg[delCount]); iSuccess++; } }else{ mygrid_pay.deleteRow(recvArg[delCount]); iSuccess++; } } delCount++; } } ReShowLabel(mygrid_pay); //totalDynamicFeeGain(); alert("提交放弃修改应收费用 共 "+delCount+" 条 成功 "+iSuccess+" 条 失败 "+iFailure+" 条"); } }else{ alert("未选中要操作的费用项"); } }else{ alert("委托已退载,费用修改费用"); return; } } //动态计算费用利润信息 function totalDynamicFeeGain(){ //获取应收费用列表行数 var rowCount_recv = mygrid_recv.getRowsNum(); var usdSum_recv = 0.0;//美元合计-应收 var rmbSum_recv = 0.0;//人民币合计-应收 var otherSum_recv = 0.0;//其他币别合计-应收 var totalAmount_recv = 0.0//应收合计-包括除人民币以外其他币别折合成人民币 var usdSum_pay = 0.0;//美元合计-应付 var rmbSum_pay = 0.0;//人民币合计-应付 var otherSum_pay = 0.0;//其他币别合计-应付 var totalAmount_pay = 0.0//应付合计-包括除人民币以外其他币别折合成人民币 var usdGain = 0.0//美元利润 var rmbGain = 0.0//人民币利润 var otherGain = 0.0//其他币别利润 var totalGain = 0.0//合计利润 var gainRate = 0.0//利润比率 //计算应收费用 for(var i = 0;i 0 ? exchangeRate_recv : 1)); break; case "rmb": rmbSum_recv = rmbSum_recv + parseFloat(amount); totalAmount_recv += parseFloat(amount); break; default: otherSum_recv = otherSum_recv + parseFloat(amount); totalAmount_recv += (parseFloat(amount) * (exchangeRate_recv > 0 ? exchangeRate_recv : 1)); break; } } $("dvUSRecvVal").innerHTML = outputMoney(usdSum_recv.toString()); $("dvRecvRMBVal").innerHTML = outputMoney(rmbSum_recv.toString()); $("dvOtherCurrencyRecvVal").innerHTML = outputMoney(otherSum_recv.toString()); $("dvRecvTotalVal").innerHTML = outputMoney(totalAmount_recv.toString()); //获取应付费用列表行数 var rowCount_pay = mygrid_pay.getRowsNum(); //计算应收费用 for(var j = 0;j 0 ? exchangeRate_pay : 1)); break; case "rmb": rmbSum_pay = parseFloat(rmbSum_pay) + parseFloat(amount); totalAmount_pay += parseFloat(amount); break; default: otherSum_pay = otherSum_pay + parseFloat(amount); totalAmount_pay += (parseFloat(amount) * (exchangeRate_pay > 0 ? exchangeRate_pay : 1)); break; } } //alert(usdSum_pay);alert(rmbSum_pay);alert(otherSum_pay);alert(totalAmount_pay); $("dvUSPayVal").innerHTML = outputMoney(usdSum_pay.toString()); $("dvPayRMBVal").innerHTML = outputMoney(rmbSum_pay.toString()); $("dvOtherCurrencyPayVal").innerHTML = outputMoney(otherSum_pay.toString()); $("dvPaySumVal").innerHTML = outputMoney(totalAmount_pay.toString()); //计算利润 usdGain = usdSum_recv - usdSum_pay;//美元利润 rmbGain = rmbSum_recv - rmbSum_pay;//人民币利润 otherGain = otherSum_recv - otherSum_pay;//其他币别利润 totalGain = totalAmount_recv - totalAmount_pay;//利润合计 $("dvUSProfitVal").innerHTML = outputMoney(usdGain.toString()); if(usdGain < 0 || usdGain == 0){ $("dvUSProfitVal").style.color = "#007F00"; } $("dvRMBProfitVal").innerHTML = outputMoney(rmbGain.toString()); if(rmbGain < 0 || rmbGain == 0){ $("dvRMBProfitVal").style.color = "#007F00"; } $("dvOtherCurrencyProfitVal").innerHTML = outputMoney(otherGain.toString()); if(otherGain < 0 || otherGain == 0){ $("dvOtherCurrencyProfitVal").style.color = '#007F00'; } $("dvProfitTotalVal").innerHTML = outputMoney(totalGain.toString()); if(totalGain < 0 || totalGain == 0){ $("dvProfitTotalVal").style.color = "#007F00"; } if(totalAmount_recv == 0){ $("dvProfitRateVal").innerHTML = "0%"; $("dvProfitRateVal").style.color = "#007F00"; }else{ //利润合计除以应付费用 gainRate = (totalGain / totalAmount_recv) * 100; var percentage = gainRate.toFixed(2); $("dvProfitRateVal").innerHTML = percentage.toString() + "%"; } } function amountSum(gridName){//未调用、未完成 if(gridName == "recv"){ //计算应收 mygrid_recv }else{ //计算应付 } } //输出money function outputMoney(number) { number= number.replace(/\,/g,""); if (isNaN(number)||number=="") return ""; number = Math.round( number*10000) /10000; if (number < 0) { var sdf = '-' + outputDollars(Math.floor(Math.abs(number) - 0) + '') + outputCents(Math.abs(number) - 0); return '-' + outputDollars(Math.floor(Math.abs(number) - 0) + '') + outputCents(Math.abs(number) - 0); } else { var sdf = outputDollars(Math.floor(number - 0) + '') + outputCents(number - 0); return outputDollars(Math.floor(number - 0) + '') + outputCents(number - 0); } } //输出美元 function outputDollars(number) { if (number.length<= 3) return (number == '' ? '0' : number); else { var mod = number.length%3; var output = (mod == 0 ? '' : (number.substring(0,mod))); for (i=0 ; i< Math.floor(number.length/3) ; i++) { if ((mod ==0) && (i ==0)) output+= number.substring(mod+3*i,mod+3*i+3); else output+= ',' + number.substring(mod+3*i,mod+3*i+3); } return (output); } } function outputCents(amount) { var ls = ""; amount = Math.round(((amount) - Math.floor(amount)) * 10000); if (amount < 10) { ls = '.000' + amount; } else if (amount < 100) { ls = '.00' + amount; } else if (amount < 1000) { ls = '.0' + amount; } else if (amount < 10000) { ls = '.' + amount; } //return (amount<10 ? '.000' + amount : '.' + amount); return ls; } //获取GUID function newGuid() { var guid = ""; for (var i = 1; i <= 32; i++){ var n = Math.floor(Math.random()*16.0).toString(16); guid += n; if((i==8)||(i==12)||(i==16)||(i==20)) guid += "-"; } return guid.toUpperCase(); } //对话框 function dialog() { // alert("打开dialog"); this.width=450; this.height=360; this.title_height=20; this.html=''; this.title=''; var self = this; var bgObj,msgObj,titleObj; this.close=function() { document.body.removeChild(document.getElementById("bgDiv")); document.getElementById("msgDiv").removeChild(document.getElementById("msgTitle")); document.body.removeChild(document.getElementById("msgDiv")); } this.show=function() { var msgw,msgh,bordercolor; msgw=self.width; msgh=self.height; bordercolor="#336699"; titlecolor="#99CCFF"; var sWidth,sHeight; sWidth=document.body.offsetWidth; sHeight=screen.height; bgObj=document.createElement("div"); bgObj.setAttribute('id','bgDiv'); bgObj.style.position="absolute"; bgObj.style.top="0"; bgObj.style.background="#777"; bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75"; bgObj.style.opacity="0.6"; bgObj.style.left="0"; bgObj.style.width=sWidth + "px"; bgObj.style.height=sHeight + "px"; bgObj.style.zIndex = "10000"; document.body.appendChild(bgObj); msgObj=document.createElement("div") msgObj.setAttribute("id","msgDiv"); msgObj.setAttribute("align","center"); msgObj.style.background="white"; msgObj.style.border="1px solid " + bordercolor; msgObj.style.position = "absolute"; msgObj.style.left = "50%"; msgObj.style.top = "30%"; msgObj.style.font="12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif"; msgObj.style.marginLeft = "-225px" ; msgObj.style.marginTop = -75+document.documentElement.scrollTop+"px"; msgObj.style.width = msgw + "px"; msgObj.style.height =msgh + "px"; msgObj.style.textAlign = "center"; msgObj.style.lineHeight ="25px"; msgObj.style.zIndex = "10001"; titleObj=document.createElement("h4"); titleObj.setAttribute("id","msgTitle"); titleObj.setAttribute("align","center"); titleObj.style.margin="0"; titleObj.style.padding="3px"; titleObj.style.background=bordercolor; titleObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(startX=20, startY=20, finishX=100, finishY=100,style=1,opacity=75,finishOpacity=100);"; titleObj.style.opacity="0.75"; titleObj.style.border="1px solid " + bordercolor; titleObj.style.height=self.title_height+"px"; titleObj.style.font="12px Verdana, Geneva, Arial, Helvetica, sans-serif"; titleObj.style.color="white"; titleObj.style.cursor="pointer"; titleObj.innerHTML=self.title; //titleObj.onclick=function(){self.close();} document.body.appendChild(msgObj); document.getElementById("msgDiv").appendChild(titleObj); var txt=document.createElement("div"); txt.style.margin="1em 0" txt.setAttribute("id","msgTxt"); txt.innerHTML=self.html; document.getElementById("msgDiv").appendChild(txt); } } //信息提示 function msgBox(){ var dg=new dialog(); dg.html="费用正在保存中,请稍等……";//""; dg.width=200; dg.height=100; dg.title=""; dg.show(); } //是否为数字 function IsNum(val){ var re = /^[-\+]?\d+(\.\d+)?$/; if (!re.test(val)){ return false; }else{ return true; } } //去除“,” function ConvertToMoney(strObj){ var result = strObj.replace(",",""); return result; } //将页面利润信息存入变量gainContainer function GetGainArg(){ var gainArg = new Array(); var ls = ""; if ($("dvRecvRMBVal").innerHTML.trim() == "" || $("dvRecvRMBVal").innerHTML.trim() == "NaN") { ls = "0"; } else { ls = $("dvRecvRMBVal").innerHTML.trim(); } gainArg.push(ConvertToMoney(ls)); if ($("dvUSRecvVal").innerHTML.trim() == "" || $("dvUSRecvVal").innerHTML.trim() == "NaN") { ls = "0"; } else { ls = $("dvUSRecvVal").innerHTML.trim(); } gainArg.push(ConvertToMoney(ls)); if ($("dvOtherCurrencyRecvVal").innerHTML.trim() == "" || $("dvOtherCurrencyRecvVal").innerHTML.trim() == "NaN") { ls = "0"; } else { ls = $("dvOtherCurrencyRecvVal").innerHTML.trim(); } gainArg.push(ConvertToMoney(ls)); if ($("dvPayRMBVal").innerHTML.trim() == "" || $("dvPayRMBVal").innerHTML.trim() == "NaN") { ls = "0"; } else { ls = $("dvPayRMBVal").innerHTML.trim(); } gainArg.push(ConvertToMoney(ls)); if ($("dvUSPayVal").innerHTML.trim() == "" || $("dvUSPayVal").innerHTML.trim() == "NaN") { ls = "0"; } else { ls = $("dvUSPayVal").innerHTML.trim(); } gainArg.push(ConvertToMoney(ls)); if ($("dvOtherCurrencyPayVal").innerHTML.trim() == "" || $("dvOtherCurrencyPayVal").innerHTML.trim() == "NaN") { ls = "0"; } else { ls = $("dvOtherCurrencyPayVal").innerHTML.trim(); } gainArg.push(ConvertToMoney(ls)); if ($("dvRecvTotalVal").innerHTML.trim() == "" || $("dvRecvTotalVal").innerHTML.trim() == "NaN") { ls = "0"; } else { ls = $("dvRecvTotalVal").innerHTML.trim(); } gainArg.push(ConvertToMoney(ls)); if ($("dvPaySumVal").innerHTML.trim() == "" || $("dvPaySumVal").innerHTML.trim() == "NaN") { ls = "0"; } else { ls = $("dvPaySumVal").innerHTML.trim(); } gainArg.push(ConvertToMoney(ls)); if ($("dvRMBProfitVal").innerHTML.trim() == "" || $("dvRMBProfitVal").innerHTML.trim() == "NaN") { ls = "0"; } else { ls = $("dvRMBProfitVal").innerHTML.trim(); } gainArg.push(ConvertToMoney(ls)); if ($("dvUSProfitVal").innerHTML.trim() == "" || $("dvUSProfitVal").innerHTML.trim() == "NaN") { ls = "0"; } else { ls = $("dvUSProfitVal").innerHTML.trim(); } gainArg.push(ConvertToMoney(ls)); if ($("dvOtherCurrencyProfitVal").innerHTML.trim() == "" || $("dvOtherCurrencyProfitVal").innerHTML.trim() == "NaN") { ls = "0"; } else { ls = $("dvOtherCurrencyProfitVal").innerHTML.trim(); } gainArg.push(ConvertToMoney(ls)); if ($("dvProfitTotalVal").innerHTML.trim() == "" || $("dvProfitTotalVal").innerHTML.trim() == "NaN") { ls = "0"; } else { ls = $("dvProfitTotalVal").innerHTML.trim(); } gainArg.push(ConvertToMoney(ls)); if ($("dvProfitRateVal").innerHTML.trim() == "" || $("dvProfitRateVal").innerHTML.trim() == "NaN") { ls = "0%"; } else { ls = $("dvProfitRateVal").innerHTML.trim(); } gainArg.push(ConvertToMoney(ls)); // // gainArg.push(ConvertToMoney($("dvRecvRMBVal").innerHTML)); // gainArg.push(ConvertToMoney($("dvUSRecvVal").innerHTML)); // gainArg.push(ConvertToMoney($("dvOtherCurrencyRecvVal").innerHTML)); // // gainArg.push(ConvertToMoney($("dvPayRMBVal").innerHTML)); // gainArg.push(ConvertToMoney($("dvUSPayVal").innerHTML)); // gainArg.push(ConvertToMoney($("dvOtherCurrencyPayVal").innerHTML)); // // gainArg.push(ConvertToMoney($("dvRecvTotalVal").innerHTML)); // gainArg.push(ConvertToMoney($("dvPaySumVal").innerHTML)); // // gainArg.push(ConvertToMoney($("dvRMBProfitVal").innerHTML)); // gainArg.push(ConvertToMoney($("dvUSProfitVal").innerHTML)); // gainArg.push(ConvertToMoney($("dvOtherCurrencyProfitVal").innerHTML)); // gainArg.push(ConvertToMoney($("dvProfitTotalVal").innerHTML)); // gainArg.push($("dvProfitRateVal").innerHTML); $("gainContainer").value = gainArg; } //过滤结算单位ComboCustomer的键盘 function filterComboCustomerPress(gridObj,rowID,rowIndex,colIndex,filterVal,oldVal){ var combo = gridObj.getCustomCombo(rowID,colIndex); var comboArg = combo.getKeys(); var doCount = 0; for(var i = 0;i 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } // //if(parseInt($("h_recvauthority").value) <= 0){ // if(!validOperatePower(rId,1)){ // return; // } if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){ alert("应付费用未保存,请先保存应付费用"); return; } if(opStatus == 1){ var iCount = 0; var recvArg = new Array(); for(var i=0;i 0){ if(recvArg.length > 0){ if(window.confirm("您确定将所选应收费用提交审核")){ var delCount = 0; var loadVal = 0; while(delCount < recvArg.length){ var rowIndex = mygrid_recv.getRowIndex(recvArg[delCount]); var feeName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); var cusName = mygrid_recv.cellByIndex(rowIndex,3).getValue(); //更新费用信息ch_fee.feestatus和工作流运行表WorkFlowDo信息,返回操作结果 var urlVal = "../AuditProcess/AuditService.aspx?handle=audit&oplb="+stroplb+"&id="+recvArg[delCount]+"&val="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); loadVal = loader.xmlDoc.responseText; if(loadVal > 0){ iSuccess++; if(iSuccess == 1){ postBillNO = recvArg[delCount]; } }else{ iFailure++; } delCount++; } if(delCount > 0){ if (loadVal != 10 && loadVal > 0) { //向审核人发送申请消息 var postUrlVal = "../message/messageservice.aspx?billno="+postBillNO+"&type=1&oplb="+stroplb+"&handle=postmessage&bsno="+bsno+"&uid="+newGuid();; var loader = dhtmlxAjax.getSync(postUrlVal); var loadVal = loader.xmlDoc.responseText; } alert("提交应收费用审核 "+delCount+" 条 成功 "+iSuccess+" 条 失败 "+iFailure+" 条"); } doInitRecvGrid(); } } }else{ alert("未选中要操作的费用项"); } }else{ alert("委托已退载,费用不能添加"); return; } } //应付费用提交审核 function orderPayAudit(){ var iSuccess = 0; var iFailure = 0; var postBillNO = ""; var bsno = $("h_bsno").value; if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();; var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; var validStatusObj = eval('(' + loadVal + ')'); var opStatus = 0; var feeStatus = 0; if(validStatusObj.valid.length > 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } // if(parseInt($("h_payauthority").value) <= 0){ // return; // } if(newFeePayCount > 0 || changeFeePayCount > 0){ alert("应收费用未保存,请先将应收费用保存,提交应付费用-提交审核"); return false; } if(opStatus == 1){ var iCount = 0; var recvArg = new Array(); for(var i=0;i 0){ if(recvArg.length > 0){ if(window.confirm("您确定将所选应付费用提交审核")){ var delCount = 0; var loadVal = 0; while(delCount < recvArg.length){ var rowIndex = mygrid_pay.getRowIndex(recvArg[delCount]); var feeName = mygrid_pay.cellByIndex(rowIndex,2).getValue(); var cusName = mygrid_pay.cellByIndex(rowIndex,3).getValue(); //更新费用信息ch_fee.feestatus和工作流运行表WorkFlowDo信息,返回操作结果 var urlVal = "../AuditProcess/AuditService.aspx?handle=audit&oplb=" + stroplb + "&id=" + recvArg[delCount] + "&val=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); loadVal = loader.xmlDoc.responseText; if (loadVal > 0) { iSuccess++; if(iSuccess == 1){ postBillNO = recvArg[delCount]; } }else{ iFailure++; } delCount++; } if (delCount > 0) { if (loadVal != 10 && loadVal > 0) { //向审核人发送申请消息 var postUrlVal = "../message/messageservice.aspx?billno=" + postBillNO + "&type=1&oplb=" + stroplb + "&handle=postmessage&bsno="+bsno+ "&uid=" + newGuid(); ; var loader = dhtmlxAjax.getSync(postUrlVal); var loadVal = loader.xmlDoc.responseText; } alert("提交应付费用审核 "+delCount+" 条 成功 "+iSuccess+" 条 失败 "+iFailure+" 条"); } doInitPayGrid(); } } }else{ alert("未选中要操作的费用项"); } }else{ alert("委托已退载,费用不能添加"); return; } } //应收费用申请修改 function orderRecvModify(){ var iSuccess = 0; var iFailure = 0; var bsno = $("h_bsno").value; if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; var validStatusObj = eval('(' + loadVal + ')'); var opStatus = 0; var feeStatus = 0; if(validStatusObj.valid.length > 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } //if(parseInt($("h_recvauthority").value) <= 0){ //return; // } if(opStatus == 1){ if(newFeePayCount > 0 || changeFeePayCount > 0){ alert("应付费用未保存,先保存应付费用再进行应收费用--申请修改"); return; } var iCount = 0; var recvArg = new Array(); for(var i=0;i 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } // if(parseInt($("h_payauthority").value) <= 0){ // return; // } if(opStatus == 1){ if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){ alert("应收费用未保存,请先将应收费用保存,再提交应付费用-申请修改"); return false; } var iCount = 0; var recvArg = new Array(); for(var i=0;i 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } // if(parseInt($("h_recvauthority").value) <= 0){ // return; // } if(opStatus == 1){ if(newFeePayCount > 0 || changeFeePayCount > 0){ alert("应付费用未保存,先保存应付费用再进行应收费用-申请删除操作"); return; } var iCount = 0; var recvArg = new Array(); for(var i=0;i 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } // if(parseInt($("h_payauthority").value) <= 0){ // return; // } if(opStatus == 1){ // if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){ // alert("应收费用未保存,请先将应收费用保存,再提交应付费用-申请删除"); // return false; // } var iCount = 0; var recvArg = new Array(); for(var i=0;i 0 || changeFeePayCount > 0){ // alert("应收费用未保存,请先将应收费用保存,再查看历史申请"); // return; // } var iCount = 0; var recvArg = new Array(); for(var i=0;i 1){ alert("每次只能查看一项费用信息"); }else{ alert("未选中要操作的费用项"); } } //应付费用历史申请 function applyPayHistory(){ // if(parseInt($("h_payauthority").value) <= 0){ // return; // } var iCount = 0; var recvArg = new Array(); for(var i=0;i 1){ alert("每次只能查看一项费用信息"); }else{ alert("未选中要操作的费用项"); } } //刷新grid的Label function ReShowLabel(gridObj){ var columnCount = gridObj.getColumnsNum(); var rowCount = gridObj.getRowsNum(); if(rowCount > 0){ for(var i = 0;i 0){ for(var i = 0;i 0){ if(valObj.indexOf("-") == 0){ valObj = "-"+valObj.replace(/-/g,""); }else{ valObj = valObj.replace(/-/g,""); } } return valObj; } //依据费用状态设置对应行的背景颜色 function markStatusColor(gridObj){ var count = gridObj.getRowsNum(); for(var i = 0;i 0 || changeFeeRecvCount > 0){ if(window.confirm("应收费用未保存,您确定要刷新应收费用列表,刷新后自动放弃未保存内容")){ doInitRecvGrid(); newFeeRecvCount = 0; changeFeeRecvCount = 0; } }else{ doInitRecvGrid(); } } //刷新应付费用 function refreshPay(){ if(newFeePayCount > 0 || changeFeePayCount > 0){ if(window.confirm("应付费用未保存,您确定要刷新应付费用列表,刷新后自动放弃未保存内容")){ doInitPayGrid(); newFeePayCount = 0; changeFeePayCount = 0; } }else{ doInitPayGrid(); } } //应收费用查看信息 function checkRecvHistory(){ // var iCount = 0; // var recvArg = new Array(); // // for(var i=0;i 1){ // // }else{ // alert("未选中要操作的费用项"); // } var strBSNO = $("h_bsno").value; var openSet = "height=540, width=890, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-540)/2 + ",Left= "+(screen.width-890)/2 var openType = "_blank"; //打开费用“历史信息查询”页面 var openUrl = "../Shipping/FeeHistory.aspx?bsno="+strBSNO+"&oplb="+stroplb+"&type=1"; window.open (openUrl,openType,openSet); } //应付费用查看信息 function checkPayHistory(){ // var iCount = 0; // var recvArg = new Array(); // // for(var i=0;i 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } if(opStatus == 1){ if(newFeePayCount > 0 || changeFeePayCount > 0){ alert("应付费用未保存,先保存应付费用,再操作应收费用-引入费用模板"); return; } var openSet = "height=700, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top=10,Left= " + (screen.width - 900) / 2; var openType = "_blank"; //打开应收费用“引入费用模板”页面 var openUrl = "../Shipping/ImportFeeTemplate.aspx?handle=import&oplb="+stroplb+"&type=1"; window.open (openUrl,openType,openSet); }else{ alert("委托已退载,不能引入费用"); return; } } //打开应付费用模板 function importPayTemplate(){ if(!validOperatePower("",2,"import")){ alert("没有权限操作数据"); return; } var bsno = $("h_bsno").value; if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();; var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; var validStatusObj = eval('(' + loadVal + ')'); var opStatus = 0; var feeStatus = 0; if(validStatusObj.valid.length > 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } if(opStatus == 1){ if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){ alert("应收费用未保存,先保存应收费用,再操作应付费用-引入费用模板"); return; } var openSet = "height=700, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top=10,Left= " + (screen.width - 900) / 2; var openType = "_blank"; //打开应付费用“引入费用模板”页面 var openUrl = "../Shipping/ImportFeeTemplate.aspx?handle=import&oplb="+stroplb+"&type=2"; window.open (openUrl,openType,openSet); }else{ alert("委托已退载,不能引入费用"); return; } } //检查浏览器是否是Ie var isIe=(document.all)?true:false; //设置select的可见状态 function setSelectState(state){ var objl=document.getElementsByTagName('select'); for(var i=0;i" + "" + "
"+content+"
"; 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 0 || changeFeeRecvCount > 0){ alert("应收费用未保存,请先保存之后再打印"); return; } for (var j = 0; j < checkedArg.length; j++) { var rowIndex = mygrid_recv.getRowIndex(checkedArg[j]); var customerName = mygrid_recv.cellByIndex(rowIndex, 3).getValue().trim(); var iCount = 0; for(var i=0;i 0 || changeFeePayCount > 0){ alert("应付费用未保存,请先保存之后再打印"); return; } for (var j = 0; j < checkedArg.length; j++) { var rowIndex = mygrid_pay.getRowIndex(checkedArg[j]); var customerName = mygrid_pay.cellByIndex(rowIndex, 3).getValue().trim(); var iCount = 0; for(var i=0;i"+feeNameArg[k]+""; } var objPos = mousePosition(ev); messContent = "
" +"
" // +" " +"
" +"
" +" " +" " +"
" +"
"; showMessageBox('费用打印',messContent,objPos,350); } //打印报表 function printReport(){ var strBSNO = ""; var typeName = ""; strBSNO = $("h_bsno").value; var printUrl = ""; var companyID = ""; var typeName = "SEAOPFEE"; var dbSourceID = ""; var userID = ""; var selectObj = $("reportType"); var selVal = parseInt(selectObj.options[selectObj.selectedIndex].value); var url = ""; var searchCustomer = ""; var selectedObj = $("sel_print"); // for(var j=0;j 0){ if(reportObj.reports[0].compid != ""){ companyID = reportObj.reports[0].compid; } if(reportObj.reports[0].sourceid != ""){ dbSourceID = reportObj.reports[0].sourceid; } if(reportObj.reports[0].compid != ""){ userID = reportObj.reports[0].userid; } printUrl = "print://?comp="+companyID+"&type="+typeName+"&dbid="+dbSourceID+"&oplb="+stroplb+"&uid="+userID;//alert(printUrl); window.location.href = window.location.href; //本页面跳转 location.href = printUrl; //跳转到打印页面 } }else{ alert("没有要打印的报表"); return; } } //打印应收费用报表 function onReportTypeChange(id){ var selectObj = $(id); var selVal = parseInt(selectObj.options[selectObj.selectedIndex].value); if(selVal == 3){ $("sel_customer").disabled = 1; $("sel_print").disabled = 1; $("dvRemove").disabled = 1; $("dvAdd").disabled = 1; } pageShowCount = selVal; } //鼠标移过图标变化 function mouseMoveImg(obj,type){ var imgUrl = obj.src; var urlArg = imgUrl.split("/"); if(type == 1){ if(urlArg[urlArg.length-1] == "edit_left.gif"){ var newUrl = ""; for(var i=0;i 0){ for(var i=0;i 0){ var delCount = 0; if(recvArg.length > 0){ while(delCount < recvArg.length){ var newId = newGuid(); //获取插入新纪录位置 var rowCount = mygrid_recv.getRowsNum(); var rowIndex = mygrid_recv.getRowIndex(recvArg[delCount]); //var feeStatus = mygrid_recv.cellByIndex(rowIndex,1).getValue(); var feeName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); var custName = mygrid_recv.cellByIndex(rowIndex,3).getValue(); var unit = mygrid_recv.cellByIndex(rowIndex,4).getValue(); var unitprice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue()))); var quantity = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,6).getValue()))); var comm = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,7).getValue()))); var amount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,8).getValue()))); var currency = mygrid_recv.cellByIndex(rowIndex,9).getValue(); var rate = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,10).getValue()))); var frt = mygrid_recv.cellByIndex(rowIndex,11).getValue(); var remark = mygrid_recv.cellByIndex(rowIndex,12).getValue(); var isadvance = mygrid_recv.cellByIndex(rowIndex,13).getValue(); var linenum = rowCount + 1; mygrid_recv.addRow(newId, [0, "录入状态", feeName, custName, unit, unitprice, quantity, comm, amount, currency, rate, frt, remark, isadvance, 0, 0, '', '', '', '', wmsoutbsno, linenum], rowCount); delCount++; var combo_currency; combo_currency = mygrid_recv.getCustomCombo(newId,9); setCurrencyCombo(combo_currency); var combo_feename; combo_feename = mygrid_recv.getCustomCombo(newId,2); setFeeNameCombo(combo_feename); var combo_cust; combo_cust = mygrid_recv.getCustomCombo(newId,3); setCustomerCombo(combo_cust,newId); var combo_unit; combo_unit = mygrid_recv.getCustomCombo(newId,4); setUnitCombo(combo_unit); var combo_frt; combo_frt = mygrid_recv.getCustomCombo(newId,11); setFrtCombo(combo_frt); } //totalDynamicFeeGain(); } }else{ alert("未选中要操作的费用项"); } // //查看是否有被选中的费用项 // if(selGroup.length > 0){ // for(var i=0;i 0){ var delCount = 0; if(recvArg.length > 0){ while(delCount < recvArg.length){ var newId = newGuid(); //获取插入新纪录位置 var rowCount = mygrid_pay.getRowsNum(); var rowIndex = mygrid_pay.getRowIndex(recvArg[delCount]); //var feeStatus = mygrid_recv.cellByIndex(rowIndex,1).getValue(); var feeName = mygrid_pay.cellByIndex(rowIndex,2).getValue(); var custName = mygrid_pay.cellByIndex(rowIndex,3).getValue(); var unit = mygrid_pay.cellByIndex(rowIndex,4).getValue(); var unitprice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,5).getValue()))); var quantity = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,6).getValue()))); var comm = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,7).getValue()))); var amount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,8).getValue()))); var currency = mygrid_pay.cellByIndex(rowIndex,9).getValue(); var rate = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,10).getValue()))); var frt = mygrid_pay.cellByIndex(rowIndex,11).getValue(); var remark = mygrid_pay.cellByIndex(rowIndex,12).getValue(); var isadvance = mygrid_pay.cellByIndex(rowIndex,13).getValue(); var linenum = rowCount + 1; mygrid_pay.addRow(newId, [0, "录入状态", feeName, custName, unit, unitprice, quantity, comm, amount, currency, rate, frt, remark, isadvance, 0, 0, '', '', '', '', wmsoutbsno, linenum], rowCount); delCount++; } //totalDynamicFeeGain(); } }else{ alert("未选中要操作的费用项"); } } function checkAll(id){//全选 if(id == "recv"){ for(var i=0;i 0){ // for(var i = 0;i < jsonCacheObj.feecode.length;i++){ // obj.put(jsonCacheObj.feecode[i].name,jsonCacheObj.feecode[i].code); // } // } } //function initLoading(){ // $("progressBar").style.display = ""; //} //function finishLoading(){ // $("progressBar").style.display = "none"; //} function initMenu(){//初始化菜单 initRecvMenu(); initPayMenu(); } function initRecvMenu(){//初始化应收费用菜单“引入费用” // recv_menu = new dhtmlXMenuObject("recvMenuObj"); recv_menu=new dhtmlXMenuObject("recvMenuObj"); recv_menu.setIconsPath("../images/"); recv_menu.addNewSibling(null, "master", "引入费用"); recv_menu.addNewChild("master", 0, "history", "历史引入", false); recv_menu.addNewChild("master", 1, "establishpay", "生成应付", false); recv_menu.addNewChild("master", 1, "template", "引入费用模板", false); recv_menu.addNewChild("establishpay", 1, "importpayselect", "所选生成", false); recv_menu.addNewChild("establishpay", 1, "importpayvall", "所有生成", false); if($("h_enable").value == "0"){ return; } recv_menu.attachEvent("onClick", function(id, zoneId, casState){ switch(id){ case "history": importRecvHistory(); break; case "establishpay": break; case "template": importRecvTemplate(); break; case "importpayselect": establishPay(1); break; case "importpayvall": establishPay(2); break; } }); } function initPayMenu(){//初始化应付费用菜单“引入费用” pay_menu = new dhtmlXMenuObject("payMenuObj"); pay_menu.setIconsPath("../images/"); pay_menu.addNewSibling(null, "master", "引入费用"); pay_menu.addNewChild("master", 0, "history", "历史引入", false); pay_menu.addNewChild("master", 1, "establishrecv", "生成应收", false); pay_menu.addNewChild("master", 1, "template", "引入费用模板", false); pay_menu.addNewChild("establishrecv", 1, "importrecvselect", "所选生成", false); pay_menu.addNewChild("establishrecv", 1, "importrecvall", "所有生成", false); if($("h_enable").value == "0"){ return; } pay_menu.attachEvent("onClick", function(id, zoneId, casState){ switch(id){ case "history": importPayHistory(); break; case "establishpay": break; case "template": importPayTemplate(); break; case "importrecvselect": establishRecv(1); break; case "importrecvall": establishRecv(2); break; } }); } function equalInput(type){ if(type == 1){ }else if(type == 2){ } } function importRecvHistory(){//应收费用菜单“历史引入” if(!validOperatePower("",1,"import")){ alert("没有权限操作数据"); return; } var bsno = $("h_bsno").value; if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();; var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; var validStatusObj = eval('(' + loadVal + ')'); var opStatus = 0; var feeStatus = 0; if(validStatusObj.valid.length > 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } if(opStatus == 1){ if(newFeePayCount > 0 || changeFeePayCount > 0){ alert("应付费用未保存,先保存应付费用,再操作应收费用-引入历史"); return; } var openSet = "height=600, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-600)/2 + ",Left= "+(screen.width-900)/2 var openType = "_blank"; //打开应收费用“历史引入”页面 var openUrl = "../Shipping/ImportFeeHistory.aspx?handle=import&oplb="+stroplb+"&historytype=1"; window.open (openUrl,openType,openSet); }else{ alert("委托已退载,不能引入费用"); return; } } function importPayHistory(){//应付费用菜单“历史引入” if(!validOperatePower("",2,"import")){ alert("没有权限操作数据"); return; } var bsno = $("h_bsno").value; if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "../Shipping/FeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb="+stroplb+"&uid="+newGuid();; var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; var validStatusObj = eval('(' + loadVal + ')'); var opStatus = 0; var feeStatus = 0; if(validStatusObj.valid.length > 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } if(opStatus == 1){ if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){ alert("应收费用未保存,先保存应收费用,再操作应付费用-引入历史"); return; } var openSet = "height=600, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-600)/2 + ",Left= "+(screen.width-900)/2 var openType = "_blank"; //打开应付费用“历史引入”页面 var openUrl = "../Shipping/ImportFeeHistory.aspx?handle=import&oplb="+stroplb+"&historytype=2"; window.open (openUrl,openType,openSet); }else{ alert("委托已退载,不能引入费用"); return; } } function establishPay(type){//type=1 只复制算选的费用到应付 type=2复制所有到应付 for(var i=0;i 0){ if(quantityObj.quantity[0].value > 0){ mygrid_pay.cellByIndex(rowIndex,4).setValue(quantityObj.quantity[0].name); mygrid_pay.cellByIndex(rowIndex,6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString())); } } }else{ mygrid_pay.cellByIndex(rowIndex,6).setValue(1); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,5).getValue()))); var quantityCount = 1;//clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString())); } }else{ var quantityObj = null; cknum=mygrid_pay.cellByIndex(rowIndex,6).getValue(); quantityObj = getTypeNameQuantity(unit,cknum); if(quantityObj.quantity.length > 0){ if(quantityObj.quantity[0].value > 0){ mygrid_pay.cellByIndex(rowIndex,4).setValue(quantityObj.quantity[0].name); mygrid_pay.cellByIndex(rowIndex,6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString())); }else{ if(getTypeNum(unit) >= 1){ mygrid_pay.cellByIndex(rowIndex,6).setValue(0); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,5).getValue()))); var quantityCount = 0;//clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_pay.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString())); } } } } } if(feeCodeObj.feecode[0].credit > 0){ var debitObj = null; debitObj = getDebitType(feeCodeObj.feecode[0].credit); if(debitObj.debit.length > 0){ if(debitObj.debit[0].value.trim() != ""){ mygrid_pay.cellByIndex(rowIndex,3).setValue(debitObj.debit[0].value); } } } ReShowLabel(mygrid_pay); //totalDynamicFeeGain(); } } } } } } function establishRecv(type){//type=1 只复制算选的费用到应收 type=2复制所有到应收 for(var i=0;i 0){ if(quantityObj.quantity[0].value > 0){ mygrid_recv.cellByIndex(rowIndex,4).setValue(quantityObj.quantity[0].name); mygrid_recv.cellByIndex(rowIndex,6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString())); } } }else{ mygrid_recv.cellByIndex(rowIndex,6).setValue(1); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue()))); var quantityCount = 1; var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString())); } }else{ var quantityObj = null; cknum=mygrid_recv.cellByIndex(rowIndex,6).getValue(); quantityObj = getTypeNameQuantity(unit,cknum); if(quantityObj.quantity.length > 0){ if(quantityObj.quantity[0].value > 0){ mygrid_recv.cellByIndex(rowIndex,4).setValue(quantityObj.quantity[0].name); mygrid_recv.cellByIndex(rowIndex,6).setValue(quantityObj.quantity[0].value); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString())); }else{ if(getTypeNum(unit) >= 1){ mygrid_recv.cellByIndex(rowIndex,6).setValue(0); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,5).getValue()))); var quantityCount = 0;//clearNoNum(isObjNaN(ConvertToMoney(quantityObj.quantity[0].value.toString()))); var amount = unitPrice * quantityCount; mygrid_recv.cellByIndex(rowIndex,8).setValue(outputMoney(amount.toString())); } } } } } if(feeCodeObj.feecode[0].debit > 0){ var debitObj = null; debitObj = getDebitType(feeCodeObj.feecode[0].debit); if(debitObj.debit.length > 0){ if(debitObj.debit[0].value.trim() != ""){ mygrid_recv.cellByIndex(rowIndex,3).setValue(debitObj.debit[0].value); } } } ReShowLabel(mygrid_recv); //totalDynamicFeeGain(); } } } } } } var h_Customer = ""; function setCustomerCombo(obj, id) {//返回info_client结算单位 var customerInfo = ""; if ($("h_custcache").value.trim() != "") { customerInfo = $("h_custcache").value.trim(); } else {//返回info_client结算单位JSON字符串 var url = "../FeeCodes/CRMClientInfo.aspx?handle=client&oplb=" + stroplb + "&uid=" + newGuid(); var loader = dhtmlxAjax.getSync(url); customerInfo = loader.xmlDoc.responseText; } var jsonCacheObj = eval('(' + customerInfo + ')'); if (jsonCacheObj.customer.length > 0) { for (var i = 0; i < jsonCacheObj.customer.length; i++) { obj.put(jsonCacheObj.customer[i].name, jsonCacheObj.customer[i].code.toString().toLowerCase() + ' ' + jsonCacheObj.customer[i].name); } } } function getGain() { var url = "../Shipping/feegridsource.aspx?read=getgain&oplb=" + stroplb + "&bsno=" + $("h_bsno").value.trim() + "&val=" + newGuid(); var loader = dhtmlxAjax.getSync(url); var ls = loader.xmlDoc.responseText; }