formedit.js 56 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438
  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. //初始化右上角按钮
  32. self.buttonList = []
  33. self.readonly = {
  34. HYMC: false,
  35. HYSJ: false,
  36. HYDD: false,
  37. ZC: false,
  38. WNRY: false,
  39. CSZB: false,
  40. YGDW: false,
  41. HYYC: false,
  42. FJ: false
  43. }
  44. //上层附件、业务参考、共享沟通组件
  45. self.arrayFile2 = null;
  46. self.arrayFile1 = [];
  47. self.uploading_zw = false;
  48. self.uploading = false;
  49. self.upload_zw = function () {
  50. var uploadformat = strToJson(s4.decryptData_CBC(apiurljs.uploadformat)).data.map(function (item) {
  51. return item.CNAME
  52. })
  53. $('#fileupload-zw').fileupload({
  54. url: apiurljs.login + 'g2app/fawenfiles/uploadFileWithForm',
  55. dataType: 'json',
  56. beforeSend: function (xhr, data) {
  57. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  58. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=FAWEN_FILES,routeinfoid=" + self.routeinfoid + ",gwtype=" + self.data.GWZL + ",dockind=D01"));
  59. },
  60. add: function (e, data) {
  61. var num = 0;
  62. var acceptFileTypes = eval('/(' + apiurljs.zwType.join("|") + ')$/i')
  63. //文件类型判断
  64. $.each(data.originalFiles, function (index, item) {
  65. if (item['type'].length > 0 && !acceptFileTypes.test(item['name'])) {
  66. sp.dialog("您好,请上传" + apiurljs.zwType.join("/") + "格式的文件!");
  67. return;
  68. } else {
  69. num++
  70. }
  71. })
  72. if (num == data.originalFiles.length) {
  73. self.uploading_zw = true;
  74. data.submit();
  75. $scope.$apply();
  76. }
  77. },
  78. // 上传完成后的执行逻辑
  79. done: function (e, data) {
  80. self.uploading_zw = false;
  81. self.getGCG()
  82. }
  83. })
  84. $timeout(function () {
  85. $("#fileupload-zw").trigger("click")
  86. }, 1)
  87. }
  88. self.upload2 = function () {
  89. var uploadformat = strToJson(s4.decryptData_CBC(apiurljs.uploadformat)).data.map(function (item) {
  90. return item.CNAME
  91. })
  92. $('#fileupload2').fileupload({
  93. url: apiurljs.login + 'g2app/abase/uploadFileWithForm',
  94. dataType: 'json',
  95. beforeSend: function (xhr, data) {
  96. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  97. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=FILE_ATTACH,routeinfoid=" + self.routeinfoid + ",ATTACHTYPE=会议通知单"));
  98. },
  99. add: function (e, data) {
  100. var num = 0;
  101. var acceptFileTypes = eval('/(' + uploadformat.join("|") + ')$/i')
  102. //文件类型判断
  103. $.each(data.originalFiles, function (index, item) {
  104. if (item['type'].length > 0 && !acceptFileTypes.test(item['name'])) {
  105. sp.dialog("您好,请上传" + uploadformat.join("/") + "格式的文件!");
  106. return;
  107. } else {
  108. num++
  109. }
  110. })
  111. if (num == data.originalFiles.length) {
  112. self.uploading = true;
  113. data.submit();
  114. $scope.$apply();
  115. }
  116. },
  117. // 上传完成后的执行逻辑
  118. done: function (e, data) {
  119. self.uploading = false;
  120. self.getOther()
  121. }
  122. })
  123. }
  124. //上传附件
  125. self.arrayFile = [];
  126. self.beforeUpload = function () {
  127. if (self.data.ID == 0) {
  128. var dataArray = [];
  129. dataArray.push(self.data);
  130. var data = {
  131. ckey: "SX_HYTZD",
  132. id: self.data.ID,
  133. routeid: self.routeid,
  134. routeinfoid: self.routeinfoid,
  135. routeinfotitle: self.data.HYMC,
  136. directionid: self.directionid,
  137. formeditid: self.formeditid,
  138. data: JSON.stringify(dataArray)
  139. }
  140. $http.post(apiurljs.login + "g2app/abase/saveData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  141. .success(function (obj) {
  142. var res = strToJson(s4.decryptData_CBC(obj.data));
  143. if (res.code == 0) {
  144. self.data.ID = res.data.ID;
  145. self.routeid = res.data.ROUTEID;
  146. self.routeinfoid = res.data.ROUTEINFOID;
  147. self.getSwenList(1)
  148. self.upload()
  149. } else {
  150. sp.dialog(res.message)
  151. }
  152. })
  153. } else {
  154. self.upload()
  155. }
  156. }
  157. self.upload = function () {
  158. $('#fileupload').fileupload({
  159. url: apiurljs.login + 'g2app/abase/saveUploadFileName',
  160. dataType: 'json',
  161. beforeSend: function (xhr, data) {
  162. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  163. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SX_HYTZD,column=FJ,routeinfoid=" + self.routeinfoid + ",loaded=" + data.loaded + ",total=" + data.total));
  164. },
  165. add: function (e, data) {
  166. var num = 0;
  167. //var acceptFileTypes = /(pdf|ofd)$/i;
  168. //文件类型判断
  169. $.each(data.originalFiles, function (index, item) {
  170. if (item['type'].length) {
  171. num++
  172. }
  173. //if (item['type'].length > 0 && !acceptFileTypes.test(item['name'])) {
  174. // sp.dialog("您好,请上传pdf/ofd格式的文件!");
  175. // return;
  176. //} else {
  177. // num++
  178. //}
  179. })
  180. if (num == data.originalFiles.length) {
  181. data.submit();
  182. }
  183. },
  184. // 上传完成后的执行逻辑
  185. done: function (e, data) {
  186. var arrayFile = strToJson(s4.decryptData_CBC(data.result.data).slice(0, s4.decryptData_CBC(data.result.data).lastIndexOf("}") + 1))
  187. self.arrayFile = arrayFile.data;
  188. $scope.$apply();//绑定数据局部刷新
  189. }
  190. })
  191. $timeout(function () {
  192. $("#fileupload").trigger("click")
  193. }, 1)
  194. }
  195. self.deleteFile = function (file) {
  196. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  197. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  198. 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>";
  199. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  200. sp.openCenter(".sp-dialog");
  201. ///取消按钮
  202. $('.sp-closeDialog').click(function (event) {
  203. sp.closeCenter(".sp-dialog");
  204. event.preventDefault();
  205. event.stopPropagation();
  206. });
  207. //post消息的id
  208. $("#delDataTrue").click(function () {
  209. var data = {
  210. tablename: "FILE_ATTACH",
  211. id: file.ID
  212. };
  213. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  214. .success(function (obj) {
  215. var res = strToJson(s4.decryptData_CBC(obj.data));
  216. sp.dialoghide();
  217. if (res.success) {
  218. self.getOther();
  219. } else {
  220. sp.dialog("删除失败,请联系管理员!");
  221. }
  222. });
  223. });
  224. }
  225. self.goAttach = function (obj) {
  226. if (obj) {
  227. if (apiurljs.zhType.indexOf(obj.FILEEXT) == -1) {
  228. sp.dialog("文件暂不支持在线预览,请点击下载查看!")
  229. return
  230. }
  231. $("#attachlist")[0].contentWindow.openFile(obj)
  232. if ($(".fa-chevron-down").is(":hidden") == true) {
  233. showToggle(document.getElementById("toggleButton"))
  234. }
  235. } else {
  236. if ($("#attachlist").attr("src") == '') {
  237. $("#attachlist").attr("src", "attachlist.html?page=formedit&routeinfoid=" + self.routeinfoid)
  238. }
  239. }
  240. }
  241. self.getSwenList = function (n) {
  242. self.SwenList = [];
  243. var data = {
  244. directionid: self.directionid,
  245. userid: self.userId,
  246. routeinfoid: self.routeinfoid,
  247. routeid: self.routeid,
  248. formeditid: ""
  249. }
  250. $http.post(apiurljs.login + "g2app/abase/queryDataLink", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  251. .success(function (obj) {
  252. var res = strToJson(s4.decryptData_CBC(obj.data));
  253. if (self.copyrightid == "") {
  254. self.copyrightid = res.data.LINKS[0].COPYRIGHTID
  255. }
  256. $.each(res.data.LINKS, function (index, item) {
  257. if (item.TEMPFORM.indexOf("formedit.html") > -1) {
  258. self.Title = item.VNAME;
  259. }
  260. if (item.TEMPFORM.indexOf("?docmode") > 0) {
  261. if (item.TEMPFORM.indexOf("attachlist") > -1 || item.TEMPFORM.indexOf("fawenfile") > -1) {
  262. item.TEMPFORM = item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  263. } else {
  264. item.TEMPFORM = "../" + item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  265. }
  266. } else {
  267. item.TEMPFORM = "#";
  268. }
  269. self.SwenList.push(item)
  270. })
  271. self.SwenList.push({
  272. VNAME: "流程图",
  273. DIRECTIONID: self.SwenList[0].DIRECTIONID,
  274. TEMPFORM: "modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1]
  275. })
  276. if (n == 0) {
  277. self.getFLOW()
  278. } else {
  279. self.getData()
  280. }
  281. })
  282. }
  283. self.getSwenList(0)
  284. self.getFLOW = function () {
  285. var data = {
  286. copyrightid: self.copyrightid
  287. }
  288. $http.post(apiurljs.login + "g2work/flow/queryDataByCopyrightid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  289. .success(function (obj) {
  290. var res = strToJson(s4.decryptData_CBC(obj.data));
  291. self.flowTitle = res.data.CNAME;
  292. self.getGWZL()
  293. })
  294. }
  295. self.getGWZL = function () {
  296. var data = {
  297. tablename: "CODE_GWTYPE",
  298. colums: "ID,CODE,CNAME,FLOWID,DOCFILE,REDFILE",
  299. order: "SORTID desc",
  300. sqlwhere: {
  301. USEMARK: 1,
  302. FLOWID: "AA97"
  303. },
  304. sqlinwhere: "",
  305. sqllikewhere: ""
  306. }
  307. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  308. .success(function (obj) {
  309. var res = strToJson(s4.decryptData_CBC(obj.data));
  310. self.GWZL = res.data;
  311. self.getJJQK()
  312. })
  313. }
  314. self.getJJQK = function () {
  315. var data = {
  316. ckey: "CODE_EMERGENCY",
  317. routeinfoid: self.routeinfoid
  318. }
  319. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  320. .success(function (obj) {
  321. var res = strToJson(s4.decryptData_CBC(obj.data));
  322. self.JJCD = res.data.CODE_EMERGENCY;
  323. self.getZDDB()
  324. })
  325. }
  326. self.getZDDB = function () {
  327. var data = {
  328. ckey: "CODE_OVERSEE",
  329. routeinfoid: self.routeinfoid
  330. }
  331. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  332. .success(function (obj) {
  333. var res = strToJson(s4.decryptData_CBC(obj.data));
  334. self.ZDDB = res.data.CODE_OVERSEE;
  335. self.getDpList()
  336. })
  337. }
  338. self.getDpList = function () {
  339. var data = {
  340. unitid: "AA"
  341. }
  342. $http.post(apiurljs.login + "g2app/dataabase/querySectByCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  343. .success(function (obj) {
  344. var res = strToJson(s4.decryptData_CBC(obj.data));
  345. self.dpList = [];
  346. res.data.forEach(function (item) {
  347. if (item.CHILD_DATA.length == 0) {
  348. self.dpList.push(item)
  349. } else {
  350. item.CHILD_DATA.forEach(function (item1) {
  351. if (item1.CHILD_DATA.length == 0) {
  352. self.dpList.push(item1)
  353. } else {
  354. item1.CHILD_DATA.forEach(function (item2) {
  355. if (item2.CHILD_DATA.length == 0) {
  356. self.dpList.push(item2)
  357. }
  358. })
  359. }
  360. })
  361. }
  362. })
  363. self.dpList.forEach(function (item) {
  364. item.checked = false;
  365. })
  366. self.DpList = {
  367. CSZB: JSON.parse(JSON.stringify(self.dpList))
  368. }
  369. self.AllCheckedDp = {};
  370. self.DpLength = {};
  371. self.selectDpList = {};
  372. self.getUserList()
  373. })
  374. }
  375. self.getUserList = function () {
  376. $http.post(apiurljs.login + "g2app/dataabase/getDpList", { data: s4.encryptData_CBC("") }, postCfg)
  377. .success(function (obj) {
  378. var res = strToJson(s4.decryptData_CBC(obj.data));
  379. self.userList = res.data;
  380. self.userList.forEach(function (item) {
  381. item.checked = false;
  382. item.USER.forEach(function (item1) {
  383. item1.checked = false;
  384. item1.USHOWNAME1 = item1.USHOWNAME.length > 3 ? item1.USHOWNAME.slice(0, 3) + "..." : item1.USHOWNAME;
  385. item1.USHOWNAME2 = item1.USHOWNAME.length > 10 ? item1.USHOWNAME.slice(0, 10) + "..." : item1.USHOWNAME
  386. })
  387. })
  388. self.UserList = {
  389. WNRY: JSON.parse(JSON.stringify(self.userList))
  390. };
  391. self.AllChecked = {};
  392. self.UserLength = {};
  393. self.selectList = {};
  394. self.getData()
  395. })
  396. }
  397. //获取数据
  398. self.getData = function () {
  399. var data = {
  400. ckey: "SX_HYTZD",
  401. id: 0,
  402. directionid: self.directionid,
  403. formeditid: self.formeditid,
  404. routeid: self.routeid,
  405. routeinfoid: self.routeinfoid
  406. }
  407. $http.post(apiurljs.login + "g2app/abase/queryData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  408. .success(function (obj) {
  409. var res = strToJson(s4.decryptData_CBC(obj.data));
  410. console.log('self.GWZL',self.GWZL)
  411. console.log('res.data.SX_HYTZD',res.data.SX_HYTZD)
  412. self.data = {
  413. ID: res.data.SX_HYTZD.ID,
  414. APPCODE: res.data.SX_HYTZD.APPCODE,
  415. HYMC: res.data.SX_HYTZD.HYMC,
  416. HYSJ: res.data.SX_HYTZD.HYSJ == "" ? sp.format(sp.getLocalDate()) : sp.format(res.data.SX_HYTZD.HYSJ),
  417. HYDD: res.data.SX_HYTZD.HYDD,
  418. ZC: res.data.SX_HYTZD.ZC,
  419. GWZL:res.data.SX_HYTZD.GWZL == "" ? self.GWZL[0].CODE : res.data.SX_HYTZD.GWZL,
  420. WNRY: res.data.SX_HYTZD.WNRY,
  421. WNRYUSERID: res.data.SX_HYTZD.WNRYUSERID,
  422. CSZB: res.data.SX_HYTZD.CSZB,
  423. YGDW: res.data.SX_HYTZD.YGDW,
  424. HYYC: res.data.SX_HYTZD.HYYC,
  425. }
  426. self.readonly = {
  427. HYMC: res.data.SX_HYTZD["HYMC.EREADONLY"] == "true",
  428. HYSJ: res.data.SX_HYTZD["HYSJ.EREADONLY"] == "true",
  429. HYDD: res.data.SX_HYTZD["HYDD.EREADONLY"] == "true",
  430. ZC: res.data.SX_HYTZD["ZC.EREADONLY"] == "true",
  431. WNRY: res.data.SX_HYTZD["WNRY.EREADONLY"] == "true",
  432. CSZB: res.data.SX_HYTZD["CSZB.EREADONLY"] == "true",
  433. YGDW: res.data.SX_HYTZD["YGDW.EREADONLY"] == "true",
  434. HYYC: res.data.SX_HYTZD["HYYC.EREADONLY"] == "true",
  435. FJ: res.data.SX_HYTZD["FJ.EREADONLY"] == "true"
  436. }
  437. if (res.data.SX_HYTZD.FJ && res.data.SX_HYTZD.FJ != "") {
  438. self.arrayFile = JSON.parse(res.data.SX_HYTZD.FJ);
  439. }
  440. if (self.data.ID == 0) {
  441. self.filedChange = true;
  442. } else {
  443. self.filedChange = false;
  444. }
  445. self.buttonList = res.data["SX_HYTZD.FUNCLIST"];
  446. var n = {}, all = {};
  447. for (var i in self.UserList) {
  448. self.AllChecked[i] = false;
  449. self.UserLength[i] = 0;
  450. self.selectList[i] = []
  451. n[i] = [];
  452. all[i] = 0;
  453. $.each(self.UserList[i], function (index, item) {
  454. n[i].push(0)
  455. $.each(item.USER, function (index1, item1) {
  456. self.UserLength[i]++
  457. if (self.data.WNRYUSERID.indexOf(item1.USERID) != -1 && i == "WNRY") {
  458. n[i][index]++;
  459. item1.checked = true;
  460. self.selectList[i].push(item1);
  461. }
  462. })
  463. if (n[i][index] == item.USER.length && n[i][index] != 0) {
  464. item.checked = true;
  465. all[i]++;
  466. } else {
  467. item.checked == false;
  468. }
  469. })
  470. if (all[i] == self.UserList[i].length) {
  471. self.AllChecked[i] = true;
  472. } else {
  473. self.AllChecked[i] = false;
  474. }
  475. }
  476. for (var i in self.DpList) {
  477. self.AllCheckedDp[i] = false;
  478. self.DpLength[i] = 0;
  479. self.selectDpList[i] = []
  480. all[i] = 0;
  481. $.each(self.DpList[i], function (index, item) {
  482. self.DpLength[i]++
  483. if (self.data.CSZB.indexOf(item.SECTION) != -1 && i == "CSZB") {
  484. all[i]++;
  485. item.checked = true;
  486. self.selectDpList[i].push(item);
  487. }
  488. })
  489. if (all[i] == self.DpList[i].length) {
  490. self.AllCheckedDp[i] = true;
  491. } else {
  492. self.AllCheckedDp[i] = false;
  493. }
  494. }
  495. self.getOpinion1()
  496. self.getOther()
  497. //watermark({
  498. // "watermarl_element": "app",
  499. // "watermark_txt": "测试水印内容",
  500. // "watermark_width": 150,
  501. // "watermark_height": 110,
  502. // "watermark_angle": 345
  503. //})
  504. })
  505. }
  506. //获取附件和插件
  507. self.getOther = function () {
  508. var data = {
  509. tablename: "FILE_ATTACH",
  510. colums: "*",
  511. order: "ID desc",
  512. sqlwhere: { ROUTEINFOID: self.routeinfoid },
  513. sqlinwhere: "",
  514. sqllikewhere: ""
  515. }
  516. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  517. .success(function (obj) {
  518. var res = strToJson(s4.decryptData_CBC(obj.data));
  519. self.arrayFile1 = [];
  520. if (res.data.length > 0) {
  521. res.data.forEach(function (item) {
  522. if (item.ATTACHTYPE.indexOf("-正文") > -1) {
  523. self.arrayFile2 = item;
  524. } else {
  525. self.arrayFile1.push(item)
  526. }
  527. })
  528. self.goAttach()
  529. }
  530. })
  531. }
  532. //获取意见(不上表)
  533. self.opiniontype = 99;
  534. self.getOpinion1 = function () {
  535. var data = {
  536. cmanid: self.userId,
  537. routeinfoid: self.routeinfoid,
  538. routeid: "",//self.routeid,
  539. tableid: "SX_HYTZD",
  540. colid: "",
  541. opiniontype: self.opiniontype,
  542. orderbycol: "CDATE desc"
  543. }
  544. $http.post(apiurljs.login + "g2app/abase/queryDataOpinionWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  545. .success(function (obj) {
  546. var res = strToJson(s4.decryptData_CBC(obj.data));
  547. if (res.success == true) {
  548. self.YJ.nulla = res.data;
  549. self.YJ.nullaSTATUS = false;
  550. self.YJ.nulla.forEach(function (item) {
  551. item.CDATE = sp.datefmt("yyyy-MM-dd HH:mm", item.CDATE);
  552. //if (item.ROUTEID == self.routeid && item.COLID == "") {
  553. // self.YJ.nullaSTATUS = true;
  554. //}
  555. })
  556. } else {
  557. sp.dialog(res.message)
  558. }
  559. })
  560. }
  561. //发文打开过程稿在线编辑
  562. self.getGCG = function () {
  563. var data = {
  564. dockind: "D01",
  565. routeinfoid: self.routeinfoid
  566. }
  567. $http.post(apiurljs.login + "g2app/fawenfiles/queryDataList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  568. .success(function (obj) {
  569. var res = strToJson(s4.decryptData_CBC(obj.data));
  570. self.gaoTypeArrayFirst = res.data;
  571. if (self.gaoTypeArrayFirst.length > 1) {
  572. var data = {
  573. id: self.gaoTypeArrayFirst[0].ID
  574. }
  575. $http.post(apiurljs.login + "g2app/fawenfiles/deleteDataFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  576. .success(function (obj) {
  577. var res = strToJson(s4.decryptData_CBC(obj.data));
  578. if (res.success) {
  579. self.getGCG()
  580. }
  581. });
  582. } else if (self.gaoTypeArrayFirst.length > 0) {
  583. if (self.gaoTypeArrayFirst[0].FILEURL.indexOf("files") > -1) {
  584. var set_filepath = apiurljs.login + "g2work/files/" + self.gaoTypeArrayFirst[0].FILEURL.slice(7);
  585. } else {
  586. var set_filepath = apiurljs.login.split("glwork/")[0] + "glworkweb/" + self.gaoTypeArrayFirst[0].FILEURL;
  587. }
  588. self.getFileWo(self.gaoTypeArrayFirst[0].ID, self.gaoTypeArrayFirst[0].FILENAMES, set_filepath);
  589. self.goAttach(self.gaoTypeArrayFirst[0])
  590. }
  591. console.log(self.gaoTypeArrayFirst)
  592. })
  593. }
  594. //生成正文三种方式:空白模板,红头模板,上传本地文件
  595. self.newMoBan1 = function () {
  596. if (self.gaoTypeArrayFirst&&self.gaoTypeArrayFirst.length > 0) {
  597. var data = {
  598. id: self.gaoTypeArrayFirst[0].ID
  599. }
  600. $http.post(apiurljs.login + "g2app/fawenfiles/deleteDataFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  601. .success(function (obj) {
  602. var res = strToJson(s4.decryptData_CBC(obj.data));
  603. if (res.success) {
  604. var data = {
  605. dockind: "D01",
  606. routeinfoid: self.routeinfoid,
  607. gwtype: self.data.GWZL,
  608. filekind: "DOCFILE"
  609. }
  610. $http.post(apiurljs.login + "g2app/fawenfiles/newDataFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  611. .success(function (obj) {
  612. var res = strToJson(s4.decryptData_CBC(obj.data));
  613. if (res.success) {
  614. self.getGCG()
  615. } else {
  616. sp.dialog("创建失败,请联系管理员!");
  617. }
  618. });
  619. } else {
  620. sp.dialog("创建失败,请联系管理员!");
  621. }
  622. });
  623. } else {
  624. var data = {
  625. dockind: "D01",
  626. routeinfoid: self.routeinfoid,
  627. gwtype: self.data.GWZL,
  628. filekind: "DOCFILE"
  629. }
  630. $http.post(apiurljs.login + "g2app/fawenfiles/newDataFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  631. .success(function (obj) {
  632. var res = strToJson(s4.decryptData_CBC(obj.data));
  633. if (res.success) {
  634. self.getGCG()
  635. } else {
  636. sp.dialog("创建失败,请联系管理员!");
  637. }
  638. });
  639. }
  640. }
  641. self.newMoBan2 = function () {
  642. if (self.gaoTypeArrayFirst&&self.gaoTypeArrayFirst.length > 0) {
  643. var data = {
  644. id: self.gaoTypeArrayFirst[0].ID
  645. }
  646. $http.post(apiurljs.login + "g2app/fawenfiles/deleteDataFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  647. .success(function (obj) {
  648. var res = strToJson(s4.decryptData_CBC(obj.data));
  649. if (res.success) {
  650. var data = {
  651. dockind: "D01",
  652. routeinfoid: self.routeinfoid,
  653. gwtype: self.data.GWZL,
  654. filekind: "REDFILE"
  655. }
  656. $http.post(apiurljs.login + "g2app/fawenfiles/newDataFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  657. .success(function (obj) {
  658. var res = strToJson(s4.decryptData_CBC(obj.data));
  659. if (res.success) {
  660. self.getGCG()
  661. } else {
  662. sp.dialog("创建失败,请联系管理员!");
  663. }
  664. });
  665. } else {
  666. sp.dialog("创建失败,请联系管理员!");
  667. }
  668. });
  669. } else {
  670. var data = {
  671. dockind: "D01",
  672. routeinfoid: self.routeinfoid,
  673. gwtype: self.data.GWZL,
  674. filekind: "REDFILE"
  675. }
  676. $http.post(apiurljs.login + "g2app/fawenfiles/newDataFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  677. .success(function (obj) {
  678. var res = strToJson(s4.decryptData_CBC(obj.data));
  679. if (res.success) {
  680. self.getGCG()
  681. } else {
  682. sp.dialog("创建失败,请联系管理员!");
  683. }
  684. });
  685. }
  686. }
  687. self.getFileWo = function (fileid, filename, filepath) {
  688. var data = {
  689. method: 1,
  690. params: {
  691. userId: self.userName,
  692. fileId: fileid,
  693. fileName: filename,
  694. filePath: filepath,
  695. userRight: self.dotype == 1 ? 0 : 1,// 用户权限 编辑:UserRightEdit = 0; 只读:UserRightReadonly = 1; 临时只读:UserRightTempReadonly = 2;此时页面上编辑—临时只读按钮,打开只能临时只读,不打开可以进行编辑
  696. //saveFlag: true, /// true:自动保存文档 false:不自动保存文档 (默认为true)
  697. callbackUrl: apiurljs.login + "g2app/fawenfiles/uploadFile"
  698. }
  699. };
  700. console.log(JSON.stringify(data))
  701. $.ajax({
  702. url: apiurljs.yzFileWo + "api.do",
  703. data: {
  704. jsonParams: encodeURIComponent(JSON.stringify(data))
  705. },
  706. type: "POST",
  707. dataType: "json",
  708. general: false,
  709. async: false,
  710. success: function (data) {
  711. console.log(data);
  712. if (data) {
  713. if (data.errorCode === "0") {
  714. let rst = data.result;
  715. console.log(rst.urls);
  716. if (rst && rst.urls) {
  717. var get_urls = rst.urls;
  718. console.log(get_urls);
  719. if (typeof (get_urls) === "string") {
  720. $timeout(function () {
  721. //$("#iframe_book").css("height", $(".ibox-content").height() - 123)
  722. $("#iframe_book").attr("src", get_urls)
  723. })
  724. } else {
  725. console.warn("无效的urls:" + get_urls);
  726. }
  727. } else {
  728. console.warn("ajax响应内容data.result有问题:" + rst);
  729. }
  730. } else {
  731. alert(data.errorMessage);
  732. }
  733. } else {
  734. console.warn("ajax响应内容为空!");
  735. }
  736. },
  737. });
  738. }
  739. //判断页面字段是否只读readonly、是否隐藏show
  740. self.hide = function (type, field) {
  741. if (self.dotype == 0 && type == "readonly") {
  742. return true;
  743. } else {
  744. if (self[type][field] == true) {
  745. return true;
  746. } else {
  747. return false;
  748. }
  749. }
  750. }
  751. //右上角按钮调用方法
  752. self.btnEvent = function (item) {
  753. switch (item.CODE) {
  754. case "SAVEITEM": self.btnSave(0); break;
  755. case "PRINTITEM": self.btnPrint(); break;
  756. case "MEETITEM": self.Meet(); break;
  757. case "SENDLOG": self.RouteList(); break;
  758. default: self.forward(item); break;
  759. }
  760. }
  761. self.openDpList = function (str) {
  762. if (self.hide("readonly", str) == true) {
  763. return
  764. } else {
  765. self.filed = str;
  766. //self.AllCheckedDp = false;
  767. sp.layer("#DpList")
  768. $("#DpList .sp-page").eq(0).scrollTop(0);
  769. }
  770. }
  771. self.checkAllDp = function () {
  772. self.AllCheckedDp[self.filed] = !self.AllCheckedDp[self.filed];
  773. $.each(self.DpList[self.filed], function (index, item) {
  774. item.checked = self.AllCheckedDp[self.filed];
  775. })
  776. self.submitDpList(1)
  777. }
  778. self.checkDpItem = function (item) {
  779. item.checked = !item.checked;
  780. var n = 0;
  781. $.each(self.DpList[self.filed], function (index, item) {
  782. if (item.checked == true) {
  783. n++
  784. }
  785. })
  786. if (n == self.DpList[self.filed].length) {
  787. self.AllCheckedDp[self.filed] = true;
  788. } else {
  789. self.AllCheckedDp[self.filed] = false;
  790. }
  791. self.submitDpList(1)
  792. }
  793. self.submitDpList = function (n) {
  794. var AllCheckedLength1 = 0;
  795. self.selectDpList[self.filed] = [];
  796. $.each(self.DpList[self.filed], function (index, item) {
  797. if (item.checked == true) {
  798. AllCheckedLength1++;
  799. self.selectDpList[self.filed].push(item)
  800. }
  801. })
  802. self.data[self.filed] = self.selectDpList[self.filed].map(function (item) {
  803. return item.SECTION
  804. }).join(",")
  805. self.AllCheckedDp[self.filed] = AllCheckedLength1 == self.DpLength[self.filed];
  806. self.changeFiled(self.filed)
  807. if (n == 0) {
  808. sp.layerhide();
  809. }
  810. }
  811. self.openUserList = function (str) {
  812. if (self.hide("readonly", str) == true) {
  813. return
  814. } else {
  815. self.filed = str;
  816. //self.AllChecked[self.filed] = false;
  817. sp.layer("#userList")
  818. $("#userList .sp-page").eq(0).scrollTop(0);
  819. }
  820. }
  821. self.checkAllUser = function () {
  822. self.AllChecked[self.filed] = !self.AllChecked[self.filed];
  823. $.each(self.UserList[self.filed], function (index, item) {
  824. item.checked = self.AllChecked[self.filed];
  825. $.each(item.USER, function (index1, item1) {
  826. item1.checked = self.AllChecked[self.filed];
  827. })
  828. })
  829. self.submitUserList(1)
  830. }
  831. self.checkUserItem = function (item) {
  832. item.checked = !item.checked;
  833. $.each(item.USER, function (index, item1) {
  834. item1.checked = item.checked;
  835. })
  836. var n = 0;
  837. $.each(self.UserList[self.filed], function (index, item) {
  838. if (item.checked == true) {
  839. n++
  840. }
  841. })
  842. if (n == self.UserList[self.filed].length) {
  843. self.AllChecked[self.filed] = true;
  844. } else {
  845. self.AllChecked[self.filed] = false;
  846. }
  847. self.submitUserList(1)
  848. }
  849. self.checkUser = function (item) {
  850. item.checked = !item.checked;
  851. var n = [], all = 0;
  852. $.each(self.UserList[self.filed], function (x, y) {
  853. n.push(0);
  854. $.each(y.USER, function (x1, y1) {
  855. if (y1.checked == true) {
  856. n[x]++
  857. }
  858. })
  859. if (n[x] == y.USER.length && n[x] != 0) {
  860. y.checked = true;
  861. all++
  862. } else {
  863. y.checked = false;
  864. }
  865. })
  866. if (all == self.UserList[self.filed].length) {
  867. self.AllChecked[self.filed] = true;
  868. } else {
  869. self.AllChecked[self.filed] = false;
  870. }
  871. self.submitUserList(1)
  872. }
  873. self.submitUserList = function (n) {
  874. var AllCheckedLength = 0;
  875. self.selectList[self.filed] = [];
  876. $.each(self.UserList[self.filed], function (index, item) {
  877. $.each(item.USER, function (index1, item1) {
  878. if (item1.checked == true) {
  879. AllCheckedLength++;
  880. self.selectList[self.filed].push(item1)
  881. }
  882. })
  883. })
  884. self.data[self.filed] = self.selectList[self.filed].map(function (item) {
  885. return item.USHOWNAME
  886. }).join(",")
  887. if (self.data[self.filed + "USERID"] != undefined) {
  888. self.data[self.filed + "USERID"] = self.selectList[self.filed].map(function (item) {
  889. return item.USERID
  890. }).join(",")
  891. }
  892. self.AllChecked[self.filed] = AllCheckedLength == self.UserLength[self.filed];
  893. self.changeFiled(self.filed)
  894. if (n == 0) {
  895. sp.layerhide();
  896. }
  897. }
  898. //保存提交
  899. self.btnSave = function (n) {
  900. if (spngvld.submit(".sp-page-center")) {
  901. var dataArray = [];
  902. dataArray.push(self.data);
  903. var data = {
  904. ckey: "SX_HYTZD",
  905. id: self.data.ID,
  906. routeid: self.routeid,
  907. routeinfoid: self.routeinfoid,
  908. routeinfotitle: self.data.HYMC,
  909. directionid: self.directionid,
  910. formeditid: self.formeditid,
  911. data: JSON.stringify(dataArray)
  912. }
  913. $http.post(apiurljs.login + "g2app/abase/saveData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  914. .success(function (obj) {
  915. var res = strToJson(s4.decryptData_CBC(obj.data));
  916. if (res.code == 0) {
  917. self.data.ID = res.data.ID;
  918. self.routeid = res.data.ROUTEID;
  919. self.routeinfoid = res.data.ROUTEINFOID;
  920. self.filedChange = false;
  921. if (n == 0) {
  922. sp.dialog("保存成功!");
  923. $timeout(function () {
  924. sp.dialoghide()
  925. }, 1500)
  926. self.getSwenList(1)
  927. } else if (n == 1) {
  928. self.forward(self.btnItem);
  929. } else {
  930. self.sendAll();
  931. }
  932. } else {
  933. sp.dialog(res.message)
  934. }
  935. })
  936. }
  937. }
  938. self.openList = function () {
  939. var data = {
  940. flowid: "AA93",
  941. userid: self.userId,
  942. infostatus: "STOP",
  943. pageno: 1,
  944. pagesize: 50,
  945. querycondition: ""
  946. }
  947. $http.post(apiurljs.login + "g2work/routeinfo/queryDataRelateFlowWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  948. .success(function (obj) {
  949. var res = strToJson(s4.decryptData_CBC(obj.data));
  950. self.YTlist = res.data;
  951. self.YTlist.forEach(function (item) {
  952. item.checked = false;
  953. })
  954. sp.layer("#CBYT")
  955. })
  956. }
  957. self.checkItem = function (obj) {
  958. self.YTlist.forEach(function (item) {
  959. item.checked = false;
  960. })
  961. obj.checked = true;
  962. }
  963. self.submitYT = function () {
  964. self.YTlist.forEach(function (item) {
  965. if(item.checked == true){
  966. self.data.YT = item.TITLE
  967. }
  968. })
  969. sp.layerhide()
  970. }
  971. //打印
  972. self.btnPrint = function () {
  973. // 创建隐藏的可下载链接
  974. var eleLink = document.createElement('a');
  975. eleLink.download = "";
  976. eleLink.style.display = 'none';
  977. eleLink.href = apiurljs.login + "g2app/shouwen/PrintWord?data=" + encodeURIComponent(s4.encryptData_CBC("templatefilename=XZGZDT.ftl&tablename=SX_HYTZD&outfilepath=/tmp/会议通知单.wps&prtdate=RIQI&routeinfoid=" + self.routeinfoid));
  978. // 触发点击
  979. document.body.appendChild(eleLink);
  980. eleLink.click();
  981. // 然后移除
  982. document.body.removeChild(eleLink);
  983. //window.open(apiurljs.login + "g2app/shouwen/PrintWord?templatefilename=shouwen.ftl&tablename=SX_HYTZD&outfilepath=" + apiurljs.print + "&routeinfoid=" + self.routeinfoid)
  984. }
  985. //下载附件
  986. self.download = function (item) {
  987. window.open(apiurljs.login + "g2work/files/" + item.FILEURL.slice(7))
  988. }
  989. //删除附件
  990. self.deleteFile1 = function (item, str) {
  991. var data = {
  992. tablename: "SX_HYTZD",
  993. column: str,
  994. routeinfoid: self.routeinfoid,
  995. fileid: item.FILEID,
  996. filenames: item.FILEOLDNAME
  997. }
  998. $http.post(apiurljs.login + "g2app/abase/deleteUploadFileName", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  999. .success(function (obj) {
  1000. var res = strToJson(s4.decryptData_CBC(obj.data));
  1001. if (res.success == true) {
  1002. self.arrayFile = res.data;
  1003. } else {
  1004. sp.dialog(res.message)
  1005. }
  1006. })
  1007. }
  1008. //签写意见编辑状态
  1009. self.opinion = {
  1010. nulla: false
  1011. }
  1012. self.YJ = {
  1013. nulla: [],
  1014. nullaSTATUS: false
  1015. }
  1016. //意见(下表)
  1017. self.openOptionList = function () {
  1018. if (self.routeinfoid == 0 && self.routeid == 0) {
  1019. sp.dialog("请先保存!")
  1020. return;
  1021. }
  1022. if (self.opinion.nulla == true) {
  1023. return;
  1024. }
  1025. self.nulla = "";
  1026. $(".optionList").css("height", 149)
  1027. self.opinion.nulla = true;
  1028. }
  1029. self.closeOptionList = function () {
  1030. $(".optionList").css("height", 389)
  1031. self.opinion.nulla = false;
  1032. }
  1033. self.submitOptionList = function () {
  1034. var data = {
  1035. cmanid: self.userId,
  1036. routeinfoid: self.routeinfoid,
  1037. routeid: self.routeid,
  1038. tableid: "SX_HYTZD",
  1039. colid: "",
  1040. opiniontype: 99,
  1041. cresult: "",
  1042. opinion: self.nulla,
  1043. opinionimage: ""
  1044. }
  1045. $http.post(apiurljs.login + "g2app/abase/saveDataOpinion", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1046. .success(function (obj) {
  1047. var res = strToJson(s4.decryptData_CBC(obj.data));
  1048. if (res.success == true) {
  1049. self.getOpinion1();
  1050. self.opinion.nulla = false;
  1051. $(".optionList").css("height", 389)
  1052. } else {
  1053. sp.dialog(res.message)
  1054. }
  1055. })
  1056. }
  1057. self.changeOptionList = function (item) {
  1058. self.nulla = item.OPINION;
  1059. self.opinion.nulla = true;
  1060. }
  1061. //意见附件(下表)
  1062. self.uploading1 = false;
  1063. self.upload1 = function () {
  1064. $('#fileupload1').fileupload({
  1065. url: apiurljs.login + 'g2app/abase/UploadWholeFileWithRouteAttach',
  1066. dataType: 'json',
  1067. beforeSend: function (xhr, data) {
  1068. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  1069. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SYS_ROUTE_ATTACHLIST,userid=" + self.userId + ",routeinfoid=" + self.routeinfoid
  1070. + ",routeid=" + self.routeid + ",tableid=SX_HYTZD"));
  1071. },
  1072. // 上传完成后的执行逻辑
  1073. done: function (e, data) {
  1074. self.uploading1 = false;
  1075. self.getOpinion1()
  1076. }
  1077. })
  1078. }
  1079. //下载意见表附件
  1080. self.downLoadOption = function (item) {
  1081. window.open(apiurljs.login + "g2work/files/" + item.FILEPATH.slice(7))
  1082. }
  1083. //删除意见表附件
  1084. self.deleteOptionFile = function (file, str) {
  1085. var data = {
  1086. routeid: file.ROUTEID,
  1087. tableid: "SX_HYTZD",
  1088. colid: str,
  1089. fileid: file.FILEID
  1090. };
  1091. $http.post(apiurljs.login + "g2app/abase/deleteDataOpinionWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1092. .success(function (obj) {
  1093. var res = strToJson(s4.decryptData_CBC(obj.data));
  1094. sp.dialoghide();
  1095. if (res.success) {
  1096. if (str != "") {
  1097. self.getOpinion(str);
  1098. } else {
  1099. self.getOpinion1();
  1100. }
  1101. } else {
  1102. sp.dialog("删除失败,请联系管理员!");
  1103. }
  1104. });
  1105. }
  1106. //删除意见
  1107. self.Dopinion = function (str, item) {
  1108. var data = {
  1109. cmanid: self.userId,
  1110. routeid: self.routeid,
  1111. tableid: "SX_HYTZD",
  1112. colid: str,
  1113. }
  1114. $http.post(apiurljs.login + "g2app/abase/deleteDataOpinion", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1115. .success(function (obj) {
  1116. var res = strToJson(s4.decryptData_CBC(obj.data));
  1117. if (res.success == true) {
  1118. if (str != "") {
  1119. self.getOpinion(str);
  1120. } else {
  1121. self.getOpinion1();
  1122. }
  1123. self.changeFiled(str)
  1124. } else {
  1125. sp.dialog(res.message)
  1126. }
  1127. })
  1128. }
  1129. self.phraseText = "";//添加常用语
  1130. self.phraseList = []//常用语列表
  1131. //获取常用语库
  1132. self.phrase = function (colid) {
  1133. sp.layer("#phrase");
  1134. self.colid = colid;
  1135. self.getPhrase();
  1136. }
  1137. //添加常用语到常用语库
  1138. self.Aphrase = function () {
  1139. if (self.phraseText == "") {
  1140. return;
  1141. }
  1142. var data = {
  1143. cmanid: self.userId,
  1144. tableid: "SX_HYTZD",
  1145. colid: self.colid,
  1146. contents: self.phraseText
  1147. }
  1148. $http.post(apiurljs.login + "g2app/abase/insertDataPatterns", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1149. .success(function (obj) {
  1150. var res = strToJson(s4.decryptData_CBC(obj.data));
  1151. if (res.success == true) {
  1152. self.phraseText = "";
  1153. self.getPhrase();
  1154. } else {
  1155. sp.dialog(res.message)
  1156. }
  1157. })
  1158. }
  1159. //获取常用语库
  1160. self.getPhrase = function () {
  1161. var data = {
  1162. cmanid: self.userId,
  1163. tableid: "SX_HYTZD",
  1164. colid: self.colid
  1165. }
  1166. $http.post(apiurljs.login + "g2app/abase/queryDataPatterns", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1167. .success(function (obj) {
  1168. var res = strToJson(s4.decryptData_CBC(obj.data));
  1169. self.phraseList = res.data;
  1170. self.phraseSelect = self.phraseList[0].CONTENTS;
  1171. })
  1172. }
  1173. //从常用语库删除
  1174. self.Dphrase = function () {
  1175. var id = null;
  1176. $.each(self.phraseList, function (index, item) {
  1177. if (item.CONTENTS == self.phraseSelect) {
  1178. id = item.ID;
  1179. }
  1180. })
  1181. var data = {
  1182. id: id
  1183. }
  1184. $http.post(apiurljs.login + "g2app/abase/deleteDataPatterns", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1185. .success(function (obj) {
  1186. var res = strToJson(s4.decryptData_CBC(obj.data));
  1187. self.getPhrase();
  1188. })
  1189. }
  1190. //常用语确认为意见
  1191. self.btnPhrase = function () {
  1192. if (!self.colid) {
  1193. self.nulla = self.phraseSelect;
  1194. } else {
  1195. self.data[self.colid] = self.phraseSelect;
  1196. }
  1197. sp.layerhide();
  1198. }
  1199. //签字—手写
  1200. self.QianZi = function (str) {
  1201. self.opinion[str + "Img"] = true;
  1202. setTimeout(function () {
  1203. new lineCanvas(str + "QZ")
  1204. }, 1)
  1205. }
  1206. //清除手写
  1207. self.canvasClear = function (str) {
  1208. var cxt = $("#" + str + "QZ").find("canvas")[0].getContext("2d");
  1209. cxt.clearRect(0, 0, $("#" + str + "QZ").find("canvas")[0].width, $("#" + str + "QZ").find("canvas")[0].height)
  1210. }
  1211. //发生修改
  1212. self.changeFiled = function (str) {
  1213. self.filedChange = true;
  1214. }
  1215. //转发
  1216. self.forward = function (obj) {
  1217. self.btnItem = obj;
  1218. if (self.filedChange == true) {
  1219. self.btnSave(1)
  1220. } else {
  1221. $("#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=huiyishibg")
  1222. sp.layer("#forward")
  1223. }
  1224. }
  1225. //查看流转记录
  1226. self.RouteList = function () {
  1227. sp.openNewWindow("../../forward/modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1], "流程图")
  1228. //var data = {
  1229. // directionid: self.directionid,
  1230. // userid: self.userId,
  1231. // routeid: self.routeid,
  1232. // routeinfoid: self.routeinfoid,
  1233. //}
  1234. //$http.post(apiurljs.login + "g2app/abase/queryDataRouteList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1235. //.success(function (obj) {
  1236. // var res = strToJson(s4.decryptData_CBC(obj.data));
  1237. // self.routeList = res.data;
  1238. // $.each(self.routeList, function (index, item) {
  1239. // item.mainUser = [];
  1240. // item.copyUsers = [];
  1241. // $.each(item.USERS, function (index1, item1) {
  1242. // if (item1.KIND == 0) {
  1243. // item.mainUser.push(item1.USERNAME);
  1244. // } else {
  1245. // item.copyUsers.push(item1.USERNAME);
  1246. // }
  1247. // })
  1248. // item.mainUser = item.mainUser.join(",");
  1249. // item.copyUsers = item.copyUsers.join(",");
  1250. // })
  1251. // setTimeout(function (item) {
  1252. // sp.layer("#RouteList");
  1253. // }, 100);
  1254. //})
  1255. }
  1256. self.reSizeRow = function () {
  1257. var bodybox = document.getElementById("bodyDiv");
  1258. var topbox = document.getElementById("topDiv");
  1259. var bottombox = document.getElementById("bottomDiv");
  1260. var line = document.getElementById("lineDiv");
  1261. document.getElementById("lineDiv").addEventListener("mousedown", function (event) {
  1262. $(".mousemove").show()
  1263. var bodyboxH = bodybox.clientHeight;
  1264. var topboxH = topbox.clientHeight;
  1265. var bottomboxH = bottombox.clientHeight;
  1266. //var y = event.pageY - line.offsetTop;
  1267. var y = event.pageY - line.clientHeight;
  1268. document.addEventListener("mousemove", boxMove)
  1269. function boxMove(event) {
  1270. if (topboxH * 1 + (event.pageY - y) * 1 - 36 <= 45) {
  1271. //
  1272. } else if (bottomboxH * 1 - (event.pageY - y) * 1 - 36 <= 45) {
  1273. //
  1274. } else {
  1275. topbox.style.height = topboxH * 1 + (event.pageY - y) * 1 - 36 + "px";
  1276. //topbox.getElementsByTagName("iframe")[0].style.height = topboxH * 1 + (event.pageY - y) * 1 - 45 + "px";
  1277. bottombox.style.height = bodyboxH * 1 - topboxH * 1 - (event.pageY - y) * 1 + 36 + "px";
  1278. bottombox.getElementsByTagName("iframe")[0].style.height = bodyboxH * 1 - topboxH * 1 - (event.pageY - y) * 1 - 25 + "px";
  1279. }
  1280. }
  1281. document.addEventListener("mouseup", function () {
  1282. $(".mousemove").hide()
  1283. document.removeEventListener("mousemove", boxMove)
  1284. })
  1285. })
  1286. }
  1287. ////头部关键字搜索---20230905
  1288. self.headBtnSearchKeyword = "";
  1289. self.headSearchResult = [];
  1290. self.headSearchResult_view = false;
  1291. self.headBtnSearch = function () {
  1292. if (sp.isval(self.headBtnSearchKeyword)) {
  1293. self.headSearchResult = [];
  1294. var data = {
  1295. "url": "/basic/api/StatSelect/selectCodeList",
  1296. "data": { "keyWord": self.headBtnSearchKeyword }
  1297. }
  1298. //console.log(JSON.stringify(data));
  1299. $http.post(apiurljs.login + "g2app/yizhangtu/selectCodeList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  1300. .success(function (obj) {
  1301. var res = strToJson(s4.decryptData_CBC(obj.data));
  1302. //console.log(JSON.stringify(res.data));
  1303. self.headSearchResult = res.data.build;
  1304. if (sp.isval(self.headSearchResult)) {
  1305. self.headSearchResult_view = true;
  1306. } else {
  1307. self.headSearchResult_view = false;
  1308. }
  1309. })
  1310. } else {
  1311. self.headSearchResult_view = false;
  1312. }
  1313. };
  1314. self.headKeywordPage = function (itemdata) {
  1315. var get_token = localStorage.getItem("main-token");
  1316. var set_url = apiurljs.onePic + "wholeProcessPage/?token=" + get_token + "&name=" + itemdata.name + "&type=" + itemdata.type + "&id=" + itemdata.id;
  1317. $('#attachlist')[0].contentWindow.openTool(set_url, '一张图');
  1318. self.headSearchResult_view = false;
  1319. };
  1320. self.onePic = function () {
  1321. $('#attachlist')[0].contentWindow.openTool(apiurljs.onePic + "wholeProcessPage/?token=" + localStorage.getItem("main-token"), "地图搜索")
  1322. }
  1323. //头部下滚冻结
  1324. $(function () {
  1325. $(".sp-page-center").eq(0).css("max-height", $("#topDiv").height()).css("height", $("#topDiv").height())
  1326. //$("body").bind("scroll", function () {
  1327. // var scrollTop = $("body").scrollTop();
  1328. // if (scrollTop == 0) {
  1329. // $(".FixTop").removeClass("FixTop");
  1330. // }
  1331. // if (scrollTop > 35) {
  1332. // $(".sp-page-title").parents(".sp-box").addClass("FixTop");
  1333. // }
  1334. //});
  1335. //页面高度撑满
  1336. setTimeout(function () {
  1337. if ($(".ibox-content").height() < $(window).height() - 31) {
  1338. $(".ibox-content").css("height", $(window).height() - 31)
  1339. }
  1340. $(".mousemove").css("top", 0).css("left", 0).css("width", $(window).width()).css("height", $(window).height() - 10)
  1341. }, 1)
  1342. })
  1343. }])
  1344. app.filter('trustHtml', function ($sce) {
  1345. return function (input) {
  1346. return $sce.trustAsHtml(input.replace(/\n/g, '<br/>').replace(/\s/g, '&nbsp;'));
  1347. };
  1348. });
  1349. //canvas画布签字
  1350. function lineCanvas(obj) {
  1351. var self = this;
  1352. self.linewidth = 1;
  1353. self.color = "#000000";
  1354. self.background = "#ffffff";
  1355. self.canvas = document.createElement("canvas");
  1356. document.getElementById(obj).appendChild(self.canvas);
  1357. self.cxt = self.canvas.getContext("2d");
  1358. self.canvas.width = document.getElementById(obj).clientWidth;
  1359. self.canvas.height = document.getElementById(obj).scrollHeight;
  1360. self.cxt.fillStyle = self.background;
  1361. self.cxt.fillRect(0, 0, self.canvas.width, self.canvas.width);
  1362. self.cxt.strokeStyle = self.color;
  1363. self.cxt.lineWidth = self.linewidth;
  1364. self.cxt.lineCap = "round";
  1365. //开始绘制
  1366. self.canvas.addEventListener("mousedown", function (e) {
  1367. self.cxt.beginPath();
  1368. self.cxt.lineTo(e.pageX - document.getElementById(obj).offsetLeft - 25, e.pageY - document.getElementById(obj).offsetTop + $(".sp-page-center").scrollTop() - 25);
  1369. self.canvas.addEventListener("mousemove", move)
  1370. }.bind(self), false);
  1371. //绘制中
  1372. function move() {
  1373. var e = window.event;
  1374. self.cxt.lineTo(e.pageX - document.getElementById(obj).offsetLeft - 25, e.pageY - document.getElementById(obj).offsetTop + $(".sp-page-center").scrollTop() - 25);
  1375. self.cxt.stroke();
  1376. }
  1377. //结束绘制
  1378. self.canvas.addEventListener("mouseup", up)
  1379. function up() {
  1380. self.cxt.closePath();
  1381. self.canvas.removeEventListener("mousemove", move)
  1382. }
  1383. };
  1384. var parentData = {}
  1385. function getData() {
  1386. parentData = angular.element(document.getElementById("app")).scope().data
  1387. return parentData
  1388. }
  1389. function showToggle(e) {
  1390. $(e).children().toggle()
  1391. $(e).next().toggle()
  1392. }
  1393. function toggleYJL(e) {
  1394. if ($(e).children(".fa-angle-double-down").is(":hidden") == true) {
  1395. $("#topDiv").css("height", 160)
  1396. $(e).parent().css("height", 450)
  1397. $("#attachlist").css("height", 200)
  1398. $("#bottomDiv").css("height", "")
  1399. } else {
  1400. $("#topDiv").css("height", 600)
  1401. $(e).parent().css("height", 10)
  1402. }
  1403. $(e).children().toggle()
  1404. }