diff --git a/src/components/GenericMonitorList.vue b/src/components/GenericMonitorList.vue index 8f3658e2..6ea9e7f4 100644 --- a/src/components/GenericMonitorList.vue +++ b/src/components/GenericMonitorList.vue @@ -27,7 +27,6 @@ range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" - value-format="YYYY-MM-DD HH:mm:ss" @change="handleFilterChange(col.dataIndex, filters[col.dataIndex])" > @@ -174,15 +173,33 @@ const loadData = async () => { order: sortOrder.order === 'ascending' ? 'asc' : (sortOrder.order === 'descending' ? 'desc' : undefined), }; - // 将日期范围筛选转换为 start_time 和 end_time + // Custom function to format Date objects to YYYY-MM-DDTHH:mm:ssZ00:00 + const formatToRFC3339WithOffset = (date) => { + if (!date) return ''; // Handle null or undefined dates + const year = date.getUTCFullYear(); + const month = (date.getUTCMonth() + 1).toString().padStart(2, '0'); + const day = date.getUTCDate().toString().padStart(2, '0'); + const hours = date.getUTCHours().toString().padStart(2, '0'); + const minutes = date.getUTCMinutes().toString().padStart(2, '0'); + const seconds = date.getUTCSeconds().toString().padStart(2, '0'); + return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}Z`; + }; + + // 将日期范围筛选转换为 start_time 和 end_time,并确保是 RFC3339 UTC 格式 (不带毫秒) filterableColumns.value.forEach(col => { if (col.filterType === 'dateRange' && filters[col.dataIndex] && filters[col.dataIndex].length === 2) { - params[`start_time`] = filters[col.dataIndex][0]; - params[`end_time`] = filters[col.dataIndex][1]; + // filters[col.dataIndex] will now contain Date objects directly from el-date-picker + const startDateObj = filters[col.dataIndex][0]; + const endDateObj = filters[col.dataIndex][1]; + + params[`start_time`] = formatToRFC3339WithOffset(startDateObj); + params[`end_time`] = formatToRFC3339WithOffset(endDateObj); delete params[col.dataIndex]; } }); + console.log('Sending parameters to fetchData:', params); + const result = await props.fetchData(params); data.value = result.list; pagination.total = result.total;