| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430 |
- 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 = "<tr><td>";
- html += "<input type='hidden' id='tmodelId_" +
- tacheModel.tmodelId + "' name='tmodelId_" +
- tacheModel.tmodelId + "' value='" + tacheModel.tmodelId + "'>";
- html += tacheModel.tmodelName;
- html += "</td><td>";
- if(isCheck){
- html += "<input type='hidden' id='isCheck_" + tacheModel.tmodelId
- + "' name='isCheck_" + tacheModel.tmodelId + "' value='1'>";
- } else {
- html += "<input type='hidden' id='isCheck_" + tacheModel.tmodelId
- + "' name='isCheck_" + tacheModel.tmodelId + "' value='0'>";
- }
- if(info != "" && info != null && info != undefined){
- html += "<span style='color:red'>" + info + "</span>";
- } else {
- var lzCount = 0;
- for(var j = 0 ; j < users.length; j++){
- var userState = users[j].state;
- if(userState == "1"){
- html += "<input type='checkbox' id='tmodel_" +
- tacheModel.tmodelId + "' name='tmodel_" + tacheModel.tmodelId +
- "' value='" + users[j].id + "' checked='checked'>";
- html += users[j].userId.username;
- } else {
- lzCount ++;
- }
- // else {
- // html += "<input type='checkbox' id='tmodel_" +
- // tacheModel.tmodelId + "' name='tmodel_" + tacheModel.tmodelId +
- // "' value='" + users[j].id + "' readonly='readonly'>";
- // html += users[j].userId.username;
- // html += "(该用户已离职) ";
- // }
- }
- if(users.length == lzCount){
- html += "<span style='color:red'>下一环节操作人无人在职!</span>";
- }
- }
- html += "</td></tr>";
- table.append(html);
- }
- } else {
- var table= $("#nextTacheInfoTd");
- table.html("");
- var html = "<td style='text-align: center;' colspan='2'>";
- html += "<span style='color: red;'>" + resultInfo + "</span>";
- html += "</td>";
- 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();
- }
|