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; function $(id){ return document.getElementById(id); } function document.onkeydown(){ if(event.keyCode == 8){ if(document.selection){ var range = document.selection.createRange();; if(range.parentElement().name == null){ return false; }else{ return true; } } } } function clickNull(){ } function doInitRecvGrid(){ // alert("doInitRecvGrid"); enableAction(); mygrid_recv = new dhtmlXGridObject('mygrid_container_recv'); mygrid_recv.setImagePath("../images/"); mygrid_recv.setSkin("xp"); mygrid_recv.setHeader(",费用状态,应收费用名称,结算单位,计费标准,单价,数量,佣金比例,金额,币别,汇率,FRT,费用备注,是否垫付,结算金额,开票金额,发票号码,录入人,录入时间,TID"); mygrid_recv.setInitWidths("40,70,110,150,70,80,80,90,90,50,70,70,70,70,70,70,120,80,100,0"); mygrid_recv.setColAlign("center,center,right,right,right,right,right,right,right,right,right,right,right,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"); mygrid_recv.setColTypes("ch,ro,co,co,co,ed,ed,ed,ed,co,ed,co,txt,ch,ro,ro,ro,ro,ro,ro"); var bsno = $("dvOrderNumVal").value.trim(); //判断委托单有无应收费用 var urlVal = "../Shipping/feegridsource.aspx?type=1&read=exist&showcount=1&oplb=op_Seai&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=op_Seai&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转换汉字标识 quantityObj = getTypeNameQuantity(unit); 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); //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; quantityObj = getTypeNameQuantity(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(""); 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); } // 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){ 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); } 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; } } } }); // mygrid_recv.attachEvent("onRowSelect", function(id,ind){ // if(ind == 2 || ind == 3){ // var id = rId; // 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); // } // // 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; // } // } // } // } // }); // mygrid_recv.attachEvent("onMouseOver", function(id,ind){ // // if($("h_enable").value == "1"){ // var rowIndex = mygrid_recv.getRowIndex(id); // var stateVal = mygrid_recv.cellByIndex(rowIndex,1).getValue().trim(); // // if(stateVal == "录入状态"|| stateVal == "驳回提交"){ // if(ind == 2 || ind == 3 || ind == 4 || ind == 9 || ind == 11){ // 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); // } // // 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); // } // } // } // } // }); //手动编写Grid控件编辑事件,由于免费控件没有提供完整的编辑判断功能,现特此做更改 mygrid_recv.attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){ var newCheckValue = false; //初始化状态 if(stage == 0){ //alert(); //return true; //var cell = mygrid_recv.cellById(rId,cInd); //alert(cell.getValue()); //var selectedId = mygrid_recv.getSelectedRowId(); var rowIndex = mygrid_recv.getRowIndex(rId); var oldVal = mygrid_recv.cellByIndex(rowIndex,1).getValue().trim(); // alert(cInd) // if(cInd == 0){ // return true; // } 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{ //return true; if(validOperatePower(rId,1)){ return true; }else{ alert("对不起,你没有此权限"); return false; } } //return true; }else{ if(validOperatePower(rId,1)){ if(cInd == 0){ return true; }else{ alert("对不起,你没有此权限"); return false; } }else{ alert("对不起,你没有此权限"); return false; } //return false; //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(cInd == 2 || cInd == 3){ if(flagFilter == 0){ //alert(txtEdit.value); } } } //如果编辑结束 if(stage == 2){ 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())); mygrid_recv.cellByIndex(rowIndex,6).setValue(outputMoney(quantityCount.toString())); 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); //alert(curValue); //alert(rId);alert(curValue); //var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+curValue; //获取海运进口委托(op_seai)费用1汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?handle=seai&oplb=op_Seai&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 == 8){ return; }else if(cInd == 4){ var rowIndex = mygrid_recv.getRowIndex(rId); var unitVal = mygrid_recv.cellByIndex(rowIndex,4).getValue(); var quantityObj = null; quantityObj = getTypeNameQuantity(unitVal); 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 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(); 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;i0 && cellVal.indexOf(" ") < cellVal.length) { cellVal = cellVal.substring(0,cellVal.indexOf(" ")); for(var i = 0;i 0) { mygrid_recv.cellByIndex(rowIndex,cInd).setValue(comboArg[i]); mygrid_recv.cellByIndex(rowIndex,cInd).setLabel(comboArg[i]); break; } } } 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=op_Seai&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); //var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+feeCodeObj.feecode[0].cur; //获取委托(op_seai)费用1汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?handle=seai&oplb=op_Seai&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; } } }); // mygrid_recv.attachEvent("onSelectStateChanged", function(id){ // var combo_feename; // combo_feename = mygrid_recv.getCustomCombo(id,1); // setFeeNameCombo(combo_feename); // // // var combo_cust; // combo_cust = mygrid_recv.getCustomCombo(id,2); // setCustomerCombo(combo_cust); // // var combo_unit; // combo_unit = mygrid_recv.getCustomCombo(id,3); // setUnitCombo(combo_unit); // // var combo_currency; // combo_currency = mygrid_recv.getCustomCombo(id,8); // setCurrencyCombo(combo_currency); // // var combo_frt; // combo_frt = mygrid_recv.getCustomCombo(id,10); // setFrtCombo(combo_frt); // }); // mygrid_recv.attachEvent("onRowSelect", function(id,ind){ // // var combo_feename; // combo_feename = mygrid_recv.getCustomCombo(id,1); // setFeeNameCombo(combo_feename); // // // var combo_cust; // combo_cust = mygrid_recv.getCustomCombo(id,2); // setCustomerCombo(combo_cust); // // var combo_unit; // combo_unit = mygrid_recv.getCustomCombo(id,3); // setUnitCombo(combo_unit); // // var combo_currency; // combo_currency = mygrid_recv.getCustomCombo(id,8); // setCurrencyCombo(combo_currency); // // var combo_frt; // combo_frt = mygrid_recv.getCustomCombo(id,10); // setFrtCombo(combo_frt); // }); mygrid_recv.attachEvent("onSelectStateChanged", function(id){ 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(); //触发操作事件前获取单元值 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); 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 == 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{ } 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=op_Seai&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); //var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+feeCodeObj.feecode[0].cur; //获取海运出口委托(op_seai)费用汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?handle=seai&oplb=op_Seai&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; } } //Tab键 if(code == 9){ //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; // if(cInd == 2){ // //var combo = mygrid_recv.getCustomCombo(rId,cInd); // // } var rId = selectedId; 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,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,5).setValue(outputMoney(unitPrice.toString())); 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); //filterComboCustomerPress(mygrid_recv,rId,rowIndex,8,nValue,oValue); var curValue = mygrid_recv.cellByIndex(rowIndex,9).getValue(); //var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+curValue+"&val="+newGuid()+"&uid="+newGuid(); //获取海运出口委托(op_seai)费用汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?handle=seai&oplb=op_Seai&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 == 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=op_Seai&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); //var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+feeCodeObj.feecode[0].cur; //获取海运出口委托(op_seai)费用汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?handle=seai&oplb=op_Seai&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); } } } } } } 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 } if((code>=65&&code<=90) || (code>=48 && code <=57)||(code>=96 && code<=105)){//如果是输入英文字符 if(ind == 2 || ind == 3 ||ind == 4||ind == 11){ //获取键盘输入字符 var pressVal = String.fromCharCode(code); var start=0; var end=0; if(document.selection){ var range = document.selection.createRange(); if(range.parentElement().className == txtEdit.className){ // create a selection of the whole textarea var range_all = document.body.createTextRange(); range_all.moveToElementText(txtEdit); for (start=0; range_all.compareEndPoints("StartToStart", range) < 0; start++){ range_all.moveStart('character', 1); } for (var i = 0; i <= start; i ++){ if (txtEdit.value.charAt(i) == '\n') start++; } var range_all = document.body.createTextRange(); range_all.moveToElementText(txtEdit); for (end = 0; range_all.compareEndPoints('StartToEnd', range) < 0; end ++) range_all.moveStart('character', 1); for (var i = 0; i <= end; i ++){ if (txtEdit.value.charAt(i) == '\n') end ++; } } } //如果是当前检索位置 if(rowIndex == pressRowIndex && ind == pressCellIndex){ //未选中多个字符 if(start == end){ if(start != pressRecord.length){ if(start != 0){ var firstVal = pressRecord.substring(0,start - 1); var endVal = pressRecord.substring(start + 1,txtEdit.value.length - 1); // alert(firstVal);alert(endVal); pressRecord = firstVal+pressVal+endVal; } }else{ pressRecord = pressRecord+pressVal; } } //选中多个字符 if(start != end){ var firstVal = pressRecord.substring(0,start); var endVal = pressRecord.substring(end - 1,txtEdit.value.length - 1); // alert(firstVal);alert(endVal); pressRecord = firstVal+pressVal+endVal; } }else{ pressRecord = pressVal; pressRowIndex = rowIndex; pressCellIndex = ind; } // alert(pressRecord);alert(start);alert(end);alert(txtEdit.value); //获取combo下拉列表 var combo = mygrid_recv.getCustomCombo(selectedId,ind); var comboArg = combo.getKeys(); var count = 0; //开始遍历检索 //如果检索成功 状态pressCount=1 如果不成功应为pressCount=2 for(var i = 0;i=48 && code <=57)||(code>=96 && code<=105)){ if(ind == 5 ||ind == 6 ||ind == 7 ||ind == 10){ return true; } } } //delete if(code == 8){ //code8 begin if(ind == 2 || ind == 3 ||ind == 4||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(start != 0){ var firstVal = pressRecord.substring(0,start - 1); var endVal = pressRecord.substring(start + 1,txtEdit.value.length - 1); pressRecord = firstVal; // alert(firstVal);alert(endVal);alert(pressRecord); } } //选中多个字符 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.trim().length > 0){ var combo = mygrid_recv.getCustomCombo(selectedId,ind); var comboArg = combo.getKeys(); var count = 0; for(var i = 0;i 0){ mygrid_recv.clearSelection(); mygrid_recv.editStop(); mygrid_recv.selectCell(rowIndex-1,1,true,true); mygrid_recv.editCell(); } }else{ pressCount = 0; return true; } //code38 end } //键盘输入数字code >= 48 && code <= 57|| code >= 96 && code <= 105 || if(code == 188|| code == 110|| code == 190){ if( ind == 2|| ind == 3|| ind == 4||ind == 5|| ind == 6|| ind == 7|| ind == 8|| ind == 10||ind == 12){ return true; } } if(code == 189 || code == 109){ if(ind == 5){ return true; } } //onKeyPress end }); // var pressVal = ""; // var pressColIndex = 0; // var pressRowIndex = 0; // var pressGridType = 1;//recv setTimeout(function(){ markStatusColor(mygrid_recv); },460); } //讲下拉列表Combo所有生成Array数组 function setComboByArray(gridNewObj,comboObj,rowGID,colIndex){ //var comboTxt_arg = new Array(); var comboVal_arg = new Array(); comboVal_arg = comboObj.getKeys(); var newCombo = gridNewObj.getCustomCombo(rowGID,colIndex); for(var i = 0;i < comboVal_arg.length;i++){ var txtValue = comboObj.get(comboVal_arg[i]); newCombo.put(comboVal_arg[i],txtValue); } } function spliceBuffer(arrayRow){ var strBuffer = ""; for(var i = 0;i,费用状态,应付费用名称,结算单位,计费标准,单价,数量,佣金比例,金额,币别,汇率,FRT,费用备注,是否垫付,结算金额,申请金额,支票号码,录入人,录入时间,TID"); mygrid_pay.setInitWidths("40,70,110,150,70,80,80,90,90,50,70,70,70,70,70,70,100,80,100,0"); mygrid_pay.setColAlign("center,center,right,right,right,right,right,right,right,right,right,right,right,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"); mygrid_pay.setColTypes("ch,ro,co,co,co,ed,ed,ed,ed,co,ed,co,txt,ch,ro,ro,ro,ro,ro,ro"); var bsno = $("dvOrderNumVal").value.trim(); ////判断委托单有无应付费用 var urlVal = "../Shipping/feegridsource.aspx?type=2&read=exist&showcount=1&oplb=op_Seai&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=op_Seai&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(){ // 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,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; quantityObj = getTypeNameQuantity(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_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); //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 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; quantityObj = getTypeNameQuantity(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_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); //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(opType == 1){ mygrid_pay.cellByIndex(rowIndex,3).setValue(customerName.trim()); }else{ mygrid_pay.cellByIndex(rowIndex,3).setValue(debitObj.debit[0].value); } // 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= 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); } 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){ var newCheckValue = false; //初始化状态 if(stage == 0){ //alert(); //return true; //var cell = mygrid_pay.cellById(rId,cInd); //alert(cell.getValue()); //var selectedId = mygrid_pay.getSelectedRowId(); var rowIndex = mygrid_pay.getRowIndex(rId); var oldVal = mygrid_pay.cellByIndex(rowIndex,1).getValue().trim(); // if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){ // alert("应收费用未保存,请先将应收费用保存,再添加应付费用"); // return false; // } // if(cInd == 0){ // return true; // } if(oldVal == "录入状态" || oldVal == "驳回提交"){ if($("h_enable").value == "0"){ if(cInd == 0){ //if(parseInt($("h_recvauthority").value) > 0){ if(validOperatePower(rId,2)){ return true; }else{ return false; } } return false; }else{ //return true; if(validOperatePower(rId,2)){ return true; }else{ return false; } } //return true; }else{ if(validOperatePower(rId,2)){ if(cInd == 0){ return true; }else{ return false; } }else{ return false; } //return false; //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(cInd == 2 || cInd == 3){ if(flagFilter == 0){ //alert(txtEdit.value); } } } //如果编辑结束 if(stage == 2){ 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 == 9){ var rowIndex = mygrid_pay.getRowIndex(rId); //filterComboCustomerPress(mygrid_pay,rId,rowIndex,9,nValue,oValue); var curValue = mygrid_pay.cellByIndex(rowIndex,9).getValue(); //alert(curValue); //alert(rId);alert(curValue); //var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+curValue; var bsno = $("h_bsno").value; //获取海运进口委托(op_seai)费用1汇率 var urlVal = "../FeeCodes/CurrencyCodeService.aspx?handle=seai&oplb=op_Seai&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 == 8){ return; }else if(cInd == 4){ var rowIndex = mygrid_pay.getRowIndex(rId); var unitVal = mygrid_pay.cellByIndex(rowIndex,4).getValue(); var quantityObj = null; quantityObj = getTypeNameQuantity(unitVal); 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 0){ mygrid_pay.cellByIndex(rowIndex,cInd).setValue(comboArg[i]); mygrid_pay.cellByIndex(rowIndex,cInd).setLabel(comboArg[i]); tempCount++; break; } } } }//alert(tempCount) if(tempCount == 0){ mygrid_pay.cellByIndex(rowIndex,cInd).setValue(""); mygrid_pay.cellByIndex(rowIndex,cInd).setLabel(""); } isExchange = false; pressRecord = ""; pressRowIndex = -1; pressCellIndex = -1; pressCount = 0; flagFilter = 0; // var url = ""; // var feeCodeObj = null; // var feeName = mygrid_pay.cellByIndex(rowIndex,1).getValue().trim(); // // if(feeName != ""){//通过费用名称获取费用代码表(code_fee)币别汇率信息 // url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&feename="+escape(feeName)+"&uid="+newGuid(); // // var loader = dhtmlxAjax.getSync(url); // // var feeCodeInfo = loader.xmlDoc.responseText; // feeCodeObj = eval('(' + feeCodeInfo + ')'); // // if(feeCodeObj.feecode.length > 0){//获取委托(op_seai)费用1汇率 // mygrid_pay.cellByIndex(rowIndex,8).setValue(feeCodeObj.feecode[0].cur); // var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+feeCodeObj.feecode[0].cur; // var loader = dhtmlxAjax.getSync(urlVal); // var loadVal = loader.xmlDoc.responseText; // mygrid_pay.cellByIndex(rowIndex,9).setValue(loadVal); // totalDynamicFeeGain(); // } // } return true; // }else{ // 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 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_pay.cellByIndex(rowIndex,cInd).setValue(""); mygrid_pay.cellByIndex(rowIndex,cInd).setLabel(""); } return true; } } }else{ var cellVal = mygrid_pay.cellByIndex(rowIndex,cInd).getValue(); var combo = mygrid_pay.getCustomCombo(rId,cInd); var comboArg = combo.getKeys(); if(cellVal.indexOf(" ") >0 && cellVal.indexOf(" ") < cellVal.length){ cellVal = cellVal.substring(0,cellVal.indexOf(" ")); for(var i = 0;i 0){ mygrid_pay.cellByIndex(rowIndex,cInd).setValue(comboArg[i]); mygrid_pay.cellByIndex(rowIndex,cInd).setLabel(comboArg[i]); break; } } } 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=op_Seai&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); //var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+feeCodeObj.feecode[0].cur; //获取委托(op_seai)费用1汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?handle=seai&oplb=op_Seai&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; } } }); // mygrid_pay.attachEvent("onSelectStateChanged", function(id){ // var combo_feename; // combo_feename = mygrid_pay.getCustomCombo(id,1); // setFeeNameCombo(combo_feename); // // // var combo_cust; // combo_cust = mygrid_pay.getCustomCombo(id,2); // setCustomerCombo(combo_cust); // // var combo_unit; // combo_unit = mygrid_pay.getCustomCombo(id,3); // setUnitCombo(combo_unit); // // var combo_currency; // combo_currency = mygrid_pay.getCustomCombo(id,8); // setCurrencyCombo(combo_currency); // // var combo_frt; // combo_frt = mygrid_pay.getCustomCombo(id,10); // setFrtCombo(combo_frt); // }); // mygrid_pay.attachEvent("onRowSelect", function(id,ind){ // // var combo_feename; // combo_feename = mygrid_pay.getCustomCombo(id,1); // setFeeNameCombo(combo_feename); // // // var combo_cust; // combo_cust = mygrid_pay.getCustomCombo(id,2); // setCustomerCombo(combo_cust); // // var combo_unit; // combo_unit = mygrid_pay.getCustomCombo(id,3); // setUnitCombo(combo_unit); // // var combo_currency; // combo_currency = mygrid_pay.getCustomCombo(id,8); // setCurrencyCombo(combo_currency); // // var combo_frt; // combo_frt = mygrid_pay.getCustomCombo(id,10); // setFrtCombo(combo_frt); // }); mygrid_pay.attachEvent("onSelectStateChanged", function(id){ 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(); //触发操作事件前获取单元值 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); 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 == 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{ } 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=op_Seai&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); //var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+feeCodeObj.feecode[0].cur; //获取委托(op_seai)费用1汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?handle=seai&oplb=op_Seai&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键 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); //filterComboCustomerPress(mygrid_recv,rId,rowIndex,8,nValue,oValue); var curValue = mygrid_pay.cellByIndex(rowIndex,9).getValue(); //alert(curValue); //alert(rId);alert(curValue); //var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+curValue+"&val="+newGuid(); //获取海运进口委托(op_seai)费用1汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?handle=seai&oplb=op_Seai&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 == 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=op_Seai&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); //var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+feeCodeObj.feecode[0].cur; //获取委托(op_seai)费用1汇率 var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?handle=seai&oplb=op_Seai&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 } if((code>=65&&code<=90) || (code>=48 && code <=57)||(code>=96 && code<=105)){//如果是输入英文字符 if(ind == 2 || ind == 3 ||ind == 4||ind == 11){ //获取键盘输入字符 var pressVal = String.fromCharCode(code); var start=0; var end=0; if(document.selection){ var range = document.selection.createRange(); if(range.parentElement().className == txtEdit.className){ // create a selection of the whole textarea var range_all = document.body.createTextRange(); range_all.moveToElementText(txtEdit); for (start=0; range_all.compareEndPoints("StartToStart", range) < 0; start++){ range_all.moveStart('character', 1); } for (var i = 0; i <= start; i ++){ if (txtEdit.value.charAt(i) == '\n') start++; } var range_all = document.body.createTextRange(); range_all.moveToElementText(txtEdit); for (end = 0; range_all.compareEndPoints('StartToEnd', range) < 0; end ++) range_all.moveStart('character', 1); for (var i = 0; i <= end; i ++){ if (txtEdit.value.charAt(i) == '\n') end ++; } } } //如果是当前检索位置 if(rowIndex == pressRowIndex && ind == pressCellIndex){ //未选中多个字符 if(start == end){ if(start != pressRecord.length){ if(start != 0){ var firstVal = pressRecord.substring(0,start - 1); var endVal = pressRecord.substring(start + 1,txtEdit.value.length - 1); // alert(firstVal);alert(endVal); pressRecord = firstVal+pressVal+endVal; } }else{ pressRecord = pressRecord+pressVal; } } //选中多个字符 if(start != end){ var firstVal = pressRecord.substring(0,start); var endVal = pressRecord.substring(end - 1,txtEdit.value.length - 1); // alert(firstVal);alert(endVal); pressRecord = firstVal+pressVal+endVal; } }else{ pressRecord = pressVal; pressRowIndex = rowIndex; pressCellIndex = ind; } // alert(pressRecord);alert(start);alert(end);alert(txtEdit.value); //获取combo下拉列表 var combo = mygrid_pay.getCustomCombo(selectedId,ind); var comboArg = combo.getKeys(); var count = 0; //开始遍历检索 //如果检索成功 状态pressCount=1 如果不成功应为pressCount=2 for(var i = 0;i=48 && code <=57)||(code>=96 && code<=105)){ if(ind == 5 ||ind == 6 ||ind == 7 ||ind == 10){ return true; } } } //delete if(code == 8){ //code8 begin if(ind == 2 || ind == 3 ||ind == 4||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(start != 0){ var firstVal = pressRecord.substring(0,start - 1); var endVal = pressRecord.substring(start + 1,txtEdit.value.length - 1); pressRecord = firstVal; // alert(firstVal);alert(endVal);alert(pressRecord); } } //选中多个字符 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.trim().length > 0){ var combo = mygrid_pay.getCustomCombo(selectedId,ind); var comboArg = combo.getKeys(); var count = 0; for(var i = 0;i 0){ mygrid_pay.clearSelection(); mygrid_pay.editStop(); mygrid_pay.selectCell(rowIndex-1,1,true,true); mygrid_pay.editCell(); } }else{ pressCount = 0; return true; } //code38 end } //键盘输入数字code >= 48 && code <= 57|| code >= 96 && code <= 105 || if(code == 188|| code == 110|| code == 190){ if( ind == 2|| ind == 3|| ind == 4||ind == 5|| ind == 6|| ind == 7|| ind == 8|| ind == 10||ind == 11){ return true; } } if(code == 189 || code == 109){ if(ind == 5){ 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 = $("dvOrderNumVal").value.trim(); if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "SeaiFeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb=op_Seai&uid="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; var validStatusObj = eval('(' + loadVal + ')'); var opStatus = 0; var feeStatus = 0; if(validStatusObj.valid.length > 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } //if(parseInt($("h_recvauthority").value) <= 0){ if(!validOperatePower("",1,"add")){ return; } if(opStatus == 1){ // if(newFeePayCount > 0 || changeFeePayCount > 0){ // alert("应付费用未保存,请先将应付费用保存,再添加应收费用"); // return false; // } // if(mygrid_recv.getRowsNum() > 0){ var newId = newGuid(); //获取插入新纪录位置 var rowCount = mygrid_recv.getRowsNum(); mygrid_recv.addRow(newId,[0,"录入状态","","","",0,0,0,0,"RMB",1,"PP","",false,0,0,'','','','0'],rowCount); //mygrid_recv.addRow(newId,"",mygrid_recv.getRowsNum()); mygrid_recv.clearSelection(); //mygrid_recv.selectRow(mygrid_recv.getRowIndex(newId),false,false,true); //mygrid_recv.loadXML("../Shipping/feegridsource.aspx?type=1&read=add&showcount="+page_count); //mygrid_recv.enableCellIds(true); 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); 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{ // var bsno = $("dvOrderNumVal").value.trim(); // mygrid_recv.loadXML("../Shipping/feegridsource.aspx?type=1&read=add&showcount=1&bsno="+bsno); // newFeeRecvCount++; // //mygrid_recv.init(); // } }else{ alert("委托已退载,费用不能添加"); return; } } function addPayRow(){ var bsno = $("dvOrderNumVal").value.trim(); if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "SeaiFeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb=op_Seai&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(parseInt($("h_payauthority").value) <= 0){ // return; // } if(opStatus == 1){ // if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){ // alert("应收费用未保存,请先将应收费用保存,再添加应付费用"); // return false; // } //if(mygrid_pay.getRowsNum() > 0){ var newId = newGuid(); //获取插入新纪录位置 var rowCount = mygrid_pay.getRowsNum(); mygrid_pay.addRow(newId,[0,"录入状态","","","",0,0,0,0,"RMB",1,"PP","",false,0,0,'','','','0'],rowCount); //mygrid_recv.addRow(newId,"",mygrid_recv.getRowsNum()); mygrid_pay.selectRow(mygrid_pay.getRowIndex(newId),false,false,true); //mygrid_recv.loadXML("../Shipping/feegridsource.aspx?type=1&read=add&showcount="+page_count); //mygrid_recv.enableCellIds(true); 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); 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{ // var bsno = $("dvOrderNumVal").value.trim(); // mygrid_pay.loadXML("../Shipping/feegridsource.aspx?type=2&read=add&showcount=1&bsno="+bsno); // newFeePayCount++; // //mygrid_pay.init(); // } }else{ alert("委托已退载,费用不能添加"); return; } } function deleteRecvRow(){ var bsno = $("dvOrderNumVal").value.trim(); if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "SeaiFeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb=op_Seai&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(parseInt($("h_recvauthority").value) <= 0){ 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 = "SeaiFeeService.aspx?gid="+recvArg[delCount]+"&handle=delete&oplb=op_Seai&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; } } // //查看是否有被选中的费用项 // if(selGroup.length > 0){ // if(selGroup.length > 1){ // var delCount = 0; // if(window.confirm("您确定要将所选应收费用删除")){ // var dg=new dialog(); // dg.html=""; // dg.width=200; // dg.height=100; // dg.title="标题"; // dg.show(); // while(delCount < selGroup.length){ // var rowIndex = mygrid_recv.getRowIndex(selGroup[delCount]); // // var feeName = mygrid_recv.cellByIndex(rowIndex,1).getValue(); // var cusName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); // // // // var urlVal = "SeaiFeeService.aspx?gid="+selGroup[delCount]+"&handle=delete"+"&no="+newGuid();; // var loader = dhtmlxAjax.getSync(urlVal); // var loadVal = loader.xmlDoc.responseText; // // if(loadVal > 0 ){ // mygrid_recv.deleteRow(selGroup[delCount]); // }else{ // mygrid_recv.deleteSelectedRows(); // } // delCount++; // } // dg.close(); // totalDynamicFeeGain(); // } // }else{ // var delCount = 0; // while(delCount < selGroup.length){ // var rowIndex = mygrid_recv.getRowIndex(selGroup[delCount]); // // var feeName = mygrid_recv.cellByIndex(rowIndex,1).getValue(); // var cusName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); // // if(window.confirm("您确定要将 应收费用("+feeName+") 删除")){ // var dg=new dialog(); // dg.html=""; // dg.width=200; // dg.height=100; // dg.title="标题"; // dg.show(); // // var urlVal = "SeaiFeeService.aspx?gid="+selGroup[delCount]+"&handle=delete"+"&no="+newGuid(); // var loader = dhtmlxAjax.getSync(urlVal); // var loadVal = loader.xmlDoc.responseText; // if(loadVal > 0 ){ // mygrid_recv.deleteRow(selGroup[delCount]); // dg.close(); // alert("删除成功"); // }else{ // mygrid_recv.deleteSelectedRows(); // dg.close(); // } // totalDynamicFeeGain(); // } // delCount++; // } // } // }else{ // alert("未选中要操作的费用项"); // // } function deletePayRow(id){ var bsno = $("dvOrderNumVal").value.trim(); if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "SeaiFeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb=op_Seai"+"&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(parseInt($("h_payauthority").value) <= 0){ // return; // } if(opStatus == 1){ // 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 = "SeaiFeeService.aspx?gid="+recvArg[delCount]+"&handle=delete&oplb=op_Seai"+"&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(){ // alert("saveRecvChange"); var bsno = $("dvOrderNumVal").value.trim(); var jsonFeeObj = null; //if(parseInt($("h_recvauthority").value) <= 0){ // if(!validOperatePower("",1,"save")){ // return; // } 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 && parseInt($("h_payauthority").value) <= 0){ // if(!validOperatePower(rId,1) && !validOperatePower(rId,2)){ // return; // } var recvState = 0; var payState = 0; if(opStatus == 1){ recvState = saveRecvChange();//保存应收费用 payState = savePayChange();//保存应付费用 // alert("recvState "+recvState+ " payState "+payState); 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; // alert("h_post "+$("h_post").value); } }else{ alert("委托已退载,费用不能修改"); return; } // alert("saveAction 完成"); } //保存应付费用 function savePayChange(){ var bsno = $("dvOrderNumVal").value.trim(); var jsonFeeObj = null; // if(parseInt($("h_payauthority").value) <= 0){ // return 1; // } // if(!validOperatePower("",2,"save")){ // return; // } 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(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 = "SeaiFeeService.aspx?gid="+recvArg[delCount]+"&handle=recover&oplb=op_Seai&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 = $("dvOrderNumVal").value.trim(); if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "SeaiFeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb=op_Seai"+"&uid="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; var validStatusObj = eval('(' + loadVal + ')'); var opStatus = 0; var feeStatus = 0; if(validStatusObj.valid.length > 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } // if(parseInt($("h_payauthority").value) <= 0){ // return; // } if(opStatus == 1){ //查看是否有被选中的费用项 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 = "SeaiFeeService.aspx?gid="+recvArg[delCount]+"&handle=recover&oplb=op_Seai&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 print_recv(){ var strBSNO = ""; strBSNO = $("h_bsno").value; if(strBSNO == ""){ return; } // var openSet = "height=680, width=1050, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-710)/2 + ",Left= "+(screen.width-800)/2 // var openType = "_blank"; // var openUrl = "../Reports/DebitNoteReport.aspx?bsno="+strBSNO+"&type=1"; // window.open (openUrl,openType,openSet); //if(parseInt($("h_recvauthority").value) <= 0){ // if(!validOperatePower(rId,1)){ // alert("没有权限操作"); // return; // } if(!validOperatePower("",1,"print")){ alert("没有权限"); return; } printMessageBox(event,1); // var printUrl = ""; // var companyID = ""; // var typeName = "SEAOPFEE"; // var dbSourceID = ""; // var userID = ""; // // var url = "../Reports/ReportService.aspx?handle=printseaopfee&bsno="+strBSNO+"&feetype=1&val="+newGuid(); // // var loader = dhtmlxAjax.getSync(url); // var reportVal = loader.xmlDoc.responseText; // var reportObj = null; // // if(reportVal != ""){ // reportObj = eval('(' + reportVal + ')'); // if(reportObj.reports.length > 0){ // if(reportObj.reports[0].compid != ""){ // companyID = reportObj.reports[0].compid; // } // if(reportObj.reports[0].sourceid != ""){ // dbSourceID = reportObj.reports[0].sourceid; // } // if(reportObj.reports[0].compid != ""){ // userID = reportObj.reports[0].userid; // } // printUrl = "print://?comp="+companyID+"&type="+typeName+"&dbid="+dbSourceID+"&uid="+userID;//alert(printUrl); // // window.location.href = window.location.href; // location.href = printUrl; // } // // }else{ // alert("没有要打印的报表"); // return; // } } function print_pay(){ var strBSNO = ""; strBSNO = $("h_bsno").value; if(strBSNO == ""){ return; } // var openSet = "height=680, width=1050, toolbar=no, menubar=no,scrollbars=no, resizable=1,location=no, status=no,Top= " +(screen.height-710)/2 + ",Left= "+(screen.width-800)/2 // var openType = "_blank"; // var openUrl = "../Reports/DebitNoteReport.aspx?bsno="+strBSNO+"&type=2"; // window.open (openUrl,openType,openSet); // if(parseInt($("h_payauthority").value) <= 0){ // alert("没有权限操作"); // return; // } if(!validOperatePower("",2,"print")){ alert("没有权限"); return; } printMessageBox(event,2); // var printUrl = ""; // var companyID = ""; // var typeName = "SEAOPFEE"; // var dbSourceID = ""; // var userID = ""; // // var url = "../Reports/ReportService.aspx?handle=printseaopfee&bsno="+strBSNO+"&feetype=2&val="+newGuid(); // // var loader = dhtmlxAjax.getSync(url); // var reportVal = loader.xmlDoc.responseText; // var reportObj = null; // // if(reportVal != ""){ // reportObj = eval('(' + reportVal + ')'); // if(reportObj.reports.length > 0){ // if(reportObj.reports[0].compid != ""){ // companyID = reportObj.reports[0].compid; // } // if(reportObj.reports[0].sourceid != ""){ // dbSourceID = reportObj.reports[0].sourceid; // } // if(reportObj.reports[0].compid != ""){ // userID = reportObj.reports[0].userid; // } // printUrl = "print://?comp="+companyID+"&type="+typeName+"&dbid="+dbSourceID+"&uid="+userID;//alert(printUrl); // window.location.href = window.location.href; // location.href = printUrl; // } // // }else{ // alert("没有要打印的报表"); // return; // } } //动态计算费用利润信息 function 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(amount); totalAmount_pay += parseFloat(amount); break; default: 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*100) /100; if(number<0) return '-'+outputDollars(Math.floor(Math.abs(number)-0) + '') + outputCents(Math.abs(number) - 0); else return outputDollars(Math.floor(number-0) + '') + outputCents(number - 0); } //输出美元 function outputDollars(number) { if (number.length<= 3) return (number == '' ? '0' : number); else { var mod = number.length%3; var output = (mod == 0 ? '' : (number.substring(0,mod))); for (i=0 ; i< Math.floor(number.length/3) ; i++) { if ((mod ==0) && (i ==0)) output+= number.substring(mod+3*i,mod+3*i+3); else output+= ',' + number.substring(mod+3*i,mod+3*i+3); } return (output); } } function outputCents(amount) { amount = Math.round( ( (amount) - Math.floor(amount) ) *100); return (amount<10 ? '.0' + amount : '.' + amount); } //获取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(); 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; // alert(" GetGainArg "+"gainContainer "+$("gainContainer").value); } //过滤结算单位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; 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=Seaiaudit&oplb=op_Seai&id="+recvArg[delCount]+"&val="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; if(loadVal > 0){ iSuccess++; if(iSuccess == 1){ postBillNO = recvArg[delCount]; } }else{ iFailure++; } delCount++; } if(delCount > 0){ //向审核人发送申请消息 var postUrlVal = "../message/messageservice.aspx?billno="+postBillNO+"&type=1&oplb=op_Seai&handle=postmessage"+"&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 = $("dvOrderNumVal").value.trim(); if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "SeaiFeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb=op_Seai"+"&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; 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=Seaiaudit&oplb=op_Seai&id="+recvArg[delCount]+"&val="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; if(loadVal > 0){ iSuccess++; if(iSuccess == 1){ postBillNO = recvArg[delCount]; } }else{ iFailure++; } delCount++; } if(delCount > 0){ //向审核人发送申请消息 var postUrlVal = "../message/messageservice.aspx?billno="+postBillNO+"&type=1&oplb=op_Seai&handle=postmessage"+"&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 = $("dvOrderNumVal").value.trim(); if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "SeaiFeeService.aspx?bsno="+bsno+"&handle=checkopstatus"+"&uid="+newGuid();; var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; var validStatusObj = eval('(' + loadVal + ')'); var opStatus = 0; var feeStatus = 0; if(validStatusObj.valid.length > 0){ opStatus = parseInt(validStatusObj.valid[0].opstatus); feeStatus = parseInt(validStatusObj.valid[0].feestatus); } if(feeStatus < 1){ alert("委托业务已锁定,不能编辑费用信息"); return; } //if(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"; //打开费用“历史信息查询”页面FeeHistory.aspx var openUrl = "../Shipping/FeeHistory.aspx?bsno="+strBSNO+"&oplb=op_Seai&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"; //打开应收费用“引入费用模板”页面ImportFeeTemplate.aspx var openUrl = "../Shipping/ImportFeeTemplate.aspx?handle=import&oplb=op_Seai&type=1"; window.open (openUrl,openType,openSet); }else{ alert("委托已退载,不能引入费用"); return; } } //打开应付费用模板 function importPayTemplate(){ // if(parseInt($("h_payauthority").value) <= 0){ // return; // } if(!validOperatePower("",2,"import")){ alert("没有权限操作数据"); return; } var bsno = $("dvOrderNumVal").value.trim(); if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "SeaiFeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb=op_Seai"+"&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"; //打开应付费用“引入费用模板”页面ImportFeeTemplate.aspx var openUrl = "../Shipping/ImportFeeTemplate.aspx?handle=import&oplb=op_Seai&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 0 || changeFeePayCount > 0){ alert("应付费用未保存,请先保存之后再打印"); return; } for(var j=0;j"+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+"&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 < jsonCacheObj.drate.length;i++){ obj.put(jsonCacheObj.drate[i].code,jsonCacheObj.drate[i].code); } } } function setCustomerCombo(obj){//返回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=op_Seai&uid="+newGuid(); var loader = dhtmlxAjax.getSync(url); customerInfo = loader.xmlDoc.responseText; } var jsonCacheObj = eval('(' + customerInfo + ')'); if(jsonCacheObj.customer.length > 0){ for(var i = 0;i < jsonCacheObj.customer.length;i++){ obj.put(jsonCacheObj.customer[i].name,jsonCacheObj.customer[i].code + ' '+jsonCacheObj.customer[i].name); } } } function setFeeNameCombo(obj){ var feeCodeInfo = ""; if($("h_feecache").value.trim() != ""){ feeCodeInfo = $("h_feecache").value.trim(); }else{//返回code_fee费用信息的JSON字符串 var url = "../FeeCodes/FeeCodeService.aspx?handle=feecode&oplb=op_Seai&uid="+newGuid(); var loader = dhtmlxAjax.getSync(url); feeCodeInfo = loader.xmlDoc.responseText; } var jsonCacheObj = eval('(' + feeCodeInfo + ')'); if(jsonCacheObj.feecode.length > 0){ for(var i = 0;i < jsonCacheObj.feecode.length;i++){ obj.put(jsonCacheObj.feecode[i].name,jsonCacheObj.feecode[i].code); } } } function setUnitCombo(obj) {//初始化计费标准Combo obj.put("单票", "单票"); obj.put("重量", "重量"); //obj.put("净重", "净重"); obj.put("尺码", "尺码"); obj.put("TEU", "TEU"); obj.put("箱型", "箱型"); obj.put("CBM", "CBM"); obj.put("BILL", "BILL"); var feeCodeCtnObj = null; var bsno = $("dvOrderNumVal").value.trim(); //根据BSNO获取海运出口委托集装箱(op_ctn)信息,返回JSON数据源 var url = "../FeeCodes/FeeCodeCtnService.aspx?handle=getctnunit&oplb=op_Seai&bsno="+bsno+"&uid="+newGuid(); var loader = dhtmlxAjax.getSync(url); var ctnInfo = loader.xmlDoc.responseText; if(ctnInfo.trim() != ""){ feeCodeCtnObj = eval('(' + ctnInfo + ')'); if(feeCodeCtnObj.ctns.length > 0){ for(var i=0;i 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(); mygrid_recv.addRow(newId,[0,"录入状态",feeName,custName,unit,unitprice,quantity,comm,amount,currency,rate,frt,remark,isadvance,0,0,'','','',''],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); 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(); mygrid_pay.addRow(newId,[0,"录入状态",feeName,custName,unit,unitprice,quantity,comm,amount,currency,rate,frt,remark,isadvance,0,0,'','','',''],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.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); 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); 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 = $("dvOrderNumVal").value.trim(); if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "SeaiFeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb=op_Seai"+"&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"; //打开应收费用“历史引入”页面ImportFeeHistory.aspx var openUrl = "../Shipping/ImportFeeHistory.aspx?handle=import&oplb=op_Seai&historytype=1"; window.open (openUrl,openType,openSet); }else{ alert("委托已退载,不能引入费用"); return; } } function importPayHistory(){//应付费用菜单“历史引入” if(!validOperatePower("",2,"import")){ alert("没有权限操作数据"); return; } var bsno = $("dvOrderNumVal").value.trim(); if(bsno == ""){ return; } //验证委托状态是否为退舱状态(op_status和 op_seai),返回json值 var urlVal = "SeaiFeeService.aspx?bsno="+bsno+"&handle=checkopstatus&oplb=op_Seai"+"&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"; //打开应付费用“历史引入”页面ImportFeeHistory.aspx var openUrl = "../Shipping/ImportFeeHistory.aspx?handle=import&oplb=op_Seai&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,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; quantityObj = getTypeNameQuantity(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_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); //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); //} } } } 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,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; quantityObj = getTypeNameQuantity(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(""); 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(customerName.trim() != ""){ // mygrid_recv.cellByIndex(rowIndex,3).setValue(customerName.trim()); // }else{ mygrid_recv.cellByIndex(rowIndex,3).setValue(debitObj.debit[0].value); // } } } } ReShowLabel(mygrid_recv); totalDynamicFeeGain(); } } } } } }