rcap.js 13 KB

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