|
@ -1,4 +1,5 @@ |
|
|
<script lang="ts" setup> |
|
|
<script lang="ts" setup> |
|
|
|
|
|
import { ElMessage } from 'element-plus' |
|
|
import { computed, defineEmits, defineProps, onMounted, onUnmounted, ref, watch } from 'vue' |
|
|
import { computed, defineEmits, defineProps, onMounted, onUnmounted, ref, watch } from 'vue' |
|
|
|
|
|
|
|
|
const props = defineProps({ |
|
|
const props = defineProps({ |
|
@ -14,6 +15,10 @@ const props = defineProps({ |
|
|
type: [String, Date], |
|
|
type: [String, Date], |
|
|
default: null, |
|
|
default: null, |
|
|
}, |
|
|
}, |
|
|
|
|
|
disabled: { |
|
|
|
|
|
type: Boolean, |
|
|
|
|
|
default: false, |
|
|
|
|
|
}, |
|
|
format: { |
|
|
format: { |
|
|
type: String, |
|
|
type: String, |
|
|
default: 'YYYY-MM-DD HH:mm:ss', |
|
|
default: 'YYYY-MM-DD HH:mm:ss', |
|
@ -105,7 +110,9 @@ onMounted(() => { |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
// 监听props变化 |
|
|
// 监听props变化 |
|
|
watch(() => props.modelValue, (newVal) => { |
|
|
|
|
|
|
|
|
watch( |
|
|
|
|
|
() => props.modelValue, |
|
|
|
|
|
(newVal) => { |
|
|
if (newVal) { |
|
|
if (newVal) { |
|
|
const date = new Date(Number(newVal)) |
|
|
const date = new Date(Number(newVal)) |
|
|
if (!Number.isNaN(date.getTime())) { |
|
|
if (!Number.isNaN(date.getTime())) { |
|
@ -120,7 +127,9 @@ watch(() => props.modelValue, (newVal) => { |
|
|
else { |
|
|
else { |
|
|
selectedDate.value = null |
|
|
selectedDate.value = null |
|
|
} |
|
|
} |
|
|
}, { deep: true }) |
|
|
|
|
|
|
|
|
}, |
|
|
|
|
|
{ deep: true }, |
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
// 日期操作 |
|
|
// 日期操作 |
|
|
const prevMonth = () => { |
|
|
const prevMonth = () => { |
|
@ -233,6 +242,10 @@ const toggleDropdown = (event?: MouseEvent) => { |
|
|
if (event) { |
|
|
if (event) { |
|
|
event.stopPropagation() |
|
|
event.stopPropagation() |
|
|
} |
|
|
} |
|
|
|
|
|
if (props.disabled) { |
|
|
|
|
|
ElMessage.error('请在消毒结束后再试') |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
isDropdownVisible.value = !isDropdownVisible.value |
|
|
isDropdownVisible.value = !isDropdownVisible.value |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -242,7 +255,9 @@ const isSameDay = (date1: Date, date2: Date | null) => { |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
return ( |
|
|
return ( |
|
|
date1.getFullYear() === date2.getFullYear() && date1.getMonth() === date2.getMonth() && date1.getDate() === date2.getDate() |
|
|
|
|
|
|
|
|
date1.getFullYear() === date2.getFullYear() |
|
|
|
|
|
&& date1.getMonth() === date2.getMonth() |
|
|
|
|
|
&& date1.getDate() === date2.getDate() |
|
|
) |
|
|
) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -253,10 +268,7 @@ const isDateInRange = (date: Date) => { |
|
|
if (min && date < min) { |
|
|
if (min && date < min) { |
|
|
return false |
|
|
return false |
|
|
} |
|
|
} |
|
|
if (max && date > max) { |
|
|
|
|
|
return false |
|
|
|
|
|
} |
|
|
|
|
|
return true |
|
|
|
|
|
|
|
|
return !(max && date > max) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 点击外部关闭下拉框 |
|
|
// 点击外部关闭下拉框 |
|
@ -307,9 +319,7 @@ onUnmounted(() => { |
|
|
<button class="nav-btn" @click="prevMonth"> |
|
|
<button class="nav-btn" @click="prevMonth"> |
|
|
<el-icon><ArrowLeft /></el-icon> |
|
|
<el-icon><ArrowLeft /></el-icon> |
|
|
</button> |
|
|
</button> |
|
|
<span class="current-date"> |
|
|
|
|
|
{{ currentYear }}年 {{ currentMonth + 1 }}月 |
|
|
|
|
|
</span> |
|
|
|
|
|
|
|
|
<span class="current-date"> {{ currentYear }}年 {{ currentMonth + 1 }}月 </span> |
|
|
<button class="nav-btn" @click="nextMonth"> |
|
|
<button class="nav-btn" @click="nextMonth"> |
|
|
<el-icon><ArrowRight /></el-icon> |
|
|
<el-icon><ArrowRight /></el-icon> |
|
|
</button> |
|
|
</button> |
|
@ -343,19 +353,34 @@ onUnmounted(() => { |
|
|
时间: |
|
|
时间: |
|
|
</div> |
|
|
</div> |
|
|
<el-select v-model="selectedHour" class="time-select" @change="updateTime"> |
|
|
<el-select v-model="selectedHour" class="time-select" @change="updateTime"> |
|
|
<el-option v-for="i in hoursOptions" :key="i" :value="i.toString().padStart(2, '0')" style="font-size: 20px;line-height: 2px;height: 5rem;display: flex; align-items: center;"> |
|
|
|
|
|
|
|
|
<el-option |
|
|
|
|
|
v-for="i in hoursOptions" |
|
|
|
|
|
:key="i" |
|
|
|
|
|
:value="i.toString().padStart(2, '0')" |
|
|
|
|
|
style="font-size: 20px; line-height: 2px; height: 5rem; display: flex; align-items: center" |
|
|
|
|
|
> |
|
|
{{ i.toString().padStart(2, '0') }} |
|
|
{{ i.toString().padStart(2, '0') }} |
|
|
</el-option> |
|
|
</el-option> |
|
|
</el-select> |
|
|
</el-select> |
|
|
<span class="time-separator">:</span> |
|
|
<span class="time-separator">:</span> |
|
|
<el-select v-model="selectedMinute" class="time-select" @change="updateTime"> |
|
|
<el-select v-model="selectedMinute" class="time-select" @change="updateTime"> |
|
|
<el-option v-for="i in minuteOptions" :key="i" :value="i.toString().padStart(2, '0')" style="font-size: 20px;line-height: 2px;height: 5rem;display: flex; align-items: center;"> |
|
|
|
|
|
|
|
|
<el-option |
|
|
|
|
|
v-for="i in minuteOptions" |
|
|
|
|
|
:key="i" |
|
|
|
|
|
:value="i.toString().padStart(2, '0')" |
|
|
|
|
|
style="font-size: 20px; line-height: 2px; height: 5rem; display: flex; align-items: center" |
|
|
|
|
|
> |
|
|
{{ i.toString().padStart(2, '0') }} |
|
|
{{ i.toString().padStart(2, '0') }} |
|
|
</el-option> |
|
|
</el-option> |
|
|
</el-select> |
|
|
</el-select> |
|
|
<span class="time-separator">:</span> |
|
|
<span class="time-separator">:</span> |
|
|
<el-select v-model="selectedSecond" class="time-select" @change="updateTime"> |
|
|
<el-select v-model="selectedSecond" class="time-select" @change="updateTime"> |
|
|
<el-option v-for="i in secondOptions" :key="i" :value="i.toString().padStart(2, '0')" style="font-size: 20px;line-height: 2px;height: 5rem;display: flex; align-items: center;"> |
|
|
|
|
|
|
|
|
<el-option |
|
|
|
|
|
v-for="i in secondOptions" |
|
|
|
|
|
:key="i" |
|
|
|
|
|
:value="i.toString().padStart(2, '0')" |
|
|
|
|
|
style="font-size: 20px; line-height: 2px; height: 5rem; display: flex; align-items: center" |
|
|
|
|
|
> |
|
|
{{ i.toString().padStart(2, '0') }} |
|
|
{{ i.toString().padStart(2, '0') }} |
|
|
</el-option> |
|
|
</el-option> |
|
|
</el-select> |
|
|
</el-select> |
|
@ -420,7 +445,9 @@ $fontSize: 1.5rem; |
|
|
background-color: white; |
|
|
background-color: white; |
|
|
border: 1px solid #e2e8f0; |
|
|
border: 1px solid #e2e8f0; |
|
|
border-radius: 4px; |
|
|
border-radius: 4px; |
|
|
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); |
|
|
|
|
|
|
|
|
box-shadow: |
|
|
|
|
|
0 4px 6px -1px rgba(0, 0, 0, 0.1), |
|
|
|
|
|
0 2px 4px -1px rgba(0, 0, 0, 0.06); |
|
|
z-index: 100; |
|
|
z-index: 100; |
|
|
padding: 12px; |
|
|
padding: 12px; |
|
|
} |
|
|
} |
|
@ -562,7 +589,8 @@ select { |
|
|
gap: 10px; |
|
|
gap: 10px; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.confirm-btn, .cancel-btn { |
|
|
|
|
|
|
|
|
.confirm-btn, |
|
|
|
|
|
.cancel-btn { |
|
|
padding: 8px 16px; |
|
|
padding: 8px 16px; |
|
|
border: none; |
|
|
border: none; |
|
|
border-radius: 4px; |
|
|
border-radius: 4px; |
|
@ -589,11 +617,13 @@ select { |
|
|
background-color: #e2e8f0; |
|
|
background-color: #e2e8f0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.fade-enter-active, .fade-leave-active { |
|
|
|
|
|
|
|
|
.fade-enter-active, |
|
|
|
|
|
.fade-leave-active { |
|
|
transition: opacity 0.2s; |
|
|
transition: opacity 0.2s; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.fade-enter-from, .fade-leave-to { |
|
|
|
|
|
|
|
|
.fade-enter-from, |
|
|
|
|
|
.fade-leave-to { |
|
|
opacity: 0; |
|
|
opacity: 0; |
|
|
} |
|
|
} |
|
|
// 修改选择框本身的宽高 |
|
|
// 修改选择框本身的宽高 |
|
|