customStartFlow.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. function checkForm() {
  2. /*
  3. * var rs = $.validate({ name : "v_ins_name", model : [ { type : "require",
  4. * msg : "流程标题不能为空!", msgBox : "v_ins_name_box" }, { type : "len", min : 1,
  5. * max : 50, msg : "流程标题长度不能超过50个字!", msgBox : "v_ins_name_box" } ] });
  6. */
  7. // 同步标题输入框的值到隐藏字段,确保数据一致性
  8. if($("#insNameText").is(":visible")) {
  9. $("#insName").val($("#insNameText").val());
  10. }
  11. if($.trim($("#insName").val()) == ''){
  12. addError("流程标题不能为空!");
  13. window.scrollTo(0,0);
  14. return false;
  15. }
  16. if($.trim($("#insName").val()).length > 100){
  17. addError("流程标题不能超过100个字!");
  18. window.scrollTo(0,0);
  19. return false;
  20. }
  21. var rs = true;
  22. var reqOffice = $("#reqOffice").val();
  23. if(reqOffice == "1"){
  24. rs = checkOffice() && rs;
  25. }
  26. var pathJudgeType = $("#pathJudgeType").val();
  27. if (pathJudgeType == "1") {
  28. rs = $.validate({
  29. name : "nextTmodelId",
  30. model : [ {
  31. type : "require",
  32. msg : "下一步环节不能为空!"
  33. } ]
  34. });
  35. }
  36. var usersNames = $("[type='text'][id*='usersName']:visible");
  37. for ( var i = 0; i < usersNames.length; i++) {
  38. rs = $.validate({
  39. name : usersNames[i].id,
  40. model : [ {
  41. type : "require",
  42. msg : "下一步环节操作人不能为空!"
  43. } ]
  44. }) && rs;
  45. }
  46. if (rs) {
  47. return true;
  48. }
  49. return false;
  50. }
  51. function checkOffice(){
  52. var rs = true;
  53. rs = $.validate({
  54. name : "file_fileId",
  55. model : [ {
  56. type : "require",
  57. msg : "请上传附件!"
  58. }]
  59. });
  60. $("#file_fileId").focus();
  61. return rs;
  62. }
  63. function formJs() {
  64. if (formId == "0") { //没有表单
  65. var rs = checkForm();
  66. $("#formInsId").val("0");
  67. if (rs) {
  68. //$('.bsubmit').attr("disabled", "disabled");
  69. preProcess("FlowAction.do", "#insForm");
  70. }
  71. } else {//有表单
  72. var rs = true;
  73. rs = checkForm() && rs;
  74. if (rs) {
  75. var hasGen = $(window.frames["formIns"].document).find(
  76. "#hasGen").val();//查找是否启用软航印章
  77. $('.bsubmit').attr("disabled", "disabled");
  78. if(document.frames == undefined){
  79. window.frames["formIns"].replaceTextarea();
  80. } else {
  81. document.frames.formIns.replaceTextarea();
  82. }
  83. // if (hasGen == 0) { //无软航印章文件直接提交表单
  84. // $(window.frames["formIns"].document).find("#formIns").submit();
  85. // } else {//有软航印章文件调用js方法提交
  86. if(document.frames == undefined){
  87. window.frames["formIns"].save();
  88. } else {
  89. document.frames.formIns.save();
  90. }
  91. // }
  92. }
  93. }
  94. }
  95. /**
  96. * 修改流程标题
  97. */
  98. function changeInsName() {
  99. $("#insNameText").show();
  100. $("#insNameEnter").show();
  101. $("#insNameEdit").hide();
  102. $("#insNameFont").hide();
  103. }
  104. /**
  105. * 确认标题修改
  106. */
  107. function confirmInsName() {
  108. if($.trim($("#insNameText").val()) == ''){
  109. addError("流程标题不能为空!");
  110. return;
  111. }
  112. if($.trim($("#insNameText").val()).length > 100){
  113. addError("流程标题不能超过100个字!");
  114. return;
  115. }
  116. $("#insNameText").hide();
  117. $("#insNameEnter").hide();
  118. $("#insNameEdit").show();
  119. $("#insNameFont").show();
  120. $("#insNameFont").text($("#insNameText").val());
  121. $("#insName").val($("#insNameText").val());
  122. }
  123. var officeDialog = null;
  124. var nextTacheDialog = null;
  125. var nextTacheInfoDialog = null;
  126. var pdfDialog = null;
  127. function ow(owurl, name) {
  128. officeDialog = openTopDialog({
  129. height : 700,
  130. width : 1000,
  131. url : owurl,
  132. showMax : false,
  133. showToggle : false,
  134. showMin : false,
  135. isResize : false,
  136. modal : true,
  137. title : name,
  138. allowClose : true
  139. });
  140. }
  141. function pw(owurl, name) {
  142. pdfDialog = openTopDialog({
  143. height : 700,
  144. width : 1000,
  145. url : owurl,
  146. showMax : false,
  147. showToggle : false,
  148. showMin : false,
  149. isResize : false,
  150. modal : true,
  151. title : name,
  152. allowClose : true
  153. });
  154. }
  155. function closeOfficeDialog() {
  156. officeDialog.close();
  157. }
  158. function openOffice() {
  159. var officeId = $("#officeId").val();
  160. var limitViewOffice = $("#limitViewOffice").val();
  161. // var pdfId = $("#pdfId").val();
  162. // ow('${pageContext.request.contextPath}/NtkoAction.do?task=edit&fileId='
  163. // + officeId + '&limitViewOffice='+limitViewOffice+'&pdfId='+pdfId, '公文编辑');
  164. if(limitViewOffice == "1") {
  165. window.showModalDialog('${pageContext.request.contextPath}/NtkoAction.do?task=info&fileId='
  166. + officeId, window, "dialogWidth=1000px;dialogHeight=700px;resizable=no;scroll=no;status=no;");
  167. } else {
  168. window.showModalDialog('${pageContext.request.contextPath}/NtkoAction.do?task=edit&fileId='
  169. + officeId, window, "dialogWidth=1000px;dialogHeight=700px;resizable=no;scroll=no;status=no;");
  170. }
  171. }
  172. function setValue(fileId, fileName) {
  173. $("#officeId").val(fileId);
  174. $("#officeName").val(fileName);
  175. //alert($(window.frames["formIns"].document).find("#doc_id"));//.val(fileId);
  176. window.frames["formIns"].setValue(fileId, fileName);
  177. //$("#editOffice").show();
  178. //$("#createOffice").hide();
  179. //$("#editOffice").show();
  180. }
  181. function openPdf() {
  182. var officeId = $("#officeId").val();
  183. var pdfId = $("#pdfId").val();
  184. //var limitViewOffice = $("#limitViewOffice").val();
  185. if(pdfId == ""){
  186. pw('${pageContext.request.contextPath}/NtkoAction.do?task=openPdf&isNew=1&fileId='
  187. + officeId, '公文查看');
  188. }else{
  189. pw('${pageContext.request.contextPath}/NtkoAction.do?task=openPdf&isNew=0&fileId='
  190. + pdfId, '公文查看');
  191. }
  192. }
  193. function setPdfValue(fileId) {
  194. $("#pdfId").val(fileId);
  195. $("#limitViewOffice").val("1");
  196. $("#editPdf").show();
  197. }
  198. function setNtkoPdfValue(fileId) {
  199. $("#pdfId").val(fileId);
  200. $("#editPdf").show();
  201. }
  202. function closePdfDialog() {
  203. pdfDialog.close();
  204. }
  205. /**
  206. * 点击"提交"展示"选择下一环节信息"
  207. */
  208. function chooseNextTache(buttonName) {
  209. if(!confirm("确认" + buttonName + "该流程?")){
  210. return;
  211. }
  212. var rs = true;
  213. var reqRemark = $("#reqRemark").val();
  214. if (reqRemark == "1") {
  215. rs = $.validate({
  216. name : "remark",
  217. model : [ {
  218. type : "require",
  219. msg : "流程内容不能为空!"
  220. },{
  221. type : "len",
  222. min : 0,
  223. max : 1000,
  224. msg : "流程内容长度不能超过1000个字!"
  225. } ]
  226. });
  227. }else{
  228. rs = $.validate({
  229. name : "remark",
  230. model : [ {
  231. type : "len",
  232. min : 0,
  233. max : 1000,
  234. msg : "流程内容长度不能超过1000个字!"
  235. } ]
  236. });
  237. }
  238. //判断公文是否编辑,未完成
  239. if (hasOffice == "1") {
  240. var reqEditOffice = $("#reqEditOffice").val();
  241. if(reqEditOffice == "1"){
  242. rs = $.validate({
  243. name : "officeId",
  244. model : [ {
  245. type : "require",
  246. msg : "公文未编辑!"
  247. }]
  248. }) && rs;
  249. }
  250. }
  251. if (formId != "0") {//判断流程是否有表单,有表单则进行表单验证
  252. if(document.frames == undefined){
  253. rs = window.frames["formIns"].checkForm() && rs;
  254. } else {
  255. rs = document.frames.formIns.checkForm() && rs;
  256. }
  257. }
  258. if (!rs) {
  259. return;
  260. }
  261. window.scrollTo(0,0);
  262. //nextTacheDialog.show();
  263. formJs();
  264. }
  265. /**
  266. * 关闭"选择下一环节信息"对话框
  267. */
  268. function closeNextTache() {
  269. nextTacheDialog.hidden();
  270. }
  271. function closeNextTacheInfo() {
  272. nextTacheInfoDialog.hidden();
  273. }
  274. /**
  275. * 初始化"选择下一环节信息"对话框
  276. */
  277. $(function() {
  278. nextTacheInfoDialog = $.ligerDialog.open({
  279. width : 800,
  280. target : $("#nextTacheInfo"),
  281. showMax : false,
  282. showToggle : false,
  283. showMin : false,
  284. show : false,
  285. isResize : false,
  286. modal : true,
  287. title : "后续环节人员查看及选择",
  288. allowClose : true,
  289. containerId : 'insForm'
  290. });
  291. nextTacheInfoDialog.hidden();
  292. });
  293. function preProcess(actionUrl, formName) {
  294. $("#task").val("preProcess");
  295. var x = $(formName).serializeArray();
  296. $.each(x, function(i, field) {
  297. field.value = encodeURI(field.value);
  298. });
  299. $.ajax({
  300. url : actionUrl,
  301. async : true,
  302. type : "post",
  303. data : x,
  304. dataType : 'json',
  305. success : function(data) {
  306. // alert(data);
  307. // addInfo(data);
  308. // var oldTabid = $("#tabid").val();
  309. // window.parent.f_reloadTab(oldTabid);
  310. // window.parent.frames[oldTabid].closeODialog($("#dialogId").val());
  311. // alert(data[0].nextTacheInstances);
  312. var resultState = data[0].resultState;
  313. var submitState = data[0].submitState;
  314. var resultInfo = data[0].resultInfo;
  315. if(!submitState){
  316. $("#sbmbtn").hide();
  317. $("#clsbtn").show();
  318. } else {
  319. $("#sbmbtn").show();
  320. $("#clsbtn").hide();
  321. }
  322. document.body.scrollIntoView();//滚动到页面顶部
  323. if(resultState){
  324. var table= $("#nextTacheInfoTd");
  325. table.html("");
  326. var nextTacheInstances = data[0].nextTacheInstances;
  327. for(var i = 0 ; i < nextTacheInstances.length; i++){
  328. var users = nextTacheInstances[i].users;
  329. var info = nextTacheInstances[i].info;
  330. var isCheck = nextTacheInstances[i].isCheck;
  331. var tacheModel = nextTacheInstances[i].tacheModel;
  332. var html = "<tr><td>";
  333. html += "<input type='hidden' id='tmodelId_" +
  334. tacheModel.tmodelId + "' name='tmodelId_" +
  335. tacheModel.tmodelId + "' value='" + tacheModel.tmodelId + "'>";
  336. html += tacheModel.tmodelName;
  337. html += "</td><td>";
  338. if(isCheck){
  339. html += "<input type='hidden' id='isCheck_" + tacheModel.tmodelId
  340. + "' name='isCheck_" + tacheModel.tmodelId + "' value='1'>";
  341. } else {
  342. html += "<input type='hidden' id='isCheck_" + tacheModel.tmodelId
  343. + "' name='isCheck_" + tacheModel.tmodelId + "' value='0'>";
  344. }
  345. if(info != "" && info != null && info != undefined){
  346. html += "<span style='color:red'>" + info + "</span>";
  347. } else {
  348. var lzCount = 0;
  349. for(var j = 0 ; j < users.length; j++){
  350. var userState = users[j].state;
  351. if(userState == "1"){
  352. html += "<input type='checkbox' id='tmodel_" +
  353. tacheModel.tmodelId + "' name='tmodel_" + tacheModel.tmodelId +
  354. "' value='" + users[j].id + "' checked='checked'>";
  355. html += users[j].userId.username;
  356. } else {
  357. lzCount ++;
  358. }
  359. // else {
  360. // html += "<input type='checkbox' id='tmodel_" +
  361. // tacheModel.tmodelId + "' name='tmodel_" + tacheModel.tmodelId +
  362. // "' value='" + users[j].id + "' readonly='readonly'>";
  363. // html += users[j].userId.username;
  364. // html += "(该用户已离职)&nbsp;";
  365. // }
  366. }
  367. if(users.length == lzCount){
  368. html += "<span style='color:red'>下一环节操作人无人在职!</span>";
  369. }
  370. }
  371. html += "</td></tr>";
  372. table.append(html);
  373. }
  374. } else {
  375. var table= $("#nextTacheInfoTd");
  376. table.html("");
  377. var html = "<td style='text-align: center;' colspan='2'>";
  378. html += "<span style='color: red;'>" + resultInfo + "</span>";
  379. html += "</td>";
  380. table.append(html);
  381. }
  382. //nextTacheDialog.hide();
  383. $("#validateTip").hide();
  384. nextTacheInfoDialog.show();
  385. },
  386. error : function() {
  387. alert("数据处理失败,请检查网络重新登录或联系管理员!");
  388. $("button").removeAttr("disabled");
  389. },
  390. beforeSend : function() {
  391. //$("button").attr("disabled", "disabled");
  392. }
  393. });
  394. }
  395. function saveFlow() {
  396. $("#sbmbtn").attr("disabled", "disabled");
  397. $("#task").val("start");
  398. var x = $("#insForm").serializeArray();
  399. $.each(x, function(i, field) {
  400. field.value = encodeURI(field.value);
  401. });
  402. var tmodelIds = $("[name*='tmodelId_']");
  403. for(var i = 0; i < tmodelIds.length; i++){
  404. var bool = false;
  405. var isCheck = $("#isCheck_" + tmodelIds[i].value).val();
  406. if(isCheck == '1'){
  407. $("input[name='tmodel_" + tmodelIds[i].value + "']").each(function(){
  408. if(this.checked){
  409. bool = true;
  410. }
  411. });
  412. if(!bool){
  413. $("#validateTip").show();
  414. $("#sbmbtn").removeAttr("disabled");
  415. return false;
  416. }
  417. }
  418. }
  419. var result1 = false;
  420. $.ajax({
  421. url : "FlowAction.do",
  422. async : false,
  423. type : "post",
  424. data : x,
  425. dataType : 'json',
  426. success : function(data) {
  427. var resultState = data[0].resultState;
  428. var resultInfo = data[0].resultInfo;
  429. if (!resultState){
  430. addError(resultInfo);
  431. } else {
  432. addInfo("流程发起成功!");
  433. result1 = true;
  434. }
  435. },
  436. error : function() {
  437. alert("数据处理失败,请检查网络重新登录或联系管理员!");
  438. $("button").removeAttr("disabled");
  439. },
  440. beforeSend : function() {
  441. //$("button").attr("disabled", "disabled");
  442. }
  443. });
  444. if(result1){
  445. /*
  446. var oldTabid = $("#tabid").val();
  447. window.parent.f_reloadTab(oldTabid);
  448. window.parent.frames[oldTabid].closeODialog($("#dialogId").val());*/
  449. /*var closetype = $("#closetype").val();
  450. var dialogId = $("#dialogId").val();
  451. var parentDialogId = "ligerWindow_"+$("#parentDialogId").val();
  452. if(closetype==1){
  453. window.parent.frames['content'].frames[$("#tabid").val()].closeODialog(dialogId);
  454. } else if(closetype==2){
  455. window.parent.frames[parentDialogId].closeODialog(dialogId);
  456. }else {
  457. var oldTabid = $("#tabid").val();
  458. window.parent.f_reloadTab(oldTabid);
  459. window.parent.frames[oldTabid].closeODialog($("#dialogId").val());
  460. }*/
  461. closeSelf()
  462. }else{
  463. $("#sbmbtn").removeAttr("disabled");
  464. }
  465. }
  466. //表单暂存
  467. function tempformJs() {
  468. if(document.frames == undefined){
  469. window.frames["formIns"].replaceTextarea();
  470. } else {
  471. document.frames.formIns.replaceTextarea();
  472. }
  473. $(window.frames["formIns"].document).find("#formIns").attr("action","bpmFormInstanceAction.do?task=tempInsForSave");
  474. $(window.frames["formIns"].document).find("#formIns").submit();
  475. nextTacheInfoDialog.hidden();
  476. }
  477. //保存草稿
  478. function saveDraft() {
  479. if(document.frames == undefined){
  480. window.frames["formIns"].replaceTextarea();
  481. } else {
  482. document.frames.formIns.replaceTextarea();
  483. }
  484. if(document.frames == undefined){
  485. window.frames["formIns"].draftsave();
  486. } else {
  487. document.frames.formIns.draftsave();
  488. }
  489. }