feat: 7月迭代
All checks were successful
构建并部署前端到测试环境 / build-and-deploy (push) Successful in 4m21s

This commit is contained in:
luo
2026-07-28 14:00:22 +08:00
parent f0a2b84e53
commit 2706c52a47
63 changed files with 4113 additions and 3945 deletions

View File

@@ -5,7 +5,7 @@
v-model:filter="searchForm"
:items="searchFormItems"
:show-expand="true"
label-width="85"
label-width="100px"
@reset="handleReset"
@search="handleSearch"
/>
@@ -17,7 +17,10 @@
@refresh="handleRefresh"
>
<template #left>
<div class="page-intro"> 仅展示可预计且尚未过期的资产,0-3 天资产优先显示。 </div>
<div class="page-intro">
临期资产 {{ summary.total_count }} 条(卡 {{ summary.card_count }},设备
{{ summary.device_count }}),0-3 天资产优先显示。
</div>
</template>
</ArtTableHeader>
@@ -47,11 +50,12 @@
<script setup lang="ts">
import { h, onMounted, reactive, ref, computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { ElTag } from 'element-plus'
import { ElMessage, ElTag } from 'element-plus'
import { AssetService, PackageManageService, ShopService } from '@/api/modules'
import type {
AssetType,
ExpiringAssetItem,
ExpiringAssetSummary,
ExpiringAssetType,
ExpiringAssetQueryParams,
PackageResponse,
ShopResponse
@@ -72,6 +76,12 @@
const shopOptions = ref<ShopResponse[]>([])
const packageOptions = ref<PackageResponse[]>([])
const items = ref<ExpiringAssetItem[]>([])
const summary = reactive<ExpiringAssetSummary>({
card_count: 0,
device_count: 0,
total_count: 0,
window_days: 15
})
const searchForm = reactive<ExpiringAssetQueryParams>({
asset_type: undefined,
keyword: '',
@@ -91,7 +101,7 @@
type: 'select',
config: { clearable: true, placeholder: '全部' },
options: [
{ label: '网卡', value: 'card' },
{ label: '物联网卡', value: 'iot_card' },
{ label: '设备', value: 'device' }
]
},
@@ -137,13 +147,25 @@
label: '最小剩余天数',
prop: 'days_min',
type: 'input',
config: { clearable: true, inputmode: 'numeric', placeholder: '最小天数' }
config: {
clearable: true,
type: 'number',
min: 0,
max: 15,
placeholder: '最小天数'
}
},
{
label: '最大剩余天数',
prop: 'days_max',
type: 'input',
config: { clearable: true, inputmode: 'numeric', placeholder: '最大天数' }
config: {
clearable: true,
type: 'number',
min: 0,
max: 15,
placeholder: '最大天数'
}
},
{
label: '预计到期起始',
@@ -170,15 +192,15 @@
]
const getExpiryClass = (level?: string | null) => {
if (level === 'critical' || level === '0_3') return 'expiry-critical'
if (level === 'warning' || level === '4_7') return 'expiry-warning'
if (level === 'notice' || level === '8_15') return 'expiry-notice'
if (level === 'red') return 'expiry-critical'
if (level === 'purple') return 'expiry-warning'
if (level === 'pink') return 'expiry-notice'
return ''
}
const getExpiryTagType = (level?: string | null) => {
if (level === 'critical' || level === '0_3') return 'danger'
if (level === 'warning' || level === '4_7') return 'warning'
if (level === 'red') return 'danger'
if (level === 'purple') return 'warning'
return 'info'
}
@@ -215,7 +237,7 @@
prop: 'asset_type',
label: '资产类型',
width: 100,
formatter: (row: ExpiringAssetItem) => (row.asset_type === 'card' ? '网卡' : '设备')
formatter: (row: ExpiringAssetItem) => (row.asset_type === 'iot_card' ? '物联网卡' : '设备')
},
{
prop: 'identifier',
@@ -246,7 +268,7 @@
h(
'span',
{ class: getExpiryClass(row.expiry_level) },
formatDateTime(row.estimated_final_expires_at)
formatDateTime(row.estimated_final_expires_at) || '-'
)
},
{
@@ -254,10 +276,8 @@
label: '剩余天数',
width: 100,
formatter: (row: ExpiringAssetItem) =>
h(
ElTag,
{ type: getExpiryTagType(row.expiry_level), size: 'small' },
() => `${row.days_until_final_expiry}天`
h(ElTag, { type: getExpiryTagType(row.expiry_level), size: 'small' }, () =>
row.days_until_final_expiry == null ? '-' : `${row.days_until_final_expiry}天`
)
},
{
@@ -271,15 +291,43 @@
const loadAssets = async () => {
loading.value = true
try {
const response = await AssetService.getExpiringAssets({
...searchForm,
const toInteger = (value: unknown) => {
if (value === undefined || value === null || value === '') return undefined
const numberValue = Number(value)
return Number.isInteger(numberValue) ? numberValue : undefined
}
const params: ExpiringAssetQueryParams = {
page: pagination.currentPage,
size: pagination.pageSize
})
page_size: pagination.pageSize
}
if (searchForm.asset_type) params.asset_type = searchForm.asset_type
const keyword = searchForm.keyword?.trim()
if (keyword) params.keyword = keyword
if (searchForm.shop_id !== undefined && searchForm.shop_id !== null) {
params.shop_id = searchForm.shop_id
}
if (searchForm.package_id !== undefined && searchForm.package_id !== null) {
params.package_id = searchForm.package_id
}
const daysMin = toInteger(searchForm.days_min)
const daysMax = toInteger(searchForm.days_max)
if (daysMin !== undefined) params.days_min = daysMin
if (daysMax !== undefined) params.days_max = daysMax
if (searchForm.expires_from) params.expires_from = searchForm.expires_from
if (searchForm.expires_to) params.expires_to = searchForm.expires_to
const response = await AssetService.getExpiringAssets(params)
if (response.code === 0 && response.data) {
items.value = response.data.items || []
pagination.total = response.data.total || 0
Object.assign(summary, response.data.summary)
} else {
ElMessage.error(response.msg || '获取临期资产失败')
}
} catch (error) {
console.error('获取临期资产失败:', error)
ElMessage.error('获取临期资产失败')
} finally {
loading.value = false
}
@@ -318,21 +366,20 @@
const goToAsset = (row: ExpiringAssetItem) => {
router.push({
path: RoutesAlias.AssetInformation,
query: row.asset_type === 'card' ? { iccid: row.identifier } : { virtual_no: row.identifier }
query:
row.asset_type === 'iot_card' ? { iccid: row.identifier } : { virtual_no: row.identifier }
})
}
const getActions = (row: ExpiringAssetItem) => [
{ label: '查看资产', type: 'primary' as const, handler: () => goToAsset(row) },
...(row.can_renew
? [{ label: '续费', type: 'primary' as const, handler: () => goToAsset(row) }]
: [])
{ label: '查看资产', type: 'primary' as const, handler: () => goToAsset(row) }
]
onMounted(() => {
const assetType = route.query.asset_type
if (assetType === 'card' || assetType === 'device')
searchForm.asset_type = assetType as AssetType
if (assetType === 'card' || assetType === 'iot_card' || assetType === 'device') {
searchForm.asset_type = assetType === 'card' ? 'iot_card' : (assetType as ExpiringAssetType)
}
void Promise.all([loadAssets(), searchShops(), searchPackages()])
})
</script>