From 063ecfe3dfdd74af894844ee889b761dcb01716e Mon Sep 17 00:00:00 2001 From: lai <10633968+laiyujun1@user.noreply.gitee.com> Date: Wed, 26 Feb 2025 21:08:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/hooks/common/table.ts | 10 +- src/views/billing/cdrlrecords/index.vue | 80 +++------ src/views/billing/packagehistories/index.vue | 179 ++++++++++++------- src/views/billing/rechargehistory/index.vue | 44 ++--- 4 files changed, 154 insertions(+), 159 deletions(-) diff --git a/src/hooks/common/table.ts b/src/hooks/common/table.ts index 8c54c5c..4b535ff 100644 --- a/src/hooks/common/table.ts +++ b/src/hooks/common/table.ts @@ -79,13 +79,12 @@ export function useTable(config: AntDesign.AntDe const pagination: TablePaginationConfig = reactive({ showSizeChanger: true, - pageSizeOptions: [10, 15, 20, 25, 30], + pageSizeOptions: ['5','10', '15', '20','30'], total: 0, - simple: false, - // size: 'f', + size: 'default', current: 1, - pageSize: 10, - defaultPageSize: 10, + pageSize: 5, + defaultPageSize: 5, responsive: true, onChange: async (current: number, pageSize: number) => { pagination.current = current; @@ -105,7 +104,6 @@ export function useTable(config: AntDesign.AntDe const mobilePagination = computed(() => { const p: TablePaginationConfig = { ...pagination, - simple: appStore.isMobile }; return p; diff --git a/src/views/billing/cdrlrecords/index.vue b/src/views/billing/cdrlrecords/index.vue index 864036b..989ae92 100644 --- a/src/views/billing/cdrlrecords/index.vue +++ b/src/views/billing/cdrlrecords/index.vue @@ -37,7 +37,6 @@ interface RawCDRRecord { // CDR记录数据 const cdrData = ref([]); -const loading = ref(false); const pagination = ref({ current: 1, pageSize: 10, @@ -77,7 +76,15 @@ function formatTimestamp(timestamp: number): string { }); } -const columns: TableColumnsType = [ + +const { columns, data, loading, getData, mobilePagination, searchParams } = useTable({ + apiFn: fetchCDRHistory, + apiParams: { + pageNum: 1, + pageSize: 5, + }, + rowKey: 'cdrlrecords', + columns: () => [ { title: t('page.cdrlrecords.devicename'), dataIndex: 'deviceName', @@ -98,52 +105,16 @@ const columns: TableColumnsType = [ width: '30%', align: 'right' } -]; - -// 获取CDR记录数据 -async function getCDRHistory(page = pagination.value.current, pageSize = pagination.value.pageSize) { - loading.value = true; - try { - const { data, error } = await fetchCDRHistory({ - pageNum: page, - pageSize: pageSize - }); - if (!error && data) { - // 将原始数据映射为显示所需的格式 - cdrData.value = data.rows.map((item: RawCDRRecord) => ({ - id: item.id, - deviceName: item.clientName, - macAddress: item.clientMac, - trafficUp: formatTraffic(item.trafficUp), // 格式化上传流量 - trafficDown: formatTraffic(item.trafficDown), // 格式化下载流量 - startTime: formatTimestamp(item.startTime), // 格式化开始时间 - endTime: formatTimestamp(item.endTime) // 格式化结束时间 - })); - pagination.value.total = data.total; - } - } catch (err) { - console.error('Failed to fetch CDR history:', err); - } finally { - loading.value = false; - } -} - -// 处理分页变化 -function handleTableChange(pag: any) { - pagination.value.current = pag.current; - pagination.value.pageSize = pag.pageSize; - getCDRHistory(pag.current, pag.pageSize); -} - -// 刷新设备列表 -async function handleRefresh() { - await getCDRHistory(); -} - -// 组件挂载时获取数据 -onMounted(() => { - getCDRHistory(); +] }); + + + + + + + +