From a162dcc650399aa3e6ab14235ddb44b7ce71ea8c Mon Sep 17 00:00:00 2001 From: sexygoat <1538832180@qq.com> Date: Fri, 29 May 2026 09:38:30 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=9C=AC=E6=9C=88=E5=B7=B2=E7=94=A8?= =?UTF-8?q?=E6=B5=81=E9=87=8F=E5=92=8C=E8=BF=90=E8=90=A5=E5=95=86=E5=91=A8?= =?UTF-8?q?=E6=9C=9F=E6=9C=88=E5=86=85=E5=B7=B2=E7=94=A8=E6=B5=81=E9=87=8F?= =?UTF-8?q?=E4=BB=A3=E7=90=86=E4=BC=81=E4=B8=9A=E4=B8=8D=E5=B1=95=E7=A4=BA?= =?UTF-8?q?,=E5=85=B6=E4=BB=96=E8=B4=A6=E5=8F=B7=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../proposal.md | 20 ++++++++++ .../asset-card-usage-field-permission/spec.md | 37 +++++++++++++++++++ .../tasks.md | 6 +++ .../components/BasicInfoCard.vue | 13 ++++++- 4 files changed, 74 insertions(+), 2 deletions(-) create mode 100644 openspec/changes/update-asset-card-usage-field-permission/proposal.md create mode 100644 openspec/changes/update-asset-card-usage-field-permission/specs/asset-card-usage-field-permission/spec.md create mode 100644 openspec/changes/update-asset-card-usage-field-permission/tasks.md diff --git a/openspec/changes/update-asset-card-usage-field-permission/proposal.md b/openspec/changes/update-asset-card-usage-field-permission/proposal.md new file mode 100644 index 0000000..d665e05 --- /dev/null +++ b/openspec/changes/update-asset-card-usage-field-permission/proposal.md @@ -0,0 +1,20 @@ +# Change: 为资产卡信息月内流量字段增加权限控制 + +## Why + +资产信息页卡信息中的“本月已用流量”和“运营商周期月内已用流量”属于敏感用量字段,需要统一通过同一个权限编码控制可见性,并对代理账号和企业账号强制隐藏。 + +## What Changes + +- 为资产信息页卡信息中的“本月已用流量”增加权限控制。 +- 为资产信息页卡信息中的“运营商周期月内已用流量”增加相同权限控制。 +- 两个字段统一使用权限编码 `asset_info:view_card_month_usage`。 +- 当当前登录账号 `user_type` 为 `3` 代理账号或 `4` 企业账号时,即使拥有权限也不显示这两个字段。 + +## Impact + +- Affected specs: + - `asset-card-usage-field-permission` +- Affected code: + - `src/views/asset-management/asset-information/components/BasicInfoCard.vue` + - 角色/权限树配置中与 `asset_info:view_card_month_usage` 相关的注册位置 diff --git a/openspec/changes/update-asset-card-usage-field-permission/specs/asset-card-usage-field-permission/spec.md b/openspec/changes/update-asset-card-usage-field-permission/specs/asset-card-usage-field-permission/spec.md new file mode 100644 index 0000000..014192a --- /dev/null +++ b/openspec/changes/update-asset-card-usage-field-permission/specs/asset-card-usage-field-permission/spec.md @@ -0,0 +1,37 @@ +## ADDED Requirements + +### Requirement: Asset Card Month Usage Field Permission + +The asset information page SHALL gate the card information fields `本月已用流量` and `运营商周期月内已用流量` with the same permission code `asset_info:view_card_month_usage`. + +The asset information page MUST hide both fields for logged-in accounts whose `user_type` is `3` (代理账号) or `4` (企业账号), regardless of whether the account has `asset_info:view_card_month_usage`. + +#### Scenario: Show both fields when platform user has permission + +- **GIVEN** 当前登录账号的 `user_type` 不是 `3` 也不是 `4` +- **AND** 用户拥有 `asset_info:view_card_month_usage` +- **WHEN** 页面渲染资产信息的卡信息区域 +- **THEN** 页面 MUST 显示 `本月已用流量` +- **AND** 页面 MUST 显示 `运营商周期月内已用流量` + +#### Scenario: Hide both fields when permission is missing + +- **GIVEN** 当前登录账号的 `user_type` 不是 `3` 也不是 `4` +- **AND** 用户不拥有 `asset_info:view_card_month_usage` +- **WHEN** 页面渲染资产信息的卡信息区域 +- **THEN** 页面 MUST NOT 显示 `本月已用流量` +- **AND** 页面 MUST NOT 显示 `运营商周期月内已用流量` + +#### Scenario: Hide both fields for agent accounts + +- **GIVEN** 当前登录账号的 `user_type` 是 `3` +- **WHEN** 页面渲染资产信息的卡信息区域 +- **THEN** 页面 MUST NOT 显示 `本月已用流量` +- **AND** 页面 MUST NOT 显示 `运营商周期月内已用流量` + +#### Scenario: Hide both fields for enterprise accounts + +- **GIVEN** 当前登录账号的 `user_type` 是 `4` +- **WHEN** 页面渲染资产信息的卡信息区域 +- **THEN** 页面 MUST NOT 显示 `本月已用流量` +- **AND** 页面 MUST NOT 显示 `运营商周期月内已用流量` diff --git a/openspec/changes/update-asset-card-usage-field-permission/tasks.md b/openspec/changes/update-asset-card-usage-field-permission/tasks.md new file mode 100644 index 0000000..c8dd4a8 --- /dev/null +++ b/openspec/changes/update-asset-card-usage-field-permission/tasks.md @@ -0,0 +1,6 @@ +## 1. Implementation + +- [x] 1.1 在资产信息页卡信息中为“本月已用流量”接入 `asset_info:view_card_month_usage` 权限 +- [x] 1.2 在资产信息页卡信息中为“运营商周期月内已用流量”接入同一个 `asset_info:view_card_month_usage` 权限 +- [x] 1.3 确保 `user_type` 为 `3` 代理账号或 `4` 企业账号时隐藏上述两个字段 +- [x] 1.4 完成 OpenSpec 严格校验 diff --git a/src/views/asset-management/asset-information/components/BasicInfoCard.vue b/src/views/asset-management/asset-information/components/BasicInfoCard.vue index 2570452..65822e6 100644 --- a/src/views/asset-management/asset-information/components/BasicInfoCard.vue +++ b/src/views/asset-management/asset-information/components/BasicInfoCard.vue @@ -51,10 +51,10 @@ - {{ + {{ formatDataSize(cardInfo?.current_month_usage_mb || 0) }} - {{ + {{ formatDataSize(cardInfo?.last_gateway_reading_mb || 0) }} {{ @@ -479,6 +479,7 @@ import { CopyDocument } from '@element-plus/icons-vue' import { useAssetFormatters } from '../composables/useAssetFormatters' import { useAuth } from '@/composables/useAuth' + import { useUserStore } from '@/store/modules/user' import { formatDateTime } from '@/utils/business/format' // Props @@ -583,6 +584,9 @@ }) const { hasAuth } = useAuth() + const userStore = useUserStore() + + const CARD_MONTH_USAGE_PERMISSION = 'asset_info:view_card_month_usage' const realnamePolicyPermission = computed(() => { return props.cardInfo?.asset_type === 'card' @@ -600,6 +604,11 @@ const canShowPolling = computed(() => hasAuth(pollingPermission.value)) + const canShowCardMonthUsage = computed(() => { + const userType = Number(userStore.info.user_type ?? 0) + return ![3, 4].includes(userType) && hasAuth(CARD_MONTH_USAGE_PERMISSION) + }) + // Emits interface Emits { (e: 'update:pollingEnabled', value: boolean): void