rcap1.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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.currentYear = sp.currentYear();
  18. self.currentMonth = sp.currentMonth();
  19. self.currentDay = new Date().getDate();
  20. self.currentWeek = getWeek(self.currentYear, self.currentMonth, self.currentDay)
  21. self.checkItem = 2;
  22. self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  23. self.YZAP = false;
  24. self.getROLE = function () {
  25. var data = {
  26. userid: self.userId
  27. };
  28. $http.post(apiurljs.login + "g2work/datazu/queryDataUserAuth", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  29. .success(function (obj) {
  30. var res = strToJson(s4.decryptData_CBC(obj.data));
  31. for (var i = 0; i < res.data[0].auths.length; i++) {
  32. if (res.data[0].auths[i].ZID == "AA08" && res.data[0].auths[i].AUTH == "1") {
  33. self.YZAP = true;
  34. }
  35. }
  36. });
  37. }
  38. self.getROLE()
  39. self.list = [];
  40. self.getHY = function () {
  41. var data = {
  42. pageno: 1,
  43. pagesize: 3,
  44. order: "HYSJ desc",
  45. cdate: sp.format(sp.getLocalDate()) + " 00:00:00",
  46. userid: self.userId
  47. }
  48. $http.post(apiurljs.login + "g2app/desk/queryHuiYiWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  49. .success(function (obj) {
  50. var res = strToJson(s4.decryptData_CBC(obj.data));
  51. self.list = res.data;
  52. console.log(self.list)
  53. self.list.forEach(function (item) {
  54. item.ZC1 = item.ZC;
  55. if (item.ZC == "") {
  56. item.ZC = "&nbsp;";
  57. }
  58. })
  59. });
  60. }
  61. //self.getHY()
  62. self.getZB = function () {
  63. var data = {
  64. pageno: 1,
  65. pagesize: 10,
  66. order: "ZBSJ",
  67. startdate: sp.format(sp.getLocalDate()),
  68. enddate: sp.dateCount(1),
  69. userid: ""
  70. }
  71. $http.post(apiurljs.login + "g2app/desk/queryZhiBanWithPageT", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  72. .success(function (obj) {
  73. //var res = strToJson(s4.decryptData_CBC(obj.data));
  74. var res = {
  75. "data": [{ "ZBGBXM1": "魏海军", "ZBSJ1": "张军", "ZBGBXM2": "", "DBLDXM": "李子英", "RIQI": 1, "NF": "2023", "CMONTH": "12", "SQDW": "办公室", "XINGQI": "星期五", "ZBSJ": "C01", "ZBSJV": "18:00-次日8:30", "NYR": "2023-12-01", "ZW": "二级巡视员" },
  76. { "ZBGBXM1": "刘颖", "ZBSJ1": "张子彬", "ZBGBXM2": "", "DBLDXM": "谷燕成", "RIQI": 2, "NF": "2023", "CMONTH": "12", "SQDW": "办公室", "XINGQI": "星期六", "ZBSJ": "C02", "ZBSJV": "8:00-14:00", "NYR": "2023-12-02", "ZW": "办公室主任、二级巡视员" },
  77. { "ZBGBXM1": "汤浩", "ZBSJ1": "张子彬", "ZBGBXM2": "", "DBLDXM": "谷燕成", "RIQI": 2, "NF": "2023", "CMONTH": "12", "SQDW": "办公室", "XINGQI": "星期六", "ZBSJ": "C03", "ZBSJV": "14:00-20:00", "NYR": "2023-12-02", "ZW": "办公室主任、二级巡视员" },
  78. { "ZBGBXM1": "孔林杰", "ZBSJ1": "张子彬", "ZBGBXM2": "", "DBLDXM": "谷燕成", "RIQI": 2, "NF": "2023", "CMONTH": "12", "SQDW": "办公室", "XINGQI": "星期六", "ZBSJ": "C04", "ZBSJV": "20:00-次日8:00", "NYR": "2023-12-02", "ZW": "办公室主任、二级巡视员" }]
  79. }
  80. console.log(res)
  81. self.list = [];
  82. self.list1 = [];
  83. res.data.forEach(function (item) {
  84. if (item.NYR == sp.dateCount(0)) {
  85. self.list.push(item)
  86. }
  87. if (item.NYR == sp.dateCount(1)) {
  88. self.list1.push(item)
  89. }
  90. })
  91. self.leader = OnlyOne(self.list, "DBLDXM")
  92. self.siji = OnlyOne(self.list, "ZBSJ1")
  93. self.leader1 = OnlyOne(self.list1, "DBLDXM")
  94. self.siji1 = OnlyOne(self.list1, "ZBSJ1")
  95. //var current = 0, next = 0;
  96. //$.each(self.dataList, function (index, item) {
  97. // if (item.NF + "-" + formate(item.CMONTH) + "-" + formate(item.RIQI) == sp.format(sp.getLocalDate())) {
  98. // current = index;
  99. // return;
  100. // } else if (item.NF + "-" + formate(item.CMONTH) + "-" + formate(item.RIQI) > sp.format(sp.getLocalDate())) {
  101. // next = index;
  102. // }
  103. //})
  104. //if (current != 0) {
  105. // for (var i = current; i < self.dataList.length; i++) {
  106. // if (self.list.length == 4) {
  107. // return
  108. // }
  109. // self.list.push(self.dataList[i])
  110. // }
  111. // if (self.list.length < 4) {
  112. // for (var j = self.list.length; j < 4; j++) {
  113. // self.list.unshift(self.dataList[current - j])
  114. // }
  115. // }
  116. // self.list = self.list.filter(function (item) {
  117. // return item!=undefined
  118. // })
  119. //} else {
  120. // for (var i = next; i < self.dataList.length; i++) {
  121. // if (self.list.length == 4) {
  122. // return
  123. // }
  124. // self.list.push(self.dataList[i])
  125. // }
  126. // if (self.list.length < 4) {
  127. // for (var j = self.list.length; j < 4; j++) {
  128. // self.list.unshift(self.dataList[next - j])
  129. // }
  130. // }
  131. // self.list = self.list.filter(function (item) {
  132. // return item != undefined
  133. // })
  134. //}
  135. });
  136. }
  137. self.getZB()
  138. self.goCurrentMonth = function () {
  139. if (self.deviceType == "pad") {
  140. window.top.jumpPageParent("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html?date=" + sp.datefmt('yyyy-MM',sp.getLocalDate()))
  141. } else {
  142. window.top.sp.addTabNav("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html?date=" + sp.datefmt('yyyy-MM', sp.getLocalDate()))
  143. }
  144. }
  145. self.goNextMonth = function () {
  146. if (self.deviceType == "pad") {
  147. window.top.jumpPageParent("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html?date=" + sp.datefmt("yyyy-MM", sp.getPreMonthDay(sp.getLocalDate(), 1)))
  148. } else {
  149. window.top.sp.addTabNav("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html?date=" + sp.datefmt("yyyy-MM", sp.getPreMonthDay(sp.getLocalDate(), 1)))
  150. }
  151. }
  152. self.GoToPage = function () {
  153. if (self.deviceType == "pad") {
  154. if (self.checkItem == 1) {
  155. //window.top.jumpPageParent("FZJ06", "会议室管理", "tpl/huiyishimgr/list.html");
  156. } else if (self.checkItem == 2) {
  157. window.top.jumpPageParent("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html")
  158. } else if (self.checkItem == 3) {
  159. window.top.jumpPageParent("FZJ26", "一周安排", "tpl/lingdaobg/YZAP/taizhang.html")
  160. } else {
  161. window.top.jumpPageParent("FZJ28", "书记批示", "tpl/shujipishi/taizhang.html")
  162. }
  163. } else {
  164. if (self.checkItem == 1) {
  165. //window.top.sp.addTabNav("FZJ06", "会议室管理", "tpl/huiyishimgr/list.html");
  166. } else if (self.checkItem == 2) {
  167. window.top.sp.addTabNav("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html")
  168. } else if (self.checkItem == 3) {
  169. window.top.sp.addTabNav("FZJ26", "一周安排", "tpl/lingdaobg/YZAP/taizhang.html")
  170. } else {
  171. window.top.sp.addTabNav("FZJ28", "书记批示", "tpl/shujipishi/taizhang.html")
  172. }
  173. }
  174. }
  175. self.goYZAP = function (date) {
  176. if (self.deviceType == "pad") {
  177. window.top.jumpPageParent("FZJ26-1", "一周安排查询", "tpl/lingdaobg/YZAP/total.html?date=" + date)
  178. } else {
  179. window.top.sp.addTabNav("FZJ26-1", "一周安排查询", "tpl/lingdaobg/YZAP/total.html?date=" + date)
  180. }
  181. }
  182. self.getYZAP = function () {
  183. self.weekList = sp.getWeekNumber(new Date()).dateString.split(",").map(function (day) {
  184. return sp.currentYear() + "-" + day.replace(".", "-")
  185. })
  186. var data = {
  187. tablename: "SX_YZAPTZ",
  188. pagesize: 4,
  189. pageno: 1,
  190. colums: "*,TO_CHAR(YZAPDATE,'MM-dd HH:mm')as YZAPDATE1",
  191. order: "ID",
  192. sqlwhere: "",
  193. sqlorwhere: "",
  194. sqlinwhere: "",
  195. sqllikewhere: ""
  196. }
  197. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  198. .success(function (obj) {
  199. var res = strToJson(s4.decryptData_CBC(obj.data));
  200. self.list = res.data;
  201. self.list.forEach(function (item) {
  202. item.Date = sp.datefmt("MM-dd HH:mm",item.CTIME);
  203. })
  204. })
  205. }
  206. self.getPSTZ = function () {
  207. var data = {
  208. tablename: "SX_SJPSWJTZ",
  209. pagesize: 4,
  210. pageno: 1,
  211. colums: "*,TO_CHAR(QPSJ,'dd')as QPSJ1,TO_CHAR(DBTXTIME,'yyyy-mm-dd')as DBTXTIME1",
  212. order: "ID",
  213. sqlwhere: "",
  214. sqlorwhere: "",
  215. sqlinwhere: "",
  216. sqllikewhere: ""
  217. }
  218. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  219. .success(function (obj) {
  220. var res = strToJson(s4.decryptData_CBC(obj.data));
  221. self.list = res.data;
  222. self.list.forEach(function (item) {
  223. if (item.SJPS != null && item.SJPS.slice(0, 1) == "[") {
  224. var text = [];
  225. JSON.parse(item.SJPS).forEach(function (item1) {
  226. text.push(item1.opinion + " — " + item1.username + "," + item1.cdate)
  227. })
  228. item.SJPS = text.join(";")
  229. }
  230. })
  231. })
  232. }
  233. }])
  234. app.filter('toHtml', function ($sce) {
  235. return function (str) {
  236. return $sce.trustAsHtml(str.replace(/\n/g, '<br/>').replace(/\s/g, '&nbsp;'));
  237. };
  238. });
  239. function getWeek(year, month, day) {
  240. switch (new Date(year, month - 1, day).getDay()) {
  241. case 0: var week = "星期日"; break;
  242. case 1: var week = "星期一"; break;
  243. case 2: var week = "星期二"; break;
  244. case 3: var week = "星期三"; break;
  245. case 4: var week = "星期四"; break;
  246. case 5: var week = "星期五"; break;
  247. case 6: var week = "星期六"; break;
  248. }
  249. return week
  250. }
  251. function formate(num) {
  252. return num > 9 ? num : "0" + num;
  253. }
  254. function OnlyOne(arr,filed) {
  255. var new_arr = [], obj = {};
  256. for (var i = 0; i < arr.length; i++) {
  257. if (!obj[arr[i][filed]]) {
  258. new_arr.push(arr[i])
  259. obj[arr[i][filed]] = true;
  260. }
  261. }
  262. return new_arr
  263. }