Merge branch 'main' of https://gitlab.guxuan.icu/Leo_Ding/JinShan_uniapp
This commit is contained in:
commit
f48f805d61
@ -180,12 +180,23 @@
|
||||
@confirm="handleDateConfirm" @close="showCalendar = false" :mask-close-able="true"></u-calendar>
|
||||
|
||||
<!-- 时间选择器 -->
|
||||
<u-datetime-picker :show="showStartTimePicker" v-model="startTimePickerValue" :min-date="Date.now()"
|
||||
:mode="mode" @confirm="handleStartTimeConfirm" @cancel="showStartTimePicker = false"
|
||||
ref="startTimePicker"></u-datetime-picker>
|
||||
<u-datetime-picker :show="showStartTimePicker"
|
||||
v-model="startTimePickerValue"
|
||||
:min-date="Date.now()"
|
||||
:mode="mode"
|
||||
@confirm="handleStartTimeConfirm"
|
||||
@cancel="showStartTimePicker = false"
|
||||
ref="startTimePicker"></u-datetime-picker>
|
||||
|
||||
<u-datetime-picker :show="showEndTimePicker" v-model="endTimePickerValue" :min-date="Date.now()" :mode="mode"
|
||||
@confirm="handleEndTimeConfirm" @cancel="showEndTimePicker = false" ref="endTimePicker"></u-datetime-picker>
|
||||
<u-datetime-picker
|
||||
:show="showEndTimePicker"
|
||||
v-model="endTimePickerValue"
|
||||
:min-date="Date.now()"
|
||||
:mode="mode"
|
||||
@confirm="handleEndTimeConfirm"
|
||||
@cancel="showEndTimePicker = false"
|
||||
ref="endTimePicker">
|
||||
</u-datetime-picker>
|
||||
<u-picker :show="showApplyType" :columns="applyTypeColumns" @confirm="applyConfirm"
|
||||
@cancel="showApplyType=false"></u-picker>
|
||||
<u-popup :show="readShow" mode="center" :round="10">
|
||||
@ -342,20 +353,51 @@
|
||||
this.Id = options.Id;
|
||||
this.isSelfStudy = JSON.parse(options.isSelfStudy)
|
||||
this.mode = options.isSelfStudy === 'true' ? 'year-month' : 'datetime'
|
||||
|
||||
// 设置默认时间值
|
||||
if (this.isSelfStudy) {
|
||||
// 自习室模式,只显示年月
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
||||
|
||||
this.startTime = `${year}-${month}`;
|
||||
this.endTime = `${year}-${month}`;
|
||||
this.startTimePickerValue = this.startTime;
|
||||
this.endTimePickerValue = this.endTime;
|
||||
} else {
|
||||
// 普通会议室模式,显示完整日期时间
|
||||
const now = new Date();
|
||||
const year = now.getFullYear();
|
||||
const month = (now.getMonth() + 1).toString().padStart(2, '0');
|
||||
const day = now.getDate().toString().padStart(2, '0');
|
||||
|
||||
this.startTime = `${year}-${month}-${day} 09:00`;
|
||||
this.endTime = `${year}-${month}-${day} 10:00`;
|
||||
this.startTimePickerValue = this.startTime;
|
||||
this.endTimePickerValue = this.endTime;
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
formattedSelectedDate() {
|
||||
if (!this.selectedDate) return '请选择日期';
|
||||
console.log(this.selectedDate)
|
||||
// const date = new Date(this.selectedDate);
|
||||
// const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
|
||||
// const month = date.getMonth() + 1;
|
||||
// const day = date.getDate();
|
||||
// const weekday = weekdays[date.getDay()];
|
||||
if (!this.selectedDate) return '请选择日期';
|
||||
|
||||
// return `${month}月${day}日 ${weekday}`;
|
||||
return this.selectedDate
|
||||
if (this.isSelfStudy) {
|
||||
// 自习室模式,显示年月格式
|
||||
const [year, month] = this.selectedDate.split('-');
|
||||
return `${year}年${month}月`;
|
||||
} else {
|
||||
// 普通会议室模式,显示完整日期
|
||||
const date = new Date(this.selectedDate);
|
||||
const weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
|
||||
const month = date.getMonth() + 1;
|
||||
const day = date.getDate();
|
||||
const weekday = weekdays[date.getDay()];
|
||||
|
||||
return `${month}月${day}日 ${weekday}`;
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
@ -441,42 +483,53 @@
|
||||
},
|
||||
|
||||
handleStartTimeConfirm(e) {
|
||||
// 对于uView的datetime-picker,e.value是时间戳
|
||||
const date = new Date(e.value);
|
||||
if (this.isSelfStudy) {
|
||||
// 自习室模式处理年月
|
||||
const date = new Date(e.value);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const hours = String(date.getHours()).padStart(2, '0');
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||||
this.startTime = `${year}-${month}`;
|
||||
this.startTimePickerValue = this.startTime;
|
||||
} else {
|
||||
// 普通会议室模式处理完整日期时间
|
||||
const date = new Date(e.value);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const hours = String(date.getHours()).padStart(2, '0');
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||||
|
||||
this.startTime = `${year}-${month}-${day} ${hours}:${minutes}`;
|
||||
this.startTimePickerValue = this.startTime;
|
||||
this.showStartTimePicker = false;
|
||||
this.startTime = `${year}-${month}-${day} ${hours}:${minutes}`;
|
||||
this.startTimePickerValue = this.startTime;
|
||||
}
|
||||
|
||||
// 如果结束时间早于开始时间,自动调整结束时间
|
||||
if (new Date(this.endTime) < new Date(this.startTime)) {
|
||||
const endDate = new Date(date.getTime() + 60 * 60 * 1000); // 加1小时
|
||||
this.endTime = `${endDate.getFullYear()}-${String(endDate.getMonth() + 1).padStart(2, '0')}-${String(endDate.getDate()).padStart(2, '0')} ${String(endDate.getHours()).padStart(2, '0')}:${String(endDate.getMinutes()).padStart(2, '0')}`;
|
||||
this.endTimePickerValue = this.endTime;
|
||||
}
|
||||
this.showStartTimePicker = false;
|
||||
},
|
||||
|
||||
handleEndTimeConfirm(e) {
|
||||
const date = new Date(e.value);
|
||||
if (this.isSelfStudy) {
|
||||
// 自习室模式处理年月
|
||||
const date = new Date(e.value);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const hours = String(date.getHours()).padStart(2, '0');
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||||
this.endTime = `${year}-${month}`;
|
||||
this.endTimePickerValue = this.endTime;
|
||||
} else {
|
||||
// 普通会议室模式处理完整日期时间
|
||||
const date = new Date(e.value);
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
const hours = String(date.getHours()).padStart(2, '0');
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||||
|
||||
this.endTime = `${year}-${month}-${day} ${hours}:${minutes}`;
|
||||
this.endTimePickerValue = this.endTime;
|
||||
this.showEndTimePicker = false;
|
||||
this.endTime = `${year}-${month}-${day} ${hours}:${minutes}`;
|
||||
this.endTimePickerValue = this.endTime;
|
||||
}
|
||||
|
||||
// 验证时间是否合理
|
||||
this.validateTime();
|
||||
this.showEndTimePicker = false;
|
||||
},
|
||||
|
||||
adjustEndTime() {
|
||||
|
||||
@ -285,10 +285,11 @@
|
||||
},
|
||||
|
||||
goDetail(item) {
|
||||
|
||||
console.log("====item",item)
|
||||
// 安全获取ID(兼容各种可能的字段名)
|
||||
const id = item.id;
|
||||
const isSelfStudy = item.title === '自习室' ? true : false
|
||||
const isSelfStudy = item.title === '自习室';
|
||||
|
||||
if (!id) {
|
||||
uni.showToast({
|
||||
title: '会议室信息异常',
|
||||
@ -297,8 +298,42 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果是自习室,先弹出提示确认框
|
||||
if (item.roomType == 2 ) {
|
||||
uni.showModal({
|
||||
title: '温馨提示',
|
||||
content: '自习室预约时间按月为单位,单次预约最长两个月,请确认是否继续?',
|
||||
confirmColor: '#007AFF', // 可根据uView主题色调整
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
// 用户点击确定,执行跳转
|
||||
this.navigateToDetail(id, true);
|
||||
} else if (res.cancel) {
|
||||
// 用户点击取消,可选操作(如提示取消)
|
||||
uni.showToast({
|
||||
title: '已取消',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('弹窗失败:', err);
|
||||
uni.showToast({
|
||||
title: '操作失败',
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 非自习室,直接跳转
|
||||
this.navigateToDetail(id, false);
|
||||
}
|
||||
},
|
||||
|
||||
// 封装跳转逻辑,避免重复代码
|
||||
navigateToDetail(id, isSelfStudy) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/meetingDetail/index?Id=${encodeURIComponent(id)}&isSelfStudy=${isSelfStudy}`, // 使用encodeURIComponent防止特殊字符问题
|
||||
url: `/pages/meetingDetail/index?Id=${encodeURIComponent(id)}&isSelfStudy=${isSelfStudy}`,
|
||||
success: () => {
|
||||
console.log('导航成功,ID:', id);
|
||||
},
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user