forward.js 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  1. 'use strict';
  2. var app = angular.module('app', []);
  3. app.controller("forwardCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
  4. var self = this;
  5. var s4 = new SM4Util();
  6. self.userId = $.cookie("GlWorkPlatform-userid");
  7. self.userName = $.cookie("GlWorkPlatform-chineseName");
  8. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  9. self.routeid = sp.getUrlName("routeid");
  10. self.routeinfoid = sp.getUrlName("routeinfoid");
  11. self.copyrightid = sp.getUrlName("copyrightid");
  12. self.directionid = sp.getUrlName("directionid");
  13. self.formeditid = sp.getUrlName("formeditid");
  14. self.directionFlag = false;
  15. self.directionList1 = [];
  16. self.setZDY = false;
  17. var postCfg = {
  18. headers: {
  19. 'Content-Type': 'application/json',
  20. 'Authorization': "Bearer " + self.get_AccessToken
  21. }
  22. };
  23. self.getDirectionFlag = function () {
  24. var data = {
  25. copyrightid: self.copyrightid
  26. }
  27. $http.post(apiurljs.login + "g2work/abase/queryFormeditSignByCopyrightid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  28. .success(function (obj) {
  29. var res = strToJson(s4.decryptData_CBC(obj.data));
  30. if (res.data.length > 0) {
  31. self.directionList1 = res.data;
  32. }
  33. var data1 = {
  34. directionid: self.directionid
  35. }
  36. $http.post(apiurljs.login + "g2work/flowdirection/queryData", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg)
  37. .success(function (obj1) {
  38. var res1 = strToJson(s4.decryptData_CBC(obj1.data));
  39. self.directionFlag = res1.data.TOINFOSTATUS != "START" && self.directionList1.length > 0;
  40. })
  41. self.forward()
  42. })
  43. }
  44. self.getDirectionFlag()
  45. //转发
  46. self.forward = function () {
  47. self.activeGroup = "部门";
  48. self.searchName = "";
  49. self.searchRole = "";
  50. self.saveZB = false;
  51. self.jiaqian = false;
  52. self.opinionYY = false;
  53. var data = {
  54. codefuncbutton: sp.getUrlName("codefuncbutton"),
  55. directionid: self.directionid,
  56. directionidtarget: sp.getUrlName("directionidtarget"),
  57. userid: self.userId,
  58. routeinfoid: self.routeinfoid,
  59. routeid: self.routeid
  60. }
  61. $http.post(apiurljs.login + "g2app/abase/queryDataSendByTarget", {
  62. data: s4.encryptData_CBC(JSON.stringify(data))
  63. }, postCfg)
  64. .success(function (obj) {
  65. var res = strToJson(s4.decryptData_CBC(obj.data));
  66. self.showContent = true;
  67. self.directions = res.data; //所有可选流向
  68. self.direction = self.directions[0]; //所选流向
  69. if (self.direction.SENDERRORS && self.direction.SENDERRORS.MESSAGE != "") {
  70. self.showContent = false;
  71. if (self.direction.CODEFUNCBUTTON == "SENDCOMMIT" && self.direction.SENDERRORS.ERRORLIST.length == 2 && self.direction.SENDERRORS.ERRORLIST[1].TABLEID != "" && self.direction.SENDERRORS.ERRORLIST[1].COLID != "") {
  72. window.parent.document.getElementById("forwardWin").style.height = "100px";
  73. self.opinionYY = true;
  74. $("#forward").show();
  75. } else {
  76. self.direction.CODEFUNCTITLE = self.direction.SENDERRORS.MESSAGE;
  77. window.parent.document.getElementById("forwardWin").style.height = "100px";
  78. window.parent.sp.setCenter("#forward")
  79. self.forward1(0)
  80. return
  81. }
  82. }else if (self.direction.ENDNODETYPE == 1 || self.direction.CODEFUNCBUTTON == "SENDCOPYEND" || self.direction.CODEFUNCBUTTON == "SENDPERUSAL" || self.direction.CODEFUNCBUTTON == "SENDCOMMIT") {
  83. self.showContent = false;
  84. self.direction.CODEFUNCTITLE = self.direction.CODEFUNCTITLE;
  85. self.direction.CODEMARK = self.direction.CODEMARK;
  86. window.parent.document.getElementById("forwardWin").style.height = "100px";
  87. window.parent.sp.setCenter("#forward")
  88. self.forward1(0)
  89. } else if (self.direction.ENDNODETYPE == 3) {
  90. self.showContent = true;
  91. self.forwardUser = [];
  92. self.directionList = self.direction["DIRECTION.CHILD"];
  93. $.each(self.directionList, function (index, item) {
  94. item.forwardUser = index;
  95. self.forwardUser.push([])
  96. item.people1 = item.SENDUSERS.USERS.USERS; //人员
  97. item.people1.forEach(function (item) {
  98. item.show = item.USERS.length > 0;
  99. item.childshow = false;
  100. item.USERS.forEach(function (item1) {
  101. item1.show = true;
  102. })
  103. })
  104. item.people2 = item.SENDUSERS.USERSALL.USERS; //人员
  105. item.people2.forEach(function (item) {
  106. item.show = true;
  107. item.childshow = false;
  108. item.USERS.forEach(function (item1) {
  109. item1.show = true;
  110. })
  111. })
  112. item.people = JSON.parse(JSON.stringify(item.people1));
  113. })
  114. self.activeDirection = self.directionList[0]
  115. self.roleList = self.activeDirection.SENDUSERS.USERS.ROLES;
  116. //if (self.directionid == "Flow_1rc0ejj_e4096a15-696a-4924-bfc1-50602b70dd1f") {
  117. //非收文并发节点,默认勾选人员
  118. if (Concurrency(self.directionList) == true && sp.getUrlName("cookie") != "shouwenbg" && sp.getUrlName("cookie") != "PH") {
  119. var n = [], x = 0;
  120. self.directionList.forEach(function (item, index) {
  121. n.push(0)
  122. item.people1.forEach(function (item1, index1) {
  123. n[index] = n[index] + item1.USERS.length;
  124. })
  125. })
  126. n.forEach(function (item) {
  127. if (item > 1) {
  128. x = x + 1;
  129. }
  130. })
  131. if (x == 0) { //如果推荐人员唯一时,缺省直接赋值转发,可以重新选择
  132. self.showContent = false;
  133. var usernameStr = [];
  134. self.directionList.forEach(function (item, index) {
  135. item.people1.forEach(function (item1, index1) {
  136. if (item1.USERS.length == 1) {
  137. usernameStr.push(item1.USERS[0].USERNAME)
  138. self.forwardUser[index].push(item1.USERS[0]);
  139. }
  140. })
  141. })
  142. self.forwardUser.forEach(function (x, y) {
  143. x[0].type = 1;
  144. })
  145. self.direction.CODEFUNCTITLE = "确认后将转发【" + usernameStr.join(",") + "】";
  146. window.parent.document.getElementById("forwardWin").style.height = "110px";
  147. window.parent.sp.setCenter("#forward")
  148. self.forward1(0)
  149. } else {
  150. self.showContent = true;
  151. window.parent.document.getElementById("forwardWin").style.height = "740px";
  152. window.parent.sp.setCenter("#forward")
  153. self.forward1(0)
  154. }
  155. } else {
  156. window.parent.document.getElementById("forwardWin").style.height = "740px";
  157. window.parent.sp.setCenter("#forward")
  158. self.forward1(0)
  159. }
  160. } else {
  161. self.forwardUser = [];
  162. self.directionList = [];
  163. self.directionList.push(self.direction)
  164. $.each(self.directionList, function (index, item) {
  165. item.forwardUser = index;
  166. self.forwardUser.push([])
  167. item.people1 = item.SENDUSERS.USERS.USERS; //人员
  168. item.people1.forEach(function (item) {
  169. item.show = item.USERS.length > 0;
  170. item.childshow = false;
  171. item.USERS.forEach(function (item1) {
  172. item1.show = true;
  173. })
  174. })
  175. item.people2 = item.SENDUSERS.USERSALL.USERS; //人员
  176. item.people2.forEach(function (item) {
  177. item.show = true;
  178. item.childshow = false;
  179. item.USERS.forEach(function (item1) {
  180. item1.show = true;
  181. })
  182. })
  183. item.people = JSON.parse(JSON.stringify(item.people1));
  184. })
  185. self.activeDirection = self.directionList[0]
  186. self.roleList = self.direction.SENDUSERS.USERS.ROLES;
  187. var n = 0;
  188. self.directionList[0].people1.forEach(function (item) {
  189. n = n + item.USERS.length;
  190. })
  191. if (n == 1) { //如果推荐人员唯一时,缺省直接赋值转发,可以重新选择
  192. self.showContent = false;
  193. self.adduserAll(2);
  194. var usernameStr = "";
  195. self.directionList[0].people1.forEach(function (item) {
  196. if (item.USERS.length == 1) {
  197. usernameStr = item.USERS[0].USERNAME
  198. }
  199. })
  200. //var usernameStr = self.direction.SENDUSERS.USERS.USERS[0].USERS[0].USERNAME;
  201. self.direction.CODEFUNCTITLE = "确认后将转发【" + usernameStr + "】";
  202. window.parent.document.getElementById("forwardWin").style.height = "110px";
  203. window.parent.sp.setCenter("#forward")
  204. self.forward1(0)
  205. } else {
  206. self.showContent = true;
  207. window.parent.document.getElementById("forwardWin").style.height = "740px";
  208. window.parent.sp.setCenter("#forward")
  209. self.forward1(0)
  210. }
  211. }
  212. })
  213. }
  214. self.resetup = function () {
  215. self.showContent = true;
  216. window.parent.document.getElementById("forwardWin").style.height = "740px";
  217. window.parent.sp.setCenter("#forward")
  218. }
  219. //转发(新)
  220. self.forward1 = function (n) {
  221. if (n == 0) {
  222. $("#forward").show();
  223. } else {
  224. if (self.activeGroup == "部门") {
  225. if (self.jiaqian == true) {
  226. //self.directionList = self.direction["DIRECTION.CHILD"];
  227. $.each(self.directionList, function (index, item) {
  228. item.people2.forEach(function (item) {
  229. item.show = true;
  230. item.childshow = false;
  231. item.USERS.forEach(function (item1) {
  232. item1.show = true;
  233. self.forwardUser[self.activeDirection
  234. .forwardUser].forEach(function (item2) {
  235. if (item1.USERID == item2.USERID) {
  236. item1.show = false;
  237. }
  238. })
  239. })
  240. })
  241. item.people = JSON.parse(JSON.stringify(item.people2));
  242. })
  243. self.roleList = self.activeDirection.SENDUSERS.USERSALL.ROLES;
  244. } else {
  245. //self.directionList = self.direction["DIRECTION.CHILD"];
  246. $.each(self.directionList, function (index, item) {
  247. item.people1.forEach(function (item) {
  248. item.show = true;
  249. item.childshow = false;
  250. item.USERS.forEach(function (item1) {
  251. item1.show = true;
  252. self.forwardUser[self.activeDirection
  253. .forwardUser].forEach(function (item2) {
  254. if (item1.USERID == item2.USERID) {
  255. item1.show = false;
  256. }
  257. })
  258. })
  259. })
  260. item.people = JSON.parse(JSON.stringify(item.people1));
  261. })
  262. self.roleList = self.activeDirection.SENDUSERS.USERS.ROLES;
  263. }
  264. } else if (self.activeGroup == "自定义分组") {
  265. self.getZbList(2)
  266. } else if (self.activeGroup == "常用分组") {
  267. self.getZbList2(2)
  268. }
  269. }
  270. if (self.direction.ENDNODETYPE != 1 && self.direction.CODEFUNCBUTTON != "SENDCOPYEND" && self.direction.CODEFUNCBUTTON != "SENDPERUSAL" && self.direction.CODEFUNCBUTTON != "SENDCOMMIT") {
  271. self.itemShow()
  272. self.activeUser = null;
  273. self.moveFlag1 = false;
  274. self.moveFlag2 = false;
  275. }
  276. }
  277. //网关切换流向
  278. self.changeType = function (n) {
  279. self.type = n;
  280. self.activeDirection = self.directionList[n];
  281. if (self.activeDirection.jiaqian == true) {
  282. self.activeGroup = '常用分组'
  283. } else {
  284. self.activeGroup = '部门'
  285. }
  286. self.forward1(1)
  287. }
  288. //流程加签
  289. self.addDirection = function (obj) {
  290. var n = 0;
  291. self.directionList.forEach(function (item) {
  292. if (item.CNAME == obj.CNAME) {
  293. n = n + 1;
  294. }
  295. })
  296. if (n == 0) {
  297. self.directionList.push({
  298. forwardUser: self.directionList.length,
  299. CNAME: "加签:" + obj.CNAME,
  300. DIRECTIONID: obj.FORMEDITID,
  301. jiaqian: true,
  302. people: [],
  303. people1: [],
  304. people2: [],
  305. })
  306. self.forwardUser.push([])
  307. self.changeType(self.directionList.length - 1)
  308. }
  309. }
  310. //加签流程移除
  311. self.delDirection = function (n) {
  312. self.changeType(n - 1);
  313. self.directionList.splice(n, 1)
  314. self.forwardUser.splice(n, 1)
  315. }
  316. self.jiaqianCheck = function () {
  317. if (self.jiaqian == true) {
  318. $.each(self.directionList, function (index, item) {
  319. item.people = JSON.parse(JSON.stringify(item.people2));
  320. })
  321. self.roleList = self.activeDirection.SENDUSERS.USERSALL.ROLES;
  322. } else {
  323. $.each(self.directionList, function (index, item) {
  324. item.people = JSON.parse(JSON.stringify(item.people1));
  325. })
  326. self.roleList = self.activeDirection.SENDUSERS.USERS.ROLES;
  327. }
  328. }
  329. //n==1全选;n==2全清;n==3反选
  330. self.ForwardCheck = function (n) {
  331. if (n == 1) {
  332. self.activeDirection.people.forEach(function (item) {
  333. item.USERS.forEach(function (item1) {
  334. item1.checked = true;
  335. })
  336. })
  337. } else if (n == 2) {
  338. self.activeDirection.people.forEach(function (item) {
  339. item.USERS.forEach(function (item1) {
  340. item1.checked = false;
  341. })
  342. })
  343. } else if (n == 3) {
  344. self.activeDirection.people.forEach(function (item) {
  345. item.USERS.forEach(function (item1) {
  346. item1.checked = !item1.checked;;
  347. })
  348. })
  349. }
  350. }
  351. self.searchPerson = function () {
  352. self.activeDirection.people.forEach(function (item) {
  353. item.show = false;
  354. var n = 0;
  355. item.USERS.forEach(function (item1) {
  356. item1.show = false;
  357. if (self.activeGroup == "部门") {
  358. if (item1.ROLECODE.indexOf(self.searchRole) > -1 && item1.USERNAME.indexOf(self.searchName) > -1) {
  359. item1.show = true;
  360. n++
  361. self.forwardUser.forEach(function (item2) {
  362. if (item1.USERID == item2.USERID) {
  363. item1.show = false;
  364. }
  365. })
  366. } else {
  367. item1.show = false;
  368. }
  369. } else {
  370. if (item1.USERNAME.indexOf(self.searchName) > -1) {
  371. item1.show = true;
  372. n++
  373. self.forwardUser.forEach(function (item2) {
  374. if (item1.USERID == item2.USERID) {
  375. item1.show = false;
  376. }
  377. })
  378. } else {
  379. item1.show = false;
  380. }
  381. }
  382. })
  383. if (n > 0) {
  384. item.show = true;
  385. item.childshow = false;
  386. }
  387. })
  388. }
  389. self.searchPerson2 = function () {
  390. if (self.activeGroup == "自定义分组") {
  391. self.getZbMsList()
  392. } else {
  393. self.getZbMsList2()
  394. }
  395. }
  396. self.chekcDP = function (obj) {
  397. obj.USERS.forEach(function (item) {
  398. item.checked = !item.checked;
  399. })
  400. self.adduser()
  401. }
  402. self.checkAddUser = function (obj) {
  403. obj.checked = true;
  404. self.activeDirection.people.forEach(function (item, index) {
  405. item.USERS.forEach(function (item1, index1) {
  406. var useridhas = false;
  407. if (item1.checked == true && item1.show == true) {
  408. self.forwardUser[self.activeDirection.forwardUser].forEach(function (x) {
  409. if (x.USERID == item1.USERID) {
  410. useridhas = true;
  411. }
  412. })
  413. if (useridhas == false) {
  414. self.forwardUser[self.activeDirection.forwardUser].push(item1);
  415. }
  416. item1.checked = false;
  417. item1.show = false;
  418. }
  419. })
  420. })
  421. self.forwardUser[self.activeDirection.forwardUser].forEach(function (x, y) {
  422. x.type = y == 0 ? 1 : 2
  423. })
  424. self.getmoveFlag()
  425. if (self.forwardUser[self.activeDirection.forwardUser].length == 1) {
  426. self.moveFlag1 = false;
  427. self.moveFlag2 = false;
  428. return;
  429. }
  430. }
  431. self.adduser = function () {
  432. self.activeDirection.people.forEach(function (item, index) {
  433. item.USERS.forEach(function (item1, index1) {
  434. var useridhas = false;
  435. if (item1.checked == true && item1.show == true) {
  436. self.forwardUser[self.activeDirection.forwardUser].forEach(function (x) {
  437. if (x.USERID == item1.USERID) {
  438. useridhas = true;
  439. }
  440. })
  441. if (useridhas == false) {
  442. self.forwardUser[self.activeDirection.forwardUser].push(item1);
  443. }
  444. item1.checked = false;
  445. item1.show = false;
  446. }
  447. })
  448. })
  449. self.forwardUser[self.activeDirection.forwardUser].forEach(function (x, y) {
  450. x.type = y == 0 ? 1 : 2
  451. })
  452. self.getmoveFlag()
  453. if (self.forwardUser[self.activeDirection.forwardUser].length == 1) {
  454. self.moveFlag1 = false;
  455. self.moveFlag2 = false;
  456. return;
  457. }
  458. }
  459. self.deluser = function () {
  460. self.forwardUser[self.activeDirection.forwardUser].forEach(function (item) {
  461. if (item.checked == true) {
  462. item.checked = false;
  463. item.show = true;
  464. item.childshow = false;
  465. self.activeDirection.people.forEach(function (x) {
  466. x.USERS.forEach(function (y) {
  467. if (item.USERID == y.USERID) {
  468. y.checked = false;
  469. y.show = true;
  470. }
  471. })
  472. })
  473. }
  474. })
  475. self.forwardUser[self.activeDirection.forwardUser] = self.forwardUser[self.activeDirection.forwardUser].filter(function (item) {
  476. return item.show == false;
  477. })
  478. self.getmoveFlag()
  479. if (self.forwardUser[self.activeDirection.forwardUser].length == 1) {
  480. self.moveFlag1 = false;
  481. self.moveFlag2 = false;
  482. return;
  483. }
  484. }
  485. self.adduserAll = function () {
  486. self.activeDirection.people.forEach(function (item, index) {
  487. item.USERS.forEach(function (item1, index1) {
  488. var useridhas = false;
  489. if (item1.show == true) {
  490. self.forwardUser[self.activeDirection.forwardUser].forEach(function (x) {
  491. if (x.USERID == item1.USERID) {
  492. useridhas = true;
  493. }
  494. })
  495. if (useridhas == false) {
  496. self.forwardUser[self.activeDirection.forwardUser].push(item1);
  497. }
  498. item1.checked = false;
  499. item1.show = false;
  500. }
  501. })
  502. })
  503. self.forwardUser[self.activeDirection.forwardUser].forEach(function (x, y) {
  504. x.type = y == 0 ? 1 : 2
  505. })
  506. self.getmoveFlag()
  507. if (self.forwardUser[self.activeDirection.forwardUser].length == 1) {
  508. self.moveFlag1 = false;
  509. self.moveFlag2 = false;
  510. return;
  511. }
  512. }
  513. self.deluserAll = function () {
  514. self.forwardUser[self.activeDirection.forwardUser].forEach(function (item) {
  515. item.checked = false;
  516. item.show = true;
  517. item.childshow = false;
  518. self.activeDirection.people.forEach(function (x) {
  519. x.USERS.forEach(function (y) {
  520. if (item.USERID == y.USERID) {
  521. y.checked = false;
  522. y.show = true;
  523. }
  524. })
  525. })
  526. })
  527. self.forwardUser[self.activeDirection.forwardUser] = [];
  528. self.getmoveFlag()
  529. self.moveFlag1 = false;
  530. self.moveFlag2 = false;
  531. }
  532. self.checkForwardUser = function (n) {
  533. if (self.activeUser != n) {
  534. self.activeUser = n;
  535. } else {
  536. self.activeUser = null;
  537. }
  538. if (self.forwardUser.length == 1) {
  539. self.moveFlag1 = false;
  540. self.moveFlag2 = false;
  541. return;
  542. }
  543. if (self.activeUser == null) {
  544. self.moveFlag1 = false;
  545. self.moveFlag2 = false;
  546. } else {
  547. self.getmoveFlag()
  548. }
  549. }
  550. self.getmoveFlag = function () {
  551. if (self.activeUser == 0) {
  552. self.moveFlag1 = false;
  553. self.moveFlag2 = true;
  554. } else if (self.activeUser == self.forwardUser[self.activeDirection.forwardUser].length -
  555. 1) {
  556. self.moveFlag1 = true;
  557. self.moveFlag2 = false;
  558. } else {
  559. self.moveFlag1 = true;
  560. self.moveFlag2 = true;
  561. }
  562. self.itemShow()
  563. }
  564. self.itemShow = function () {
  565. if (self.direction.SENDERRORS.MESSAGE == "") {
  566. self.activeDirection.people.forEach(function (item) {
  567. item.show = false;
  568. if (item.USERS.USERS) {
  569. item.USERS.USERS.forEach(function (item1) {
  570. if (item1.show == true) {
  571. item.show = true
  572. //item.childshow = false;
  573. }
  574. })
  575. } else {
  576. item.USERS.forEach(function (item1) {
  577. if (item1.show == true) {
  578. item.show = true
  579. //item.childshow = false;
  580. }
  581. })
  582. }
  583. })
  584. }
  585. }
  586. self.moveUp = function () {
  587. var a = self.forwardUser[self.activeDirection.forwardUser][self.activeUser],
  588. b = self.forwardUser[self.activeDirection.forwardUser][self.activeUser - 1];
  589. self.forwardUser[self.activeDirection.forwardUser][self.activeUser] = b;
  590. self.forwardUser[self.activeDirection.forwardUser][self.activeUser - 1] = a;
  591. self.activeUser = self.activeUser - 1;
  592. self.getmoveFlag()
  593. }
  594. self.moveDown = function () {
  595. var a = self.forwardUser[self.activeDirection.forwardUser][self.activeUser],
  596. b = self.forwardUser[self.activeDirection.forwardUser][self.activeUser + 1];
  597. self.forwardUser[self.activeDirection.forwardUser][self.activeUser] = b;
  598. self.forwardUser[self.activeDirection.forwardUser][self.activeUser + 1] = a;
  599. self.activeUser = self.activeUser + 1;
  600. self.getmoveFlag(n)
  601. }
  602. self.getZbList = function () {
  603. var data = {
  604. userid: self.userId
  605. }
  606. $http.post(apiurljs.login + "g2app/usercustom/queryCustomDataList", {
  607. data: s4.encryptData_CBC(JSON.stringify(data))
  608. }, postCfg)
  609. .success(function (obj) {
  610. var res = strToJson(s4.decryptData_CBC(obj.data));
  611. self.zdyfzList = []
  612. if (res.data.length > 0) {
  613. for (let i = 0; i < res.data.length; i++) {
  614. self.zdyfzList.push({
  615. ZID: res.data[i].CODE,
  616. ZUM: res.data[i].CNAME
  617. })
  618. }
  619. self.searchRole = self.zdyfzList[self.zdyfzList.length-1].ZID
  620. self.getZbMsList()
  621. } else {
  622. self.activeDirection.people = [];
  623. }
  624. })
  625. }
  626. self.getZbList3 = function () {
  627. var data = {
  628. userid: self.userId
  629. }
  630. $http.post(apiurljs.login + "g2app/usercustom/queryCustomDataList", {
  631. data: s4.encryptData_CBC(JSON.stringify(data))
  632. }, postCfg)
  633. .success(function (obj) {
  634. var res = strToJson(s4.decryptData_CBC(obj.data));
  635. self.zdyfzList = []
  636. if (res.data.length > 0) {
  637. for (let i = 0; i < res.data.length; i++) {
  638. self.zdyfzList.push({
  639. ZID: res.data[i].CODE,
  640. ZUM: res.data[i].CNAME
  641. })
  642. }
  643. self.searchRole = self.zdyfzList[self.zdyfzList.length - 1].ZID
  644. self.getZbMsList()
  645. } else {
  646. self.activeDirection.people = [];
  647. }
  648. })
  649. }
  650. //常用分组
  651. self.getZbList2 = function () {
  652. var data = {
  653. userid: self.userId
  654. }
  655. $http.post(apiurljs.login + "g2app/usercustom/queryGeneralDataList", {
  656. data: s4.encryptData_CBC(JSON.stringify(data))
  657. }, postCfg)
  658. .success(function (obj) {
  659. var res = strToJson(s4.decryptData_CBC(obj.data));
  660. self.zdyfzList = []
  661. if (res.data.length > 0) {
  662. for (let i = 0; i < res.data.length; i++) {
  663. self.zdyfzList.push({
  664. ZID: res.data[i].CODE,
  665. ZUM: res.data[i].CNAME
  666. })
  667. }
  668. self.searchRole = self.zdyfzList[self.zdyfzList.length - 1].ZID
  669. self.getZbMsList2()
  670. } else {
  671. self.activeDirection.people = [];
  672. }
  673. })
  674. }
  675. self.getZbMsList = function () {
  676. var data = {
  677. userid: self.userId,
  678. code: self.searchRole
  679. }
  680. $http.post(apiurljs.login + "g2app/usercustom/queryCustomData", {
  681. data: s4.encryptData_CBC(JSON.stringify(data))
  682. }, postCfg)
  683. .success(function (obj) {
  684. var res = strToJson(s4.decryptData_CBC(obj.data));
  685. $.each(self.directionList, function (index, item) {
  686. item.people = res.data
  687. })
  688. self.activeDirection.people = self.directionList[0].people[0].USERS.USERS
  689. self.activeDirection.people.forEach(function (item) {
  690. var n = 0;
  691. item.USERS.forEach(function (item1) {
  692. item1.show = true;
  693. self.forwardUser[self.activeDirection.forwardUser]
  694. .forEach(function (obj) {
  695. if (obj.USERID == item1.USERID) {
  696. n = n + 1;
  697. item1.show = false;
  698. }
  699. })
  700. })
  701. item.show = item.USERS.length != n;
  702. item.childshow = false;
  703. })
  704. })
  705. }
  706. self.getZbMsList2 = function () {
  707. var data = {
  708. userid: self.userId,
  709. code: self.searchRole
  710. }
  711. $http.post(apiurljs.login + "g2app/usercustom/queryGeneralData", {
  712. data: s4.encryptData_CBC(JSON.stringify(data))
  713. }, postCfg)
  714. .success(function (obj) {
  715. var res = strToJson(s4.decryptData_CBC(obj.data));
  716. $.each(self.directionList, function (index, item) {
  717. item.people = res.data
  718. })
  719. self.activeDirection.people = self.directionList[0].people[0].USERS.USERS
  720. self.activeDirection.people.forEach(function (item) {
  721. var n = 0;
  722. item.USERS.forEach(function (item1) {
  723. item1.show = true;
  724. self.forwardUser[self.activeDirection.forwardUser]
  725. .forEach(function (obj) {
  726. if (obj.USERID == item1.USERID) {
  727. n = n + 1;
  728. item1.show = false;
  729. }
  730. })
  731. })
  732. item.show = item.USERS.length != n;
  733. item.childshow = false;
  734. })
  735. })
  736. }
  737. self.checkZB = function (item1) {
  738. self.zbCode = item1.CODE;
  739. self.activeDirection.people.forEach(function (item) {
  740. item.show = false;
  741. item.checked = false;
  742. item1.USERS.forEach(function (item2) {
  743. if (item.USERID == item2.USERID) {
  744. item.show = true;
  745. item.childshow = false;
  746. item.set = self.zbCode;
  747. }
  748. })
  749. })
  750. self.forwardUser[self.activeDirection.forwardUser].forEach(function (obj) {
  751. item1.USERS.forEach(function (item2) {
  752. if (obj.USERID == item2.USERID) {
  753. obj.show = false;
  754. obj.set = self.zbCode;
  755. }
  756. })
  757. })
  758. }
  759. self.delZB = function (item) {
  760. var data = {
  761. code: item.ZID,
  762. userid: self.userId
  763. }
  764. $http.post(apiurljs.login + "g2app/usercustom/delCustomData", {
  765. data: s4.encryptData_CBC(JSON.stringify(data))
  766. }, postCfg)
  767. .success(function (obj) {
  768. var res = strToJson(s4.decryptData_CBC(obj.data));
  769. if (res.success == true) {
  770. self.getZbList()
  771. }
  772. })
  773. }
  774. self.btnSaveZB = function () {
  775. if (self.forwardUser[self.activeDirection.forwardUser].length == 0) {
  776. return
  777. }
  778. var data = {
  779. userid: self.userId,
  780. cname: self.cnameZB,
  781. userids: JSON.stringify(self.forwardUser[self.activeDirection.forwardUser].map(
  782. function (item) {
  783. return {
  784. userid: item.USERID,
  785. username: item.USERNAME
  786. }
  787. }))
  788. }
  789. $http.post(apiurljs.login + "g2app/usercustom/saveCustomData", {
  790. data: s4.encryptData_CBC(JSON.stringify(data))
  791. }, postCfg)
  792. .success(function (obj) {
  793. var res = strToJson(s4.decryptData_CBC(obj.data));
  794. if (res.success == true) {
  795. self.searchName = "";
  796. self.searchRole = "";
  797. self.saveZB = false;
  798. self.activeGroup = '自定义分组'
  799. self.forwardUser[self.activeDirection.forwardUser] = []
  800. //self.getZbList3()
  801. self.getZbList()
  802. }
  803. })
  804. }
  805. self.sendFlag = false;
  806. self.sendAll = function () {
  807. self.sendFlag = true;
  808. if (self.direction.ENDNODETYPE == 1) {
  809. var sendUser = [{
  810. DIRECTIONID: self.direction.DIRECTIONID,
  811. MAINUSERID: "STOP",
  812. COPYUSERID: ""
  813. }]
  814. } else if (self.direction.CODEFUNCBUTTON == "SENDCOPYEND" || self.direction.CODEFUNCBUTTON ==
  815. "SENDPERUSAL" || self.direction.CODEFUNCBUTTON == "SENDCOMMIT") {
  816. var sendUser = [{
  817. DIRECTIONID: self.direction.DIRECTIONID,
  818. MAINUSERID: "",
  819. COPYUSERID: ""
  820. }]
  821. } else {
  822. var sendUser = [];
  823. var n = 0, text = [];
  824. self.directionList.forEach(function (item) {
  825. if (self.forwardUser[item.forwardUser].length > 0) {
  826. n++
  827. sendUser.push({
  828. DIRECTIONID: item.DIRECTIONID,
  829. MAINUSERID: self.forwardUser[item.forwardUser].filter(function (item1) {
  830. return item1.type == 1
  831. }).map(function (item1) {
  832. return item1.USERID
  833. }).join("|"),
  834. COPYUSERID: self.forwardUser[item.forwardUser].filter(function (item1) {
  835. return item1.type == 2
  836. }).map(function (item1) {
  837. return item1.USERID
  838. }).join("|")
  839. })
  840. } else {
  841. text.push(item.CNAME)
  842. }
  843. })
  844. //非收文并发节点,每条流向人员不许为空
  845. if (Concurrency(self.directionList) == true && sp.getUrlName("cookie") != "shouwenbg" && sp.getUrlName("cookie") != "PH") {
  846. if (text.length > 0) {
  847. window.top.sp.layerhide()
  848. window.top.sp.dialog(text.join(",") + "<br/>未选择人员,请选择人员!");
  849. self.sendFlag = false;
  850. return
  851. }
  852. } else {
  853. if (n == 0) {
  854. window.top.sp.layerhide()
  855. window.top.sp.dialog(text.join(",") + "<br/>未选择人员,请选择至少一项人员!");
  856. self.sendFlag = false;
  857. return
  858. }
  859. }
  860. }
  861. var data = {
  862. codefuncbutton: self.direction.CODEFUNCBUTTON,
  863. directionid: self.directionid,
  864. userid: self.userId,
  865. routeinfoid: self.routeinfoid,
  866. routeid: self.routeid,
  867. data: JSON.stringify(sendUser)
  868. }
  869. $http.post(apiurljs.login + "g2app/abase/saveDataSend", {
  870. data: s4.encryptData_CBC(JSON.stringify(data))
  871. }, postCfg)
  872. .success(function (obj) {
  873. var res = strToJson(s4.decryptData_CBC(obj.data));
  874. self.goFunc(sp.getUrlName("directionidtarget"))
  875. self.sendFlag = false;
  876. window.parent.sp.layerhide()
  877. var href = window.parent.location.href.slice(window.parent.location.href
  878. .indexOf("tpl")).split("/")
  879. if (res.success == true) {
  880. window.parent.sp.dialog("发送成功!");
  881. setTimeout(function () {
  882. if (localStorage.getItem("tjJxtGoldenlinkWork-deviceType") != "pad") {
  883. if (window.top.location.href.indexOf("/index.html") == -1) {
  884. window.top.close()
  885. localStorage.setItem('GlWorkPlatform-' + sp.getUrlName(
  886. "cookie") + '-refresh', 1)
  887. } else {
  888. window.parent.location.href = "../../" + href[0] + "/" +
  889. href[1] + "/list.html"
  890. }
  891. } else {
  892. window.parent.location.href = "../../" + href[0] + "/" +
  893. href[1] + "/list.html"
  894. }
  895. }, 2000)
  896. } else {
  897. window.top.sp.dialog(res.message)
  898. }
  899. })
  900. .error(function () {
  901. self.sendFlag = false;
  902. })
  903. }
  904. self.goFunc = function (str) {
  905. switch (str) {
  906. case "SequenceFlow_02bni32_c2c3da8e-be69-47f5-9e7e-522923444b67":
  907. self.GUIDANG();
  908. break;
  909. case "Flow_1q1jyh7_bbd06bd0-1ca2-409b-9f1e-35de93d46a27":
  910. self.SXDBYS();
  911. break;
  912. case "Flow_1k5r8tm_094430ce-e841-4a09-83f0-ccbb59f1cce1":
  913. self.GWDBYQ();
  914. break;
  915. case "Flow_1rbo1mh_094430ce-e841-4a09-83f0-ccbb59f1cce1":
  916. self.GWDBYQ();
  917. break;
  918. case "SequenceFlow_02bni32_af78f780-9140-42c4-81c5-34fd14fcf9b3":
  919. self.WJFBB();
  920. break;
  921. }
  922. }
  923. self.GUIDANG = function () {
  924. var data = {
  925. routeinfoid: [self.data.DAROUTEINFOID],
  926. userid: self.userId,
  927. username: self.userName,
  928. updata: [],
  929. columns: "ID,DOCUMENTID,DOCUMENTTYPE,SERIALNUM,MAINDPT,ATTACHMENT,ISSUINGAGENCY,DOCISSUEDDATE,ANNOTATION,CCDPT,PRINTSENDDPT,PRINTDATE,RELEASELEVEL,ARCHCODE,ARCHYEAR,RETENTPERIOD,ORGANIZATIONMA,ITEMNUM,ELECTRONICID,ENVIRONINFO,SOFTWENVIRON,HARDWENVIRON,DISTYPE,DISACTOR,DISDPT,DISTIME,DISLRESULT,MIJIQIXIAN,EMERGENCYDEGREE,DOCISSUERID,DOCISSUEDNUM,SIGNER,DOCTITLE,FINISHEDDATE,FLOWID,SENDSTATUS,CREATDATE,CREATUSERID,CREATNAME,SENDNAME,SENDUSERID,SENDDATE,MODELMARK,MERGEID,MOBANNAME,TABLENAME,WENHAO,DANGANML,ZRZ,JIANHAO,YESHU,BEIZHU,DPCODE,DPNAME,DAROUTEINFOID AS ROUTEINFOID"
  930. }
  931. $http.post(apiurljs.login + "g2app/DangAn/YJYGDSendDataZL", {
  932. data: s4.encryptData_CBC(JSON.stringify(data))
  933. }, postCfg)
  934. .success(function (obj1) { })
  935. }
  936. self.SXDBYS = function () {
  937. var data1 = {
  938. tablename: self.data.YTABLENAME,
  939. id: self.data.YID,
  940. data: {
  941. SQYQRQ: self.data.SQYQSJ,
  942. ZZYQWCQX: getNextDate(self.data.YYQBJSJ, parseInt(self.data.YQTS)),
  943. DBSX: getNextDate(self.data.YYQBJSJ, parseInt(self.data.YQTS))
  944. }
  945. }
  946. $http.post(apiurljs.login + "g2app/dataabase/upFormData", {
  947. data: s4.encryptData_CBC(JSON.stringify(data1))
  948. }, postCfg)
  949. .success(function (obj1) {
  950. var res1 = strToJson(s4.decryptData_CBC(obj1.data));
  951. if (res1.success) {
  952. var data2 = {
  953. routeinfoid: self.routeinfoid,
  954. userid: self.userId,
  955. edate: getNextDate(self.data.YYQBJSJ, parseInt(self.data.YQTS)),
  956. linkrouteinfoid: self.data.YROUTEINFOID
  957. }
  958. $http.post(apiurljs.login +
  959. "g2work/routeinfo/addRouteinfoTimelimitDelayedate", {
  960. data: s4.encryptData_CBC(JSON.stringify(data2))
  961. }, postCfg)
  962. .success(function (obj2) {
  963. var res2 = strToJson(s4.decryptData_CBC(obj2.data));
  964. })
  965. } else {
  966. sp.dialog(res1.message)
  967. return false
  968. }
  969. })
  970. }
  971. self.GWDBYQ = function () {
  972. var data1 = {
  973. tablename: self.data.YTABLENAME,
  974. id: self.data.YID,
  975. data: {
  976. DBSX: self.data.SQYQSJ
  977. }
  978. }
  979. $http.post(apiurljs.login + "g2app/dataabase/upFormData", {
  980. data: s4.encryptData_CBC(JSON.stringify(data))
  981. }, postCfg)
  982. .success(function (obj1) {
  983. var res1 = strToJson(s4.decryptData_CBC(obj1.data));
  984. if (res1.success) {
  985. var data2 = {
  986. routeinfoid: self.routeinfoid,
  987. userid: self.userId,
  988. edate: self.data.SQYQSJ,
  989. linkrouteinfoid: self.data.YROUTEINFOID
  990. }
  991. $http.post(apiurljs.login +
  992. "g2work/routeinfo/addRouteinfoTimelimitDelayedate", {
  993. data: s4.encryptData_CBC(JSON.stringify(data))
  994. }, postCfg)
  995. .success(function (obj2) {
  996. var res2 = strToJson(s4.decryptData_CBC(obj2.data));
  997. })
  998. } else {
  999. sp.dialog(res1.message)
  1000. return false
  1001. }
  1002. })
  1003. }
  1004. self.WJFBB = function () {
  1005. var data = {
  1006. tablename: "SX_FBLIST",
  1007. data: {
  1008. WJLY: "WJ",
  1009. FLOWID: "AA50",
  1010. FORMROUTEINFOID: self.routeinfoid,
  1011. FBUSERID: self.userId,
  1012. FBNAME: self.userName,
  1013. LM: window.parent.getData().LX,
  1014. FBRQ: sp.getLocalDate(),
  1015. FBBM: window.parent.getData().FBBM,
  1016. WJBT: window.parent.getData().WJBT
  1017. }
  1018. }
  1019. $http.post(apiurljs.login + "g2app/dataabase/insertFormData", {
  1020. data: s4.encryptData_CBC(JSON.stringify(data))
  1021. }, postCfg)
  1022. .success(function (obj1) { })
  1023. }
  1024. self.submitYJ = function () {
  1025. var data = {
  1026. cmanid: self.userId,
  1027. routeinfoid: self.routeinfoid,
  1028. routeid: self.routeid,
  1029. tableid: self.direction.SENDERRORS.ERRORLIST[1].TABLEID,
  1030. colid: self.direction.SENDERRORS.ERRORLIST[1].COLID,
  1031. opiniontype: 0,
  1032. cresult: "",
  1033. opinion: "已阅",
  1034. opinionimage: ""
  1035. }
  1036. $http.post(apiurljs.login + "g2app/abase/saveDataOpinion", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1037. .success(function (obj) {
  1038. var res = strToJson(s4.decryptData_CBC(obj.data));
  1039. if (res.success == true) {
  1040. self.sendAll()
  1041. } else {
  1042. window.parent.sp.layerhide()
  1043. window.top.sp.dialog(res.message)
  1044. setTimeout(function () {
  1045. window.top.sp.dialoghide()
  1046. window.top.sp.layer("#forward")
  1047. },2000)
  1048. }
  1049. })
  1050. }
  1051. }])
  1052. //返回n天后日期
  1053. function getNextDate(time, n) {
  1054. var date = "";
  1055. $.ajax({
  1056. url: apiurljs.login + "g2app/dataabase/getTheoryDate",
  1057. type: 'post',
  1058. async: false,
  1059. contentType: "application/json",
  1060. beforeSend: function (request) {
  1061. request.setRequestHeader("Authorization", "Bearer " + localStorage.getItem("GlWorkPlatform-AccessToken"));
  1062. },
  1063. data: JSON.stringify({
  1064. data: s4.encryptData_CBC(JSON.stringify({
  1065. startdate: time + " 00:00:00",
  1066. yqday: n
  1067. }))
  1068. }),
  1069. dataType: "json",
  1070. success: function (obj) {
  1071. var res = strToJson(s4.decryptData_CBC(obj.data));
  1072. date = sp.format(res.data);
  1073. }
  1074. })
  1075. return date
  1076. }
  1077. //并发流程
  1078. function Concurrency(array) {
  1079. var n = array.length;
  1080. array.forEach(function (item) {
  1081. if (item.jiaqian == true) {
  1082. n = n - 1;
  1083. }
  1084. })
  1085. return n > 1
  1086. }