|
|
|
@ -1,10 +1,9 @@
|
|
|
|
|
import TableActionCard from '@/components/TableActionCard';
|
|
|
|
|
import IsDelete from '@/components/TableActionCard/isDelete';
|
|
|
|
|
import { getInterfaces, postInterfaces } from '@/services/realTime/interfaces';
|
|
|
|
|
import { getPlatform } from '@/services/realTime/interfaces';
|
|
|
|
|
import type { ActionType, ProColumns } from '@ant-design/pro-components';
|
|
|
|
|
import { PageContainer, ProCard, ProTable } from '@ant-design/pro-components';
|
|
|
|
|
import { FormattedMessage, useIntl } from '@umijs/max';
|
|
|
|
|
import { Button, message } from 'antd';
|
|
|
|
|
import { FormattedMessage } from '@umijs/max';
|
|
|
|
|
import { Button } from 'antd';
|
|
|
|
|
import React, { useRef, useState } from 'react';
|
|
|
|
|
import { proTablePaginationOptions } from '../../../../config/defaultTable';
|
|
|
|
|
import CaptureButton from './components/CaptureButton';
|
|
|
|
@ -13,29 +12,30 @@ import './components/CaptureForm.less';
|
|
|
|
|
import CreateForm from './components/CreateForm';
|
|
|
|
|
import UpdateForm from './components/UpdateForm';
|
|
|
|
|
// svg 转组件
|
|
|
|
|
import { ReactComponent as Details } from '../../../../public/images/icons/details.svg';
|
|
|
|
|
// import { ReactComponent as Details } from '../../../../public/images/icons/details.svg';
|
|
|
|
|
// import { ReactComponent as Delete } from '../../../../public/images/icons/delete.svg';
|
|
|
|
|
import { EditOutlined } from '@ant-design/icons';
|
|
|
|
|
import { ReactComponent as Capture } from '../../../../public/images/icons/capture.svg';
|
|
|
|
|
const DeviceList: React.FC = () => {
|
|
|
|
|
/**
|
|
|
|
|
* @en-US International configuration
|
|
|
|
|
* @zh-CN 国际化配置
|
|
|
|
|
* */
|
|
|
|
|
const intl = useIntl();
|
|
|
|
|
// const intl = useIntl();
|
|
|
|
|
const actionRef = useRef<ActionType>();
|
|
|
|
|
// 动态设置每页数量
|
|
|
|
|
const [currentPageSize, setCurrentPageSize] = useState<number>(10);
|
|
|
|
|
|
|
|
|
|
const handleDestroy = async (selectedRow: API.UpdateInterfacesParams) => {
|
|
|
|
|
postInterfaces({ id: selectedRow.id, device_status: '3' })
|
|
|
|
|
.then(() => {
|
|
|
|
|
message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
|
|
|
|
|
actionRef.current?.reload();
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
// const handleDestroy = async (selectedRow: API.UpdateInterfacesParams) => {
|
|
|
|
|
// postInterfaces({ id: selectedRow.id, device_status: '3' })
|
|
|
|
|
// .then(() => {
|
|
|
|
|
// message.success(intl.formatMessage({ id: 'common.success', defaultMessage: '成功' }));
|
|
|
|
|
// actionRef.current?.reload();
|
|
|
|
|
// })
|
|
|
|
|
// .catch(() => {
|
|
|
|
|
// message.error(intl.formatMessage({ id: 'common.failure', defaultMessage: '失败' }));
|
|
|
|
|
// });
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
const [currentRow, setCurrentRow] = useState<API.UpdateInterfacesParams>();
|
|
|
|
|
/**
|
|
|
|
@ -75,34 +75,142 @@ const DeviceList: React.FC = () => {
|
|
|
|
|
setCaptureModalOpen(true);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const expandedRowRender = (record: any) => {
|
|
|
|
|
console.log(record, 'record');
|
|
|
|
|
const data = record.devices;
|
|
|
|
|
return (
|
|
|
|
|
<ProTable
|
|
|
|
|
className="table_body_bg"
|
|
|
|
|
cardProps={{
|
|
|
|
|
bodyStyle: {
|
|
|
|
|
margin: 0,
|
|
|
|
|
padding: 0,
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
rowKey={(record) => record.id}
|
|
|
|
|
columns={[
|
|
|
|
|
{
|
|
|
|
|
title: (
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
id="device.interface_manage.table.list.name"
|
|
|
|
|
defaultMessage="接口名称"
|
|
|
|
|
/>
|
|
|
|
|
),
|
|
|
|
|
dataIndex: 'device_name',
|
|
|
|
|
hideInSearch: true,
|
|
|
|
|
// width: 150,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: <FormattedMessage id="alarm_rules.page.status" defaultMessage="设备状态" />,
|
|
|
|
|
dataIndex: 'test_result',
|
|
|
|
|
hideInSearch: true,
|
|
|
|
|
// width: 280,
|
|
|
|
|
render: (dom, entity) => {
|
|
|
|
|
return <CaptureButton values={entity || {}} reload={actionRef.current?.reload} />;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: (
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
id="device.interface_manage.table.list.createTime"
|
|
|
|
|
defaultMessage="创建时间"
|
|
|
|
|
/>
|
|
|
|
|
),
|
|
|
|
|
// width: 200,
|
|
|
|
|
dataIndex: 'create_time',
|
|
|
|
|
sorter: true,
|
|
|
|
|
hideInSearch: true,
|
|
|
|
|
valueType: 'dateTime',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
title: <FormattedMessage id="pages.searchTable.titleOption" defaultMessage="操作" />,
|
|
|
|
|
dataIndex: 'option',
|
|
|
|
|
valueType: 'option',
|
|
|
|
|
// width: 100,
|
|
|
|
|
fixed: 'right',
|
|
|
|
|
render: (_, record) => [
|
|
|
|
|
<TableActionCard
|
|
|
|
|
key="TableActionCardRef"
|
|
|
|
|
renderActions={[
|
|
|
|
|
{
|
|
|
|
|
key: 'capture',
|
|
|
|
|
renderDom: (
|
|
|
|
|
<Button
|
|
|
|
|
key="capture"
|
|
|
|
|
type="link"
|
|
|
|
|
size="small"
|
|
|
|
|
style={{
|
|
|
|
|
color: '#004FB2',
|
|
|
|
|
}}
|
|
|
|
|
icon={
|
|
|
|
|
<Capture
|
|
|
|
|
style={{
|
|
|
|
|
marginRight: 3,
|
|
|
|
|
display: 'inline-flex',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
color: 'inherit',
|
|
|
|
|
fontStyle: 'normal',
|
|
|
|
|
lineHeight: 0,
|
|
|
|
|
textAlign: 'center',
|
|
|
|
|
textTransform: 'none',
|
|
|
|
|
verticalAlign: '-0.2em',
|
|
|
|
|
textRendering: 'optimizeLegibility',
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
console.log('11');
|
|
|
|
|
setCaptureModalOpen(true);
|
|
|
|
|
setCurrentRow(record);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{/* 最近拍摄 */}
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
id="device.interface_manage.table.list.capture"
|
|
|
|
|
defaultMessage="最近拍摄"
|
|
|
|
|
/>
|
|
|
|
|
</Button>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
></TableActionCard>,
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
headerTitle={false}
|
|
|
|
|
search={false}
|
|
|
|
|
options={false}
|
|
|
|
|
dataSource={data}
|
|
|
|
|
pagination={false}
|
|
|
|
|
showHeader={false}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
const columns: ProColumns<API.UpdateInterfacesParams>[] = [
|
|
|
|
|
{
|
|
|
|
|
title: (
|
|
|
|
|
<FormattedMessage id="device.interface_manage.table.list.name" defaultMessage="接口名称" />
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
id="device.interface_manage.table.list.platform_name"
|
|
|
|
|
defaultMessage="设备名称"
|
|
|
|
|
/>
|
|
|
|
|
),
|
|
|
|
|
dataIndex: 'device_name',
|
|
|
|
|
dataIndex: 'platform_name',
|
|
|
|
|
hideInSearch: true,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: <FormattedMessage id="alarm_rules.page.status" defaultMessage="设备状态" />,
|
|
|
|
|
title: (
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
id="device.interface_manage.table.list.statusUpdate"
|
|
|
|
|
defaultMessage="最近一次状态查询"
|
|
|
|
|
/>
|
|
|
|
|
),
|
|
|
|
|
dataIndex: 'test_result',
|
|
|
|
|
hideInSearch: true,
|
|
|
|
|
render: (dom, entity) => {
|
|
|
|
|
return <CaptureButton values={entity || {}} reload={actionRef.current?.reload} />;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
// {
|
|
|
|
|
// title: <FormattedMessage id="device.interface_manage.table.list.address" defaultMessage="接口地址" />,
|
|
|
|
|
// dataIndex: 'device_api',
|
|
|
|
|
// hideInSearch: true,
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// title: <FormattedMessage id="device.interface_manage.table.list.testTime" defaultMessage="状态查询时间" />,
|
|
|
|
|
// dataIndex: 'test_time',
|
|
|
|
|
// sorter: true,
|
|
|
|
|
// hideInSearch: true,
|
|
|
|
|
// valueType: 'dateTime',
|
|
|
|
|
// },
|
|
|
|
|
{
|
|
|
|
|
title: (
|
|
|
|
|
<FormattedMessage
|
|
|
|
@ -120,7 +228,7 @@ const DeviceList: React.FC = () => {
|
|
|
|
|
title: <FormattedMessage id="pages.searchTable.titleOption" defaultMessage="操作" />,
|
|
|
|
|
dataIndex: 'option',
|
|
|
|
|
valueType: 'option',
|
|
|
|
|
width: '260px',
|
|
|
|
|
width: '300px',
|
|
|
|
|
fixed: 'right',
|
|
|
|
|
render: (_, record) => [
|
|
|
|
|
<TableActionCard
|
|
|
|
@ -129,68 +237,52 @@ const DeviceList: React.FC = () => {
|
|
|
|
|
{
|
|
|
|
|
key: 'capture',
|
|
|
|
|
renderDom: (
|
|
|
|
|
<Button
|
|
|
|
|
key="capture"
|
|
|
|
|
type="link"
|
|
|
|
|
size="small"
|
|
|
|
|
style={{
|
|
|
|
|
color: '#004FB2',
|
|
|
|
|
}}
|
|
|
|
|
icon={
|
|
|
|
|
<Capture
|
|
|
|
|
style={{
|
|
|
|
|
marginRight: 3,
|
|
|
|
|
display: 'inline-flex',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
color: 'inherit',
|
|
|
|
|
fontStyle: 'normal',
|
|
|
|
|
lineHeight: 0,
|
|
|
|
|
textAlign: 'center',
|
|
|
|
|
textTransform: 'none',
|
|
|
|
|
verticalAlign: '-0.2em',
|
|
|
|
|
textRendering: 'optimizeLegibility',
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
console.log('11');
|
|
|
|
|
setCaptureModalOpen(true);
|
|
|
|
|
setCurrentRow(record);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
{/* 最近拍摄 */}
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
id="device.interface_manage.table.list.capture"
|
|
|
|
|
defaultMessage="最近拍摄"
|
|
|
|
|
/>
|
|
|
|
|
</Button>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'update',
|
|
|
|
|
renderDom: (
|
|
|
|
|
// <Button
|
|
|
|
|
// key="capture"
|
|
|
|
|
// type="link"
|
|
|
|
|
// size="small"
|
|
|
|
|
// style={{
|
|
|
|
|
// color: '#004FB2',
|
|
|
|
|
// }}
|
|
|
|
|
// icon={
|
|
|
|
|
// <Capture
|
|
|
|
|
// style={{
|
|
|
|
|
// marginRight: 3,
|
|
|
|
|
// display: 'inline-flex',
|
|
|
|
|
// alignItems: 'center',
|
|
|
|
|
// color: 'inherit',
|
|
|
|
|
// fontStyle: 'normal',
|
|
|
|
|
// lineHeight: 0,
|
|
|
|
|
// textAlign: 'center',
|
|
|
|
|
// textTransform: 'none',
|
|
|
|
|
// verticalAlign: '-0.2em',
|
|
|
|
|
// textRendering: 'optimizeLegibility',
|
|
|
|
|
// }}
|
|
|
|
|
// />
|
|
|
|
|
// }
|
|
|
|
|
// onClick={() => {
|
|
|
|
|
// console.log('11');
|
|
|
|
|
// setCaptureModalOpen(true);
|
|
|
|
|
// setCurrentRow(record);
|
|
|
|
|
// }}
|
|
|
|
|
// >
|
|
|
|
|
// {/* 最近拍摄 */}
|
|
|
|
|
// <FormattedMessage
|
|
|
|
|
// id="device.interface_manage.table.list.capture"
|
|
|
|
|
// defaultMessage="最近拍摄"
|
|
|
|
|
// />
|
|
|
|
|
// </Button>
|
|
|
|
|
<Button
|
|
|
|
|
key="update"
|
|
|
|
|
type="link"
|
|
|
|
|
size="small"
|
|
|
|
|
style={{
|
|
|
|
|
color: '#004FB2',
|
|
|
|
|
// display: 'flex',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
}}
|
|
|
|
|
icon={
|
|
|
|
|
<Details
|
|
|
|
|
<EditOutlined
|
|
|
|
|
style={{
|
|
|
|
|
marginRight: 3,
|
|
|
|
|
display: 'inline-flex',
|
|
|
|
|
alignItems: 'center',
|
|
|
|
|
color: 'inherit',
|
|
|
|
|
fontStyle: 'normal',
|
|
|
|
|
lineHeight: 0,
|
|
|
|
|
textAlign: 'center',
|
|
|
|
|
textTransform: 'none',
|
|
|
|
|
verticalAlign: '-0.2em',
|
|
|
|
|
textRendering: 'optimizeLegibility',
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
@ -199,20 +291,13 @@ const DeviceList: React.FC = () => {
|
|
|
|
|
setCurrentRow(record);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<FormattedMessage id="common.details" defaultMessage="详情" />
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
id="device.interface_manage.table.list.rename"
|
|
|
|
|
defaultMessage="重命名"
|
|
|
|
|
/>
|
|
|
|
|
</Button>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 'destroy',
|
|
|
|
|
renderDom: (
|
|
|
|
|
<IsDelete
|
|
|
|
|
deleteApi={() => {
|
|
|
|
|
handleDestroy(record).then(() => {});
|
|
|
|
|
}}
|
|
|
|
|
></IsDelete>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
]}
|
|
|
|
|
></TableActionCard>,
|
|
|
|
|
],
|
|
|
|
@ -301,23 +386,23 @@ const DeviceList: React.FC = () => {
|
|
|
|
|
style={{ margin: 0, padding: 0, boxShadow: '0px 4px 8px 0px rgba(0,79,178,0.15)' }}
|
|
|
|
|
bodyStyle={{ margin: 0, padding: 0 }}
|
|
|
|
|
headerBordered
|
|
|
|
|
title="设备列表"
|
|
|
|
|
extra={
|
|
|
|
|
<Button
|
|
|
|
|
type="primary"
|
|
|
|
|
style={{
|
|
|
|
|
boxShadow: 'none',
|
|
|
|
|
}}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setCreateModalOpen(true);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<FormattedMessage
|
|
|
|
|
id="device.interface_manage.table.list.add"
|
|
|
|
|
defaultMessage="新建设备/输入源"
|
|
|
|
|
/>
|
|
|
|
|
</Button>
|
|
|
|
|
}
|
|
|
|
|
title="设备状态"
|
|
|
|
|
// extra={
|
|
|
|
|
// <Button
|
|
|
|
|
// type="primary"
|
|
|
|
|
// style={{
|
|
|
|
|
// boxShadow: 'none',
|
|
|
|
|
// }}
|
|
|
|
|
// onClick={() => {
|
|
|
|
|
// setCreateModalOpen(true);
|
|
|
|
|
// }}
|
|
|
|
|
// >
|
|
|
|
|
// <FormattedMessage
|
|
|
|
|
// id="device.interface_manage.table.list.add"
|
|
|
|
|
// defaultMessage="新建设备/输入源"
|
|
|
|
|
// />
|
|
|
|
|
// </Button>
|
|
|
|
|
// }
|
|
|
|
|
>
|
|
|
|
|
<ProTable<API.DeviceCategory>
|
|
|
|
|
cardProps={{
|
|
|
|
@ -353,7 +438,7 @@ const DeviceList: React.FC = () => {
|
|
|
|
|
let sort_select = sort[reqParams.orderKey];
|
|
|
|
|
reqParams.desc = sort_select === 'descend';
|
|
|
|
|
}
|
|
|
|
|
let resp = await getInterfaces({ ...reqParams });
|
|
|
|
|
let resp = await getPlatform({ ...reqParams });
|
|
|
|
|
return {
|
|
|
|
|
data: resp.data.results.map((v: API.DeviceCategory) => {
|
|
|
|
|
return { ...v, key: v.id };
|
|
|
|
@ -365,6 +450,7 @@ const DeviceList: React.FC = () => {
|
|
|
|
|
};
|
|
|
|
|
}}
|
|
|
|
|
columns={columns}
|
|
|
|
|
expandable={{ expandedRowRender }}
|
|
|
|
|
/>
|
|
|
|
|
</ProCard>
|
|
|
|
|
<CreateForm
|
|
|
|
|