新增工单加上计划完成时间 为了工单中任务分布 还有 增益系数完成
This commit is contained in:
@@ -48,7 +48,6 @@ const levelColorMap = {
|
||||
INFO: '#1890FF', // 信息 蓝
|
||||
};
|
||||
|
||||
|
||||
// 快速根据 value 获取 label
|
||||
const getLevelLabel = (val) => {
|
||||
const item = errorLevelOptions.find(opt => opt.value === val);
|
||||
@@ -63,7 +62,6 @@ const getLevelLabel = (val) => {
|
||||
const AlarmLevelTag = ({ level, size = 'small' }) => {
|
||||
const color = levelColorMap[level] || '#86909C';
|
||||
const text = getLevelLabel(level);
|
||||
|
||||
// 详情大标签
|
||||
if (size === 'large') {
|
||||
return (
|
||||
@@ -84,7 +82,6 @@ const AlarmLevelTag = ({ level, size = 'small' }) => {
|
||||
</Tag>
|
||||
);
|
||||
}
|
||||
|
||||
// 表格小标签
|
||||
return (
|
||||
<Tag
|
||||
@@ -124,6 +121,9 @@ export default function AlarmCenterPage() {
|
||||
const [editModalVisible, setEditModalVisible] = useState(false);
|
||||
const [editForm] = Form.useForm();
|
||||
|
||||
// ========== 新增:工单弹窗状态 & 表单 ==========
|
||||
const [createOrderModalVisible, setCreateOrderModalVisible] = useState(false);
|
||||
const [orderForm] = Form.useForm();
|
||||
|
||||
// 查询条件
|
||||
const [queryParams, setQueryParams] = useState({
|
||||
@@ -254,7 +254,6 @@ export default function AlarmCenterPage() {
|
||||
useEffect(() => {
|
||||
fetchList();
|
||||
|
||||
|
||||
}, [pageNum, stationId]);
|
||||
useEffect(() => {
|
||||
fetchTodayAndYesterdayStat();
|
||||
@@ -371,7 +370,6 @@ export default function AlarmCenterPage() {
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
const pieData = [
|
||||
{
|
||||
name: '错误',
|
||||
@@ -431,52 +429,60 @@ export default function AlarmCenterPage() {
|
||||
console.log('派发工单', currentAlarm);
|
||||
};
|
||||
|
||||
|
||||
// 生成工单
|
||||
const handleaddOrder = async () => {
|
||||
// ========== 修改:点击生成工单只打开弹窗,不直接请求接口 ==========
|
||||
const handleaddOrder = () => {
|
||||
if (!currentAlarm) {
|
||||
messageApi.warning('无告警信息,无法生成工单');
|
||||
return;
|
||||
}
|
||||
// 预填充表单
|
||||
orderForm.setFieldsValue({
|
||||
orderTitle: currentAlarm.alarmTitle || '告警生成工单',
|
||||
planStartTime: null
|
||||
});
|
||||
setCreateOrderModalVisible(true);
|
||||
};
|
||||
|
||||
// ========== 新增:弹窗提交工单函数 ==========
|
||||
const submitCreateOrder = async (values) => {
|
||||
try {
|
||||
// 组装接口需要的所有参数(你给的格式)
|
||||
const params = {
|
||||
id: '',
|
||||
orderNo: '',
|
||||
orderTitle: currentAlarm.alarmTitle || '告警生成工单',
|
||||
orderTitle: values.orderTitle,
|
||||
sourceType: 7, // 来源 7=告警
|
||||
orderType: 5, // 类型 5=运维
|
||||
priorityLevel: currentAlarm.alarmLevel === 1 ? 1 : 2, // 严重=高,其他=中
|
||||
priorityLevel: currentAlarm.alarmLevel === 'ERROR' ? 1 : 2, // 修复:等级是字符串,不是数字1
|
||||
deviceId: currentAlarm.deviceId || '',
|
||||
deviceName: currentAlarm.deviceName || '',
|
||||
deviceType: currentAlarm.deviceType, // 没有就传空
|
||||
deviceType: currentAlarm.deviceType,
|
||||
siteId: stationId,
|
||||
orgId: userInfo?.orgId || '',
|
||||
assigneeId: '',
|
||||
assigneeName: '',
|
||||
collaboratorIds: '',
|
||||
collaboratorNames: '',
|
||||
planStartTime: '',
|
||||
planStartTime: values.planStartTime ? dayjs(values.planStartTime).format('YYYY-MM-DD HH:mm:ss') : '',
|
||||
planEndTime: '',
|
||||
deadlineTime: '',
|
||||
actualStartTime: '',
|
||||
actualEndTime: '',
|
||||
orderStatus: 1, // 1-待处理
|
||||
alarmId: currentAlarm.id || '', // 关联告警ID
|
||||
alarmNo: currentAlarm.alarmNo || '', // 关联告警编号
|
||||
taskDescription: currentAlarm.alarmContent || '', // 任务描述=告警内容
|
||||
aiSuggestion: currentAlarm.rootCause || '', // AI建议
|
||||
alarmId: currentAlarm.id || '',
|
||||
alarmNo: currentAlarm.alarmNo || '',
|
||||
taskDescription: values.taskDescription,
|
||||
aiSuggestion: currentAlarm.rootCause || '',
|
||||
requiredEquipment: '',
|
||||
estimatedImpact: '',
|
||||
handleResult: '',
|
||||
handleRemark: ''
|
||||
};
|
||||
|
||||
// 调用新增接口
|
||||
const res = await addWorkOrder(params);
|
||||
if (res.code === 0 || res.code === 200) {
|
||||
messageApi.success('工单生成成功');
|
||||
setCreateOrderModalVisible(false);
|
||||
orderForm.resetFields();
|
||||
} else {
|
||||
messageApi.error(res.msg || '工单生成失败');
|
||||
}
|
||||
@@ -485,6 +491,7 @@ export default function AlarmCenterPage() {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: '0' }}>
|
||||
{contextHolder}
|
||||
@@ -516,10 +523,10 @@ export default function AlarmCenterPage() {
|
||||
},
|
||||
{
|
||||
title: '严重告警',
|
||||
value: todayData.levelStats?.[1] || 0,
|
||||
value: todayData.levelStats?.["ERROR"] || 0,
|
||||
trend: (() => {
|
||||
const now = todayData.levelStats?.["ERROR"] ?? 0;
|
||||
const last = yesterdayData.levelStats?.[1] ?? 0;
|
||||
const last = yesterdayData.levelStats?.["ERROR"] ?? 0;
|
||||
if (last === 0) return '较昨日 无变化';
|
||||
const rateNum = ((now - last) / last) * 100;
|
||||
const rateStr = rateNum.toFixed(1);
|
||||
@@ -781,7 +788,8 @@ export default function AlarmCenterPage() {
|
||||
innerRadius={45}
|
||||
outerRadius={80}
|
||||
backgroundColor="transparent"
|
||||
/> </Card>
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Card bordered={false} title="告警状态统计" style={{ borderRadius: 8 }}>
|
||||
@@ -820,7 +828,6 @@ export default function AlarmCenterPage() {
|
||||
{/* 告警详情抽屉 */}
|
||||
<Drawer
|
||||
title="告警详情"
|
||||
//open={true}
|
||||
open={drawerVisible}
|
||||
onClose={() => setDrawerVisible(false)}
|
||||
width={480}
|
||||
@@ -910,18 +917,15 @@ export default function AlarmCenterPage() {
|
||||
</Form.Item>
|
||||
</Card>
|
||||
|
||||
|
||||
{/* 底部按钮 */}
|
||||
<Button type="primary" block htmlType="submit">确认处理</Button>
|
||||
|
||||
|
||||
|
||||
|
||||
</>
|
||||
</Form>
|
||||
)}
|
||||
</Spin>
|
||||
</Drawer>
|
||||
|
||||
{/* ====================== 修改告警弹窗 ====================== */}
|
||||
<Modal
|
||||
title="修改告警"
|
||||
@@ -989,6 +993,53 @@ export default function AlarmCenterPage() {
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
{/* ========== 新增:生成工单弹窗 ========== */}
|
||||
<Modal
|
||||
title="新建工单"
|
||||
open={createOrderModalVisible}
|
||||
onCancel={() => {
|
||||
setCreateOrderModalVisible(false);
|
||||
orderForm.resetFields();
|
||||
}}
|
||||
width={500}
|
||||
maskClosable={false}
|
||||
footer={null}
|
||||
>
|
||||
<Form
|
||||
form={orderForm}
|
||||
layout="vertical"
|
||||
onFinish={submitCreateOrder}
|
||||
>
|
||||
<Form.Item
|
||||
label="工单标题"
|
||||
name="orderTitle"
|
||||
rules={[{ required: true, message: '请输入工单标题' }]}
|
||||
>
|
||||
<Input placeholder="请输入工单标题" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="计划开始时间"
|
||||
name="planStartTime"
|
||||
rules={[{ required: true, message: '请选择计划开始时间' }]}
|
||||
>
|
||||
<DatePicker
|
||||
showTime
|
||||
style={{ width: '100%' }}
|
||||
placeholder="请选择计划开始时间"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
|
||||
<Form.Item style={{ textAlign: 'right', marginBottom: 0 }}>
|
||||
<Button onClick={() => setCreateOrderModalVisible(false)}>取消</Button>
|
||||
<Button type="primary" htmlType="submit" style={{ marginLeft: 8 }}>
|
||||
确认生成工单
|
||||
</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user