工单布局修改
This commit is contained in:
45
src/api/workOrder.ts
Normal file
45
src/api/workOrder.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
|
||||
import request from './request';
|
||||
//获取工单列表
|
||||
export function getWorkOrderApi() {
|
||||
return request({
|
||||
url: `/iot/ioTworkOrder/list`,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
//获取工单详情
|
||||
export function getWorkOrderDetailApi(id: any) {
|
||||
return request({
|
||||
url: `/iot/ioTworkOrder/${id}`,
|
||||
method: 'get',
|
||||
});
|
||||
}
|
||||
//新增工单/
|
||||
|
||||
export function addWorkOrder(data) {
|
||||
return request({
|
||||
url: `/iot/ioTworkOrder`,
|
||||
method: 'post',
|
||||
data
|
||||
});
|
||||
}
|
||||
//修改工单/iot/ioTworkOrder
|
||||
|
||||
export function updateWorkOrder(data) {
|
||||
return request({
|
||||
url: `/iot/ioTworkOrder`,
|
||||
method: 'put',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
//派发工单 /iot/ioTworkOrder/dispat
|
||||
|
||||
export function dispatchWorkOrder(data) {
|
||||
return request({
|
||||
url: `/iot/ioTworkOrder/dispat`,
|
||||
method: 'put',
|
||||
data
|
||||
});
|
||||
}
|
||||
|
||||
@@ -278,7 +278,6 @@ export default function AgoraRtcRoom() {
|
||||
: "RTC 未连接"
|
||||
}
|
||||
/>
|
||||
|
||||
<Badge
|
||||
color={
|
||||
published
|
||||
|
||||
@@ -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' }}
|
||||
>
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
|
||||
@@ -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: '' });
|
||||
|
||||
@@ -262,8 +262,8 @@ export default function StationDashboard() {
|
||||
}}
|
||||
>
|
||||
{/* 今日发电量 */}
|
||||
<Col flex="1 1 16.666%">
|
||||
<Card bordered={false} style={cardStyle} bodyStyle={{ padding: '16px' }}>
|
||||
<Col flex="1 1 16.666%" style={{ height: '140px' }}>
|
||||
<Card bordered={false} style={{ ...cardStyle, height: "100%" }} bodyStyle={{ padding: '16px' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<div>
|
||||
<div style={{ color: '#000', fontSize: 14, fontWeight: 600, marginBottom: 8 }}>今日发电量</div>
|
||||
@@ -290,8 +290,8 @@ export default function StationDashboard() {
|
||||
</Col>
|
||||
|
||||
{/* 当前功率 */}
|
||||
<Col flex="1 1 16.666%">
|
||||
<Card bordered={false} style={cardStyle} bodyStyle={{ padding: '16px' }}>
|
||||
<Col flex="1 1 16.666%" style={{ height: '140px' }}>
|
||||
<Card bordered={false} style={{ ...cardStyle, height: "100%" }} bodyStyle={{ padding: '16px' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<div>
|
||||
<div style={{ color: '#000', fontSize: 14, fontWeight: 600, marginBottom: 8 }}>当前功率</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import {
|
||||
Layout, Card, Row, Col, Button, Table, Tag, Select, Input, Typography, Space,
|
||||
Statistic, Modal, message, Empty, Drawer, Descriptions, Timeline, Divider, Form, Tabs, Progress, Badge, DatePicker, Pagination
|
||||
@@ -25,97 +25,54 @@ import {
|
||||
History,
|
||||
ExternalLink
|
||||
} from 'lucide-react';
|
||||
// 导入工单接口
|
||||
import { getWorkOrderApi, getWorkOrderDetailApi, updateWorkOrder, dispatchWorkOrder } from '../api/workOrder';
|
||||
|
||||
const { Option } = Select;
|
||||
const { Search } = Input;
|
||||
const { Text, Title } = Typography;
|
||||
const { RangePicker } = DatePicker;
|
||||
const FormItem = Form.Item;
|
||||
|
||||
// 模拟数据
|
||||
const workOrderData = [
|
||||
{
|
||||
id: 'WO20250524001',
|
||||
title: '逆变器 INV-05 告警排查',
|
||||
source: 'AI诊断',
|
||||
type: '检修',
|
||||
priority: 'high',
|
||||
status: 'pending',
|
||||
handler: '李工',
|
||||
deadline: '2025-05-24 14:30',
|
||||
},
|
||||
{
|
||||
id: 'WO20250524002',
|
||||
title: '区块 B-12 热斑复检',
|
||||
source: '无人机巡检',
|
||||
type: '巡检',
|
||||
priority: 'high',
|
||||
status: 'processing',
|
||||
handler: '王工',
|
||||
deadline: '2025-05-24 15:00',
|
||||
},
|
||||
{
|
||||
id: 'WO20250524003',
|
||||
title: '组件清洗任务 C-05',
|
||||
source: '清洗优化',
|
||||
type: '清洗',
|
||||
priority: 'medium',
|
||||
status: 'dispatched',
|
||||
handler: '赵工',
|
||||
deadline: '2025-05-24 16:00',
|
||||
},
|
||||
{
|
||||
id: 'WO20250524004',
|
||||
title: '周界摄像头 CAM-08 离线修复',
|
||||
source: '视频监控',
|
||||
type: '维修',
|
||||
priority: 'medium',
|
||||
status: 'processing',
|
||||
handler: '陈工',
|
||||
deadline: '2025-05-24 17:30',
|
||||
},
|
||||
{
|
||||
id: 'WO20250524005',
|
||||
title: '除草机器人补给',
|
||||
source: '装备控制',
|
||||
type: '运维',
|
||||
priority: 'low',
|
||||
status: 'pending',
|
||||
handler: '刘工',
|
||||
deadline: '2025-05-24 18:00',
|
||||
},
|
||||
{
|
||||
id: 'WO20250524006',
|
||||
title: '逆变器室夜间巡检',
|
||||
source: '人工创建',
|
||||
type: '巡检',
|
||||
priority: 'medium',
|
||||
status: 'completed',
|
||||
handler: '张运维',
|
||||
deadline: '2025-05-24 21:00',
|
||||
}
|
||||
];
|
||||
|
||||
// 工单状态配置
|
||||
const statusConfig = {
|
||||
pending: { label: '待处理', color: '#52c41a', textColor: '#1890ff', bg: '#e6f7ff', border: '#91d5ff' },
|
||||
dispatched: { label: '已派发', color: '#52c41a', textColor: '#52c41a', bg: '#f6ffed', border: '#b7eb8f' },
|
||||
processing: { label: '执行中', color: '#1890ff', textColor: '#1890ff', bg: '#e6f7ff', border: '#91d5ff' },
|
||||
completed: { label: '已完成', color: '#52c41a', textColor: '#52c41a', bg: '#f6ffed', border: '#b7eb8f' },
|
||||
suspended: { label: '已挂起', color: '#faad14', textColor: '#faad14', bg: '#fff7e6', border: '#ffe7ba' }
|
||||
// 优先级数字映射 1高 2中 3低
|
||||
const priorityConfig = {
|
||||
1: { label: '高', color: '#ff4d4f', bg: '#fff1f0', border: '#ff4d4f' },
|
||||
2: { label: '中', color: '#faad14', bg: '#fff7e6', border: '#faad14' },
|
||||
3: { label: '低', color: '#52c41a', bg: '#f6ffed', border: '#52c41a' }
|
||||
};
|
||||
|
||||
// 优先级配置
|
||||
const priorityConfig = {
|
||||
low: { label: '低', color: '#52c41a', bg: '#f6ffed' },
|
||||
medium: { label: '中', color: '#faad14', bg: '#fff7e6' },
|
||||
high: { label: '高', color: '#ff4d4f', bg: '#fff1f0' }
|
||||
// 工单状态数字映射
|
||||
const orderStatusConfig = {
|
||||
1: { label: '待处理', textColor: '#1890ff' },
|
||||
2: { label: '执行中', textColor: '#1890ff' },
|
||||
3: { label: '挂起', textColor: '#faad14' },
|
||||
4: { label: '已完成', textColor: '#52c41a' },
|
||||
5: { label: '处理中', textColor: '#722ed1' }
|
||||
};
|
||||
|
||||
// 工单类型映射
|
||||
const orderTypeConfig = {
|
||||
1: '巡检',
|
||||
2: '检修',
|
||||
3: '清洗',
|
||||
4: '维修',
|
||||
5: '运维'
|
||||
};
|
||||
|
||||
const WorkOrderPage = () => {
|
||||
const [activeTab, setActiveTab] = useState('1');
|
||||
const [selectedRowKey, setSelectedRowKey] = useState('WO20250524002');
|
||||
const [selectedRowKey, setSelectedRowKey] = useState('');
|
||||
// 接口相关状态
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [workOrderList, setWorkOrderList] = useState([]);
|
||||
const [workOrderTotal, setWorkOrderTotal] = useState(0);
|
||||
const [currentDetail, setCurrentDetail] = useState(null);
|
||||
// 弹窗表单
|
||||
const [form] = Form.useForm();
|
||||
const [editModalVisible, setEditModalVisible] = useState(false);
|
||||
const [dispatchModalVisible, setDispatchModalVisible] = useState(false);
|
||||
|
||||
// 统计数据
|
||||
// 统计数据(保留原模拟不变)
|
||||
const stats = [
|
||||
{ title: '今日新增工单', value: 18, subValue: '+3', subText: '较昨日', icon: <ClipboardList size={24} color="#1890ff" />, bg: '#e6f7ff' },
|
||||
{ title: '待处理工单', value: 12, subValue: '5', subText: '高优先级', icon: <Clock size={24} color="#ff4d4f" />, bg: '#fff1f0' },
|
||||
@@ -125,43 +82,56 @@ const WorkOrderPage = () => {
|
||||
{ title: 'AI建议生成', value: 7, unit: '单', subValue: '', subText: '今日自动生成', icon: <Cpu size={24} color="#722ed1" />, bg: '#f9f0ff' },
|
||||
];
|
||||
|
||||
// 表格列
|
||||
// 表格列【已适配后端真实字段】
|
||||
const columns = [
|
||||
{ title: '工单编号', dataIndex: 'id', key: 'id', width: 130 },
|
||||
{ title: '工单标题', dataIndex: 'title', key: 'title', width: 180, ellipsis: true },
|
||||
{ title: '来源', dataIndex: 'source', key: 'source', width: 100 },
|
||||
{ title: '类型', dataIndex: 'type', key: 'type', width: 80 },
|
||||
{ title: '工单编号', dataIndex: 'orderNo', key: 'orderNo', width: 130 },
|
||||
{ title: '工单标题', dataIndex: 'orderTitle', key: 'orderTitle', width: 180, ellipsis: true },
|
||||
{
|
||||
title: '类型',
|
||||
dataIndex: 'orderType',
|
||||
key: 'orderType',
|
||||
width: 80,
|
||||
render: (val) => orderTypeConfig[val] || '未知'
|
||||
},
|
||||
{
|
||||
title: '优先级',
|
||||
dataIndex: 'priority',
|
||||
key: 'priority',
|
||||
dataIndex: 'priorityLevel',
|
||||
key: 'priorityLevel',
|
||||
width: 80,
|
||||
render: (p) => (
|
||||
<Tag color={priorityConfig[p].bg} style={{ color: priorityConfig[p].color, border: `1px solid ${priorityConfig[p].color}`, borderRadius: 4 }}>
|
||||
{priorityConfig[p].label}
|
||||
<Tag
|
||||
style={{
|
||||
color: priorityConfig[p]?.color,
|
||||
background: priorityConfig[p]?.bg,
|
||||
border: `1px solid ${priorityConfig[p]?.border}`,
|
||||
borderRadius: 4
|
||||
}}
|
||||
>
|
||||
{priorityConfig[p]?.label}
|
||||
</Tag>
|
||||
)
|
||||
},
|
||||
{ title: '负责人', dataIndex: 'handler', key: 'handler', width: 80 },
|
||||
{ title: '截止时间', dataIndex: 'deadline', key: 'deadline', width: 150 },
|
||||
{ title: '负责人', dataIndex: 'assigneeName', key: 'assigneeName', width: 80 },
|
||||
{ title: '截止时间', dataIndex: 'deadlineTime', key: 'deadlineTime', width: 150 },
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
dataIndex: 'orderStatus',
|
||||
key: 'orderStatus',
|
||||
width: 90,
|
||||
render: (s) => (
|
||||
<span style={{ color: statusConfig[s].textColor }}>{statusConfig[s].label}</span>
|
||||
<span style={{ color: orderStatusConfig[s]?.textColor }}>{orderStatusConfig[s]?.label}</span>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 60,
|
||||
fixed: "right",
|
||||
render: () => <Button type="link" size="small">查看</Button>
|
||||
},
|
||||
];
|
||||
|
||||
// 图表数据
|
||||
// 图表模拟数据保留不变
|
||||
const pieData = [
|
||||
{ type: '待处理', value: 12 },
|
||||
{ type: '执行中', value: 9 },
|
||||
@@ -179,6 +149,116 @@ const WorkOrderPage = () => {
|
||||
{ date: '05-24', value: 11 },
|
||||
];
|
||||
|
||||
// ========== 接口请求方法 ==========
|
||||
// 获取工单列表
|
||||
const getWorkOrderList = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const res = await getWorkOrderApi();
|
||||
if (res.code == 0) {
|
||||
setWorkOrderList(res.rows || []);
|
||||
setWorkOrderTotal(res.total || 0);
|
||||
if (res.rows && res.rows.length > 0) {
|
||||
setSelectedRowKey(res.rows[0].id);
|
||||
getWorkOrderDetail(res.rows[0].id);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('获取工单列表失败');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 获取工单详情
|
||||
const getWorkOrderDetail = async (id) => {
|
||||
try {
|
||||
const res = await getWorkOrderDetailApi(id);
|
||||
if (res.code === 0) {
|
||||
setCurrentDetail(res.data);
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('获取工单详情失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 选中表格行
|
||||
const handleRowSelect = (keys) => {
|
||||
if (keys.length > 0) {
|
||||
setSelectedRowKey(keys[0]);
|
||||
getWorkOrderDetail(keys[0]);
|
||||
}
|
||||
};
|
||||
|
||||
// 打开修改工单弹窗
|
||||
const openEditModal = () => {
|
||||
if (!selectedRowKey) return message.warning('请先选择一条工单');
|
||||
form.setFieldsValue({
|
||||
title: currentDetail?.orderTitle,
|
||||
content: currentDetail?.taskDescription,
|
||||
priority: currentDetail?.priorityLevel,
|
||||
type: currentDetail?.orderType,
|
||||
remark: currentDetail?.remark
|
||||
});
|
||||
setEditModalVisible(true);
|
||||
};
|
||||
|
||||
// 打开派发工单弹窗
|
||||
const openDispatchModal = () => {
|
||||
if (!selectedRowKey) return message.warning('请先选择一条工单');
|
||||
form.setFieldsValue({
|
||||
title: currentDetail?.orderTitle,
|
||||
content: currentDetail?.taskDescription,
|
||||
priority: currentDetail?.priorityLevel,
|
||||
type: currentDetail?.orderType,
|
||||
remark: currentDetail?.remark
|
||||
});
|
||||
setDispatchModalVisible(true);
|
||||
};
|
||||
|
||||
// 提交修改工单
|
||||
const submitEdit = async (values) => {
|
||||
try {
|
||||
// 适配后端传参:id、title、content、priority、type、remark
|
||||
await updateWorkOrder({
|
||||
id: selectedRowKey,
|
||||
orderTitle: values.title,
|
||||
taskDescription: values.content,
|
||||
priorityLevel: values.priority,
|
||||
orderType: values.type,
|
||||
remark: values.remark
|
||||
});
|
||||
message.success('修改工单成功');
|
||||
setEditModalVisible(false);
|
||||
getWorkOrderList();
|
||||
} catch (error) {
|
||||
message.error('修改工单失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 提交派发工单
|
||||
const submitDispatch = async (values) => {
|
||||
try {
|
||||
await dispatchWorkOrder({
|
||||
id: selectedRowKey,
|
||||
orderTitle: values.title,
|
||||
taskDescription: values.content,
|
||||
priorityLevel: values.priority,
|
||||
orderType: values.type,
|
||||
remark: values.remark
|
||||
});
|
||||
message.success('派发工单成功');
|
||||
setDispatchModalVisible(false);
|
||||
getWorkOrderList();
|
||||
} catch (error) {
|
||||
message.error('派发工单失败');
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getWorkOrderList();
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div style={{ padding: '16px 24px', background: '#f0f2f5', minHeight: '100vh' }}>
|
||||
{/* 顶部标题和页签 */}
|
||||
@@ -287,25 +367,26 @@ const WorkOrderPage = () => {
|
||||
<Col span={15}>
|
||||
<Card
|
||||
bordered={false}
|
||||
title={<div style={{ display: 'flex', alignItems: 'center' }}><Text strong style={{ fontSize: 16 }}>工单列表</Text><Text type="secondary" style={{ fontSize: 12, marginLeft: 8 }}>(共 147 条)</Text></div>}
|
||||
title={<div style={{ display: 'flex', alignItems: 'center' }}><Text strong style={{ fontSize: 16 }}>工单列表</Text><Text type="secondary" style={{ fontSize: 12, marginLeft: 8 }}>(共 {workOrderTotal} 条)</Text></div>}
|
||||
bodyStyle={{ padding: 0 }}
|
||||
style={{ borderRadius: 8, marginBottom: 16 }}
|
||||
>
|
||||
<Table
|
||||
dataSource={workOrderData}
|
||||
dataSource={workOrderList}
|
||||
columns={columns}
|
||||
pagination={false}
|
||||
loading={loading}
|
||||
size="middle"
|
||||
rowKey="id"
|
||||
scroll={{ x: 'max-content' }}
|
||||
rowSelection={{
|
||||
type: 'radio',
|
||||
selectedRowKeys: [selectedRowKey],
|
||||
onChange: (keys) => setSelectedRowKey(keys[0] as string)
|
||||
onChange: handleRowSelect
|
||||
}}
|
||||
/>
|
||||
<div style={{ padding: '16px', textAlign: 'right' }}>
|
||||
<Pagination size="small" total={147} showSizeChanger showQuickJumper />
|
||||
<Pagination size="small" total={workOrderTotal} showSizeChanger showQuickJumper />
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
@@ -335,7 +416,7 @@ const WorkOrderPage = () => {
|
||||
/>
|
||||
<div style={{ position: 'absolute', top: '42%', left: '30%', textAlign: 'center', transform: 'translate(-50%, -50%)' }}>
|
||||
<div style={{ fontSize: 14, color: '#8c8c8c' }}>总数</div>
|
||||
<div style={{ fontSize: 24, fontWeight: 'bold' }}>147</div>
|
||||
<div style={{ fontSize: 24, fontWeight: 'bold' }}>{workOrderTotal}</div>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
@@ -390,27 +471,40 @@ const WorkOrderPage = () => {
|
||||
>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 16 }}>
|
||||
<Text strong style={{ fontSize: 16 }}>工单详情</Text>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>工单编号: WO20250524002</Text>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>工单编号: {currentDetail?.orderNo || '--'}</Text>
|
||||
</div>
|
||||
|
||||
<div style={{ marginBottom: 20 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 8 }}>
|
||||
<Title level={4} style={{ margin: '0 12px 0 0' }}>区块 B-12 热斑复检</Title>
|
||||
<Tag color="#fff1f0" style={{ color: '#ff4d4f', border: '1px solid #ff4d4f' }}>高优先级</Tag>
|
||||
<Title level={4} style={{ margin: '0 12px 0 0' }}>{currentDetail?.orderTitle || '暂无标题'}</Title>
|
||||
{currentDetail?.priorityLevel && (
|
||||
<Tag
|
||||
style={{
|
||||
color: priorityConfig[currentDetail.priorityLevel]?.color,
|
||||
background: priorityConfig[currentDetail.priorityLevel]?.bg,
|
||||
border: `1px solid ${priorityConfig[currentDetail.priorityLevel]?.border}`
|
||||
}}
|
||||
>
|
||||
{priorityConfig[currentDetail.priorityLevel].label}优先级
|
||||
</Tag>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Row gutter={[0, 12]}>
|
||||
<Col span={12}><Text type="secondary">来源:</Text><Text>无人机巡检</Text></Col>
|
||||
<Col span={12}><Text type="secondary">工单类型:</Text><Text>巡检</Text></Col>
|
||||
<Col span={12}><Text type="secondary">负责人:</Text><Text>王工</Text></Col>
|
||||
<Col span={12}><Text type="secondary">协同人员:</Text><Text>无人机 A01 / 张运维</Text></Col>
|
||||
<Col span={24}><Text type="secondary">计划时间:</Text><Text>2025-05-24 13:30 - 15:00</Text></Col>
|
||||
<Col span={12}><Text type="secondary">关联设备:</Text><Text style={{ color: '#1890ff' }}>UAV-A01</Text></Col>
|
||||
<Col span={12}><Text type="secondary">关联区域:</Text><Text>B-12</Text></Col>
|
||||
<Col span={24}><Text type="secondary">当前状态:</Text><Tag color="blue" style={{ borderRadius: 10 }}>执行中</Tag></Col>
|
||||
<Col span={12}><Text type="secondary">来源:</Text><Text>{currentDetail?.sourceType || '--'}</Text></Col>
|
||||
<Col span={12}><Text type="secondary">工单类型:</Text><Text>{orderTypeConfig[currentDetail?.orderType] || '--'}</Text></Col>
|
||||
<Col span={12}><Text type="secondary">负责人:</Text><Text>{currentDetail?.assigneeName || '--'}</Text></Col>
|
||||
<Col span={12}><Text type="secondary">协同人员:</Text><Text>{currentDetail?.collaboratorNames || '无'}</Text></Col>
|
||||
<Col span={24}><Text type="secondary">计划时间:</Text><Text>{currentDetail?.planStartTime ? `${currentDetail.planStartTime} ~ ${currentDetail.planEndTime}` : '--'}</Text></Col>
|
||||
<Col span={12}><Text type="secondary">关联设备:</Text><Text style={{ color: '#1890ff' }}>{currentDetail?.deviceName || '无'}</Text></Col>
|
||||
<Col span={12}><Text type="secondary">关联电站:</Text><Text>{currentDetail?.siteName || '无'}</Text></Col>
|
||||
<Col span={24}>
|
||||
<Text type="secondary">当前状态:</Text>
|
||||
<Tag color="blue" style={{ borderRadius: 10 }}>{orderStatusConfig[currentDetail?.orderStatus]?.label || '--'}</Tag>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
<Text type="secondary">任务描述:</Text>
|
||||
<Text>对 AI 识别热斑区域进行复检与红外复核,确认是否需要更换组件。</Text>
|
||||
<Text>{currentDetail?.taskDescription || '暂无描述'}</Text>
|
||||
</Col>
|
||||
</Row>
|
||||
</div>
|
||||
@@ -440,8 +534,8 @@ const WorkOrderPage = () => {
|
||||
</div>
|
||||
|
||||
<Row gutter={8}>
|
||||
<Col span={6}><Button type="primary" block>派发工单</Button></Col>
|
||||
<Col span={6}><Button icon={<ReloadOutlined />} block>转派</Button></Col>
|
||||
<Col span={6}><Button type="primary" block onClick={openDispatchModal}>派发工单</Button></Col>
|
||||
<Col span={6}><Button icon={<ReloadOutlined />} block onClick={openEditModal}>转派</Button></Col>
|
||||
<Col span={6}><Button icon={<PauseOutlined />} danger ghost block>挂起</Button></Col>
|
||||
<Col span={6}><Button icon={<CheckOutlined />} style={{ background: '#52c41a', color: '#fff', border: 'none' }} block>完成工单</Button></Col>
|
||||
</Row>
|
||||
@@ -458,21 +552,21 @@ const WorkOrderPage = () => {
|
||||
<div style={{ background: '#f9f0ff', padding: '12px 8px', borderRadius: 8, textAlign: 'center' }}>
|
||||
<RobotOutlined style={{ fontSize: 20, color: '#722ed1', marginBottom: 8 }} />
|
||||
<div style={{ fontSize: 12 }}>建议携带</div>
|
||||
<div style={{ fontSize: 12, fontWeight: 'bold' }}>红外热像设备</div>
|
||||
<div style={{ fontSize: 12, fontWeight: 'bold' }}>{currentDetail?.requiredEquipment || '无'}</div>
|
||||
</div>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<div style={{ background: '#f6ffed', padding: '12px 8px', borderRadius: 8, textAlign: 'center' }}>
|
||||
<ThunderboltOutlined style={{ fontSize: 20, color: '#52c41a', marginBottom: 8 }} />
|
||||
<div style={{ fontSize: 12 }}>优先复检组件</div>
|
||||
<div style={{ fontSize: 10, fontWeight: 'bold' }}>B-12-03 / B-12-05</div>
|
||||
<div style={{ fontSize: 12 }}>AI建议方案</div>
|
||||
<div style={{ fontSize: 10, fontWeight: 'bold' }}>{currentDetail?.aiSuggestion || '无'}</div>
|
||||
</div>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<div style={{ background: '#fff7e6', padding: '12px 8px', borderRadius: 8, textAlign: 'center' }}>
|
||||
<RiseOutlined style={{ fontSize: 20, color: '#faad14', marginBottom: 8 }} />
|
||||
<div style={{ fontSize: 12 }}>预计影响发电</div>
|
||||
<div style={{ fontSize: 12, fontWeight: 'bold' }}>2.1%</div>
|
||||
<div style={{ fontSize: 12 }}>预计发电影响</div>
|
||||
<div style={{ fontSize: 12, fontWeight: 'bold' }}>{currentDetail?.estimatedImpact ?? 0}%</div>
|
||||
</div>
|
||||
</Col>
|
||||
</Row>
|
||||
@@ -518,6 +612,64 @@ const WorkOrderPage = () => {
|
||||
</Row>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{/* 修改工单弹窗 */}
|
||||
<Modal title="修改工单" open={editModalVisible} onCancel={() => setEditModalVisible(false)} footer={null} width={520}>
|
||||
<Form form={form} layout="vertical" onFinish={submitEdit}>
|
||||
<FormItem name="title" label="工单标题">
|
||||
<Input placeholder="请输入工单标题" />
|
||||
</FormItem>
|
||||
<FormItem name="content" label="工单内容">
|
||||
<Input.TextArea rows={4} placeholder="请输入工单内容" />
|
||||
</FormItem>
|
||||
<FormItem name="priority" label="优先级">
|
||||
<Select placeholder="请选择优先级">
|
||||
<Option value={1}>高</Option>
|
||||
<Option value={2}>中</Option>
|
||||
<Option value={3}>低</Option>
|
||||
</Select>
|
||||
</FormItem>
|
||||
<FormItem name="type" label="工单类型">
|
||||
<Input placeholder="请输入工单类型" />
|
||||
</FormItem>
|
||||
<FormItem name="remark" label="备注">
|
||||
<Input.TextArea rows={2} placeholder="请输入备注" />
|
||||
</FormItem>
|
||||
<FormItem style={{ textAlign: 'right', marginBottom: 0 }}>
|
||||
<Button onClick={() => setEditModalVisible(false)}>取消</Button>
|
||||
<Button type="primary" htmlType="submit" style={{ marginLeft: 8 }}>确认修改</Button>
|
||||
</FormItem>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
{/* 派发工单弹窗 */}
|
||||
<Modal title="派发工单" open={dispatchModalVisible} onCancel={() => setDispatchModalVisible(false)} footer={null} width={520}>
|
||||
<Form form={form} layout="vertical" onFinish={submitDispatch}>
|
||||
<FormItem name="title" label="工单标题">
|
||||
<Input placeholder="请输入工单标题" />
|
||||
</FormItem>
|
||||
<FormItem name="content" label="工单内容">
|
||||
<Input.TextArea rows={4} placeholder="请输入工单内容" />
|
||||
</FormItem>
|
||||
<FormItem name="priority" label="优先级">
|
||||
<Select placeholder="请选择优先级">
|
||||
<Option value={1}>高</Option>
|
||||
<Option value={2}>中</Option>
|
||||
<Option value={3}>低</Option>
|
||||
</Select>
|
||||
</FormItem>
|
||||
<FormItem name="type" label="工单类型">
|
||||
<Input placeholder="请输入工单类型" />
|
||||
</FormItem>
|
||||
<FormItem name="remark" label="备注">
|
||||
<Input.TextArea rows={2} placeholder="请输入备注" />
|
||||
</FormItem>
|
||||
<FormItem style={{ textAlign: 'right', marginBottom: 0 }}>
|
||||
<Button onClick={() => setDispatchModalVisible(false)}>取消</Button>
|
||||
<Button type="primary" htmlType="submit" style={{ marginLeft: 8 }}>确认派发</Button>
|
||||
</FormItem>
|
||||
</Form>
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user