fix: 套餐用量显示
Some checks failed
构建并部署前端到测试环境 / build-and-deploy (push) Has been cancelled

This commit is contained in:
luo
2026-07-23 11:52:25 +08:00
parent db7b3562da
commit e9c0e17d6a
3 changed files with 14 additions and 20 deletions

View File

@@ -36,7 +36,7 @@
<template v-if="isAdminOrPlatform">
<div class="flow-stats-container">
<!-- 真流量 -->
<div v-if="canViewCurrentPackageRealUsage" class="flow-stat-section">
<div v-if="canShowCurrentPackageRealUsage" class="flow-stat-section">
<div class="flow-stat-label">真流量使用</div>
<div class="flow-stat-row">
<span class="stat-item">
@@ -303,13 +303,17 @@
const canViewCurrentPackageVirtualUsage = computed(() =>
hasAuth('asset_info:view_current_package_virtual_usage')
)
const canShowCurrentPackageRealUsage = computed(
() =>
canViewCurrentPackageRealUsage.value || props.currentPackage?.enable_virtual_data === false
)
const canShowCurrentPackageVirtualUsage = computed(
() =>
canViewCurrentPackageVirtualUsage.value && props.currentPackage?.enable_virtual_data !== false
)
const shouldShowTrafficCard = computed(() => {
if (!isAdminOrPlatform.value) return true
return canViewCurrentPackageRealUsage.value || canShowCurrentPackageVirtualUsage.value
return canShowCurrentPackageRealUsage.value || canShowCurrentPackageVirtualUsage.value
})
const descriptionsColumn = computed(() => {

View File

@@ -69,7 +69,7 @@
<template #default="scope">
<div class="traffic-progress">
<template v-if="isAdminOrPlatform && shouldShowAdminTrafficBreakdown(scope.row)">
<div v-if="canViewCurrentPackageRealUsage" class="progress-text">
<div v-if="canShowPackageRealUsage(scope.row)" class="progress-text">
<span class="used"
>已使用真流量: {{ formatDataSize(scope.row.real_used_mb || 0) }}</span
>
@@ -88,7 +88,7 @@
>停机阈值: {{ formatDataSize(scope.row.virtual_total_mb || 0) }}</span
>
</div>
<div v-if="canViewCurrentPackageRealUsage" class="progress-wrapper">
<div v-if="canShowPackageRealUsage(scope.row)" class="progress-wrapper">
<div class="progress-track">
<ElProgress
style="margin-top: 4px"
@@ -123,7 +123,7 @@
<div
v-if="canShowPackageVirtualUsage(scope.row)"
class="progress-text"
:style="{ marginTop: canViewCurrentPackageRealUsage ? '8px' : '0' }"
:style="{ marginTop: canShowPackageRealUsage(scope.row) ? '8px' : '0' }"
>
<span class="used"
>已使用流量: {{ formatDataSize(scope.row.virtual_used_mb || 0) }}</span
@@ -300,12 +300,7 @@
width="30%"
@closed="resetUsedDataForm"
>
<ElForm
ref="usedDataFormRef"
:model="usedDataForm"
:rules="usedDataRules"
label-width="90px"
>
<ElForm ref="usedDataFormRef" :model="usedDataForm" :rules="usedDataRules" label-width="90px">
<ElFormItem label="套餐名称">
<span>{{ selectedPackage?.package_name || '-' }}</span>
</ElFormItem>
@@ -595,12 +590,15 @@
// Props 使用 API 类型
type PackageInfo = AssetPackageUsageRecord
const canShowPackageRealUsage = (pkg: PackageInfo) =>
canViewCurrentPackageRealUsage.value || pkg.enable_virtual_data === false
const canShowPackageVirtualUsage = (pkg: PackageInfo) =>
canViewCurrentPackageVirtualUsage.value && pkg.enable_virtual_data !== false
const shouldShowAdminTrafficBreakdown = (pkg: PackageInfo) => {
if (!isAdminOrPlatform.value) return true
return canViewCurrentPackageRealUsage.value || canShowPackageVirtualUsage(pkg)
return canShowPackageRealUsage(pkg) || canShowPackageVirtualUsage(pkg)
}
interface Props {