import { Button, Form, FormInstance, Input, Table } from "antd"; import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { debounce } from "lodash"; import { DageTableActions } from "@dage/pc-components"; import { messageApi } from "@/api"; const DEFAULT_PARAMS = { pageNum: 1, pageSize: 20, searchKey: "", }; export default function MessagePage() { const formRef = useRef(null); const [loading, setLoading] = useState(false); const [list, setList] = useState<[]>([]); const [params, setParams] = useState({ ...DEFAULT_PARAMS, }); const [total, setTotal] = useState(0); const getList = useCallback(async () => { setLoading(true); try { const data = await messageApi.getList(params); setList(data.records); setTotal(data.total); } finally { setLoading(false); } }, [params]); useEffect(() => { getList(); }, [getList]); const handleDelete = useCallback( async (id: number) => { await messageApi.delete(id); getList(); }, [getList] ); const COLUMNS = useMemo(() => { return [ { title: "留言时间", dataIndex: "updateTime", }, { title: "称号", dataIndex: "name", }, { title: "联系方式", dataIndex: "phone", }, { title: "正文", dataIndex: "content", }, { title: "操作", render: (item: any) => { return ( ); }, }, ]; }, [handleDelete]); const handleReset = useCallback(() => { setParams({ ...DEFAULT_PARAMS }); setTimeout(() => { formRef.current?.resetFields(); }); }, [formRef]); const debounceSearch = useMemo( () => debounce((changedVal: unknown, vals: any) => { setParams({ ...params, ...vals }); }, 500), [params] ); const paginationChange = useCallback( () => (pageNum: number, pageSize: number) => { setParams({ ...params, pageNum, pageSize }); }, [params] ); return (
); }