chore: /admin/usage页面增加一个刷新按钮
This commit is contained in:
@@ -154,6 +154,9 @@
|
|||||||
|
|
||||||
<!-- Right: actions -->
|
<!-- Right: actions -->
|
||||||
<div v-if="showActions" class="flex w-full flex-wrap items-center justify-end gap-3 sm:w-auto">
|
<div v-if="showActions" class="flex w-full flex-wrap items-center justify-end gap-3 sm:w-auto">
|
||||||
|
<button type="button" @click="$emit('refresh')" class="btn btn-secondary">
|
||||||
|
{{ t('common.refresh') }}
|
||||||
|
</button>
|
||||||
<button type="button" @click="$emit('reset')" class="btn btn-secondary">
|
<button type="button" @click="$emit('reset')" class="btn btn-secondary">
|
||||||
{{ t('common.reset') }}
|
{{ t('common.reset') }}
|
||||||
</button>
|
</button>
|
||||||
@@ -194,6 +197,7 @@ const emit = defineEmits([
|
|||||||
'update:startDate',
|
'update:startDate',
|
||||||
'update:endDate',
|
'update:endDate',
|
||||||
'change',
|
'change',
|
||||||
|
'refresh',
|
||||||
'reset',
|
'reset',
|
||||||
'export',
|
'export',
|
||||||
'cleanup'
|
'cleanup'
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<TokenUsageTrend :trend-data="trendData" :loading="chartsLoading" />
|
<TokenUsageTrend :trend-data="trendData" :loading="chartsLoading" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<UsageFilters v-model="filters" v-model:startDate="startDate" v-model:endDate="endDate" :exporting="exporting" @change="applyFilters" @reset="resetFilters" @cleanup="openCleanupDialog" @export="exportToExcel" />
|
<UsageFilters v-model="filters" v-model:startDate="startDate" v-model:endDate="endDate" :exporting="exporting" @change="applyFilters" @refresh="refreshData" @reset="resetFilters" @cleanup="openCleanupDialog" @export="exportToExcel" />
|
||||||
<UsageTable :data="usageLogs" :loading="loading" />
|
<UsageTable :data="usageLogs" :loading="loading" />
|
||||||
<Pagination v-if="pagination.total > 0" :page="pagination.page" :total="pagination.total" :page-size="pagination.page_size" @update:page="handlePageChange" @update:pageSize="handlePageSizeChange" />
|
<Pagination v-if="pagination.total > 0" :page="pagination.page" :total="pagination.total" :page-size="pagination.page_size" @update:page="handlePageChange" @update:pageSize="handlePageSizeChange" />
|
||||||
</div>
|
</div>
|
||||||
@@ -83,6 +83,7 @@ const loadChartData = async () => {
|
|||||||
} catch (error) { console.error('Failed to load chart data:', error) } finally { chartsLoading.value = false }
|
} catch (error) { console.error('Failed to load chart data:', error) } finally { chartsLoading.value = false }
|
||||||
}
|
}
|
||||||
const applyFilters = () => { pagination.page = 1; loadLogs(); loadStats(); loadChartData() }
|
const applyFilters = () => { pagination.page = 1; loadLogs(); loadStats(); loadChartData() }
|
||||||
|
const refreshData = () => { loadLogs(); loadStats(); loadChartData() }
|
||||||
const resetFilters = () => { startDate.value = formatLD(weekAgo); endDate.value = formatLD(now); filters.value = { start_date: startDate.value, end_date: endDate.value, billing_type: null }; granularity.value = 'day'; applyFilters() }
|
const resetFilters = () => { startDate.value = formatLD(weekAgo); endDate.value = formatLD(now); filters.value = { start_date: startDate.value, end_date: endDate.value, billing_type: null }; granularity.value = 'day'; applyFilters() }
|
||||||
const handlePageChange = (p: number) => { pagination.page = p; loadLogs() }
|
const handlePageChange = (p: number) => { pagination.page = p; loadLogs() }
|
||||||
const handlePageSizeChange = (s: number) => { pagination.page_size = s; pagination.page = 1; loadLogs() }
|
const handlePageSizeChange = (s: number) => { pagination.page_size = s; pagination.page = 1; loadLogs() }
|
||||||
|
|||||||
Reference in New Issue
Block a user