工单布局修改

This commit is contained in:
mmc
2026-05-14 08:45:14 +08:00
parent 13bfbca03d
commit c0e8a1cd3e
7 changed files with 389 additions and 148 deletions

View File

@@ -278,7 +278,6 @@ export default function AgoraRtcRoom() {
: "RTC 未连接"
}
/>
<Badge
color={
published

View File

@@ -7,13 +7,13 @@ import zhCN from 'antd/locale/zh_CN';
import {
DashboardOutlined, ExperimentOutlined, VideoCameraOutlined,
BellOutlined, UserOutlined, LogoutOutlined,
AppstoreOutlined, SettingOutlined
AppstoreOutlined, SettingOutlined, MenuUnfoldOutlined, MenuFoldOutlined
} from '@ant-design/icons';
import logo from '../assets/logo.png';
import { useSelector } from 'react-redux';
import { RootState, useAppDispatch } from '../store';
import { logout } from '../store/userSlice';
import { setCurrentStation, clearStation } from '../store/stationSlice'; // 👈 引入
import { setCurrentStation, clearStation } from '../store/stationSlice';
import { getMenuList } from '../api/mune';
import { getStationList } from '../api/stationManage';
import envConfig from '../../env';
@@ -30,12 +30,9 @@ export default function AppLayout() {
const location = useLocation();
const dispatch = useAppDispatch();
// 全局用户信息
const { userInfo } = useSelector((state: RootState) => state.user);
// 全局场站信息
const { currentStation, stationId } = useSelector((state: RootState) => state.station);
// 获取场站列表
const getStationData = () => {
const params = {
pageNum: 1,
@@ -46,8 +43,6 @@ export default function AppLayout() {
if (res.code === 200) {
const list = res.rows || [];
setStationList(list);
// 如果没有选中任何场站,默认选第一个
if (!currentStation && list.length > 0) {
dispatch(setCurrentStation(list[0]));
}
@@ -55,15 +50,13 @@ export default function AppLayout() {
});
};
// 切换场站
const handleStationChange = (id: number) => {
const station = stationList.find(s => s.id === id);
if (station) {
dispatch(setCurrentStation(station)); // 👈 存全局
dispatch(setCurrentStation(station));
}
};
// 获取菜单
const getMenu = () => {
const data = { pageNum: 1, pageSize: 10000 };
getMenuList(data).then(res => {
@@ -75,7 +68,6 @@ export default function AppLayout() {
});
};
// 图标映射
const getIcon = (path) => {
if (path.includes('overview')) return <DashboardOutlined />;
if (path.includes('device')) return <ExperimentOutlined />;
@@ -87,17 +79,15 @@ export default function AppLayout() {
return <AppstoreOutlined />;
};
// 菜单
const menuItems = menuList.map(item => ({
key: item.path || `/menu/${item.menuId}`,
icon: getIcon(item.path),
label: item.menuName,
}));
// 退出登录时清空场站
const handleLogout = async () => {
await dispatch(logout());
dispatch(clearStation()); // 👈 清空
dispatch(clearStation());
navigate('/login', { replace: true });
};
@@ -131,6 +121,20 @@ export default function AppLayout() {
padding: '0 16px'
}}>
<Space size="large" style={{ display: 'flex', alignItems: 'center' }}>
{/* ====================== 收起/展开按钮 ====================== */}
<Button
type="text"
icon={collapsed ? <MenuUnfoldOutlined /> : <MenuFoldOutlined />}
onClick={() => setCollapsed(!collapsed)}
style={{
fontSize: '16px',
color: '#fff',
width: 40,
height: 40,
}}
/>
<Space size="small">
<img src={logo} alt="Logo" style={{ width: 24, height: 24 }} />
{!collapsed && (
@@ -140,7 +144,6 @@ export default function AppLayout() {
)}
</Space>
{/* 全局场站选择器 */}
<Select
value={stationId}
placeholder="请选择电站"
@@ -181,7 +184,7 @@ export default function AppLayout() {
collapsible
collapsed={collapsed}
trigger={null}
width={220}
width={150}
theme="light"
style={{ borderRight: '1px solid #e5e7eb' }}
>

View File

@@ -1,11 +1,11 @@
import React, { useState, useRef } from 'react';
import {
Form, Select, Input, Button, Space, message, Card, Typography,
Row, Col, Modal
Form, Select, Button, Space, message, Card, Typography,
Row, Col, Modal, Input
} from 'antd';
import QRCode from 'qrcode';
import axios from 'axios';
import DictManager from "../DictManager"
import DictManager from "../DictManager";
const { Text } = Typography;
@@ -51,9 +51,12 @@ const SerialNumGenerate = () => {
const [loading, setLoading] = useState(false);
const qrRef = useRef(null);
// 查询相关状态
const [queryCode, setQueryCode] = useState('');
const [queryLoading, setQueryLoading] = useState(false);
const [manageVisible, setManageVisible] = useState(false);
// 全部解构出来
const {
types,
models,
@@ -69,9 +72,7 @@ const SerialNumGenerate = () => {
return `${num}-${check}`;
};
// ==============================================
// 【最终版】生成序列号 + JSON二维码
// ==============================================
// 生成序列号 + JSON二维码
const generateQRCode = async () => {
try {
const values = await form.validateFields();
@@ -139,6 +140,27 @@ const SerialNumGenerate = () => {
}
};
// 查询二维码
const handleQueryQRCode = async () => {
if (!queryCode) return message.warning('请输入序列号');
setQueryLoading(true);
try {
const res = await axios.get('/api/query-qrcode', { params: { sn: queryCode } });
if (res.data?.qrUrl) {
setQrUrl(res.data.qrUrl);
setQrJson(res.data.qrJson || '');
setSerialNumber(res.data.serialNumber || '');
message.success('查询成功');
} else {
message.warning('未找到该序列号');
}
} catch {
message.error('查询失败');
} finally {
setQueryLoading(false);
}
};
return (
<div style={{ padding: '0 20px', minHeight: '100vh' }}>
<Card
@@ -186,6 +208,25 @@ const SerialNumGenerate = () => {
</Button>
</Form.Item>
</Form>
{/* 查询模块(已加回) */}
<Card size="small" title="查询历史二维码" style={{ marginTop: 20 }}>
<Space style={{ width: '100%' }}>
<Input
value={queryCode}
onChange={(e) => setQueryCode(e.target.value)}
placeholder="输入序列号查询"
style={
{
width: '300px'
}
}
/>
<Button type="primary" loading={queryLoading} onClick={handleQueryQRCode}>
查询
</Button>
</Space>
</Card>
</Col>
{/* 右侧二维码 */}
@@ -213,7 +254,7 @@ const SerialNumGenerate = () => {
<Space style={{ marginTop: 24 }}>
<Button onClick={downloadQRCode}>下载二维码</Button>
<Button type="primary" loading={loading} onClick={saveToDatabase}>保存到数据库</Button>
<Button type="primary" loading={loading} onClick={saveToDatabase}>保存</Button>
</Space>
</div>
</Col>
@@ -232,6 +273,7 @@ const SerialNumGenerate = () => {
<DictManager title="机器人型号" data={models} onAdd={() => { }} onUpdate={() => { }} onDelete={() => { }} />
<DictManager title="配置" data={configs} onAdd={() => { }} onUpdate={() => { }} onDelete={() => { }} />
<DictManager title="国家" data={countries} onAdd={() => { }} onUpdate={() => { }} onDelete={() => { }} />
<DictManager title="省份" data={provinces} onAdd={() => { }} onUpdate={() => { }} onDelete={() => { }} />
</Modal>
</div>
);

View File

@@ -326,7 +326,7 @@ export default function AlarmCenterPage() {
}}
/>
</Col>
<Col>
<Col style={{ alignSelf: 'flex-end' }}>
<Space>
<Button style={{ borderRadius: 8 }} onClick={() => {
setQueryParams({ deviceId: '', alarmLevel: '', handleStatus: '', startTime: '', endTime: '' });