小细节优化和派单逻辑
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
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, Popconfirm, Image
|
||||
Statistic, Modal, message, Empty, Drawer, Descriptions, Timeline, Divider, Form, Tabs, Progress, Badge, DatePicker, Pagination, Popconfirm, Image,
|
||||
Tooltip
|
||||
} from 'antd';
|
||||
import {
|
||||
CheckOutlined, ClockCircleOutlined, ControlOutlined,
|
||||
@@ -36,7 +37,8 @@ import {
|
||||
startWorkOrder,
|
||||
completeWorkOrder,
|
||||
suspendWorkOrder,
|
||||
deleteWorkOrder
|
||||
deleteWorkOrder,
|
||||
dispatchWorkOrder
|
||||
} from '../api/workOrder';
|
||||
import { getSiteDevice, getSiteUAVList } from '../api/device';
|
||||
import { UniversalLineChart } from '../components/recharts';
|
||||
@@ -45,7 +47,7 @@ import { orderTypeConfig, sourceTypeMap } from '../constants';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { RootState } from '../store';
|
||||
import { getUser } from '../api/user';
|
||||
import utils, { errorLevelOptions, getWorkOrderTypeText, levelColorMap, workOrderTypeOptions } from '../lib/utils';
|
||||
import utils, { errorLevelOptions, getWorkOrderTypeText, levelColorMap, levelNum2Text, levelText2Num, workOrderTypeOptions } from '../lib/utils';
|
||||
import { getAlarmList } from '../api/alarmApi';
|
||||
|
||||
const { Option } = Select;
|
||||
@@ -80,8 +82,6 @@ const WorkOrderPage = () => {
|
||||
const [workOrderList, setWorkOrderList] = useState([]);
|
||||
const [workOrderTotal, setWorkOrderTotal] = useState(0);
|
||||
const [currentDetail, setCurrentDetail] = useState(null);
|
||||
const [userList, setUserList] = useState([]);
|
||||
const [deviceList, setDeviceList] = useState([]);
|
||||
const [orderStat, setOrderStat] = useState({
|
||||
todayAdd: 0, // 今日新增工单
|
||||
pending: 0, // 待处理总数
|
||||
@@ -97,6 +97,9 @@ const WorkOrderPage = () => {
|
||||
|
||||
// 从 redux 获取用户信息
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
console.log(userInfo, 434234);
|
||||
|
||||
const isShowDispatch = userInfo?.roleId !== 26; //普通用户
|
||||
const { stationId } = useSelector((state: RootState) => state.station);
|
||||
const [deviceAll, setDevicesAll] = useState([]);
|
||||
|
||||
@@ -145,6 +148,8 @@ const WorkOrderPage = () => {
|
||||
const [alarmChartData, setAlarmChartData] = useState([]);
|
||||
const [latestThreeAlarm, setLatestThreeAlarm] = useState([]);
|
||||
const [alarmAllModalVisible, setAlarmAllModalVisible] = useState(false);
|
||||
const [userList, setUserList] = useState([]);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -195,6 +200,21 @@ const WorkOrderPage = () => {
|
||||
const nextScheduleDay = () => {
|
||||
setScheduleDate(dayjs(scheduleDate).add(1, 'day').format('YYYY-MM-DD'));
|
||||
};
|
||||
const getUserData = () => {
|
||||
const params = {
|
||||
pageNum: 1,
|
||||
pageSize: 99999,
|
||||
orgId: userInfo?.orgId,
|
||||
siteId: userInfo?.siteId,
|
||||
};
|
||||
getUser(params).then(res => {
|
||||
if (res.code === 200) {
|
||||
setUserList(res.rows || []);
|
||||
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
// 获取工单配色(优先级)
|
||||
@@ -230,7 +250,7 @@ const WorkOrderPage = () => {
|
||||
// 今日新增
|
||||
if (createDay === today) todayAdd++;
|
||||
// 本月已完成
|
||||
if (item.orderStatus === 4 && createDay >= monthStart) finishedMonth++;
|
||||
if (item.orderStatus === 3 && createDay >= monthStart) finishedMonth++;
|
||||
// AI生成工单 sourceType=7 告警自动生成
|
||||
if (item.sourceType === 7) aiCreate++;
|
||||
|
||||
@@ -540,11 +560,18 @@ const WorkOrderPage = () => {
|
||||
});
|
||||
setCompleteModalVisible(true);
|
||||
};
|
||||
const getRelatedAlarmInfo = (alarmId) => {
|
||||
if (!alarmId || !weekAlarmList?.length) return null;
|
||||
// 匹配规则:工单alarmId 对应告警 alarmNo,按需改成 alarm.id
|
||||
const alarm = weekAlarmList.find(item => String(item.id) == String(alarmId));
|
||||
return alarm?.alarmContent || null;
|
||||
};
|
||||
|
||||
// 提交完成工单(参数完全对齐你的JSON)
|
||||
const submitComplete = async (values) => {
|
||||
try {
|
||||
const now = dayjs().format('YYYY-MM-DDTHH:mm:ss');
|
||||
// 1. 组装后端需要的 IOTWorkOrder JSON 对象
|
||||
const now = dayjs().format('YYYY-MM-DD HH:mm:ss');
|
||||
// 1. 组装后端需要的 IOTWorkOrder JSON 对象
|
||||
const workOrderObj = {
|
||||
...currentDetail,
|
||||
@@ -557,6 +584,8 @@ const WorkOrderPage = () => {
|
||||
handleRemark: values.handleRemark,
|
||||
};
|
||||
|
||||
console.log('workOrderObj', workOrderObj);
|
||||
|
||||
// 2. 新建 FormData,适配 @RequestPart 混合参数
|
||||
const formData = new FormData();
|
||||
// workOrder 字段:转JSON字符串
|
||||
@@ -611,6 +640,7 @@ const WorkOrderPage = () => {
|
||||
// 打开修改工单弹窗
|
||||
const openEditModal = () => {
|
||||
if (!selectedRowKey) return messageApi.warning('请先选择一条工单');
|
||||
const levelText = levelNum2Text[currentDetail?.priorityLevel]; //数字转字符串
|
||||
form.setFieldsValue({
|
||||
orderTitle: currentDetail?.orderTitle,
|
||||
orderType: currentDetail?.orderType,
|
||||
@@ -648,6 +678,7 @@ const WorkOrderPage = () => {
|
||||
orderTitle: values.orderTitle,
|
||||
orderType: values.orderType,
|
||||
priorityLevel: values.priorityLevel,
|
||||
//priorityLevel: levelText2Num[values.priorityLevel],
|
||||
taskDescription: values.taskDescription,
|
||||
};
|
||||
await updateWorkOrder(params);
|
||||
@@ -731,10 +762,19 @@ const WorkOrderPage = () => {
|
||||
|
||||
useEffect(() => {
|
||||
fetchAllData();
|
||||
getWorkOrderList();
|
||||
fetchWeekAlarmData(); // 新增加载7天告警
|
||||
const initQuery = async () => {
|
||||
const values = queryForm.getFieldsValue();
|
||||
await getWorkOrderList(values);
|
||||
};
|
||||
initQuery();
|
||||
}, [stationId]);
|
||||
|
||||
useEffect(() => {
|
||||
getUserData();
|
||||
|
||||
}, []);
|
||||
|
||||
const cardStyle = {
|
||||
borderRadius: 12,
|
||||
border: '1px solid #f0f0f0',
|
||||
@@ -771,8 +811,7 @@ const WorkOrderPage = () => {
|
||||
</Tag>
|
||||
)
|
||||
},
|
||||
{ title: '设备名称', dataIndex: 'deviceName', key: 'deviceName', width: 160, ellipsis: true },
|
||||
{ title: '站点', dataIndex: 'siteName', key: 'siteName', width: 130 },
|
||||
{ title: '设备', dataIndex: 'deviceId', key: 'deviceId', width: 160, ellipsis: true },
|
||||
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime', width: 160 },
|
||||
{
|
||||
title: '状态',
|
||||
@@ -832,8 +871,7 @@ const WorkOrderPage = () => {
|
||||
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 8 }}>
|
||||
<Title level={4} style={{ margin: '0 32px 0 0' }}>工单任务管理</Title>
|
||||
<Tabs activeKey={activeTab} onChange={setActiveTab} items={[
|
||||
{ key: '1', label: '工单总览' }, { key: '2', label: '待处理工单' }, { key: '3', label: '执行中' },
|
||||
{ key: '4', label: '已完成' }, { key: '5', label: '工单模板' },
|
||||
{ key: '1', label: '工单总览' },
|
||||
]} tabBarStyle={{ marginBottom: 0 }} />
|
||||
</div>
|
||||
|
||||
@@ -867,7 +905,9 @@ const WorkOrderPage = () => {
|
||||
|
||||
{/* 筛选栏 */}
|
||||
<Card bordered={false} bodyStyle={{ padding: '8px 16px 0px 16px' }} style={{ ...cardStyle, marginBottom: 8 }}>
|
||||
<Form form={queryForm} layout="inline">
|
||||
<Form form={queryForm} layout="inline" initialValues={{
|
||||
orderStatus: 1
|
||||
}}>
|
||||
<Form.Item name="orderType" label="工单类型">
|
||||
<Select style={{ width: 120 }} size="small" options={workOrderTypeOptions} allowClear showSearch optionFilterProp="label" filterOption={(input, option) => option.label.toLowerCase().includes(input.toLowerCase())} />
|
||||
</Form.Item>
|
||||
@@ -1056,9 +1096,19 @@ const WorkOrderPage = () => {
|
||||
zIndex: 2
|
||||
}}
|
||||
>
|
||||
<b style={{ display: 'block', whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }}>
|
||||
{order.orderTitle}
|
||||
</b>
|
||||
<Tooltip title={order.orderTitle}>
|
||||
<b
|
||||
style={{
|
||||
display: 'block',
|
||||
whiteSpace: "nowrap",
|
||||
overflow: "hidden",
|
||||
textOverflow: "ellipsis"
|
||||
}}
|
||||
>
|
||||
{order.orderTitle}
|
||||
</b>
|
||||
</Tooltip>
|
||||
|
||||
<span style={{ fontSize: 9 }}>
|
||||
{dayjs(order.planStartTime).format('HH:mm')}
|
||||
</span>
|
||||
@@ -1171,7 +1221,8 @@ const WorkOrderPage = () => {
|
||||
<Col span={24}>
|
||||
<span style={{ fontSize: 12 }}>任务描述:</span>
|
||||
<div style={{ fontSize: 12, color: '#4E5969', marginTop: 4, lineHeight: 1.6 }}>
|
||||
{currentDetail?.taskDescription || '暂无描述'}
|
||||
{getRelatedAlarmInfo(currentDetail?.alarmId)}
|
||||
|
||||
</div>
|
||||
</Col>
|
||||
|
||||
@@ -1335,8 +1386,8 @@ const WorkOrderPage = () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Row gutter={12}>
|
||||
<Col span={6}>
|
||||
<Row style={{ display: 'flex', gap: 12 }}>
|
||||
<div style={{ flex: 1 }}>
|
||||
<Button
|
||||
type="primary"
|
||||
block
|
||||
@@ -1346,16 +1397,39 @@ const WorkOrderPage = () => {
|
||||
>
|
||||
执行工单
|
||||
</Button>
|
||||
</Col>
|
||||
<Col span={6}><Button icon={<EditOutlined />} block onClick={openEditModal} style={{ borderRadius: 8, height: 36, fontWeight: 600 }}>修改</Button></Col>
|
||||
<Col span={6}><Popconfirm title="确定挂起?" onConfirm={handleSuspend}><Button icon={<PauseOutlined />} danger ghost block style={{ borderRadius: 8, height: 36, fontWeight: 600 }}>挂起</Button></Popconfirm></Col>
|
||||
<Col span={6}><Button
|
||||
icon={<CheckCircleOutlined />}
|
||||
style={{ background: '#00B42A', color: '#fff', border: 'none', borderRadius: 8, height: 36, fontWeight: 600 }}
|
||||
block
|
||||
onClick={openCompleteModal}
|
||||
>完成</Button></Col>
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<Button icon={<EditOutlined />} block onClick={openEditModal} style={{ borderRadius: 8, height: 36, fontWeight: 600 }}>修改</Button>
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<Popconfirm title="确定挂起?" onConfirm={handleSuspend}>
|
||||
<Button icon={<PauseOutlined />} danger ghost block style={{ borderRadius: 8, height: 36, fontWeight: 600 }}>挂起</Button>
|
||||
</Popconfirm>
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<Button
|
||||
icon={<CheckCircleOutlined />}
|
||||
style={{ background: '#00B42A', color: '#fff', border: 'none', borderRadius: 8, height: 36, fontWeight: 600 }}
|
||||
block
|
||||
onClick={openCompleteModal}
|
||||
>完成</Button>
|
||||
</div>
|
||||
{isShowDispatch && (
|
||||
<div style={{ flex: 1 }}>
|
||||
<Button
|
||||
type="primary"
|
||||
block
|
||||
onClick={openExecuteModal}
|
||||
style={{ borderRadius: 8, height: 36, fontWeight: 600 }}
|
||||
icon={<PlayCircleFilled />}
|
||||
>
|
||||
派单
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</Row>
|
||||
|
||||
|
||||
</Card>
|
||||
|
||||
<Card bordered={false} title={<Text strong style={{ fontSize: 14, color: '#1D2129' }}>AI 建议与关联信息</Text>}
|
||||
@@ -1491,9 +1565,12 @@ const WorkOrderPage = () => {
|
||||
|
||||
</FormItem>
|
||||
<FormItem name="priorityLevel" label="优先级" rules={[{ required: true, message: '请选择优先级' }]}>
|
||||
<Select placeholder="请选择优先级">
|
||||
<Option value={1}>高</Option><Option value={2}>中</Option><Option value={3}>低</Option>
|
||||
</Select>
|
||||
{/*<Select placeholder="请选择优先级">
|
||||
<Option value={1}>ERROR(高)</Option><Option value={2}>WARNING</Option><Option value={3}>INFO</Option>
|
||||
</Select>*/}
|
||||
<Form.Item name="priorityLevel" label="优先级">
|
||||
<Select options={errorLevelOptions} allowClear />
|
||||
</Form.Item>
|
||||
</FormItem>
|
||||
<FormItem name="taskDescription" label="任务描述" rules={[{ required: true, message: '请输入任务描述' }]}>
|
||||
<Input.TextArea rows={4} placeholder="请输入任务描述" />
|
||||
|
||||
Reference in New Issue
Block a user