feat(csms): 充电桩添加 deviceName 字段,区别于 identifier 用于区分设备

This commit is contained in:
2026-03-16 13:43:46 +08:00
parent 0118dd2e15
commit 654a2a66d9
14 changed files with 2095 additions and 40 deletions

View File

@@ -285,7 +285,7 @@ function TrendChart() {
// ── RecentTransactions ────────────────────────────────────────────────────
function RecentTransactions({ txns }: { txns: Transaction[] }) {
function RecentTransactions({ txns, isAdmin = false }: { txns: Transaction[]; isAdmin?: boolean }) {
if (txns.length === 0) {
return <div className="py-8 text-center text-sm text-muted"></div>;
}
@@ -312,10 +312,15 @@ function RecentTransactions({ txns }: { txns: Transaction[] }) {
</span>
<div className="min-w-0 flex-1">
<p className="truncate text-sm font-medium text-foreground">
{tx.chargePointIdentifier ?? "—"}
{tx.chargePointDeviceName ?? tx.chargePointIdentifier ?? "—"}
{tx.connectorNumber != null && (
<span className="ml-1 text-xs text-muted">#{tx.connectorNumber}</span>
)}
{isAdmin && tx.chargePointDeviceName && tx.chargePointIdentifier && (
<span className="ml-1 font-mono text-xs text-muted">
({tx.chargePointIdentifier})
</span>
)}
</p>
<p className="text-xs text-muted">
{tx.idTag}
@@ -347,7 +352,7 @@ function RecentTransactions({ txns }: { txns: Transaction[] }) {
// ── ChargePointStatus ─────────────────────────────────────────────────────
function ChargePointStatus({ cps }: { cps: ChargePoint[] }) {
function ChargePointStatus({ cps, isAdmin }: { cps: ChargePoint[]; isAdmin: boolean }) {
if (cps.length === 0) {
return <div className="py-8 text-center text-sm text-muted"></div>;
}
@@ -369,11 +374,16 @@ function ChargePointStatus({ cps }: { cps: ChargePoint[] }) {
/>
<div className="min-w-0 flex-1">
<p className="truncate text-sm font-medium text-foreground">
{cp.chargePointIdentifier}
</p>
<p className="text-xs text-muted">
{cp.chargePointModel ?? cp.chargePointVendor ?? "未知型号"}
{cp.deviceName ?? cp.chargePointIdentifier}
</p>
{isAdmin && cp.deviceName && (
<p className="font-mono text-xs text-muted">{cp.chargePointIdentifier}</p>
)}
{!(isAdmin && cp.deviceName) && (
<p className="text-xs text-muted">
{cp.chargePointModel ?? cp.chargePointVendor ?? "未知型号"}
</p>
)}
</div>
<div className="shrink-0 text-right">
{online ? (
@@ -563,12 +573,12 @@ export default function DashboardPage() {
<div className="grid grid-cols-1 gap-4 lg:grid-cols-5">
<div className="lg:col-span-2">
<Panel title="充电桩状态">
<ChargePointStatus cps={data?.cps ?? []} />
<ChargePointStatus cps={data?.cps ?? []} isAdmin={isAdmin} />
</Panel>
</div>
<div className="lg:col-span-3">
<Panel title="最近充电会话">
<RecentTransactions txns={data?.txns ?? []} />
<RecentTransactions txns={data?.txns ?? []} isAdmin={isAdmin} />
</Panel>
</div>
</div>