mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 19:09:19 +08:00
fix: 推广费表单 feeDate 格式化为 YYYY-MM-DD 字符串,避免 JSON 序列化时区偏移
This commit is contained in:
+17
-2
@@ -9,6 +9,7 @@ import type { ShopVO } from '#/api/ecommerce/shop/types';
|
|||||||
|
|
||||||
import { nextTick, onMounted, ref, watch } from 'vue';
|
import { nextTick, onMounted, ref, watch } from 'vue';
|
||||||
|
|
||||||
|
import type { Dayjs } from 'dayjs';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
|
|
||||||
import { useVbenModal } from '@vben/common-ui';
|
import { useVbenModal } from '@vben/common-ui';
|
||||||
@@ -70,7 +71,12 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
const formRef = ref();
|
const formRef = ref();
|
||||||
const isEdit = ref(false);
|
const isEdit = ref(false);
|
||||||
|
|
||||||
const formData = ref<PromotionFeeDTO.Create>({
|
/** 表单内用 Dayjs,提交时再格式化为 YYYY-MM-DD */
|
||||||
|
type PromotionFeeFormState = Omit<PromotionFeeDTO.Create, 'feeDate'> & {
|
||||||
|
feeDate?: Dayjs;
|
||||||
|
};
|
||||||
|
|
||||||
|
const formData = ref<PromotionFeeFormState>({
|
||||||
shopId: undefined as any,
|
shopId: undefined as any,
|
||||||
feeTypeId: undefined as any,
|
feeTypeId: undefined as any,
|
||||||
productId: undefined,
|
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 () => {
|
const handleOk = async () => {
|
||||||
try {
|
try {
|
||||||
await formRef.value?.validate();
|
await formRef.value?.validate();
|
||||||
|
|
||||||
|
const feeDate = feeDateToApiString(formData.value.feeDate!);
|
||||||
|
|
||||||
if (isEdit.value && props.promotionFeeData) {
|
if (isEdit.value && props.promotionFeeData) {
|
||||||
const updateData: PromotionFeeDTO.Update = {
|
const updateData: PromotionFeeDTO.Update = {
|
||||||
id: props.promotionFeeData.id,
|
id: props.promotionFeeData.id,
|
||||||
...formData.value,
|
...formData.value,
|
||||||
|
feeDate,
|
||||||
};
|
};
|
||||||
await updatePromotionFeeApi(updateData);
|
await updatePromotionFeeApi(updateData);
|
||||||
message.success('更新成功');
|
message.success('更新成功');
|
||||||
} else {
|
} else {
|
||||||
await createPromotionFeeApi(formData.value);
|
await createPromotionFeeApi({
|
||||||
|
...formData.value,
|
||||||
|
feeDate,
|
||||||
|
});
|
||||||
message.success('创建成功');
|
message.success('创建成功');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user