customStartFlow.js 13 KB

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