|
|
@@ -1,57 +1,93 @@
|
|
|
import SearchComponent from '@/components/SearchComponent';
|
|
|
-import { BellFilled, FileFilled, FileTextFilled, ToolFilled } from '@ant-design/icons';
|
|
|
+import { FileFilled, FileTextFilled, ToolFilled } from '@ant-design/icons';
|
|
|
import type { ProColumns } from '@jetlinks/pro-table';
|
|
|
-import { Button, Card, Col, Empty, Pagination, Row, Space } from 'antd';
|
|
|
-import classNames from 'classnames';
|
|
|
-import moment from 'moment';
|
|
|
+import { Badge, Button, Card, Col, Empty, Pagination, Row, Space } from 'antd';
|
|
|
import { useEffect, useState } from 'react';
|
|
|
import './index.less';
|
|
|
import SolveComponent from '../SolveComponent';
|
|
|
+import SolveLog from '../SolveLog';
|
|
|
import { AlarmLogModel } from '../model';
|
|
|
-import Service from '../service';
|
|
|
-
|
|
|
-export const service = new Service('alarm/record');
|
|
|
+import moment from 'moment';
|
|
|
+import { observer } from '@formily/reactive-react';
|
|
|
+import { service } from '@/pages/rule-engine/Alarm/Log';
|
|
|
+import { getMenuPathByParams, MENUS_CODE } from '@/utils/menu';
|
|
|
+import { useHistory } from 'umi';
|
|
|
|
|
|
interface Props {
|
|
|
type: string;
|
|
|
}
|
|
|
-const defaultImage = require('/public/images/alarm/log.png');
|
|
|
|
|
|
const imgMap = new Map();
|
|
|
-imgMap.set(1, require('/public/images/alarm/level_1.png'));
|
|
|
-imgMap.set(2, require('/public/images/alarm/level_2.png'));
|
|
|
-imgMap.set(3, require('/public/images/alarm/level_3.png'));
|
|
|
-imgMap.set(4, require('/public/images/alarm/level_4.png'));
|
|
|
-imgMap.set(5, require('/public/images/alarm/level_5.png'));
|
|
|
+imgMap.set('product', require('/public/images/alarm/product.png'));
|
|
|
+imgMap.set('device', require('/public/images/alarm/device.png'));
|
|
|
+imgMap.set('other', require('/public/images/alarm/other.png'));
|
|
|
+imgMap.set('org', require('/public/images/alarm/org.png'));
|
|
|
+
|
|
|
+const titleMap = new Map();
|
|
|
+titleMap.set('product', '产品');
|
|
|
+titleMap.set('device', '设备');
|
|
|
+titleMap.set('other', '其他');
|
|
|
+titleMap.set('org', '部门');
|
|
|
|
|
|
-const TabComponent = (props: Props) => {
|
|
|
+const colorMap = new Map();
|
|
|
+colorMap.set(1, '#E50012');
|
|
|
+colorMap.set(2, '#FF9457');
|
|
|
+colorMap.set(3, '#FABD47');
|
|
|
+colorMap.set(4, '#999999');
|
|
|
+colorMap.set(5, '#C4C4C4');
|
|
|
+
|
|
|
+const TabComponent = observer((props: Props) => {
|
|
|
const columns: ProColumns<any>[] = [
|
|
|
{
|
|
|
title: '名称',
|
|
|
dataIndex: 'name',
|
|
|
},
|
|
|
- // {
|
|
|
- // title: '状态',
|
|
|
- // dataIndex: 'state',
|
|
|
- // valueType: 'select',
|
|
|
- // valueEnum: {
|
|
|
- // disabled: {
|
|
|
- // text: '已停止',
|
|
|
- // status: 'disabled',
|
|
|
- // },
|
|
|
- // enabled: {
|
|
|
- // text: '已启动',
|
|
|
- // status: 'enabled',
|
|
|
- // },
|
|
|
- // },
|
|
|
- // },
|
|
|
- // {
|
|
|
- // title: '说明',
|
|
|
- // dataIndex: 'description',
|
|
|
- // },
|
|
|
+ {
|
|
|
+ title: '级别',
|
|
|
+ dataIndex: 'level',
|
|
|
+ valueType: 'select',
|
|
|
+ valueEnum: {
|
|
|
+ 1: {
|
|
|
+ text: '级别一',
|
|
|
+ status: '1',
|
|
|
+ },
|
|
|
+ 2: {
|
|
|
+ text: '级别二',
|
|
|
+ status: '2',
|
|
|
+ },
|
|
|
+ 3: {
|
|
|
+ text: '级别三',
|
|
|
+ status: '3',
|
|
|
+ },
|
|
|
+ 4: {
|
|
|
+ text: '级别四',
|
|
|
+ status: '4',
|
|
|
+ },
|
|
|
+ 5: {
|
|
|
+ text: '级别五',
|
|
|
+ status: '5',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '状态',
|
|
|
+ dataIndex: 'state',
|
|
|
+ valueType: 'select',
|
|
|
+ valueEnum: {
|
|
|
+ warning: {
|
|
|
+ text: '告警中',
|
|
|
+ status: 'warning',
|
|
|
+ },
|
|
|
+ normal: {
|
|
|
+ text: '无告警',
|
|
|
+ status: 'normal',
|
|
|
+ },
|
|
|
+ },
|
|
|
+ },
|
|
|
];
|
|
|
|
|
|
const [param, setParam] = useState<any>({ pageSize: 10, terms: [] });
|
|
|
+ const history = useHistory<Record<string, string>>();
|
|
|
|
|
|
const [dataSource, setDataSource] = useState<any>({
|
|
|
data: [],
|
|
|
@@ -74,7 +110,7 @@ const TabComponent = (props: Props) => {
|
|
|
type: 'and',
|
|
|
},
|
|
|
],
|
|
|
- sorts: [{ name: 'createTime', order: 'desc' }],
|
|
|
+ sorts: [{ name: 'alarmDate', order: 'desc' }],
|
|
|
})
|
|
|
.then((resp) => {
|
|
|
if (resp.status === 200) {
|
|
|
@@ -103,73 +139,100 @@ const TabComponent = (props: Props) => {
|
|
|
<Card>
|
|
|
{dataSource?.data.length > 0 ? (
|
|
|
<Row gutter={24} style={{ marginTop: 10 }}>
|
|
|
- {(dataSource?.data || []).map((item: any, index: number) => (
|
|
|
+ {(dataSource?.data || []).map((item: any) => (
|
|
|
<Col key={item.id} span={24}>
|
|
|
<div className="alarm-log-item">
|
|
|
<div className="alarm-log-title">
|
|
|
- <div>{item.name}</div>
|
|
|
+ <div
|
|
|
+ className="alarm-log-level"
|
|
|
+ style={{ backgroundColor: colorMap.get(item.level) }}
|
|
|
+ >
|
|
|
+ <div className="alarm-log-text">
|
|
|
+ {AlarmLogModel.defaultLevel.find((i) => i.level === item.level)?.title ||
|
|
|
+ item.level}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div className="alarm-log-title-text">{item.name}</div>
|
|
|
</div>
|
|
|
<div className="alarm-log-content">
|
|
|
<div className="alarm-log-image">
|
|
|
<img
|
|
|
width={88}
|
|
|
height={88}
|
|
|
- src={defaultImage}
|
|
|
+ src={imgMap.get(props.type)}
|
|
|
alt={''}
|
|
|
style={{ marginRight: 20 }}
|
|
|
/>
|
|
|
<div className="alarm-type">
|
|
|
- <div className="name">产品</div>
|
|
|
- <div className="text">海康烟感A海康烟感A</div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <div className="alarm-log-time">
|
|
|
- <div className="log-title">最近告警时间</div>
|
|
|
- <div className="context">
|
|
|
- {moment(item.timestamp).format('YYYY-MM-DD HH:mm:ss')}
|
|
|
+ <div className="name">{titleMap.get(item.targetType)}</div>
|
|
|
+ <div className="text">{item.targetName}</div>
|
|
|
</div>
|
|
|
- </div>
|
|
|
- <div className="alarm-log-level">
|
|
|
- <div className="log-title">告警级别</div>
|
|
|
- <div className="context">
|
|
|
- <img src={imgMap.get(index + 1)} alt={''} style={{ marginRight: 5 }} />
|
|
|
- {item.level}
|
|
|
+ <div className="alarm-log-right">
|
|
|
+ <div className="alarm-log-time">
|
|
|
+ <div className="log-title">最近告警时间</div>
|
|
|
+ <div className="context">
|
|
|
+ {moment(item.alarmDate).format('YYYY-MM-DD HH:mm:ss')}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div className="alarm-log-time" style={{ paddingLeft: 10 }}>
|
|
|
+ <div className="log-title">状态</div>
|
|
|
+ <div className="context">
|
|
|
+ <Badge status={item.state.value === 'warning' ? 'error' : 'default'} />
|
|
|
+ <span
|
|
|
+ style={{
|
|
|
+ color: item.state.value === 'warning' ? '#E50012' : 'black',
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {item.state.text}
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div
|
|
|
- className={classNames(
|
|
|
- 'alarm-log-status',
|
|
|
- item.status.value ? 'status-active' : '',
|
|
|
- )}
|
|
|
- >
|
|
|
- <BellFilled className="icon" />
|
|
|
- {item.status.text}
|
|
|
- </div>
|
|
|
<div className="alarm-log-actions">
|
|
|
<Space>
|
|
|
+ {item.state.value === 'warning' && (
|
|
|
+ <div className="alarm-log-action">
|
|
|
+ <Button
|
|
|
+ type={'link'}
|
|
|
+ onClick={() => {
|
|
|
+ AlarmLogModel.solveVisible = true;
|
|
|
+ AlarmLogModel.current = item;
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <div className="btn">
|
|
|
+ <ToolFilled className="icon" />
|
|
|
+ <div>告警处理</div>
|
|
|
+ </div>
|
|
|
+ </Button>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
<div className="alarm-log-action">
|
|
|
<Button
|
|
|
type={'link'}
|
|
|
onClick={() => {
|
|
|
- AlarmLogModel.solveVisible = true;
|
|
|
+ AlarmLogModel.current = item;
|
|
|
+ const url = getMenuPathByParams(
|
|
|
+ MENUS_CODE['rule-engine/Alarm/Log/Detail'],
|
|
|
+ item.id,
|
|
|
+ );
|
|
|
+ history.push(url);
|
|
|
}}
|
|
|
>
|
|
|
<div className="btn">
|
|
|
- <ToolFilled className="icon" />
|
|
|
- <div>告警处理</div>
|
|
|
- </div>
|
|
|
- </Button>
|
|
|
- </div>
|
|
|
- <div className="alarm-log-action">
|
|
|
- <Button type={'link'}>
|
|
|
- <div className="btn">
|
|
|
<FileFilled className="icon" />
|
|
|
<div>告警日志</div>
|
|
|
</div>
|
|
|
</Button>
|
|
|
</div>
|
|
|
<div className="alarm-log-action">
|
|
|
- <Button type={'link'}>
|
|
|
+ <Button
|
|
|
+ type={'link'}
|
|
|
+ onClick={() => {
|
|
|
+ AlarmLogModel.logVisible = true;
|
|
|
+ AlarmLogModel.current = item;
|
|
|
+ }}
|
|
|
+ >
|
|
|
<div className="btn">
|
|
|
<FileTextFilled className="icon" />
|
|
|
<div>处理记录</div>
|
|
|
@@ -212,9 +275,31 @@ const TabComponent = (props: Props) => {
|
|
|
</div>
|
|
|
)}
|
|
|
</Card>
|
|
|
- {AlarmLogModel.solveVisible && <SolveComponent />}
|
|
|
+ {AlarmLogModel.solveVisible && (
|
|
|
+ <SolveComponent
|
|
|
+ close={() => {
|
|
|
+ AlarmLogModel.solveVisible = false;
|
|
|
+ AlarmLogModel.current = {};
|
|
|
+ }}
|
|
|
+ reload={() => {
|
|
|
+ AlarmLogModel.solveVisible = false;
|
|
|
+ AlarmLogModel.current = {};
|
|
|
+ handleSearch(param);
|
|
|
+ }}
|
|
|
+ data={AlarmLogModel.current}
|
|
|
+ />
|
|
|
+ )}
|
|
|
+ {AlarmLogModel.logVisible && (
|
|
|
+ <SolveLog
|
|
|
+ close={() => {
|
|
|
+ AlarmLogModel.logVisible = false;
|
|
|
+ AlarmLogModel.current = {};
|
|
|
+ }}
|
|
|
+ data={AlarmLogModel.current}
|
|
|
+ />
|
|
|
+ )}
|
|
|
</div>
|
|
|
);
|
|
|
-};
|
|
|
+});
|
|
|
|
|
|
export default TabComponent;
|