Files
axp-ui/src/components/FieldDate.vue
T
2023-07-11 10:38:21 +03:00

33 lines
716 B
Vue

<script setup lang="ts">
import { computed } from 'vue'
import { cFieldsSchema, getDateCommonFormat } from 'axp-ts'
import UiField from './Field.vue'
const props = defineProps<{
modelValue?: Date
}>()
const emit = defineEmits<{ (e: 'update:modelValue', v?: Date): void }>()
const valueStr = computed({
get: () => {
try {
const value = cFieldsSchema.shape.date.parse(props.modelValue)
const format = getDateCommonFormat(value)
return format
} catch (e) {}
},
set: (val) => {
try {
const value = cFieldsSchema.shape.date.parse(val)
emit('update:modelValue', value)
} catch (e) {}
}
})
</script>
<template>
<ui-field type="date" class="ui-field-date" v-model="valueStr" />
</template>