fixed
This commit is contained in:
@@ -186,20 +186,21 @@ export async function getDocuments(searchParams: DocumentSearchParams = {}): Pro
|
|||||||
// 处理日期范围
|
// 处理日期范围
|
||||||
if (searchParams.dateFrom) {
|
if (searchParams.dateFrom) {
|
||||||
// 添加当天开始时间 00:00:00
|
// 添加当天开始时间 00:00:00
|
||||||
filter['created_at'] = `gte.'${searchParams.dateFrom} 00:00:00'`;
|
filter['created_at'] = `gte.'${dayjs(`${searchParams.dateFrom} 00:00:00`).format()}'`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (searchParams.dateTo) {
|
if (searchParams.dateTo) {
|
||||||
// 如果有开始日期,使用and条件;否则直接设置结束日期
|
// 如果有开始日期,使用and条件;否则直接设置结束日期
|
||||||
const dateToKey = searchParams.dateFrom ? 'and' : 'created_at';
|
const dateToKey = searchParams.dateFrom ? 'and' : 'created_at';
|
||||||
|
const newDateFrom = dayjs(`${searchParams.dateFrom} 00:00:00`).format();
|
||||||
|
const newDateTo = dayjs(`${searchParams.dateTo} 23:59:59`).format();
|
||||||
// 添加当天结束时间 23:59:59
|
// 添加当天结束时间 23:59:59
|
||||||
if (dateToKey === 'and') {
|
if (dateToKey === 'and') {
|
||||||
delete filter['created_at'];
|
delete filter['created_at'];
|
||||||
// 使用OR操作符连接两个条件
|
// 使用OR操作符连接两个条件
|
||||||
filter[dateToKey] = `(created_at.gte.'${dayjs(searchParams.dateFrom).format()}',created_at.lte.'${dayjs(searchParams.dateTo).format()}')`;
|
filter[dateToKey] = `(created_at.gte.'${newDateFrom}',created_at.lte.'${newDateTo}')`;
|
||||||
} else {
|
} else {
|
||||||
filter['created_at'] = `lte.'${dayjs(searchParams.dateTo).format()}'`;
|
filter['created_at'] = `lte.'${newDateTo}'`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user