rcap1.js 11 KB

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