代码修改

This commit is contained in:
qiuyuan 2025-08-27 09:33:02 +08:00
parent 2376a9eaf2
commit 5db1ee877f
2 changed files with 162 additions and 74 deletions

View File

@ -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) {
// uViewdatetime-pickere.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() {

View File

@ -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);
},