bugfix: 修复H5日期组件返回的值缺少秒的问题

This commit is contained in:
niedongsheng 2026-04-10 13:56:27 +08:00
parent 80909dfd4d
commit 2d3253ba0e

View File

@ -55,6 +55,7 @@
<script setup> <script setup>
import { ref, computed, watch } from 'vue' import { ref, computed, watch } from 'vue'
import { Field, Popup, DatePicker, TimePicker } from 'vant' import { Field, Popup, DatePicker, TimePicker } from 'vant'
import { formatDate } from '@shared/utils'
// Props // Props
const props = defineProps({ const props = defineProps({
@ -141,6 +142,11 @@ const props = defineProps({
return option return option
} }
}, },
//
resultFormat: {
type: String,
default: 'YYYY-MM-DD HH:mm:ss'
},
// //
filter: { filter: {
type: Function, type: Function,
@ -350,13 +356,14 @@ const formatTimePart = () => {
// //
const onConfirm = () => { const onConfirm = () => {
let finalValue = formatDatePart() let finalValue = formatDatePart()
if (hasTime.value) { if (hasTime.value) {
const timePart = formatTimePart() const timePart = formatTimePart()
if (timePart) { if (timePart) {
finalValue += ' ' + timePart finalValue += ' ' + timePart
} }
} }
finalValue = formatDate(finalValue)
emit('update:modelValue', finalValue) emit('update:modelValue', finalValue)
emit('change', finalValue) emit('change', finalValue)