forwardUser.js 40 KB

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