rcap.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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. self.list.forEach(function (item) {
  53. item.ZC1 = item.ZC;
  54. if (item.ZC == "") {
  55. item.ZC = "&nbsp;";
  56. }
  57. })
  58. });
  59. }
  60. //self.getHY()
  61. self.getZB = function () {
  62. self.listShow = true;
  63. self.list1Show = false;
  64. var data = {
  65. pageno: 0,
  66. pagesize: 0,
  67. order: "NYR ASC,ZBSJ ASC",
  68. startdate: sp.monthfirst(sp.getLocalDate()),
  69. enddate: sp.formatMonthLast(sp.getLocalDate()),
  70. userid: ""
  71. }
  72. $http.post(apiurljs.login + "g2app/desk/queryZhiBanWithPageT", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  73. .success(function (obj) {
  74. var res = strToJson(s4.decryptData_CBC(obj.data));
  75. self.list = [];
  76. res.data.forEach(function (item) {
  77. var n = 0;
  78. self.list.forEach(function (item1) {
  79. if (item1.NYR == item.NYR) {
  80. n++
  81. item1.ZBLD.push(item.ZBGBXM1)
  82. item1.ZBLD.push(item.ZBGBXM2)
  83. if (item1.DBLD.join(",").indexOf(item.DBLDXM) == -1) {
  84. item1.DBLD.push(item.DBLDXM)
  85. }
  86. }
  87. })
  88. if (n == 0) {
  89. item.ZBLD = [];
  90. item.ZBLD.push(item.ZBGBXM1)
  91. item.ZBLD.push(item.ZBGBXM2)
  92. item.DBLD = [];
  93. item.DBLD.push(item.DBLDXM)
  94. self.list.push(item)
  95. }
  96. });
  97. self.list.forEach(function (item) {
  98. item.ZBLD1 = item.ZBLD.filter(function (x) {
  99. return x != "" && x != null;
  100. }).join(",")
  101. item.DBLDXM1 = item.DBLD.filter(function (x) {
  102. return x != "" && x != null;
  103. }).join(",")
  104. })
  105. var data = {
  106. pageno: 0,
  107. pagesize: 0,
  108. order: "NYR ASC,ZBSJ ASC",
  109. startdate: sp.monthfirst(sp.getPreMonthDay(sp.getLocalDate(), 1)),
  110. enddate: sp.formatMonthLast(sp.getPreMonthDay(sp.getLocalDate(), 1)),
  111. userid: ""
  112. }
  113. $http.post(apiurljs.login + "g2app/desk/queryZhiBanWithPageT", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  114. .success(function (obj1) {
  115. var res1 = strToJson(s4.decryptData_CBC(obj1.data));
  116. self.list1 = [];
  117. res1.data.forEach(function (item) {
  118. var n = 0;
  119. self.list1.forEach(function (item1) {
  120. if (item1.NYR == item.NYR) {
  121. n++
  122. item1.ZBLD.push(item.ZBGBXM1)
  123. item1.ZBLD.push(item.ZBGBXM2)
  124. if (item1.DBLD.join(",").indexOf(item.DBLDXM) == -1) {
  125. item1.DBLD.push(item.DBLDXM)
  126. }
  127. }
  128. })
  129. if (n == 0) {
  130. item.ZBLD = [];
  131. item.ZBLD.push(item.ZBGBXM1)
  132. item.ZBLD.push(item.ZBGBXM2)
  133. item.DBLD = [];
  134. item.DBLD.push(item.DBLDXM)
  135. self.list1.push(item)
  136. }
  137. });
  138. self.list1.forEach(function (item) {
  139. item.ZBLD1 = item.ZBLD.filter(function (x) {
  140. return x != "" && x != null;
  141. }).join(",")
  142. item.DBLDXM1 = item.DBLD.filter(function (x) {
  143. return x != "" && x != null;
  144. }).join(",")
  145. })
  146. });
  147. });
  148. }
  149. self.getZB()
  150. self.goCurrentMonth = function () {
  151. //if (self.deviceType == "pad") {
  152. // window.top.jumpPageParent("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html?date=" + sp.datefmt('yyyy-MM',sp.getLocalDate()))
  153. //} else {
  154. // window.top.sp.addTabNav("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html?date=" + sp.datefmt('yyyy-MM', sp.getLocalDate()))
  155. //}
  156. if (self.deviceType == "pad") {
  157. window.top.jumpPageParent("FZJ08-1", "值班表", "tpl/zhibanmgr/zhiban.html?date=" + sp.datefmt('yyyy-MM', sp.getLocalDate()))
  158. } else {
  159. window.top.sp.addTabNav("FZJ08-1", "值班表", "tpl/zhibanmgr/zhiban.html?date=" + sp.datefmt('yyyy-MM', sp.getLocalDate()))
  160. }
  161. }
  162. self.goNextMonth = function () {
  163. if (self.deviceType == "pad") {
  164. window.top.jumpPageParent("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html?date=" + sp.datefmt("yyyy-MM", sp.getPreMonthDay(sp.getLocalDate(), 1)))
  165. } else {
  166. window.top.sp.addTabNav("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html?date=" + sp.datefmt("yyyy-MM", sp.getPreMonthDay(sp.getLocalDate(), 1)))
  167. }
  168. }
  169. self.GoToPage = function () {
  170. if (self.deviceType == "pad") {
  171. if (self.checkItem == 1) {
  172. //window.top.jumpPageParent("FZJ06", "会议室管理", "tpl/huiyishimgr/list.html");
  173. } else if (self.checkItem == 2) {
  174. window.top.jumpPageParent("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html")
  175. } else if (self.checkItem == 3) {
  176. window.top.jumpPageParent("FZF08", "一周安排", "tpl/lingdaobg/YZAP/taizhang.html")
  177. } else {
  178. window.top.jumpPageParent("FZR19", "书记批示", "tpl/shujipishi/taizhang.html")
  179. }
  180. } else {
  181. if (self.checkItem == 1) {
  182. //window.top.sp.addTabNav("FZJ06", "会议室管理", "tpl/huiyishimgr/list.html");
  183. } else if (self.checkItem == 2) {
  184. window.top.sp.addTabNav("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html")
  185. } else if (self.checkItem == 3) {
  186. window.top.sp.addTabNav("FZF08", "一周安排", "tpl/lingdaobg/YZAP/taizhang.html")
  187. } else {
  188. window.top.sp.addTabNav("FZR19", "书记批示", "tpl/shujipishi/taizhang.html")
  189. }
  190. }
  191. }
  192. self.goYZAP = function (date) {
  193. if (self.deviceType == "pad") {
  194. window.top.jumpPageParent("FZF08-1", "一周安排查询", "tpl/lingdaobg/YZAP/total.html?date=" + date)
  195. } else {
  196. window.top.sp.addTabNav("FZF08-1", "一周安排查询", "tpl/lingdaobg/YZAP/total.html?date=" + date)
  197. }
  198. }
  199. self.getYZAP = function (selectDay) {
  200. self.list = [];
  201. self.loading = false;
  202. var data = {
  203. tablename: "SX_YZAPTZ",
  204. colums: "*,TO_CHAR(YZAPDATE,'MM-dd')as YZAPDATE1",
  205. order: "YZAPDATE ASC,CTIME ASC,LDSORTID ASC,CNAME ASC",
  206. sqlwhere: " and YZAPDATE BETWEEN '" + sp.getWeekNumber(new Date()).begin + " 00:00:00' AND '" + sp.getWeekNumber(new Date()).end + " 23:59:59'"
  207. }
  208. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColStr", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  209. .success(function (obj) {
  210. var res = strToJson(s4.decryptData_CBC(obj.data));
  211. self.list = res.data;
  212. self.list.forEach(function (item) {
  213. item.CTIME1 = item.CTIME.slice(11, 16);
  214. item.CNAME = item.CNAME == "null" ? "" : item.CNAME
  215. item.ATTENDANCESCOPE = item.ATTENDANCESCOPE == "null" ? "" : item.ATTENDANCESCOPE
  216. item.ADDR = item.ADDR == "null" ? "" : item.ADDR
  217. item.TIMEPERIOD1 = item.TIMEPERIOD;
  218. item.CTIME2 = item.CTIME1;
  219. item.CNAME1 = item.CNAME;
  220. item.ATTENDANCESCOPE1 = item.ATTENDANCESCOPE;
  221. item.ADDR1 = item.ADDR;
  222. })
  223. })
  224. }
  225. self.getPSTZ = function () {
  226. var data = {
  227. tablename: "SX_SJPSWJTZ",
  228. pagesize: 4,
  229. pageno: 1,
  230. colums: "*,TO_CHAR(QPSJ,'dd')as QPSJ1,TO_CHAR(DBTXTIME,'yyyy-mm-dd')as DBTXTIME1",
  231. order: "ID",
  232. sqlwhere: "",
  233. sqlorwhere: "",
  234. sqlinwhere: "",
  235. sqllikewhere: ""
  236. }
  237. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  238. .success(function (obj) {
  239. var res = strToJson(s4.decryptData_CBC(obj.data));
  240. self.list = res.data;
  241. self.list.forEach(function (item) {
  242. if (item.SJPS != null && item.SJPS.slice(0, 1) == "[") {
  243. var text = [];
  244. JSON.parse(item.SJPS).forEach(function (item1) {
  245. text.push(item1.opinion + " — " + item1.username + "," + item1.cdate)
  246. })
  247. item.SJPS = text.join(";")
  248. }
  249. })
  250. })
  251. }
  252. }])
  253. app.filter('toHtml', function ($sce) {
  254. return function (str) {
  255. return $sce.trustAsHtml(str.replace(/\n/g, '<br/>').replace(/\s/g, '&nbsp;'));
  256. };
  257. });
  258. app.directive("repeatFinish", function () {
  259. return {
  260. link: function (scope) {
  261. if (scope.$last == true) {
  262. setTimeout(function () {
  263. $("#table").rowspan(2)
  264. $("#table").rowspan(1)
  265. $("#table").rowspan(0)
  266. }, 10);
  267. }
  268. }
  269. };
  270. });
  271. function getWeek(year, month, day) {
  272. switch (new Date(year, month - 1, day).getDay()) {
  273. case 0: var week = "星期日"; break;
  274. case 1: var week = "星期一"; break;
  275. case 2: var week = "星期二"; break;
  276. case 3: var week = "星期三"; break;
  277. case 4: var week = "星期四"; break;
  278. case 5: var week = "星期五"; break;
  279. case 6: var week = "星期六"; break;
  280. }
  281. return week
  282. }
  283. jQuery.fn.rowspan = function (colIdx) { //封装的一个JQuery小插件
  284. return this.each(function () {
  285. var that;
  286. $('tr', this).each(function (row) {
  287. $('td:eq(' + colIdx + ')', this).filter(':visible').each(function (col) {
  288. if (that != null && $(this).html() == $(that).html()) {
  289. var rowspan = $(that).attr("rowSpan");
  290. if (rowspan == undefined) {
  291. $(that).attr("rowSpan", 1);
  292. rowspan = $(that).attr("rowSpan");
  293. }
  294. rowspan = Number(rowspan) + 1;
  295. $(that).attr("rowSpan", rowspan);
  296. $(this).remove();
  297. } else {
  298. that = this;
  299. }
  300. });
  301. });
  302. });
  303. }
  304. function formate(num) {
  305. return num > 9 ? num : "0" + num;
  306. }
  307. function OnlyOne(arr,filed) {
  308. var new_arr = [], obj = {};
  309. for (var i = 0; i < arr.length; i++) {
  310. if (!obj[arr[i][filed]]) {
  311. new_arr.push(arr[i])
  312. obj[arr[i][filed]] = true;
  313. }
  314. }
  315. return new_arr
  316. }