fix: 单卡设备显示字段
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 1m6s

This commit is contained in:
sexygoat
2026-05-21 14:43:11 +08:00
parent 3e42c4e98c
commit 4226824be9

View File

@@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref, computed, onMounted } from 'vue'
import { resolveAsset, getAssetRealtimeStatus, getCurrentPackage, getAssetPackages } from '@/api/assets'
import type { AssetRealtimeStatus, AssetPackage } from '@/api/assets'
import type { AssetRealtimeStatus, AssetPackage, AssetResolveResponse } from '@/api/assets'
import { formatTime, formatDataSize } from '@/utils/format'
import { formatPackageDataSize, formatPackagePrice, getPackageRemainMb, getPackageTotalMb, getPackageUsagePercent, getPackageUsedMb } from '../package-display'
@@ -28,6 +28,20 @@
const cardInfo = computed(() => isCard.value ? assetInfo.value : null)
// 设备信息
const deviceInfo = computed(() => isDevice.value ? assetInfo.value : null)
type DeviceBoundCard = NonNullable<AssetResolveResponse['cards']>[number]
const deviceBoundCards = computed<DeviceBoundCard[]>(() => Array.isArray(deviceInfo.value?.cards) ? deviceInfo.value.cards : [])
const activeDeviceCard = computed<DeviceBoundCard | null>(() => {
if (deviceBoundCards.value.length === 1) {
return deviceBoundCards.value[0]
}
if (deviceBoundCards.value.length > 1) {
return deviceBoundCards.value.find(card => card.is_current) ?? null
}
return null
})
const deviceRealNameStatus = computed(() => activeDeviceCard.value?.real_name_status ?? deviceInfo.value?.real_name_status)
// 搜索资产
async function handleSearch() {
@@ -890,10 +904,10 @@
</view>
<!-- 实名状态 -->
<view v-if="deviceInfo.real_name_status !== undefined" class="flex items-start justify-between">
<view v-if="deviceRealNameStatus !== undefined" class="flex items-start justify-between">
<text class="text-12px text-[#999] w-80px">实名状态</text>
<text class="flex-1 text-13px text-[#212121] text-right">
{{ getRealNameStatusText(deviceInfo.real_name_status) }}
{{ getRealNameStatusText(deviceRealNameStatus) }}
</text>
</view>
@@ -941,10 +955,10 @@
</view>
<!-- 绑定卡片列表 -->
<view v-if="deviceInfo.cards && deviceInfo.cards.length > 0" class="bg-white rounded-16px shadow-[0_2px_12px_rgba(0,0,0,0.06)] overflow-hidden mt-2 p-2 px-4 pb-3">
<view v-if="deviceBoundCards.length > 0" class="bg-white rounded-16px shadow-[0_2px_12px_rgba(0,0,0,0.06)] overflow-hidden mt-2 p-2 px-4 pb-3">
<text class="text-13px font-600 text-[#212121] block mb-2">绑定IoT卡</text>
<view class="space-y-2">
<view v-for="card in deviceInfo.cards" :key="card.card_id" class="bg-[#f5f5f5] rounded-12px p-3">
<view v-for="card in deviceBoundCards" :key="card.card_id" class="bg-[#f5f5f5] rounded-12px p-3">
<view class="flex items-center justify-between mb-1">
<view class="flex items-center gap-2 min-w-0">
<text class="text-12px text-[#212121]">卡槽 {{ card.slot_position }}</text>