fawenfile.js 42 KB

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