function checkForm() { /* * var rs = $.validate({ name : "v_ins_name", model : [ { type : "require", * msg : "流程标题不能为空!", msgBox : "v_ins_name_box" }, { type : "len", min : 1, * max : 50, msg : "流程标题长度不能超过50个字!", msgBox : "v_ins_name_box" } ] }); */ // 同步标题输入框的值到隐藏字段,确保数据一致性 if($("#insNameText").is(":visible")) { $("#insName").val($("#insNameText").val()); } if($.trim($("#insName").val()) == ''){ addError("流程标题不能为空!"); return false; } if($.trim($("#insName").val()).length > 100){ addError("流程标题不能超过100个字!"); return false; } var rs = true; var reqOffice = $("#reqOffice").val(); if(reqOffice == "1"){ rs = $.validate({ name : "file_fileId", model : [ { type : "require", msg : "请上传附件!" }] }) && rs; } var pathJudgeType = $("#pathJudgeType").val(); if (pathJudgeType == "1") { rs = $.validate({ name : "nextTmodelId", model : [ { type : "require", msg : "下一步环节不能为空!" } ] }); } var usersNames = $("[type='text'][id*='usersName']:visible"); for ( var i = 0; i < usersNames.length; i++) { rs = $.validate({ name : usersNames[i].id, model : [ { type : "require", msg : "下一步环节操作人不能为空!" } ] }) && rs; } if (rs) { return true; } return false; } function formJs() { if (formId == "0") { //没有表单 var rs = checkForm(); $("#formInsId").val("0"); if (rs) { //$('.bsubmit').attr("disabled", "disabled"); preProcess("FlowAction.do", "#insForm"); } } else {//有表单 var rs = true; rs = checkForm() && rs; if (rs) { var hasGen = $(window.frames["formIns"].document).find( "#hasGen").val();//查找是否启用软航印章 $('.bsubmit').attr("disabled", "disabled"); if(document.frames == undefined){ window.frames["formIns"].replaceTextarea(); } else { document.frames.formIns.replaceTextarea(); } if (hasGen == 0) { //无软航印章文件直接提交表单 $(window.frames["formIns"].document).find("#formIns").attr("action","bpmFormInstanceAction.do?task=saveIns"); $(window.frames["formIns"].document).find("#formIns").submit(); } else {//有软航印章文件调用js方法提交 if(document.frames == undefined){ window.frames["formIns"].save(); } else { document.frames.formIns.save(); } } } } } /** * 修改流程标题 */ function changeInsName() { $("#insNameText").show(); $("#insNameEnter").show(); $("#insNameEdit").hide(); $("#insNameFont").hide(); } /** * 确认标题修改 */ function confirmInsName() { if($.trim($("#insNameText").val()) == ''){ addError("流程标题不能为空!"); return; } if($.trim($("#insNameText").val()).length > 100){ addError("流程标题不能超过100个字!"); return; } $("#insNameText").hide(); $("#insNameEnter").hide(); $("#insNameEdit").show(); $("#insNameFont").show(); $("#insNameFont").text($("#insNameText").val()); $("#insName").val($("#insNameText").val()); } var officeDialog = null; var nextTacheDialog = null; var nextTacheInfoDialog = null; function ow(owurl, name) { officeDialog = $.ligerDialog.open({ height : 700, width : 1000, url : owurl, showMax : false, showToggle : false, showMin : false, isResize : false, modal : true, title : name, allowClose : false }); } function closeOfficeDialog() { officeDialog.close(); } function openOffice() { var officeId = $("#officeId").val(); ow('${pageContext.request.contextPath}/NtkoAction.do?task=edit&fileId=' + officeId, 'web文档'); } function setValue(fileId, fileName) { $("#officeId").val(fileId); $("#officeName").val(fileName); $("#createOffice").hide(); $("#editOffice").show(); } /** * 点击"提交"展示"选择下一环节信息" */ function chooseNextTache(buttonName) { if(!confirm("确认" + buttonName + "该流程?")){ return; } var rs = true; var reqRemark = $("#reqRemark").val(); if (reqRemark == "1") { rs = $.validate({ name : "remark", model : [ { type : "require", msg : "流程内容不能为空!" },{ type : "len", min : 0, max : 1000, msg : "流程内容长度不能超过1000个字!" } ] }); }else{ rs = $.validate({ name : "remark", model : [ { type : "len", min : 0, max : 1000, msg : "流程内容长度不能超过1000个字!" } ] }); } if (formId != "0") {//判断流程是否有表单,有表单则进行表单验证 if(document.frames == undefined){ rs = window.frames["formIns"].checkForm() && rs; } else { rs = document.frames.formIns.checkForm() && rs; } } if (!rs) { return; } window.scrollTo(0,0); //nextTacheDialog.show(); formJs(); } /** * 关闭"选择下一环节信息"对话框 */ function closeNextTache() { nextTacheDialog.hidden(); } function closeNextTacheInfo() { nextTacheInfoDialog.hidden(); } /** * 初始化"选择下一环节信息"对话框 */ $(function() { nextTacheInfoDialog = $.ligerDialog.open({ width : 800, target : $("#nextTacheInfo"), showMax : false, showToggle : false, showMin : false, show : false, isResize : false, modal : true, title : "后续环节人员查看及选择", allowClose : true, containerId : 'insForm' }); nextTacheInfoDialog.hidden(); }); function preProcess(actionUrl, formName) { $("#task").val("preProcess"); var x = $(formName).serializeArray(); $.each(x, function(i, field) { field.value = encodeURI(field.value); }); $.ajax({ url : actionUrl, async : true, type : "post", data : x, dataType : 'json', success : function(data) { // alert(data); // addInfo(data); // var oldTabid = $("#tabid").val(); // window.parent.f_reloadTab(oldTabid); // window.parent.frames[oldTabid].closeODialog($("#dialogId").val()); // alert(data[0].nextTacheInstances); var resultState = data[0].resultState; var submitState = data[0].submitState; var resultInfo = data[0].resultInfo; if(!submitState){ $("#sbmbtn").hide(); $("#clsbtn").show(); } else { $("#sbmbtn").show(); $("#clsbtn").hide(); } document.body.scrollIntoView();//滚动到页面顶部 if(resultState){ var table= $("#nextTacheInfoTd"); table.html(""); var nextTacheInstances = data[0].nextTacheInstances; for(var i = 0 ; i < nextTacheInstances.length; i++){ var users = nextTacheInstances[i].users; var info = nextTacheInstances[i].info; var isCheck = nextTacheInstances[i].isCheck; var tacheModel = nextTacheInstances[i].tacheModel; var html = ""; html += ""; html += tacheModel.tmodelName; html += ""; if(isCheck){ html += ""; } else { html += ""; } if(info != "" && info != null && info != undefined){ html += "" + info + ""; } else { var lzCount = 0; for(var j = 0 ; j < users.length; j++){ var userState = users[j].state; if(userState == "1"){ html += ""; html += users[j].userId.username; } else { lzCount ++; } // else { // html += ""; // html += users[j].userId.username; // html += "(该用户已离职) "; // } } if(users.length == lzCount){ html += "下一环节操作人无人在职!"; } } html += ""; table.append(html); } } else { var table= $("#nextTacheInfoTd"); table.html(""); var html = ""; html += "" + resultInfo + ""; html += ""; table.append(html); } //nextTacheDialog.hide(); $("#validateTip").hide(); nextTacheInfoDialog.show(); }, error : function() { alert("数据处理失败,请检查网络重新登录或联系管理员!"); $("button").removeAttr("disabled"); }, beforeSend : function() { //$("button").attr("disabled", "disabled"); } }); } function saveFlow() { $("#sbmbtn").attr("disabled", "disabled"); $("#task").val("start"); var x = $("#insForm").serializeArray(); $.each(x, function(i, field) { field.value = encodeURI(field.value); }); var tmodelIds = $("[name*='tmodelId_']"); for(var i = 0; i < tmodelIds.length; i++){ var bool = false; var isCheck = $("#isCheck_" + tmodelIds[i].value).val(); if(isCheck == '1'){ $("input[name='tmodel_" + tmodelIds[i].value + "']").each(function(){ if(this.checked){ bool = true; } }); if(!bool){ $("#validateTip").show(); $("#sbmbtn").removeAttr("disabled"); return false; } } } var result1 = false; $.ajax({ url : "FlowAction.do", async : false, type : "post", data : x, dataType : 'json', success : function(data) { var resultState = data[0].resultState; var resultInfo = data[0].resultInfo; if (!resultState){ addError(resultInfo); } else { addInfo("流程发起成功!"); result1 = true; } }, error : function() { alert("数据处理失败,请检查网络重新登录或联系管理员!"); $("button").removeAttr("disabled"); }, beforeSend : function() { //$("button").attr("disabled", "disabled"); } }); if(result1){ var closetype = $("#closetype").val(); var dialogId = $("#dialogId").val(); var parentDialogId = "ligerWindow_"+$("#parentDialogId").val(); if(closetype==1){ window.parent.frames['content'].frames[$("#tabid").val()].closeODialog(dialogId); } else if(closetype==2){ window.parent.frames[parentDialogId].closeODialog(dialogId); }else { var oldTabid = $("#tabid").val(); window.parent.f_reloadTab(oldTabid); window.parent.frames[oldTabid].closeODialog($("#dialogId").val()); } }else{ $("#sbmbtn").removeAttr("disabled"); } } //表单暂存 function tempformJs() { if(document.frames == undefined){ window.frames["formIns"].replaceTextarea(); } else { document.frames.formIns.replaceTextarea(); } $(window.frames["formIns"].document).find("#formIns").attr("action","bpmFormInstanceAction.do?task=tempInsForSave"); $(window.frames["formIns"].document).find("#formIns").submit(); nextTacheInfoDialog.hidden(); }