import { PageContainer } from '@ant-design/pro-layout'; import type { ActionType, ProColumns } from '@jetlinks/pro-table'; import ProTable from '@jetlinks/pro-table'; import { useRef, useState } from 'react'; import { useIntl } from '@@/plugin-locale/localeExports'; import { BadgeStatus, PermissionButton } from '@/components'; import SearchComponent from '@/components/SearchComponent'; import { DeleteOutlined, EditOutlined, PlusOutlined } from '@ant-design/icons'; import { StatusColorEnum } from '@/components/BadgeStatus'; import SaveModal from './save'; import PasswordModal from './password'; import Service from './service'; import { message } from 'antd'; export const service = new Service('platforms'); export default () => { const actionRef = useRef(); const intl = useIntl(); const [param, setParam] = useState({}); const [saveVisible, setSaveVisible] = useState(false); const [passwordVisible, setPasswordVisible] = useState(false); const { permission } = PermissionButton.usePermission('system/Platforms'); const deleteById = async (id: string) => { const resp: any = await service.remove(id); if (resp.status === 200) { message.success('操作成功'); actionRef.current?.reload(); } }; const columns: ProColumns[] = [ { dataIndex: 'name', title: '名称', }, { dataIndex: 'accessName', title: '用户名', }, { dataIndex: 'role', title: '角色', }, { dataIndex: 'state', title: intl.formatMessage({ id: 'pages.searchTable.titleStatus', defaultMessage: '状态', }), width: 160, valueType: 'select', renderText: (record) => record ? ( ) : ( '' ), valueEnum: { disable: { text: '禁用', status: 'offline', }, started: { text: '正常', status: 'started', }, }, }, { dataIndex: 'description', title: intl.formatMessage({ id: 'pages.system.description', defaultMessage: '说明', }), hideInSearch: true, }, { title: intl.formatMessage({ id: 'pages.data.option', defaultMessage: '操作', }), valueType: 'option', align: 'center', width: 200, render: (_, record) => [ {}} > , {}} > , {}} > , { setPasswordVisible(true); }} > , { deleteById(record.id); }, }} tooltip={{ title: record.state.value === 'started' ? 请先禁用,再删除 : 删除, }} onClick={() => {}} > , ], }, ]; return ( { // 重置分页数据 actionRef.current?.reset?.(); setParam(data); }} /> { setSaveVisible(true); }} icon={} > {intl.formatMessage({ id: 'pages.data.option.add', defaultMessage: '新增', })} } /> { setSaveVisible(false); }} onReload={() => { actionRef.current?.reload(); }} /> { setPasswordVisible(false); }} onReload={() => { actionRef.current?.reload(); }} /> ); };