formedit.js 41 KB

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