formedit.js 60 KB

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