import React, { useCallback, useEffect, useMemo, useState } from 'react' import styles from './index.module.scss' import { Button, Input, Select } from 'antd' import { useDispatch, useSelector } from 'react-redux' import { A1EditInfoType } from './data' import { A7_APIdel, A7_APIgetList, A7_APIpublish } from '@/store/action/A7collection' import { RootState } from '@/store' import { MessageFu } from '@/utils/message' import { A7tableType } from '@/types/api/A7collection' import MyPopconfirm from '@/components/MyPopconfirm' import MyTable from '@/components/MyTable' import { A7tableC } from '@/utils/tableData' import A7add from './A7add' import { handleCopyClick } from '@/utils/copyTxt' import { editPreview } from '@/store/action/layout' import { baseURL } from '@/utils/http' const pageDataBase = { pageNum: 1, pageSize: 10 } function A7collection() { const dispatch = useDispatch() const [pageData, setPageData] = useState(pageDataBase) const [title, setTitle] = useState('') const [type, setType] = useState(0) const getListFu = useCallback( (title?: string) => { // status: -1 全部 0 未发布 1 已发布 dispatch(A7_APIgetList({ ...pageData, status: -1, title, type })) }, [dispatch, pageData, type] ) useEffect(() => { getListFu() }, [getListFu]) // 点击重置 const resetSelectFu = useCallback(() => { setPageData({ ...pageDataBase }) }, []) const tableInfo = useSelector((state: RootState) => state.A7collection.tableInfo) const delTableFu = useCallback( async (id: number) => { const res = await A7_APIdel(id) if (res.code === 0) { MessageFu.success('删除成功!') if (tableInfo.list.length === 1 && pageData.pageNum > 1) { setPageData({ ...pageData, pageNum: pageData.pageNum - 1 }) } getListFu() } }, [getListFu, pageData, tableInfo.list.length] ) const publishFu = useCallback( async (id: number) => { const res = await A7_APIpublish(id) if (res.code === 0) { MessageFu.success('发布成功!') getListFu() } }, [getListFu] ) const tableLastBtn = useMemo(() => { return [ { title: '操作', render: (item: A7tableType) => ( <> {item.status === 0 && ( )} {item.status === 0 && ( )} delTableFu(item.artifactId)} /> ) } ] }, [delTableFu, dispatch, publishFu]) //新增、编辑 const [editInfo, setEditInfo] = useState({ id: 0, txt: '' }) return (
克博典藏 {editInfo.id ? ` - ${editInfo.txt}` : ''}
{/* 顶部筛选 */}
setTitle(e.target.value)} value={title} />
类别: