Skip to content

Commit

Permalink
feat(设备管理): 设备告警
Browse files Browse the repository at this point in the history
  • Loading branch information
Lind-pro committed Nov 3, 2020
1 parent 5921383 commit 267e962
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 6 deletions.
6 changes: 3 additions & 3 deletions config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ export default {
},
proxy: proxy[REACT_APP_ENV || 'dev'],
chainWebpack: webpackPlugin,
extraBabelPlugins: [
['transform-remove-console', { exclude: ['error', 'info'] }]
]
// extraBabelPlugins: [
// ['transform-remove-console', { exclude: ['error', 'info'] }]
// ]
// proxy: {
// '/jetlinks': {
// // target: 'http://192.168.3.89:8848/',
Expand Down
12 changes: 9 additions & 3 deletions config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ export const routes = [
iconfont: 'icon-gujianshengji',
component: './device/firmware/editor',
},
{
path: '/device/alarm',
name: '设备告警',
icon: 'alert',
component: './device/alarmlog',
}
],
},
{
Expand Down Expand Up @@ -367,15 +373,15 @@ export const routes = [
icon: 'desktop',
tenant: ['admin'],
iconfont: 'icon-icon-',
authority: ['big-screen','admin'],
authority: ['big-screen', 'admin'],
routes: [
{
path: '/data-screen/category',
name: '分类管理',
icon: 'appstore',
tenant: ['admin'],
iconfont: 'icon-category-search-fill',
authority: ['big-screen','admin'],
authority: ['big-screen', 'admin'],
version: 'pro',
component: './data-screen/category',
},
Expand All @@ -385,7 +391,7 @@ export const routes = [
icon: 'fund',
tenant: ['admin'],
iconfont: 'icon-screen',
authority: ['big-screen','admin'],
authority: ['big-screen', 'admin'],
version: 'pro',
component: './data-screen/screen',
}
Expand Down
169 changes: 169 additions & 0 deletions src/pages/device/alarmlog/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
import SearchForm from "@/components/SearchForm";
import ProTable from "@/pages/system/permission/component/ProTable";
import apis from "@/services";
import encodeQueryParam from "@/utils/encodeParam";
import { PageHeaderWrapper } from "@ant-design/pro-layout";
import { Card, Divider, message, Modal, Tag } from "antd";
import { ColumnProps } from "antd/lib/table";
import moment from "moment";
import React, { Fragment, useEffect, useRef, useState } from "react";
import { AlarmLog } from "../alarm/data";

interface Props { }
const Alarmlog: React.FC<Props> = () => {
const [loading, setLoading] = useState(false);
const [result, setResult] = useState<any>({});
const productList = useRef<any[]>([]);
const [searchParam, setSearchParam] = useState({
pageSize: 10,
sorts: {
order: "descend",
field: "alarmTime"
}
});
useEffect(() => {
handleSearch(searchParam);
apis.deviceProdcut.queryNoPagin(
encodeQueryParam({ paging: false }))
.then((resp) => {
if (resp.status === 200) {
productList.current = resp.result;
}
});
}, []);
const handleSearch = (params?: any) => {
setSearchParam(params);
setLoading(true);
apis.deviceAlarm.findAlarmLog(encodeQueryParam(params))
.then((response: any) => {
if (response.status === 200) {
setResult(response.result);
}
}).finally(() => { setLoading(false) });

};
const alarmLogColumns: ColumnProps<AlarmLog>[] = [
{
title: '设备ID',
dataIndex: 'deviceId',
},
{
title: '设备名称',
dataIndex: 'deviceName',
},
{
title: '告警名称',
dataIndex: 'alarmName',
},
{
title: '告警时间',
dataIndex: 'alarmTime',
width: '300px',
render: (text: any) => text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : '/',
sorter: true,
defaultSortOrder: 'descend'
},
{
title: '处理状态',
dataIndex: 'state',
align: 'center',
width: '100px',
render: text => text === 'solve' ? <Tag color="#87d068">已处理</Tag> : <Tag color="#f50">未处理</Tag>,
},
{
title: '操作',
width: '120px',
align: 'center',
render: (record: any) => (
<Fragment>
<a onClick={() => {
let content: string;
try {
content = JSON.stringify(record.alarmData, null, 2);
} catch (error) {
content = record.alarmData;
}
Modal.confirm({
width: '40VW',
title: '告警数据',
content: <pre>{content}
{record.state === 'solve' && (
<>
<br /><br />
<span style={{ fontSize: 16 }}>处理结果:</span>
<br />
<p>{record.description}</p>
</>
)}
</pre>,
okText: '确定',
cancelText: '关闭',
})
}}>详情</a>
<Divider type="vertical" />
{
record.state !== 'solve' && (
<a onClick={() => {
// setSolveAlarmLogId(record.id);
// setSolveVisible(true);
}}>处理</a>
)
}
</Fragment>
)
},
];
return (
<PageHeaderWrapper title="告警记录">
<Card bordered={false} style={{ marginBottom: 16 }}>
<div>
<div>

<SearchForm
search={(params: any) => {
handleSearch({
terms: { ...params },
pageSize: 10,
sorts: searchParam.sorts
});
}}
formItems={[{
label: '设备ID',
key: 'deviceId$like',
type: 'string',
},
{
label: '产品',
key: 'productId$IN',
type: 'list',
props: {
data: productList.current,
mode: 'tags',
}
},
{
label: '告警时间',
key: 'alarmTime$btw',
type: 'time',
},
]}
/>
</div>
</div>
</Card>
<Card>
<ProTable
loading={loading}
dataSource={result?.data}
columns={alarmLogColumns}
rowKey="id"
onSearch={(params: any) => {
handleSearch(params);
}}
paginationConfig={result}
/>
</Card>
</PageHeaderWrapper>
)
}
export default Alarmlog;

0 comments on commit 267e962

Please sign in to comment.