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

@@ -77,6 +77,7 @@ function relativeTime(iso: string): string {
// ── Edit form type ─────────────────────────────────────────────────────────
type EditForm = {
deviceName: string;
chargePointVendor: string;
chargePointModel: string;
registrationStatus: "Accepted" | "Pending" | "Rejected";
@@ -96,6 +97,7 @@ export default function ChargePointDetailPage({ params }: { params: Promise<{ id
const [editOpen, setEditOpen] = useState(false);
const [editBusy, setEditBusy] = useState(false);
const [editForm, setEditForm] = useState<EditForm>({
deviceName: "",
chargePointVendor: "",
chargePointModel: "",
registrationStatus: "Pending",
@@ -122,6 +124,7 @@ export default function ChargePointDetailPage({ params }: { params: Promise<{ id
const openEdit = () => {
if (!cp) return;
setEditForm({
deviceName: cp.deviceName ?? "",
chargePointVendor: cp.chargePointVendor ?? "",
chargePointModel: cp.chargePointModel ?? "",
registrationStatus: cp.registrationStatus as EditForm["registrationStatus"],
@@ -142,6 +145,7 @@ export default function ChargePointDetailPage({ params }: { params: Promise<{ id
registrationStatus: editForm.registrationStatus,
pricingMode: editForm.pricingMode,
feePerKwh: editForm.pricingMode === "fixed" ? fee : 0,
deviceName: editForm.deviceName.trim() || null,
});
await cpQuery.refetch();
setEditOpen(false);
@@ -202,9 +206,12 @@ export default function ChargePointDetailPage({ params }: { params: Promise<{ id
<div className="flex flex-wrap items-start justify-between gap-4">
<div className="space-y-1.5">
<div className="flex flex-wrap items-center gap-2">
<h1 className="font-mono text-2xl font-semibold text-foreground">
{cp.chargePointIdentifier}
<h1 className="text-2xl font-semibold text-foreground">
{cp.deviceName ?? <span className="font-mono">{cp.chargePointIdentifier}</span>}
</h1>
{isAdmin && cp.deviceName && (
<span className="font-mono text-sm text-muted">{cp.chargePointIdentifier}</span>
)}
<Chip
color={registrationColorMap[cp.registrationStatus] ?? "warning"}
size="sm"
@@ -561,6 +568,16 @@ export default function ChargePointDetailPage({ params }: { params: Promise<{ id
<Modal.Heading></Modal.Heading>
</Modal.Header>
<Modal.Body className="space-y-3">
<TextField fullWidth>
<Label className="text-sm font-medium"></Label>
<Input
placeholder="1号楼A区01号桩"
value={editForm.deviceName}
onChange={(e) =>
setEditForm((f) => ({ ...f, deviceName: e.target.value }))
}
/>
</TextField>
<div className="grid grid-cols-2 gap-3">
<TextField fullWidth>
<Label className="text-sm font-medium"></Label>