<p>我打算在同一日历中使用两个不同的时期。到目前为止,我发现的唯一方法是在两个不同的日历中执行此操作,如下所示:</p>
<p>
<pre class="brush:js;toolbar:false;">$(".btn-show").click(function(e) {
e.preventDefault();
el = $(this).data('element');
$(el).show();
$("section > div").not(el).hide();
});
$(document).on('click', '.dad-visita', function(){
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
initialViews = 'timeGridWeek';
}else{
initialViews = 'timeGridWeek';
}
var calendarEl = document.getElementById('calendario');
var today = moment().day();
var calendar = new FullCalendar.Calendar(calendarEl, {
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
locale: "pt-br",
buttonText:{
today: 'Hoje',
list: 'Lista'
},
navLinks: true,
firstDay: today,
hiddenDays: [ 0 ],
initialView: initialViews,
editable: true,
selectable: true,
unselectAuto:true,
eventOverlap: false,
eventColor: '#f16621',
slotDuration: '00:45',
allDaySlot : false,
eventStartEditable: false,
eventDurationEditable:false,
longPressDelay: 0,
nowIndicator: "true",
slotMinTime: '10:30',
slotMaxTime: '12:00',
contentHeight: 'auto',
});
calendar.render();
});
$(document).on('click', '.dad-visita', function(){
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
initialViews = 'timeGridWeek';
}else{
initialViews = 'timeGridWeek';
}
var calendarEl = document.getElementById('calendario1');
var today = moment().day();
var calendar = new FullCalendar.Calendar(calendarEl, {
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
locale: "pt-br",
buttonText:{
today: 'Hoje',
list: 'Lista'
},
navLinks: true,
firstDay: today,
hiddenDays: [ 0 ],
initialView: initialViews,
editable: true,
selectable: true,
unselectAuto:true,
eventOverlap: false,
eventColor: '#f16621',
slotDuration: '00:45',
allDaySlot : false,
eventStartEditable: false,
eventDurationEditable:false,
longPressDelay: 0,
nowIndicator: "true",
slotMinTime: '14:30',
slotMaxTime: '19:00',
contentHeight: 'auto',
});
日历.render();
});</pre>
<link href="https://cdn.jsdelivr.net/npm/fullcalendar@5.9.0/main.min.css" rel="样式表”>
<脚本 src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<脚本 src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<脚本 src="https://cdn.jsdelivr.net/npm/fullcalendar@5.9.0/main.min.js"></script>
<脚本 src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/pt-br.js"></script>
<a href="s160" data-element="#minhaDiv160" class="btn-show bad-visita">
<i class="metismenu-icon pe-7s-info"></i>
顾问拜访
</a>
<节 id="s160">
<div class="cal-wrapper"><div id='calendario'></div></div>
<div class="cal-wrapper"><div id='calendario1'></div></div>
;
</section></pre>
</p>
<p>但是这样我就必须有两个日历,这不是正确的方法。我必须这样做的原因是我需要 slotDuration 为 45 分钟,并且在早上它会正确假设事件的时间。</p>
<p>但是下午的活动从 14:30 开始,并且通过此 slotDuration,如果您将 slotMinTime 设置为 10:30,将 slotMaxTime 设置为 19:00,则下午活动的日历将从 14:15 开始,如示例所示: </p>
<p>
<pre class="brush:js;toolbar:false;">$(".btn-show").click(function(e) {
e.preventDefault();
el = $(this).data('element');
$(el).show();
$("section > div").not(el).hide();
});
$(document).on('click', '.dad-visita', function(){
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
initialViews = 'timeGridWeek';
}else{
initialViews = 'timeGridWeek';
}
var calendarEl = document.getElementById('calendario');
var today = moment().day();
var calendar = new FullCalendar.Calendar(calendarEl, {
headerToolbar: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
locale: "pt-br",
buttonText:{
today: 'Hoje',
list: 'Lista'
},
navLinks: true,
firstDay: today,
hiddenDays: [ 0 ],
initialView: initialViews,
editable: true,
selectable: true,
unselectAuto:true,
eventOverlap: false,
eventColor: '#f16621',
slotDuration: '00:45',
allDaySlot : false,
eventStartEditable: false,
eventDurationEditable:false,
longPressDelay: 0,
nowIndicator: "true",
slotMinTime: '10:30',
slotMaxTime: '19:00',
contentHeight: 'auto',
});
日历.render();
});</pre>
<link href="https://cdn.jsdelivr.net/npm/fullcalendar@5.9.0/main.min.css" rel="样式表”>
<脚本 src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<脚本 src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<脚本 src="https://cdn.jsdelivr.net/npm/fullcalendar@5.9.0/main.min.js"></script>
<脚本 src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/pt-br.js"></script>
<a href="s160" data-element="#minhaDiv160" class="btn-show bad-visita">
<i class="metismenu-icon pe-7s-info"></i>
顾问拜访
</a>
<节 id="s160">
<div class="cal-wrapper"><div id='calendario'></div></div>
<div class="cal-wrapper"><div id='calendario1'></div></div>
;
</section></pre>
</p>
<p>当从 14:15 开始时,它很快就会返回我想要的所有不同下午事件的时间。</p>
<p>我仍然找不到解决这个问题的方法。</p>
<p><strong>带有 selectAllow 的代码:</strong></p>
<p>
$(".btn-show").click(function(e) {
e.preventDefault();
el = $(this).data('元素');
$(el).show();
$("section > div").not(el).hide();
});
$(document).on('click', '.dad-visita', function(){
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
初始视图 = 'timeGridWeek';
}别的{
初始视图 = 'timeGridWeek';
}
var calendarEl = document.getElementById('calendario');
var 今天 = moment().day();
var 日历 = new FullCalendar.Calendar(calendarEl, {
标题工具栏:{
left: '上一个,下一个今天',
中心:'标题',
右:'dayGridMonth、timeGridWeek、timeGridDay'
},
区域设置:“pt-br”,
按钮文本:{
今天:“Hoje”,
列表:“列表”
},
导航链接:真实,
第一天:今天,
隐藏天数: [ 0 ],
初始视图:初始视图,
可编辑:真实,
可选:真,
取消选择自动:true,
事件重叠:假,
事件颜色: '#f16621',
时隙持续时间:'00:15',
allDaySlot : 假,
事件开始可编辑:假,
事件持续时间可编辑:假,
长按延迟:0,
now指标:“true”,
slotMinTime: '10:30',
slotMaxTime: '19:00',
内容高度:'自动',
选择:函数(开始,结束){
var start1 = moment((start.startStr)).format('HH:mm:ss');
if(start1 == '14:15:00'){
$('#ModalAddVisit #start').val(moment((start.startStr)).format('YYYY-MM-DD' + " " + '14:30:00'));
$('#ModalAddVisit #end').val(moment((start.startStr)).format('YYYY-MM-DD' + " " + '15:15:00'));
$("#ModalAddVisit").modal("显示");
}
},
});
日历.render();
});</前>
<pre class="brush:html;toolbar:false;"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/ bootstrap.min.css">
<link href="https://cdn.jsdelivr.net/npm/fullcalendar@5.9.0/main.min.css" rel="stylesheet">
<脚本 src="https://cdn.jsdelivr.net/npm/jquery@3.6.0/dist/jquery.min.js"></script>
<脚本 src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<脚本 src="https://cdn.jsdelivr.net/npm/fullcalendar@5.9.0/main.min.js"></script>
<脚本 src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/locale/pt-br.js"></script>
<脚本 src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<脚本 src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.min.js"></script>
<a href="s160" data-element="#minhaDiv160" class="btn-show Dad-visita">
<i class="metismenu-icon pe-7s-info"></i>
顾问拜访
</a>
<节 id="s160">
<div class="cal-wrapper"><div id='calendario'></div></div>
</节>
<div class="modal-content">
<div class="modal-header">
NOVA VISITA
;
<按钮类型=“按钮”类=“btn-close”data-bs-dismiss=“modal”aria-label=“关闭”>按钮>
;
<div class="modal-body">
<form method="POST" class="row g-3 insvisit">
<div class="col-6">
<标签=“开始”> <strong>数据/HORA INICIAL</strong> <span style="color: red;">*</span></label>
<需要输入类型=“文本”名称=“开始”id=“开始”>
<div class="col-6">
<标签=“结束”> <strong>数据/HORA FINAL</strong> <span style="color: red;">*</span></label>
<输入类型=“文本”名称=“结束”id=“结束”必需>
FullCalendar 不允许您在同一日历上设置两个不同的最小值和最大值。
要解决这个问题,但仍能实现强制执行 45 分钟时段的目标,并在中午休息一段时间(此时无法创建任何活动),您可以