From 04d23d8c24b4e687e0e9c35c0035440a586f617a Mon Sep 17 00:00:00 2001 From: admin Date: Thu, 30 Apr 2026 21:21:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=88=B0=E6=9C=9F=E6=97=B6=E9=97=B4=E5=88=97?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将到期时间从余额列分离为独立列 - 更新 developer/users/components/columns.ts - 更新 columnLabels 添加 balance 和 expiry_at --- .../developer/users/components/columns.ts | 57 ++++++++++++------- .../developer/users/components/data-table.vue | 2 + 2 files changed, 40 insertions(+), 19 deletions(-) diff --git a/frontend/src/pages/developer/users/components/columns.ts b/frontend/src/pages/developer/users/components/columns.ts index 7b956b8..3ab5a08 100644 --- a/frontend/src/pages/developer/users/components/columns.ts +++ b/frontend/src/pages/developer/users/components/columns.ts @@ -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'), diff --git a/frontend/src/pages/developer/users/components/data-table.vue b/frontend/src/pages/developer/users/components/data-table.vue index a4572fd..8db1801 100644 --- a/frontend/src/pages/developer/users/components/data-table.vue +++ b/frontend/src/pages/developer/users/components/data-table.vue @@ -53,6 +53,8 @@ const columnLabels: Record = { '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', }