feat: 更新数据获取逻辑并添加数据使用情况展示

This commit is contained in:
TsMask
2025-02-28 19:44:47 +08:00
parent 4861230f56
commit 33088a9366
2 changed files with 29 additions and 5 deletions

View File

@@ -370,8 +370,8 @@ function fnGetList(pageNum?: number) {
}); });
// 取最大值ID用作实时累加 // 取最大值ID用作实时累加
if (res.total > 0) { if (total > 0) {
modalState.maxId = Number(res.rows[0].id); modalState.maxId = Number(rows[0].id);
} }
} }
tableState.loading = false; tableState.loading = false;

View File

@@ -295,6 +295,8 @@ let state = reactive({
total: 0, total: 0,
/**表格加载状态 */ /**表格加载状态 */
loading: false, loading: false,
/**数据总量 up,down */
dataUsage: ['0 B', '0 B'],
}); });
/**查询列表, pageNum初始页数 */ /**查询列表, pageNum初始页数 */
@@ -330,10 +332,11 @@ function fnGetList(pageNum?: number) {
listSMFDataCDR(toRaw(queryParams)) listSMFDataCDR(toRaw(queryParams))
.then(res => { .then(res => {
if (res.code === RESULT_CODE_SUCCESS) { if (res.code === RESULT_CODE_SUCCESS && Array.isArray(res.data.rows)) {
state.total = res.total; const { total, rows } = res.data;
state.total = total;
// 遍历处理cdr字符串数据 // 遍历处理cdr字符串数据
state.data = res.rows state.data = rows
.map((item: any) => { .map((item: any) => {
let cdrJSON = item.cdrJSON; let cdrJSON = item.cdrJSON;
if (!cdrJSON) { if (!cdrJSON) {
@@ -455,6 +458,18 @@ function fnRanderChartDataUpdate() {
], ],
}); });
cdrChart.hideLoading(); cdrChart.hideLoading();
// 累加总量
let uplinkTotal = 0;
let downlinkTotal = 0;
for (let index = 0; index < dataVolumeUplinkYSeriesData.length; index++) {
uplinkTotal += dataVolumeUplinkYSeriesData[index];
downlinkTotal += dataVolumeDownlinkYSeriesData[index];
}
state.dataUsage = [
parseSizeFromByte(uplinkTotal),
parseSizeFromByte(downlinkTotal),
];
} }
/** /**
@@ -669,6 +684,15 @@ onBeforeUnmount(() => {
<a-card :bordered="false"> <a-card :bordered="false">
<!-- 图数据 --> <!-- 图数据 -->
<div ref="cdrChartDom" style="height: 600px; width: 100%"></div> <div ref="cdrChartDom" style="height: 600px; width: 100%"></div>
<a-descriptions title="Data Usage" bordered :column="2">
<a-descriptions-item label="Total Uplink">
{{ state.dataUsage[0] }}
</a-descriptions-item>
<a-descriptions-item label="Total Downlink">
{{ state.dataUsage[1] }}
</a-descriptions-item>
</a-descriptions>
</a-card> </a-card>
</PageContainer> </PageContainer>
</template> </template>