var commonGridObj_step; var editCount; function $(id){ return document.getElementById(id); } function createStepGrid(){ var headerArgs_step = new Array("","步骤编号","系统名称","显示名称","过滤条件","审核人","是否必须审核","是否最终审核","是否并行","是否区分部门","所属部门","创建人","创建时间","备注"); //width var widthArgs_step = new Array("40","80","150","150","150","100","100","100","100","80","80","150","150","150"); //column align var colAlignArgs_step = new Array("center","center","center","center","center","center","center","center","center","center","center","center","center","center"); //column sort var colSortArgs_step = new Array("na","str","str","str","str","str","str","str","str","str","str","str","str","str"); //column type var colTypeArgs_step = new Array("ch","ro","ed","ed","ro","ro","ch","ch","ch","ch","ro","ro","ro","txt"); commonGridObj_step = new TGridCommon("mygrid_container_steps","form1",headerArgs_step,widthArgs_step,colAlignArgs_step,colSortArgs_step,colTypeArgs_step); commonGridObj_step.setResponseUrl("WorkFlowGridSource.aspx"); var workflowID = $("h_workflowid").value.trim(); commonGridObj_step.setRequest("WorkFlowGridSource.aspx?handle=steplist&flowid="+workflowID); commonGridObj_step.setSourceType("json"); commonGridObj_step.setSkin("xp"); commonGridObj_step.setImageUrl("../images/"); commonGridObj_step.initGrid(); commonGridObj_step.bind(); commonGridObj_step.getGridObj().enableEditEvents(true,false,true); commonGridObj_step.getGridObj().attachEvent("onEditCell",function(stage,rId,cInd,nValue,oValue){ if(stage == 0){ if(cInd == 6 || cInd == 7 || cInd == 8){ return false; }else{ return true; } } if(stage == 2){ return true; } }); commonGridObj_step.getGridObj().attachEvent("onRowSelect", function(id,ind){ if(ind == 5){ var openSet = "height=360, width=460, toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no,Top= " +(screen.height-490)/2 + ",Left= "+(screen.width-1000)/2 var openType = "_blank"; if (id==""){ alert("请保存步骤信息后,再设置"); return; } var openUrl = "UserTree.aspx?stepid="+id; window.open (openUrl,openType,openSet); } }); } function checkAll(gridObj){ if(gridObj != null){ var checkAllVal = $("ck_all").checked; for(var i=0;i 0){ var delCount = 0; if(recvArg.length > 0){ if(window.confirm("您确定要将所选工作流步骤删除")){ while(delCount < recvArg.length){ //删除工作流步骤信息,分2种情况,1:workflow_step;2:workflow_step,workflow_do var urlVal = "WorkFlowGridSource.aspx?stepid="+recvArg[delCount]+"&handle=deleteStep"; var loader = dhtmlxAjax.getSync(urlVal); var loadVal = loader.xmlDoc.responseText; if(loadVal == 1 ){ //commonGridObj_step.getGridObj().deleteRow(recvArg[delCount]); } delCount++; } } } createStepGrid(); } }//end deleteStep function refreshList(){ if(window.confirm("您确定要刷新页面,有未保存的记录,如果确定刷新则放弃未保存的记录")){ createStepGrid(); } } //获取新的步骤编号信息 function getLastStepNo(){ var lastStepNo = 0; if(commonGridObj_step != null){ for(var i=0;i lastStepNo){ lastStepNo = tempStepNo; } } } return lastStepNo+1; } function saveStep(){ var saveStepObj = null; if(commonGridObj_step != null){ for(var i=0;i= 0){ alert("系统名称格式错误,不能识别单引号"); return; } if(stepDescription.trim() == ""){ alert("显示名称不能为空"); return; } if(stepDescription.trim().indexOf("'") >= 0){ alert("显示名称格式错误,不能识别单引号"); return; } if(saveStepObj != null){ if(saveStepObj.steps.length > 0){ var newCache = saveStepObj.steps; newCache = {id:rowID,no:stepNo,name:stepName,desp:stepDescription,must:isMust,last:isLast,parallel:isParallel,dept:isDepartment,remark:remark}; saveStepObj.steps.push(newCache); $("h_cache").value = JSON.stringify(saveStepObj); }else{ var cacheBuffer = ""; var result = ""; cacheBuffer += "{"; cacheBuffer += "\"id\":\""+rowID+"\","; cacheBuffer += "\"no\":\""+stepNo+"\","; cacheBuffer += "\"name\":"+stepName+","; cacheBuffer += "\"desp\":\""+stepDescription+"\","; cacheBuffer += "\"must\":"+isMust+","; cacheBuffer += "\"last\":"+isLast+","; cacheBuffer += "\"parallel\":"+isParallel+","; cacheBuffer += "\"dept\":"+isDepartment+","; cacheBuffer += "\"remark\":\""+remark+"\""; cacheBuffer += "}"; result += "{\"steps\":["; result += cacheBuffer; result += "]}"; saveStepObj = eval('(' + result + ')'); $("h_cache").value = JSON.stringify(saveStepObj); } }else{ var cacheBuffer = ""; var result = ""; cacheBuffer += "{"; cacheBuffer += "\"id\":\""+rowID+"\","; cacheBuffer += "\"no\":\""+stepNo+"\","; cacheBuffer += "\"name\":\""+stepName+"\","; cacheBuffer += "\"desp\":\""+stepDescription+"\","; cacheBuffer += "\"must\":"+isMust+","; cacheBuffer += "\"last\":"+isLast+","; cacheBuffer += "\"parallel\":"+isParallel+","; cacheBuffer += "\"dept\":"+isDepartment+","; cacheBuffer += "\"remark\":\""+remark+"\""; cacheBuffer += "}"; result += "{\"steps\":["; result += cacheBuffer; result += "]}"; saveStepObj = eval('(' + result + ')'); $("h_cache").value = JSON.stringify(saveStepObj); } } } if($("h_cache").value.trim() != ""){ $("h_post").value = "1"; postEnterFee(); } } function upStep(){ var tempCount = 0; var checkState = 0; for(var i=0;i 1){ checkState = 0; tempCount = 0; alert("每次只能移动一条步骤"); return; } if(checkState == 0){ alert("已经是最第一步骤,不能移动"); return; } var oldObj = getCacheObj(); var oldCount = checkState - 1; oldObj.steps[0].id = commonGridObj_step.getGridObj().getRowId(oldCount); oldObj.steps[0].check = parseInt(commonGridObj_step.getGridObj().cellByIndex(oldCount,0).getValue()); oldObj.steps[0].no = parseInt(commonGridObj_step.getGridObj().cellByIndex(oldCount,1).getValue()); oldObj.steps[0].name = commonGridObj_step.getGridObj().cellByIndex(oldCount,2).getValue(); oldObj.steps[0].desp = commonGridObj_step.getGridObj().cellByIndex(oldCount,3).getValue(); oldObj.steps[0].must = commonGridObj_step.getGridObj().cellByIndex(oldCount,6).getValue(); oldObj.steps[0].last = commonGridObj_step.getGridObj().cellByIndex(oldCount,7).getValue(); oldObj.steps[0].parallel = commonGridObj_step.getGridObj().cellByIndex(oldCount,8).getValue(); oldObj.steps[0].dept = commonGridObj_step.getGridObj().cellByIndex(oldCount,9).getValue(); //alert(JSON.stringify(oldObj)); var currObj = getCacheObj(); var currCount = checkState; currObj.steps[0].id = commonGridObj_step.getGridObj().getRowId(currCount); currObj.steps[0].check = parseInt(commonGridObj_step.getGridObj().cellByIndex(currCount,0).getValue()); currObj.steps[0].no = parseInt(commonGridObj_step.getGridObj().cellByIndex(currCount,1).getValue()); currObj.steps[0].name = commonGridObj_step.getGridObj().cellByIndex(currCount,2).getValue(); currObj.steps[0].desp = commonGridObj_step.getGridObj().cellByIndex(currCount,3).getValue(); currObj.steps[0].must = commonGridObj_step.getGridObj().cellByIndex(currCount,6).getValue(); currObj.steps[0].last = commonGridObj_step.getGridObj().cellByIndex(currCount,7).getValue(); currObj.steps[0].parallel = commonGridObj_step.getGridObj().cellByIndex(currCount,8).getValue(); currObj.steps[0].dept = commonGridObj_step.getGridObj().cellByIndex(currCount,9).getValue(); //alert(JSON.stringify(currObj)); commonGridObj_step.getGridObj().setRowId(oldCount,currObj.steps[0].id); // commonGridObj_step.getGridObj().cellByIndex(oldCount,1).setValue(currObj.steps[0].no); commonGridObj_step.getGridObj().cellByIndex(oldCount,0).setValue(currObj.steps[0].check); commonGridObj_step.getGridObj().cellByIndex(oldCount,2).setValue(currObj.steps[0].name); commonGridObj_step.getGridObj().cellByIndex(oldCount,3).setValue(currObj.steps[0].desp); commonGridObj_step.getGridObj().cellByIndex(oldCount,6).setValue(currObj.steps[0].must); commonGridObj_step.getGridObj().cellByIndex(oldCount,7).setValue(currObj.steps[0].last); commonGridObj_step.getGridObj().cellByIndex(oldCount,8).setValue(currObj.steps[0].parallel); commonGridObj_step.getGridObj().cellByIndex(oldCount,9).setValue(currObj.steps[0].dept); commonGridObj_step.getGridObj().setRowId(currCount,oldObj.steps[0].id); // commonGridObj_step.getGridObj().cellByIndex(currCount,1).setValue(oldObj.steps[0].no); commonGridObj_step.getGridObj().cellByIndex(currCount,0).setValue(oldObj.steps[0].check); commonGridObj_step.getGridObj().cellByIndex(currCount,2).setValue(oldObj.steps[0].name); commonGridObj_step.getGridObj().cellByIndex(currCount,3).setValue(oldObj.steps[0].desp); commonGridObj_step.getGridObj().cellByIndex(currCount,6).setValue(oldObj.steps[0].must); commonGridObj_step.getGridObj().cellByIndex(currCount,7).setValue(oldObj.steps[0].last); commonGridObj_step.getGridObj().cellByIndex(currCount,8).setValue(oldObj.steps[0].parallel); commonGridObj_step.getGridObj().cellByIndex(currCount,9).setValue(oldObj.steps[0].dept); // alert(JSON.stringify(currObj));alert(JSON.stringify(oldObj)); } function downStep(){ var tempCount = 0; var checkState = 0; for(var i=0;i 1){ checkState = 0; tempCount = 0; alert("每次只能移动一条步骤"); return; } if(checkState == (commonGridObj_step.getGridObj().getRowsNum() - 1)){ alert("已经是最后步骤,不能移动"); return; } var oldObj = getCacheObj(); var oldCount = checkState; oldObj.steps[0].id = commonGridObj_step.getGridObj().getRowId(oldCount); oldObj.steps[0].check = parseInt(commonGridObj_step.getGridObj().cellByIndex(oldCount,0).getValue()); oldObj.steps[0].no = parseInt(commonGridObj_step.getGridObj().cellByIndex(oldCount,1).getValue()); oldObj.steps[0].name = commonGridObj_step.getGridObj().cellByIndex(oldCount,2).getValue(); oldObj.steps[0].desp = commonGridObj_step.getGridObj().cellByIndex(oldCount,3).getValue(); oldObj.steps[0].must = commonGridObj_step.getGridObj().cellByIndex(oldCount,6).getValue(); oldObj.steps[0].last = commonGridObj_step.getGridObj().cellByIndex(oldCount,7).getValue(); oldObj.steps[0].parallel = commonGridObj_step.getGridObj().cellByIndex(oldCount,8).getValue(); oldObj.steps[0].dept = commonGridObj_step.getGridObj().cellByIndex(oldCount,9).getValue(); //alert(JSON.stringify(oldObj)); var currObj = getCacheObj(); var currCount = checkState + 1; currObj.steps[0].id = commonGridObj_step.getGridObj().getRowId(currCount); currObj.steps[0].check = parseInt(commonGridObj_step.getGridObj().cellByIndex(currCount,0).getValue()); currObj.steps[0].no = parseInt(commonGridObj_step.getGridObj().cellByIndex(currCount,1).getValue()); currObj.steps[0].name = commonGridObj_step.getGridObj().cellByIndex(currCount,2).getValue(); currObj.steps[0].desp = commonGridObj_step.getGridObj().cellByIndex(currCount,3).getValue(); currObj.steps[0].must = commonGridObj_step.getGridObj().cellByIndex(currCount,6).getValue(); currObj.steps[0].last = commonGridObj_step.getGridObj().cellByIndex(currCount,7).getValue(); currObj.steps[0].parallel = commonGridObj_step.getGridObj().cellByIndex(currCount,8).getValue(); currObj.steps[0].dept = commonGridObj_step.getGridObj().cellByIndex(currCount,9).getValue(); //alert(JSON.stringify(currObj)); commonGridObj_step.getGridObj().setRowId(oldCount,currObj.steps[0].id); // commonGridObj_step.getGridObj().cellByIndex(oldCount,1).setValue(currObj.steps[0].no); commonGridObj_step.getGridObj().cellByIndex(oldCount,0).setValue(currObj.steps[0].check); commonGridObj_step.getGridObj().cellByIndex(oldCount,2).setValue(currObj.steps[0].name); commonGridObj_step.getGridObj().cellByIndex(oldCount,3).setValue(currObj.steps[0].desp); commonGridObj_step.getGridObj().cellByIndex(oldCount,6).setValue(currObj.steps[0].must); commonGridObj_step.getGridObj().cellByIndex(oldCount,7).setValue(currObj.steps[0].last); commonGridObj_step.getGridObj().cellByIndex(oldCount,8).setValue(currObj.steps[0].parallel); commonGridObj_step.getGridObj().cellByIndex(oldCount,9).setValue(currObj.steps[0].dept); commonGridObj_step.getGridObj().setRowId(currCount,oldObj.steps[0].id); // commonGridObj_step.getGridObj().cellByIndex(currCount,1).setValue(oldObj.steps[0].no); commonGridObj_step.getGridObj().cellByIndex(currCount,0).setValue(oldObj.steps[0].check); commonGridObj_step.getGridObj().cellByIndex(currCount,2).setValue(oldObj.steps[0].name); commonGridObj_step.getGridObj().cellByIndex(currCount,3).setValue(oldObj.steps[0].desp); commonGridObj_step.getGridObj().cellByIndex(currCount,6).setValue(oldObj.steps[0].must); commonGridObj_step.getGridObj().cellByIndex(currCount,7).setValue(oldObj.steps[0].last); commonGridObj_step.getGridObj().cellByIndex(currCount,8).setValue(oldObj.steps[0].parallel); commonGridObj_step.getGridObj().cellByIndex(currCount,9).setValue(oldObj.steps[0].dept); // alert(JSON.stringify(currObj));alert(JSON.stringify(oldObj)); } function getCacheObj(){ var tempObj = null; var cacheBuffer = ""; var result = ""; cacheBuffer += "{"; cacheBuffer += "\"id\":\"\","; cacheBuffer += "\"check\":0,"; cacheBuffer += "\"no\":\"\","; cacheBuffer += "\"name\":\"\","; cacheBuffer += "\"desp\":\"\","; cacheBuffer += "\"must\":0,"; cacheBuffer += "\"last\":0,"; cacheBuffer += "\"parallel\":0,"; cacheBuffer += "\"dept\":0,"; cacheBuffer += "\"remark\":\"\""; cacheBuffer += "}"; result += "{\"steps\":["; result += cacheBuffer; result += "]}"; tempObj = eval('(' + result + ')'); return tempObj; } function doParallel(){ var tempCount = 0; var checkState = 0; var paraObj = null; var sameNo = 0; var isExistLast = 0; for(var i=0;i 0){ commonGridObj_step.getGridObj().cellByIndex(k,7).setValue(1); } commonGridObj_step.getGridObj().cellByIndex(k,8).setValue(1); break; } } } } function postEnterFee(){ var myForm = document.getElementById("form1"); myForm.submit() ; }