fix:some
All checks were successful
构建并部署前端到测试环境 / deploy (push) Successful in 55s

This commit is contained in:
luo
2026-10-20 17:21:48 +08:00
parent 7f3ff10fda
commit 6dedd9f852
5 changed files with 310 additions and 5 deletions

View File

@@ -2,7 +2,7 @@
* 运营商类型配置
*/
import { CarrierType } from '@/types/api'
import { CarrierType, type CarrierRealnameControlEnabled } from '@/types/api'
// 运营商类型选项
export const CARRIER_TYPE_OPTIONS = [
@@ -30,3 +30,11 @@ export function getCarrierTypeLabel(type: CarrierType): string {
export function getCarrierTypeColor(type: CarrierType): string {
return CARRIER_TYPE_MAP[type]?.color || '#666'
}
export function getCarrierRealnameControlLabel(
enabled?: CarrierRealnameControlEnabled | null
): string {
if (enabled === 1) return '管控'
if (enabled === 0) return '不管控'
return '-'
}

View File

@@ -14,6 +14,7 @@ export enum CarrierType {
export type CarrierTrafficThresholdEnabled = 0 | 1
export type CarrierTrafficThresholdUnit = 'MB' | 'GB'
export type CarrierRealnameControlEnabled = 0 | 1
// 运营商响应数据
export interface Carrier {
@@ -23,6 +24,7 @@ export interface Carrier {
carrier_type: CarrierType
description?: string | null
data_reset_day?: number | null // 上游流量重置日(1-28)
realname_control_enabled?: CarrierRealnameControlEnabled // 通道实名管控,仅超级管理员与平台账号可见
realname_link_type?: string | null // 实名链接类型
realname_link_template?: string | null // 实名链接模板
traffic_threshold_enabled?: CarrierTrafficThresholdEnabled | null // 通道流量阈值开关
@@ -47,6 +49,7 @@ export interface CreateCarrierParams {
carrier_type: CarrierType
description?: string | null
data_reset_day?: number | null // 上游流量重置日(1-28)
realname_control_enabled?: CarrierRealnameControlEnabled // 通道实名管控 (0:不管控, 1:管控)
realname_link_type?: string | null // 实名链接类型
realname_link_template?: string | null // 实名链接模板
traffic_threshold_enabled?: CarrierTrafficThresholdEnabled | null // 通道流量阈值开关
@@ -59,6 +62,7 @@ export interface UpdateCarrierParams {
carrier_name?: string
description?: string | null
data_reset_day?: number | null // 上游流量重置日(1-28)
realname_control_enabled?: CarrierRealnameControlEnabled // 通道实名管控 (0:不管控, 1:管控)
realname_link_type?: string | null // 实名链接类型
realname_link_template?: string | null // 实名链接模板
traffic_threshold_enabled?: CarrierTrafficThresholdEnabled | null // 通道流量阈值开关

View File

@@ -34,6 +34,9 @@
<ElDescriptionsItem label="流量重置日">
{{ carrier.data_reset_day ?? '未配置' }}
</ElDescriptionsItem>
<ElDescriptionsItem v-if="canConfigureRealnameControl" label="通道实名管控">
{{ getCarrierRealnameControlLabel(carrier.realname_control_enabled) }}
</ElDescriptionsItem>
<ElDescriptionsItem label="实名链接类型">
{{ carrier.realname_link_type || '未配置' }}
</ElDescriptionsItem>
@@ -71,7 +74,11 @@
import { usePermission } from '@/composables/usePermission'
import { RoutesAlias } from '@/router/routesAlias'
import { formatDateTime } from '@/utils/business/format'
import { getStatusText, getCarrierTypeLabel } from '@/config/constants'
import {
getStatusText,
getCarrierTypeLabel,
getCarrierRealnameControlLabel
} from '@/config/constants'
import type { Carrier } from '@/types/api'
defineOptions({ name: 'CarrierDetail' })
@@ -80,6 +87,7 @@
const router = useRouter()
const { isPlatformAccount } = usePermission()
const canConfigureTrafficThreshold = computed(() => isPlatformAccount.value)
const canConfigureRealnameControl = computed(() => isPlatformAccount.value)
const { width } = useWindowSize()
const descriptionColumns = computed(() => (width.value < 768 ? 1 : 2))
const loading = ref(false)

View File

@@ -144,6 +144,20 @@
/>
</ElFormItem>
</template>
<ElFormItem
v-if="canConfigureRealnameControl"
label="通道实名管控"
prop="realname_control_enabled"
>
<ElSwitch
v-model="form.realname_control_enabled"
:active-value="1"
:inactive-value="0"
active-text="管控"
inactive-text="不管控"
inline-prompt
/>
</ElFormItem>
<ElFormItem label="实名链接类型" prop="realname_link_type">
<ElSelect
v-model="form.realname_link_type"
@@ -205,7 +219,8 @@
getStatusText,
CARRIER_TYPE_OPTIONS,
getCarrierTypeLabel,
getCarrierTypeColor
getCarrierTypeColor,
getCarrierRealnameControlLabel
} from '@/config/constants'
defineOptions({ name: 'CarrierManagement' })
@@ -214,6 +229,7 @@
const { hasAuth } = useAuth()
const { isPlatformAccount } = usePermission()
const canConfigureTrafficThreshold = computed(() => isPlatformAccount.value)
const canConfigureRealnameControl = computed(() => isPlatformAccount.value)
const canUpdateCarrierStatus = hasAuth('carrier:update_status')
const dialogVisible = ref(false)
const loading = ref(false)
@@ -284,6 +300,9 @@
{ label: '运营商名称', prop: 'carrier_name' },
{ label: '运营商类型', prop: 'carrier_type' },
{ label: '运营商描述', prop: 'description' },
...(canConfigureRealnameControl.value
? [{ label: '通道实名管控', prop: 'realname_control_enabled' }]
: []),
...(canConfigureTrafficThreshold.value
? [
{ label: '通道阈值状态', prop: 'traffic_threshold_enabled' },
@@ -352,6 +371,7 @@
carrier_type: null,
description: '',
data_reset_day: 1,
realname_control_enabled: 0,
traffic_threshold_mode: 'unconfigured',
traffic_threshold_unit: null,
traffic_threshold_value: null,
@@ -405,6 +425,17 @@
minWidth: 200,
showOverflowTooltip: true
},
...(canConfigureRealnameControl.value
? [
{
prop: 'realname_control_enabled',
label: '通道实名管控',
width: 140,
formatter: (row: Carrier) =>
getCarrierRealnameControlLabel(row.realname_control_enabled)
}
]
: []),
...(canConfigureTrafficThreshold.value
? [
{
@@ -574,6 +605,7 @@
form.carrier_type = row.carrier_type
form.description = row.description
form.data_reset_day = row.data_reset_day || 1
form.realname_control_enabled = row.realname_control_enabled ?? 0
form.traffic_threshold_mode = getThresholdMode(row.traffic_threshold_enabled)
form.traffic_threshold_unit = row.traffic_threshold_unit ?? null
form.traffic_threshold_value = row.traffic_threshold_value ?? null
@@ -586,6 +618,7 @@
form.carrier_type = null
form.description = ''
form.data_reset_day = 1
form.realname_control_enabled = 0
form.traffic_threshold_mode = 'unconfigured'
form.traffic_threshold_unit = null
form.traffic_threshold_value = null
@@ -621,6 +654,11 @@
const formatThresholdValue = (value?: number | null) =>
value === null || value === undefined ? '未配置' : String(value)
const getRealnameControlPayload = (): Pick<CreateCarrierParams, 'realname_control_enabled'> =>
canConfigureRealnameControl.value
? { realname_control_enabled: form.realname_control_enabled }
: {}
const getTrafficThresholdPayload = () => {
if (!canConfigureTrafficThreshold.value) return {}
if (form.traffic_threshold_mode === 'unconfigured') {
@@ -701,7 +739,8 @@
realname_link_type: form.realname_link_type,
realname_link_template:
form.realname_link_type === 'template' ? form.realname_link_template : undefined,
...getTrafficThresholdPayload()
...getTrafficThresholdPayload(),
...getRealnameControlPayload()
}
if (dialogType.value === 'add') {
@@ -715,7 +754,8 @@
realname_link_type: form.realname_link_type,
realname_link_template:
form.realname_link_type === 'template' ? form.realname_link_template : undefined,
...getTrafficThresholdPayload()
...getTrafficThresholdPayload(),
...getRealnameControlPayload()
}
await CarrierService.updateCarrier(form.id, updateData)
ElMessage.success('修改成功')