diff --git a/ui/src/components/promotions/promotionForm.vue b/ui/src/components/promotions/promotionForm.vue index 786c6b0..dc7b10f 100644 --- a/ui/src/components/promotions/promotionForm.vue +++ b/ui/src/components/promotions/promotionForm.vue @@ -26,7 +26,7 @@ import { error } from 'console'; import Input from '../ui/input/Input.vue'; import Field from '../ui/field/Field.vue'; -const { handleSubmit, errors, values, resetForm } = useForm({ +const { handleSubmit, errors, values, resetForm, setFieldValue } = useForm({ validationSchema: toTypedSchema(batchPromotionSchema), validateOnMount: false, }) @@ -103,8 +103,21 @@ onMounted(async () => { allRanks.value = await getAllRanks(); }) +function setAllToday() { + const today = () => { + const d = new Date() + const year = d.getFullYear() + const month = String(d.getMonth() + 1).padStart(2, '0') + const day = String(d.getDate()).padStart(2, '0') + return `${year}-${month}-${day}` + } + values.promotions?.forEach((_, index) => { + // @ts-ignore + setFieldValue(`promotions[${index}].start_date`, today()) + }) +}