diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/promotion-fee/components/PromotionFeeFormModal.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/promotion-fee/components/PromotionFeeFormModal.vue index c7b14857..607df0ce 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/promotion-fee/components/PromotionFeeFormModal.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/promotion-fee/components/PromotionFeeFormModal.vue @@ -9,6 +9,7 @@ import type { ShopVO } from '#/api/ecommerce/shop/types'; import { nextTick, onMounted, ref, watch } from 'vue'; +import type { Dayjs } from 'dayjs'; import dayjs from 'dayjs'; import { useVbenModal } from '@vben/common-ui'; @@ -70,7 +71,12 @@ const [Modal, modalApi] = useVbenModal({ const formRef = ref(); const isEdit = ref(false); -const formData = ref({ +/** 表单内用 Dayjs,提交时再格式化为 YYYY-MM-DD */ +type PromotionFeeFormState = Omit & { + feeDate?: Dayjs; +}; + +const formData = ref({ shopId: undefined as any, feeTypeId: undefined as any, productId: undefined, @@ -187,19 +193,28 @@ const resetFormData = () => { }; }; +/** 发生日期仅表示日历日,格式化为本地 YYYY-MM-DD,避免 JSON 序列化为 UTC ISO 后日期错位 */ +const feeDateToApiString = (v: Dayjs) => dayjs(v).format('YYYY-MM-DD'); + const handleOk = async () => { try { await formRef.value?.validate(); + const feeDate = feeDateToApiString(formData.value.feeDate!); + if (isEdit.value && props.promotionFeeData) { const updateData: PromotionFeeDTO.Update = { id: props.promotionFeeData.id, ...formData.value, + feeDate, }; await updatePromotionFeeApi(updateData); message.success('更新成功'); } else { - await createPromotionFeeApi(formData.value); + await createPromotionFeeApi({ + ...formData.value, + feeDate, + }); message.success('创建成功'); }