dbList.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  25. .success(function (obj) {
  26. var res = strToJson(s4.decryptData_CBC(obj.data));
  27. console.log(res.data)
  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: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  47. .success(function (obj) {
  48. var res = strToJson(s4.decryptData_CBC(obj.data));
  49. self.totalObj = res.data;
  50. //self.getdbList(self.totalObj.OTHERCOUNT, self.totalObj.OTHERROUTEIDVARLIST)
  51. if (n == 0) {
  52. self.totalObj.NEWCOUNT > 0 ?
  53. self.getdbList(self.totalObj.NEWCOUNT, self.totalObj.NEWROUTEIDVARLIST):
  54. self.totalObj.LW01COUNT>0?
  55. self.getdbList(self.totalObj.LW01COUNT, self.totalObj.LW01ROUTEIDVARLIST) :
  56. self.totalObj.LW02COUNT > 0 ?
  57. self.getdbList(self.totalObj.LW02COUNT, self.totalObj.LW02ROUTEIDVARLIST) :
  58. self.totalObj.LW03COUNT > 0 ?
  59. self.getdbList(self.totalObj.LW03COUNT, self.totalObj.LW03ROUTEIDVARLIST) :
  60. self.totalObj.LW04COUNT > 0 ?
  61. self.getdbList(self.totalObj.LW04COUNT, self.totalObj.LW04ROUTEIDVARLIST) :
  62. self.totalObj.LB01COUNT > 0 ?
  63. self.getdbList(self.totalObj.LB01COUNT, self.totalObj.LB01ROUTEIDVARLIST) :
  64. self.totalObj.LB02COUNT > 0 ?
  65. self.getdbList(self.totalObj.LB02COUNT, self.totalObj.LB02ROUTEIDVARLIST) :
  66. self.totalObj.LB03COUNT > 0 ?
  67. self.getdbList(self.totalObj.LB03COUNT, self.totalObj.LB03ROUTEIDVARLIST) :
  68. self.totalObj.BLACKCOUNT > 0 ?
  69. self.getdbList(self.totalObj.BLACKCOUNT, self.totalObj.BLACKROUTEIDVARLIST) :
  70. self.totalObj.REDCOUNT > 0 ?
  71. self.getdbList(self.totalObj.REDCOUNT, self.totalObj.REDROUTEIDVARLIST) :
  72. self.totalObj.YELLOWCOUNT > 0 ?
  73. self.getdbList(self.totalObj.YELLOWCOUNT, self.totalObj.YELLOWROUTEIDVARLIST) :
  74. self.totalObj.GREENCOUNT > 0 ?
  75. self.getdbList(self.totalObj.GREENCOUNT, self.totalObj.GREENROUTEIDVARLIST):
  76. self.getdbList(self.totalObj.OTHERCOUNT, self.totalObj.OTHERROUTEIDVARLIST)
  77. } else {
  78. self.getdbList()
  79. }
  80. })
  81. }
  82. self.getFlow()
  83. $interval(function () {
  84. //self.getToTal(1)
  85. },5000)
  86. self.getdbList = function (size, str) {
  87. if (str) {
  88. self.active = {
  89. str: str,
  90. size: size
  91. }
  92. }
  93. console.log(self.active)
  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. console.log(data)
  104. $http.post(apiurljs.login + "g2work/routeinfo/queryDataTodoWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  105. .success(function (obj) {
  106. var res = strToJson(s4.decryptData_CBC(obj.data));
  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. console.log(obj)
  165. //window.top.sp.addTabNav(obj.FLOWCODE, obj.CNAME, obj.FILEN);
  166. sp.openNewWindow("../../" + obj.FILEN + "&flowid=" + obj.FLOWID, obj.TITLE)
  167. }
  168. self.getToTal(1)
  169. event.stopPropagation()
  170. }
  171. self.goParams = function (params) {
  172. if (self.deviceType == "pad") {
  173. window.top.jumpPageParent("FZB01", "收文办理", "tpl/shouwenbg/list.html?params=" + params);
  174. } else {
  175. window.top.sp.addTabNav("FZB01", "收文办理", "tpl/shouwenbg/list.html?params=" + params);
  176. }
  177. }
  178. }])
  179. function formate(num) {
  180. return num > 9 ? num : "0" + num;
  181. }
  182. function getWeek(date) {
  183. switch (new Date(date).getDay()) {
  184. case 0: return "星期日"; break;
  185. case 1: return "星期一"; break;
  186. case 2: return "星期二"; break;
  187. case 3: return "星期三"; break;
  188. case 4: return "星期四"; break;
  189. case 5: return "星期五"; break;
  190. case 6: return "星期六"; break;
  191. }
  192. }
  193. function getDate(str) {
  194. var year = str.getFullYear();
  195. var month = str.getMonth();
  196. var day = str.getDate();
  197. return new Date(year, month, day).getTime()
  198. }