daiban.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination',
  4. ]);
  5. app.controller("indexCtrl", ["$scope", "$http", "$timeout", "$interval", function ($scope, $http, $timeout, $interval) {
  6. var self = this;
  7. self.userId = $.cookie("GlWorkPlatform-userid");
  8. self.userName = $.cookie("GlWorkPlatform-username");
  9. self.userChineseName = $.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.flowids = [];
  18. self.flows = [];
  19. self.getFlow = function () {
  20. var data = {
  21. userid: self.userId,
  22. ntops: 0
  23. }
  24. $http.post(apiurljs.login + "g2work/routeinfo/queryDataToDoFlowRouteCountDesktopByUserid", data, postCfg)
  25. .success(function (obj) {
  26. var res = obj;
  27. res.data.forEach(function (item) {
  28. if (item.FLOWID.indexOf("AA") > -1) {
  29. self.flowids.push(item.FLOWID)
  30. self.flows.push({ FLOWID: item.FLOWID, FLOWCODE: item.FLOWCODE, CNAME: item.CNAME, FILEN: item.FILEN })
  31. }
  32. })
  33. self.getDBFL()
  34. })
  35. }
  36. self.getDBFL = function () {
  37. var data = {
  38. ckey: "CODE_DBFL",
  39. routeinfoid: ""
  40. }
  41. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  42. .success(function (obj) {
  43. var res = strToJson(s4.decryptData_CBC(obj.data));
  44. self.DBFL = res.data.CODE_DBFL.reverse();
  45. self.getData(1)
  46. })
  47. }
  48. self.getFlow()
  49. self.thWidth = { width: $(".sp-table").outerWidth() - 405 };
  50. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  51. self.pageno = 1;
  52. self.total_count = 0;
  53. self.itemsPerPage = 5;
  54. self.type = 0;
  55. self.getData = function (pageno) {
  56. self.list = [];
  57. self.pageno = pageno;
  58. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  59. var querycondition = [];
  60. var ordercondition = [{ COLID: "RECEIVEDATE", SORTTYPE: "desc" }]
  61. var data = {
  62. flowid: self.type == 0 ? self.flowids.join("|") : self.DBFL[self.DBFL.length - self.type].CODE.replace(/,/g,"|"),
  63. userid: self.userId,
  64. pageno: self.pageno,
  65. pagesize: self.itemsPerPage,
  66. columnscondition:"",
  67. querycondition: JSON.stringify(querycondition),
  68. ordercondition: JSON.stringify(ordercondition)
  69. }
  70. $http.post(apiurljs.login + "g2work/routeinfo/queryDataTodoWithPage", data, postCfg)
  71. .success(function (res) {
  72. if (res.data == null || res.data == undefined || res.data == "") {
  73. self.noDataTip = 0;
  74. if (self.params != "") {
  75. self.params = "";
  76. self.getData(1)
  77. }
  78. } else {
  79. self.noDataTip = 1;
  80. self.list = res.data;
  81. self.total_count = res.totalCount;
  82. $.each(self.list, function (index, item) {
  83. item.TITLE1 = item.TITLE.length > 20 ? item.TITLE.slice(0, 20) + "..." : item.TITLE;
  84. if (self.type == "finish") {
  85. item.RECEIVEDATE = item.FINISHEDDATE;
  86. }
  87. })
  88. }
  89. })
  90. }
  91. self.refresh = function () {
  92. self.getData(self.pageno);
  93. }
  94. self.goUrl = function (obj) {
  95. self.flows.forEach(function (item) {
  96. if (item.FLOWID.indexOf(obj.FLOWID) > -1) {
  97. obj.FLOWCODE = item.FLOWCODE;
  98. obj.CNAME = item.CNAME;
  99. if (obj.FILEN.indexOf("tpl") == -1) {
  100. obj.FILEN = item.FILEN.replace(item.FILEN.split("/")[2], obj.FILEN)
  101. }
  102. }
  103. })
  104. if (self.deviceType == "pad") {
  105. window.top.jumpPageParent(obj.FLOWCODE, obj.CNAME, obj.FILEN);
  106. } else {
  107. sp.openNewWindow("../../" + obj.FILEN + "&dotype=1&flowid=" + obj.FLOWID, obj.TITLE)
  108. }
  109. self.getToTal(1)
  110. event.stopPropagation()
  111. }
  112. self.dbCount = 0;
  113. self.getDB = function () {
  114. var data = {
  115. userid: self.userId,
  116. msgkind: "督办台账"
  117. }
  118. $http.post(apiurljs.login + "icenter/notice/queryDataMessageCount", data, postCfg)
  119. .success(function (res) {
  120. self.dbCount = res.data.MSGCOUNT;
  121. })
  122. }
  123. self.goDBMORE = function () {
  124. window.top.sp.addTabNav("DBTX", "督办提醒", "tpl/shixiangdb/dbmore.html")
  125. }
  126. self.getDB()
  127. $interval(function () {
  128. self.refresh()
  129. }, 60000)
  130. $interval(function () {
  131. self.getDB()
  132. }, 5000)
  133. }])