import { PermissionButton } from '@/components'; import SearchComponent from '@/components/SearchComponent'; import useDomFullHeight from '@/hooks/document/useDomFullHeight'; import { getMenuPathByParams, MENUS_CODE } from '@/utils/menu'; import { onlyMessage } from '@/utils/util'; import { DeleteOutlined, EditOutlined, PlayCircleOutlined, PlusOutlined, StopOutlined, } from '@ant-design/icons'; import { PageContainer } from '@ant-design/pro-layout'; import ProTable, { ActionType, ProColumns } from '@jetlinks/pro-table'; import { Badge } from 'antd'; import { useRef, useState } from 'react'; import Service from './service'; import { useHistory } from '@/hooks'; export const service = new Service('network/card/platform'); const Platform = () => { const { minHeight } = useDomFullHeight(`.record`, 24); const actionRef = useRef(); const [param, setParam] = useState({}); const history = useHistory(); const { permission } = PermissionButton.usePermission('iot-card/Platform'); const statusUpdate = async (data: any) => { const res = await service.update(data); if (res.status === 200) { onlyMessage('操作成功'); actionRef.current?.reload(); } }; const columns: ProColumns[] = [ { title: '名称', dataIndex: 'name', ellipsis: true, }, { title: '平台类型', dataIndex: 'operatorName', ellipsis: true, valueType: 'select', valueEnum: { onelink: { text: '移动OneLink', status: 'onelink', }, ctwing: { text: '电信Ctwing', status: 'ctwing', }, unicom: { text: '联通Unicom', status: 'unicom', }, }, }, { title: '状态', dataIndex: 'state', ellipsis: true, valueType: 'select', valueEnum: { enabled: { text: '启用', status: 'enabled', }, disabled: { text: '禁用', status: 'disabled', }, }, render: (_, record: any) => ( ), }, { title: '说明', dataIndex: 'explain', ellipsis: true, hideInSearch: true, }, { title: '操作', valueType: 'option', fixed: 'right', render: (text, record) => [ { const url = `${getMenuPathByParams(MENUS_CODE['iot-card/Platform/Detail'], record.id)}`; history.push(url); }} type={'link'} style={{ padding: 0 }} tooltip={{ title: '编辑', }} > , { if (record.state.value === 'enabled') { statusUpdate({ id: record.id, config: { ...record.config }, state: 'disabled', operatorName: record.operatorName, }); } else { statusUpdate({ id: record.id, config: { ...record.config }, state: 'enabled', operatorName: record.operatorName, }); } }, }} > {record.state.value === 'enabled' ? : } , { const res: any = await service.remove(record.id); if (res.status === 200) { onlyMessage('操作成功'); actionRef.current?.reload(); } }, }} key="delete" type="link" > , ], }, ]; return ( { // 重置分页数据 actionRef.current?.reset?.(); setParam(data); }} /> { const url = `${getMenuPathByParams(MENUS_CODE['iot-card/Platform/Detail'])}`; history.push(url); }} style={{ marginRight: 12 }} isPermission={permission.add} key="button" icon={} type="primary" > 新增 } request={async (params: any) => { delete params?.total; const res = await service.getList({ ...params, sorts: [{ name: 'createTime', order: 'desc' }], }); return { code: res.status, result: res.result, status: res.status, }; }} /> ); }; export default Platform;