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; 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(){ mygrid_recv = new dhtmlXGridObject('mygrid_container_recv'); mygrid_recv.setImagePath("../images/"); mygrid_recv.setSkin("xp"); mygrid_recv.setHeader(",费用状态,应收费用名称,结算单位,计费标准,单价,数量,佣金比例,金额,币别,汇率,FRT,费用备注,是否垫付"); mygrid_recv.setInitWidths("40,70,110,150,70,80,80,90,90,50,70,70,70,70"); mygrid_recv.setColAlign("center,center,right,right,right,right,right,right,right,right,right,right,right,center"); // mygrid_recv.setSkin("light"); mygrid_recv.setColSorting("na,str,str,str,int,int,int,int,int,int,int,int,int,str"); mygrid_recv.setColTypes("ch,ro,co,co,co,ed,ed,ed,ed,co,ed,co,txt,ch"); var bsno = $("dvOrderNumVal").value.trim(); var urlVal = "CrmOrderFeeGridSource.aspx?type=1&read=exist&showcount=1&bsno="+bsno+"&val="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; loader = null; if(parseInt(loadVal) == 1){ mygrid_recv.loadXML("CrmOrderFeeGridSource.aspx?type=1&read=init&showcount=1&bsno="+bsno,function(){ ReShowLabel(mygrid_recv); doInitPayGrid(); }); setTimeout(function(){ ReShowLabel(mygrid_recv); },200); }else{ doInitPayGrid(); } mygrid_recv.init(); mygrid_recv.enableEditEvents(true,false,true); //mygrid_recv.enableMultiselect(true); //mygrid_recv.setTabOrder("1,2,3,4,5,6,7,8,9,10,11,12"); //mygrid_recv.enableLightMouseNavigation(true); mygrid_recv.enableKeyboardSupport(true); var url = "CrmOrderFeeGridSource.aspx?handle=getauditstatus&bsno="+bsno+"&val="+newGuid(); var loader = dhtmlxAjax.getSync(url); curStatus = parseInt(loader.xmlDoc.responseText); if(curStatus == 9 || curStatus == 2){ mygrid_recv.enableEditEvents(true,false,true); if(parseInt($("h_authority").value) <= 0){ $("btn_audit").disabled = true; } }else{ mygrid_recv.enableEditEvents(false,false,false); $("btn_addrecv").onclick = clickNull; $("btn_saverecv").onclick = clickNull; $("btn_delrecv").onclick = clickNull; $("btn_abanrecv").onclick = clickNull; $("btn_refreshrecv").onclick = clickNull; $("btn_printrecv").onclick = clickNull; $("btn_audit").disabled = true; } setTimeout(function(){ // for(var i=0;i= 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; } } }); //手动编写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; // } var crmStatus = parseInt($("h_crmstatus").value); if(crmStatus != 9 && crmStatus != 2){ return false; } if(oldVal == "录入状态"){ if(parseInt($("h_authority").value) > 0){ return true; }else{ return false; } //return true; }else{ if(parseInt($("h_authority").value) > 0){ if(cInd == 0){ return true; }else{ return false; } }else{ 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 quantityOrig = mygrid_recv.cellByIndex(rowIndex,6).getValue(); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_recv.cellByIndex(rowIndex,6).getValue()))); if(!isDigit(quantityOrig)){ return false; } 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; var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?bsno="+bsno+"&type=2¤cy="+feeCodeObj.feecode[0].cur+"&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; // var url = ""; // var feeCodeObj = null; // var feeName = mygrid_recv.cellByIndex(rowIndex,1).getValue(); // // if(feeName.trim() != ""){ // url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&feename="+escape(feeName)+"&uid="+newGuid();alert(url); // // var loader = dhtmlxAjax.getSync(url); // // var feeCodeInfo = loader.xmlDoc.responseText; // feeCodeObj = eval('(' + feeCodeInfo + ')'); // // if(feeCodeObj.feecode.length > 0){ // mygrid_recv.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_recv.cellByIndex(rowIndex,9).setValue(loadVal); // // } // } totalDynamicFeeGain(); return true; // }else{ // 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 != ""){ url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&feename="+escape(feeName)+"&uid="+newGuid(); var loader = dhtmlxAjax.getSync(url); var feeCodeInfo = loader.xmlDoc.responseText; feeCodeObj = eval('(' + feeCodeInfo + ')'); if(feeCodeObj.feecode.length > 0){ if(feeCodeObj.feecode[0].cur.trim() != ""){ mygrid_recv.cellByIndex(rowIndex,9).setValue(feeCodeObj.feecode[0].cur); //var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+feeCodeObj.feecode[0].cur; var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?bsno="+bsno+"&type=2¤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("onKeyPress", function(code,cFlag,sFlag){ //onKeyPress begin var crmStatus = parseInt($("h_crmstatus").value); if(crmStatus != 9 && crmStatus != 2){ return false; } //获取当前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){ 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 != ""){ url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&feename="+escape(feeName)+"&uid="+newGuid(); var loader = dhtmlxAjax.getSync(url); var feeCodeInfo = loader.xmlDoc.responseText; feeCodeObj = eval('(' + feeCodeInfo + ')'); if(feeCodeObj.feecode.length > 0){ if(feeCodeObj.feecode[0].cur.trim() != ""){ mygrid_recv.cellByIndex(rowIndex,9).setValue(feeCodeObj.feecode[0].cur); //var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+feeCodeObj.feecode[0].cur; var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?bsno="+bsno+"&type=2¤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(); var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?bsno="+bsno+"&type=2¤cy="+feeCodeObj.feecode[0].cur+"&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 != ""){ 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){ mygrid_recv.cellByIndex(rowIndex,9).setValue(feeCodeObj.feecode[0].cur); //var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+feeCodeObj.feecode[0].cur; var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?bsno="+bsno+"&type=2¤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,费用备注,是否垫付"); mygrid_pay.setInitWidths("40,70,110,150,70,80,80,90,90,50,70,70,70,70"); mygrid_pay.setColAlign("center,center,right,right,right,right,right,right,right,right,right,right,right,center"); // mygrid_pay.setSkin("light"); mygrid_pay.setColSorting("na,str,str,str,int,int,int,int,int,int,int,int,int,str"); mygrid_pay.setColTypes("ch,ro,co,co,co,ed,ed,ed,ed,co,ed,co,txt,ch"); var bsno = $("dvOrderNumVal").value.trim(); var urlVal = "CrmOrderFeeGridSource.aspx?type=2&read=exist&showcount=1&bsno="+bsno+"&val="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; loader = null; if(parseInt(loadVal) == 1){ mygrid_pay.loadXML("CrmOrderFeeGridSource.aspx?type=2&read=init&showcount=1&bsno="+bsno,function(){ ReShowLabel(mygrid_pay); getFeeProfit(bsno); }); }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 url = "CrmOrderFeeGridSource.aspx?handle=getauditstatus&bsno="+bsno+"&val="+newGuid(); var loader = dhtmlxAjax.getSync(url); curStatus = parseInt(loader.xmlDoc.responseText); if(curStatus == 9 || curStatus == 2){ mygrid_pay.enableEditEvents(true,false,true); }else{ mygrid_pay.enableEditEvents(false,false,false); $("btn_addpay").onclick = clickNull; $("btn_savepay").onclick = clickNull; $("btn_delpay").onclick = clickNull; $("btn_abanpay").onclick = clickNull; $("btn_refreshpay").onclick = clickNull; $("btn_printpay").onclick = clickNull; } var cacheTemplate = $("h_cachetemplate").value; var importType = parseInt($("h_importtype").value); setTimeout(function(){ // for(var i=0;i= 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; // } var crmStatus = parseInt($("h_crmstatus").value); if(crmStatus != 9 && crmStatus != 2){ return false; } if(oldVal == "录入状态"){ if(parseInt($("h_authority").value) > 0){ return true; }else{ return false; } //return true; }else{ if(parseInt($("h_authority").value) > 0){ 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 quantityOrig = mygrid_pay.cellByIndex(rowIndex,6).getValue(); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(mygrid_pay.cellByIndex(rowIndex,6).getValue()))); if(!isDigit(quantityOrig)){ return false; } 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; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?bsno="+bsno+"&type=2¤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 != ""){ // 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){ // 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 != ""){ url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&feename="+escape(feeName)+"&uid="+newGuid(); var loader = dhtmlxAjax.getSync(url); var feeCodeInfo = loader.xmlDoc.responseText; feeCodeObj = eval('(' + feeCodeInfo + ')'); if(feeCodeObj.feecode.length > 0){ if(feeCodeObj.feecode[0].cur.trim() != ""){ mygrid_pay.cellByIndex(rowIndex,9).setValue(feeCodeObj.feecode[0].cur); //var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+feeCodeObj.feecode[0].cur; var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?bsno="+bsno+"&type=2¤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("onKeyPress", function(code,cFlag,sFlag){ //onKeyPress begin var crmStatus = parseInt($("h_crmstatus").value); if(crmStatus != 9 && crmStatus != 2){ return false; } //获取当前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 != ""){ url = "../FeeCodes/FeeCodeService.aspx?handle=getcurrency&feename="+escape(feeName)+"&uid="+newGuid(); var loader = dhtmlxAjax.getSync(url); var feeCodeInfo = loader.xmlDoc.responseText; feeCodeObj = eval('(' + feeCodeInfo + ')'); if(feeCodeObj.feecode.length > 0){ if(feeCodeObj.feecode[0].cur.trim() != ""){ mygrid_pay.cellByIndex(rowIndex,9).setValue(feeCodeObj.feecode[0].cur); //var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+feeCodeObj.feecode[0].cur; var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?bsno="+bsno+"&type=2¤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(); var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?bsno="+bsno+"&type=2¤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 != ""){ 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){ mygrid_pay.cellByIndex(rowIndex,9).setValue(feeCodeObj.feecode[0].cur); //var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+feeCodeObj.feecode[0].cur; var bsno = $("h_bsno").value; var urlVal = "../FeeCodes/CurrencyCodeService.aspx?bsno="+bsno+"&type=2¤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(); // var urlVal = "FeeService.aspx?bsno="+bsno+"&handle=checkopstatus"+"&uid="+newGuid(); // var loader = dhtmlxAjax.getSync(urlVal); // var loadVal = loader.xmlDoc.responseText; var opStatus = 1;//parseInt(loadVal); if(parseInt($("h_authority").value) <= 0){ 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],rowCount); //mygrid_recv.addRow(newId,"",mygrid_recv.getRowsNum()); mygrid_recv.clearSelection(); //mygrid_recv.selectRow(mygrid_recv.getRowIndex(newId),false,false,true); //mygrid_recv.loadXML("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("feegridsource.aspx?type=1&read=add&showcount=1&bsno="+bsno); // newFeeRecvCount++; // //mygrid_recv.init(); // } }else{ alert("委托已退载,费用不能添加"); return; } } function addPayRow(){ var bsno = $("dvOrderNumVal").value.trim(); // var urlVal = "FeeService.aspx?bsno="+bsno+"&handle=checkopstatus"+"&uid="+newGuid();; // var loader = dhtmlxAjax.getSync(urlVal); // var loadVal = loader.xmlDoc.responseText; var opStatus = 1;//parseInt(loadVal); if(parseInt($("h_authority").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],rowCount); //mygrid_recv.addRow(newId,"",mygrid_recv.getRowsNum()); mygrid_pay.selectRow(mygrid_pay.getRowIndex(newId),false,false,true); //mygrid_recv.loadXML("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("feegridsource.aspx?type=2&read=add&showcount=1&bsno="+bsno); // newFeePayCount++; // //mygrid_pay.init(); // } }else{ alert("委托已退载,费用不能添加"); return; } } function deleteRecvRow(){ // var bsno = $("dvOrderNumVal").value.trim(); // var urlVal = "FeeService.aspx?bsno="+bsno+"&handle=checkopstatus"+"&uid="+newGuid();; // var loader = dhtmlxAjax.getSync(urlVal); // var loadVal = loader.xmlDoc.responseText; var bsno = $("dvOrderNumVal").value.trim(); var opStatus = 1;//parseInt(loadVal); if(parseInt($("h_authority").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_recv.getRowIndex(recvArg[delCount]); var feeName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); var cusName = mygrid_recv.cellByIndex(rowIndex,3).getValue(); var urlVal = "FeeService.aspx?crmfee="+recvArg[delCount]+"&handle=deletecrmfee"+"&no="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; if(loadVal > 0 ){ mygrid_recv.deleteRow(recvArg[delCount]); } 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 = "FeeService.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 = "FeeService.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(){ var bsno = $("dvOrderNumVal").value.trim(); // var urlVal = "FeeService.aspx?bsno="+bsno+"&handle=checkopstatus"+"&uid="+newGuid();; // var loader = dhtmlxAjax.getSync(urlVal); // var loadVal = loader.xmlDoc.responseText; var opStatus = 1;//parseInt(loadVal); if(parseInt($("h_authority").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 feeName = mygrid_pay.cellByIndex(rowIndex,2).getValue(); var cusName = mygrid_pay.cellByIndex(rowIndex,3).getValue(); var urlVal = "FeeService.aspx?crmfee="+recvArg[delCount]+"&handle=deletecrmfee"+"&no="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; if(loadVal > 0 ){ mygrid_pay.deleteRow(recvArg[delCount]); } delCount++; } getFeeProfit(bsno); } } }else{ alert("未选中要操作的费用项"); } }else{ alert("委托已退载,费用不能修改"); return; } } function saveRecvChange(){ var bsno = $("dvOrderNumVal").value.trim(); var jsonFeeObj = null; 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 feeName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); var cusName = mygrid_recv.cellByIndex(rowIndex,3).getValue(); var urlVal = "FeeService.aspx?crmfee="+recvArg[delCount]+"&handle=recovercrmfee&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 0){ var delCount = 0; if(recvArg.length > 0){ if(window.confirm("您确定要将所选应付费用放弃修改")){ 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(); var urlVal = "FeeService.aspx?crmfee="+recvArg[delCount]+"&handle=recovercrmfee&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 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; // 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_authority").value) <= 0){ 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{ //计算应付 } } 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() { 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.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; } 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; } 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 || changeFeePayCount > 0){ alert("应付费用未保存,请先保存应付费用"); return; } if(opStatus == 1){ var iCount = 0; var recvArg = new Array(); for(var i=0;i 0){ if(recvArg.length > 0){ if(window.confirm("您确定将所选应收费用提交审核")){ var delCount = 0; var loadVal = 0; while(delCount < recvArg.length){ var rowIndex = mygrid_recv.getRowIndex(recvArg[delCount]); var feeName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); var cusName = mygrid_recv.cellByIndex(rowIndex,3).getValue(); var urlVal = "../AuditProcess/AuditService.aspx?handle=audit&oplb=op_Seae&id=" + recvArg[delCount] + "&val=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); loadVal = loader.xmlDoc.responseText; if(loadVal > 0){ iSuccess++; }else{ iFailure++; } delCount++; } if (delCount > 0) { if (loadVal != 10 && loadVal > 0) { //向审核人发送申请消息 var postUrlVal = "../message/messageservice.aspx?billno=" + postBillNO + "&type=1&oplb=" + stroplb + "&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 bsno = $("dvOrderNumVal").value.trim(); // var urlVal = "FeeService.aspx?bsno="+bsno+"&handle=checkopstatus"+"&uid="+newGuid();; // var loader = dhtmlxAjax.getSync(urlVal); // var loadVal = loader.xmlDoc.responseText; var opStatus = 1;//parseInt(loadVal); if(parseInt($("h_authority").value) <= 0){ return; } if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){ alert("应收费用未保存,请先将应收费用保存,提交应付费用-提交审核"); return false; } if(opStatus == 1){ var iCount = 0; var recvArg = new Array(); for(var i=0;i 0){ if(recvArg.length > 0){ if(window.confirm("您确定将所选应付费用提交审核")){ var delCount = 0; var loadVal = 0; while(delCount < recvArg.length){ var rowIndex = mygrid_pay.getRowIndex(recvArg[delCount]); var feeName = mygrid_pay.cellByIndex(rowIndex,2).getValue(); var cusName = mygrid_pay.cellByIndex(rowIndex,3).getValue(); var urlVal = "../AuditProcess/AuditService.aspx?handle=audit&oplb=op_Seae&id="+recvArg[delCount]+"&val="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); loadVal = loader.xmlDoc.responseText; if(loadVal > 0){ iSuccess++; }else{ iFailure++; } delCount++; } if (delCount > 0) { if (loadVal != 10 && loadVal > 0) { //向审核人发送申请消息 var postUrlVal = "../message/messageservice.aspx?billno=" + postBillNO + "&type=1&oplb=" + stroplb + "&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(); // var urlVal = "FeeService.aspx?bsno="+bsno+"&handle=checkopstatus"+"&uid="+newGuid();; // var loader = dhtmlxAjax.getSync(urlVal); // var loadVal = loader.xmlDoc.responseText; var opStatus = 1;//parseInt(loadVal); if(parseInt($("h_authority").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 || 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 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_authority").value) <= 0){ return; } var iCount = 0; var recvArg = new Array(); for(var i=0;i 1){ alert("每次只能查看一项费用信息"); }else{ alert("未选中要操作的费用项"); } } 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){alert(222); 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){ var strBSNO = $("h_bsno").value; var openSet = "height=540, width=890, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-540)/2 + ",Left= "+(screen.width-890)/2 var openType = "_blank"; var openUrl = "FeeHistory.aspx?bsno="+strBSNO+"&type=1"; window.open (openUrl,openType,openSet); }else{ alert("未选中要操作的费用项"); } } function checkPayHistory(){ var iCount = 0; var recvArg = new Array(); for(var i=0;i 0 || changeFeePayCount > 0){ alert("应付费用未保存,先保存应付费用,再操作应收费用-引入费用模板"); return; } var openSet = "height=700, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top=10,Left= " + (screen.width - 900) / 2; var openType = "_blank"; var openUrl = "ImportFeeTemplate.aspx?handle=import&type=1"; window.open (openUrl,openType,openSet); }else{ alert("委托已退载,不能引入费用"); return; } } function importPayTemplate(){ if(parseInt($("h_authority").value) <= 0){ return; } var bsno = $("dvOrderNumVal").value.trim(); // var urlVal = "FeeService.aspx?bsno="+bsno+"&handle=checkopstatus"+"&uid="+newGuid();; // var loader = dhtmlxAjax.getSync(urlVal); // var loadVal = loader.xmlDoc.responseText; var opStatus = 1;//parseInt(loadVal); if(opStatus == 1){ if(newFeeRecvCount > 0 || changeFeeRecvCount > 0){ alert("应收费用未保存,先保存应收费用,再操作应付费用-引入费用模板"); return; } var openSet = "height=700, width=1000, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top=10,Left= " + (screen.width - 900) / 2; var openType = "_blank"; var openUrl = "ImportFeeTemplate.aspx?handle=import&type=2"; window.open (openUrl,openType,openSet); }else{ alert("委托已退载,不能引入费用"); return; } } 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); } //让背景渐渐变暗 function showBackground(obj,endInt){ if(isIe){ obj.filters.alpha.opacity+=5; if(obj.filters.alpha.opacity 0 || changeFeeRecvCount > 0){ alert("应收费用未保存,请先保存之后再打印"); return; } var selRowID = mygrid_recv.getSelectedRowId(); if(selRowID != null){ var selGroup = new Array(); if(selRowID.indexOf(",") > 0){ selGroup = selRowID.split(","); }else{ if(selRowID != null){ selGroup.push(selRowID); } } if(selGroup.length > 0){ for(var i=0;i"+customerName+""; break; } } } } }else{ for(var i=0;i"+customerName+""; } } }else{ if(newFeePayCount > 0 || changeFeePayCount > 0){ alert("应付费用未保存,请先保存之后再打印"); return; } var selRowID = mygrid_pay.getSelectedRowId(); if(selRowID != null){ var selGroup = new Array(); if(selRowID.indexOf(",") > 0){ selGroup = selRowID.split(","); }else{ if(selRowID != null){ selGroup.push(selRowID); } } if(selGroup.length > 0){ for(var i=0;i"+customerName+""; break; } } } } }else{ for(var i=0;i"+customerName+""; } } } 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){ var customerInfo = ""; if($("h_custcache").value.trim() != ""){ customerInfo = $("h_custcache").value.trim(); }else{ var url = "../FeeCodes/CRMClientInfo.aspx?handle=client&uid="+newGuid(); var loader = dhtmlxAjax.getSync(url); customerInfo = loader.xmlDoc.responseText; } var jsonCacheObj = eval('(' + customerInfo + ')'); if(jsonCacheObj.customer.length > 0){ for(var i = 0;i < jsonCacheObj.customer.length;i++){ obj.put(jsonCacheObj.customer[i].name,jsonCacheObj.customer[i].code + ' '+jsonCacheObj.customer[i].name); } } } function setFeeNameCombo(obj){ var feeCodeInfo = ""; if($("h_feecache").value.trim() != ""){ feeCodeInfo = $("h_feecache").value.trim(); }else{ var url = "../FeeCodes/FeeCodeService.aspx?handle=feecode&uid="+newGuid(); var loader = dhtmlxAjax.getSync(url); feeCodeInfo = loader.xmlDoc.responseText; } var jsonCacheObj = eval('(' + feeCodeInfo + ')'); if(jsonCacheObj.feecode.length > 0){ for(var i = 0;i < jsonCacheObj.feecode.length;i++){ obj.put(jsonCacheObj.feecode[i].name,jsonCacheObj.feecode[i].code); } } } //function setCustomerCombo(obj){ // var url = "../FeeCodes/CRMClientInfo.aspx?handle=client&uid="+newGuid(); // var loader = dhtmlxAjax.getSync(url); // // var 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 url = "../FeeCodes/FeeCodeService.aspx?handle=feecode&uid="+newGuid(); // var loader = dhtmlxAjax.getSync(url); // // var 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) { 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(); var url = "../FeeCodes/FeeCodeCtnService.aspx?handle=getcrmctn&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){ selGroup = selRowID.split(","); }else{ if(selRowID != null){ selGroup.push(selRowID); } } //查看是否有被选中的费用项 if(selGroup.length > 0){ for(var i=0;i 0){ selGroup = selRowID.split(","); }else{ if(selRowID != null){ selGroup.push(selRowID); } } //查看是否有被选中的费用项 if(selGroup.length > 0){ for(var i=0;i 0) { var addfull=oldUrl.indexOf("addfull"); if(addfull>0) { var handleIndex = oldUrl.indexOf("handle="); newUrl = oldUrl.substring(0,handleIndex); window.parent.opener.location.href = window.parent.opener.location.href; parentObj.href = newUrl+"handle=edit&isAudit=1&id="+bsno; } else { //newUrl = oldUrl.substring(0,idIndex+4); window.parent.opener.location.href = window.parent.opener.location.href; //parentObj.href = newUrl+bsno; } } else { var handleIndex = oldUrl.indexOf("handle="); newUrl = oldUrl.substring(0,handleIndex); window.parent.opener.location.href = window.parent.opener.location.href; parentObj.href = newUrl+"handle=edit&isAudit=1&id="+bsno; } }else{ $("btn_audit").disabled = false; if(parseInt(postVal) == -3){ alert("销售订舱未录费用不能提交审核"); } } } } } function initDownFeeName(){ var url = "../FeeCodes/FeeCodeService.aspx?handle=feecode&uid="+newGuid(); var loader = dhtmlxAjax.getSync(url); var feeCodeInfo = loader.xmlDoc.responseText; //var jsonCacheObj = eval('(' + feeCodeInfo + ')'); if($("h_feecache").value.trim() == ""){ $("h_feecache").value = feeCodeInfo; } var url = "../FeeCodes/CRMClientInfo.aspx?handle=client&uid="+newGuid(); var loader = dhtmlxAjax.getSync(url); var customerInfo = loader.xmlDoc.responseText; if($("h_custcache").value.trim() == ""){ $("h_custcache").value = customerInfo; } // if(jsonCacheObj.feecode.length > 0){ // for(var i = 0;i < jsonCacheObj.feecode.length;i++){ // obj.put(jsonCacheObj.feecode[i].name,jsonCacheObj.feecode[i].code); // } // } }