fawenfile.js 42 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021
  1. 'use strict';
  2. var app = angular.module('app', [
  3. ]);
  4. app.controller("formeditCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
  5. var self = this;
  6. var s4 = new SM4Util();
  7. self.userId = $.cookie("GlWorkPlatform-userid");
  8. self.userName = $.cookie("GlWorkPlatform-chineseName");
  9. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  10. self.routeid = sp.getUrlName("routeid");
  11. self.routeinfoid = sp.getUrlName("routeinfoid");
  12. self.directionid = sp.getUrlName("directionid");
  13. self.formeditid = sp.getUrlName("formeditid");
  14. self.docmode = sp.getUrlName("docmode");
  15. self.dotype = sp.getUrlName("dotype");
  16. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  17. self.get_lastReturnPage = sp.getUrlName("lastReturnPage");
  18. self.get_type = sp.getUrlName("type");
  19. sp.fitHeight("#iframe_WO", 100);
  20. if (self.get_lastReturnPage != "") {
  21. self.return = "../../../" + self.get_lastReturnPage + "?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type
  22. } else {
  23. self.return = "../list.html?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type
  24. }
  25. var postCfg = {
  26. headers: {
  27. 'Content-Type': 'application/json',
  28. 'Authorization': "Bearer " + self.get_AccessToken
  29. }
  30. };
  31. self.video = false;
  32. self.QianPi = false;
  33. self.watchNum = 0;
  34. //初始化右上角按钮
  35. self.buttonList = []
  36. self.getSwenList = function () {
  37. self.SwenList = [];
  38. var data = {
  39. directionid: self.directionid,
  40. userid: self.userId,
  41. routeinfoid: self.routeinfoid,
  42. routeid: self.routeid,
  43. formeditid: ""
  44. }
  45. $http.post(apiurljs.login + "g2app/abase/queryDataLink", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  46. .success(function (obj) {
  47. var res = strToJson(s4.decryptData_CBC(obj.data));
  48. $.each(res.data.LINKS, function (index, item) {
  49. item.TEMPFORM = item.TEMPFORM + "&flowid=" + sp.getUrlName("flowid")
  50. if (item.TEMPFORM.indexOf("fawenfile.html") > -1) {
  51. self.Title = item.VNAME;
  52. }
  53. if (item.TEMPFORM.indexOf("?docmode") > 0) {
  54. if (item.TEMPFORM.indexOf("attachlist") > -1 || item.TEMPFORM.indexOf("fawenfile") > -1) {
  55. item.TEMPFORM = item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  56. } else {
  57. item.TEMPFORM = "../" + item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  58. }
  59. } else {
  60. item.TEMPFORM = "#";
  61. }
  62. self.SwenList.push(item)
  63. })
  64. self.SwenList.push({
  65. VNAME: "流程图",
  66. DIRECTIONID: self.SwenList[0].DIRECTIONID,
  67. TEMPFORM: "modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1]
  68. })
  69. self.getGWZL()
  70. })
  71. }
  72. self.getSwenList(0)
  73. self.getGWZL = function () {
  74. var data = {
  75. tablename: "CODE_GWTYPE",
  76. colums: "ID,CODE,CNAME,FLOWID",
  77. order: "ID desc",
  78. sqlwhere: {
  79. USEMARK: 1,
  80. FLOWID: sp.getUrlName("flowid")
  81. },
  82. sqlinwhere: "",
  83. sqllikewhere: ""
  84. }
  85. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  86. .success(function (obj) {
  87. var res = strToJson(s4.decryptData_CBC(obj.data));
  88. console.log(res.data)
  89. self.GWZL = res.data;
  90. //console.log(JSON.stringify(self.GWZL));
  91. self.getDOCKIND()
  92. })
  93. }
  94. self.getDOCKIND = function () {
  95. var data = {
  96. ckey: "CODE_DOCKIND",
  97. routeinfoid: self.routeinfoid
  98. }
  99. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  100. .success(function (obj) {
  101. var res = strToJson(s4.decryptData_CBC(obj.data));
  102. self.DOCKIND = res.data.CODE_DOCKIND;
  103. self.getFuncList()
  104. })
  105. }
  106. self.getFuncList = function () {
  107. var data = {
  108. ckey: "FW_DWZSWSXW",
  109. id: 0,
  110. directionid: self.directionid,
  111. formeditid: self.formeditid,
  112. routeid: self.routeid,
  113. routeinfoid: self.routeinfoid
  114. }
  115. $http.post(apiurljs.login + "g2app/abase/queryData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  116. .success(function (obj) {
  117. var res = strToJson(s4.decryptData_CBC(obj.data));
  118. self.file = {
  119. GWZL: res.data.FW_DWZSWSXW.GWZL,
  120. DOCKIND: self.DOCKIND[0].CODE
  121. }
  122. var data = {
  123. ckey: "FAWEN_FILES",
  124. id: 0,
  125. directionid: self.directionid,
  126. formeditid: self.formeditid,
  127. routeid: self.routeid,
  128. routeinfoid: self.routeinfoid
  129. }
  130. $http.post(apiurljs.login + "g2app/abase/queryData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  131. .success(function (obj1) {
  132. var res1 = strToJson(s4.decryptData_CBC(obj1.data));
  133. self.buttonList = self.dotype == 0 ? [] : res1.data["FAWEN_FILES.FUNCLIST"];
  134. ///---zyg---********************************
  135. self.getFileByKind(1, self.DOCKIND[0].CODE);
  136. self.getFileByKind(2, self.DOCKIND[1].CODE);
  137. self.getFileByKind(3, self.DOCKIND[2].CODE);
  138. })
  139. })
  140. }
  141. ///---zyg---*************************************************************************
  142. self.btnCreateFileKind = function () {
  143. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  144. var dialogBody = "<div class=\"sp-dialog-body\">您确认要创建吗?</div>";
  145. var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='delDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  146. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  147. sp.openCenter(".sp-dialog");
  148. ///取消按钮
  149. $('.sp-closeDialog').click(function (event) {
  150. sp.closeCenter(".sp-dialog");
  151. event.preventDefault();
  152. event.stopPropagation();
  153. });
  154. //post消息的id
  155. $("#delDataTrue").click(function () {
  156. var data = {
  157. dockind: self.file.DOCKIND,
  158. routeinfoid: self.routeinfoid,
  159. gwtype: self.file.GWZL
  160. }
  161. console.log(data);
  162. $http.post(apiurljs.login + "g2app/fawenfiles/newDataFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  163. .success(function (obj) {
  164. var res = strToJson(s4.decryptData_CBC(obj.data));
  165. console.log(JSON.stringify(res));
  166. sp.dialoghide();
  167. if (res.success) {
  168. self.getFileByKind(1, self.DOCKIND[0].CODE);
  169. //self.getFileByKind(2, self.DOCKIND[1].CODE);
  170. } else {
  171. sp.dialog("创建失败,请联系管理员!");
  172. }
  173. ///
  174. });
  175. });
  176. };
  177. self.gaoTypeArrayFirst = [];
  178. self.gaoTypeArraySecond = [];
  179. self.gaoTypeArrayThird = [];
  180. self.leftFileKind_active_id = "";///当前选中的文件的id
  181. self.getFileByKind = function (ctype, dockindStr) {
  182. var data = {
  183. dockind: dockindStr,
  184. routeinfoid: self.routeinfoid
  185. }
  186. //console.log(data);
  187. $http.post(apiurljs.login + "g2app/fawenfiles/queryDataList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  188. .success(function (obj) {
  189. var res = strToJson(s4.decryptData_CBC(obj.data));
  190. if (ctype == 1) {
  191. self.gaoTypeArrayFirst = res.data;
  192. if (sp.isval(self.gaoTypeArrayFirst)) {
  193. ///self.getFileWo("1111219901", "自定义表单工作梳理.doc", "http://10.233.22.204:8088/glwork/g2work/files2/inline/865e508cb0c706bd2e09e73f2168cb8a/431d39d5e28fec47bc346a3b8e2f35f7/e887aae5ae9ae8a1a8e58d95e5b7a5e4bd9ce9878fe9878de696b0e6a2b3e79086.doc");
  194. ///http://10.233.22.204:8088/glworkweb/UploadAttach/doc1090286669558296576.wps
  195. var set_filepath = apiurljs.login.split("glwork/")[0] + "glworkweb/" + self.gaoTypeArrayFirst[0].FILEURL;
  196. //console.log(set_filepath);
  197. self.getFileWo(self.gaoTypeArrayFirst[0].ID, self.gaoTypeArrayFirst[0].FILENAMES, set_filepath);
  198. self.leftFileKind_active_id = self.gaoTypeArrayFirst[0].ID;
  199. } else {
  200. $("#iframe_WO").attr("src", "");
  201. self.leftFileKind_active_id = "";
  202. }
  203. } else if (ctype == 2) {
  204. self.gaoTypeArraySecond = res.data;
  205. if (self.gaoTypeArraySecond.length > 0) {
  206. self.browse(self.gaoTypeArraySecond[0])
  207. } else {
  208. $("#iframe_WO").attr("src", "");
  209. }
  210. } else if (ctype == 3) {
  211. self.gaoTypeArrayThird = res.data;
  212. if (self.gaoTypeArrayThird.length > 0) {
  213. self.browse(self.gaoTypeArrayThird[0])
  214. } else {
  215. $("#iframe_WO").attr("src", "");
  216. }
  217. }
  218. ///
  219. })
  220. };
  221. self.btnClickFileKind = function (itemdata) {
  222. ///点击过程稿标题--zyg--20230328---***********
  223. self.leftFileKind_active_id = itemdata.ID;
  224. var set_filepath = apiurljs.login.split("glwork/")[0] + "glworkweb/" + itemdata.FILEURL;
  225. self.getFileWo(itemdata.ID, itemdata.FILENAMES, set_filepath);
  226. };
  227. self.btnDelFileKind = function (itemdata, n) {
  228. ///点击过程稿--删除图标--zyg--20230328---***********
  229. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  230. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  231. var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='delDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  232. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  233. sp.openCenter(".sp-dialog");
  234. ///取消按钮
  235. $('.sp-closeDialog').click(function (event) {
  236. sp.closeCenter(".sp-dialog");
  237. event.preventDefault();
  238. event.stopPropagation();
  239. });
  240. //post消息的id
  241. $("#delDataTrue").click(function () {
  242. var data = {
  243. id: itemdata.ID
  244. }
  245. $http.post(apiurljs.login + "g2app/fawenfiles/deleteDataFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  246. .success(function (obj) {
  247. var res = strToJson(s4.decryptData_CBC(obj.data));
  248. //console.log(JSON.stringify(res));
  249. sp.dialoghide();
  250. if (res.success) {
  251. self.getFileByKind(n, self.DOCKIND[n - 1].CODE);
  252. } else {
  253. sp.dialog("创建失败,请联系管理员!");
  254. }
  255. ///
  256. });
  257. });
  258. };
  259. self.getFileWo = function (fileid, filename, filepath) {
  260. //var str = "jsonParams: %7B%22method%22%3A1%2C%22params%22%3A%7B%22userId%22%3A%2210.222.33.204%22%2C%22fileId%22%3A%22bcc3655a692547259a2f2335f78cd52f_558347767%22%2C%22filePath%22%3A%22%2Fdoc1090299906328735744.wps%22%2C%22userRight%22%3A0%2C%22mobileFlag%22%3Afalse%2C%22saveFlag%22%3Atrue%7D%2C%22indexFlag%22%3Atrue%7D";
  261. //console.log(decodeURIComponent(str));
  262. ////调用永中中转--zyg--**********************************--2023
  263. var data = {
  264. method: 1,
  265. params: {
  266. userId: self.userName,
  267. fileId: fileid,
  268. fileName: filename,
  269. filePath: filepath,
  270. userRight: self.dotype == 1 ? 0 : 1, // 用户权限 编辑:UserRightEdit = 0; 只读:UserRightReadonly = 1; 临时只读:UserRightTempReadonly = 2;此时页面上编辑—临时只读按钮,打开只能临时只读,不打开可以进行编辑
  271. //saveFlag: true, /// true:自动保存文档 false:不自动保存文档 (默认为true)
  272. callbackUrl: apiurljs.login + "g2app/fawenfiles/uploadFile"
  273. }
  274. };
  275. console.log(JSON.stringify(data))
  276. $.ajax({
  277. url: apiurljs.yzFileWo + "api.do",
  278. data: {
  279. jsonParams: encodeURIComponent(JSON.stringify(data))
  280. },
  281. type: "POST",
  282. dataType: "json",
  283. general: false,
  284. async: false,
  285. success: function (data) {
  286. console.log(data);
  287. if (data) {
  288. if (data.errorCode === "0") {
  289. let rst = data.result;
  290. console.log(rst.urls);
  291. if (rst && rst.urls) {
  292. var get_urls = rst.urls;
  293. console.log(get_urls);
  294. if (typeof (get_urls) === "string") {
  295. $timeout(function () {
  296. $("#iframe_WO").attr("src", get_urls);
  297. })
  298. } else {
  299. console.warn("无效的urls:" + get_urls);
  300. }
  301. } else {
  302. console.warn("ajax响应内容data.result有问题:" + rst);
  303. }
  304. } else {
  305. alert(data.errorMessage);
  306. }
  307. } else {
  308. console.warn("ajax响应内容为空!");
  309. }
  310. },
  311. });
  312. };
  313. //self.btnSave_1 = function () {
  314. // document.getElementById("iframe_WO").contentWindow.YozoOffice.Application.ActiveDocument.Save(true);
  315. //}
  316. self.btnSave = function () {
  317. ////调用永中保存函数--zyg--**********************************--2023
  318. //console.log("保存文件");
  319. var data = {
  320. method: 2,
  321. params: {
  322. fileId: self.leftFileKind_active_id
  323. }
  324. };
  325. $.ajax({
  326. url: apiurljs.yzFileWo + "api.do",
  327. data: {
  328. jsonParams: encodeURIComponent(JSON.stringify(data))
  329. },
  330. type: "POST",
  331. dataType: "json",
  332. general: false,
  333. async: false,
  334. success: function (data) {
  335. console.log(data);
  336. if (data && data.errorCode === "0") {
  337. sp.dialog("保存成功");
  338. }
  339. },
  340. });
  341. }
  342. //打印
  343. self.printFile = function () {
  344. document.getElementById("iframe_WO").contentWindow.YozoOffice.print();
  345. }
  346. self.btnXiuDing = function () {
  347. console.log("开启/关闭修订模式")
  348. }
  349. //右上角按钮调用方法
  350. self.btnEvent = function (item) {
  351. switch (item.CODE) {
  352. case "SAVEITEM": self.btnSave(); break;
  353. case "PRINTITEM": self.printFile(); break;
  354. case "SAVEOFD": self.toOFD(); break;
  355. case "GAIZITEM": self.qianZ(); break;
  356. case "SENDLOG": self.RouteList(); break;
  357. default: self.forward(item); break;
  358. }
  359. }
  360. //生成终稿
  361. self.toOFD = function () {
  362. if (self.gaoTypeArraySecond.length != 0) {
  363. sp.dialog("请删除成文稿后,点击文件保存!")
  364. $timeout(function () {
  365. sp.dialoghide()
  366. }, 1000)
  367. return
  368. }
  369. var data = {
  370. routeinfoid: self.routeinfoid,
  371. gwtype: self.file.GWZL,
  372. dockind:"D02"
  373. }
  374. $http.post(apiurljs.login + "g2app/fawenfiles/convertDataFinalOFDFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  375. .success(function (obj) {
  376. var res = strToJson(s4.decryptData_CBC(obj.data));
  377. if (res.success == true) {
  378. self.getFileByKind(2, self.DOCKIND[1].CODE)
  379. }
  380. })
  381. }
  382. //签章
  383. self.qianZ = function () {
  384. if (self.gaoTypeArrayThird.length != 0 || self.gaoTypeArraySecond.length != 0) {
  385. sp.dialog("请删除终稿、签章稿后,点击签章!")
  386. $timeout(function () {
  387. sp.dialoghide()
  388. }, 1000)
  389. return
  390. }
  391. var data = {
  392. srcpath: "/root/TongWeb7.0/applications/glworkweb/UploadAttach/" + self.gaoTypeArraySecond[0].FILENAMES,
  393. outpath: "/root/TongWeb7.0/applications/glworkweb/UploadAttach",
  394. routeinfoid: self.routeinfoid,
  395. gwtype: self.file.GWZL,
  396. dockind: "D03"
  397. }
  398. $http.post(apiurljs.login + "g2app/signature/getSignature",{ data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  399. .success(function (obj) {
  400. var res = strToJson(s4.decryptData_CBC(obj.data));
  401. if (res.success == true) {
  402. self.getFileByKind(3, self.DOCKIND[2].CODE)
  403. }
  404. })
  405. }
  406. self.download = function (item) {
  407. window.open(apiurljs.login.split("glwork/")[0] + "glworkweb/" + item.FILEURL)
  408. }
  409. self.browse = function (item) {
  410. var set_convertType;
  411. if (item.FILEEXT == "ofd") {
  412. set_convertType = 570;
  413. } else {
  414. set_convertType = 0;
  415. }
  416. let postData = {
  417. convertType: set_convertType,
  418. fileUrl: apiurljs.login.split("glwork/")[0] + "glworkweb/" + item.FILEURL
  419. };
  420. var postCfg_transfer = {
  421. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  422. transformRequest: function (data) {
  423. return $.param(data);
  424. }
  425. };
  426. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  427. .success(function (res) {
  428. //console.log(res);
  429. if (res.errorcode === 0) {
  430. $("#iframe_WO").attr("src", res.data.viewUrl);
  431. } else {
  432. sp.dialog(res.message);
  433. }
  434. });
  435. }
  436. //转发
  437. self.forward = function (obj) {
  438. self.activeGroup = "部门";
  439. self.forwardUser = [];
  440. self.searchName = "";
  441. self.saveZB = false;
  442. self.btnItem = obj;
  443. if (self.filedChange == true) {
  444. self.btnSave(1)
  445. } else {
  446. var data = {
  447. codefuncbutton: self.btnItem.CODE,
  448. directionid: self.directionid,
  449. directionidtarget: self.btnItem.DIRECTIONIDTARGET,
  450. userid: self.userId,
  451. routeinfoid: self.routeinfoid,
  452. routeid: self.routeid
  453. }
  454. $http.post(apiurljs.login + "g2app/abase/queryDataSendByTarget", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  455. .success(function (obj) {
  456. var res = strToJson(s4.decryptData_CBC(obj.data));
  457. self.showContent = true;
  458. self.directions = res.data;//所有可选流向
  459. self.direction = self.directions[0];//所选流向
  460. if (self.direction.ENDNODETYPE == 1 || self.direction.CODEFUNCBUTTON == "SENDCOPYEND" || self.direction.CODEFUNCBUTTON == "SENDPERUSAL") {
  461. self.showContent = false;
  462. self.forward1(0)
  463. } else if (self.direction.ENDNODETYPE == 3) {
  464. self.showContent = true;
  465. self.forwardUser = [];
  466. self.directionList = self.direction["DIRECTION.CHILD"];
  467. $.each(self.directionList, function (index, item) {
  468. item.forwardUser = index;
  469. self.forwardUser.push([])
  470. //item.show = false;
  471. item.Dep = [];//部门
  472. item.Dep.push(item.SENDUSERS.SECTS[0]);
  473. item.organCode = item.Dep[0].CODE;//所选部门编号
  474. $.each(item.Dep, function (index1, item1) {
  475. item1.open = true;
  476. $.each(item1.C_H_I_L_D, function (index2, item2) {
  477. item2.open = true;
  478. })
  479. })
  480. item.people = item.SENDUSERS.USERS;//人员
  481. item.people.forEach(function (item1) {
  482. item1.show = true;
  483. })
  484. item.mainSend = null;//主送
  485. item.copySend = [];//抄送
  486. })
  487. self.activeDirection = self.directionList[0]
  488. console.log(self.activeDirection)
  489. self.forward2(0)
  490. } else {
  491. self.showContent = true;
  492. self.forwardUser = [];
  493. self.Dep = [];//部门
  494. self.Dep.push(self.direction.SENDUSERS.SECTS[0]);
  495. self.organCode = self.Dep[0].CODE;//所选部门编号
  496. $.each(self.Dep, function (index, item) {
  497. item.open = true;
  498. $.each(item.C_H_I_L_D, function (index1, item1) {
  499. item1.open = true;
  500. })
  501. })
  502. self.people = self.direction.SENDUSERS.USERS;//人员
  503. self.people.forEach(function (item) {
  504. item.show = true;
  505. })
  506. self.mainSend = null;//主送
  507. self.copySend = [];//抄送
  508. self.forward1(0)
  509. }
  510. //setTimeout(function () {
  511. // sp.layer("#forward");
  512. //}, 100)
  513. })
  514. }
  515. }
  516. //转发(新)
  517. self.forward1 = function (n) {
  518. if (n == 0) {
  519. sp.layer("#forward");
  520. } else {
  521. if (self.activeGroup == "自定义") {
  522. self.getZbList()
  523. }
  524. }
  525. self.activeUser = null;
  526. self.moveFlag1 = false;
  527. self.moveFlag2 = false;
  528. }
  529. self.searchPerson = function () {
  530. self.people.forEach(function (item) {
  531. if (item.USERNAME.indexOf(self.searchName) > -1) {
  532. item.show = true;
  533. } else {
  534. item.show = false;
  535. }
  536. })
  537. }
  538. self.adduser = function () {
  539. self.people.forEach(function (item) {
  540. if (item.checked == true && item.show == true) {
  541. self.forwardUser.push(item);
  542. item.checked = false;
  543. item.show = false;
  544. }
  545. })
  546. if (self.forwardUser.length == 1) {
  547. self.moveFlag1 = false;
  548. self.moveFlag2 = false;
  549. return;
  550. }
  551. self.getmoveFlag()
  552. }
  553. self.deluser = function () {
  554. self.forwardUser.forEach(function (item) {
  555. if (item.checked == true) {
  556. item.checked = false;
  557. item.show = true;
  558. }
  559. })
  560. self.forwardUser = self.forwardUser.filter(function (item) {
  561. return item.show == false;
  562. })
  563. if (self.forwardUser.length == 1) {
  564. self.moveFlag1 = false;
  565. self.moveFlag2 = false;
  566. return;
  567. }
  568. self.getmoveFlag()
  569. }
  570. self.adduserAll = function () {
  571. self.people.forEach(function (item) {
  572. if (item.show == true) {
  573. self.forwardUser.push(item);
  574. item.checked = false;
  575. item.show = false;
  576. }
  577. })
  578. if (self.forwardUser.length == 1) {
  579. self.moveFlag1 = false;
  580. self.moveFlag2 = false;
  581. return;
  582. }
  583. self.getmoveFlag()
  584. }
  585. self.deluserAll = function () {
  586. self.forwardUser.forEach(function (item) {
  587. item.checked = false;
  588. item.show = true;
  589. })
  590. self.forwardUser = [];
  591. self.moveFlag1 = false;
  592. self.moveFlag2 = false;
  593. }
  594. self.checkForwardUser = function (n) {
  595. if (self.activeUser != n) {
  596. self.activeUser = n;
  597. } else {
  598. self.activeUser = null;
  599. }
  600. if (self.forwardUser.length == 1) {
  601. self.moveFlag1 = false;
  602. self.moveFlag2 = false;
  603. return;
  604. }
  605. if (self.activeUser == null) {
  606. self.moveFlag1 = false;
  607. self.moveFlag2 = false;
  608. } else {
  609. self.getmoveFlag()
  610. }
  611. }
  612. self.getmoveFlag = function () {
  613. if (self.activeUser == 0) {
  614. self.moveFlag1 = false;
  615. self.moveFlag2 = true;
  616. } else if (self.activeUser == self.forwardUser.length - 1) {
  617. self.moveFlag1 = true;
  618. self.moveFlag2 = false;
  619. } else {
  620. self.moveFlag1 = true;
  621. self.moveFlag2 = true;
  622. }
  623. }
  624. self.moveUp = function () {
  625. var a = self.forwardUser[self.activeUser], b = self.forwardUser[self.activeUser - 1];
  626. self.forwardUser[self.activeUser] = b;
  627. self.forwardUser[self.activeUser - 1] = a;
  628. self.activeUser = self.activeUser - 1;
  629. self.getmoveFlag()
  630. }
  631. self.moveDown = function () {
  632. var a = self.forwardUser[self.activeUser], b = self.forwardUser[self.activeUser + 1];
  633. self.forwardUser[self.activeUser] = b;
  634. self.forwardUser[self.activeUser + 1] = a;
  635. self.activeUser = self.activeUser + 1;
  636. self.getmoveFlag()
  637. }
  638. self.getZbList = function () {
  639. var data = {
  640. userid: self.userId
  641. }
  642. $http.post(apiurljs.login + "g2app/usercustom/queryCustomData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  643. .success(function (obj) {
  644. var res = strToJson(s4.decryptData_CBC(obj.data));
  645. self.zbList = res.data;
  646. self.zbCode = self.zbList[0].CODE;
  647. self.people.forEach(function (item) {
  648. item.show = false;
  649. self.zbList.forEach(function (item1) {
  650. item1.USERS.forEach(function (item2) {
  651. if (item.USERID == item2.USERID) {
  652. item.show = true;
  653. item.set = self.zbCode;
  654. }
  655. })
  656. self.forwardUser.forEach(function (obj) {
  657. item1.USERS.forEach(function (item2) {
  658. if (obj.USERID == item2.USERID) {
  659. obj.show = false;
  660. obj.set = self.zbCode;
  661. }
  662. })
  663. })
  664. })
  665. })
  666. })
  667. }
  668. self.checkZB = function (item1) {
  669. self.zbCode = item1.CODE;
  670. self.people.forEach(function (item) {
  671. item.show = false;
  672. item.checked = false;
  673. item1.USERS.forEach(function (item2) {
  674. if (item.USERID == item2.USERID) {
  675. item.show = true;
  676. item.set = self.zbCode;
  677. }
  678. })
  679. })
  680. self.forwardUser.forEach(function (obj) {
  681. item1.USERS.forEach(function (item2) {
  682. if (obj.USERID == item2.USERID) {
  683. obj.show = false;
  684. obj.set = self.zbCode;
  685. }
  686. })
  687. })
  688. }
  689. self.delZB = function (item) {
  690. var data = {
  691. code: item.CODE,
  692. userid: self.userId
  693. }
  694. $http.post(apiurljs.login + "g2app/usercustom/delCustomData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  695. .success(function (obj) {
  696. var res = strToJson(s4.decryptData_CBC(obj.data));
  697. if (res.success == true) {
  698. self.getZbList()
  699. }
  700. })
  701. }
  702. self.btnSaveZB = function () {
  703. if (self.forwardUser.length == 0) {
  704. return
  705. }
  706. var data = {
  707. userid: self.userId,
  708. cname: self.cnameZB,
  709. userids: JSON.stringify(self.forwardUser.map(function (item) {
  710. return { userid: item.USERID }
  711. }))
  712. }
  713. $http.post(apiurljs.login + "g2app/usercustom/saveCustomData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  714. .success(function (obj) {
  715. var res = strToJson(s4.decryptData_CBC(obj.data));
  716. if (res.success == true) {
  717. self.searchName = "";
  718. self.saveZB = false;
  719. self.getZbList()
  720. }
  721. })
  722. }
  723. //a代表所选项上一级,b代表当前所选项
  724. self.setMainSend = function (a, b) {
  725. a.mainSend = b;
  726. }
  727. self.setCopySend = function (a, b) {
  728. a.copySend.push(b);
  729. }
  730. self.delCopySend = function (a, b) {
  731. a.copySend.splice(a.copySend.indexOf(b), 1)
  732. }
  733. self.sendFlag = false;
  734. self.send = function () {
  735. self.sendFlag = true;
  736. if (self.direction.ENDNODETYPE == 1) {
  737. var sendUser = {
  738. DIRECTIONID: self.direction.DIRECTIONID,
  739. MAINUSERID: "STOP",
  740. COPYUSERID: ""
  741. }
  742. } else if (self.direction.CODEFUNCBUTTON == "SENDCOPYEND" || self.direction.CODEFUNCBUTTON == "SENDPERUSAL") {
  743. var sendUser = {
  744. DIRECTIONID: self.direction.DIRECTIONID,
  745. MAINUSERID: "",
  746. COPYUSERID: ""
  747. }
  748. } else {
  749. if (self.forwardUser.length == 0) {
  750. sp.layerhide()
  751. sp.dialog("请选择人员!");
  752. $timeout(function () {
  753. sp.dialoghide()
  754. sp.layer("#forward");
  755. }, 2000)
  756. return
  757. }
  758. //if (self.mainSend == null && (self.direction.SENDRULE == 0 || self.direction.SENDRULE == 1)) {
  759. // self.mainNull = true;
  760. // self.sendFlag = false;
  761. // return;
  762. //}
  763. //var sendUser = {
  764. // DIRECTIONID: self.direction.DIRECTIONID,
  765. // MAINUSERID: self.mainSend ? self.mainSend.USERID : "",
  766. // COPYUSERID: self.copySend.map(function (item) {
  767. // return item.USERID
  768. // }).join("|")
  769. //}
  770. var sendUser = {
  771. DIRECTIONID: self.direction.DIRECTIONID,
  772. MAINUSERID: self.forwardUser.map(function (item) {
  773. return item.USERID
  774. }).join("|"),
  775. COPYUSERID: ""
  776. }
  777. }
  778. var data = {
  779. codefuncbutton: self.direction.CODEFUNCBUTTON,
  780. directionid: self.directionid,
  781. userid: self.userId,
  782. routeinfoid: self.routeinfoid,
  783. routeid: self.routeid,
  784. data: "[" + JSON.stringify(sendUser) + "]"
  785. }
  786. $http.post(apiurljs.login + "g2app/abase/saveDataSend", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  787. .success(function (obj) {
  788. var res = strToJson(s4.decryptData_CBC(obj.data));
  789. self.sendFlag = false;
  790. sp.closeCenter('.sp-layer');
  791. if (res.success == true) {
  792. sp.dialog("发送成功!");
  793. $timeout(function () {
  794. window.location.href = "../list.html?lastReturnPageno=" + sp.getUrlName("lastReturnPageno")
  795. }, 1500)
  796. } else {
  797. sp.dialog(res.message)
  798. }
  799. })
  800. }
  801. self.openPeopleList = function (item1) {
  802. $.each(self.directionList, function (index, item) {
  803. if (item.CNAME == item1.CNAME) {
  804. item.show = !item1.show;
  805. } else {
  806. item.show = false;
  807. }
  808. })
  809. }
  810. self.sendAll = function () {
  811. if (self.filedChange == true) {
  812. self.btnSave(2)
  813. } else {
  814. var sendUser = [];
  815. self.directionList.forEach(function (item) {
  816. if (item.mainSend != null || item.copySend.length > 0) {
  817. sendUser.push({
  818. DIRECTIONID: item.DIRECTIONID,
  819. MAINUSERID: item.mainSend ? item.mainSend.USERID : "",
  820. COPYUSERID: item.copySend.map(function (item1) {
  821. return item1.USERID
  822. }).join("|")
  823. })
  824. }
  825. })
  826. var data = {
  827. codefuncbutton: self.direction.CODEFUNCBUTTON,
  828. directionid: self.directionid,
  829. userid: self.userId,
  830. routeinfoid: self.routeinfoid,
  831. routeid: self.routeid,
  832. data: JSON.stringify(sendUser)
  833. }
  834. $http.post(apiurljs.login + "g2app/abase/saveDataSend", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  835. .success(function (obj) {
  836. var res = strToJson(s4.decryptData_CBC(obj.data));
  837. sp.closeCenter('.sp-layer');
  838. if (res.success == true) {
  839. if (apiurljs.sendMsg == true) {
  840. if (self.mainSend) {
  841. var data = {
  842. acceptuserid: self.mainSend.USERID,
  843. flowid: "AA18",
  844. routeinfoid: self.routeinfoid
  845. }
  846. $http.post(apiurljs.login + "g2app/message/queryDataTodoFilen", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  847. .success(function (obj) {
  848. var res = strToJson(s4.decryptData_CBC(obj.data));
  849. if (res.success) {
  850. var data = {
  851. users: self.mainSend.UINPUTNAME,
  852. title: "你有一份新邮件",
  853. subtitle: self.data.BT,
  854. content: "请及时处理",
  855. link: window.location.origin + "/g2workweb/fromMessage.html?userid=" + self.mainSend.USERID + "&&openPage=" + res.data + "&dotype=" + self.dotype + "&type=" + self.get_type + "&&PKID=FZF08&&CNAME=发文管理"
  856. }
  857. $http.post(apiurljs.login + "g2app/message/sendEmailMessage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  858. .success(function (obj) {
  859. var res = strToJson(s4.decryptData_CBC(obj.data));
  860. if (res.data.status == 200) {
  861. sp.dialog("发送成功!");
  862. $timeout(function () {
  863. window.location.href = "../list.html?lastReturnPageno=" + sp.getUrlName("lastReturnPageno")
  864. }, 1500)
  865. } else {
  866. sp.dialog(res.message)
  867. }
  868. })
  869. } else {
  870. sp.dialog(res.message)
  871. }
  872. })
  873. } else {
  874. var n = 0;
  875. $.each(self.copySend, function (index, item) {
  876. var data = {
  877. acceptuserid: item.USERID,
  878. flowid: "AA18",
  879. routeinfoid: self.routeinfoid
  880. }
  881. $http.post(apiurljs.login + "g2app/message/queryDataTodoFilen", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  882. .success(function (obj) {
  883. var res = strToJson(s4.decryptData_CBC(obj.data));
  884. if (res.success) {
  885. var data = {
  886. users: item.UINPUTNAME,
  887. title: "你有一份新邮件",
  888. subtitle: self.data.BT,
  889. content: "请及时处理",
  890. link: window.location.origin + "/g2workweb/fromMessage.html?userid=" + item.USERID + "&&openPage=" + res.data + "&dotype=" + self.dotype + "&type=" + self.get_type + "&&PKID=FZF08&&CNAME=发文管理"
  891. }
  892. $http.post(apiurljs.login + "g2app/message/sendEmailMessage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  893. .success(function (obj) {
  894. var res = strToJson(s4.decryptData_CBC(obj.data));
  895. if (res.data.status == 200) {
  896. n++
  897. } else {
  898. sp.dialog(res.message);
  899. return false
  900. }
  901. })
  902. } else {
  903. sp.dialog(res.message);
  904. return false
  905. }
  906. })
  907. })
  908. if (n == self.copySend.length) {
  909. sp.dialog("发送成功!");
  910. $timeout(function () {
  911. window.location.href = "../list.html?lastReturnPageno=" + sp.getUrlName("lastReturnPageno")
  912. }, 1500)
  913. }
  914. }
  915. } else {
  916. sp.dialog("发送成功!");
  917. $timeout(function () {
  918. window.location.href = "../list.html?lastReturnPageno=" + sp.getUrlName("lastReturnPageno")
  919. }, 1500)
  920. }
  921. } else {
  922. sp.dialog(res.message)
  923. }
  924. })
  925. }
  926. }
  927. //查看流转记录
  928. self.RouteList = function () {
  929. $(".sp-page-center").hide();
  930. var data = {
  931. directionid: self.directionid,
  932. userid: self.userId,
  933. routeid: self.routeid,
  934. routeinfoid: self.routeinfoid,
  935. }
  936. $http.post(apiurljs.login + "g2app/abase/queryDataRouteList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  937. .success(function (obj) {
  938. var res = strToJson(s4.decryptData_CBC(obj.data));
  939. self.routeList = res.data;
  940. $.each(self.routeList, function (index, item) {
  941. $.each(item.USERS, function (index1, item1) {
  942. if (item1.KIND == 0) {
  943. item.mainUser = [];
  944. item.mainUser.push(item1.USERNAME);
  945. item.mainUser = item.mainUser.join(",");
  946. } else if (item1.KIND == 1) {
  947. item.copyUsers = [];
  948. item.copyUsers.push(item1.USERNAME)
  949. item.copyUsers = item.copyUsers.join(",");
  950. } else {
  951. item.mainUser = [];
  952. item.mainUser.push(item1.USERNAME);
  953. item.mainUser = item.mainUser.join(",");
  954. }
  955. })
  956. })
  957. $time(function (item) {
  958. sp.layer("#RouteList");
  959. }, 100);
  960. })
  961. }
  962. //头部下滚冻结
  963. $(function () {
  964. $(".sp-page-center").css("max-height", $(window).height() - 58).css("height", $(window).height() - 58)
  965. //页面高度撑满
  966. setTimeout(function () {
  967. if ($(".ibox-content").height() < $(window).height() - 31) {
  968. $(".ibox-content").css("height", $(window).height() - 31)
  969. }
  970. }, 1)
  971. $(".sp-bgMask").bind("click", function () {
  972. $('.sp-page-center').show(); $('.Browse').attr('src', $('.Browse').attr('src'));
  973. });
  974. })
  975. }])