import { Button, Input, Modal, Table } from 'antd' import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' import styles from './index.module.scss' import { getGoodsListAllAPI } from '@/store/action/object4' import { useDispatch, useSelector } from 'react-redux' import { RootState } from '@/store' import ImageLazy from '@/components/ImageLazy' import '../../Object3/AddObject3/GoodsAll.css' import { MessageFu } from '@/utils/message' type Props = { colsePage: any addPage: boolean } function GoodsAll({ colsePage, addPage }: Props) { const dispatch = useDispatch() // 进页面获取列表 useEffect(() => { dispatch(getGoodsListAllAPI('')) }, [dispatch]) // 藏品名称 const [name, setName] = useState('') const nameTime = useRef(-1) const nameChange = useCallback( (e: React.ChangeEvent) => { setName(e.target.value) clearTimeout(nameTime.current) nameTime.current = window.setTimeout(() => { dispatch(getGoodsListAllAPI(e.target.value)) }, 500) }, [dispatch] ) // 有关表格 const results = useSelector((state: RootState) => state.object4Store.goodsAllList) // 已经选中的表格数据 const resultsAc = useSelector((state: RootState) => state.object4Store.goodsTableList) const columns = useMemo(() => { return [ { title: '缩略图', render: (item: any) => }, { title: '藏品编号名称', dataIndex: 'dictNum' }, { title: '藏品编号', render: (item: any) => (item.num ? item.num : '-') }, { title: '藏品名称', dataIndex: 'name' }, { title: '类别', dataIndex: 'dictGoodType' } ] }, []) // 选中的表格数据 const [tableSelectList, setTableSelectList] = useState([]) // 表格的多选 const rowSelection = useMemo(() => { return { onChange: (selectedRowKeys: any, selectedRows: any) => { setTableSelectList(selectedRows) }, // 默认选中 defaultSelectedRowKeys: resultsAc.map((v: any) => v.id) } }, [resultsAc]) // 点击确定 const btnOkFu = useCallback(() => { dispatch({ type: 'object4/getGoodsTableList', payload: tableSelectList.map((v: any) => { return { ...v, outLocation: '' } }) }) MessageFu.success('添加成功!') colsePage() }, [colsePage, dispatch, tableSelectList]) return (
藏品编号: nameChange(e)} />

) } const MemoGoodsAll = React.memo(GoodsAll) export default MemoGoodsAll