fix(ui): 修复充电状态筛选重置
This commit is contained in:
+14
-12
@@ -1,7 +1,7 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import { createFileRoute, Link, useNavigate } from '@tanstack/react-router'
|
||||
import { createColumnHelper, flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-table'
|
||||
import { ArrowLeft, Battery, BatteryCharging, BatteryLow, Database, FilterX, Search, Zap } from 'lucide-react'
|
||||
import { ArrowLeft, Battery, BatteryCharging, BatteryLow, FilterX, Search, Zap } from 'lucide-react'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { z } from 'zod'
|
||||
import { orpc } from '@/client/orpc'
|
||||
@@ -77,6 +77,8 @@ function parseSort(value: string): BatteryListSort {
|
||||
}
|
||||
|
||||
function parsePowerStatus(value: string): PowerStatus | undefined {
|
||||
if (value === '') return undefined
|
||||
|
||||
const parsed = Number(value)
|
||||
|
||||
return POWER_STATUS_VALUES.find((option) => option === parsed)
|
||||
@@ -242,11 +244,11 @@ function BatteriesPage() {
|
||||
<div className="flex flex-col gap-5 lg:flex-row lg:items-end lg:justify-between">
|
||||
<div>
|
||||
<Badge variant="info" className="mb-4">
|
||||
<Database className="size-3.5" /> MySQL 实时记录
|
||||
<Battery className="size-3.5" /> 实时设备数据
|
||||
</Badge>
|
||||
<h1 className="text-3xl font-light tracking-tight text-white">设备电池实时状态</h1>
|
||||
<h1 className="text-3xl font-light tracking-tight text-white">设备状态明细</h1>
|
||||
<p className="mt-2 max-w-2xl text-sm leading-6 text-zinc-400">
|
||||
只展示 ls_battery_info 最新采集记录,筛选、排序和分页均通过 ORPC 服务端查询完成。
|
||||
查看最新设备状态,快速定位低电量、充电中和长期未更新的设备。
|
||||
</p>
|
||||
<p className="mt-2 text-xs tabular-nums text-zinc-500">
|
||||
{data ? `更新于 ${new Date(data.updatedAt).toLocaleString('zh-CN')}` : '加载中…'}
|
||||
@@ -257,7 +259,7 @@ function BatteriesPage() {
|
||||
to="/"
|
||||
className="inline-flex items-center gap-2 rounded-lg border border-white/10 bg-white/[0.04] px-3 py-2 text-sm text-zinc-300 transition-colors hover:border-teal-400/30 hover:text-teal-300"
|
||||
>
|
||||
<ArrowLeft className="size-4" /> 返回 SoH 看板
|
||||
<ArrowLeft className="size-4" /> 返回健康看板
|
||||
</Link>
|
||||
</nav>
|
||||
</div>
|
||||
@@ -290,7 +292,7 @@ function BatteriesPage() {
|
||||
<SectionTitle
|
||||
icon={<Search className="size-4" />}
|
||||
title="筛选设备"
|
||||
description="按真实采集字段筛选,不在前端伪造或补齐记录。"
|
||||
description="按设备名称、编号、电量与充电状态快速缩小排查范围。"
|
||||
/>
|
||||
{hasActiveFilters && (
|
||||
<Button type="button" className="h-9 px-3 text-xs" onClick={clearFilters}>
|
||||
@@ -301,14 +303,14 @@ function BatteriesPage() {
|
||||
<div className="flex flex-wrap items-end gap-4">
|
||||
<div className="flex flex-col gap-2 min-w-[260px] flex-1">
|
||||
<label htmlFor="search-input" className="text-xs font-medium text-zinc-500">
|
||||
设备名称 / MAC
|
||||
设备名称 / 设备编号
|
||||
</label>
|
||||
<div className="relative">
|
||||
<Search className="pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-zinc-600" />
|
||||
<Input
|
||||
id="search-input"
|
||||
type="text"
|
||||
placeholder="搜索设备名称或 MAC..."
|
||||
placeholder="搜索设备名称或编号..."
|
||||
maxLength={100}
|
||||
className="pl-9"
|
||||
value={localSearch}
|
||||
@@ -369,7 +371,7 @@ function BatteriesPage() {
|
||||
|
||||
<div className="flex flex-col gap-2">
|
||||
<label htmlFor="page-size-select" className="text-xs font-medium text-zinc-500">
|
||||
页大小
|
||||
每页条数
|
||||
</label>
|
||||
<Select
|
||||
id="page-size-select"
|
||||
@@ -411,7 +413,7 @@ function BatteriesPage() {
|
||||
})
|
||||
}
|
||||
/>
|
||||
<Zap className="size-4 text-amber-300" /> 仅看低电量
|
||||
<Zap className="size-4 text-amber-300" /> 仅显示低电量设备
|
||||
</label>
|
||||
</div>
|
||||
</Card>
|
||||
@@ -440,7 +442,7 @@ function BatteriesPage() {
|
||||
) : data?.items.length === 0 ? (
|
||||
<tr>
|
||||
<td colSpan={columns.length} className="h-32 text-center text-zinc-500">
|
||||
暂无匹配设备
|
||||
未找到符合条件的设备
|
||||
</td>
|
||||
</tr>
|
||||
) : (
|
||||
@@ -461,7 +463,7 @@ function BatteriesPage() {
|
||||
|
||||
<div className="mt-6 flex items-center justify-between text-sm text-zinc-500">
|
||||
<div>
|
||||
显示 {data?.items.length ?? 0} 台设备
|
||||
当前显示 {data?.items.length ?? 0} 台设备
|
||||
{data?.total ? ` (共 ${data.total} 台)` : ''}
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
|
||||
Reference in New Issue
Block a user