attachlist.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. 'use strict';
  2. var app = angular.module('app', [
  3. ]);
  4. app.controller("formeditCtrl", ["$scope", "$http", "$sce", function ($scope, $http, $sce) {
  5. var self = this;
  6. var s4 = new SM4Util();
  7. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  8. self.routeinfoid = sp.getUrlName("routeinfoid");
  9. var width = window.outerWidth;
  10. var height = window.outerHeight;
  11. var postCfg = {
  12. headers: {
  13. 'Content-Type': 'application/json',
  14. 'Authorization': "Bearer " + self.get_AccessToken
  15. }
  16. };
  17. self.getData = function () {
  18. var data = {
  19. tablename: "FILE_ATTACH",
  20. colums: "*",
  21. order: "ID asc",
  22. sqlwhere: { ROUTEINFOID: self.routeinfoid },
  23. sqlinwhere: "",
  24. sqllikewhere: ""
  25. }
  26. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  27. .success(function (obj) {
  28. var res = strToJson(s4.decryptData_CBC(obj.data));
  29. self.arrayFile = [];
  30. if (res.data.length > 0) {
  31. res.data.forEach(function (item) {
  32. if (item.ATTACHTYPE.indexOf("-正文") == -1) {
  33. self.arrayFile.push(item)
  34. }
  35. if (item.ATTACHTYPE.indexOf("-正文") != -1 && sp.getUrlName("page") == "formedit") {
  36. self.browse(item)
  37. }
  38. })
  39. if (sp.getUrlName("page") != "formedit") {
  40. self.browse(self.arrayFile[0])
  41. }
  42. }
  43. })
  44. }
  45. self.getData()
  46. $scope.browse = function (obj) {
  47. self.browse(obj);
  48. }
  49. self.browse = function (obj) {
  50. var n = 0;
  51. self.iframeList.forEach(function (item) {
  52. if (item.title == obj.FILENAMES && item.source == apiurljs.login + "g2work/files2/inline/" + obj.FILEURL.slice(7)) {
  53. n++
  54. }
  55. })
  56. if (n == 0) {
  57. //console.log(obj);
  58. ///20230324---zyg ---永中转换-----start
  59. var set_convertType = 0;
  60. if (obj.FILEEXT == "doc") {
  61. set_convertType = 0;
  62. } else if (obj.FILEEXT == "pdf") {
  63. set_convertType = 20;
  64. } else if (obj.FILEEXT == "ofd") {
  65. set_convertType = 570;
  66. } else if (/(png|jpg|jpeg|gif|bmp|jfif|svg|tif|tiff)$/i.test(obj.FILEEXT) == true) {
  67. set_convertType = 23;
  68. } else {
  69. set_convertType = 0;
  70. }
  71. let postData = {
  72. convertType: set_convertType,
  73. fileUrl: apiurljs.login + "g2work/files2/inline/" + obj.FILEURL.slice(7)
  74. };
  75. var postCfg_transfer = {
  76. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  77. transformRequest: function (data) {
  78. return $.param(data);
  79. }
  80. };
  81. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  82. .success(function (res) {
  83. //console.log(res);
  84. if (res.errorcode === 0) {
  85. let rst = res.data;
  86. //console.log(rst.viewUrl);
  87. 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) })
  88. self.add()
  89. } else {
  90. sp.dialog(res.message);
  91. }
  92. });
  93. ///20230324---zyg ---永中转换-----end
  94. }
  95. }
  96. $scope.addGJL = function (name, url) {
  97. self.addGJL(name, url);
  98. }
  99. self.addGJL = function (name, url) {
  100. var n = 0;
  101. self.iframeList.forEach(function (item) {
  102. if (item.title == name && item.source == url) {
  103. n++
  104. }
  105. })
  106. if (n == 0) {
  107. self.iframeList.push({ id: self.iframeList.length + 1, title: name, url: $sce.trustAsResourceUrl(url), source: url })
  108. self.add()
  109. $scope.$apply();
  110. }
  111. }
  112. self.iframeList = []//[{ id: 1, url: "../../index/img-new/background3.png", source: "../../index/img-new/background3.png", boxWidth: { width: 1200 }, iframeWidth: { width: 1190 } }]
  113. self.add = function () {
  114. if (self.iframeList.length == 1) {
  115. self.iframeList[0].boxWidth = { width: $(".col-md-12").width() }
  116. self.iframeList[0].iframeWidth = { width: $(".col-md-12").width() - 10 }
  117. } else {
  118. self.iframeList.forEach(function (item) {
  119. item.boxWidth = { width: Math.trunc($(".col-md-12").width() / 4 * 2 / (self.iframeList.length - 1)) - 10 }
  120. item.iframeWidth = { width: item.boxWidth.width - 10 }
  121. })
  122. self.iframeList[self.iframeList.length - 1].boxWidth = { width: Math.trunc($(".col-md-12").width() / 4 * 2) - 10 }
  123. self.iframeList[self.iframeList.length - 1].iframeWidth = { width: self.iframeList[self.iframeList.length - 1].boxWidth.width - 10 }
  124. }
  125. }
  126. self.openItem = function (obj) {
  127. window.open(obj.url, obj.title, 'width=' + width + ',height=' + height + ',toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')
  128. }
  129. self.closeItem = function (n) {
  130. self.iframeList.splice(n, 1)
  131. if (self.iframeList.length == 0) {
  132. } else if (self.iframeList.length == 1) {
  133. self.iframeList[0].boxWidth = { width: $(".col-md-12").width() }
  134. self.iframeList[0].iframeWidth = { width: $(".col-md-12").width() - 10 }
  135. } else {
  136. self.iframeList.forEach(function (item) {
  137. item.boxWidth = { width: Math.trunc($(".col-md-12").width() / 4 * 2 / (self.iframeList.length - 1)) - 10 }
  138. item.iframeWidth = { width: item.boxWidth.width - 10 }
  139. })
  140. self.iframeList[self.iframeList.length - 1].boxWidth = { width: Math.trunc($(".col-md-12").width() / 4 * 2) - 10 }
  141. self.iframeList[self.iframeList.length - 1].iframeWidth = { width: self.iframeList[self.iframeList.length - 1].boxWidth.width - 10 }
  142. }
  143. }
  144. self.reSize = function (n) {
  145. var leftbox = document.getElementsByClassName("iframe-item")[n - 1];
  146. var rightbox = document.getElementsByClassName("iframe-item")[n];
  147. var line = document.getElementsByClassName("iframe-border-right")[n - 1];
  148. document.getElementsByClassName("iframe-border-right")[n - 1].addEventListener("mousedown", function (event) {
  149. $(".mousemove").show()
  150. var leftboxW = leftbox.style.width.slice(0, leftbox.style.width.length - 2);
  151. var rightboxW = rightbox.style.width.slice(0, rightbox.style.width.length - 2);
  152. var x = event.pageX - line.offsetLeft;
  153. document.addEventListener("mousemove", boxMove)
  154. function boxMove(event) {
  155. if (leftboxW * 1 + (event.pageX - x) * 1 <= 200) {
  156. //document.removeEventListener("mousemove", boxMove)
  157. } else if (rightboxW * 1 - (event.pageX - x) * 1 <= 200) {
  158. //document.removeEventListener("mousemove", boxMove)
  159. } else {
  160. leftbox.style.width = leftboxW * 1 + (event.pageX - x) * 1 + "px";
  161. //leftbox.getElementsByClassName("iframe-title")[0].style.width = leftboxW * 1 + (event.pageX - x) * 1 - 10 + "px";
  162. leftbox.getElementsByTagName("iframe")[0].style.width = leftboxW * 1 + (event.pageX - x) * 1 - 10 + "px";
  163. self.iframeList[n - 1].boxWidth.width = leftboxW * 1 + (event.pageX - x) * 1;
  164. self.iframeList[n - 1].iframeWidth.width = leftboxW * 1 + (event.pageX - x) * 1 - 10;
  165. rightbox.style.width = rightboxW * 1 - (event.pageX - x) * 1 + "px";
  166. //rightbox.getElementsByClassName("iframe-title")[0].style.width = rightboxW * 1 - (event.pageX - x) * 1 - 10 + "px";
  167. rightbox.getElementsByTagName("iframe")[0].style.width = rightboxW * 1 - (event.pageX - x) * 1 - 10 + "px";
  168. self.iframeList[n].boxWidth.width = rightboxW * 1 - (event.pageX - x) * 1;
  169. self.iframeList[n].iframeWidth.width = rightboxW * 1 - (event.pageX - x) * 1 - 10;
  170. }
  171. }
  172. document.addEventListener("mouseup", function () {
  173. $(".mousemove").hide()
  174. document.removeEventListener("mousemove", boxMove)
  175. })
  176. })
  177. }
  178. $(function () {
  179. $(window).resize(function () {
  180. if (self.iframeList.length > 0) {
  181. $("#iframeList").css("height", $(window).height())
  182. $(".mousemove").css("top", $("#iframeList").offset().top).css("left", $("#iframeList").offset().left).css("width", $("#iframeList").width()).css("height", $(window).height())
  183. if (self.iframeList.length == 1) {
  184. self.iframeList[0].boxWidth = { width: $(".col-md-12").width() }
  185. self.iframeList[0].iframeWidth = { width: $(".col-md-12").width() - 10 }
  186. } else {
  187. self.iframeList.forEach(function (item) {
  188. item.boxWidth = { width: Math.trunc($(".col-md-12").width() / 4 * 2 / (self.iframeList.length - 1)) - 10 }
  189. item.iframeWidth = { width: item.boxWidth.width - 10 }
  190. })
  191. self.iframeList[self.iframeList.length - 1].boxWidth = { width: Math.trunc($(".col-md-12").width() / 4 * 2) - 10 }
  192. self.iframeList[self.iframeList.length - 1].iframeWidth = { width: self.iframeList[self.iframeList.length - 1].boxWidth.width - 10 }
  193. }
  194. $scope.$apply();
  195. }
  196. })
  197. })
  198. }])
  199. app.directive("repeatFinish", function () {
  200. return {
  201. link: function (scope) {
  202. if (scope.$last == true) {
  203. $("#iframeList").css("height", $(window).height())
  204. $(".mousemove").css("top", $("#iframeList").offset().top).css("left", $("#iframeList").offset().left).css("width", $("#iframeList").width()).css("height", $(window).height())
  205. }
  206. }
  207. };
  208. });
  209. function openFile(obj) {
  210. angular.element(document.getElementById('app')).scope().browse(obj);
  211. }
  212. function openTool(url, name) {
  213. angular.element(document.getElementById('app')).scope().addGJL(name, url);
  214. }