You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

96 lines
4.4 KiB

import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { PageContainer, ProTable } from '@ant-design/pro-components';
import { CardDetail, DescriptionsDetail } from '@component/ui';
import { useRoutes, dateFormatter } from '@component/utils';
import { getMachineInfo } from './action';
import React from 'react';
import { useRequest } from 'ahooks';
import { message } from 'antd';
export default function () {
var _a;
const { paramsParse: { deviceCode }, } = useRoutes();
const { data, loading } = useRequest(getMachineInfo, {
defaultParams: { deviceCode },
onError(result) {
message.error(result.message);
},
});
const status = [
{ label: '正常', val: 1, color: '#95bc49' },
{ label: '离线', val: 2, color: '#999999' },
{ label: '故障', val: 3, color: '#d9001b' },
];
const messageStatus = [
{ label: '上线下线', val: 1000 },
{ label: '设备签到', val: 1001 },
{ label: '设备报警', val: 1002, color: '#FF3836' },
{ label: '设备心跳', val: 1003 },
{ label: '设备故障', val: 1004 },
{ label: '状态上报', val: 1006 },
];
const columns = React.useMemo(() => [
{
title: '消息类型',
dataIndex: 'serviceId',
render(_, { serviceId }) {
return messageStatus.map((item) => {
if (item.val == serviceId) {
return (_jsx("span", Object.assign({ style: (item === null || item === void 0 ? void 0 : item.color) && { color: item.color } }, { children: item.label })));
}
});
},
},
{
title: '设备ID',
dataIndex: 'imei',
},
{
title: '消息时间',
dataIndex: 'createdAt',
renderText: dateFormatter,
},
], []);
return (_jsx(PageContainer, Object.assign({ header: {
title: null,
}, loading: loading }, { children: _jsxs("div", Object.assign({ className: "page-content-detail", style: { padding: '20px' } }, { children: [_jsx(CardDetail, Object.assign({ title: "\u57FA\u672C\u4FE1\u606F" }, { children: _jsx(DescriptionsDetail, { column: 2, dataSource: data, columns: [
{
title: '设备IMEI',
dataIndex: 'deviceCode',
},
{
title: '设备状态',
dataIndex: 'deviceStatus',
render(deviceStatus) {
return status.map((item) => {
if (item.val == deviceStatus) {
return (_jsx("span", Object.assign({ style: { color: item.color } }, { children: item.label })));
}
});
},
},
{
title: '所属企业',
dataIndex: 'customerName',
},
{
title: '预警消息数',
dataIndex: 'earlyWarningNum',
},
{
title: '安装日期',
dataIndex: 'installAt',
valueType: 'date',
fieldProps: {
format: 'YYYY-MM-DD HH:mm',
},
},
{
title: '位置信息',
dataIndex: 'position',
},
{
title: '归属机构',
dataIndex: 'insuranceName',
},
] }) })), _jsx(CardDetail, Object.assign({ title: "\u8BBE\u5907\u6D88\u606F" }, { children: _jsx(ProTable, { columns: columns, dataSource: (_a = data === null || data === void 0 ? void 0 : data.list) !== null && _a !== void 0 ? _a : [], toolBarRender: false, search: false, pagination: { pageSize: 10 } }) }))] })) })));
}