import { service } from '@/pages/media/Cascade'; import SearchComponent from '@/components/SearchComponent'; import { CloseOutlined, DisconnectOutlined, EditOutlined } from '@ant-design/icons'; import { PageContainer } from '@ant-design/pro-layout'; import type { ActionType, ProColumns } from '@jetlinks/pro-table'; import ProTable from '@jetlinks/pro-table'; import { Button, Input, message, Popover, Space } from 'antd'; import { useRef, useState } from 'react'; import { useIntl, useLocation } from 'umi'; import BindChannel from './BindChannel'; import BadgeStatus, { StatusColorEnum } from '@/components/BadgeStatus'; import { PermissionButton } from '@/components'; const Channel = () => { const location: any = useLocation(); const actionRef = useRef(); const [param, setParam] = useState({}); const intl = useIntl(); const [visible, setVisible] = useState(false); const [selectedRowKey, setSelectedRowKey] = useState([]); const id = location?.query?.id || ''; const [data, setData] = useState(''); const [popVisible, setPopvisible] = useState(''); const { permission } = PermissionButton.usePermission('media/Cascade'); const unbind = async (list: string[]) => { const resp = await service.unbindChannel(id, list); if (resp.status === 200) { actionRef.current?.reload(); message.success('操作成功!'); if (list.length === 1) { const index = selectedRowKey.indexOf(list[0]); const dt = [...selectedRowKey]; dt.splice(index, 1); setSelectedRowKey([...dt]); } } }; const content = (record: any) => { return (
{ setData(e.target.value); }} />
); }; const columns: ProColumns[] = [ { dataIndex: 'deviceName', title: '设备名称', }, { dataIndex: 'name', title: '通道名称', }, { dataIndex: 'gbChannelId', title: '国标ID', tooltip: '国标级联有18位、20位两种格式。在当前页面修改不会修改视频设备-通道页面中的国标ID', render: (text: any, record: any) => ( {text}
编辑国标ID
{ setPopvisible(''); setData(''); }} /> } > { setData(''); setPopvisible(record.id); }} >
), }, { dataIndex: 'address', title: '安装地址', }, { dataIndex: 'manufacturer', title: '厂商', }, { dataIndex: 'status', title: '在线状态', valueType: 'select', valueEnum: { online: { text: '已连接', status: 'online', }, offline: { text: '离线', status: 'offline', }, }, render: (text: any, record: any) => ( ), }, { title: '操作', valueType: 'option', align: 'center', width: 200, render: (text: any, record: any) => [ { unbind([record.channelId]); }, }} > , ], }, ]; return ( field={columns} target="bind-channel" onSearch={(params) => { actionRef.current?.reload(); setParam({ ...param, terms: params?.terms ? [...params?.terms] : [], }); }} /> actionRef={actionRef} params={param} columns={columns} search={false} headerTitle={'通道列表'} request={async (params) => { return service.queryBindChannel(id, { ...params, sorts: [{ name: 'name', order: 'desc' }], }); }} rowKey="channelId" rowSelection={{ selectedRowKeys: selectedRowKey, onChange: (selectedRowKeys) => { setSelectedRowKey(selectedRowKeys as string[]); }, }} tableAlertRender={({ selectedRowKeys, onCleanSelected }) => ( {intl.formatMessage({ id: 'pages.bindUser.bindTheNewUser.selected', defaultMessage: '已选', })}{' '} {selectedRowKeys.length}{' '} {intl.formatMessage({ id: 'pages.bindUser.bindTheNewUser.item', defaultMessage: '项', })} {intl.formatMessage({ id: 'pages.bindUser.bindTheNewUser.deselect', defaultMessage: '取消选择', })} )} toolBarRender={() => [ { setVisible(true); }} type={'primary'} > 绑定通道 , { if (selectedRowKey.length > 0) { unbind(selectedRowKey); setSelectedRowKey([]); } else { message.error('请先选择需要解绑的通道列表'); } }, }} > 批量解绑 , ]} /> {visible && ( { setVisible(false); actionRef.current?.reload(); }} /> )} ); }; export default Channel;