ywbl.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination',
  4. ]);
  5. app.controller("indexCtrl", ["$scope", "$http", "$interval", "$timeout", function ($scope, $http, $interval, $timeout) {
  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. var colors = ["#d5e7f5", "#d2f4e0", "#feedcf", "#fcdce1", "#e0f2f2", "#eae9f7"]
  18. self.getTop6 = function () {
  19. var data = {
  20. userid: self.userId,
  21. ntops:0//6
  22. }
  23. $http.post(apiurljs.login + "g2work/routeinfo/queryDataToDoFlowRouteCountDesktopByUserid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  24. .success(function (obj) {
  25. var res = strToJson(s4.decryptData_CBC(obj.data));
  26. self.ywblList = res.data;
  27. $.each(self.ywblList, function (index, item) {
  28. item.background = { "background-color": "" + colors[index % 6] + "" };
  29. item.news = { "background": "url(img/triangle" + (index % 6 + 1) + ".png) no-repeat center" }
  30. item.base = { "background": "url('img/base" + (index % 6 + 1) + ".png') no-repeat center center", "background-size": "110% 115%" };
  31. item.circel = { "background": "url('img/icon" + (index % 6 + 1) + ".png') no-repeat center center rgba(74,156,247,0.6)" };
  32. item.show = item.FILEN.indexOf("shouwenbg") > -1 || item.FILEN.indexOf("shixiangdb") > -1 || item.FILEN.indexOf("xinfangbg") > -1
  33. //self.getData(item, index + 1)
  34. })
  35. self.ywblCss = {
  36. "width": self.ywblList.length > 6 ? self.deviceType == "pad" ? "calc(100% - 60px)" : "calc(100% - 100px)" : "100%",
  37. "height": "150px",
  38. "overflow": "hidden"
  39. }
  40. })
  41. }
  42. self.getTop6()
  43. $interval(function () {
  44. //self.getTop6()
  45. }, 5000)
  46. self.ywblMove = function (n) {
  47. var marginLeft = parseInt($(".sp-page").css("margin-left").slice(0, $(".sp-page").css("margin-left").indexOf("px"))) + n * $(".Item").outerWidth();
  48. if (marginLeft > 0) {
  49. marginLeft = 0
  50. } else if (marginLeft < ($(".sp-page").outerWidth() - $(".Item").outerWidth() * 6) * -1) {
  51. marginLeft = ($(".sp-page").outerWidth() - $(".Item").outerWidth() * 6) * -1
  52. }
  53. $(".sp-page").css("margin-left", marginLeft)
  54. }
  55. self.getData = function (obj, n) {
  56. $timeout(function () {
  57. var chart = new Highcharts.Chart({
  58. chart: {
  59. spacing: [40, 0, 40, 0],
  60. renderTo: "chart" + n,
  61. backgroundColor: 'rgba(0,0,0,0)',
  62. type: 'pie',
  63. style: {
  64. position: 'relative',
  65. left: '-8px'
  66. }
  67. },
  68. title: {
  69. floating: true,
  70. text: '', //图表的标题
  71. useHTML: true,
  72. formatter: function () {
  73. return '<img src="img/img1.png" width=60px>'
  74. }
  75. },
  76. tooltip: {
  77. enabled: false,
  78. },
  79. colors: ['#FFFF00', '#32CD32', '#FF0000'],
  80. legend: {
  81. enabled: false,
  82. },
  83. plotOptions: {
  84. pie: {
  85. cursor: 'pointer',
  86. size: 75,
  87. dataLabels: {
  88. enabled: false,
  89. }
  90. }
  91. },
  92. series: [{
  93. data: [{ name: "紫灯", y: 1, num: obj.BLACKCOUNT }, { name: "红灯", y: 1, num: obj.REDCOUNT }, { name: "黄灯", y: 1, num: obj.YELLOWCOUNT }, { name: "绿灯", y: 1, num: obj.GREENCOUNT }]
  94. }],
  95. credits: {
  96. enabled: false//隐藏右下角网址
  97. },
  98. exporting: {
  99. enabled: false//隐藏右上角打印
  100. }
  101. })
  102. chart.setSize(100, 98)
  103. },0)
  104. }
  105. self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  106. self.addTabNav = function (obj) {
  107. if (self.deviceType == "pad") {
  108. window.top.jumpPageParent(obj.FLOWCODE, obj.CNAME, obj.FILEN);
  109. } else {
  110. window.top.sp.addTabNav(obj.FLOWCODE, obj.CNAME, obj.FILEN);
  111. }
  112. event.stopPropagation()
  113. }
  114. self.goParams = function (obj, params) {
  115. if (params != "") {
  116. if (self.deviceType == "pad") {
  117. window.top.jumpPageParent(obj.FLOWCODE, obj.CNAME, obj.FILEN + (obj.FILEN.indexOf("?") == -1 ? "?params=" + params : "&params=" + params));
  118. } else {
  119. window.top.sp.addTabNav(obj.FLOWCODE, obj.CNAME, obj.FILEN + (obj.FILEN.indexOf("?") == -1 ? "?params=" + params : "&params=" + params));
  120. }
  121. }
  122. event.stopPropagation()
  123. }
  124. }])
  125. app.directive("repeatFinish", function () {
  126. return {
  127. link: function (scope) {
  128. if (scope.$parent.ctl.ywblList.length > 6) {
  129. if (scope.$parent.ctl.deviceType == "pad") {
  130. $(".Item").eq(scope.$index).css("width", ($(window).width() - 60) / 6)
  131. if (scope.$last == true) {
  132. $(".sp-page").css("width", scope.$parent.ctl.ywblList.length * ($(window).width() - 60) / 6)
  133. }
  134. } else {
  135. $(".Item").eq(scope.$index).css("width", ($(window).width() - 100) / 6)
  136. if (scope.$last == true) {
  137. $(".sp-page").css("width", scope.$parent.ctl.ywblList.length * ($(window).width() - 100) / 6)
  138. }
  139. }
  140. } else {
  141. $(".Item").eq(scope.$index).css("width", $(window).width() / 6)
  142. if (scope.$last == true) {
  143. $(".sp-page").css("width", scope.$parent.ctl.ywblList.length * $(window).width() / 6)
  144. }
  145. }
  146. }
  147. };
  148. });