import TableActionCard from '@/components/TableActionCard'; import IsDelete from '@/components/TableActionCard/isDelete'; import { getInterfacesUpload, postInterfacesUpload } from '@/services/realTime/interfaces'; import { EditOutlined } from '@ant-design/icons'; import type { ActionType, ProColumns } from '@ant-design/pro-components'; import { PageContainer, ProTable } from '@ant-design/pro-components'; import { FormattedMessage, useIntl } from '@umijs/max'; import { Button, Tag, message } from 'antd'; import moment from 'moment'; import React, { useRef, useState } from 'react'; import { proTablePaginationOptions } from '../../../../config/defaultTable'; import CaptureForm from './components/CaptureForm'; import CreateForm from './components/CreateForm'; import UpdateForm from './components/UpdateForm'; const OfflineDeviceList: React.FC = () => { /** * @en-US International configuration * @zh-CN 国际化配置 * */ const intl = useIntl(); const actionRef = useRef(); // 动态设置每页数量 const [currentPageSize, setCurrentPageSize] = useState(10); const handleDestroy = async (selectedRow: API.UpdateInterfacesParams) => { postInterfacesUpload({ 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(); /** * @en-US Pop-up window of new window * @zh-CN 新建窗口的弹窗 * */ const [createModalOpen, setCreateModalOpen] = useState(false); const handleCreateModal = () => { if (createModalOpen) { setCreateModalOpen(false); setCurrentRow(undefined); } else { setCreateModalOpen(true); } }; // 编辑弹框 const [updateModalOpen, setUpdateModalOpen] = useState(false); const handleUpdateModal = () => { if (updateModalOpen) { setUpdateModalOpen(false); setCurrentRow(undefined); } else { setUpdateModalOpen(true); } }; // 最近拍摄 const [captureModalOpen, setCaptureModalOpen] = useState(false); const handleCaptureModal = () => { console.log(captureModalOpen); if (captureModalOpen) { setCaptureModalOpen(false); setCurrentRow(undefined); } else { setCaptureModalOpen(true); } }; // 测试连接 // const [loading, setLoading] = useState(false); const columns: ProColumns[] = [ { title: ( ), dataIndex: 'device_name', hideInSearch: true, }, { title: ( ), dataIndex: 'operate_mode', hideInSearch: true, render: (dom) => { return (
{dom === 1 && 'FTP'} {dom === 2 && 'FTP上传'} {dom === 3 && '文件系统'}
); }, }, { title: ( ), dataIndex: 'test_result', hideInSearch: true, render: (dom, entity) => { return (
{dom === 1 ? '获取成功' : '获取失败'} {moment(entity.create_time).format('YYYY-MM-DD hh:mm:ss')} {/*
// ); }, }, // { // title: , // dataIndex: 'device_api', // hideInSearch: true, // }, // { // title: , // dataIndex: 'test_time', // sorter: true, // hideInSearch: true, // valueType: 'dateTime', // }, { title: ( ), dataIndex: 'create_time', sorter: true, hideInSearch: true, valueType: 'dateTime', }, { title: , dataIndex: 'option', valueType: 'option', width: '260px', fixed: 'right', render: (_, record) => [ } // onClick={() => { // console.log('11'); // setCaptureModalOpen(true); // setCurrentRow(record); // }} // > // {/* 最近拍摄 */} // // // ), // }, { key: 'update', renderDom: ( ), }, { key: 'destroy', renderDom: ( { handleDestroy(record).then(() => {}); }} > ), }, ]} >, ], }, ]; return (
离线设备管理
} > cardProps={{ bodyStyle: { padding: 20, }, }} options={{ fullScreen: false, setting: false, density: false, reload: false }} actionRef={actionRef} rowKey="key" search={false} showSorterTooltip={false} pagination={{ ...proTablePaginationOptions, pageSize: currentPageSize, onChange: (page, pageSize) => setCurrentPageSize(pageSize), }} columnsState={{ persistenceKey: 'device_category_list', persistenceType: 'localStorage', }} request={async (params = {}, sort) => { const { current, ...rest } = params; const reqParams = { page: current, desc: false, orderKey: '', ...rest, }; if (sort && Object.keys(sort).length) { reqParams.orderKey = Object.keys(sort)[0]; let sort_select = sort[reqParams.orderKey]; reqParams.desc = sort_select === 'descend'; } // let resp = await postDeviceCategoryGetDeviceCategoryList({ ...reqParams }); let resp = await getInterfacesUpload({ ...reqParams }); return { data: resp.data.results.map((v: API.DeviceCategory) => { return { ...v, key: v.id }; }), success: resp.success, total: resp.data.count, current: resp.data.page, pageSize: resp.data.pageSize, }; }} columns={columns} />
); }; export default OfflineDeviceList;