'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, postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; 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, postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; self.list = res.data; console.log(self.list) self.list.forEach(function (item) { item.ZC1 = item.ZC; if (item.ZC == "") { item.ZC = " "; } }) }); } //self.getHY() self.getZB = function () { var data = { pageno: 1, pagesize: 10, order: "ZBSJ", startdate: sp.format(sp.getLocalDate()), enddate: sp.dateCount(1), userid: "" } $http.post(apiurljs.login + "g2app/desk/queryZhiBanWithPageT", data, postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = { "data": [{ "ZBGBXM1": "魏海军", "ZBSJ1": "张军", "ZBGBXM2": "", "DBLDXM": "李子英", "RIQI": 1, "NF": "2023", "CMONTH": "12", "SQDW": "办公室", "XINGQI": "星期五", "ZBSJ": "C01", "ZBSJV": "18:00-次日8:30", "NYR": "2023-12-01", "ZW": "二级巡视员" }, { "ZBGBXM1": "刘颖", "ZBSJ1": "张子彬", "ZBGBXM2": "", "DBLDXM": "谷燕成", "RIQI": 2, "NF": "2023", "CMONTH": "12", "SQDW": "办公室", "XINGQI": "星期六", "ZBSJ": "C02", "ZBSJV": "8:00-14:00", "NYR": "2023-12-02", "ZW": "办公室主任、二级巡视员" }, { "ZBGBXM1": "汤浩", "ZBSJ1": "张子彬", "ZBGBXM2": "", "DBLDXM": "谷燕成", "RIQI": 2, "NF": "2023", "CMONTH": "12", "SQDW": "办公室", "XINGQI": "星期六", "ZBSJ": "C03", "ZBSJV": "14:00-20:00", "NYR": "2023-12-02", "ZW": "办公室主任、二级巡视员" }, { "ZBGBXM1": "孔林杰", "ZBSJ1": "张子彬", "ZBGBXM2": "", "DBLDXM": "谷燕成", "RIQI": 2, "NF": "2023", "CMONTH": "12", "SQDW": "办公室", "XINGQI": "星期六", "ZBSJ": "C04", "ZBSJV": "20:00-次日8:00", "NYR": "2023-12-02", "ZW": "办公室主任、二级巡视员" }] } console.log(res) self.list = []; self.list1 = []; res.data.forEach(function (item) { if (item.NYR == sp.dateCount(0)) { self.list.push(item) } if (item.NYR == sp.dateCount(1)) { self.list1.push(item) } }) self.leader = OnlyOne(self.list, "DBLDXM") self.siji = OnlyOne(self.list, "ZBSJ1") self.leader1 = OnlyOne(self.list1, "DBLDXM") self.siji1 = OnlyOne(self.list1, "ZBSJ1") //var current = 0, next = 0; //$.each(self.dataList, function (index, item) { // if (item.NF + "-" + formate(item.CMONTH) + "-" + formate(item.RIQI) == sp.format(sp.getLocalDate())) { // current = index; // return; // } else if (item.NF + "-" + formate(item.CMONTH) + "-" + formate(item.RIQI) > sp.format(sp.getLocalDate())) { // next = index; // } //}) //if (current != 0) { // for (var i = current; i < self.dataList.length; i++) { // if (self.list.length == 4) { // return // } // self.list.push(self.dataList[i]) // } // if (self.list.length < 4) { // for (var j = self.list.length; j < 4; j++) { // self.list.unshift(self.dataList[current - j]) // } // } // self.list = self.list.filter(function (item) { // return item!=undefined // }) //} else { // for (var i = next; i < self.dataList.length; i++) { // if (self.list.length == 4) { // return // } // self.list.push(self.dataList[i]) // } // if (self.list.length < 4) { // for (var j = self.list.length; j < 4; j++) { // self.list.unshift(self.dataList[next - j]) // } // } // self.list = self.list.filter(function (item) { // return item != undefined // }) //} }); } 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())) } } 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("FZJ26", "一周安排", "tpl/lingdaobg/YZAP/taizhang.html") } else { window.top.jumpPageParent("FZJ28", "书记批示", "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("FZJ26", "一周安排", "tpl/lingdaobg/YZAP/taizhang.html") } else { window.top.sp.addTabNav("FZJ28", "书记批示", "tpl/shujipishi/taizhang.html") } } } self.goYZAP = function (date) { if (self.deviceType == "pad") { window.top.jumpPageParent("FZJ26-1", "一周安排查询", "tpl/lingdaobg/YZAP/total.html?date=" + date) } else { window.top.sp.addTabNav("FZJ26-1", "一周安排查询", "tpl/lingdaobg/YZAP/total.html?date=" + date) } } self.getYZAP = function () { self.weekList = sp.getWeekNumber(new Date()).dateString.split(",").map(function (day) { return sp.currentYear() + "-" + day.replace(".", "-") }) var data = { tablename: "SX_YZAPTZ", pagesize: 4, pageno: 1, colums: "*,TO_CHAR(YZAPDATE,'MM-dd HH:mm')as YZAPDATE1", order: "ID", sqlwhere: "", sqlorwhere: "", sqlinwhere: "", sqllikewhere: "" } $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", data, postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; self.list = res.data; self.list.forEach(function (item) { item.Date = sp.datefmt("MM-dd HH:mm",item.CTIME); }) }) } 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, postCfg) .success(function (obj) { //var res = strToJson(s4.decryptData_CBC(obj.data)); var res = obj; 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, ' ')); }; }); 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 } 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 }