var mygrid_recv; var page_count = 5; var column_count; var jsonOpBlissueObj; var changeCount = 0; function $(id){ return document.getElementById(id); } function initWinScreen() { var winScreenHeight = 0; var winScreenWidth = 0; if(window.screen.height) { winScreenHeight = window.screen.height; } if(window.screen.width) { winScreenWidth = window.screen.width; } if(winScreenWidth >= 1440 && winScreenWidth >= 900) { document.getElementById("mygrid_container_recv").style.height = "420px"; } else if(winScreenWidth >= 1366 && winScreenWidth >= 768) { document.getElementById("mygrid_container_recv").style.height = "340px"; } else if(winScreenWidth >= 1024 && winScreenWidth >= 768) { document.getElementById("mygrid_container_recv").style.height = "300px"; } } function doInitRecvGrid(){ mygrid_recv = new dhtmlXGridObject('mygrid_container_recv'); mygrid_recv.setImagePath("../images/"); mygrid_recv.setSkin("xp"); mygrid_recv.setHeader("处理状态,处理时间,处理人,撤销状态,自由添加状态,备注"); mygrid_recv.setInitWidths("100,120,80,60,100,150"); mygrid_recv.setColAlign("center,left,left,left,left,left"); mygrid_recv.setColSorting("str,str,str,str,str,str"); mygrid_recv.setColTypes("co,ro,ro,ro,ro,ed"); var BSNO = $("hid_BSNO").value.trim(); var urlVal = "SeaExportInfoBlissueSurGridSource.aspx?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("SeaExportInfoBlissueSurGridSource.aspx?read=init&showcount=1&BSNO="+BSNO); setTimeout(function(){ ReShowLabel(mygrid_recv); },200); } mygrid_recv.init(); mygrid_recv.enableEditEvents(true,false,true); mygrid_recv.enableMultiselect(true); mygrid_recv.enableKeyboardSupport(true); mygrid_recv.attachEvent("onRowDblClicked", function(rId,cInd) { var rowIndex = mygrid_recv.getRowIndex(rId); var sBLSTATUS = mygrid_recv.cellByIndex(rowIndex,0).getValue().trim(); if(sBLSTATUS=="放单申请") { var openSet = "height=300, width=700, toolbar=no, menubar=no,scrollbars=no, resizable=0,location=no, status=no,Top= " +(screen.height/2-100) + ",Left= "+(screen.width/2-100); var openType = "_blank"; var openUrl = "SeaExportInfoBlissueSurPutSingle.aspx?handle=edit&id="+rId+"&bsno="+$("hid_BSNO").value+"&val="+newGuid(); var tempWin = window.open ("about:blank",openType,openSet); tempWin.location = openUrl; } }); var pushVal = ""; var pressRecord = ""; var pressRowIndex = -1; var pressCellIndex = -1; var pressCount = 0; var isExchange = false; var shiftCount = 0; var isDelete = 0; var flagFilter = 0; var flagTab = 0; var flagEnter = 0; var flagDelete = 0; //手动编写Grid控件编辑事件,由于免费控件没有提供完整的编辑判断功能,现特此做更改 mygrid_recv.attachEvent("onEditCell",function(stage,rId,nValue,cInd,oValue,aValue,rValue) { var newCheckValue = false; //初始化状态 if(stage == 0) { var selectedId = mygrid_recv.getSelectedRowId(); var rowIndex = mygrid_recv.getRowIndex(selectedId); var oldVal = mygrid_recv.cellByIndex(rowIndex,0).getValue().trim(); return true; } if(stage == 1) { var selectedId = mygrid_recv.getSelectedRowId(); var rowIndex = mygrid_recv.getRowIndex(selectedId); var txtEdit; for(i = 0; i < document.all.length; i++) { if(document.all(i).tagName == "TEXTAREA") { txtEdit = document.all(i); txtEdit.focus(); txtEdit.select(); break; } } } //如果编辑结束 if(stage == 2) { if(cInd == 0) { var rowIndex = mygrid_recv.getRowIndex(rId); if(pressCount == 1) { if(flagFilter == 1) { mygrid_recv.cellByIndex(rowIndex,cInd).setLabel(oValue); return true; } else { var cellVal = mygrid_recv.cellByIndex(rowIndex,cInd).getValue(); var combo = mygrid_recv.getCustomCombo(rId,cInd); var comboArg = combo.getKeys(); var tempCount = 0; if(cellVal.indexOf(" ") >0 && cellVal.indexOf(" ") < cellVal.length){ cellVal = cellVal.substring(0,cellVal.indexOf(" ")); for(var i = 0;i 0) { mygrid_recv.cellByIndex(rowIndex,cInd).setValue(comboArg[i]); mygrid_recv.cellByIndex(rowIndex,cInd).setLabel(comboArg[i]); tempCount++; break; } } } isExchange = false; pressRecord = ""; pressRowIndex = -1; pressCellIndex = -1; pressCount = 0; flagFilter = 0; return true; } } else if(pressCount == 2) { if(flagFilter == 1) { mygrid_recv.editStop(); mygrid_recv.cellByIndex(rowIndex,cInd).setLabel(oValue); } else { if(pressRowIndex != rowIndex && pressCellIndex != cInd) { return true; } else { isExchange = false; pressRecord = ""; pressRowIndex = -1; pressCellIndex = -1; pressCount = 0; flagFilter = 0; var cellVal = mygrid_recv.cellByIndex(rowIndex,cInd).getValue(); 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; } } } return true; } } else { return true; } } }); //键盘操作事件 mygrid_recv.attachEvent("onKeyPress", function(code,cFlag,sFlag) { //onKeyPress begin //获取当前RowID var selectedId = mygrid_recv.getSelectedRowId(); //获取当前RowIndex var rowIndex = mygrid_recv.getRowIndex(selectedId); //获取当前CellIndex(ind) var ind = mygrid_recv.getSelectedCellIndex(); //触发操作事件前获取单元值 var oldVal = mygrid_recv.cellByIndex(rowIndex,ind).getValue(); //获取编辑单元 var txtEdit; for(i = 0; i < document.all.length; i++) { if(document.all(i).tagName == "TEXTAREA") { txtEdit = document.all(i); break; } } if(code == 13) { if(ind ==0) { //如果是检索失败, 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; } return true; } else { return true; } } else if(code == 9)//Tab键 { var colCount = mygrid_recv.getColumnsNum(); var rowCount = mygrid_recv.getRowsNum(); if(ind < colCount) { isExchange = false; pressRecord = ""; pressRowIndex = -1; pressCellIndex = -1; mygrid_recv.editStop(true); mygrid_recv.cellByIndex(rowIndex,ind).setLabel(oldVal); var cInd = ind; var rId = selectedId; mygrid_recv.selectCell(rowIndex,ind+1,true,true); mygrid_recv.editCell(); if(ind == colCount - 1) { if(rowIndex < rowCount) { mygrid_recv.editStop(true); mygrid_recv.clearSelection(); mygrid_recv.selectCell(rowIndex+1,0,true,true); mygrid_recv.editCell(); } else { return; } } } } else if(code == 40)//向下方向键 { var rowCount = mygrid_recv.getRowsNum(); mygrid_recv.clearSelection(); mygrid_recv.editStop(); if(rowIndex == (rowCount - 1)) { addRecvRow(); } else { mygrid_recv.selectCell(rowIndex+1,0,true,true); mygrid_recv.editCell(); } } else if(code == 38)//向上箭头 { if(rowIndex > 0) { mygrid_recv.clearSelection(); mygrid_recv.editStop(); mygrid_recv.selectCell(rowIndex-1,0,true,true); mygrid_recv.editCell(); } } else { return true; } }); setTimeout(function(){ markStatusColor(mygrid_recv); },400); } //讲下拉列表Combo所有生成Array数组 function setComboByArray(gridNewObj,comboObj,rowGID,colIndex) { 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 0) // { var newId = newGuid(); //获取插入新纪录位置 var rowCount = mygrid_recv.getRowsNum(); var loader = dhtmlxAjax.getSync("SeaExportInfoBlissueSurGridSource.aspx?read=addrq"); var loadrq = loader.xmlDoc.responseText; loader = dhtmlxAjax.getSync("SeaExportInfoBlissueSurGridSource.aspx?read=addname"); var loadname = loader.xmlDoc.responseText; alert(loadrq+","+loadname); mygrid_recv.addRow(newId,["",loadrq,loadname,"","",""],rowCount); mygrid_recv.clearSelection(); var rId; if(rowCount==0) { rId = mygrid_recv.getRowId(rowCount); } else { rId = mygrid_recv.getRowId(rowCount-1); } var combo_customer; combo_customer = mygrid_recv.getCustomCombo(rId,0); //重新状态类型 setComboByArray(mygrid_recv,combo_customer,newId,0); mygrid_recv.editStop(true); mygrid_recv.selectCell(mygrid_recv.getRowIndex(newId),0,true,true); mygrid_recv.editCell(); // } // else // { // var BSNO = $("hid_BSNO").value.trim(); // if(BSNO=="") // { // alert("请先确定委托信息已保存!"); // return; // } // alert(BSNO); // mygrid_recv.loadXML("SeaExportInfoBlissueSurGridSource.aspx?read=add&showcount=1&BSNO="+BSNO); // } } 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 OpBlissueName = mygrid_recv.cellByIndex(rowIndex,1).getValue(); var cusName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); var delflag = mygrid_recv.cellByIndex(rowIndex,3).getValue(); var isadd = mygrid_recv.cellByIndex(rowIndex,4).getValue(); if(isadd=="否") { continue; } // //var urlVal = "OpBlissueService.aspx?gid="+selGroup[delCount]+"&handle=delete"+"&no="+newGuid(); var urlVal = "SeaExportInfoBlissueSurGridSource.aspx?read=delete&gid="+selGroup[delCount]; 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 status = mygrid_recv.cellByIndex(rowIndex,0).getValue(); var OpBlissueName = mygrid_recv.cellByIndex(rowIndex,1).getValue(); var cusName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); var delflag = mygrid_recv.cellByIndex(rowIndex,3).getValue(); var isadd = mygrid_recv.cellByIndex(rowIndex,4).getValue(); if(isadd=="否") { alert("只允许删除 自由添加状态 的数据!"); return; } // if(window.confirm("确定要将("+status+")删除吗?")) { var dg=new dialog(); dg.html=""; dg.width=200; dg.height=100; dg.title="标题"; dg.show(); //var urlVal = "OpBlissueService.aspx?gid="+selGroup[delCount]+"&handle=delete"+"&no="+newGuid(); var urlVal = "SeaExportInfoBlissueSurGridSource.aspx?read=delete&gid="+selGroup[delCount]; 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 saveRecvChange() { var strError=""; var strError2=""; var strError3=""; var BSNO = $("hid_BSNO").value.trim(); if(BSNO=="") { alert("请先确定委托信息已保存!"); return; } // jsonOpBlissueObj = "{\"$type\":\"DSWeb.Models.JsonOpBlissueGroupEntity, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\",\"JsonOpBlissueEntities\":["; column_count = mygrid_recv.getColumnsNum(); var tempJson = ""; var rowCount = mygrid_recv.getRowsNum(); for(var i = 0;i < rowCount;i++) { var delflag = mygrid_recv.cellByIndex(i,3).getValue(); var isadd = mygrid_recv.cellByIndex(i,4).getValue(); if(isadd=="否") { continue; } // //获取RowID tempJson = ""; var rId = mygrid_recv.getRowId(i); tempJson += "\"$type\":\"DSWeb.Models.JsonOpBlissueEntity, DSWeb, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\","; tempJson += "\"OpBlissue1\":\""+rId+"\",";//gid strError=""; for(var j=0;j < column_count;j++) { var cell = mygrid_recv.cellById(rId,j); var value = ""; //value = cell.cell.innerText; // .getValue(); value = cell.cell.textContent || cell.cell.innerText; if((j+2)==2) { if(value.trim() == "") { value = "0"; strError="处理状态不允许为空!" continue; } else if(value.trim() == "申请电放" || value.trim() == "批准电放" || value.trim() == "提单电放" || value.trim() == "申请提单" || value.trim() == "提单签收" || value.trim() == "提单签出" || value.trim() == "放单申请" || value.trim() == "批准放单") { value = "0"; strError="处理状态不允许为“申请电放、批准电放、提单电放、申请提单、提单签收、提单签出、放单申请、批准放单”,请按提单处理流程生成!" continue; } else { if(value == "") { value = "null"; } if(j==1 && value!="null") { var aVvalue = new Array(); if(value.indexOf("/")>0) { aVvalue = value.split("/"); value=aVvalue[2]+"-"+aVvalue[0]+"-"+aVvalue[1]+" 00:00:00" } // var s1 = value.indexOf("-"); var s2 = value.lastIndexOf("-"); var s3 = s2-s1; if(s3<3) { value = value.substr(0,s1+1)+"0"+ value.substr(s1+1); } } if(j==3 || j==4) { continue; } } } else { if(value == "") { value = "null"; } if(j==1 && value!="null") { var aVvalue = new Array(); if(value.indexOf("/")>0) { aVvalue = value.split("/"); value=aVvalue[2]+"-"+aVvalue[0]+"-"+aVvalue[1]+" 00:00:00" } // var s1 = value.indexOf("-"); var s2 = value.lastIndexOf("-"); var s3 = s2-s1; if(s3<3) { value = value.substr(0,s1+1)+"0"+ value.substr(s1+1); } } if(j==3 || j==4) { continue; } } tempJson += "\"OpBlissue"+(j+2)+"\":\""+value+"\","; } tempJson += "\"OpBlissue8\":\""+BSNO+"\""; tempJson = "{"+tempJson+"}"; // if(strError!="") { strError2=strError; continue; } else { strError3+=","+BSNO } // if(i == rowCount - 1) { jsonOpBlissueObj = jsonOpBlissueObj+tempJson; } else { jsonOpBlissueObj = jsonOpBlissueObj+tempJson+","; } } // if(strError2!="") { alert(strError2); strError2=""; var dg=new dialog(); dg.close(); return; } // if(strError3=="") { var dg=new dialog(); dg.close(); return; } jsonOpBlissueObj += "]}"; var txt_name = $("recvContainer"); txt_name.value = jsonOpBlissueObj; msgBox(); setTimeout(postEnterOpBlissue,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 postEnterOpBlissue(){ 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(){ doInitRecvGrid(); //setTimeout(doInitPayGrid,200); //setTimeout(totalDynamicOpBlissueGain,700); } //放弃应收费用修改 重新加载页面 function recoverRecvChange(){ var selRowID = mygrid_recv.getSelectedRowId(); //查看是否有被选中的费用项 if(selRowID != null){ var rowIndex = mygrid_recv.getRowIndex(selRowID); var status = mygrid_recv.cellByIndex(rowIndex,0).getValue(); var OpBlissueName = mygrid_recv.cellByIndex(rowIndex,1).getValue(); var cusName = mygrid_recv.cellByIndex(rowIndex,2).getValue(); if(window.confirm("您确定放弃所有的修改吗?")){//("+OpBlissueName+")部门的 var dg=new dialog(); dg.html=""; dg.width=200; dg.height=100; dg.title="标题"; dg.show(); //var urlVal = "OpBlissueService.aspx?gid="+selRowID+"&handle=recover"; var urlVal = "SeaExportInfoBlissueSurGridSource.aspx?read=recover&gid="+selRowID; 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){ for(var i = 0;i