l
chenfeng 6 months ago
parent 1704885c08
commit ac5cf94ed6
  1. 103
      src/main/webapp/html/back/yuyueList/reservationRecord_commont.html
  2. 109
      src/main/webapp/html/back/yuyueList/reservationRecord_commontTwo.html

@ -465,31 +465,25 @@
btnAlign: 'c',
success: function(layero, index) {
// 初始化日期选择器
// 确保弹框 DOM 完全加载后,再初始化日期选择器
setTimeout(function() {
layui.laydate.render({
elem: '#modifyAppointmentDate',
type: 'date',
format: 'yyyy-MM-dd',
min: 0,
value: currentDate,
trigger: 'click',
});
}, 100);
// 加载时段数据
getAppointmentTimeSlots()
.then(function(slots) {
renderTimeSlots(slots);
if(currentSlot) {
$('#modifyAppointmentSlot').val(currentSlot);
layui.form.render('select');
layui.laydate.render({
elem: '#modifyAppointmentDate',
type: 'date',
format: 'yyyy-MM-dd',
min: 0,
value: currentDate,
trigger: 'click',
done: function(value, date) {
// 日期选择后加载对应日期的时段
if (value) {
loadTimeSlotsByDate(value);
}
})
.catch(function(error) {
layer.msg(error, {icon: 2});
$('#modifyAppointmentSlot').html('<option value="">加载失败</option>');
});
}
});
// 初始加载时段数据
if (currentDate) {
loadTimeSlotsByDate(currentDate, currentSlot);
}
},
yes: function(index, layero) {
var form = layui.form;
@ -519,24 +513,37 @@
});
}
// 获取预约时段数据的函数
function getAppointmentTimeSlots() {
return new Promise((resolve, reject) => {
$.ajax({
url: ctx + "/appointmentRecord/getTimeInfo?timeInfoId="+ appointmentTimeInfoId,
type: "GET",
dataType: "json",
success: function(res) {
if(res.success && res.data) {
resolve(res.data);
} else {
reject(res.message || "获取时段数据失败");
// 根据日期加载时段数据
function loadTimeSlotsByDate(date, selectedSlot) {
layer.load(1); // 显示加载中
// 清空现有选项并显示加载中
var $select = $('#modifyAppointmentSlot');
$select.html('<option value="">加载中...</option>');
layui.form.render('select');
$.ajax({
url: ctx + "/appointmentRecord/getTimeInfo?timeInfoId="+ appointmentTimeInfoId+"&unavailableDate="+date,
type: "GET",
dataType: "json",
success: function(res) {
layer.closeAll('loading');
if(res.success && res.data) {
renderTimeSlots(res.data);
if(selectedSlot) {
$select.val(selectedSlot);
layui.form.render('select');
}
},
error: function(xhr, status, error) {
reject("请求失败: " + error);
} else {
$select.html('<option value="">加载失败</option>');
layer.msg(res.message || "获取时段数据失败", {icon: 2});
}
});
},
error: function(xhr, status, error) {
layer.closeAll('loading');
$select.html('<option value="">请求失败</option>');
layer.msg("请求时段数据失败: " + error, {icon: 2});
}
});
}
@ -545,13 +552,17 @@
var $select = $('#modifyAppointmentSlot');
$select.empty(); // 清空现有选项
// 添加默认选项
$select.append('<option value="">请选择时段</option>');
if (slots && slots.length > 0) {
// 添加默认选项
$select.append('<option value="">请选择时段</option>');
// 添加动态选项
slots.forEach(function(slot) {
$select.append(`<option value="${slot.id}">${slot.timeName}</option>`);
});
// 添加动态选项
slots.forEach(function(slot) {
$select.append(`<option value="${slot.id}">${slot.timeName}</option>`);
});
} else {
$select.append('<option value="">该日期无可用时段</option>');
}
// 重新渲染Layui表单
layui.form.render('select');

@ -473,39 +473,25 @@
btnAlign: 'c',
success: function(layero, index) {
// 初始化日期选择器
// 确保弹框 DOM 完全加载后,再初始化日期选择器
setTimeout(function() {
layui.laydate.render({
elem: '#modifyAppointmentDate',
type: 'date',
format: 'yyyy-MM-dd',
min: 0,
value: currentDate,
trigger: 'click',
// ✅ 方法 2:如果仍然无效,改用 done 回调手动拦截
done: function(value, date) {
// if (value === currentDate) {
// layer.msg("不能选择原预约日期!");
// $('#modifyAppointmentDate').val(''); // 清空选择
// return false;
// }
layui.laydate.render({
elem: '#modifyAppointmentDate',
type: 'date',
format: 'yyyy-MM-dd',
min: 0,
value: currentDate,
trigger: 'click',
done: function(value, date) {
// 日期选择后加载对应日期的时段
if (value) {
loadTimeSlotsByDate(value);
}
});
}, 100);
}
});
// 加载时段数据
getAppointmentTimeSlots()
.then(function(slots) {
renderTimeSlots(slots);
if(currentSlot) {
$('#modifyAppointmentSlot').val(currentSlot);
layui.form.render('select');
}
})
.catch(function(error) {
layer.msg(error, {icon: 2});
$('#modifyAppointmentSlot').html('<option value="">加载失败</option>');
});
// 初始加载时段数据
if (currentDate) {
loadTimeSlotsByDate(currentDate, currentSlot);
}
},
yes: function(index, layero) {
var form = layui.form;
@ -535,24 +521,37 @@
});
}
// 获取预约时段数据的函数
function getAppointmentTimeSlots() {
return new Promise((resolve, reject) => {
$.ajax({
url: ctx + "/appointmentRecord/getTimeInfo?timeInfoId="+ appointmentTimeInfoId,
type: "GET",
dataType: "json",
success: function(res) {
if(res.success && res.data) {
resolve(res.data);
} else {
reject(res.message || "获取时段数据失败");
// 根据日期加载时段数据
function loadTimeSlotsByDate(date, selectedSlot) {
layer.load(1); // 显示加载中
// 清空现有选项并显示加载中
var $select = $('#modifyAppointmentSlot');
$select.html('<option value="">加载中...</option>');
layui.form.render('select');
$.ajax({
url: ctx + "/appointmentRecord/getTimeInfo?timeInfoId="+ appointmentTimeInfoId+"&unavailableDate="+date,
type: "GET",
dataType: "json",
success: function(res) {
layer.closeAll('loading');
if(res.success && res.data) {
renderTimeSlots(res.data);
if(selectedSlot) {
$select.val(selectedSlot);
layui.form.render('select');
}
},
error: function(xhr, status, error) {
reject("请求失败: " + error);
} else {
$select.html('<option value="">加载失败</option>');
layer.msg(res.message || "获取时段数据失败", {icon: 2});
}
});
},
error: function(xhr, status, error) {
layer.closeAll('loading');
$select.html('<option value="">请求失败</option>');
layer.msg("请求时段数据失败: " + error, {icon: 2});
}
});
}
@ -561,13 +560,17 @@
var $select = $('#modifyAppointmentSlot');
$select.empty(); // 清空现有选项
// 添加默认选项
$select.append('<option value="">请选择时段</option>');
if (slots && slots.length > 0) {
// 添加默认选项
$select.append('<option value="">请选择时段</option>');
// 添加动态选项
slots.forEach(function(slot) {
$select.append(`<option value="${slot.id}">${slot.timeName}</option>`);
});
// 添加动态选项
slots.forEach(function(slot) {
$select.append(`<option value="${slot.id}">${slot.timeName}</option>`);
});
} else {
$select.append('<option value="">该日期无可用时段</option>');
}
// 重新渲染Layui表单
layui.form.render('select');

Loading…
Cancel
Save