attachlist.js 15 KB

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