'use strict'; var app = angular.module('app', [ 'angularUtils.directives.dirPagination', ]); app.controller("indexCtrl", ["$scope", "$http", "$interval", "$timeout", function ($scope, $http, $interval, $timeout) { var self = this; self.userId = $.cookie("GlWorkPlatform-userid"); self.userName = $.cookie("GlWorkPlatform-username"); self.userChineseName = $.cookie("GlWorkPlatform-chineseName") self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } }; self.currentYear = sp.currentYear(); self.currentMonth = sp.currentMonth(); self.currentDay = new Date().getDate(); self.currentWeek = getWeek(self.currentYear, self.currentMonth, self.currentDay) self.checkItem = 2; self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType"); self.YZAP = false; self.getROLE = function () { var data = { userid: self.userId }; $http.post(apiurljs.login + "g2work/datazu/queryDataUserAuth", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); for (var i = 0; i < res.data[0].auths.length; i++) { if (res.data[0].auths[i].ZID == "AA08" && res.data[0].auths[i].AUTH == "1") { self.YZAP = true; } } }); } self.getROLE() self.list = []; self.getHY = function () { var data = { pageno: 1, pagesize: 3, order: "HYSJ desc", cdate: sp.format(sp.getLocalDate()) + " 00:00:00", userid: self.userId } $http.post(apiurljs.login + "g2app/desk/queryHuiYiWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.list = res.data; self.list.forEach(function (item) { item.ZC1 = item.ZC; if (item.ZC == "") { item.ZC = " "; } }) }); } //self.getHY() self.getZB = function () { self.listShow = true; self.list1Show = false; var data = { pageno: 0, pagesize: 0, order: "NYR ASC,ZBSJ ASC", startdate: sp.monthfirst(sp.getLocalDate()), enddate: sp.formatMonthLast(sp.getLocalDate()), userid: "" } $http.post(apiurljs.login + "g2app/desk/queryZhiBanWithPageT", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.list = []; res.data.forEach(function (item) { var n = 0; self.list.forEach(function (item1) { if (item1.NYR == item.NYR) { n++ item1.ZBLD.push(item.ZBGBXM1) item1.ZBLD.push(item.ZBGBXM2) if (item1.DBLD.join(",").indexOf(item.DBLDXM) == -1) { item1.DBLD.push(item.DBLDXM) } } }) if (n == 0) { item.ZBLD = []; item.ZBLD.push(item.ZBGBXM1) item.ZBLD.push(item.ZBGBXM2) item.DBLD = []; item.DBLD.push(item.DBLDXM) self.list.push(item) } }); self.list.forEach(function (item) { item.ZBLD1 = item.ZBLD.filter(function (x) { return x != "" && x != null; }).join(",") item.DBLDXM1 = item.DBLD.filter(function (x) { return x != "" && x != null; }).join(",") }) var data = { pageno: 0, pagesize: 0, order: "NYR ASC,ZBSJ ASC", startdate: sp.monthfirst(sp.getPreMonthDay(sp.getLocalDate(), 1)), enddate: sp.formatMonthLast(sp.getPreMonthDay(sp.getLocalDate(), 1)), userid: "" } $http.post(apiurljs.login + "g2app/desk/queryZhiBanWithPageT", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj1) { var res1 = strToJson(s4.decryptData_CBC(obj1.data)); self.list1 = []; res1.data.forEach(function (item) { var n = 0; self.list1.forEach(function (item1) { if (item1.NYR == item.NYR) { n++ item1.ZBLD.push(item.ZBGBXM1) item1.ZBLD.push(item.ZBGBXM2) if (item1.DBLD.join(",").indexOf(item.DBLDXM) == -1) { item1.DBLD.push(item.DBLDXM) } } }) if (n == 0) { item.ZBLD = []; item.ZBLD.push(item.ZBGBXM1) item.ZBLD.push(item.ZBGBXM2) item.DBLD = []; item.DBLD.push(item.DBLDXM) self.list1.push(item) } }); self.list1.forEach(function (item) { item.ZBLD1 = item.ZBLD.filter(function (x) { return x != "" && x != null; }).join(",") item.DBLDXM1 = item.DBLD.filter(function (x) { return x != "" && x != null; }).join(",") }) }); }); } self.getZB() self.goCurrentMonth = function () { //if (self.deviceType == "pad") { // window.top.jumpPageParent("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html?date=" + sp.datefmt('yyyy-MM',sp.getLocalDate())) //} else { // window.top.sp.addTabNav("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html?date=" + sp.datefmt('yyyy-MM', sp.getLocalDate())) //} if (self.deviceType == "pad") { window.top.jumpPageParent("FZJ08-1", "值班表", "tpl/zhibanmgr/zhiban.html?date=" + sp.datefmt('yyyy-MM', sp.getLocalDate())) } else { window.top.sp.addTabNav("FZJ08-1", "值班表", "tpl/zhibanmgr/zhiban.html?date=" + sp.datefmt('yyyy-MM', sp.getLocalDate())) } } self.goNextMonth = function () { if (self.deviceType == "pad") { window.top.jumpPageParent("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html?date=" + sp.datefmt("yyyy-MM", sp.getPreMonthDay(sp.getLocalDate(), 1))) } else { window.top.sp.addTabNav("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html?date=" + sp.datefmt("yyyy-MM", sp.getPreMonthDay(sp.getLocalDate(), 1))) } } self.GoToPage = function () { if (self.deviceType == "pad") { if (self.checkItem == 1) { //window.top.jumpPageParent("FZJ06", "会议室管理", "tpl/huiyishimgr/list.html"); } else if (self.checkItem == 2) { window.top.jumpPageParent("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html") } else if (self.checkItem == 3) { window.top.jumpPageParent("FZF08", "一周安排", "tpl/lingdaobg/YZAP/taizhang.html") } else { window.top.jumpPageParent("FZR19", "书记批示", "tpl/shujipishi/taizhang.html") } } else { if (self.checkItem == 1) { //window.top.sp.addTabNav("FZJ06", "会议室管理", "tpl/huiyishimgr/list.html"); } else if (self.checkItem == 2) { window.top.sp.addTabNav("FZJ08", "值班管理", "tpl/zhibanmgr/zhiban.html") } else if (self.checkItem == 3) { window.top.sp.addTabNav("FZF08", "一周安排", "tpl/lingdaobg/YZAP/taizhang.html") } else { window.top.sp.addTabNav("FZR19", "书记批示", "tpl/shujipishi/taizhang.html") } } } self.goYZAP = function (date) { if (self.deviceType == "pad") { window.top.jumpPageParent("FZF08-1", "一周安排查询", "tpl/lingdaobg/YZAP/total.html?date=" + date) } else { window.top.sp.addTabNav("FZF08-1", "一周安排查询", "tpl/lingdaobg/YZAP/total.html?date=" + date) } } self.getYZAP = function (selectDay) { self.list = []; self.loading = false; var data = { tablename: "SX_YZAPTZ", colums: "*,TO_CHAR(YZAPDATE,'MM-dd')as YZAPDATE1", order: "YZAPDATE ASC,CTIME ASC,LDSORTID ASC,CNAME ASC", sqlwhere: " and YZAPDATE BETWEEN '" + sp.getWeekNumber(new Date()).begin + " 00:00:00' AND '" + sp.getWeekNumber(new Date()).end + " 23:59:59'" } $http.post(apiurljs.login + "g2app/dataabase/queryDataByColStr", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.list = res.data; self.list.forEach(function (item) { item.CTIME1 = item.CTIME.slice(11, 16); item.CNAME = item.CNAME == "null" ? "" : item.CNAME item.ATTENDANCESCOPE = item.ATTENDANCESCOPE == "null" ? "" : item.ATTENDANCESCOPE item.ADDR = item.ADDR == "null" ? "" : item.ADDR item.TIMEPERIOD1 = item.TIMEPERIOD; item.CTIME2 = item.CTIME1; item.CNAME1 = item.CNAME; item.ATTENDANCESCOPE1 = item.ATTENDANCESCOPE; item.ADDR1 = item.ADDR; }) }) } self.getPSTZ = function () { var data = { tablename: "SX_SJPSWJTZ", pagesize: 4, pageno: 1, colums: "*,TO_CHAR(QPSJ,'dd')as QPSJ1,TO_CHAR(DBTXTIME,'yyyy-mm-dd')as DBTXTIME1", order: "ID", sqlwhere: "", sqlorwhere: "", sqlinwhere: "", sqllikewhere: "" } $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.list = res.data; self.list.forEach(function (item) { if (item.SJPS != null && item.SJPS.slice(0, 1) == "[") { var text = []; JSON.parse(item.SJPS).forEach(function (item1) { text.push(item1.opinion + " — " + item1.username + "," + item1.cdate) }) item.SJPS = text.join(";") } }) }) } }]) app.filter('toHtml', function ($sce) { return function (str) { return $sce.trustAsHtml(str.replace(/\n/g, '
').replace(/\s/g, ' ')); }; }); app.directive("repeatFinish", function () { return { link: function (scope) { if (scope.$last == true) { setTimeout(function () { $("#table").rowspan(2) $("#table").rowspan(1) $("#table").rowspan(0) }, 10); } } }; }); function getWeek(year, month, day) { switch (new Date(year, month - 1, day).getDay()) { case 0: var week = "星期日"; break; case 1: var week = "星期一"; break; case 2: var week = "星期二"; break; case 3: var week = "星期三"; break; case 4: var week = "星期四"; break; case 5: var week = "星期五"; break; case 6: var week = "星期六"; break; } return week } jQuery.fn.rowspan = function (colIdx) { //封装的一个JQuery小插件 return this.each(function () { var that; $('tr', this).each(function (row) { $('td:eq(' + colIdx + ')', this).filter(':visible').each(function (col) { if (that != null && $(this).html() == $(that).html()) { var rowspan = $(that).attr("rowSpan"); if (rowspan == undefined) { $(that).attr("rowSpan", 1); rowspan = $(that).attr("rowSpan"); } rowspan = Number(rowspan) + 1; $(that).attr("rowSpan", rowspan); $(this).remove(); } else { that = this; } }); }); }); } function formate(num) { return num > 9 ? num : "0" + num; } function OnlyOne(arr,filed) { var new_arr = [], obj = {}; for (var i = 0; i < arr.length; i++) { if (!obj[arr[i][filed]]) { new_arr.push(arr[i]) obj[arr[i][filed]] = true; } } return new_arr }