var commonGridObj_old; var commonGridObj_new; var stroplb;//业务类别 function $(id){ return document.getElementById(id); } function doInitOldFeeGrid(){ commonGridObj_old = new dhtmlXGridObject('mygrid_container_old'); commonGridObj_old.setImagePath("../images/"); commonGridObj_old.setSkin("xp"); commonGridObj_old.setHeader("费用状态,应收费用名称,结算单位,计费标准,单价,数量,佣金比例,金额,币别,汇率,FRT,费用备注,是否垫付"); commonGridObj_old.setInitWidths("70,110,150,70,80,80,90,90,50,70,70,70,70"); commonGridObj_old.setColAlign("center,right,right,right,right,right,right,right,right,right,right,right,center"); commonGridObj_old.setColSorting("str,txt,txt,int,int,int,int,int,int,int,int,int,str"); commonGridObj_old.setColTypes("ro,co,co,co,ed,ed,ed,ed,co,ed,co,txt,ch"); var id = $("h_fee").value.trim(); var type = $("h_type").value.trim(); var loadType = $("h_loadtype").value.trim(); var urlVal = "FeeModifySource.aspx?handle=exist&id="+id+"&val="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; loader = null; if(parseInt(loadVal) == 1){ var handleType = parseInt($("h_handle").value); var applyState = parseInt($("h_applystate").value); var checkState = parseInt($("sel_check").value); switch(handleType){ case 1: commonGridObj_old.loadXML("FeeModifySource.aspx?handle=apply&id="+id+"&applystate="+applyState+"&checkstate="+checkState+"&applytype=1&val="+newGuid()+"&oplb="+stroplb); break; case 2: commonGridObj_old.loadXML("FeeModifySource.aspx?handle=apply&id="+id+"&applystate="+applyState+"&checkstate="+checkState+"&applytype=1&val="+newGuid()+"&oplb="+stroplb); break; case 3: commonGridObj_old.loadXML("FeeModifySource.aspx?handle=apply&id="+id+"&applystate="+applyState+"&checkstate="+checkState+"&applytype=1&val="+newGuid()+"&oplb="+stroplb); break; } setTimeout(function(){ ReShowLabel(commonGridObj_old); },200); } commonGridObj_old.init(); commonGridObj_old.enableMultiselect(true); commonGridObj_old.attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){ //初始化状态 if(stage == 0){ return false; } }); } //讲下拉列表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;i0 && cellVal.indexOf(" ") < cellVal.length){ cellVal = cellVal.substring(0,cellVal.indexOf(" ")); for(var i = 0;i 0){ commonGridObj_new.cellByIndex(rowIndex,cInd).setValue(comboArg[i]); commonGridObj_new.cellByIndex(rowIndex,cInd).setLabel(comboArg[i]); tempCount++; break; } } }alert(tempCount) if(tempCount == 0){ commonGridObj_new.cellByIndex(rowIndex,cInd).setValue(""); commonGridObj_new.cellByIndex(rowIndex,cInd).setLabel(""); } isExchange = false; pressRecord = ""; pressRowIndex = -1; pressCellIndex = -1; pressCount = 0; flagFilter = 0; return true; // }else{ // return true; // } } }else if(pressCount == 2){ if(flagFilter == 1){ commonGridObj_new.editStop(); commonGridObj_new.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 = commonGridObj_new.cellByIndex(rowIndex,cInd).getValue();//alert(cellVal) var combo = commonGridObj_new.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){ commonGridObj_new.cellByIndex(rowIndex,cInd).setValue(""); commonGridObj_new.cellByIndex(rowIndex,cInd).setLabel(""); } return true; } } }else{ var cellVal = commonGridObj_new.cellByIndex(rowIndex,cInd).getValue(); var combo = commonGridObj_new.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){ commonGridObj_new.cellByIndex(rowIndex,cInd).setValue(comboArg[i]); commonGridObj_new.cellByIndex(rowIndex,cInd).setLabel(comboArg[i]); break; } } } return true; } }else{ return true; } } }); // commonGridObj_new.attachEvent("onEnter",function(rowId,celInd){ // var rowIndex = commonGridObj_new.getRowIndex(rowId); // var ColumnsNum=commonGridObj_new.getColumnsNum(); // if (ColumnsNum==14){ // $("txt_reason").value=commonGridObj_new.cellByIndex(rowIndex,13).getValue(); // } // return true; // }); //键盘操作事件 commonGridObj_new.attachEvent("onKeyPress", function(code,cFlag,sFlag){ //onKeyPress begin //获取当前RowID var selectedId = commonGridObj_new.getSelectedRowId(); //获取当前RowIndex var rowIndex = commonGridObj_new.getRowIndex(selectedId); //获取当前CellIndex(ind) var ind = commonGridObj_new.getSelectedCellIndex(); //触发操作事件前获取单元值 var oldVal = commonGridObj_new.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; } } // alert(" rowIndex "+rowIndex); if(code == 13){ if(ind == 1 || ind == 2 ||ind == 3||ind == 10){ //如果是检索失败, if(pressCount == 2){ commonGridObj_new.editStop(); //将value写入cell(触发 stage2) commonGridObj_new.cellByIndex(rowIndex,ind).setValue(oldVal); //重新打开cell(触发stage0 stage1) commonGridObj_new.selectCell(rowIndex,ind,true,true); commonGridObj_new.cellByIndex(rowIndex,ind).setLabel(oldVal); commonGridObj_new.editCell(); return true; }else{ } return true; }else{ return true; } // if (commonGridObj_new.getColumnsNum()==14 && rowIndex>0){ // $("txt_reason").value=commonGridObj_new.cellByIndex(rowIndex,13).getValue(); // } } //Tab键 if(code == 9){ //code9 begin var colCount = commonGridObj_new.getColumnsNum(); var rowCount = commonGridObj_new.getRowsNum(); if(ind < colCount){ isExchange = false; pressRecord = ""; pressRowIndex = -1; pressCellIndex = -1; commonGridObj_new.editStop(true); commonGridObj_new.cellByIndex(rowIndex,ind).setLabel(oldVal); var cInd = ind; var rId = selectedId; if(cInd == 4){ var rowIndex = commonGridObj_new.getRowIndex(rId); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_new.cellByIndex(rowIndex,4).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_new.cellByIndex(rowIndex,5).getValue()))); var amount = unitPrice * quantityCount; commonGridObj_new.cellByIndex(rowIndex,4).setValue(outputMoney(unitPrice.toString())); commonGridObj_new.cellByIndex(rowIndex,7).setValue(outputMoney(amount.toString())); totalDynamicFeeGain(); }else if(cInd == 5){ var rowIndex = commonGridObj_new.getRowIndex(rId); var unitPrice = clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_new.cellByIndex(rowIndex,4).getValue()))); var quantityCount = clearNoNum(isObjNaN(ConvertToMoney(commonGridObj_new.cellByIndex(rowIndex,5).getValue()))); var amount = unitPrice * quantityCount; //mygrid_recv.cellByIndex(rowIndex,4).setValue(outputMoney(unitPrice.toString())); commonGridObj_new.cellByIndex(rowIndex,5).setValue(outputMoney(quantityCount.toString())); commonGridObj_new.cellByIndex(rowIndex,7).setValue(outputMoney(amount.toString())); totalDynamicFeeGain(); }else if(cInd == 8){ var rowIndex = commonGridObj_new.getRowIndex(rId); //filterComboCustomerPress(mygrid_recv,rId,rowIndex,8,nValue,oValue); var curValue = commonGridObj_new.cellByIndex(rowIndex,8).getValue(); //alert(curValue); //alert(rId);alert(curValue); var urlVal = "../FeeCodes/CurrencyCodeService.aspx?gid="+rId+"¤cy="+curValue+"&val="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; commonGridObj_new.cellByIndex(rowIndex,9).setValue(loadVal); totalDynamicFeeGain(); loader == null; } commonGridObj_new.selectCell(rowIndex,ind+1,true,true); commonGridObj_new.editCell(); if(ind == colCount - 2){ if(rowIndex < rowCount){ commonGridObj_new.editStop(true); commonGridObj_new.clearSelection(); commonGridObj_new.selectCell(rowIndex+1,1,true,true); commonGridObj_new.editCell(); }else{ return; } } } //cdoe9 end } if(code>=65&&code<=90){//如果是输入英文字符 if(ind == 1 || ind == 2 ||ind == 3||ind == 10){ //获取键盘输入字符 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 = commonGridObj_new.getCustomCombo(selectedId,ind); var comboArg = combo.getKeys(); var count = 0; //开始遍历检索 //如果检索成功 状态pressCount=1 如果不成功应为pressCount=2 for(var i = 0;i 0){ var combo = commonGridObj_new.getCustomCombo(selectedId,ind); var comboArg = combo.getKeys(); var count = 0; for(var i = 0;i 0){ commonGridObj_new.clearSelection(); commonGridObj_new.editStop(); commonGridObj_new.selectCell(rowIndex-1,1,true,true); commonGridObj_new.editCell(); } }else{ pressCount = 0; return true; } //code38 end } //键盘输入数字 if(code >= 48 && code <= 57|| code >= 96 && code <= 105 || code == 188|| code == 110|| code == 190){ if( ind == 1|| ind == 2|| ind == 3||ind == 4|| ind == 5|| ind == 6|| ind == 7|| ind == 9||ind == 11){ return true; } } //onKeyPress end }); var pressVal = ""; var pressColIndex = 0; var pressRowIndex = 0; var pressGridType = 1;//recv } function addRecvRow(){ if(mygrid_recv.getRowsNum() > 0){ var newId = newGuid(); //获取插入新纪录位置 var rowCount = mygrid_recv.getRowsNum(); mygrid_recv.addRow(newId,["录入状态","","","",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); mygrid_recv.editStop(true); mygrid_recv.selectCell(mygrid_recv.getRowIndex(newId),1,true,true); mygrid_recv.editCell(); }else{ var bsno = $("dvOrderNumVal").value.trim(); mygrid_recv.loadXML("feegridsource.aspx?type=1&read=add&showcount=1&bsno="+bsno+"&oplb="+stroplb); //mygrid_recv.init(); } } function addPayRow(){ if(commonGridObj_new.getRowsNum() > 0){ var newId = newGuid(); //获取插入新纪录位置 var rowCount = commonGridObj_new.getRowsNum(); commonGridObj_new.addRow(newId,["录入状态","","","",0,0,0,0,"RMB",1,"PP","",false],rowCount); //mygrid_recv.addRow(newId,"",mygrid_recv.getRowsNum()); commonGridObj_new.selectRow(commonGridObj_new.getRowIndex(newId),false,false,true); //mygrid_recv.loadXML("feegridsource.aspx?type=1&read=add&showcount="+page_count); //mygrid_recv.enableCellIds(true); var rId = commonGridObj_new.getRowId(rowCount-1); var combo_name; var combo_customer; var combo_unit; var combo_currency; combo_name = commonGridObj_new.getCustomCombo(rId,1); combo_customer = commonGridObj_new.getCustomCombo(rId,2); combo_unit = commonGridObj_new.getCustomCombo(rId,3); combo_currency = commonGridObj_new.getCustomCombo(rId,8); //重新加载应收费用名称 setComboByArray(commonGridObj_new,combo_name,newId,1); //重新加载结算单位 setComboByArray(commonGridObj_new,combo_customer,newId,2); //重新加载计费标准 setComboByArray(commonGridObj_new,combo_unit,newId,3); //重新加载币别 setComboByArray(commonGridObj_new,combo_currency,newId,8); }else{ var bsno = $("dvOrderNumVal").value.trim(); commonGridObj_new.loadXML("feegridsource.aspx?type=2&read=add&showcount=1&bsno="+bsno+"&oplb="+stroplb); //commonGridObj_new.init(); } } function deleteRecvRow(){ var selRowID = mygrid_recv.getSelectedRowId(); var selGroup = new Array(); if(selRowID.indexOf(",") > 0){ selGroup = selRowID.split(","); }else{ if(selRowID != null){ selGroup.push(selRowID); } } //查看是否有被选中的费用项 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(); } }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(); } } delCount++; } } }else{ alert("未选中要操作的费用项"); } } function deletePayRow(){ var selRowID = commonGridObj_new.getSelectedRowId(); var selGroup = new Array(); if(selRowID.indexOf(",") > 0){ selGroup = selRowID.split(","); }else{ if(selRowID != null){ selGroup.push(selRowID); } } //查看是否有被选中的费用项 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 = commonGridObj_new.getRowIndex(selGroup[delCount]); var feeName = commonGridObj_new.cellByIndex(rowIndex,1).getValue(); var cusName = commonGridObj_new.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 ){ commonGridObj_new.deleteRow(selGroup[delCount]); }else{ commonGridObj_new.deleteSelectedRows(); } delCount++; } dg.close(); } }else{ var delCount = 0; while(delCount < selGroup.length){ var rowIndex = commonGridObj_new.getRowIndex(selGroup[delCount]); var feeName = commonGridObj_new.cellByIndex(rowIndex,1).getValue(); var cusName = commonGridObj_new.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; alert(); if(loadVal > 0 ){ commonGridObj_new.deleteRow(selGroup[delCount]); dg.close(); alert("删除成功"); }else{ commonGridObj_new.deleteSelectedRows(); dg.close(); } } delCount++; } } }else{ alert("未选中要操作的费用项"); } } function saveRecvChange(){ //jsonFeeObj = "{\"postFee\": ["; var bsno = $("dvOrderNumVal").value.trim(); jsonFeeObj = "{\"$type\":\"DSWeb.Models.JsonFeeGroupEntity, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\",\"JsonFeeEntities\":["; column_count = mygrid_recv.getColumnsNum(); var tempJson = ""; var rowCount = mygrid_recv.getRowsNum(); for(var i = 0;i < rowCount;i++){ //获取RowID tempJson = ""; var rId = mygrid_recv.getRowId(i); tempJson += "\"$type\":\"DSWeb.Models.JsonFeeEntity, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\","; tempJson += "\"fee1\":\""+rId+"\",";//gid //tempJson += "\"fee1\":\""+2222+"\","; for(var j=0;j < column_count;j++){ var cell = mygrid_recv.cellById(rId,j); var value = ""; value = cell.getValue(); if(value == ""){ value = "null"; } switch(j){ case 0: case 1: case 2: case 3: case 8: case 10: case 11: tempJson += "\"fee"+(j+2)+"\":\""+value+"\","; break; case 12: if(value == 1){ value = true; }else{ value = false; } tempJson += "\"fee"+(j+2)+"\":"+value+","; //tempJson += "\"fee"+(j+3)+"\":\""+bsno+"\""; break; default: tempJson += "\"fee"+(j+2)+"\":"+ConvertToMoney(value)+","; } //tempJson += "\"fun"+(j+2)+"\":\"false\""; } tempJson += "\"fee15\":\""+bsno+"\""; //tempJson += "\"fee"+14+"\":true"; tempJson = "{"+tempJson+"}"; if(i == rowCount - 1){ jsonFeeObj = jsonFeeObj+tempJson; }else{ jsonFeeObj = jsonFeeObj+tempJson+","; } } //jsonFeeObj = jsonFeeObj +"{"+ tempJson +"}"; jsonFeeObj += "]}"; var txt_name = $("recvContainer"); txt_name.value = jsonFeeObj; GetGainArg(); //post form msgBox(); setTimeout(postEnterFee,200); // var bsno = $("dvOrderNumVal").innerHTML.trim(); // setTimeout(function(){ // mygrid_recv.loadXML("feegridsource.aspx?type=1&read=init&showcount=1&bsno="+bsno); // },200); // //postEnterFee(); } function savePayChange(){ var bsno = $("dvOrderNumVal").value.trim(); jsonPayObj = "{\"$type\":\"DSWeb.Models.JsonFeeGroupEntity, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\",\"JsonFeeEntities\":["; column_count = commonGridObj_new.getColumnsNum(); var tempJson = ""; var rowCount = commonGridObj_new.getRowsNum(); for(var i = 0;i < rowCount;i++){ //获取RowID tempJson = ""; var rId = commonGridObj_new.getRowId(i); tempJson += "\"$type\":\"DSWeb.Models.JsonFeeEntity, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\","; tempJson += "\"fee1\":\""+rId+"\",";//gid //tempJson += "\"fee1\":\""+2222+"\","; for(var j=0;j < column_count;j++){ var cell = commonGridObj_new.cellById(rId,j); var value = ""; value = cell.getValue(); if(value == ""){ value = "null"; } switch(j){ case 0: case 1: case 2: case 3: case 8: case 10: case 11: tempJson += "\"fee"+(j+2)+"\":\""+value+"\","; break; case 12: if(value == 1){ value = true; }else{ value = false; } tempJson += "\"fee"+(j+2)+"\":"+value+","; break; default: tempJson += "\"fee"+(j+2)+"\":"+ConvertToMoney(value)+","; } //tempJson += "\"fun"+(j+2)+"\":\"false\""; } tempJson += "\"fee15\":\""+bsno+"\""; //tempJson += "\"fee"+14+"\":true"; tempJson = "{"+tempJson+"}"; if(i == rowCount - 1){ jsonPayObj = jsonPayObj+tempJson; }else{ jsonPayObj = jsonPayObj+tempJson+","; } } //jsonFeeObj = jsonFeeObj +"{"+ tempJson +"}"; jsonPayObj += "]}"; var txt_name = $("payContainer"); txt_name.value = jsonPayObj; GetGainArg(); //post form // alert(jsonPayObj); msgBox(); setTimeout(postEnterFee,200); // var bsno = $("dvOrderNumVal").innerHTML.trim(); // setTimeout(function(){ // commonGridObj_new.loadXML("feegridsource.aspx?type=2&read=init&showcount=1&bsno="+bsno); // },200); } function doOnRowSelected(rowID,celInd){ alert("Selected row ID is "+rowID+"\nUser clicked cell with index "+celInd); } function getValue(){ var colLabel=mygrid_recv.getColumnLabel(0); alert(colLabel); var colLabel2=mygrid_recv.getColumnLabel(0,1); alert(colLabel2); } //post数据 function postEnterFee(){ /*var myForm = document.createElement("form"); myForm.method="post" ; myForm.action = "gridshow.aspx" ; var myInput = document.createElement("input") ; myInput.setAttribute("name", "abc") ; myInput.setAttribute("value", "bbs"); myForm.appendChild(myInput) ; document.body.appendChild(myForm) ; myForm.submit() ; document.body.removeChild(myForm) ;*/ var myForm = document.getElementById("form1"); myForm.submit() ; } function findRow(){ var colNum = mygrid.getColumnsNum(); //alert(colNum); var count = mygrid.getRowsNum(); //alert(count); //var combo = mygrid.getCombo(1); //combo.put("abc","abc"); } function initGrid(){ stroplb= $("h_oplb").value; doInitOldFeeGrid(); setTimeout(doInitNewFeeGrid,200); //setTimeout(doInitPayGrid,100000); } //放弃应收费用修改 重新加载页面 function recoverRecvChange(){ var selRowID = mygrid_recv.getSelectedRowId(); //查看是否有被选中的费用项 if(selRowID != null){ var rowIndex = mygrid_recv.getRowIndex(selRowID); 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="+selRowID+"&handle=recover"; var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; if(!IsNum(loadVal)){ var recvArg = new Array(); recvArg = loadVal.split(","); var selRowIndex = mygrid_recv.getRowIndex(recvArg[0]); var colCount = mygrid_recv.getColumnsNum(); for(var i=1;i 0 ){ // // }else{ // dg.close(); // alert("恢复失败"); // } //doInitRecvGrid(); }else{ return; } }else{ alert("未选中要操作的费用项"); } } //放弃应付费用修改 重新加载页面 function recoverPayChange(){ var selRowID = commonGridObj_new.getSelectedRowId(); //查看是否有被选中的费用项 if(selRowID != null){ var rowIndex = commonGridObj_new.getRowIndex(selRowID); var feeName = commonGridObj_new.cellByIndex(rowIndex,1).getValue(); var cusName = commonGridObj_new.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="+selRowID+"&handle=recover"; var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; if(!IsNum(loadVal)){ var recvArg = new Array(); recvArg = loadVal.split(","); var selRowIndex = commonGridObj_new.getRowIndex(recvArg[0]); var colCount = commonGridObj_new.getColumnsNum(); for(var i=1;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 = commonGridObj_new.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.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){ selGroup = selRowID.split(","); }else{ if(selRowID != null){ selGroup.push(selRowID); } } //查看是否有被选中的费用项 if(selGroup.length > 0){ if(selGroup.length > 1){ var delCount = 0; var loadVal = 0; if(window.confirm("您确定批准通过所选应收费用")){ 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 = "../AuditProcess/AuditService.aspx?handle=audit&oplb=" + stroplb + "&id=" + selGroup[delCount] + "&val=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); loadVal = loader.xmlDoc.responseText; if(loadVal > 0 ){ }else{ } 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{ var delCount = 0; var loadVal = 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 urlVal = "../AuditProcess/AuditService.aspx?handle=audit&oplb="+stroplb+"&id="+selGroup[delCount]+"&val="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); loadVal = loader.xmlDoc.responseText; if(loadVal > 0 ){ doInitRecvGrid(); }else{ } } 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("未选中要操作的费用项"); } } function orderPayAudit(){ var selRowID = commonGridObj_new.getSelectedRowId(); var selGroup = new Array(); if(selRowID.indexOf(",") > 0){ selGroup = selRowID.split(","); }else{ if(selRowID != null){ selGroup.push(selRowID); } } //查看是否有被选中的费用项 if(selGroup.length > 0){ if(selGroup.length > 1){ var delCount = 0; var loadVal = 0; if(window.confirm("您确定批准通过所选应收费用")){ while(delCount < selGroup.length){ var rowIndex = commonGridObj_new.getRowIndex(selGroup[delCount]); var feeName = commonGridObj_new.cellByIndex(rowIndex,1).getValue(); var cusName = commonGridObj_new.cellByIndex(rowIndex,2).getValue(); var urlVal = "../AuditProcess/AuditService.aspx?handle=audit&oplb=" + stroplb + "&id=" + selGroup[delCount] + "&val=" + newGuid(); var loader = dhtmlxAjax.getSync(urlVal); loadVal = loader.xmlDoc.responseText; if(loadVal > 0 ){ }else{ } 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{ var delCount = 0; var loadVal = 0; while(delCount < selGroup.length){ var rowIndex = commonGridObj_new.getRowIndex(selGroup[delCount]); var feeName = commonGridObj_new.cellByIndex(rowIndex,1).getValue(); var cusName = commonGridObj_new.cellByIndex(rowIndex,2).getValue(); if(window.confirm("您确定要将 应收费用("+feeName+") 批准通过")){ var urlVal = "../AuditProcess/AuditService.aspx?handle=audit&oplb="+stroplb+"&id="+selGroup[delCount]+"&val="+newGuid(); var loader = dhtmlxAjax.getSync(urlVal); loadVal = loader.xmlDoc.responseText; if(loadVal > 0 ){ doInitRecvGrid(); }else{ } } 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("未选中要操作的费用项"); } } function orderRecvModify(){ var selRowID = mygrid_recv.getSelectedRowId(); //查看是否有被选中的费用项 if(selRowID != null){ var rowIndex = mygrid_recv.getRowIndex(selRowID); var feeName = mygrid_recv.cellByIndex(rowIndex,1).getValue(); var cusName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); if(window.confirm("您确定要将 应收费用("+feeName+") 提交申请修改")){ } }else{ alert("未选中要操作的费用项"); } } function orderPayModify(){ var selRowID = commonGridObj_new.getSelectedRowId(); //查看是否有被选中的费用项 if(selRowID != null){ var rowIndex = mygrid_recv.getRowIndex(selRowID); var feeName = mygrid_recv.cellByIndex(rowIndex,1).getValue(); var cusName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); if(window.confirm("您确定要将 应付费用("+feeName+") 提交申请修改")){ } }else{ alert("未选中要操作的费用项"); } } function orderRecvDelete(){ var selRowID = mygrid_recv.getSelectedRowId(); //查看是否有被选中的费用项 if(selRowID != null){ var rowIndex = mygrid_recv.getRowIndex(selRowID); var feeName = mygrid_recv.cellByIndex(rowIndex,1).getValue(); var cusName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); if(window.confirm("您确定要将 应收费用("+feeName+") 提交申请删除")){ } }else{ alert("未选中要操作的费用项"); } } function orderPayDelete(){ var selRowID = commonGridObj_new.getSelectedRowId(); //查看是否有被选中的费用项 if(selRowID != null){ var rowIndex = mygrid_recv.getRowIndex(selRowID); var feeName = mygrid_recv.cellByIndex(rowIndex,1).getValue(); var cusName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); if(window.confirm("您确定要将 应付费用("+feeName+") 提交申请删除")){ } }else{ alert("未选中要操作的费用项"); } } function ReShowLabel(gridObj){ var columnCount = gridObj.getColumnsNum(); var rowCount = gridObj.getRowsNum(); if (columnCount==14){ $("txt_reason").value=gridObj.cellByIndex(0,13).getValue(); } if(rowCount > 0){ for(var i = 0;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; } }else{ alert("费用未保存不能打印"); return; } }