Merge pull request 'lyc-dev' (#160) from lyc-dev into main

This commit is contained in:
lyc 2024-08-29 16:50:05 +08:00
commit bb56c3fdab
3 changed files with 85 additions and 0 deletions

View File

@ -76,3 +76,36 @@ export const toTimeText = (timeStamp, simple) => {
}
return timeText
}
/**
*
* @returns 当前年--
*/
export const getCurrentTime = (format)=> {
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');
const hours = now.getHours().toString().padStart(2, '0');
const minutes = now.getMinutes().toString().padStart(2, '0');
if(format == 'YYYY-MM-DD'){
return `${year}-${month}-${day}`;
}
if(format == 'HH:mm'){
return `${hours}:${minutes}`;
}
}
/**
*
* @param {number} m 指定时间
* @returns 指定时间之后的 小时:分钟
*/
export const getAfterMinutes = (m) => {
const now = new Date();
const afterMinutes = new Date(now.getTime() + m * 60 * 1000);
let hours = afterMinutes.getHours();
hours = hours < 10 ? ('0' + hours) : hours
let minutes = afterMinutes.getMinutes();
minutes = minutes < 10 ? ('0' + minutes) : minutes
return `${hours}:${minutes}`;
}

View File

@ -35,6 +35,7 @@
placeholder="请选择日期"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
:disabled-date="disabledDate"
/>
</el-col>
</el-form-item>
@ -53,6 +54,8 @@
range-separator="-"
start-placeholder="开始时间"
end-placeholder="结束时间"
:disabled-hours="disabledHours"
:disabled-minutes="disabledMinute"
/>
</el-col>
</el-form-item>
@ -81,6 +84,8 @@ import { ref, defineExpose, onMounted, reactive, computed, watch } from 'vue'
import { addSmartClassReserv, updateSmartClassReserv, listClassmain } from '@/api/classManage'
import useUserStore from '@/store/modules/user'
import { ElMessage } from 'element-plus'
import { getCurrentTime, getAfterMinutes } from '@/utils/date'
const emit = defineEmits(['addSuccess'])
const props = defineProps({
bookId: {
@ -143,6 +148,47 @@ const locationOptions = [
const locationMessage = computed(() => {
return locationOptions.find((item) => item.value === form.type).message
})
//
const disabledDate = (time)=> {
//
const today = new Date();
if (time.getTime() < today.getTime() - 8.64e7) {
// true
return true;
}
//
const oneMonthLater = new Date(today.getTime() + 30 * 24 * 60 * 60 * 1000);
if (time.getTime() > oneMonthLater.getTime()) {
return true;
}
return false;
}
// -
const disabledHours = ()=>{
if(getCurrentTime('YYYY-MM-DD') == form.day){
const arrs = []
for (let i = 0; i < 24; i++) {
if (new Date().getHours() <= i) continue;
arrs.push(i)
}
return arrs;
}
}
// -
const disabledMinute = () => {
if(getCurrentTime('YYYY-MM-DD') == form.day){
const arrs = []
for (let i = 0; i < 60; i++) {
if (new Date().getMinutes() <= i && form.time[0]) continue;
arrs.push(i)
}
return arrs;
}
}
const openDialog = (data) => {
if (data) {
updateForm.value = data
@ -154,6 +200,11 @@ const openDialog = (data) => {
form.resource = data.classList.split(',').map((item) => parseInt(item))
form.classRoom = data.classRoom
}
else{
//
form.day = getCurrentTime('YYYY-MM-DD')
form.time = [getCurrentTime('HH:mm'), getAfterMinutes(45)]
}
centerDialogVisible.value = true
}
const closeDialog = () => {

View File

@ -19,6 +19,7 @@ const emit = defineEmits(['update:modelValue'])
onMounted(async() => {
if (canvasRef.value) {
FabricVue.drawConfig.drawColors = ['red']
FabricVue.drawConfig.drawWidth = 3
FabricVue.boardConfig.mode = TYPES.ActionMode.OTHER
FabricVue.boardConfig.backgroundColor = 'transparent'
const option = { freeDrawingCursor: 'default' }