样式和工单列表接口
This commit is contained in:
@@ -20,6 +20,7 @@ import {
|
||||
exportAlarm
|
||||
} from '../../api/alarmApi.js';
|
||||
import { UniversalBarChart, UniversalLineChart, UniversalPieChart } from '../recharts.jsx';
|
||||
import { addWorkOrder } from '@/api/workOrder.js';
|
||||
|
||||
const { RangePicker } = DatePicker;
|
||||
const { Text } = Typography;
|
||||
@@ -70,6 +71,8 @@ export default function AlarmCenterPage() {
|
||||
const [total, setTotal] = useState(0);
|
||||
const [pageNum, setPageNum] = useState(1);
|
||||
const [pageSize] = useState(10);
|
||||
const [messageApi, contextHolder] = message.useMessage();
|
||||
|
||||
|
||||
// 查询条件
|
||||
const [queryParams, setQueryParams] = useState({
|
||||
@@ -103,7 +106,7 @@ export default function AlarmCenterPage() {
|
||||
setTotal(res.total || 0);
|
||||
}
|
||||
} catch (err) {
|
||||
message.error('加载失败');
|
||||
messageApi.error('加载失败');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -134,7 +137,7 @@ export default function AlarmCenterPage() {
|
||||
setDrawerVisible(true);
|
||||
}
|
||||
} catch (err) {
|
||||
message.error('加载详情失败');
|
||||
messageApi.error('加载详情失败');
|
||||
} finally {
|
||||
setDetailLoading(false);
|
||||
}
|
||||
@@ -148,12 +151,12 @@ export default function AlarmCenterPage() {
|
||||
handleStatus: values.handleStatus,
|
||||
handleRemark: values.handleRemark || '已处理'
|
||||
});
|
||||
message.success('处理成功');
|
||||
messageApi.success('处理成功');
|
||||
setDrawerVisible(false);
|
||||
fetchList();
|
||||
fetchStat();
|
||||
} catch (err) {
|
||||
message.error('处理失败');
|
||||
messageApi.error('处理失败');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -273,9 +276,63 @@ export default function AlarmCenterPage() {
|
||||
color: '#1890FF',
|
||||
},
|
||||
].filter(i => i.value > 0);
|
||||
// 生成工单
|
||||
const handleaddOrder = async () => {
|
||||
if (!currentAlarm) {
|
||||
messageApi.warning('无告警信息,无法生成工单');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 组装接口需要的所有参数(你给的格式)
|
||||
const params = {
|
||||
id: '',
|
||||
orderNo: '',
|
||||
orderTitle: currentAlarm.alarmTitle || '告警生成工单',
|
||||
sourceType: 7, // 来源 7=告警
|
||||
orderType: 5, // 类型 5=运维
|
||||
priorityLevel: currentAlarm.alarmLevel === 1 ? 1 : 2, // 严重=高,其他=中
|
||||
deviceId: currentAlarm.deviceId || '',
|
||||
deviceName: currentAlarm.deviceName || '',
|
||||
deviceType: '', // 没有就传空
|
||||
siteId: '',
|
||||
siteName: '',
|
||||
orgId: '',
|
||||
assigneeId: '',
|
||||
assigneeName: '',
|
||||
collaboratorIds: '',
|
||||
collaboratorNames: '',
|
||||
planStartTime: '',
|
||||
planEndTime: '',
|
||||
deadlineTime: '',
|
||||
actualStartTime: '',
|
||||
actualEndTime: '',
|
||||
orderStatus: 1, // 1-待处理
|
||||
alarmId: currentAlarm.id || '', // 关联告警ID
|
||||
alarmNo: currentAlarm.alarmNo || '', // 关联告警编号
|
||||
taskDescription: currentAlarm.alarmContent || '', // 任务描述=告警内容
|
||||
aiSuggestion: currentAlarm.rootCause || '', // AI建议
|
||||
requiredEquipment: '',
|
||||
estimatedImpact: '',
|
||||
handleResult: '',
|
||||
handleRemark: ''
|
||||
};
|
||||
|
||||
// 调用新增接口
|
||||
const res = await addWorkOrder(params);
|
||||
if (res.code === 0 || res.code === 200) {
|
||||
messageApi.success('工单生成成功');
|
||||
} else {
|
||||
messageApi.error(res.msg || '工单生成失败');
|
||||
}
|
||||
} catch (error) {
|
||||
messageApi.error('接口调用失败');
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
return (
|
||||
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: '16px 24px' }}>
|
||||
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: '0' }}>
|
||||
{contextHolder}
|
||||
|
||||
{/* 查询栏 */}
|
||||
<Row gutter={8} style={{ marginBottom: 8 }}>
|
||||
@@ -639,6 +696,13 @@ export default function AlarmCenterPage() {
|
||||
{/* 推荐处理措施 */}
|
||||
<Card size="small" title="推荐处理措施" style={{ marginBottom: 16 }}>
|
||||
<div style={{ color: '#333' }}>{currentAlarm.handleSuggestion || '-'}</div>
|
||||
<div className="flex justify-between">
|
||||
<div>
|
||||
|
||||
</div>
|
||||
<Button type="primary" onClick={handleaddOrder}>生成工单</Button>
|
||||
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
{/* 处理操作 */}
|
||||
|
||||
Reference in New Issue
Block a user