detail.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination',
  4. ]);
  5. app.controller("detailCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
  6. var self = this;
  7. var s4 = new SM4Util();
  8. self.userId = $.cookie("GlWorkPlatform-userid");
  9. self.userName = $.cookie("GlWorkPlatform-chineseName");
  10. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  11. self.flbs = sp.getUrlName("flbs");
  12. self.frompage = sp.getUrlName("frompage");
  13. self.return = self.frompage + ".html?pageno=" + sp.getUrlName("pageno");
  14. self.keyword = $.cookie("GlWorkPlatform-flfg-keywork");
  15. var postCfg = {
  16. headers: {
  17. 'Content-Type': 'application/json',
  18. 'Authorization': "Bearer " + self.get_AccessToken
  19. }
  20. };
  21. self.totalpage = 0;
  22. self.pageno = 1;
  23. self.pages = [];
  24. self.getData = function (pageno) {
  25. self.pageno = pageno;
  26. var data = {
  27. token: localStorage.getItem("main-token"),
  28. flbs: self.flbs,
  29. page: self.pageno,
  30. pageSize: 10
  31. }
  32. $http.post(apiurljs.login + "g2app/flfg/getFlfgwbByflbs", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  33. .success(function (obj) {
  34. var res = strToJson(s4.decryptData_CBC(obj.data));
  35. console.log(res)
  36. self.totalpage = res.data.result.total_pages;
  37. //self.list = res.data.result.data;
  38. //self.list1 = res.data.result.data;
  39. if (self.pages.length == 0) {
  40. for (var i = 1; i < self.totalpage + 1; i++) {
  41. self.pages.push(i)
  42. }
  43. }
  44. res.data.result.data.forEach(function (item) {
  45. if (self.keyword != "") {
  46. item.fBt1 = item.fBt.replaceAll(self.keyword, "<span \class='sp-color-red'\>" + self.keyword + "<\/span>");
  47. item.fWblr1 = item.fWblr.replaceAll(self.keyword, "<span \class='sp-color-red'\>" + self.keyword + "<\/span>");
  48. } else {
  49. item.fBt1 = item.fBt
  50. item.fWblr1 = item.fWblr
  51. }
  52. })
  53. self.list = res.data.result.data;
  54. self.getDownLoad()
  55. $(".current").scrollTop(0)
  56. //if (self.pageno % 2 == 1) {
  57. // self.list = res.data.result.data;
  58. //} else {
  59. // self.list1 = res.data.result.data;
  60. //}
  61. })
  62. }
  63. if (self.frompage == "bzgf") {
  64. self.browse = JSON.parse($.cookie("GlWorkPlatform-flfg-browse"))
  65. var fileflex = {
  66. token: $.cookie("main-token"),
  67. fileTile: self.browse.fBbmc,
  68. fileId: self.browse.fWjid
  69. }
  70. $http.post(apiurljs.login + "g2app/flfg/getFlfgFilePerFix", { data: s4.encryptData_CBC(JSON.stringify(fileflex)) }, postCfg)
  71. .success(function (obj) {
  72. var res = strToJson(s4.decryptData_CBC(obj.data));
  73. var set_convertType = 0;
  74. if (res.data.PERFIX == "doc") {
  75. set_convertType = 0;
  76. } else if (res.data.PERFIX == "pdf") {
  77. set_convertType = 20;
  78. } else if (res.data.PERFIX == "ofd") {
  79. set_convertType = 570;
  80. } else {
  81. set_convertType = 0;
  82. }
  83. var postData = {
  84. convertType: set_convertType,
  85. fileUrl: apiurljs.login + "g2app/getFlfgFile/" + localStorage.getItem("main-token") + "/" + self.browse.fWjid + "/" + encodeURIComponent(self.browse.fBbmc)
  86. };
  87. var postCfg_transfer = {
  88. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  89. transformRequest: function (data) {
  90. return $.param(data);
  91. }
  92. };
  93. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  94. .success(function (res) {
  95. if (res.errorcode === 0) {
  96. console.log(res)
  97. $("#iframe_book").attr("src", res.data.viewUrl)
  98. } else {
  99. sp.dialog(res.message);
  100. }
  101. });
  102. })
  103. } else {
  104. self.getData(self.pageno);
  105. }
  106. self.getDownLoad = function () {
  107. var fileflex = {
  108. token: localStorage.getItem("main-token"),
  109. fileTile: self.frompage == "bzgf" ? self.browse.fBbmc : self.list[0].fFgbt,
  110. fileId: self.frompage == "bzgf" ? self.browse.fWjid : self.list[0].fWjid
  111. }
  112. $http.post(apiurljs.login + "g2app/flfg/getFlfgFilePerFix", { data: s4.encryptData_CBC(JSON.stringify(fileflex)) }, postCfg)
  113. .success(function (obj) {
  114. var res = strToJson(s4.decryptData_CBC(obj.data));
  115. if (res.data.SUCCESS == true) {
  116. self.downloadHref = res.data;
  117. } else {
  118. self.downloadHref = null;
  119. }
  120. })
  121. }
  122. self.download = function () {
  123. window.open(apiurljs.login + "g2app/getFlfgFile/" + localStorage.getItem("main-token") + "/" + self.downloadHref.FILEID + "/" + encodeURIComponent(self.downloadHref.FILENAME))
  124. }
  125. $(function () {
  126. $("#iframe_book").css("height", $(window).height() - 145)
  127. $(".book").css("height", $(window).height() - 145)
  128. $(".current").css("height", $(window).height() - 145)
  129. //$(".previous").css("height", $(window).height() - 145)
  130. $(".previousTop").css("height", $(window).height() - 145)
  131. //$(document).on("click", ".current", function () {
  132. // if (self.pageno < self.totalpage) {
  133. // self.getData(self.pageno + 1);
  134. // $(".current").addClass("next").addClass("previous")
  135. // setTimeout(function () {
  136. // $(".next").siblings().eq(1).addClass("current").removeClass("previous")
  137. // }, 1000)
  138. // setTimeout(function () {
  139. // $(".previous").css("height", $(window).height() - 145)
  140. // $(".next").removeClass("current").removeClass("next")
  141. // }, 1500)
  142. // }
  143. //})
  144. //$(document).on("click", ".previousTop", function () {
  145. // if (self.pageno >1) {
  146. // self.getData(self.pageno--);
  147. // $(".previous").addClass("prev").addClass("current")
  148. // setTimeout(function () {
  149. // $(".previous").css("height", $(window).height() - 145)
  150. // $(".prev").siblings().eq(1).addClass("previous").removeClass("current")
  151. // }, 1000)
  152. // setTimeout(function () {
  153. // $(".prev").removeClass("previous").removeClass("prev")
  154. // }, 1500)
  155. // }
  156. //})
  157. })
  158. }])
  159. app.filter('keyword', function ($sce) {
  160. return function (str) {
  161. return $sce.trustAsHtml(str.replace(/\n/g, '<br/>').replace(/\s/g, '&nbsp;'));
  162. };
  163. });