rcap.js 12 KB

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