From c3eed024b6c5a780aba0e2d407011c2670bc072e Mon Sep 17 00:00:00 2001 From: 12451 <12451@example.com> Date: Thu, 2 Jul 2026 17:27:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9F=9C=E5=AD=90=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E9=A1=B5=E6=B7=BB=E5=8A=A0=E6=8E=A5=E8=A7=A6=E5=99=A8=E6=8E=A7?= =?UTF-8?q?=E5=88=B6=E6=8C=89=E9=92=AE(pow=5Fon/pow=5Foff)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- software/web/src/api/devices.ts | 3 + software/web/src/pages/devices/cabinet.tsx | 91 +++++++++++++++++++--- 2 files changed, 83 insertions(+), 11 deletions(-) diff --git a/software/web/src/api/devices.ts b/software/web/src/api/devices.ts index b030663..4d68666 100644 --- a/software/web/src/api/devices.ts +++ b/software/web/src/api/devices.ts @@ -79,6 +79,9 @@ export const cabinetApi = { delete: (id: number) => api.delete(`/cabinets/${id}`), regenerateAuth: (id: number) => api.post<{ auth_str: string }>(`/cabinets/${id}/regenerate-auth`), getDetail: (id: number) => api.get(`/cabinets/${id}`), + // 接触器控制 + powOn: (id: number) => api.post(`/cabinets/${id}/pow-on`), + powOff: (id: number) => api.post(`/cabinets/${id}/pow-off`), }; // 组织树 API diff --git a/software/web/src/pages/devices/cabinet.tsx b/software/web/src/pages/devices/cabinet.tsx index ed85ca7..68ff9e7 100644 --- a/software/web/src/pages/devices/cabinet.tsx +++ b/software/web/src/pages/devices/cabinet.tsx @@ -13,6 +13,8 @@ import { Grid, Button, Descriptions, + Message, + Modal, } from '@arco-design/web-react'; import { IconLeft, IconDesktop } from '@arco-design/web-react/icon'; import { cabinetApi, type CabinetDetail } from '@/api/devices'; @@ -41,6 +43,7 @@ export default function CabinetDetail() { const navigate = useNavigate(); const [loading, setLoading] = useState(true); const [detail, setDetail] = useState(null); + const [powLoading, setPowLoading] = useState(false); useEffect(() => { if (!id) return; @@ -54,6 +57,52 @@ export default function CabinetDetail() { .finally(() => setLoading(false)); }, [id]); + /** 接触器合闸 */ + const handlePowOn = () => { + if (!id) return; + Modal.confirm({ + title: '确认操作', + content: '确定要合闸恢复380V供电吗?', + onOk: async () => { + setPowLoading(true); + try { + await cabinetApi.powOn(Number(id)); + Message.success('合闸指令已发送'); + // 刷新详情 + const res = await cabinetApi.getDetail(Number(id)); + setDetail(res.data); + } catch { + Message.error('操作失败'); + } finally { + setPowLoading(false); + } + }, + }); + }; + + /** 接触器分闸 */ + const handlePowOff = () => { + if (!id) return; + Modal.confirm({ + title: '确认操作', + content: '确定要分闸切断380V供电吗?', + onOk: async () => { + setPowLoading(true); + try { + await cabinetApi.powOff(Number(id)); + Message.success('分闸指令已发送'); + // 刷新详情 + const res = await cabinetApi.getDetail(Number(id)); + setDetail(res.data); + } catch { + Message.error('操作失败'); + } finally { + setPowLoading(false); + } + }, + }); + }; + if (loading) { return ( @@ -104,17 +153,37 @@ export default function CabinetDetail() { {/* 柜子信息 */} - +
+ +
+ + +
+
{/* 仓控板列表 */}