detail2.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. 'use strict';
  2. var app = angular.module('app', [
  3. ]);
  4. //定义一个全局的截图插件变量
  5. var cropper;
  6. app.controller("formeditCtrl", ["$scope", "$http", "$timeout", "$interval", "$sce", function ($scope, $http, $timeout, $interval, $sce) {
  7. var self = this;
  8. var s4 = new SM4Util();
  9. self.userId = $.cookie("GlWorkPlatform-userid");
  10. self.userName = $.cookie("GlWorkPlatform-chineseName");
  11. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  12. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  13. self.get_type = sp.getUrlName("type");
  14. self.get_id = sp.getUrlName("ID");
  15. self.return = "list1.html?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type
  16. var postCfg = {
  17. headers: {
  18. 'Content-Type': 'application/json',
  19. 'Authorization': "Bearer " + self.get_AccessToken
  20. }
  21. };
  22. self.Title = "附件"
  23. self.SwenList = [{
  24. VNAME: "表单",
  25. TEMPFORM: "detail1.html?ID=" + self.get_id + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno
  26. }, {
  27. VNAME: "附件",
  28. TEMPFORM: "#"
  29. }, {
  30. VNAME: "稿件",
  31. TEMPFORM: "detail3.html?ID=" + self.get_id + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno
  32. }];
  33. self.getData = function () {
  34. var data = {
  35. tablename: "DOCELEMENT",
  36. colums: "*",
  37. order: "ID",
  38. sqlwhere: { ID: self.get_id },
  39. sqlorwhere: "",
  40. sqlinwhere: "",
  41. sqllikewhere: ""
  42. };
  43. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  44. .success(function (obj) {
  45. var res = strToJson(s4.decryptData_CBC(obj.data));
  46. self.routeinfoid = res.data[0].ROUTEINFOID;
  47. var data1 = {
  48. routeinfoid: self.routeinfoid,
  49. sqlwhere: "",
  50. attachtype: ['FORM_PDF', 'CWG_PDF', 'GDZ_PDF', 'FLOWRECORD_PDF', 'ZLFILE_PDF']
  51. }
  52. $http.post(apiurljs.login + "g2app/DangAn/getAttachListNotAttachType", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg)
  53. .success(function (obj1) {
  54. var res1 = strToJson(s4.decryptData_CBC(obj1.data));
  55. self.arrayFile = res1.data;
  56. self.getReturnList()
  57. if (self.arrayFile.length > 0) {
  58. self.browse(self.arrayFile[0])
  59. }
  60. })
  61. })
  62. }
  63. self.returnList = [];
  64. self.getReturnList = function () {
  65. var data = {
  66. routeinfoid: self.routeinfoid,
  67. tablename: "DOCELEMENT_01"
  68. }
  69. $http.post(apiurljs.login + "g2app/DangAn/GetDataListForPid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  70. .success(function (obj) {
  71. var res = strToJson(s4.decryptData_CBC(obj.data));
  72. self.returnList = res.data;
  73. self.returnListShow = false;
  74. self.selectReturn = self.returnList[0];
  75. $.each(self.returnList, function (index, item) {
  76. item.BACKDATE1 = sp.format(item.BACKDATE);
  77. item.BACKDATE = sp.formatMinute(item.BACKDATE);
  78. item.BACKOPINION1 = item.BACKOPINION.length > 12 ? item.BACKOPINION.slice(0, 12) + "..." : item.BACKOPINION;
  79. })
  80. })
  81. }
  82. self.getData()
  83. self.uploading = false;
  84. self.upload = function () {
  85. $('#fileupload').fileupload({
  86. url: apiurljs.login + 'g2app/abase/uploadFileWithForm',
  87. dataType: 'json',
  88. beforeSend: function (xhr, data) {
  89. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  90. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=DANGANATTACHFILE,routeinfoid=" + self.routeinfoid + ",ATTACHTYPE=FILEATTACH"));
  91. },
  92. add: function (e, data) {
  93. var num = 0;
  94. //文件类型判断
  95. $.each(data.originalFiles, function (index, item) {
  96. num++
  97. })
  98. if (num == data.originalFiles.length) {
  99. self.uploading = true;
  100. data.submit(); $scope.$apply();
  101. }
  102. },
  103. // 上传完成后的执行逻辑
  104. done: function (e, data) {
  105. self.uploading = false;
  106. self.getData()
  107. }
  108. })
  109. }
  110. self.downLoad = function (item) {
  111. window.open(apiurljs.login + "g2work/files/" + item.FILEURL.slice(7))
  112. }
  113. self.deleteFile = function (file) {
  114. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  115. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  116. 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>";
  117. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  118. sp.openCenter(".sp-dialog");
  119. ///取消按钮
  120. $('.sp-closeDialog').click(function (event) {
  121. sp.closeCenter(".sp-dialog");
  122. event.preventDefault();
  123. event.stopPropagation();
  124. });
  125. //post消息的id
  126. $("#delDataTrue").click(function () {
  127. var data = {
  128. id: file.ID
  129. };
  130. $http.post(apiurljs.login + "g2app/DangAn/deleteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  131. .success(function (obj) {
  132. var res = strToJson(s4.decryptData_CBC(obj.data));
  133. sp.dialoghide();
  134. if (res.success) {
  135. $.each(self.iframeList, function (index, item) {
  136. if (item.title == file.FILENAMES && item.source == apiurljs.login + "g2work/files2/inline/" + file.FILEURL.slice(7)) {
  137. self.closeItem(index);
  138. return false;
  139. }
  140. })
  141. self.getData();
  142. } else {
  143. sp.dialog("删除失败,请联系管理员!");
  144. }
  145. })
  146. });
  147. }
  148. self.browse = function (obj) {
  149. var n = 0;
  150. self.iframeList.forEach(function (item) {
  151. if (item.title == obj.FILENAMES && item.source == apiurljs.login + "g2work/files2/inline/" + obj.FILEURL.slice(7)) {
  152. n++
  153. }
  154. })
  155. if (n == 0) {
  156. //console.log(obj);
  157. ///20230324---zyg ---永中转换-----start
  158. var set_convertType = 0;
  159. if (obj.FILEEXT == "doc") {
  160. set_convertType = 0;
  161. } else if (obj.FILEEXT == "pdf") {
  162. set_convertType = 20;
  163. } else if (obj.FILEEXT == "ofd") {
  164. set_convertType = 570;
  165. } else if (/(png|jpg|jpeg|gif|bmp|jfif|svg|tif|tiff)$/i.test(obj.FILEEXT) == true) {
  166. set_convertType = 23;
  167. } else {
  168. set_convertType = 0;
  169. }
  170. let postData = {
  171. convertType: set_convertType,
  172. fileUrl: apiurljs.login + "g2work/files2/inline/" + obj.FILEURL.slice(7)
  173. };
  174. var postCfg_transfer = {
  175. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  176. transformRequest: function (data) {
  177. return $.param(data);
  178. }
  179. };
  180. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  181. .success(function (res) {
  182. //console.log(res);
  183. if (res.errorcode === 0) {
  184. let rst = res.data;
  185. //console.log(rst.viewUrl);
  186. self.iframeList.push({ id: self.iframeList.length + 1, title: obj.FILENAMES, url: $sce.trustAsResourceUrl(rst.viewUrl), source: apiurljs.login + "g2work/files2/inline/" + obj.FILEURL.slice(7) })
  187. self.add()
  188. } else {
  189. sp.dialog(res.message);
  190. }
  191. });
  192. ///20230324---zyg ---永中转换-----end
  193. }
  194. }
  195. self.openCJ = function (obj) {
  196. var n = 0;
  197. self.iframeList.forEach(function (item) {
  198. if (item.title == obj.CNAME && item.source == obj.URL) {
  199. n++
  200. }
  201. })
  202. if (n == 0) {
  203. self.iframeList.push({ id: self.iframeList.length + 1, title: obj.CNAME, url: $sce.trustAsResourceUrl(addToken(obj.URL) + "&routeinfoid=" + self.routeinfoid + "&pgcode=" + obj.PGCODE + "&bookmarkid=" + obj.ID), source: obj.URL, pgcode: obj.PGCODE })
  204. self.add()
  205. }
  206. }
  207. self.playItem = function (obj) {
  208. var n = 0;
  209. self.iframeList.forEach(function (item) {
  210. if (item.title == obj.WATCHLIMIT && item.source == obj.URL) {
  211. n++
  212. }
  213. })
  214. if (n == 0) {
  215. self.iframeList.push({ id: self.iframeList.length + 1, title: obj.WATCHLIMIT, url: $sce.trustAsResourceUrl(obj.FILEURL), source: obj.FILEURL })
  216. self.add()
  217. }
  218. }
  219. self.iframeList = []
  220. self.add = function () {
  221. if (self.iframeList.length == 1) {
  222. self.iframeList[0].boxWidth = { width: $(".col-md-10").width() }
  223. self.iframeList[0].iframeWidth = { width: $(".col-md-10").width() - 10 }
  224. } else {
  225. self.iframeList.forEach(function (item) {
  226. item.boxWidth = { width: Math.trunc($(".col-md-10").width() / 4 * 2 / (self.iframeList.length - 1)) - 10 }
  227. item.iframeWidth = { width: item.boxWidth.width - 10 }
  228. })
  229. self.iframeList[self.iframeList.length - 1].boxWidth = { width: Math.trunc($(".col-md-10").width() / 4 * 2) - 10 }
  230. self.iframeList[self.iframeList.length - 1].iframeWidth = { width: self.iframeList[self.iframeList.length - 1].boxWidth.width - 10 }
  231. }
  232. }
  233. self.openItem = function (obj) {
  234. window.open(obj.url)
  235. }
  236. self.closeItem = function (n) {
  237. self.iframeList.splice(n, 1)
  238. if (self.iframeList.length == 0) {
  239. } else if (self.iframeList.length == 1) {
  240. self.iframeList[0].boxWidth = { width: $(".col-md-10").width() }
  241. self.iframeList[0].iframeWidth = { width: $(".col-md-10").width() - 10 }
  242. } else {
  243. self.iframeList.forEach(function (item) {
  244. item.boxWidth = { width: Math.trunc($(".col-md-10").width() / 4 * 2 / (self.iframeList.length - 1)) - 10 }
  245. item.iframeWidth = { width: item.boxWidth.width - 10 }
  246. })
  247. self.iframeList[self.iframeList.length - 1].boxWidth = { width: Math.trunc($(".col-md-10").width() / 4 * 2) - 10 }
  248. self.iframeList[self.iframeList.length - 1].iframeWidth = { width: self.iframeList[self.iframeList.length - 1].boxWidth.width - 10 }
  249. }
  250. }
  251. self.reSize = function (n) {
  252. var leftbox = document.getElementsByClassName("iframe-item")[n - 1];
  253. var rightbox = document.getElementsByClassName("iframe-item")[n];
  254. var line = document.getElementsByClassName("iframe-border-right")[n - 1];
  255. document.getElementsByClassName("iframe-border-right")[n - 1].addEventListener("mousedown", function (event) {
  256. $(".mousemove").show()
  257. var leftboxW = leftbox.style.width.slice(0, leftbox.style.width.length - 2);
  258. var rightboxW = rightbox.style.width.slice(0, rightbox.style.width.length - 2);
  259. var x = event.pageX - line.offsetLeft;
  260. document.addEventListener("mousemove", boxMove)
  261. function boxMove(event) {
  262. if (leftboxW * 1 + (event.pageX - x) * 1 <= 200) {
  263. //document.removeEventListener("mousemove", boxMove)
  264. } else if (rightboxW * 1 - (event.pageX - x) * 1 <= 200) {
  265. //document.removeEventListener("mousemove", boxMove)
  266. } else {
  267. leftbox.style.width = leftboxW * 1 + (event.pageX - x) * 1 + "px";
  268. //leftbox.getElementsByClassName("iframe-title")[0].style.width = leftboxW * 1 + (event.pageX - x) * 1 - 10 + "px";
  269. leftbox.getElementsByTagName("iframe")[0].style.width = leftboxW * 1 + (event.pageX - x) * 1 - 10 + "px";
  270. self.iframeList[n - 1].boxWidth.width = leftboxW * 1 + (event.pageX - x) * 1;
  271. self.iframeList[n - 1].iframeWidth.width = leftboxW * 1 + (event.pageX - x) * 1 - 10;
  272. rightbox.style.width = rightboxW * 1 - (event.pageX - x) * 1 + "px";
  273. //rightbox.getElementsByClassName("iframe-title")[0].style.width = rightboxW * 1 - (event.pageX - x) * 1 - 10 + "px";
  274. rightbox.getElementsByTagName("iframe")[0].style.width = rightboxW * 1 - (event.pageX - x) * 1 - 10 + "px";
  275. self.iframeList[n].boxWidth.width = rightboxW * 1 - (event.pageX - x) * 1;
  276. self.iframeList[n].iframeWidth.width = rightboxW * 1 - (event.pageX - x) * 1 - 10;
  277. }
  278. }
  279. document.addEventListener("mouseup", function () {
  280. $(".mousemove").hide()
  281. document.removeEventListener("mousemove", boxMove)
  282. })
  283. })
  284. }
  285. //头部下滚冻结
  286. $(function () {
  287. //页面高度撑满
  288. setTimeout(function () {
  289. if ($(".ibox-content").height() < $(window).height() - 31) {
  290. $(".ibox-content").css("height", $(window).height() - 31)
  291. }
  292. }, 1)
  293. })
  294. }])
  295. app.directive("repeatFinish", function () {
  296. return {
  297. link: function (scope) {
  298. if (scope.$last == true) {
  299. $("#iframeList").css("height", $(window).height() - 110)
  300. $(".mousemove").css("top", $("#iframeList").offset().top).css("left", $("#iframeList").offset().left).css("width", $("#iframeList").width()).css("height", $(window).height() - 110)
  301. }
  302. }
  303. };
  304. });
  305. //插件路径添加token
  306. function addToken(url) {
  307. var newUrl = "";
  308. if (url.indexOf("?") > -1) {
  309. newUrl = url + "&token=" + localStorage.getItem("main-token")
  310. } else {
  311. newUrl = url + "?token=" + localStorage.getItem("main-token")
  312. }
  313. return newUrl
  314. }