123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- '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 (res) {
- 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 (res) {
- 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, postCfg)
- .success(function (res) {
- 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 data1 = {
- pageno: 0,
- pagesize: 0,
- order: "NYR",
- startdate: sp.monthfirst(sp.getPreMonthDay(sp.getLocalDate(), 1)),
- enddate: sp.formatMonthLast(sp.getPreMonthDay(sp.getLocalDate(), 1)),
- userid: ""
- }
- $http.post(apiurljs.login + "g2app/desk/queryZhiBanWithPageT", data1, postCfg)
- .success(function (res1) {
- 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, postCfg)
- .success(function (res) {
- 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, postCfg)
- .success(function (res) {
- 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, '<br/>').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
- }
|