dbList.js 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. self.flows = [];
  18. self.test = [];
  19. self.getFlow = function () {
  20. var data = {
  21. userid: self.userId,
  22. ntops: 0//6
  23. }
  24. $http.post(apiurljs.login + "g2work/routeinfo/queryDataToDoFlowRouteCountDesktopByUserid", data, postCfg)
  25. .success(function (obj) {
  26. //var res = strToJson(s4.decryptData_CBC(obj.data));
  27. var res = obj;
  28. res.data.forEach(function (item) {
  29. if (item.FLOWID != "无") {
  30. self.flows.push(item.FLOWID)
  31. self.test.push({ FLOWID: item.FLOWID, FLOWCODE: item.FLOWCODE, CNAME: item.CNAME, FILEN: item.FILEN })
  32. }
  33. })
  34. self.getToTal(0)
  35. })
  36. }
  37. self.active = {
  38. str: "",
  39. size: 0
  40. }
  41. self.getToTal = function (n) {
  42. var data = {
  43. userid: self.userId,
  44. ntops: 0
  45. };
  46. $http.post(apiurljs.login + "g2work/routeinfo/queryDataToDoFlowRouteRecordDesktopByUserid", data, postCfg)
  47. .success(function (obj) {
  48. // var res = strToJson(s4.decryptData_CBC(obj.data));
  49. var res = obj;
  50. self.totalObj = res.data;
  51. //self.getdbList(self.totalObj.OTHERCOUNT, self.totalObj.OTHERROUTEIDVARLIST)
  52. if (n == 0) {
  53. self.totalObj.NEWCOUNT > 0 ?
  54. self.getdbList(self.totalObj.NEWCOUNT, self.totalObj.NEWROUTEIDVARLIST):
  55. self.totalObj.LW01COUNT>0?
  56. self.getdbList(self.totalObj.LW01COUNT, self.totalObj.LW01ROUTEIDVARLIST) :
  57. self.totalObj.LW02COUNT > 0 ?
  58. self.getdbList(self.totalObj.LW02COUNT, self.totalObj.LW02ROUTEIDVARLIST) :
  59. self.totalObj.LW03COUNT > 0 ?
  60. self.getdbList(self.totalObj.LW03COUNT, self.totalObj.LW03ROUTEIDVARLIST) :
  61. self.totalObj.LW04COUNT > 0 ?
  62. self.getdbList(self.totalObj.LW04COUNT, self.totalObj.LW04ROUTEIDVARLIST) :
  63. self.totalObj.LB01COUNT > 0 ?
  64. self.getdbList(self.totalObj.LB01COUNT, self.totalObj.LB01ROUTEIDVARLIST) :
  65. self.totalObj.LB02COUNT > 0 ?
  66. self.getdbList(self.totalObj.LB02COUNT, self.totalObj.LB02ROUTEIDVARLIST) :
  67. self.totalObj.LB03COUNT > 0 ?
  68. self.getdbList(self.totalObj.LB03COUNT, self.totalObj.LB03ROUTEIDVARLIST) :
  69. self.totalObj.BLACKCOUNT > 0 ?
  70. self.getdbList(self.totalObj.BLACKCOUNT, self.totalObj.BLACKROUTEIDVARLIST) :
  71. self.totalObj.REDCOUNT > 0 ?
  72. self.getdbList(self.totalObj.REDCOUNT, self.totalObj.REDROUTEIDVARLIST) :
  73. self.totalObj.YELLOWCOUNT > 0 ?
  74. self.getdbList(self.totalObj.YELLOWCOUNT, self.totalObj.YELLOWROUTEIDVARLIST) :
  75. self.totalObj.GREENCOUNT > 0 ?
  76. self.getdbList(self.totalObj.GREENCOUNT, self.totalObj.GREENROUTEIDVARLIST):
  77. self.getdbList(self.totalObj.OTHERCOUNT, self.totalObj.OTHERROUTEIDVARLIST)
  78. } else {
  79. self.getdbList()
  80. }
  81. })
  82. }
  83. self.getFlow()
  84. $interval(function () {
  85. //self.getToTal(1)
  86. },5000)
  87. self.getdbList = function (size, str) {
  88. if (str) {
  89. self.active = {
  90. str: str,
  91. size: size
  92. }
  93. }
  94. var querycondition = [];
  95. querycondition.push({ "CKIND": "VARLIST", "TABLEID": "SYS_ROUTE", "COLID": "ROUTEID", "VALUEA": self.active.str, "VALUEB": "" })
  96. var data = {
  97. flowid: self.flows.join("|"),
  98. userid: self.userId,
  99. pageno: 1,
  100. pagesize: self.active.size,
  101. querycondition: JSON.stringify(querycondition)
  102. }
  103. $http.post(apiurljs.login + "g2work/routeinfo/queryDataTodoWithPage", data, postCfg)
  104. .success(function (obj) {
  105. //var res = strToJson(s4.decryptData_CBC(obj.data));
  106. var res = obj;
  107. self.dbList = res.data;
  108. self.dbItemList = {
  109. "width": ($(".dbItem1").width() / 3) * self.dbList.length,
  110. "height": "140px",
  111. "transition": "margin-left 1s ease 0s"
  112. }
  113. $.each(self.dbList, function (index, item) {
  114. item.DATE = sp.datefmt("MM-dd HH:mm", item.RECEIVEDATE);
  115. item.MIJI = item[item.CODETABLE + ".MJ"] || item[item.CODETABLE + ".MIJI"];
  116. item.JINJI = item[item.CODETABLE + ".JJCD"] || item[item.CODETABLE + ".JJLB"] || item[item.CODETABLE + ".JJQK"];
  117. item.DP1 = "来自:" + item.DP;
  118. item.USERNAMEFROM1 = "转自:" + item.USERNAMEFROM;
  119. item.width = { "width": $(".dbItem1").width() / 3 - 11, "height": "140px" };
  120. item.FILEN = item.FILEN + "&dotype=1";
  121. })
  122. })
  123. }
  124. self.getDay = function (str) {
  125. var a = getDate(new Date());
  126. var b = getDate(new Date(str));
  127. var c = parseInt((a - b) / 86400000);
  128. return c < 0 || c > 2 ? 3 : c;
  129. }
  130. self.dbItemNo = 0;//待办事项向左平移n个按钮
  131. self.dbpageWidth = 0;//待办事项向左平移距离
  132. self.dbpageLeft = function () {
  133. if (self.dbItemNo > 0 && self.dbList.length > 3) {
  134. self.dbItemNo = self.dbItemNo - 3;
  135. self.dbpageWidth = $(".dbItem1").outerWidth(true) * (self.dbItemNo / 3);
  136. $(".dbItem1").children().first().css("margin-left", self.dbpageWidth * -1);
  137. } else {
  138. return;
  139. }
  140. }
  141. self.dbpageRight = function () {
  142. if (self.dbItemNo < $(".dbItem").length - 3 && self.dbList.length > 3) {
  143. self.dbItemNo = self.dbItemNo + 3;
  144. self.dbpageWidth = $(".dbItem1").outerWidth(true) * (self.dbItemNo / 3);
  145. $(".dbItem1").children().first().css("margin-left", self.dbpageWidth * -1);
  146. } else {
  147. return;
  148. }
  149. }
  150. self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  151. self.openSwen = function (obj) {
  152. self.test.forEach(function (item) {
  153. if (item.FLOWID.indexOf(obj.FLOWID) > -1) {
  154. obj.FLOWCODE = item.FLOWCODE;
  155. obj.CNAME = item.CNAME;
  156. if (obj.FILEN.indexOf("tpl") == -1) {
  157. obj.FILEN = item.FILEN.replace(item.FILEN.split("/")[2], obj.FILEN)
  158. }
  159. }
  160. })
  161. if (self.deviceType == "pad") {
  162. window.top.jumpPageParent(obj.FLOWCODE, obj.CNAME, obj.FILEN);
  163. } else {
  164. //window.top.sp.addTabNav(obj.FLOWCODE, obj.CNAME, obj.FILEN);
  165. sp.openNewWindow("../../" + obj.FILEN + "&flowid=" + obj.FLOWID, obj.TITLE)
  166. }
  167. self.getToTal(1)
  168. event.stopPropagation()
  169. }
  170. self.goParams = function (params) {
  171. if (self.deviceType == "pad") {
  172. window.top.jumpPageParent("FZB01", "收文办理", "tpl/shouwenbg/list.html?params=" + params);
  173. } else {
  174. window.top.sp.addTabNav("FZB01", "收文办理", "tpl/shouwenbg/list.html?params=" + params);
  175. }
  176. }
  177. }])
  178. function formate(num) {
  179. return num > 9 ? num : "0" + num;
  180. }
  181. function getWeek(date) {
  182. switch (new Date(date).getDay()) {
  183. case 0: return "星期日"; break;
  184. case 1: return "星期一"; break;
  185. case 2: return "星期二"; break;
  186. case 3: return "星期三"; break;
  187. case 4: return "星期四"; break;
  188. case 5: return "星期五"; break;
  189. case 6: return "星期六"; break;
  190. }
  191. }
  192. function getDate(str) {
  193. var year = str.getFullYear();
  194. var month = str.getMonth();
  195. var day = str.getDate();
  196. return new Date(year, month, day).getTime()
  197. }