我在一个日历插件上应用的JavaScript代码将一直工作到11月,但不是12月
这是代码我在一个日历插件上应用的JavaScript代码将一直工作到11月,但不是12月,javascript,angularjs,Javascript,Angularjs,这是代码 .controller('CalendarCtrl',function($scope,$state,ProjectServices,$filter){ var _date = $filter('date')(new Date(), 'yyyy-MM-dd'); $scope.data = { embeddedDate: _date }; $scope.userData=$state.params.username; $scope.employeeNam
.controller('CalendarCtrl',function($scope,$state,ProjectServices,$filter){
var _date = $filter('date')(new Date(), 'yyyy-MM-dd');
$scope.data = { embeddedDate: _date };
$scope.userData=$state.params.username;
$scope.employeeName = $state.params.employeeName;
$scope.mgrApprvemployeeId = $state.params.employeeID;
$scope.projectName = $state.params.projectName;
if(localStorage.getItem('employeeInfo')){
var employeeDetails = JSON.parse(localStorage.getItem('employeeInfo'));
if ($scope.mgrApprvemployeeId) {
$scope.calprofile= true;
employeeId = $scope.mgrApprvemployeeId;
$scope.mgrRsrcDetails = true;
}
else {
$scope.calprofile= false;
employeeId = employeeDetails.employeeId;
$scope.mgrRsrcDetails = false;
};
};
//localStorage.setItem('userselecteddate',JSON.stringify(data));
$scope.onTimeSet=function(newDate,oldDate){
var date= new Date(newDate),
day = (date.getDate() < 10 ? '0' : '') + date.getDate();
//day=date.getDate(),
//month=date.getMonth()+1,
month = ((date.getMonth() + 1) < 10 ? '0' : '') + (date.getMonth() + 1);
year=date.getFullYear();
// week = date.getWeeks();
if(date.getDay() == 6 || date.getDay() == 0)
//if (true)
{
alert('You are submitting for a weekend!');
};
selectedDateUser=year+"-"+month+"-"+day;
$scope.data = { embeddedDate: selectedDateUser};
if (!$scope.mgrApprvemployeeId) {
$state.go('app.dayview',{calendarDate:selectedDateUser,username:$scope.userData});
} else {
$state.go('app.manager-dayview',{calendarDate:selectedDateUser,userEmployeeId:$scope.mgrApprvemployeeId,userEmployeeName:$scope.employeeName,userProjectName:$scope.projectName});
};
}
$scope.beforeRender = function ($view, $dates, $leftDate, $upDate, $rightDate) {
var todaysDate = new Date();
var currentMonth = todaysDate.getMonth()+1;
var currentYear = todaysDate.getFullYear();
var currentDay = todaysDate.getDate();
var rightDate = $rightDate.utcDateValue;
var rightFormDate = new Date(rightDate);
var selectedMonth = rightFormDate.getMonth();
var selectedYear = rightFormDate.getFullYear();
if (currentMonth == selectedMonth && currentYear == selectedYear) {
$rightDate.selectable = false;
};
angular.element(document).ready(function () {
ProjectServices.getEmployeeEffortHrs(employeeId).then(function(data) {
angular.forEach(data, function(data) {
//console.log(data.effort_date);
var effort_date = new Date(data.effort_date);
var date = effort_date.getDate();
var monthService = effort_date.getMonth()+1;
var approvedStatus = data.approveStatus;
// datesArray.push(date);
//console.log(date);
var totalEffortHours = data.total_effort;
jQuery('div.datetimepicker table.day-view tbody tr td').each(function(index){
// console.log(index);
//console.log('1234');
var str = $(this).text();
if((str.substr(0,str.indexOf(' ')) == date) && selectedMonth == monthService){
//$(this).removeClass("pending-hrs").addClass("filled-hrs");
// $(this).removeClass('pending-hrs');
// $(this).addClass('filled-hrs');
if(totalEffortHours <= 8){
$(this).removeClass('pending-hrs');
$(this).addClass('filled-hrs');
if (!$scope.mgrApprvemployeeId) {
$dates[index].selectable = false;
};
}else {
$(this).removeClass('pending-hrs');
$(this).addClass('holiday-leave');
if (!$scope.mgrApprvemployeeId) {
$dates[index].selectable = false;
};
};
// e.stopPropagation();
// $(this).html(date + <br/> + totalEffortHours);
if(approvedStatus == "Reject"){
var stringDisplay = date+"<span class='rejected-timesheet'>"+"Rejected"+" </span> ";
//$(this).removeClass('disabled');
$dates[index].selectable = true;
} else{
var stringDisplay = date+"<span>"+totalEffortHours +" hrs</span>";
//$(this).addClass('disabled');
$(this).selectable = true;
};
var escaped = $(this).text(stringDisplay).text();
$(this).html(escaped.replace(/\n/g, '<br />'));
//$(this).html($(this).html().replace(/\n/g,'<br/>'));
}
});
/*if (calendarDateDay == date) {
alert(111);
$dates[j].display = $dates[j].display + " <br/>" + totalEffortHours;
}; */
});
});
for (var j=0; j < 37; j++) {
var calendarUtcDates = $dates[j].utcDateValue;
var calendarDates = new Date(calendarUtcDates);
var calendarDateDay = calendarDates.getDate();
var calendarDateMonth = calendarDates.getMonth()+1;
var calendarDateYear = calendarDates.getFullYear();
if (calendarDateMonth == selectedMonth)
{
jQuery('div.datetimepicker table.day-view tbody tr td').each(function(){
if(($(this).text() == $dates[j].display) && calendarDateMonth == selectedMonth){
$(this).addClass('pending-hrs');
}
if (currentMonth == calendarDateMonth && currentYear == calendarDateYear && currentDay <= calendarDateDay ) {
$dates[j].future = true;
}
});
if (currentMonth == calendarDateMonth && currentYear == calendarDateYear && currentDay > calendarDateDay ) {
$dates[j].display = $dates[j].display + "<span> Pending</span>";
}else if(currentMonth > calendarDateMonth && currentYear == calendarDateYear){
$dates[j].display = $dates[j].display + "<span> Pending</span>";
};
};
if (currentMonth == calendarDateMonth && currentYear == calendarDateYear && currentDay == calendarDateDay )
{
//console.log('today date');
$dates[j].display = $dates[j].display + "<span>Today</span>";
};
}
});
}
}).filter("sanitize", ['$sce', function($sce) {
return function(htmlCode) {
return $sce.trustAsHtml(htmlCode);
}
}])
.controller('CalendarCtrl',函数($scope、$state、ProjectServices、$filter){
var_date=$filter('date')(新日期(),'yyyy-MM-dd');
$scope.data={embeddedDate:_date};
$scope.userData=$state.params.username;
$scope.employeeName=$state.params.employeeName;
$scope.mgrappveEmployeeId=$state.params.employeeID;
$scope.projectName=$state.params.projectName;
if(localStorage.getItem('employeeInfo')){
var employeeDetails=JSON.parse(localStorage.getItem('employeeInfo');
if($scope.mgrappvEmployeeId){
$scope.calprofile=true;
employeeId=$scope.mgrapprovemployeeid;
$scope.mgrrsrcdestails=true;
}
否则{
$scope.calprofile=false;
employeeId=employeeDetails.employeeId;
$scope.mgrrsrccdetails=false;
};
};
//setItem('userselecteddate',JSON.stringify(data));
$scope.onTimeSet=函数(newDate、oldDate){
var日期=新日期(newDate),
day=(date.getDate()<10?'0':'')+date.getDate();
//day=date.getDate(),
//月=日期。getMonth()+1,
月=((date.getMonth()+1)<10?'0':'')+(date.getMonth()+1);
年份=日期。getFullYear();
//week=date.getWeeks();
如果(date.getDay()==6 | | date.getDay()==0)
//如果(真)
{
警报('您正在提交周末申请!');
};
所选日期用户=年+“-”+月+“-”+日;
$scope.data={embeddedDate:selectedDateUser};
if(!$scope.mgrapprovemployeeid){
$state.go('app.dayview',{calendarDate:selectedDateUser,username:$scope.userData});
}否则{
$state.go('app.manager dayview',{calendarDate:selectedDateUser,userEmployeeId:$scope.mgrapproveMployeeId,userEmployeeName:$scope.employeeName,userProjectName:$scope.projectName});
};
}
$scope.beforeRender=函数($view、$dates、$leftDate、$upDate、$rightDate){
var todaysDate=新日期();
var currentMonth=todaysDate.getMonth()+1;
var currentYear=todaysDate.getFullYear();
var currentDay=todaysDate.getDate();
var rightDate=$rightDate.utcDateValue;
var rightFormDate=新日期(rightDate);
var selectedMonth=rightFormDate.getMonth();
var selectedYear=rightFormDate.getFullYear();
如果(currentMonth==selectedMonth&¤tYear==selectedYear){
$rightDate.selective=false;
};
angular.element(文档).ready(函数(){
ProjectServices.getemployeeefforths(employeeId).then(函数(数据){
角度.forEach(数据,函数(数据){
//console.log(data.efforce_date);
var工作量\日期=新日期(数据.工作量\日期);
var date=efforce_date.getDate();
var monthService=efforce\u date.getMonth()+1;
var approvedStatus=data.approveStatus;
//datesArray.push(日期);
//控制台日志(日期);
var totalEffortHours=数据总工作量;
jQuery('div.datetimepicker table.day-view tbody tr td')。每个(函数(索引){
//控制台日志(索引);
//console.log('1234');
var str=$(this.text();
if((str.substr(0,str.indexOf(“”))=date)和&selectedMonth==monthService){
//$(此).removeClass(“待定小时”).addClass(“已填充小时”);
//$(this.removeClass('pending-hrs');
//$(this.addClass('filled-hrs');
if(TotalEffortours calendarDateMonth&¤tYear==calendarDateYear){
$dates[j]。display=$dates[j]。display+“挂起”;
};
};
如果(currentMonth==calendarDateMonth&¤tYear==calendarDateYear&¤tDay==calendarDateDay)
{
//console.log(“今日日期”);
$dates[j]。display=$dates[j]。display+“今天”;
};
}
});
}
}).filter(“消毒”、['$sce',函数($sce){
返回函数(htmlCode){
返回$sce.trustAsHtml(htmlCode);
}
}])
上面的代码给出的输出就像用户完成了以绿色显示的工作一样。这是通过添加一个类来实现的。如果用户的工作被管理者拒绝,它应该以另一种颜色显示。这是通过添加一个范围来实现的。如果用户的工作正在等待,它应该以另一种颜色显示。这也可以通过添加一个类来完成。但这些代码只在11月有效。仅在12月无效。有人能帮我吗。你找不到任何人有时间阅读所有代码。只添加相关部分或重新组织你的问题。是的,你需要提供一个答案。你找不到任何人有时间阅读所有代码。只添加相关部分或-组织你的问题。是的,你需要提供