FullCalendar 上的默认值(拖放事件)

Default Values on a FullCalendar (drag&drop events)

(对不起我的英语,我来自阿根廷) 我正在为从侧面板(客户端 selected)拖到整个日历的班次(项目)制作日历。事件在 fullCalendar 中后,您可以使用它执行三个操作:

移位元素是使用以下函数创建的

$('#add-new-event').click(function(e) {
    e.preventDefault()
        //Get value and make sure it is not null
    var val = $('#new-event').val()
    if (val.length == 0) {
        return
    }

    var desc = $('#new-desc-event').val()
    console.log(desc);
    //Create events
    var event = $('<div />')

    event.css({
        'font-weight': 300,
        'background-color': currColor,
        'border-color': currColor,
        'color': '#fff'
    }).addClass('external-event')
    if (desc == "") {

        event.html(val)
    } else {

        event.html(val + ' - ' + desc)
    }

项目创建后(其中包含客户姓名和描述),我可以 select 并将其拖到具有以下配置的日历中

new FullCalendarInteraction.Draggable(containerEl, {
    itemSelector: '.external-event',
    eventData: function(eventEl) {

        return {
            title: eventEl.innerText,
            backgroundColor: window.getComputedStyle(eventEl, null).getPropertyValue('background-color'),
            borderColor: window.getComputedStyle(eventEl, null).getPropertyValue('background-color'),
            textColor: window.getComputedStyle(eventEl, null).getPropertyValue('color'),
        };
    }
});

view = 'timeGridDay';
header = {
    left: 'prev,next timeGridDay,timeGridWeek,dayGridMonth',
    center: '',
    right: ''
};


var calendar = new FullCalendar.Calendar(calendarEl, {
    timeZone: 'local',
    plugins: ['interaction', 'dayGrid', 'timeGrid'],
    defaultView: 'timeGridDay',
    defaultDate: hoy,
    header: header,
    businessHours: [ // specify an array instead
        {
            daysOfWeek: [1, 2, 3, 4, 5, 6],
            startTime: '09:00', // 8am
            endTime: '21:00' // 6pm
        }
    ],
    minTime: "09:00",
    maxTime: "21:00",
    events: [{
        title: 'Agustin Guerra',
        start: '2020-03-12T10:30:00',
        end: '2020-03-12T11:30:00',
        description: 'hola'
    }],
    eventClick: function(calEvent, jsEvent, view) {

        e = JSON.stringify(calEvent.event.end)
        s = JSON.stringify(calEvent.event.start)

        //  Configurando StartDate
        var startObj = (calEvent.event.start);
        var local = startObj, // Local timestamp
            m = new moment(local), // Moment representing local time
            a = moment.utc(local), // Specify that 'local' is UTC
            b = m.utc(+3); // Generate UTC time from local
        start = m.format();


        //  Configurando EndDate
        var startObj = (calEvent.event.end);
        var local = startObj, // Local timestamp
            m = new moment(local), // Moment representing local time
            a = moment.utc(local), // Specify that 'local' is UTC
            b = m.utc(+3); // Generate UTC time from local
        end = m.format();

        dia = (end).substr(8, 2);
        mes = (end).substr(5, 2);
        ano = (end).substr(0, 4);
        fecha = dia + '-' + mes + '-' + ano;


        $("#title").val(calEvent.event.title);
        $("#date").val('El dia ' + fecha);
        $("#start").val('Desde las ' + (start).substr(11, 5));
        $("#end").val('Hasta las ' + (end).substr(11, 5));
        $("#description").val(calEvent.event.description);


        $("#exampleModal").modal();

    },
    editable: true,
    droppable: true, // this allows things to be dropped onto the calendar !!!
    drop: function(info) {

        info.draggedEl.parentNode.removeChild(info.draggedEl);

    }
});

What happens is the following: When clicking on an event that is already dragged on the calendar, a modal opens where you can see the following data: Client name, Shift date, Start time, End time, and Description . But I have an error in this section.

如果我将事件从侧面板拖到 fullCalendar,然后单击它(已经在日历上),模式打开但它没有结束日期或时间,但它确实有客户端、开始时间和描述。

如果我将事件或开始时间拖放到事件中,问题仍然存在。

如果我修改了事件的持续时间,现在它已配置好并且模式正确显示数据。

我想第一次拖动事件以正确加载结束日期和时间。

问题已解决。解决方案设置 属性 forceEventDurationtrue

  forceEventDuration: true