From cae89dd5ad34db61f1e82bfeb607201473cbf270 Mon Sep 17 00:00:00 2001 From: 2256907009 <2256907009@qq.com> Date: Thu, 8 Jan 2026 18:40:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E6=94=B9=E4=BB=A3=E9=87=91?= =?UTF-8?q?=E5=8D=B7=E6=97=B6=E9=97=B4=E9=80=89=E6=8B=A9=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/marketing/Voucher.vue | 40 +++++++++++++++++++++++++++---- src/views/product/ProductList.vue | 12 +++++++--- 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/src/views/marketing/Voucher.vue b/src/views/marketing/Voucher.vue index cd070d3..44c575f 100644 --- a/src/views/marketing/Voucher.vue +++ b/src/views/marketing/Voucher.vue @@ -295,9 +295,39 @@ const handleEdit = (row) => { dialogType.value = 'edit' dialogVisible.value = true - // 转换日期字符串为日期选择器格式 - const startTime = row.startTime ? new Date(row.startTime).toLocaleString('zh-CN', {year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit'}).replace(/\//g, '-') : '' - const endTime = row.endTime ? new Date(row.endTime).toLocaleString('zh-CN', {year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit'}).replace(/\//g, '-') : '' + console.log('编辑代金券原始数据:', row) + + // 转换时间为日期字符串(YYYY-MM-DD HH:mm:ss 格式) + let startTime = '' + let endTime = '' + + if (row.startTime) { + // 处理字符串格式的时间(如 "2026-01-08T00:00:00+08:00") + const start = new Date(row.startTime) + if (!isNaN(start.getTime())) { + startTime = start.getFullYear() + '-' + + String(start.getMonth() + 1).padStart(2, '0') + '-' + + String(start.getDate()).padStart(2, '0') + ' ' + + String(start.getHours()).padStart(2, '0') + ':' + + String(start.getMinutes()).padStart(2, '0') + ':' + + String(start.getSeconds()).padStart(2, '0') + } + } + + if (row.endTime) { + // 处理字符串格式的时间(如 "2026-02-25T00:00:00+08:00") + const end = new Date(row.endTime) + if (!isNaN(end.getTime())) { + endTime = end.getFullYear() + '-' + + String(end.getMonth() + 1).padStart(2, '0') + '-' + + String(end.getDate()).padStart(2, '0') + ' ' + + String(end.getHours()).padStart(2, '0') + ':' + + String(end.getMinutes()).padStart(2, '0') + ':' + + String(end.getSeconds()).padStart(2, '0') + } + } + + console.log('转换后的时间:', { startTime, endTime }) Object.assign(voucherForm, { code_id: row.id, @@ -309,12 +339,14 @@ const handleEdit = (row) => { max_amount: row.maxAmount ? row.maxAmount / 100 : 0, max_times: row.maxTimes || 0, user_times: row.userTimes || 0, - duration_days: row.duration ? row.duration / 86400 : 30, // 秒转天 + duration_days: row.duration ? Math.round(row.duration / 86400) : 30, // 秒转天 timeRange: startTime && endTime ? [startTime, endTime] : [], renew: row.renew || false, can_stacking: row.canStacking || false, can_combine: row.canCombine || false }) + + console.log('表单数据:', voucherForm) } // 管理代金券 diff --git a/src/views/product/ProductList.vue b/src/views/product/ProductList.vue index 332687f..b3c1cb9 100644 --- a/src/views/product/ProductList.vue +++ b/src/views/product/ProductList.vue @@ -392,7 +392,7 @@