szjc.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("listCtrl", ["$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") ? sp.getUrlName("token") : localStorage.getItem("GlWorkPlatform-AccessToken");
  11. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  12. self.type = sp.getUrlName("type");
  13. var postCfg = {
  14. headers: {
  15. 'Content-Type': 'application/json',
  16. 'Authorization': "Bearer " + self.get_AccessToken
  17. }
  18. }
  19. self.search = {
  20. type: 1
  21. }
  22. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  23. self.pageno = 1;
  24. self.total_count = 0;
  25. self.itemsPerPage = 10;
  26. self.pageOptions = [10, 20, 30, 40];
  27. self.getData = function (pageno) {
  28. self.list = [];
  29. self.loading = true;
  30. self.pageno = pageno;
  31. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  32. var data = {
  33. tablename: "XQPROJECT",
  34. pagesize: self.itemsPerPage,
  35. pageno: self.pageno,
  36. colums: "*",
  37. order: "ID",
  38. sqlwhere: self.search == 1 ? { MARKRED: 1 } : { DAYSDELAY: 1 },
  39. sqlorwhere: "",
  40. sqlinwhere: "",
  41. sqllikewhere: ""
  42. };
  43. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  44. .success(function (obj) {
  45. var res = strToJson(s4.decryptData_CBC(obj.data));
  46. if (res.data == null || res.data == undefined || res.data == "") {
  47. self.noDataTip = 0;
  48. } else {
  49. self.noDataTip = 1;
  50. self.list = res.data;
  51. self.total_count = res.totalCount;
  52. }
  53. })
  54. }
  55. self.load = function () {
  56. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  57. self.getData(self.pageno);
  58. } else {
  59. $timeout(function () {
  60. self.getData(self.get_lastReturnPageno);
  61. }, 1)
  62. }
  63. }
  64. self.load()
  65. self.getInfo = function (item) {
  66. var set_convertType = 0;
  67. //if (item.CODE.indexOf("pdf") > -1) {
  68. // set_convertType = 20;
  69. //} else if (item.CODE.indexOf("ofd") > -1) {
  70. // set_convertType = 570;
  71. //} else if (/(jpg|png|gif|bmp)$/i.test(item.CODE) == true) {
  72. // set_convertType = 23;
  73. //} else {
  74. // set_convertType = 0;
  75. //}
  76. //let postData = {
  77. // convertType: set_convertType,
  78. // fileUrl: apiurljs.login + "g2work/files2/inline/" + item.CODE
  79. //};
  80. let postData = {
  81. convertType: 20,
  82. fileUrl: apiurljs.login.split("glwork")[0] + "glworkweb/tpl/deskunit/0e3084aa21ac379410aa07ab29bd9382.pdf"
  83. };
  84. var postCfg_transfer = {
  85. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  86. transformRequest: function (data) {
  87. return $.param(data);
  88. }
  89. };
  90. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  91. .success(function (res) {
  92. //console.log(res);
  93. if (res.errorcode === 0) {
  94. let rst = res.data;
  95. if (self.type == "phone") {
  96. window.location.href = rst.viewUrl
  97. } else {
  98. window.open(rst.viewUrl);
  99. }
  100. } else {
  101. sp.dialog(res.message);
  102. }
  103. });
  104. }
  105. self.changeType = function (n) {
  106. if (self.search.type == n) {
  107. return;
  108. } else {
  109. self.search.type = n;
  110. self.getData(1)
  111. }
  112. }
  113. }])