import React, { useEffect, useState, useRef } from 'react' import { connect } from 'react-redux'; import moment from 'moment'; import { RouteRequest } from '@peace/utils'; import { RouteTable } from '$utils' import SimpleBar from 'simplebar-react'; import FileModal from '../components/fileModal'; import { Tabs, Form, Input, Space, Button, Table, Checkbox, message, Pagination } from 'antd'; const { Search } = Input; import { CreditCardFilled, FilePdfOutlined } from '@ant-design/icons'; import { agent } from 'superagent'; const CheckboxGroup = Checkbox.Group; function SpecificationLibrary ({ loading, clientHeight, actions, dispatch, }) { const { resourceRetrieval } = actions const [checkAll, setCheckAll] = useState(false) const [query, setQuery] = useState({ page: 0, limit: 20 }); const [folderData, setFolderData] = useState([]); const [fileData, setFileData] = useState({ data: [], count: 0 }) const [groupModal, setGroupModal] = useState(false) const [fileModal, setFileModal] = useState(false) const [keyword, setKeywords] = useState() const [fileIds, setFileIds] = useState([]) const fileId = useRef([]) useEffect(() => { resourceData() }, []) let resourceData = (data) => { let params = data || query dispatch(resourceRetrieval.getSpecifications({ keyword: keyword, ...params, })).then(res => { if (res.success) { setFileData({ data: res.payload.data?.rows, count: res.payload.data?.count }) } }) } return <>
{ setKeywords(e?.target?.value) }} onSearch={(value, event) => { setKeywords(value) resourceData({ page: 0, limit: 10, keyword: value }) }} style={{ width: 266, }} />
{ fileData?.data?.map((v, i) => { return
{ if (fileId.current?.includes(v.id)) { fileId.current = fileId.current?.filter(c => c != v.id) setFileIds(fileId.current?.filter(c => c != v.id)) } else { fileId.current = [...fileId.current, v.id] setFileIds([...fileId.current, v.id]) } }}>
{v.fileName}
标签:{v.tags || '--'}
创建时间:{v.createAt && moment(v.createAt).format('YYYY-MM-DD HH:mm:ss') || '--'}
}) } {fileData?.count > 20 &&
`共 ${total} 个文件`} onChange={(page, pageSize) => { console.log({ page: page - 1, limit: pageSize, }); setQuery({ page: page - 1, limit: pageSize, }) resourceData({ page: page - 1, limit: pageSize, keyword: keyword }) }} />
}
{ fileModal ? { setFileModal(false); }} success={() => { resourceData({ page: 0, limit: 10, keyword: keyword }) }} remove={url => { RouteRequest.delete(RouteTable.cleanUpUploadTrash, { url: url }); }} /> : "" } } function mapStateToProps (state) { const { global, auth, resourceCatalog } = state; return { user: auth.user, actions: global.actions, clientHeight: global.clientHeight, // resourceCatalog: resourceCatalog?.data || [], // isRequesting: resourceCatalog.isRequesting }; } export default connect(mapStateToProps)(SpecificationLibrary)