bzgf.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination',
  4. ]);
  5. app.controller("indexCtrl", ["$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. var postCfg = {
  12. headers: {
  13. 'Content-Type': 'application/json',
  14. 'Authorization': "Bearer " + self.get_AccessToken
  15. }
  16. };
  17. self.keyword = "";
  18. self.getCode = function () {
  19. $http.get("js/code.txt?t=" + new Date().getTime())
  20. .success(function (res) {
  21. console.log(res)
  22. self.code = res.bzgf;
  23. self.active = self.code[0].code;
  24. self.load();
  25. })
  26. }
  27. self.getCode()
  28. self.pageno = 1;
  29. self.total_count = 0;
  30. self.itemsPerPage = 10;
  31. self.pageOptions = [10, 20, 30, 40];
  32. self.getData = function (str, pageno) {
  33. self.list = [];
  34. self.active = str;
  35. self.pageno = pageno;
  36. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  37. var data = {
  38. token: localStorage.getItem("main-token"),
  39. keyword: self.keyword,
  40. fllb: self.active,
  41. fllbp: "标准规范",
  42. page: self.pageno,
  43. pageSize: self.itemsPerPage
  44. }
  45. $http.post(apiurljs.login + "g2app/flfg/getFlfgbb", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  46. .success(function (obj) {
  47. var res = strToJson(s4.decryptData_CBC(obj.data));
  48. console.log(res.data)
  49. self.list = res.data.result.data;
  50. self.total_count = res.data.result.total_sizes;
  51. self.list.forEach(function (item) {
  52. if (self.keyword != "") {
  53. item.fBbmc1 = item.fBbmc.replaceAll(self.keyword, "<span \class='sp-color-red'\>" + self.keyword + "<\/span>");
  54. } else {
  55. item.fBbmc1 = item.fBbmc
  56. }
  57. })
  58. })
  59. }
  60. self.load = function () {
  61. if (self.get_pageno == undefined || self.get_pageno == null || self.get_pageno == "") {
  62. self.getData(self.active, self.pageno);
  63. } else {
  64. $timeout(function () {
  65. self.getData(self.active, self.get_pageno);
  66. }, 1)
  67. }
  68. }
  69. self.goUrl = function (item) {
  70. //window.location.href="detail.html"
  71. if (item.fWjid == null) {
  72. sp.dialog("文件不存在!")
  73. return;
  74. } else {
  75. $.cookie("GlWorkPlatform-flfg-browse", JSON.stringify(item), { path: '/', expires: 1 });
  76. window.location.href = "detail.html?flbs=" + item.fFlbs + "&frompage=bzgf&pageno=" + self.pageno;
  77. }
  78. }
  79. $scope.getData = function () {
  80. self.getData(self.active,1)
  81. }
  82. }])
  83. app.filter('keyword', function ($sce) {
  84. return function (str) {
  85. return $sce.trustAsHtml(str);
  86. };
  87. });
  88. function keyLogin() {
  89. if (event.keyCode == 13) { //回车键的键值为13
  90. angular.element(document.getElementById('app')).scope().getData();
  91. }
  92. }