bjtxlist.js 4.3 KB

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