feat(web): update useRequests composable

- useRequests.js: update requests composable
This commit is contained in:
caoxiaozhu
2026-05-13 15:38:59 +00:00
parent ada0eb40ca
commit f804a23239

View File

@@ -400,6 +400,13 @@ function getWeekStart(date) {
return nextDate
}
function getRecentDaysStart(date, days) {
const nextDate = new Date(date)
nextDate.setHours(0, 0, 0, 0)
nextDate.setDate(nextDate.getDate() - Math.max(0, Number(days || 1) - 1))
return nextDate
}
function resolveRangeMatch(activeRange, item) {
if (activeRange === 'custom' || activeRange === '本月') {
if (activeRange !== '本月') {
@@ -419,6 +426,11 @@ function resolveRangeMatch(activeRange, item) {
return targetDay === formatDate(now)
}
if (activeRange === '近10日') {
const recentStart = getRecentDaysStart(now, 10)
return targetDate >= recentStart && targetDate <= now
}
if (activeRange === '本周') {
const weekStart = getWeekStart(now)
const nextWeekStart = new Date(weekStart)
@@ -442,8 +454,8 @@ export function useRequests() {
const error = ref('')
const search = ref('')
const filters = reactive({ entity: '全部主体', category: '全部类型', risk: '全部状态' })
const ranges = ['今日', '本周', '本月']
const activeRange = ref('本周')
const ranges = ['今日', '近10日', '本周', '本月']
const activeRange = ref('近10日')
const filteredRequests = computed(() => {
const key = search.value.trim().toLowerCase()