forward.js 44 KB

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