fawenfile.js 42 KB

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