|
|
@ -22,7 +22,9 @@ const props = defineProps({ |
|
|
|
|
|
|
|
const emits = defineEmits(['update:modelValue', 'change']) |
|
|
|
const dateText = ref() |
|
|
|
const hoursOptions = ref([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]) |
|
|
|
const hoursOptions = ref(Array.from({ length: 24 }, (_, i) => i)) |
|
|
|
const minuteOptions = ref(Array.from({ length: 60 }, (_, i) => i)) |
|
|
|
const secondOptions = ref(Array.from({ length: 60 }, (_, i) => i)) |
|
|
|
// 初始化日期时间 |
|
|
|
const selectedDate = ref<Date | null>(null) |
|
|
|
const currentYear = ref(0) |
|
|
@ -36,7 +38,6 @@ const selectedSecond = ref('00') |
|
|
|
|
|
|
|
// 格式化显示值 |
|
|
|
const displayValue = () => { |
|
|
|
console.log('-----------------') |
|
|
|
if (!selectedDate.value) { |
|
|
|
return '' |
|
|
|
} |
|
|
@ -183,7 +184,6 @@ const updateTime = () => { |
|
|
|
|
|
|
|
// 确认选择 |
|
|
|
const confirmSelection = () => { |
|
|
|
console.log('selectedDate.value---', selectedDate.value) |
|
|
|
if (selectedDate.value) { |
|
|
|
const dateValue = formatDate(selectedDate.value, props.format) |
|
|
|
emits('update:modelValue', dateValue) |
|
|
@ -351,13 +351,13 @@ onUnmounted(() => { |
|
|
|
</el-select> |
|
|
|
<span class="time-separator">:</span> |
|
|
|
<el-select v-model="selectedMinute" @change="updateTime" class="time-select"> |
|
|
|
<el-option v-for="i in 60" :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') }} |
|
|
|
</el-option> |
|
|
|
</el-select> |
|
|
|
<span class="time-separator">:</span> |
|
|
|
<el-select v-model="selectedSecond" @change="updateTime" class="time-select"> |
|
|
|
<el-option v-for="i in 60" :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') }} |
|
|
|
</el-option> |
|
|
|
</el-select> |
|
|
@ -516,7 +516,7 @@ $fontSize: 1.5rem; |
|
|
|
margin-right: 4px; |
|
|
|
/* 最大高度限制,溢出滚动 */ |
|
|
|
max-height: 3rem; |
|
|
|
width: 6rem; |
|
|
|
width: 8rem; |
|
|
|
border: none; |
|
|
|
} |
|
|
|
} |
|
|
@ -530,6 +530,7 @@ select option { |
|
|
|
margin-right: 12px; |
|
|
|
font-size: $fontSize; |
|
|
|
color: #334155; |
|
|
|
width: 5rem; |
|
|
|
} |
|
|
|
|
|
|
|
.select-option{ |
|
|
|