123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- 'use strict';
- var app = angular.module('app', [
- 'angularUtils.directives.dirPagination',
- ]);
- app.controller("detailCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
- var self = this;
- var s4 = new SM4Util();
- self.userId = $.cookie("GlWorkPlatform-userid");
- self.userName = $.cookie("GlWorkPlatform-chineseName");
- self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- self.flbs = sp.getUrlName("flbs");
- self.frompage = sp.getUrlName("frompage");
- self.return = self.frompage + ".html?pageno=" + sp.getUrlName("pageno");
- self.keyword = $.cookie("GlWorkPlatform-flfg-keywork");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- };
- self.totalpage = 0;
- self.pageno = 1;
- self.pages = [];
- self.getData = function (pageno) {
- self.pageno = pageno;
- var data = {
- token: localStorage.getItem("main-token"),
- flbs: self.flbs,
- page: self.pageno,
- pageSize: 10
- }
- $http.post(apiurljs.login + "g2app/flfg/getFlfgwbByflbs", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- console.log(res)
- self.totalpage = res.data.result.total_pages;
- //self.list = res.data.result.data;
- //self.list1 = res.data.result.data;
- if (self.pages.length == 0) {
- for (var i = 1; i < self.totalpage + 1; i++) {
- self.pages.push(i)
- }
- }
- res.data.result.data.forEach(function (item) {
- if (self.keyword != "") {
- item.fBt1 = item.fBt.replaceAll(self.keyword, "<span \class='sp-color-red'\>" + self.keyword + "<\/span>");
- item.fWblr1 = item.fWblr.replaceAll(self.keyword, "<span \class='sp-color-red'\>" + self.keyword + "<\/span>");
- } else {
- item.fBt1 = item.fBt
- item.fWblr1 = item.fWblr
- }
- })
- self.list = res.data.result.data;
- self.getDownLoad()
- $(".current").scrollTop(0)
- //if (self.pageno % 2 == 1) {
- // self.list = res.data.result.data;
- //} else {
- // self.list1 = res.data.result.data;
- //}
- })
- }
- if (self.frompage == "bzgf") {
- self.browse = JSON.parse($.cookie("GlWorkPlatform-flfg-browse"))
- var fileflex = {
- token: $.cookie("main-token"),
- fileTile: self.browse.fBbmc,
- fileId: self.browse.fWjid
- }
- $http.post(apiurljs.login + "g2app/flfg/getFlfgFilePerFix", { data: s4.encryptData_CBC(JSON.stringify(fileflex)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- var set_convertType = 0;
- if (res.data.PERFIX == "doc") {
- set_convertType = 0;
- } else if (res.data.PERFIX == "pdf") {
- set_convertType = 20;
- } else if (res.data.PERFIX == "ofd") {
- set_convertType = 570;
- } else {
- set_convertType = 0;
- }
- var postData = {
- convertType: set_convertType,
- fileUrl: apiurljs.login + "g2app/getFlfgFile/" + localStorage.getItem("main-token") + "/" + self.browse.fWjid + "/" + encodeURIComponent(self.browse.fBbmc)
- };
- var postCfg_transfer = {
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
- transformRequest: function (data) {
- return $.param(data);
- }
- };
- $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
- .success(function (res) {
- if (res.errorcode === 0) {
- console.log(res)
- $("#iframe_book").attr("src", res.data.viewUrl)
- } else {
- sp.dialog(res.message);
- }
- });
- })
- } else {
- self.getData(self.pageno);
- }
- self.getDownLoad = function () {
- var fileflex = {
- token: localStorage.getItem("main-token"),
- fileTile: self.frompage == "bzgf" ? self.browse.fBbmc : self.list[0].fFgbt,
- fileId: self.frompage == "bzgf" ? self.browse.fWjid : self.list[0].fWjid
- }
- $http.post(apiurljs.login + "g2app/flfg/getFlfgFilePerFix", { data: s4.encryptData_CBC(JSON.stringify(fileflex)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.data.SUCCESS == true) {
- self.downloadHref = res.data;
- } else {
- self.downloadHref = null;
- }
- })
- }
- self.download = function () {
- window.open(apiurljs.login + "g2app/getFlfgFile/" + localStorage.getItem("main-token") + "/" + self.downloadHref.FILEID + "/" + encodeURIComponent(self.downloadHref.FILENAME))
- }
- $(function () {
- $("#iframe_book").css("height", $(window).height() - 145)
- $(".book").css("height", $(window).height() - 145)
- $(".current").css("height", $(window).height() - 145)
- //$(".previous").css("height", $(window).height() - 145)
- $(".previousTop").css("height", $(window).height() - 145)
- //$(document).on("click", ".current", function () {
- // if (self.pageno < self.totalpage) {
- // self.getData(self.pageno + 1);
- // $(".current").addClass("next").addClass("previous")
- // setTimeout(function () {
- // $(".next").siblings().eq(1).addClass("current").removeClass("previous")
- // }, 1000)
- // setTimeout(function () {
- // $(".previous").css("height", $(window).height() - 145)
- // $(".next").removeClass("current").removeClass("next")
- // }, 1500)
- // }
- //})
- //$(document).on("click", ".previousTop", function () {
- // if (self.pageno >1) {
- // self.getData(self.pageno--);
- // $(".previous").addClass("prev").addClass("current")
- // setTimeout(function () {
- // $(".previous").css("height", $(window).height() - 145)
- // $(".prev").siblings().eq(1).addClass("previous").removeClass("current")
- // }, 1000)
- // setTimeout(function () {
- // $(".prev").removeClass("previous").removeClass("prev")
- // }, 1500)
- // }
- //})
- })
- }])
- app.filter('keyword', function ($sce) {
- return function (str) {
- return $sce.trustAsHtml(str.replace(/\n/g, '<br/>').replace(/\s/g, ' '));
- };
- });
|