fix: 修复用户管理到期时间列显示问题
- 将到期时间从余额列分离为独立列 - 更新 developer/users/components/columns.ts - 更新 columnLabels 添加 balance 和 expiry_at
This commit is contained in:
@@ -76,7 +76,6 @@ export function getColumns(actions: {
|
||||
header: () => t('developer.users.columns.balance'),
|
||||
cell: ({ row }) => {
|
||||
const balance = row.getValue('balance') as number
|
||||
const expiryAt = row.original.expiry_at
|
||||
const billingType = row.original.application?.billing_type
|
||||
|
||||
if (balance === -1) {
|
||||
@@ -84,25 +83,9 @@ export function getColumns(actions: {
|
||||
}
|
||||
|
||||
if (billingType === 'subscription') {
|
||||
if (!expiryAt)
|
||||
return h('span', { class: 'text-muted-foreground' }, '-')
|
||||
try {
|
||||
const date = new Date(expiryAt as string)
|
||||
if (Number.isNaN(date.getTime()))
|
||||
return '-'
|
||||
const now = new Date()
|
||||
if (date < now) {
|
||||
return h(Badge, { variant: 'destructive' }, () => t('developer.users.expiry.expired'))
|
||||
}
|
||||
const daysLeft = Math.ceil((date.getTime() - now.getTime()) / (1000 * 60 * 60 * 24))
|
||||
return h('div', { class: 'flex flex-col' }, [
|
||||
h('span', { class: 'text-green-600 font-medium' }, `${daysLeft} ${t('developer.users.expiry.daysLeft')}`),
|
||||
h('span', { class: 'text-xs text-muted-foreground' }, date.toLocaleDateString('zh-CN')),
|
||||
])
|
||||
}
|
||||
catch {
|
||||
if (balance === null || balance === undefined)
|
||||
return '-'
|
||||
}
|
||||
return h('span', { class: balance > 0 ? 'text-green-600 font-medium' : 'text-muted-foreground' }, balance.toFixed(2))
|
||||
}
|
||||
|
||||
if (balance === null || balance === undefined)
|
||||
@@ -111,6 +94,42 @@ export function getColumns(actions: {
|
||||
return h('span', { class: balance > 0 ? 'text-green-600 font-medium' : 'text-muted-foreground' }, balance.toFixed(2))
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: 'expiry_at',
|
||||
header: () => t('developer.users.columns.expiryAt'),
|
||||
cell: ({ row }) => {
|
||||
const expiryAt = row.getValue('expiry_at') as string
|
||||
const billingType = row.original.application?.billing_type
|
||||
|
||||
if (billingType !== 'subscription') {
|
||||
return h('span', { class: 'text-muted-foreground' }, '-')
|
||||
}
|
||||
|
||||
if (!expiryAt) {
|
||||
return h('span', { class: 'text-muted-foreground' }, '-')
|
||||
}
|
||||
|
||||
try {
|
||||
const date = new Date(expiryAt)
|
||||
if (Number.isNaN(date.getTime()))
|
||||
return '-'
|
||||
|
||||
const now = new Date()
|
||||
if (date < now) {
|
||||
return h(Badge, { variant: 'destructive' }, () => t('developer.users.expiry.expired'))
|
||||
}
|
||||
|
||||
const daysLeft = Math.ceil((date.getTime() - now.getTime()) / (1000 * 60 * 60 * 24))
|
||||
return h('div', { class: 'flex flex-col' }, [
|
||||
h('span', { class: 'text-green-600 font-medium' }, `${daysLeft} ${t('developer.users.expiry.daysLeft')}`),
|
||||
h('span', { class: 'text-xs text-muted-foreground' }, date.toLocaleDateString('zh-CN')),
|
||||
])
|
||||
}
|
||||
catch {
|
||||
return '-'
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
accessorKey: 'last_login_at',
|
||||
header: () => t('developer.users.columns.lastLoginAt'),
|
||||
|
||||
@@ -53,6 +53,8 @@ const columnLabels: Record<string, string> = {
|
||||
'email': 'developer.users.columns.email',
|
||||
'application.name': 'developer.users.columns.application',
|
||||
'online_status': 'developer.users.columns.status',
|
||||
'balance': 'developer.users.columns.balance',
|
||||
'expiry_at': 'developer.users.columns.expiryAt',
|
||||
'last_login_at': 'developer.users.columns.lastLoginAt',
|
||||
'created_at': 'developer.users.columns.createdAt',
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user