rcap.js 12 KB

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