diff --git a/config/router.config.ts b/config/router.config.ts index 46b1726..411f067 100644 --- a/config/router.config.ts +++ b/config/router.config.ts @@ -335,6 +335,11 @@ export default [ }, ], }, + {//异常告警 + name: 'AbnormalAlarm', + path: '/AbnormalAlarm', + component: './AbnormalAlarm' + }, { component: './404', }, diff --git a/src/pages/AbnormalAlarm/index.tsx b/src/pages/AbnormalAlarm/index.tsx new file mode 100644 index 0000000..9cb2cef --- /dev/null +++ b/src/pages/AbnormalAlarm/index.tsx @@ -0,0 +1,124 @@ +import React, { useState, useRef } from 'react'; +import { message, PageHeader, Button, Spin } from 'antd'; +import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table'; +import { getPage, handleAlarm } from './service'; + + +const AbnormalAalarm: React.FC<{}> = () => { + const actionRef = useRef(); + const [spin, setSpin] = useState(false); + //显隐 查看详情窗口 + const [viewDetailModalVisible, setViewDetailModalVisible] = useState(false); + + //查询分页数据 + const [pageData, pageDataSet] = useState({ + pageNo: 1, + pageSize: 10 + }); + + //委托列表 + const columns: ProColumns[] = [ + { + title: '序号', valueType: 'index', width: 50, hideInSearch:true, align: 'center' + }, + { title: '项目名称', dataIndex: 'projectName', width: '15%', hideInSearch: false, align: 'center' }, + { title: '标段名称', dataIndex: 'sectionName', hideInSearch: false, align: 'center' }, + { title: '评审室名称', dataIndex: 'areaName', width: '10%',hideInSearch:true, align: 'center' }, + { title: '告警设备类型', dataIndex: 'deviceType', hideInSearch:true, align: 'center' }, + { title: '告警设备编号', dataIndex: 'deviceCode', width: '15%', hideInSearch:true, align: 'center'}, + { title: '告警消息', dataIndex: 'type', hideInSearch: false, align: 'center', + valueEnum: { + 1: { text: '设备离线'}, + 2: { text: '人员数量异常'}, + 3: { text: '陌生人进入'}, + } + }, + { + title: '处理状态', dataIndex: 'status', align: 'center',hideInSearch: true, + valueEnum: { + 0: { text: '未处理'}, + 1: { text: '已处理'}, + } + }, + { + title: '操作', width: '9%', align: 'center', + valueType: 'option', + render: (_, record) => { + if (record.type === "1") { + if(record.status === "0"){ + return + } + } else { + return ( + ) + } + } + }, + ]; + + /** + * 处理 + * @param fields + */ + const handle = async (fields: any) => { + setSpin(true); + const hide = message.loading('正在处理'); + try { + await handleAlarm({ + id: fields.id, + type: fields.type + }); + hide(); + message.success('处理成功'); + actionRef?.current?.reload(); + return true; + } catch (error) { + hide(); + message.error('处理失败请重试!'); + return false; + }finally{ + setSpin(false); + } + }; + + return ( + + +
+ + actionRef={actionRef}//action触发后更新表格 + columns={columns}//表格 + options={false} + bordered={false} + className='tableSearch' + size='small' + search={{ labelWidth: 'auto', span: 6 }} + request={(params) => + getPage({ + ...params, + pageNo: pageData.pageNo, + pageSize: pageData.pageSize, + }).then((res) => { + const result = { + data: res.data.records, + total: res.data.total, + success: res.success, + pageSize: res.data.size, + current: res.data.current + } + return result; + }) + } + pagination={{ + defaultPageSize: 10, + showSizeChanger: false, + onChange: (page, pageSize) => pageDataSet({ pageNo: page, pageSize: pageSize }), + onShowSizeChange: (current, size) => pageDataSet({ pageNo: current, pageSize: size }), + }} + onReset={() => { pageDataSet({ pageNo: 1, pageSize: 10 }) }} + /> +
+
+ ) +}; +export default AbnormalAalarm; \ No newline at end of file diff --git a/src/pages/AbnormalAlarm/service.ts b/src/pages/AbnormalAlarm/service.ts new file mode 100644 index 0000000..ff0362a --- /dev/null +++ b/src/pages/AbnormalAlarm/service.ts @@ -0,0 +1,28 @@ +import request from '@/utils/request'; + +/** + * 分页查询接口 + * @return 分页数据 + */ +export async function getPage(params: any) { + return request('/api/biz-service-ebtp-evaluation/v1/eval/room/alarm/page', { + method: 'POST', + data: { + ...params + }, + }); +} + +/** + * 处理告警接口 + * @param params 数据id + * @returns 处理结果 + */ +export async function handleAlarm(params: any) { + return request('/api/biz-service-ebtp-evaluation/v1/eval/room/alarm/update/status', { + method: 'POST', + data: { + ...params + }, + }); + } \ No newline at end of file