formedit.js 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  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. //初始化右上角按钮
  35. self.buttonList = []
  36. self.readonly = {
  37. SZFBH: false,
  38. GMFRHQYMC: false,
  39. SQRQ: false,
  40. LXDH: false,
  41. DZYJ: false,
  42. LXDZ: false,
  43. YZBM: false,
  44. SQGKNRMS: false,
  45. SJRQ: false,
  46. CBDWBJRQ: false,
  47. DQR: false,
  48. NBYJ: false,
  49. CSZBYJ: false,
  50. HF: false,
  51. FJ: false
  52. }
  53. //上传附件
  54. self.arrayFile = [];
  55. self.beforeUpload = function () {
  56. if (self.data.ID == 0) {
  57. var dataArray = [];
  58. dataArray.push(self.data);
  59. var data = {
  60. ckey: "SX_SZFZBYFSQGKXXCBB",
  61. id: self.data.ID,
  62. routeid: self.routeid,
  63. routeinfoid: self.routeinfoid,
  64. routeinfotitle: self.data.GMFRHQYMC + "的申请",
  65. directionid: self.directionid,
  66. formeditid: self.formeditid,
  67. data: JSON.stringify(dataArray)
  68. }
  69. $http.post(apiurljs.login + "g2app/abase/saveData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  70. .success(function (obj) {
  71. var res = strToJson(s4.decryptData_CBC(obj.data));
  72. if (res.code == 0) {
  73. self.data.ID = res.data.ID;
  74. self.routeid = res.data.ROUTEID;
  75. self.routeinfoid = res.data.ROUTEINFOID;
  76. self.getSwenList(1)
  77. self.upload()
  78. } else {
  79. sp.dialog(res.message)
  80. }
  81. })
  82. } else {
  83. self.upload()
  84. }
  85. }
  86. self.upload = function () {
  87. $('#fileupload').fileupload({
  88. url: apiurljs.login + 'g2app/abase/saveUploadFileName',
  89. dataType: 'json',
  90. beforeSend: function (xhr, data) {
  91. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  92. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SX_SZFZBYFSQGKXXCBB,column=HF,routeinfoid=" + self.routeinfoid + ",loaded=" + data.loaded + ",total=" + data.total));
  93. },
  94. // 上传完成后的执行逻辑
  95. done: function (e, data) {
  96. var arrayFile = strToJson(s4.decryptData_CBC(data.result.data).slice(0, s4.decryptData_CBC(data.result.data).lastIndexOf("}") + 1))
  97. self.arrayFile = arrayFile.data;
  98. $scope.$apply();//绑定数据局部刷新
  99. }
  100. })
  101. $timeout(function () {
  102. $("#fileupload").trigger("click")
  103. }, 1)
  104. }
  105. //上传附件
  106. self.arrayFile1 = [];
  107. self.beforeUpload1 = function () {
  108. if (self.data.ID == 0) {
  109. var dataArray = [];
  110. dataArray.push(self.data);
  111. var data = {
  112. ckey: "SX_SZFZBYFSQGKXXCBB",
  113. id: self.data.ID,
  114. routeid: self.routeid,
  115. routeinfoid: self.routeinfoid,
  116. routeinfotitle: self.data.GMFRHQYMC + "的申请",
  117. directionid: self.directionid,
  118. formeditid: self.formeditid,
  119. data: JSON.stringify(dataArray)
  120. }
  121. $http.post(apiurljs.login + "g2app/abase/saveData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  122. .success(function (obj) {
  123. var res = strToJson(s4.decryptData_CBC(obj.data));
  124. if (res.code == 0) {
  125. self.data.ID = res.data.ID;
  126. self.routeid = res.data.ROUTEID;
  127. self.routeinfoid = res.data.ROUTEINFOID;
  128. self.getSwenList(1)
  129. self.upload1()
  130. } else {
  131. sp.dialog(res.message)
  132. }
  133. })
  134. } else {
  135. self.upload1()
  136. }
  137. }
  138. self.upload1 = function () {
  139. $('#fileupload1').fileupload({
  140. url: apiurljs.login + 'g2app/abase/saveUploadFileName',
  141. dataType: 'json',
  142. beforeSend: function (xhr, data) {
  143. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  144. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SX_SZFZBYFSQGKXXCBB,column=FJ,routeinfoid=" + self.routeinfoid + ",loaded=" + data.loaded + ",total=" + data.total));
  145. },
  146. // 上传完成后的执行逻辑
  147. done: function (e, data) {
  148. var arrayFile = strToJson(s4.decryptData_CBC(data.result.data).slice(0, s4.decryptData_CBC(data.result.data).lastIndexOf("}") + 1))
  149. self.arrayFile1 = arrayFile.data;
  150. $scope.$apply();//绑定数据局部刷新
  151. }
  152. })
  153. $timeout(function () {
  154. $("#fileupload1").trigger("click")
  155. }, 1)
  156. }
  157. self.goAttach = function (obj) {
  158. if (obj) {
  159. if (apiurljs.zhType.indexOf(obj.FILEEXT) == -1) {
  160. sp.dialog("文件暂不支持在线预览,请点击下载查看!")
  161. return
  162. }
  163. $("#attachlist")[0].contentWindow.openFile(obj)
  164. if ($(".fa-chevron-down").is(":hidden") == true) {
  165. showToggle(document.getElementById("toggleButton"))
  166. }
  167. } else {
  168. $("#attachlist").attr("src", "attachlist.html?page=formedit&routeinfoid=" + self.routeinfoid)
  169. }
  170. }
  171. self.getSwenList = function (n) {
  172. self.SwenList = [];
  173. var data = {
  174. directionid: self.directionid,
  175. userid: self.userId,
  176. routeinfoid: self.routeinfoid,
  177. routeid: self.routeid,
  178. formeditid: ""
  179. }
  180. $http.post(apiurljs.login + "g2app/abase/queryDataLink", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  181. .success(function (obj) {
  182. var res = strToJson(s4.decryptData_CBC(obj.data));
  183. $.each(res.data.LINKS, function (index, item) {
  184. if (item.TEMPFORM.indexOf("formedit.html") > -1) {
  185. self.Title = item.VNAME;
  186. }
  187. if (item.TEMPFORM.indexOf("?docmode") > 0) {
  188. if (item.TEMPFORM.indexOf("attachlist") > -1) {
  189. item.TEMPFORM = item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  190. } else {
  191. item.TEMPFORM = "../" + item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  192. }
  193. } else {
  194. item.TEMPFORM = "#";
  195. }
  196. self.SwenList.push(item)
  197. })
  198. self.SwenList.push({
  199. VNAME: "流程图",
  200. DIRECTIONID: self.SwenList[0].DIRECTIONID,
  201. TEMPFORM: "modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1]
  202. })
  203. if (n == 0) {
  204. self.getBHZL()
  205. } else {
  206. self.getData()
  207. }
  208. })
  209. }
  210. self.getSwenList(0)
  211. self.getBHZL = function () {
  212. var data = {
  213. ckey: "CODE_BHZL",
  214. routeinfoid: self.routeinfoid
  215. }
  216. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  217. .success(function (obj) {
  218. var res = strToJson(s4.decryptData_CBC(obj.data));
  219. self.BHZL = res.data.CODE_BHZL;
  220. self.getData()
  221. })
  222. }
  223. //获取数据
  224. self.getData = function () {
  225. var data = {
  226. ckey: "SX_SZFZBYFSQGKXXCBB",
  227. id: 0,
  228. directionid: self.directionid,
  229. formeditid: self.formeditid,
  230. routeid: self.routeid,
  231. routeinfoid: self.routeinfoid
  232. }
  233. $http.post(apiurljs.login + "g2app/abase/queryData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  234. .success(function (obj) {
  235. var res = strToJson(s4.decryptData_CBC(obj.data));
  236. self.data = {
  237. ID: res.data.SX_SZFZBYFSQGKXXCBB.ID,
  238. APPCODE: res.data.SX_SZFZBYFSQGKXXCBB.APPCODE,
  239. BH: res.data.SX_SZFZBYFSQGKXXCBB.BH,// == "" ? self.BHZL[0].CODE : res.data.SX_SZFZBYFSQGKXXCBB.BH,
  240. SZFBH: res.data.SX_SZFZBYFSQGKXXCBB.SZFBH,
  241. GMFRHQYMC: res.data.SX_SZFZBYFSQGKXXCBB.GMFRHQYMC,
  242. SQRQ: res.data.SX_SZFZBYFSQGKXXCBB.SQRQ == "" ? sp.format(sp.getLocalDate()) : sp.format(res.data.SX_SZFZBYFSQGKXXCBB.SQRQ),
  243. LXDH: res.data.SX_SZFZBYFSQGKXXCBB.LXDH,
  244. DZYJ: res.data.SX_SZFZBYFSQGKXXCBB.DZYJ,
  245. LXDZ: res.data.SX_SZFZBYFSQGKXXCBB.LXDZ,
  246. YZBM: res.data.SX_SZFZBYFSQGKXXCBB.YZBM,
  247. SQGKNRMS: res.data.SX_SZFZBYFSQGKXXCBB.SQGKNRMS,
  248. SJRQ: res.data.SX_SZFZBYFSQGKXXCBB.SJRQ == "" ? sp.format(sp.getLocalDate()) : sp.format(res.data.SX_SZFZBYFSQGKXXCBB.SJRQ),
  249. CBDWBJRQ: res.data.SX_SZFZBYFSQGKXXCBB.CBDWBJRQ == "" ? sp.format(sp.getLocalDate()) : sp.format(res.data.SX_SZFZBYFSQGKXXCBB.CBDWBJRQ),
  250. DQR: res.data.SX_SZFZBYFSQGKXXCBB.DQR == "" ? sp.format(sp.getLocalDate()) : sp.format(res.data.SX_SZFZBYFSQGKXXCBB.DQR),
  251. NBYJ: res.data.SX_SZFZBYFSQGKXXCBB.NBYJ,
  252. CSZBYJ: res.data.SX_SZFZBYFSQGKXXCBB.CSZBYJ
  253. }
  254. self.readonly = {
  255. SZFBH: res.data.SX_SZFZBYFSQGKXXCBB["SZFBH.EREADONLY"] == "true",
  256. GMFRHQYMC: res.data.SX_SZFZBYFSQGKXXCBB["GMFRHQYMC.EREADONLY"] == "true",
  257. SQRQ: res.data.SX_SZFZBYFSQGKXXCBB["SQRQ.EREADONLY"] == "true",
  258. LXDH: res.data.SX_SZFZBYFSQGKXXCBB["LXDH.EREADONLY"] == "true",
  259. DZYJ: res.data.SX_SZFZBYFSQGKXXCBB["DZYJ.EREADONLY"] == "true",
  260. LXDZ: res.data.SX_SZFZBYFSQGKXXCBB["LXDZ.EREADONLY"] == "true",
  261. YZBM: res.data.SX_SZFZBYFSQGKXXCBB["YZBM.EREADONLY"] == "true",
  262. SQGKNRMS: res.data.SX_SZFZBYFSQGKXXCBB["SQGKNRMS.EREADONLY"] == "true",
  263. SJRQ: res.data.SX_SZFZBYFSQGKXXCBB["SJRQ.EREADONLY"] == "true",
  264. CBDWBJRQ: res.data.SX_SZFZBYFSQGKXXCBB["CBDWBJRQ.EREADONLY"] == "true",
  265. DQR: res.data.SX_SZFZBYFSQGKXXCBB["DQR.EREADONLY"] == "true",
  266. NBYJ: res.data.SX_SZFZBYFSQGKXXCBB["NBYJ.EREADONLY"] == "true",
  267. CSZBYJ: res.data.SX_SZFZBYFSQGKXXCBB["CSZBYJ.EREADONLY"] == "true",
  268. HF: res.data.SX_SZFZBYFSQGKXXCBB["HF.EREADONLY"] == "true",
  269. FJ: res.data.SX_SZFZBYFSQGKXXCBB["FJ.EREADONLY"] == "true"
  270. }
  271. if (res.data.SX_SZFZBYFSQGKXXCBB.HF && res.data.SX_SZFZBYFSQGKXXCBB.HF != "") {
  272. self.arrayFile = JSON.parse(res.data.SX_SZFZBYFSQGKXXCBB.HF);
  273. }
  274. if (res.data.SX_SZFZBYFSQGKXXCBB.FJ && res.data.SX_SZFZBYFSQGKXXCBB.FJ != "") {
  275. self.arrayFile1 = JSON.parse(res.data.SX_SZFZBYFSQGKXXCBB.FJ);
  276. }
  277. if (self.data.ID == 0) {
  278. self.filedChange = true;
  279. } else {
  280. self.filedChange = false;
  281. }
  282. self.buttonList = res.data["SX_SZFZBYFSQGKXXCBB.FUNCLIST"];
  283. self.getOpinion('NBYJ')
  284. self.getOpinion('WLDSSL')
  285. //watermark({
  286. // "watermarl_element": "app",
  287. // "watermark_txt": "测试水印内容",
  288. // "watermark_width": 150,
  289. // "watermark_height": 110,
  290. // "watermark_angle": 345
  291. //})
  292. })
  293. }
  294. //获取意见
  295. self.getOpinion = function (str) {
  296. var data = {
  297. cmanid: self.userId,
  298. routeinfoid: self.routeinfoid,
  299. routeid: "",//self.routeid,
  300. tableid: "SX_SZFZBYFSQGKXXCBB",
  301. colid: str,
  302. opiniontype: 0,
  303. orderbycol: "CDATE desc"
  304. }
  305. $http.post(apiurljs.login + "g2app/abase/queryDataOpinionWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  306. .success(function (obj) {
  307. var res = strToJson(s4.decryptData_CBC(obj.data));
  308. if (res.success == true) {
  309. self.YJ[str] = res.data;
  310. self.YJ[str + "STATUS"] = false;
  311. self.YJ[str].forEach(function (item) {
  312. item.CDATE = sp.datefmt("yyyy-MM-dd HH:mm", item.CDATE);
  313. if (item.ROUTEID == self.routeid) {
  314. self.YJ[str + "STATUS"] = true;
  315. }
  316. })
  317. } else {
  318. sp.dialog(res.message)
  319. }
  320. })
  321. }
  322. //判断页面字段是否只读readonly、是否隐藏show
  323. self.hide = function (type, field) {
  324. if (self.dotype == 0 && type == "readonly") {
  325. return true;
  326. } else {
  327. if (self[type][field] == true) {
  328. return true;
  329. } else {
  330. return false;
  331. }
  332. }
  333. }
  334. //右上角按钮调用方法
  335. self.btnEvent = function (item) {
  336. switch (item.CODE) {
  337. case "SAVEITEM": self.btnSave(0); break;
  338. case "PRINTITEM": self.btnPrint(); break;
  339. case "PRINTITEMEXTEND": self.btnPrint1(); break;
  340. case "MEETITEM": self.Meet(); break;
  341. case "SENDLOG": self.RouteList(); break;
  342. default: self.forward(item); break;
  343. }
  344. }
  345. //保存提交
  346. self.btnSave = function (n) {
  347. if (spngvld.submit(".sp-page-center")) {
  348. var dataArray = [];
  349. self.data.NBYJ = "";
  350. self.data.WLDSSL = "";
  351. dataArray.push(self.data);
  352. var data = {
  353. ckey: "SX_SZFZBYFSQGKXXCBB",
  354. id: self.data.ID,
  355. routeid: self.routeid,
  356. routeinfoid: self.routeinfoid,
  357. routeinfotitle: self.data.GMFRHQYMC+"的申请",
  358. directionid: self.directionid,
  359. formeditid: self.formeditid,
  360. data: JSON.stringify(dataArray)
  361. }
  362. $http.post(apiurljs.login + "g2app/abase/saveData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  363. .success(function (obj) {
  364. var res = strToJson(s4.decryptData_CBC(obj.data));
  365. if (res.code == 0) {
  366. self.data.ID = res.data.ID;
  367. self.routeid = res.data.ROUTEID;
  368. self.routeinfoid = res.data.ROUTEINFOID;
  369. self.filedChange = false;
  370. if (n == 0) {
  371. sp.dialog("保存成功!");
  372. $timeout(function () {
  373. sp.dialoghide()
  374. }, 1500)
  375. self.getSwenList(1)
  376. } else if (n == 1) {
  377. self.forward(self.btnItem);
  378. } else {
  379. self.sendAll();
  380. }
  381. } else {
  382. sp.dialog(res.message)
  383. }
  384. })
  385. }
  386. }
  387. //打印
  388. self.btnPrint = function () {
  389. // 创建隐藏的可下载链接
  390. var eleLink = document.createElement('a');
  391. eleLink.download = "";
  392. eleLink.style.display = 'none';
  393. eleLink.href = apiurljs.login + "g2app/shouwen/PrintWord?data=" + encodeURIComponent(s4.encryptData_CBC("templatefilename=XZGZDT.ftl&tablename=SX_SZFZBYFSQGKXXCBB&outfilepath=/tmp/市政府转办依法申请公开信息承办表.wps&prtdate=RIQI&routeinfoid=" + self.routeinfoid));
  394. // 触发点击
  395. document.body.appendChild(eleLink);
  396. eleLink.click();
  397. // 然后移除
  398. document.body.removeChild(eleLink);
  399. //window.open(apiurljs.login + "g2app/shouwen/PrintWord?templatefilename=shouwen.ftl&tablename=SX_SZFZBYFSQGKXXCBB&outfilepath=" + apiurljs.print + "&routeinfoid=" + self.routeinfoid)
  400. }
  401. /*综合打印*/
  402. self.printFiled = 1;
  403. self.btnPrint1 = function () {
  404. if (self.filedChange == true) {
  405. self.btnSave(4)
  406. } else {
  407. sp.layer("#print")
  408. }
  409. }
  410. self.printSubmit = function () {
  411. if (self.printFiled == 4) {
  412. if (self.deviceType == "pad") {
  413. window.location.href = "../../../printPreview.html?url=" + apiurljs.yzFcscloud + "g2work/files2/inline/" + self.arrayFile.FILEURL.slice(7)
  414. } else {
  415. sp.openNewWindow("../../../printPreview.html?url=" + apiurljs.yzFcscloud + "g2work/files2/inline/" + self.arrayFile.FILEURL.slice(7), '打印预览')
  416. }
  417. sp.layerhide()
  418. return
  419. }
  420. if (self.printFiled == 1) {
  421. var templatefilename = "moban_szfzb"
  422. } else if (self.printFiled == 2) {
  423. var templatefilename = "mobanoption"
  424. } else {
  425. var templatefilename = "moban_szfzb_all"
  426. }
  427. var data = {
  428. templatefilename: templatefilename + ".ftl",
  429. outfilepath: "/tmp/市政府转办" + sp.datefmt('yyyyMMddHHmmss', sp.getLocalDate()) + ".wps",
  430. routeinfoid: self.routeinfoid,
  431. tablename: "SX_SZFZBYFSQGKXXCBB",
  432. printtype: self.printFiled,
  433. printdate: "SQRQ,SJRQ,CBDWBJRQ,DQR"
  434. }
  435. $http.post(apiurljs.login + "g2app/dataabase/PrintWordExtend", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  436. .success(function (obj) {
  437. var res = strToJson(s4.decryptData_CBC(obj.data));
  438. if (self.deviceType == "pad") {
  439. window.location.href = "../../../printPreview.html?url=" + apiurljs.yzFcscloud + "g2work" + res.data[0].url
  440. } else {
  441. sp.openNewWindow("../../../printPreview.html?url=" + apiurljs.yzFcscloud + "g2work" + res.data[0].url, '打印预览')
  442. }
  443. })
  444. sp.layerhide()
  445. }
  446. //下载附件
  447. self.download = function (item) {
  448. window.open(apiurljs.login + "g2work/files/" + item.FILEURL.slice(7))
  449. }
  450. //删除附件
  451. self.deleteFile = function (item, str) {
  452. var data = {
  453. tablename: "SX_SZFZBYFSQGKXXCBB",
  454. column: str,
  455. routeinfoid: self.routeinfoid,
  456. fileid: item.FILEID,
  457. filenames: item.FILEOLDNAME
  458. }
  459. $http.post(apiurljs.login + "g2app/abase/deleteUploadFileName", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  460. .success(function (obj) {
  461. var res = strToJson(s4.decryptData_CBC(obj.data));
  462. if (res.success == true) {
  463. if (str == "HF") {
  464. self.arrayFile = res.data;
  465. } else {
  466. self.arrayFile1 = res.data;
  467. }
  468. } else {
  469. sp.dialog(res.message)
  470. }
  471. })
  472. }
  473. //签写意见编辑状态
  474. self.opinion = {
  475. NBYJ: false,
  476. NBYJImg: false,
  477. CSZBYJ: false,
  478. CSZBYJImg: false
  479. }
  480. self.YJ = {
  481. NBYJ: [],
  482. NBYJSTATUS: false,
  483. CSZBYJ: [],
  484. CSZBYJSTATUS: false
  485. }
  486. //下载意见表附件
  487. self.downLoadOption = function (item) {
  488. window.open(apiurljs.login + "g2work/files/" + item.FILEPATH.slice(7))
  489. }
  490. //删除意见表附件
  491. self.deleteOptionFile = function (file, str) {
  492. var data = {
  493. routeid: file.ROUTEID,
  494. tableid: "SX_SZFZBYFSQGKXXCBB",
  495. colid: str,
  496. fileid: file.FILEID
  497. };
  498. $http.post(apiurljs.login + "g2app/abase/deleteDataOpinionWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  499. .success(function (obj) {
  500. var res = strToJson(s4.decryptData_CBC(obj.data));
  501. sp.dialoghide();
  502. if (res.success) {
  503. self.getOpinion(str);
  504. } else {
  505. sp.dialog("删除失败,请联系管理员!");
  506. }
  507. });
  508. }
  509. //意见附件(上表)
  510. self.upload2 = function (str) {
  511. $('#fileupload-' + str).fileupload({
  512. url: apiurljs.login + 'g2app/abase/UploadWholeFileWithRouteAttach',
  513. dataType: 'json',
  514. beforeSend: function (xhr, data) {
  515. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  516. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SYS_ROUTE_ATTACHLIST,userid=" + self.userId + ",routeinfoid=" + self.routeinfoid
  517. + ",routeid=" + self.routeid + ",tableid=SX_SZFZBYFSQGKXXCBB,colid=" + str));
  518. },
  519. // 上传完成后的执行逻辑
  520. done: function (e, data) {
  521. self.uploading1 = false;
  522. self.getOpinion(str)
  523. }
  524. })
  525. }
  526. //签写意见
  527. self.openOpinion = function (str) {
  528. if (self.routeinfoid == 0 && self.routeid == 0) {
  529. sp.dialog("请先保存!")
  530. return;
  531. }
  532. self.opinion[str] = true;
  533. }
  534. //修改意见
  535. self.changeOpinion = function (str) {
  536. self.data[str] = self.YJ[str][0].OPINION;
  537. self.opinion[str] = true;
  538. }
  539. self.changeOpinionItem = function (str, item) {
  540. if (item.OPINIONIMAGE != "") {
  541. self.QianZi(str);
  542. self.opinion[str + "Img"] = true;
  543. }
  544. self.data[str] = item.OPINION;
  545. self.opinion[str] = true;
  546. }
  547. //提交意见
  548. self.Sopinion = function (str) {
  549. if (self.opinion[str + "Img"] == true) {
  550. self.data[str] = $("#" + str + "QZ").find("canvas")[0].toDataURL();
  551. } else {
  552. self.data[str] = $("#" + str).val();
  553. }
  554. var data = {
  555. cmanid: self.userId,
  556. routeinfoid: self.routeinfoid,
  557. routeid: self.routeid,
  558. tableid: "SX_SZFZBYFSQGKXXCBB",
  559. colid: str,
  560. opiniontype: 0,
  561. cresult: "",
  562. opinion: self.opinion[str + "Img"] == false ? self.data[str] : "",
  563. opinionimage: self.opinion[str + "Img"] == true ? self.data[str] : ""
  564. }
  565. $http.post(apiurljs.login + "g2app/abase/saveDataOpinion", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  566. .success(function (obj) {
  567. var res = strToJson(s4.decryptData_CBC(obj.data));
  568. if (res.success == true) {
  569. sp.dialog("保存成功!");
  570. self.getOpinion(str);
  571. self.opinion[str] = false;
  572. self.opinion[str + "Img"] = false;
  573. self.data[str] = "";
  574. self.changeFiled(str)
  575. } else {
  576. sp.dialog(res.message)
  577. }
  578. })
  579. }
  580. //删除意见
  581. self.Dopinion = function (str, item) {
  582. var data = {
  583. cmanid: self.userId,
  584. routeid: self.routeid,
  585. tableid: "SX_SZFZBYFSQGKXXCBB",
  586. colid: str,
  587. }
  588. $http.post(apiurljs.login + "g2app/abase/deleteDataOpinion", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  589. .success(function (obj) {
  590. var res = strToJson(s4.decryptData_CBC(obj.data));
  591. if (res.success == true) {
  592. self.getOpinion(str);
  593. self.changeFiled(str)
  594. } else {
  595. sp.dialog(res.message)
  596. }
  597. })
  598. }
  599. self.phraseText = "";//添加常用语
  600. self.phraseList = []//常用语列表
  601. //获取常用语库
  602. self.phrase = function (colid) {
  603. sp.layer("#phrase");
  604. self.colid = colid;
  605. self.getPhrase();
  606. }
  607. //添加常用语到常用语库
  608. self.Aphrase = function () {
  609. if (self.phraseText == "") {
  610. return;
  611. }
  612. var data = {
  613. cmanid: self.userId,
  614. tableid: "SX_SZFZBYFSQGKXXCBB",
  615. colid: self.colid,
  616. contents: self.phraseText
  617. }
  618. $http.post(apiurljs.login + "g2app/abase/insertDataPatterns", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  619. .success(function (obj) {
  620. var res = strToJson(s4.decryptData_CBC(obj.data));
  621. if (res.success == true) {
  622. self.phraseText = "";
  623. self.getPhrase();
  624. } else {
  625. sp.dialog(res.message)
  626. }
  627. })
  628. }
  629. //获取常用语库
  630. self.getPhrase = function () {
  631. var data = {
  632. cmanid: self.userId,
  633. tableid: "SX_SZFZBYFSQGKXXCBB",
  634. colid: self.colid
  635. }
  636. $http.post(apiurljs.login + "g2app/abase/queryDataPatterns", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  637. .success(function (obj) {
  638. var res = strToJson(s4.decryptData_CBC(obj.data));
  639. self.phraseList = res.data;
  640. self.phraseSelect = self.phraseList[0].CONTENTS;
  641. })
  642. }
  643. //从常用语库删除
  644. self.Dphrase = function () {
  645. var id = null;
  646. $.each(self.phraseList, function (index, item) {
  647. if (item.CONTENTS == self.phraseSelect) {
  648. id = item.ID;
  649. }
  650. })
  651. var data = {
  652. id: id
  653. }
  654. $http.post(apiurljs.login + "g2app/abase/deleteDataPatterns", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  655. .success(function (obj) {
  656. var res = strToJson(s4.decryptData_CBC(obj.data));
  657. self.getPhrase();
  658. })
  659. }
  660. //常用语确认为意见
  661. self.btnPhrase = function () {
  662. if (!self.colid) {
  663. self.nulla = self.phraseSelect;
  664. } else {
  665. self.data[self.colid] = self.phraseSelect;
  666. }
  667. sp.layerhide();
  668. }
  669. //签字—手写
  670. self.QianZi = function (str) {
  671. self.opinion[str + "Img"] = true;
  672. $timeout(function () {
  673. new lineCanvas(str + "QZ")
  674. }, 1)
  675. }
  676. //清除手写
  677. self.canvasClear = function (str) {
  678. var cxt = $("#" + str + "QZ").find("canvas")[0].getContext("2d");
  679. cxt.clearRect(0, 0, $("#" + str + "QZ").find("canvas")[0].width, $("#" + str + "QZ").find("canvas")[0].height)
  680. }
  681. //发生修改
  682. self.changeFiled = function (str) {
  683. self.filedChange = true;
  684. }
  685. //转发
  686. self.forward = function (obj) {
  687. self.btnItem = obj;
  688. if (self.filedChange == true) {
  689. self.btnSave(1)
  690. } else {
  691. $("#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=gongkaishi")
  692. sp.layer("#forward")
  693. }
  694. }
  695. //查看流转记录
  696. self.RouteList = function () {
  697. if (self.deviceType == "pad") {
  698. window.location.href = "../../forward/modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1]
  699. } else {
  700. sp.openNewWindow("../../forward/modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1], "流程图")
  701. }
  702. //var data = {
  703. // directionid: self.directionid,
  704. // userid: self.userId,
  705. // routeid: self.routeid,
  706. // routeinfoid: self.routeinfoid,
  707. //}
  708. //$http.post(apiurljs.login + "g2app/abase/queryDataRouteList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  709. //.success(function (obj) {
  710. // var res = strToJson(s4.decryptData_CBC(obj.data));
  711. // self.routeList = res.data;
  712. // $.each(self.routeList, function (index, item) {
  713. // item.mainUser = [];
  714. // item.copyUsers = [];
  715. // $.each(item.USERS, function (index1, item1) {
  716. // if (item1.KIND == 0) {
  717. // item.mainUser.push(item1.USERNAME);
  718. // } else {
  719. // item.copyUsers.push(item1.USERNAME);
  720. // }
  721. // })
  722. // item.mainUser = item.mainUser.join(",");
  723. // item.copyUsers = item.copyUsers.join(",");
  724. // })
  725. // setTimeout(function (item) {
  726. // sp.layer("#RouteList");
  727. // }, 100);
  728. //})
  729. }
  730. self.reSizeRow = function () {
  731. var bodybox = document.getElementById("bodyDiv");
  732. var topbox = document.getElementById("topDiv");
  733. var bottombox = document.getElementById("bottomDiv");
  734. var line = document.getElementById("lineDiv");
  735. document.getElementById("lineDiv").addEventListener("mousedown", function (event) {
  736. $(".mousemove").show()
  737. var bodyboxH = bodybox.clientHeight;
  738. var topboxH = topbox.clientHeight;
  739. var bottomboxH = bottombox.clientHeight;
  740. //var y = event.pageY - line.offsetTop;
  741. var y = event.pageY - line.clientHeight;
  742. document.addEventListener("mousemove", boxMove)
  743. function boxMove(event) {
  744. if (topboxH * 1 + (event.pageY - y) * 1 - 36 <= 45) {
  745. //
  746. } else if (bottomboxH * 1 - (event.pageY - y) * 1 - 36 <= 45) {
  747. //
  748. } else {
  749. topbox.style.height = topboxH * 1 + (event.pageY - y) * 1 - 36 + "px";
  750. //topbox.getElementsByTagName("iframe")[0].style.height = topboxH * 1 + (event.pageY - y) * 1 - 45 + "px";
  751. bottombox.style.height = bodyboxH * 1 - topboxH * 1 - (event.pageY - y) * 1 + 36 + "px";
  752. bottombox.getElementsByTagName("iframe")[0].style.height = bodyboxH * 1 - topboxH * 1 - (event.pageY - y) * 1 - 25 + "px";
  753. }
  754. }
  755. document.addEventListener("mouseup", function () {
  756. $(".mousemove").hide()
  757. document.removeEventListener("mousemove", boxMove)
  758. })
  759. })
  760. }
  761. ////头部关键字搜索---20230905
  762. self.headBtnSearchKeyword = "";
  763. self.headSearchResult = [];
  764. self.headSearchResult_view = false;
  765. self.headBtnSearch = function () {
  766. if (sp.isval(self.headBtnSearchKeyword)) {
  767. self.headSearchResult = [];
  768. var data = {
  769. "url": "/basic/api/StatSelect/selectCodeList",
  770. "data": { "keyWord": self.headBtnSearchKeyword }
  771. }
  772. //console.log(JSON.stringify(data));
  773. $http.post(apiurljs.login + "g2app/yizhangtu/selectCodeList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  774. .success(function (obj) {
  775. var res = strToJson(s4.decryptData_CBC(obj.data));
  776. //console.log(JSON.stringify(res.data));
  777. self.headSearchResult = res.data.build;
  778. if (sp.isval(self.headSearchResult)) {
  779. self.headSearchResult_view = true;
  780. } else {
  781. self.headSearchResult_view = false;
  782. }
  783. })
  784. } else {
  785. self.headSearchResult_view = false;
  786. }
  787. };
  788. self.headKeywordPage = function (itemdata) {
  789. var get_token = localStorage.getItem("main-token");
  790. var set_url = apiurljs.onePic + "wholeProcessPage/?token=" + get_token + "&name=" + itemdata.name + "&type=" + itemdata.type + "&id=" + itemdata.id + "";
  791. $('#attachlist')[0].contentWindow.openTool(set_url, '一张图');
  792. self.headSearchResult_view = false;
  793. };
  794. self.onePic = function () {
  795. $('#attachlist')[0].contentWindow.openTool(apiurljs.onePic + "wholeProcessPage/?token=" + localStorage.getItem("main-token"), "地图搜索")
  796. }
  797. //头部下滚冻结
  798. $(function () {
  799. $(".sp-page-center").eq(0).css("max-height", $("#topDiv").height()).css("height", $("#topDiv").height())
  800. $(".formedit center").css("height", $(".formedit center").next("div").height()).css("line-height", $(".formedit center").next("div").height() / 6 + "px")
  801. //$("body").bind("scroll", function () {
  802. // var scrollTop = $("body").scrollTop();
  803. // if (scrollTop == 0) {
  804. // $(".FixTop").removeClass("FixTop");
  805. // }
  806. // if (scrollTop > 35) {
  807. // $(".sp-page-title").parents(".sp-box").addClass("FixTop");
  808. // }
  809. //});
  810. //页面高度撑满
  811. setTimeout(function () {
  812. if ($(".ibox-content").height() < $(window).height() - 31) {
  813. $(".ibox-content").css("height", $(window).height() - 31)
  814. }
  815. $(".mousemove").css("top", 0).css("left", 0).css("width", $(window).width()).css("height", $(window).height() - 10)
  816. }, 1)
  817. })
  818. }])
  819. app.filter('trustHtml', function ($sce) {
  820. return function (input) {
  821. return $sce.trustAsHtml(input.replace(/\n/g, '<br/>').replace(/\s/g, '&nbsp;'));
  822. };
  823. });
  824. //canvas画布签字
  825. function lineCanvas(obj) {
  826. var self = this;
  827. self.linewidth = 1;
  828. self.color = "#000000";
  829. self.background = "#ffffff";
  830. self.canvas = document.createElement("canvas");
  831. document.getElementById(obj).appendChild(self.canvas);
  832. self.cxt = self.canvas.getContext("2d");
  833. self.canvas.width = document.getElementById(obj).clientWidth;
  834. self.canvas.height = document.getElementById(obj).scrollHeight;
  835. self.cxt.fillStyle = self.background;
  836. self.cxt.fillRect(0, 0, self.canvas.width, self.canvas.width);
  837. self.cxt.strokeStyle = self.color;
  838. self.cxt.lineWidth = self.linewidth;
  839. self.cxt.lineCap = "round";
  840. //开始绘制
  841. self.canvas.addEventListener("mousedown", function (e) {
  842. self.cxt.beginPath();
  843. self.cxt.lineTo(e.pageX - document.getElementById(obj).offsetLeft - 25, e.pageY - document.getElementById(obj).offsetTop + $(".sp-page-center").scrollTop() - 25);
  844. self.canvas.addEventListener("mousemove", move)
  845. }.bind(self), false);
  846. //绘制中
  847. function move() {
  848. var e = window.event;
  849. self.cxt.lineTo(e.pageX - document.getElementById(obj).offsetLeft - 25, e.pageY - document.getElementById(obj).offsetTop + $(".sp-page-center").scrollTop() - 25);
  850. self.cxt.stroke();
  851. }
  852. //结束绘制
  853. self.canvas.addEventListener("mouseup", up)
  854. function up() {
  855. self.cxt.closePath();
  856. self.canvas.removeEventListener("mousemove", move)
  857. }
  858. };
  859. function showToggle(e) {
  860. $(e).children().toggle()
  861. $(e).next().toggle()
  862. }
  863. function toggleYJL(e) {
  864. if ($(e).children(".fa-angle-double-down").is(":hidden") == true) {
  865. $("#topDiv").css("height", 160)
  866. $(e).parent().css("height", 450)
  867. $("#attachlist").css("height", 200)
  868. $("#bottomDiv").css("height", "")
  869. } else {
  870. $("#topDiv").css("height", 600)
  871. $(e).parent().css("height", 10)
  872. }
  873. $(e).children().toggle()
  874. }