fix:修改代金卷时间选择器
This commit is contained in:
@@ -295,9 +295,39 @@ const handleEdit = (row) => {
|
|||||||
dialogType.value = 'edit'
|
dialogType.value = 'edit'
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
|
|
||||||
// 转换日期字符串为日期选择器格式
|
console.log('编辑代金券原始数据:', row)
|
||||||
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, '-') : ''
|
// 转换时间为日期字符串(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, {
|
Object.assign(voucherForm, {
|
||||||
code_id: row.id,
|
code_id: row.id,
|
||||||
@@ -309,12 +339,14 @@ const handleEdit = (row) => {
|
|||||||
max_amount: row.maxAmount ? row.maxAmount / 100 : 0,
|
max_amount: row.maxAmount ? row.maxAmount / 100 : 0,
|
||||||
max_times: row.maxTimes || 0,
|
max_times: row.maxTimes || 0,
|
||||||
user_times: row.userTimes || 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] : [],
|
timeRange: startTime && endTime ? [startTime, endTime] : [],
|
||||||
renew: row.renew || false,
|
renew: row.renew || false,
|
||||||
can_stacking: row.canStacking || false,
|
can_stacking: row.canStacking || false,
|
||||||
can_combine: row.canCombine || false
|
can_combine: row.canCombine || false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log('表单数据:', voucherForm)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 管理代金券
|
// 管理代金券
|
||||||
|
|||||||
@@ -392,7 +392,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, reactive, onMounted } from 'vue'
|
import { ref, reactive, onMounted, nextTick } from 'vue'
|
||||||
import { getFileDetail } from '@/api/admin/file'
|
import { getFileDetail } from '@/api/admin/file'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { Plus, Delete, Search, Refresh } from '@element-plus/icons-vue'
|
import { Plus, Delete, Search, Refresh } from '@element-plus/icons-vue'
|
||||||
@@ -821,7 +821,9 @@ const handleAddParameter = () => {
|
|||||||
arg_min: 0,
|
arg_min: 0,
|
||||||
arg_max: 100
|
arg_max: 100
|
||||||
})
|
})
|
||||||
paramFormRef.value?.resetFields()
|
nextTick(() => {
|
||||||
|
paramFormRef.value?.resetFields()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑参数
|
// 编辑参数
|
||||||
@@ -921,6 +923,7 @@ const fetchParamValuesList = async () => {
|
|||||||
const handleAddParamValue = () => {
|
const handleAddParamValue = () => {
|
||||||
paramValueFormType.value = 'add'
|
paramValueFormType.value = 'add'
|
||||||
paramValueFormDialogVisible.value = true
|
paramValueFormDialogVisible.value = true
|
||||||
|
// 先重置表单数据
|
||||||
Object.assign(paramValueForm, {
|
Object.assign(paramValueForm, {
|
||||||
attr_id: undefined,
|
attr_id: undefined,
|
||||||
attr_name: '',
|
attr_name: '',
|
||||||
@@ -930,7 +933,10 @@ const handleAddParamValue = () => {
|
|||||||
attr_range: 0,
|
attr_range: 0,
|
||||||
range_type: 'equal'
|
range_type: 'equal'
|
||||||
})
|
})
|
||||||
paramValueFormRef.value?.resetFields()
|
// 等待 DOM 更新后再重置表单验证状态
|
||||||
|
nextTick(() => {
|
||||||
|
paramValueFormRef.value?.resetFields()
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑参数值
|
// 编辑参数值
|
||||||
|
|||||||
Reference in New Issue
Block a user