angularjs-视图上的完整日历设置动态数据(每月到每周)

hivapdat  于 2021-09-29  发布在  Java
关注(0)|答案(0)|浏览(243)

使用api在ui日历中设置数据,我调用动态函数,以正确的方式获取数据,并在日历月视图中设置数据。
但是现在,单击每月到每周,我想调用常见的getweeklydatafn函数。请帮帮我。对不起,我的英语很差。
这是我的密码,

$scope.datewise_event_data = [];
$scope.eventInfoStatus = 0;
$scope.getWeeklyDataFn = function () {
    var obj = angular.copy($scope.filter);
    var calendar = $('#calendar').fullCalendar('getCalendar');
    var view = calendar.view;
    if (!view) {
        $scope.setFlash('e', "Something Wrong In getting Data.Please Refresh Again");
        return false;
    }
    obj.view_name = view.name;
    obj.start_date = moment(view.intervalStart._d).format('YYYY-MM-DD');
   //        obj.end_date = moment(view.intervalEnd._d).format('YYYY-MM-DD');
    obj.end_date = moment(view.intervalEnd._d).subtract(1, "days").format("YYYY-MM-DD");
    ;
    weekly_calenderService.get_calender_type_wise_visits(obj).then(function (res) {
        if (res.data.flag) {
            $scope.pendingEvents = [];
            $scope.completeEvents = [];
            $scope.missEvents = [];
            $scope.savedEvents = [];
            var calEvents = [];
            _.each(res.data.data, function (nw) {
                var date = nw.date.split('-');
 //                    if (nw.pending > 0) {
                $scope.pendingEvents.push({
                    title: nw.pending,
                    event_info: nw,
                    start: new Date((date[0] * 1), (date[1] * 1) - 1, (date[2] * 1)),
                    className: 'calender-primary-label',
                    allDay: false,
                    status: 0,
                    date: nw.date
                });
   //                    }
  //                    if (nw.complete > 0) {
                $scope.completeEvents.push({
                    title: nw.complete,
                    event_info: nw,
                    start: new Date((date[0] * 1), (date[1] * 1) - 1, (date[2] * 1), 0, 0),
                    className: 'calender-success-label',
                    allDay: false,
                    status: 1,
                    date: nw.date
                });
 //                    }
 //                    if (nw.missed > 0) {
                $scope.missEvents.push({
                    title: nw.missed,
                    event_info: nw,
                    start: new Date((date[0] * 1), (date[1] * 1) - 1, (date[2] * 1)),
                    className: 'calender-danger-label',
                    allDay: false,
                    status: 2,
                    date: nw.date
                });
 //                    }
 //                    if (nw.saved > 0) {
                $scope.savedEvents.push({
                    title: nw.saved,
                    event_info: nw,
                    start: new Date((date[0] * 1), (date[1] * 1) - 1, (date[2] * 1)),
                    className: 'calender-warning-label',
                    allDay: false,
                    status: 5,
                    date: nw.date
                });
  //                    }
            })
            calEvents = $scope.pendingEvents.concat($scope.completeEvents, $scope.missEvents, $scope.savedEvents);
            $scope.calendarOptions.events = calEvents;
        } else {
            var calEvents = [];
            $scope.datewise_event_data = [];
            $scope.eventInfoStatus = -1;
            $scope.setFlash('e', res.data.message);
        }
    })
}

$scope.calendarOptions = {
    editable: false,
    height: 500,
    defaultView: 'month',
    events: [],
    displayEventTime: false,
    themeSystem: 'standard',
    header: {
        left: '',
        center: '',
        right: 'month,agendaWeek prev,title,next'
    },
    buttonText: {
        month: 'Month',
        week: 'Week',
    },
    eventClick: function (event) {
        console.log(event.status);
        var obj = angular.copy({
            date: event.date,
            status: event.status
        })
        weekly_calenderService.get_calender_datewise_visits(obj).then(function (res) {
            if (res.data.flag) {
                $scope.datewise_event_data = res.data.data;
                $scope.eventInfoStatus = event.status;
                console.log($scope.eventInfoStatus);
            } else {
                $scope.datewise_event_data = [];
                $scope.setFlash('e', res.data.message);
            }
        })
    },
    eventAfterAllRender: function (view) {
        $timeout(function () {
            $scope.getWeeklyDataFn();
        }, true);
    },
    eventRender: function (event, element, view) {
        $compile(element)($scope);
    }
}

另外,我想在下一个上一个按钮上调用这个函数。请给我正确的解决办法。

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题