feat(web): update useRequests composable
- useRequests.js: update requests composable
This commit is contained in:
@@ -400,6 +400,13 @@ function getWeekStart(date) {
|
|||||||
return nextDate
|
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) {
|
function resolveRangeMatch(activeRange, item) {
|
||||||
if (activeRange === 'custom' || activeRange === '本月') {
|
if (activeRange === 'custom' || activeRange === '本月') {
|
||||||
if (activeRange !== '本月') {
|
if (activeRange !== '本月') {
|
||||||
@@ -419,6 +426,11 @@ function resolveRangeMatch(activeRange, item) {
|
|||||||
return targetDay === formatDate(now)
|
return targetDay === formatDate(now)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (activeRange === '近10日') {
|
||||||
|
const recentStart = getRecentDaysStart(now, 10)
|
||||||
|
return targetDate >= recentStart && targetDate <= now
|
||||||
|
}
|
||||||
|
|
||||||
if (activeRange === '本周') {
|
if (activeRange === '本周') {
|
||||||
const weekStart = getWeekStart(now)
|
const weekStart = getWeekStart(now)
|
||||||
const nextWeekStart = new Date(weekStart)
|
const nextWeekStart = new Date(weekStart)
|
||||||
@@ -442,8 +454,8 @@ export function useRequests() {
|
|||||||
const error = ref('')
|
const error = ref('')
|
||||||
const search = ref('')
|
const search = ref('')
|
||||||
const filters = reactive({ entity: '全部主体', category: '全部类型', risk: '全部状态' })
|
const filters = reactive({ entity: '全部主体', category: '全部类型', risk: '全部状态' })
|
||||||
const ranges = ['今日', '本周', '本月']
|
const ranges = ['今日', '近10日', '本周', '本月']
|
||||||
const activeRange = ref('本周')
|
const activeRange = ref('近10日')
|
||||||
|
|
||||||
const filteredRequests = computed(() => {
|
const filteredRequests = computed(() => {
|
||||||
const key = search.value.trim().toLowerCase()
|
const key = search.value.trim().toLowerCase()
|
||||||
|
|||||||
Reference in New Issue
Block a user