fix:修改代金卷时间选择器
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
// 管理代金券
|
||||
|
||||
Reference in New Issue
Block a user