import type { ActionType, ProColumns, ProCoreActionType, } from '@ant-design/pro-components'; import { Popconfirm } from 'antd'; import React, { useCallback, useRef, useState } from 'react'; import ConfigurableDrawerForm, { type ConfigurableDrawerFormRef, } from '@/components/DrawerForm'; import EnhancedProTable from '@/components/EnhancedProTable'; import { formStatusType } from '@/constants'; import { createNotice, deleteNotice, getNoticePage, type NoticeVO, pushNotice, updateNotice, } from '@/services/system/message/notice'; import { baseTenantColumns, formColumns } from './config'; const SyStemMessageNotice = () => { const tableRef = useRef(null); const configurableDrawerRef = useRef(null); const [type, setType] = useState<'create' | 'update'>('create'); const [id, setId] = useState(0); const onFetch = async ( params: NoticeVO & { pageSize?: number; current?: number; }, ) => { const data = await getNoticePage({ ...params, pageNo: params.current, pageSize: params.pageSize, }); return { data: data.list, success: true, total: data.total, }; }; const handleSend = async (record: NoticeVO) => { await pushNotice(record.id); tableRef.current?.reload(); }; const handleEdit = (record: NoticeVO) => { setType('update'); setId(record.id); configurableDrawerRef.current?.open(record); }; const handleSubmit = useCallback( async (values: NoticeVO) => { if (type === 'create') { await createNotice(values); } else { await updateNotice({ ...values, id, }); } tableRef.current?.reload(); return true; }, [type, id], ); const actionColumns: ProColumns = { title: '操作', dataIndex: 'option', valueType: 'option', fixed: 'right', width: 120, render: ( text: React.ReactNode, record: NoticeVO, _: number, action: ProCoreActionType | undefined, ) => [ handleEdit(record)}> 编辑 , { await deleteNotice(record.id); action?.reload?.(); }} okText="是" cancelText="否" > 删除 , handleSend(record)}> 推送 , ], }; const columns = [...baseTenantColumns, actionColumns]; return ( <> ref={tableRef} columns={columns} request={onFetch} headerTitle="登录日志" showIndex={false} showSelection={false} /> ); }; export default SyStemMessageNotice;