123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365 |
- 'use strict';
- var app = angular.module('app', [
- 'angularUtils.directives.dirPagination',
- ]);
- app.controller("indexCtrl", ["$scope", "$http", "$interval", function ($scope, $http, $interval) {
- var self = this;
- self.userId = $.cookie("GlWorkPlatform-userid");
- self.userName = $.cookie("GlWorkPlatform-chineseName");
- self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- };
- self.getQXbtn = function () {
- var data = {
- userid: self.userId,
- ntops: 10
- };
- $http.post(apiurljs.login + "g2work/desktop/queryWorkflowCando", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.qxBtn = res.data;
- $.each(self.qxBtn, function (index, item) {
- item.FILEN = item.FILEN + "&dotype=1"
- })
- })
- }
- self.getQXbtn()
- self.openSwen = function (item) {
- window.parent.sp.addTabNav(item.FLOWID, item.FLOWNAME, item.FILEN)
- }
- self.dbList = [];
- self.Activedb = "全部";
- self.dbTitleList = [];
- self.getdbList = function (n) {
- var data = {
- userid: self.userId,
- ntops: 0
- };
- $http.post(apiurljs.login + "g2work/desktop/queryDataTodo", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (n == 0) {
- self.dbTitleList = [];
- self.dbList = [];
- self.dbDataList = res.data;
- self.dbItemList = { "width": (res.data.length + 4) * ($(".dbItem1").width() / 6 - 10), "height": "120px" }
- self.dbTitleList.push(self.Activedb);
- $.each(self.dbDataList, function (index, item) {
- if (self.dbTitleList.indexOf(item.FLOWNAME) == -1) {
- self.dbTitleList.push(item.FLOWNAME)
- }
- if (item.REMARKS.length == 3) {
- item.REMARKS = null;
- }
- item.day = self.getDay(item.RECEIVEDATE);
- item.MD = sp.datefmt("MM-dd", item.RECEIVEDATE);
- item.HM = sp.datefmt("HH:mm", item.RECEIVEDATE);
- item.USERNAMEFROM1 = "转自:" + item.USERNAMEFROM;
- item.width = { "width": $(".dbItem1").width() / 6 - 10 };
- item.FILEN = item.FILEN + "&dotype=1";
- self.dbList.push(item);
- })
- //$interval(function () {
- // self.getdbList(1)
- //}, 5000)
- } else {
- if (self.dbDataList.length == res.data.length) {
- return;
- } else {
- self.dbItemList = { "width": (res.data.length + 4) * ($(".dbItem1").width() / 6 - 10), "height": "120px" }
- var newDate = res.data.concat();
- for (var i = res.data.length - 1; i >= 0; i--) {
- $.each(self.dbDataList, function (index, item) {
- if (res.data[i].ROUTEINFOID == item.ROUTEINFOID) {
- newDate.splice(i, 1)
- }
- })
- }
- $.each(newDate, function (index, item) {
- if (self.dbTitleList.indexOf(item.FLOWNAME) == -1) {
- self.dbTitleList.push(item.FLOWNAME)
- }
- self.dbDataList.unshift(item);
- if (item.FLOWNAME == self.Activedb || self.Activedb == "全部") {
- if (item.REMARKS.length == 3) {
- item.REMARKS = null;
- }
- item.day = self.getDay(item.RECEIVEDATE);
- item.MD = sp.datefmt("MM-dd", item.RECEIVEDATE);
- item.HM = sp.datefmt("HH:mm", item.RECEIVEDATE);
- item.USERNAMEFROM1 = "转自:" + item.USERNAMEFROM;
- item.width = { "width": $(".dbItem1").width() / 6 - 10 };
- item.FILEN = item.FILEN + "&dotype=1"
- self.dbList.unshift(item);
- }
- })
- }
- }
- })
- }
- self.getDay = function (str) {
- var a = getDate(new Date());
- var b = getDate(new Date(str));
- var c = parseInt((a - b) / 86400000);
- return c < 0 || c > 2 ? 3 : c;
- }
- self.getdbList(0)
- self.dbItemNo = 0;//待办事项向左平移n个按钮
- self.dbpageWidth = 0;//待办事项向左平移距离
- self.dbpageLeft = function () {
- if (self.dbItemNo > 0 && self.dbList.length > 6) {
- //self.dbpageWidth = self.dbpageWidth + $(".dbItem").eq(self.dbItemNo - 1).outerWidth(true) * 6;
- //$(".dbItem1").children().first().css("margin-left", (self.dbpageWidth > 0 ? 0 : self.dbpageWidth));
- //self.dbItemNo = self.dbItemNo - 6;
- self.dbItemNo = self.dbItemNo - 6;
- self.dbpageWidth = $(".dbItem1").outerWidth(true) * (self.dbItemNo / 6);
- $(".dbItem1").children().first().css("margin-left", self.dbpageWidth * -1);
- } else {
- return;
- }
- }
- self.dbpageRight = function () {
- if (self.dbItemNo < $(".dbItem").length - 6 && self.dbList.length > 6) {
- //self.dbpageWidth = self.dbpageWidth - $(".dbItem").eq(self.dbItemNo).outerWidth(true) * 6;
- //$(".dbItem1").children().first().css("margin-left", self.dbpageWidth);
- //self.dbItemNo = self.dbItemNo + 6;
- self.dbItemNo = self.dbItemNo + 6;
- self.dbpageWidth = $(".dbItem1").outerWidth(true) * (self.dbItemNo / 6);
- $(".dbItem1").children().first().css("margin-left", self.dbpageWidth * -1);
- } else {
- return;
- }
- }
- self.resetdb = function (str) {
- self.dbList = [];
- self.Activedb = str;
- self.dbItemNo = 0;
- self.dbpageWidth = 0;
- $(".dbItem1").children().first().css("margin-left", 0);
- $.each(self.dbDataList, function (index, item) {
- if (item.FLOWNAME == self.Activedb || self.Activedb == "全部") {
- self.dbList.push(item);
- }
- })
- }
- self.ldrcNo = 0;//领导日程向左平移n个按钮
- self.ldrcWidth = 0;//领导日程向左平移距离
- self.ldrcLeft = function () {
- if (self.ldrcNo > 0) {
- self.dbpageWidth = self.dbpageWidth + $(".ldrcItem").eq(self.ldrcNo - 1).outerWidth(true);
- $(".ldrcItem").parent().css("margin-left", (self.dbpageWidth > 0 ? 0 : self.dbpageWidth));
- self.ldrcNo = self.ldrcNo - 1;
- } else {
- return;
- }
- }
- self.ldrcRight = function () {
- if (self.ldrcNo < $(".ldrcItem").length - 1) {
- self.dbpageWidth = self.dbpageWidth - $(".ldrcItem").eq(self.ldrcNo).outerWidth(true);
- $(".ldrcItem").parent().css("margin-left", self.dbpageWidth);
- self.ldrcNo = self.ldrcNo + 1;
- }
- }
- self.grrcNo = 0;//个人日程向左平移n个按钮
- self.grrcWidth = 0;//个人日程向左平移距离
- self.grrcLeft = function () {
- if (self.grrcNo > 0) {
- self.dbpageWidth = self.dbpageWidth + $(".grrcItem").eq(self.grrcNo - 1).outerWidth(true);
- $(".grrcItem").parent().css("margin-left", (self.dbpageWidth > 0 ? 0 : self.dbpageWidth));
- self.grrcNo = self.grrcNo - 1;
- } else {
- return;
- }
- }
- self.grrcRight = function () {
- if (self.grrcNo < $(".grrcItem").length - 1) {
- self.dbpageWidth = self.dbpageWidth - $(".grrcItem").eq(self.grrcNo).outerWidth(true);
- $(".grrcItem").parent().css("margin-left", self.dbpageWidth);
- self.grrcNo = self.grrcNo + 1;
- }
- }
- self.activeItem1 = "公文督办";
- self.activeItem2 = "通知公告";
- self.getData = function () {
- var data = {}
- $http.get("js/leader.txt", data, postCfg)
- .success(function (res) {
- self.list1 = res.list1;
- self.list2 = res.list2;
- self.ldzl = res.ldzl;
- self.today = {
- date: sp.getday(0),
- week: getWeek(sp.getday(0))
- };
- self.week = {
- date1: sp.getWeekNumber(new Date()).begin,
- date2: sp.getNextDate(sp.getWeekNumber(new Date()).begin, 1),
- date3: sp.getNextDate(sp.getWeekNumber(new Date()).begin, 2),
- date4: sp.getNextDate(sp.getWeekNumber(new Date()).begin, 3),
- date5: sp.getNextDate(sp.getWeekNumber(new Date()).begin, 4)
- }
- })
- }
- self.getData()
- /*日历开始*/
- self.all_year = [];
- self.all_month = [];
- self.select_year = ''
- self.select_month = ''
- self.active_day = ''
- self.week = ''
- //初始化显示 当前年和月
- self.show_now = function () {
- var now = new Date();
- self.select_year = now.getFullYear();
- self.select_month = now.getMonth() + 1;
- self.active_day = formate(now.getDate());
- self.cyear = now.getFullYear();
- self.cmonth = now.getMonth() + 1;
- self.cday = formate(now.getDate());
- self.showTime()
- //self.getDateWork(self.select_year, self.select_month, self.active_day)
- }
- self.showTime = function () {
- //在select中填入年份
- for (var year = self.select_year - 5; year < self.select_year + 5; year++) {
- var obj_1 = { 'value': year, 'id': year }
- self.all_year.push(obj_1);
- }
- //在select中填入月份
- for (var month = 1; month < 13; month++) {
- var obj_2 = { 'value': month, 'id': month }
- self.all_month.push(obj_2);
- }
- //初始化显示 当前年和月
- self.showDays(self.select_year, self.select_month)
- }
- //返回指定的月份的天数 月份1-12
- self.calDays = function (year, month) {
- return new Date(year, month, 0).getDate();
- }
- self.dateLeft = function () {
- var date = new Date(self.select_year, self.select_month - 1, 0)
- self.select_year = date.getFullYear();
- self.select_month = date.getMonth() + 1;
- self.showDays(self.select_year, self.select_month)
- }
- self.dateRight = function () {
- var date = new Date(self.select_year, self.select_month + 1, 0)
- self.select_year = date.getFullYear();
- self.select_month = date.getMonth() + 1;
- self.showDays(self.select_year, self.select_month)
- }
- //展示指定的年和月的所有日期
- self.showDays = function (year, month) {
- self.days = [];
- var days = [];
- self.dateWork = [];
- self.date_day = self.active_day;
- self.getWeek(self.select_year, self.select_month, self.active_day)
- //得到表示指定年和月的1日的那个时间对象
- var date = new Date(year, month - 1, 1);
- //1.先添加响应的空白的li:这个月1号是星期几,就添加几个空白的li
- var dayOfWeek = date.getDay(); //得到1日是星期几
- for (var i = 0; i < dayOfWeek; i++) {
- days.push({ day: "", id: i + 8 });
- }
- //计算一个月有多少天
- var daysOfMonth = self.calDays(year, month);
- //2. 从1号开始添加li
- for (var i = 1; i <= daysOfMonth; i++) {
- days.push({ day: formate(i), id: i + dayOfWeek + 7 });
- }
- var length = days.length;
- for (var i = 42; i > length; i--) {
- days.push({ day: "", id: daysOfMonth - i + 50 });
- }
- for (var i = 0; i < 6 ; i++) {
- self.days[i] = [];
- $.each(days, function (index, item) {
- if (Math.ceil((index + 1) / 7) == i + 1) {
- self.days[i].push(item)
- }
- })
- }
- if (JSON.stringify(days).indexOf('"day":' + JSON.stringify(self.active_day)) == -1) {
- for (var i = days.length - 1; i >= 0; i--) {
- if (days[i].day != "") {
- self.active_day = days[i].day;
- break;
- }
- }
- }
- }
- self.change_day = function (day) {
- if (day.day == "") { return; }
- var date = new Date(self.select_year, self.select_month - 1, 1);
- var dayOfWeek = date.getDay();
- self.active_day = day.day;
- self.date_day = self.active_day;
- self.getWeek(self.select_year, self.select_month, self.active_day);
- }
- self.getWeek = function (year, month, day) {
- switch (new Date(year, month - 1, day).getDay()) {
- case 0: self.week = "星期日"; break;
- case 1: self.week = "星期一"; break;
- case 2: self.week = "星期二"; break;
- case 3: self.week = "星期三"; break;
- case 4: self.week = "星期四"; break;
- case 5: self.week = "星期五"; break;
- case 6: self.week = "星期六"; break;
- }
- }
- /*日历结束*/
- self.openSwen = function (item) {
- window.parent.sp.addTabNav(item.FLOWID, item.FLOWNAME, item.FILEN)
- }
- }])
- function formate(num) {
- return num > 9 ? num : "0" + num;
- }
- function getWeek(date) {
- switch (new Date(date).getDay()) {
- case 0: return "星期日"; break;
- case 1: return "星期一"; break;
- case 2: return "星期二"; break;
- case 3: return "星期三"; break;
- case 4: return "星期四"; break;
- case 5: return "星期五"; break;
- case 6: return "星期六"; break;
- }
- }
- function getDate(str) {
- var year = str.getFullYear();
- var month = str.getMonth();
- var day = str.getDate();
- return new Date(year, month, day).getTime()
- }
|