formedit.js 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008
  1. 'use strict';
  2. var app = angular.module('app', [
  3. ]);
  4. app.controller("formeditCtrl", ["$scope", "$http", "$timeout", '$sce', function ($scope, $http, $timeout, $sce) {
  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.copyrightid = sp.getUrlName("copyrightid");
  13. self.directionid = sp.getUrlName("directionid");
  14. self.formeditid = sp.getUrlName("formeditid");
  15. self.mbid = sp.getUrlName("mbid");
  16. self.fjid = sp.getUrlName("fjid");
  17. self.docmode = sp.getUrlName("docmode");
  18. self.dotype = sp.getUrlName("dotype");
  19. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  20. self.get_lastReturnPage = sp.getUrlName("lastReturnPage");
  21. self.get_type = sp.getUrlName("type");
  22. self.return = "../list.html?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type
  23. self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  24. var postCfg = {
  25. headers: {
  26. 'Content-Type': 'application/json',
  27. 'Authorization': "Bearer " + self.get_AccessToken
  28. }
  29. };
  30. self.FormTitle = $.cookie("GlWorkPlatform-SYSNAME");
  31. var uploadformat = strToJson(s4.decryptData_CBC(apiurljs.uploadformat)).data.map(function (item) {
  32. return item.CNAME
  33. })
  34. self.arrayFile = null;
  35. self.arrayFile1 = [];
  36. self.uploading_zw = false;
  37. self.uploading = false;
  38. self.upload_zw = function () {
  39. $('#fileupload-zw').fileupload({
  40. url: apiurljs.login + 'g2app/abase/uploadFileWithForm',
  41. dataType: 'json',
  42. beforeSend: function (xhr, data) {
  43. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  44. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=FILE_ATTACH,routeinfoid=" + self.routeinfoid + ",ATTACHTYPE=规范性文件清理督办-正文"));
  45. },
  46. add: function (e, data) {
  47. var num = 0;
  48. var acceptFileTypes = eval('/(' + uploadformat.join("|") + ')$/i')
  49. //文件类型判断
  50. $.each(data.originalFiles, function (index, item) {
  51. if (item['type'].length > 0 && !acceptFileTypes.test(item['name'])) {
  52. sp.dialog("您好,请上传" + uploadformat.join("/") + "格式的文件!");
  53. return;
  54. } else {
  55. num++
  56. }
  57. })
  58. if (num == data.originalFiles.length) {
  59. self.uploading_zw = true;
  60. data.submit();
  61. $scope.$apply();
  62. }
  63. },
  64. // 上传完成后的执行逻辑
  65. done: function (e, data) {
  66. self.uploading_zw = false;
  67. self.getOther()
  68. }
  69. })
  70. }
  71. self.upload = function () {
  72. $('#fileupload').fileupload({
  73. url: apiurljs.login + 'g2app/abase/uploadFileWithForm',
  74. dataType: 'json',
  75. beforeSend: function (xhr, data) {
  76. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  77. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=FILE_ATTACH,routeinfoid=" + self.routeinfoid + ",ATTACHTYPE=规范性文件清理督办"));
  78. },
  79. add: function (e, data) {
  80. var num = 0;
  81. var acceptFileTypes = eval('/(' + uploadformat.join("|") + ')$/i')
  82. //文件类型判断
  83. $.each(data.originalFiles, function (index, item) {
  84. if (item['type'].length > 0 && !acceptFileTypes.test(item['name'])) {
  85. sp.dialog("您好,请上传" + uploadformat.join("/") + "格式的文件!");
  86. return;
  87. } else {
  88. num++
  89. }
  90. })
  91. if (num == data.originalFiles.length) {
  92. self.uploading = true;
  93. data.submit();
  94. $scope.$apply();
  95. }
  96. },
  97. // 上传完成后的执行逻辑
  98. done: function (e, data) {
  99. self.uploading = false;
  100. self.getOther()
  101. }
  102. })
  103. }
  104. self.deleteFile = function (file) {
  105. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  106. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  107. 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>";
  108. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  109. sp.openCenter(".sp-dialog");
  110. ///取消按钮
  111. $('.sp-closeDialog').click(function (event) {
  112. sp.closeCenter(".sp-dialog");
  113. event.preventDefault();
  114. event.stopPropagation();
  115. });
  116. //post消息的id
  117. $("#delDataTrue").click(function () {
  118. var data = {
  119. tablename: "FILE_ATTACH",
  120. id: file.ID
  121. };
  122. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  123. .success(function (obj) {
  124. var res = strToJson(s4.decryptData_CBC(obj.data));
  125. sp.dialoghide();
  126. if (res.success) {
  127. self.getOther();
  128. } else {
  129. sp.dialog("删除失败,请联系管理员!");
  130. }
  131. });
  132. });
  133. }
  134. self.goAttach = function (obj) {
  135. if (obj) {
  136. if (apiurljs.zhType.indexOf(obj.FILEEXT) == -1) {
  137. sp.dialog("文件暂不支持在线预览,请点击下载查看!")
  138. return
  139. }
  140. $("#attachlist")[0].contentWindow.openFile(obj)
  141. if ($(".fa-chevron-down").is(":hidden") == true) {
  142. showToggle(document.getElementById("toggleButton"))
  143. }
  144. } else {
  145. $("#attachlist").attr("src", "attachlist.html?page=formedit&routeinfoid=" + self.routeinfoid)
  146. }
  147. }
  148. //初始化只读数组
  149. self.readonly = {
  150. WJBT: false,
  151. YFRQ: false,
  152. WJH: false,
  153. SXRQ: false,
  154. WJLX: false,
  155. FZRQ: false,
  156. SFYY: false,
  157. QLYJ: false,
  158. ZECS: false,
  159. XZBM: false
  160. }
  161. //初始化右上角按钮
  162. self.buttonList = []
  163. self.getSwenList = function (n) {
  164. self.SwenList = [];
  165. var data = {
  166. directionid: self.directionid,
  167. userid: self.userId,
  168. routeinfoid: self.routeinfoid,
  169. routeid: self.routeid,
  170. formeditid: ""
  171. }
  172. $http.post(apiurljs.login + "g2app/abase/queryDataLink", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  173. .success(function (obj) {
  174. var res = strToJson(s4.decryptData_CBC(obj.data));
  175. if (self.copyrightid == "") {
  176. self.copyrightid = res.data.LINKS[0].COPYRIGHTID
  177. }
  178. $.each(res.data.LINKS, function (index, item) {
  179. if (item.TEMPFORM.indexOf("formedit.html") > -1) {
  180. self.Title = item.VNAME;
  181. }
  182. if (item.TEMPFORM.indexOf("?docmode") > 0) {
  183. if (item.TEMPFORM.indexOf("attachlist") > -1) {
  184. item.TEMPFORM = item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  185. } else {
  186. item.TEMPFORM = "../" + item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  187. }
  188. } else {
  189. item.TEMPFORM = "#";
  190. }
  191. self.SwenList.push(item)
  192. })
  193. if (n == 0) {
  194. self.getFLOW()
  195. } else {
  196. self.getData()
  197. }
  198. })
  199. }
  200. self.getSwenList(0)
  201. self.getFLOW = function () {
  202. var data = {
  203. copyrightid: self.copyrightid
  204. }
  205. $http.post(apiurljs.login + "g2work/flow/queryDataByCopyrightid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  206. .success(function (obj) {
  207. var res = strToJson(s4.decryptData_CBC(obj.data));
  208. self.flowTitle = res.data.CNAME;
  209. self.getWJLX()
  210. })
  211. }
  212. self.getWJLX = function () {
  213. var data = {
  214. ckey: "CODE_WJLX",
  215. routeinfoid: self.routeinfoid
  216. }
  217. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  218. .success(function (obj) {
  219. var res = strToJson(s4.decryptData_CBC(obj.data));
  220. self.WJLX = res.data.CODE_WJLX;
  221. self.getSFYY()
  222. })
  223. }
  224. self.getSFYY = function () {
  225. var data = {
  226. ckey: "CODE_SFYY",
  227. routeinfoid: self.routeinfoid
  228. }
  229. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  230. .success(function (obj) {
  231. var res = strToJson(s4.decryptData_CBC(obj.data));
  232. self.SFYY = res.data.CODE_SFYY;
  233. self.getData()
  234. })
  235. }
  236. //获取数据
  237. self.getData = function () {
  238. var data = {
  239. ckey: "SX_GFXWJQLDB",
  240. id: 0,
  241. directionid: self.directionid,
  242. formeditid: self.formeditid,
  243. routeid: self.routeid,
  244. routeinfoid: self.routeinfoid
  245. }
  246. $http.post(apiurljs.login + "g2app/abase/queryData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  247. .success(function (obj) {
  248. var res = strToJson(s4.decryptData_CBC(obj.data));
  249. self.data = {
  250. ID: res.data.SX_GFXWJQLDB.ID,
  251. APPCODE: res.data.SX_GFXWJQLDB.APPCODE,
  252. WJBT: res.data.SX_GFXWJQLDB.WJBT,
  253. YFRQ: res.data.SX_GFXWJQLDB.YFRQ == "" ? sp.format(sp.getLocalDate()) : sp.format(res.data.SX_GFXWJQLDB.YFRQ),
  254. WJH: res.data.SX_GFXWJQLDB.WJH,
  255. SXRQ: res.data.SX_GFXWJQLDB.SXRQ == "" ? sp.format(sp.getLocalDate()) : sp.format(res.data.SX_GFXWJQLDB.SXRQ),
  256. WJLX: res.data.SX_GFXWJQLDB.WJLX == "" ? self.WJLX[0].CODE : res.data.SX_GFXWJQLDB.WJLX,
  257. FZRQ: res.data.SX_GFXWJQLDB.FZRQ == "" ? sp.format(sp.getLocalDate()) : sp.format(res.data.SX_GFXWJQLDB.FZRQ),
  258. SFYY: res.data.SX_GFXWJQLDB.SFYY == "" ? self.SFYY[0].CODE : res.data.SX_GFXWJQLDB.SFYY,
  259. QLYJ: res.data.SX_GFXWJQLDB.QLYJ,
  260. ZECS: res.data.SX_GFXWJQLDB.ZECS,
  261. XZBM: res.data.SX_GFXWJQLDB.XZBM
  262. }
  263. self.readonly = {
  264. WJBT: res.data.SX_GFXWJQLDB["WJBT.EREADONLY"] == "true",
  265. YFRQ: res.data.SX_GFXWJQLDB["YFRQ.EREADONLY"] == "true",
  266. WJH: res.data.SX_GFXWJQLDB["WJH.EREADONLY"] == "true",
  267. SXRQ: res.data.SX_GFXWJQLDB["SXRQ.EREADONLY"] == "true",
  268. WJLX: res.data.SX_GFXWJQLDB["WJLX.EREADONLY"] == "true",
  269. FZRQ: res.data.SX_GFXWJQLDB["FZRQ.EREADONLY"] == "true",
  270. SFYY: res.data.SX_GFXWJQLDB["SFYY.EREADONLY"] == "true",
  271. QLYJ: res.data.SX_GFXWJQLDB["QLYJ.EREADONLY"] == "true",
  272. ZECS: res.data.SX_GFXWJQLDB["ZECS.EREADONLY"] == "true",
  273. XZBM: res.data.SX_GFXWJQLDB["XZBM.EREADONLY"] == "true"
  274. }
  275. if (self.data.ID == 0) {
  276. self.filedChange = true;
  277. } else {
  278. self.filedChange = false;
  279. }
  280. self.buttonList = res.data["SX_GFXWJQLDB.FUNCLIST"];
  281. self.getOpinion('QLYJ')
  282. self.getOpinion1()
  283. self.getOther()
  284. //watermark({
  285. // "watermarl_element": "app",
  286. // "watermark_txt": "测试水印内容",
  287. // "watermark_width": 150,
  288. // "watermark_height": 110,
  289. // "watermark_angle": 345
  290. //})
  291. })
  292. }
  293. //获取附件和插件
  294. self.getOther = function () {
  295. var data = {
  296. tablename: "FILE_ATTACH",
  297. colums: "*",
  298. order: "ID asc",
  299. sqlwhere: { ROUTEINFOID: self.routeinfoid },
  300. sqlinwhere: "",
  301. sqllikewhere: ""
  302. }
  303. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  304. .success(function (obj) {
  305. var res = strToJson(s4.decryptData_CBC(obj.data));
  306. self.arrayFile1 = [];
  307. if (res.data.length > 0) {
  308. res.data.forEach(function (item) {
  309. if (item.ATTACHTYPE.indexOf("-正文") > -1) {
  310. self.arrayFile = item;
  311. } else {
  312. self.arrayFile1.push(item)
  313. }
  314. })
  315. }
  316. self.goAttach()
  317. })
  318. }
  319. //获取意见
  320. self.getOpinion = function (str) {
  321. var data = {
  322. cmanid: self.userId,
  323. routeinfoid: self.routeinfoid,
  324. routeid: "",//self.routeid,
  325. tableid: "SX_GFXWJQLDB",
  326. colid: str,
  327. opiniontype: 0,
  328. orderbycol: "CDATE desc"
  329. }
  330. $http.post(apiurljs.login + "g2app/abase/queryDataOpinionWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  331. .success(function (obj) {
  332. var res = strToJson(s4.decryptData_CBC(obj.data));
  333. if (res.success == true) {
  334. self.YJ[str] = res.data;
  335. self.YJ[str + "STATUS"] = false;
  336. self.YJ[str].forEach(function (item) {
  337. item.CDATE = sp.datefmt("yyyy-MM-dd", item.CDATE);
  338. if (item.ROUTEID == self.routeid) {
  339. self.YJ[str + "STATUS"] = true;
  340. }
  341. })
  342. } else {
  343. sp.dialog(res.message)
  344. }
  345. })
  346. }
  347. //获取意见(不上表)
  348. self.opiniontype = 99;
  349. self.getOpinion1 = function () {
  350. var data = {
  351. cmanid: self.userId,
  352. routeinfoid: self.routeinfoid,
  353. routeid: "",//self.routeid,
  354. tableid: "SX_GFXWJQLDB",
  355. colid: "",
  356. opiniontype: self.opiniontype,
  357. orderbycol: "CDATE desc"
  358. }
  359. $http.post(apiurljs.login + "g2app/abase/queryDataOpinionWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  360. .success(function (obj) {
  361. var res = strToJson(s4.decryptData_CBC(obj.data));
  362. if (res.success == true) {
  363. self.YJ.nulla = res.data;
  364. console.log(res.data)
  365. self.YJ.nullaSTATUS = false;
  366. self.YJ.nulla.forEach(function (item) {
  367. item.CDATE = sp.datefmt("yyyy-MM-dd", item.CDATE);
  368. //if (item.ROUTEID == self.routeid && item.COLID == "") {
  369. // self.YJ.nullaSTATUS = true;
  370. //}
  371. })
  372. } else {
  373. sp.dialog(res.message)
  374. }
  375. })
  376. }
  377. //判断页面字段是否只读readonly、是否隐藏show
  378. self.hide = function (type, field) {
  379. if (self.dotype == 0 && type == "readonly") {
  380. return true;
  381. } else {
  382. if (self[type][field] == true) {
  383. return true;
  384. } else {
  385. return false;
  386. }
  387. }
  388. }
  389. //右上角按钮调用方法
  390. self.btnEvent = function (item) {
  391. switch (item.CODE) {
  392. case "SAVEITEM": self.btnSave(0); break;
  393. case "PRINTITEM": self.btnPrint(); break;
  394. case "MEETITEM": self.Meet(); break;
  395. case "SENDLOG": self.RouteList(); break;
  396. default: self.forward(item); break;
  397. }
  398. }
  399. self.openUserList = function (str) {
  400. if (self.hide("readonly", str) == true) {
  401. return
  402. } else {
  403. self.filed = str;
  404. //self.AllChecked[self.filed] = false;
  405. sp.layer("#userList")
  406. $("#userList .sp-page").eq(0).scrollTop(0);
  407. }
  408. }
  409. self.checkAllUser = function () {
  410. self.AllChecked[self.filed] = !self.AllChecked[self.filed];
  411. $.each(self.UserList[self.filed], function (index, item) {
  412. item.checked = self.AllChecked[self.filed];
  413. $.each(item.USER, function (index1, item1) {
  414. item1.checked = self.AllChecked[self.filed];
  415. })
  416. })
  417. self.submitUserList(1)
  418. }
  419. self.checkUserItem = function (item) {
  420. item.checked = !item.checked;
  421. $.each(item.USER, function (index, item1) {
  422. item1.checked = item.checked;
  423. })
  424. var n = 0;
  425. $.each(self.UserList[self.filed], function (index, item) {
  426. if (item.checked == true) {
  427. n++
  428. }
  429. })
  430. if (n == self.UserList[self.filed].length) {
  431. self.AllChecked[self.filed] = true;
  432. } else {
  433. self.AllChecked[self.filed] = false;
  434. }
  435. self.submitUserList(1)
  436. }
  437. self.checkUser = function (item) {
  438. item.checked = !item.checked;
  439. var n = [], all = 0;
  440. $.each(self.UserList[self.filed], function (x, y) {
  441. n.push(0);
  442. $.each(y.USER, function (x1, y1) {
  443. if (y1.checked == true) {
  444. n[x]++
  445. }
  446. })
  447. if (n[x] == y.USER.length && n[x] != 0) {
  448. y.checked = true;
  449. all++
  450. } else {
  451. y.checked = false;
  452. }
  453. })
  454. if (all == self.UserList[self.filed].length) {
  455. self.AllChecked[self.filed] = true;
  456. } else {
  457. self.AllChecked[self.filed] = false;
  458. }
  459. self.submitUserList(1)
  460. }
  461. self.submitUserList = function (n) {
  462. var AllCheckedLength = 0;
  463. self.selectList[self.filed] = [];
  464. $.each(self.UserList[self.filed], function (index, item) {
  465. $.each(item.USER, function (index1, item1) {
  466. if (item1.checked == true) {
  467. AllCheckedLength++;
  468. self.selectList[self.filed].push(item1)
  469. }
  470. })
  471. })
  472. self.data[self.filed] = self.selectList[self.filed].map(function (item) {
  473. return item.USHOWNAME
  474. }).join(",")
  475. if (self.data[self.filed + "ID"] != undefined) {
  476. self.data[self.filed + "ID"] = self.selectList[self.filed].map(function (item) {
  477. return item.USERID
  478. }).join(",")
  479. }
  480. self.AllChecked[self.filed] = AllCheckedLength == self.UserLength[self.filed];
  481. self.changeFiled(self.filed)
  482. if (n == 0) {
  483. sp.layerhide();
  484. }
  485. }
  486. //保存提交
  487. self.btnSave = function (n) {
  488. if (spngvld.submit(".sp-page-center")) {
  489. var dataArray = [];
  490. self.dataQLYJ = "";
  491. dataArray.push(self.data);
  492. var data = {
  493. ckey: "SX_GFXWJQLDB",
  494. id: self.data.ID,
  495. routeid: self.routeid,
  496. routeinfoid: self.routeinfoid,
  497. routeinfotitle: self.data.WJBT.replace(/\n/g, '').replace(/\s/g, ''),//self.data.TITLE,
  498. directionid: self.directionid,
  499. formeditid: self.formeditid,
  500. data: JSON.stringify(dataArray)
  501. }
  502. $http.post(apiurljs.login + "g2app/abase/saveData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  503. .success(function (obj) {
  504. var res = strToJson(s4.decryptData_CBC(obj.data));
  505. if (res.code == 0) {
  506. self.data.ID = res.data.ID;
  507. self.routeid = res.data.ROUTEID;
  508. self.routeinfoid = res.data.ROUTEINFOID;
  509. self.filedChange = false;
  510. if (n == 0) {
  511. sp.dialog("保存成功!");
  512. $timeout(function () {
  513. sp.dialoghide()
  514. }, 1500)
  515. self.getSwenList(1)
  516. } else if (n == 1) {
  517. self.forward(self.btnItem);
  518. } else {
  519. self.sendAll();
  520. }
  521. } else {
  522. sp.dialog(res.message)
  523. }
  524. })
  525. }
  526. }
  527. //打印
  528. self.btnPrint = function () {
  529. // 创建隐藏的可下载链接
  530. var eleLink = document.createElement('a');
  531. eleLink.download = "";
  532. eleLink.style.display = 'none';
  533. eleLink.href = apiurljs.login + "g2app/shouwen/PrintWord?data=" + encodeURIComponent(s4.encryptData_CBC("templatefilename=DCDBGWYQ.ftl&tablename=SX_GFXWJQLDB&outfilepath=/tmp/规范性文件清理督办.wps&prtdate=LWRQ,YDBSX,SQYQSJ&routeinfoid=" + self.routeinfoid));
  534. // 触发点击
  535. document.body.appendChild(eleLink);
  536. eleLink.click();
  537. // 然后移除
  538. document.body.removeChild(eleLink);
  539. //window.open(apiurljs.login + "g2app/shouwen/PrintWord?templatefilename=shouwen.ftl&tablename=SX_GFXWJQLDB&outfilepath=" + apiurljs.print + "&routeinfoid=" + self.routeinfoid)
  540. }
  541. //签写意见编辑状态
  542. self.opinion = {
  543. QLYJ: false,
  544. QLYJImg: false,
  545. nulla: false
  546. }
  547. self.YJ = {
  548. QLYJ: [],
  549. QLYJSTATUS: false,
  550. nulla: [],
  551. nullaSTATUS: false
  552. }
  553. //意见(下表)
  554. self.openOptionList = function () {
  555. if (self.routeinfoid == 0 && self.routeid == 0) {
  556. sp.dialog("请先保存!")
  557. return;
  558. }
  559. if (self.opinion.nulla == true) {
  560. return;
  561. }
  562. self.nulla = "";
  563. $(".optionList").css("height", 149)
  564. self.opinion.nulla = true;
  565. }
  566. self.closeOptionList = function () {
  567. $(".optionList").css("height", 389)
  568. self.opinion.nulla = false;
  569. }
  570. self.submitOptionList = function () {
  571. var data = {
  572. cmanid: self.userId,
  573. routeinfoid: self.routeinfoid,
  574. routeid: self.routeid,
  575. tableid: "SX_GFXWJQLDB",
  576. colid: "",
  577. opiniontype: 99,
  578. cresult: "",
  579. opinion: self.nulla,
  580. opinionimage: ""
  581. }
  582. $http.post(apiurljs.login + "g2app/abase/saveDataOpinion", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  583. .success(function (obj) {
  584. var res = strToJson(s4.decryptData_CBC(obj.data));
  585. if (res.success == true) {
  586. self.getOpinion1();
  587. self.opinion.nulla = false;
  588. $(".optionList").css("height", 389)
  589. } else {
  590. sp.dialog(res.message)
  591. }
  592. })
  593. }
  594. self.changeOptionList = function (item) {
  595. self.nulla = item.OPINION;
  596. self.opinion.nulla = true;
  597. }
  598. //意见附件(下表)
  599. self.uploading1 = false;
  600. self.upload1 = function () {
  601. $('#fileupload1').fileupload({
  602. url: apiurljs.login + 'g2app/abase/UploadWholeFileWithRouteAttach',
  603. dataType: 'json',
  604. beforeSend: function (xhr, data) {
  605. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  606. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SYS_ROUTE_ATTACHLIST,userid=" + self.userId + ",routeinfoid=" + self.routeinfoid
  607. + ",routeid=" + self.routeid + ",tableid=SX_GFXWJQLDB"));
  608. },
  609. // 上传完成后的执行逻辑
  610. done: function (e, data) {
  611. self.uploading1 = false;
  612. self.getOpinion1()
  613. }
  614. })
  615. }
  616. //下载意见表附件
  617. self.downLoadOption = function (item) {
  618. window.open(apiurljs.login + "g2work/files/" + item.FILEPATH.slice(7))
  619. }
  620. //删除意见表附件
  621. self.deleteOptionFile = function (file, str) {
  622. var data = {
  623. routeid: file.ROUTEID,
  624. tableid: "SX_GFXWJQLDB",
  625. colid: str,
  626. fileid: file.FILEID
  627. };
  628. $http.post(apiurljs.login + "g2app/abase/deleteDataOpinionWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  629. .success(function (obj) {
  630. var res = strToJson(s4.decryptData_CBC(obj.data));
  631. sp.dialoghide();
  632. if (res.success) {
  633. if (str != "") {
  634. self.getOpinion(str);
  635. } else {
  636. self.getOpinion1();
  637. }
  638. } else {
  639. sp.dialog("删除失败,请联系管理员!");
  640. }
  641. });
  642. }
  643. //意见附件(上表)
  644. self.upload2 = function (str) {
  645. $('#fileupload-' + str).fileupload({
  646. url: apiurljs.login + 'g2app/abase/UploadWholeFileWithRouteAttach',
  647. dataType: 'json',
  648. beforeSend: function (xhr, data) {
  649. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  650. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SYS_ROUTE_ATTACHLIST,userid=" + self.userId + ",routeinfoid=" + self.routeinfoid
  651. + ",routeid=" + self.routeid + ",tableid=SX_GFXWJQLDB,colid=" + str));
  652. },
  653. // 上传完成后的执行逻辑
  654. done: function (e, data) {
  655. self.uploading1 = false;
  656. self.getOpinion(str)
  657. }
  658. })
  659. }
  660. //签写意见
  661. self.openOpinion = function (str) {
  662. if (self.routeinfoid == 0 && self.routeid == 0) {
  663. sp.dialog("请先保存!")
  664. return;
  665. }
  666. self.opinion[str] = true;
  667. }
  668. //修改意见
  669. self.changeOpinion = function (str) {
  670. self.data[str] = self.YJ[str][0].OPINION;
  671. self.opinion[str] = true;
  672. }
  673. self.changeOpinionItem = function (str, item) {
  674. if (item.OPINIONIMAGE != "") {
  675. self.QianZi(str);
  676. self.opinion[str + "Img"] = true;
  677. }
  678. self.data[str] = item.OPINION;
  679. self.opinion[str] = true;
  680. }
  681. //提交意见
  682. self.Sopinion = function (str) {
  683. if (self.opinion[str + "Img"] == true) {
  684. self.data[str] = $("#" + str + "QZ").find("canvas")[0].toDataURL();
  685. } else {
  686. self.data[str] = $("#" + str).val();
  687. }
  688. var data = {
  689. cmanid: self.userId,
  690. routeinfoid: self.routeinfoid,
  691. routeid: self.routeid,
  692. tableid: "SX_GFXWJQLDB",
  693. colid: str,
  694. opiniontype: 0,
  695. cresult: "",
  696. opinion: self.opinion[str + "Img"] == false ? self.data[str] : "",
  697. opinionimage: self.opinion[str + "Img"] == true ? self.data[str] : ""
  698. }
  699. $http.post(apiurljs.login + "g2app/abase/saveDataOpinion", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  700. .success(function (obj) {
  701. var res = strToJson(s4.decryptData_CBC(obj.data));
  702. if (res.success == true) {
  703. sp.dialog("保存成功!");
  704. self.getOpinion(str);
  705. self.opinion[str] = false;
  706. self.opinion[str + "Img"] = false;
  707. self.data[str] = "";
  708. self.changeFiled(str)
  709. } else {
  710. sp.dialog(res.message)
  711. }
  712. })
  713. }
  714. //删除意见
  715. self.Dopinion = function (str, item) {
  716. var data = {
  717. cmanid: self.userId,
  718. routeid: self.routeid,
  719. tableid: "SX_GFXWJQLDB",
  720. colid: str,
  721. }
  722. $http.post(apiurljs.login + "g2app/abase/deleteDataOpinion", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  723. .success(function (obj) {
  724. var res = strToJson(s4.decryptData_CBC(obj.data));
  725. if (res.success == true) {
  726. if (str != "") {
  727. self.getOpinion(str);
  728. } else {
  729. self.getOpinion1();
  730. }
  731. self.changeFiled(str)
  732. } else {
  733. sp.dialog(res.message)
  734. }
  735. })
  736. }
  737. self.phraseText = "";//添加常用语
  738. self.phraseList = []//常用语列表
  739. //获取常用语库
  740. self.phrase = function (colid) {
  741. sp.layer("#phrase");
  742. self.colid = colid;
  743. self.getPhrase();
  744. }
  745. //添加常用语到常用语库
  746. self.Aphrase = function () {
  747. if (self.phraseText == "") {
  748. return;
  749. }
  750. var data = {
  751. cmanid: self.userId,
  752. tableid: "SX_GFXWJQLDB",
  753. colid: self.colid,
  754. contents: self.phraseText
  755. }
  756. $http.post(apiurljs.login + "g2app/abase/insertDataPatterns", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  757. .success(function (obj) {
  758. var res = strToJson(s4.decryptData_CBC(obj.data));
  759. if (res.success == true) {
  760. self.phraseText = "";
  761. self.getPhrase();
  762. } else {
  763. sp.dialog(res.message)
  764. }
  765. })
  766. }
  767. //获取常用语库
  768. self.getPhrase = function () {
  769. var data = {
  770. cmanid: self.userId,
  771. tableid: "SX_GFXWJQLDB",
  772. colid: self.colid
  773. }
  774. $http.post(apiurljs.login + "g2app/abase/queryDataPatterns", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  775. .success(function (obj) {
  776. var res = strToJson(s4.decryptData_CBC(obj.data));
  777. self.phraseList = res.data;
  778. self.phraseSelect = self.phraseList[0].CONTENTS;
  779. })
  780. }
  781. //从常用语库删除
  782. self.Dphrase = function () {
  783. var id = null;
  784. $.each(self.phraseList, function (index, item) {
  785. if (item.CONTENTS == self.phraseSelect) {
  786. id = item.ID;
  787. }
  788. })
  789. var data = {
  790. id: id
  791. }
  792. $http.post(apiurljs.login + "g2app/abase/deleteDataPatterns", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  793. .success(function (obj) {
  794. var res = strToJson(s4.decryptData_CBC(obj.data));
  795. self.getPhrase();
  796. })
  797. }
  798. //常用语确认为意见
  799. self.btnPhrase = function () {
  800. if (!self.colid) {
  801. self.nulla = self.phraseSelect;
  802. } else {
  803. self.data[self.colid] = self.phraseSelect;
  804. }
  805. sp.layerhide();
  806. }
  807. //签字—手写
  808. self.QianZi = function (str) {
  809. self.opinion[str + "Img"] = true;
  810. setTimeout(function () {
  811. new lineCanvas(str + "QZ")
  812. }, 1)
  813. }
  814. //清除手写
  815. self.canvasClear = function (str) {
  816. var cxt = $("#" + str + "QZ").find("canvas")[0].getContext("2d");
  817. cxt.clearRect(0, 0, $("#" + str + "QZ").find("canvas")[0].width, $("#" + str + "QZ").find("canvas")[0].height)
  818. }
  819. //发生修改
  820. self.changeFiled = function (str) {
  821. self.filedChange = true;
  822. }
  823. //转发
  824. self.forward = function (obj) {
  825. self.btnItem = obj;
  826. if (self.filedChange == true) {
  827. self.btnSave(1)
  828. } else {
  829. $("#forwardWin").attr("src", "../../../forward/forward.html?routeid=" + self.routeid + "&routeinfoid=" + self.routeinfoid + "&copyrightid=" + self.copyrightid + "&directionid=" + self.directionid + "&formeditid=" + self.formeditid + "&codefuncbutton=" + obj.CODE + "&directionidtarget=" + obj.DIRECTIONIDTARGET + "&cookie=wenjianbg")
  830. sp.layer("#forward")
  831. }
  832. }
  833. //查看流转记录
  834. self.RouteList = function () {
  835. sp.openNewWindow("../../../forward/modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1], "流程图")
  836. }
  837. self.reSizeRow = function () {
  838. var bodybox = document.getElementById("bodyDiv");
  839. var topbox = document.getElementById("topDiv");
  840. var bottombox = document.getElementById("bottomDiv");
  841. var line = document.getElementById("lineDiv");
  842. document.getElementById("lineDiv").addEventListener("mousedown", function (event) {
  843. $(".mousemove").show()
  844. var bodyboxH = bodybox.clientHeight;
  845. var topboxH = topbox.clientHeight;
  846. var bottomboxH = bottombox.clientHeight;
  847. //var y = event.pageY - line.offsetTop;
  848. var y = event.pageY - line.clientHeight;
  849. document.addEventListener("mousemove", boxMove)
  850. function boxMove(event) {
  851. if (topboxH * 1 + (event.pageY - y) * 1 - 36 <= 45) {
  852. //
  853. } else if (bottomboxH * 1 - (event.pageY - y) * 1 - 36 <= 45) {
  854. //
  855. } else {
  856. topbox.style.height = topboxH * 1 + (event.pageY - y) * 1 - 36 + "px";
  857. //topbox.getElementsByTagName("iframe")[0].style.height = topboxH * 1 + (event.pageY - y) * 1 - 45 + "px";
  858. bottombox.style.height = bodyboxH * 1 - topboxH * 1 - (event.pageY - y) * 1 + 36 + "px";
  859. bottombox.getElementsByTagName("iframe")[0].style.height = bodyboxH * 1 - topboxH * 1 - (event.pageY - y) * 1 - 25 + "px";
  860. }
  861. }
  862. document.addEventListener("mouseup", function () {
  863. $(".mousemove").hide()
  864. document.removeEventListener("mousemove", boxMove)
  865. })
  866. })
  867. }
  868. ////头部关键字搜索---20230905
  869. self.headBtnSearchKeyword = "";
  870. self.headSearchResult = [];
  871. self.headSearchResult_view = false;
  872. self.headBtnSearch = function () {
  873. if (sp.isval(self.headBtnSearchKeyword)) {
  874. self.headSearchResult = [];
  875. var data = {
  876. "url": "/basic/api/StatSelect/selectCodeList",
  877. "data": { "keyWord": self.headBtnSearchKeyword }
  878. }
  879. //console.log(JSON.stringify(data));
  880. $http.post(apiurljs.login + "g2app/yizhangtu/selectCodeList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  881. .success(function (obj) {
  882. var res = strToJson(s4.decryptData_CBC(obj.data));
  883. //console.log(JSON.stringify(res.data));
  884. self.headSearchResult = res.data.build;
  885. if (sp.isval(self.headSearchResult)) {
  886. self.headSearchResult_view = true;
  887. } else {
  888. self.headSearchResult_view = false;
  889. }
  890. })
  891. } else {
  892. self.headSearchResult_view = false;
  893. }
  894. };
  895. self.headKeywordPage = function (itemdata) {
  896. var get_token = localStorage.getItem("main-token");
  897. var set_url = apiurljs.onePic + "wholeProcessPage/?token=" + get_token + "&name=" + itemdata.name + "&type=" + itemdata.type + "&id=" + itemdata.id;
  898. $('#attachlist')[0].contentWindow.openTool(set_url, '一张图');
  899. self.headSearchResult_view = false;
  900. };
  901. self.onePic = function () {
  902. $('#attachlist')[0].contentWindow.openTool(apiurljs.onePic + "wholeProcessPage/?token=" + localStorage.getItem("main-token"), "地图搜索")
  903. }
  904. //头部下滚冻结
  905. $(function () {
  906. $(".sp-page-center").eq(0).css("max-height", $("#topDiv").height()).css("height", $("#topDiv").height())
  907. $(".formedit center").css("height", $(".formedit center").next("div").height()).css("line-height", $(".formedit center").next("div").height() / 6 + "px")
  908. //$("body").bind("scroll", function () {
  909. // var scrollTop = $("body").scrollTop();
  910. // if (scrollTop == 0) {
  911. // $(".FixTop").removeClass("FixTop");
  912. // }
  913. // if (scrollTop > 35) {
  914. // $(".sp-page-title").parents(".sp-box").addClass("FixTop");
  915. // }
  916. //});
  917. //页面高度撑满
  918. setTimeout(function () {
  919. if ($(".ibox-content").height() < $(window).height() - 31) {
  920. $(".ibox-content").css("height", $(window).height() - 31)
  921. }
  922. $(".mousemove").css("top", 0).css("left", 0).css("width", $(window).width()).css("height", $(window).height() - 10)
  923. }, 1)
  924. })
  925. }])
  926. app.filter('trustHtml', function ($sce) {
  927. return function (input) {
  928. return $sce.trustAsHtml(input.replace(/\n/g, '<br/>').replace(/\s/g, '&nbsp;'));
  929. };
  930. });
  931. //canvas画布签字
  932. function lineCanvas(obj) {
  933. var self = this;
  934. self.linewidth = 1;
  935. self.color = "#000000";
  936. self.background = "#ffffff";
  937. self.canvas = document.createElement("canvas");
  938. document.getElementById(obj).appendChild(self.canvas);
  939. self.cxt = self.canvas.getContext("2d");
  940. self.canvas.width = document.getElementById(obj).clientWidth;
  941. self.canvas.height = document.getElementById(obj).scrollHeight;
  942. self.cxt.fillStyle = self.background;
  943. self.cxt.fillRect(0, 0, self.canvas.width, self.canvas.width);
  944. self.cxt.strokeStyle = self.color;
  945. self.cxt.lineWidth = self.linewidth;
  946. self.cxt.lineCap = "round";
  947. //开始绘制
  948. self.canvas.addEventListener("mousedown", function (e) {
  949. self.cxt.beginPath();
  950. self.cxt.lineTo(e.pageX - document.getElementById(obj).offsetLeft - 25, e.pageY - document.getElementById(obj).offsetTop + $(".sp-page-center").scrollTop() - 25);
  951. self.canvas.addEventListener("mousemove", move)
  952. }.bind(self), false);
  953. //绘制中
  954. function move() {
  955. var e = window.event;
  956. self.cxt.lineTo(e.pageX - document.getElementById(obj).offsetLeft - 25, e.pageY - document.getElementById(obj).offsetTop + $(".sp-page-center").scrollTop() - 25);
  957. self.cxt.stroke();
  958. }
  959. //结束绘制
  960. self.canvas.addEventListener("mouseup", up)
  961. function up() {
  962. self.cxt.closePath();
  963. self.canvas.removeEventListener("mousemove", move)
  964. }
  965. };
  966. var parentData = {}
  967. function getData() {
  968. parentData = angular.element(document.getElementById("app")).scope().data
  969. return parentData
  970. }
  971. function showToggle(e) {
  972. $(e).children().toggle()
  973. $(e).next().toggle()
  974. }
  975. function toggleYJL(e) {
  976. if ($(e).children(".fa-angle-double-down").is(":hidden") == true) {
  977. $("#topDiv").css("height", 160)
  978. $(e).parent().css("height", 450)
  979. $("#attachlist").css("height", 200)
  980. $("#bottomDiv").css("height", "")
  981. } else {
  982. $("#topDiv").css("height", 600)
  983. $(e).parent().css("height", 10)
  984. }
  985. $(e).children().toggle()
  986. }