forwardUser.js 41 KB

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