|
@ -1,7 +1,7 @@ |
|
|
import React, { useEffect, useState, useRef } from 'react'; |
|
|
import React, { useEffect, useState, useRef } from 'react'; |
|
|
import { connect } from 'react-redux'; |
|
|
import { connect } from 'react-redux'; |
|
|
import moment from 'moment'; |
|
|
import moment from 'moment'; |
|
|
import { Button, Col, Row, Input, Tree, Table, Space, Tooltip, Spin, Popconfirm } from '@douyinfe/semi-ui'; |
|
|
import { Button, Col, Row, Input, Tree, Table, Space, Tooltip, Spin, Popconfirm, Pagination, DatePicker } from '@douyinfe/semi-ui'; |
|
|
import { IconSearch, IconEditStroked, IconMinusCircleStroked, IconPlusCircleStroked } from '@douyinfe/semi-icons'; |
|
|
import { IconSearch, IconEditStroked, IconMinusCircleStroked, IconPlusCircleStroked } from '@douyinfe/semi-icons'; |
|
|
import { |
|
|
import { |
|
|
getResourceFileList, postResourceFile, delResourceFile, |
|
|
getResourceFileList, postResourceFile, delResourceFile, |
|
@ -14,11 +14,14 @@ import '../style.less'; |
|
|
const ResourceRepository = (props) => { |
|
|
const ResourceRepository = (props) => { |
|
|
const { dispatch, clientHeight, apiRoot, user, resourceClassify, resourceFilelist, isRequesting } = props; |
|
|
const { dispatch, clientHeight, apiRoot, user, resourceClassify, resourceFilelist, isRequesting } = props; |
|
|
const [treeData, setTreeData] = useState([]); |
|
|
const [treeData, setTreeData] = useState([]); |
|
|
const [currentSelect, setCurrentSelect] = useState(); |
|
|
const [currentSelect, setCurrentSelect] = useState("公司培训资料"); |
|
|
const [defaultExpandedKey, setDefaultExpandedKey] = useState(); |
|
|
const [defaultExpandedKey, setDefaultExpandedKey] = useState(); |
|
|
const [modelVisiable, setModelVisiable] = useState(false); |
|
|
const [modelVisiable, setModelVisiable] = useState(false); |
|
|
const [modalData, setModalData] = useState(); |
|
|
const [modalData, setModalData] = useState(); |
|
|
const [uploadModalVisiable, setUploadModalVisiable] = useState(false); |
|
|
const [uploadModalVisiable, setUploadModalVisiable] = useState(false); |
|
|
|
|
|
const [paginationQuery, setPaginatioQuery] = useState({ limit: 10, page: 0 }); //页码信息 |
|
|
|
|
|
const [keyword, setKeyword] = useState();//文件名称过滤 |
|
|
|
|
|
const [dataRange, setDataRange] = useState();//更新时间过滤 |
|
|
const ref = useRef(); |
|
|
const ref = useRef(); |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
useEffect(() => { |
|
@ -93,7 +96,10 @@ const ResourceRepository = (props) => { |
|
|
} |
|
|
} |
|
|
const handleSelect = (e) => { |
|
|
const handleSelect = (e) => { |
|
|
setCurrentSelect(e); |
|
|
setCurrentSelect(e); |
|
|
getFile(e); |
|
|
setPaginatioQuery({ limit: 10, page: 0 }); |
|
|
|
|
|
setKeyword(null); |
|
|
|
|
|
setDataRange(null); |
|
|
|
|
|
getFile(e, { limit: 10, page: 0 }, { restSearch: true }); |
|
|
} |
|
|
} |
|
|
const handleDataToSave = (add, body) => { |
|
|
const handleDataToSave = (add, body) => { |
|
|
if (add) { |
|
|
if (add) { |
|
@ -154,11 +160,25 @@ const ResourceRepository = (props) => { |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
const getFile = (e) => { |
|
|
const handleSearch = () => { |
|
|
const arr = e.split("/"); |
|
|
setPaginatioQuery({ limit: 10, page: 0 }); |
|
|
const query = { type: arr[0] }; |
|
|
getFile(null, { limit: 10, page: 0 }); |
|
|
|
|
|
} |
|
|
|
|
|
const getFile = (e, pagination, opt) => { |
|
|
|
|
|
const arr = e ? e.split("/") : currentSelect.split("/"); |
|
|
|
|
|
const query = pagination ? { ...pagination, type: arr[0] } : { ...paginationQuery, type: arr[0] }; |
|
|
|
|
|
if (opt && opt.restSearch) { |
|
|
|
|
|
//选中树节点重置 |
|
|
|
|
|
} else { |
|
|
|
|
|
if (keyword) { query.keyword = keyword; } |
|
|
|
|
|
if (dataRange) { |
|
|
|
|
|
query.startTime = moment(dataRange[0]).format('YYYY-MM-DD HH:mm:ss'); |
|
|
|
|
|
query.endTime = moment(dataRange[1]).format('YYYY-MM-DD HH:mm:ss'); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
if (arr[1]) { query.departmentName = arr[1]; } |
|
|
if (arr[1]) { query.departmentName = arr[1]; } |
|
|
if (arr[2]) { query.trainDate = arr[2]; } |
|
|
if (arr[2]) { query.trainDate = arr[2]; } |
|
|
|
|
|
|
|
|
dispatch(getResourceFileList(query)); |
|
|
dispatch(getResourceFileList(query)); |
|
|
} |
|
|
} |
|
|
const getClassify = () => { |
|
|
const getClassify = () => { |
|
@ -212,7 +232,7 @@ const ResourceRepository = (props) => { |
|
|
defaultExpandAll={true} |
|
|
defaultExpandAll={true} |
|
|
treeData={treeData} |
|
|
treeData={treeData} |
|
|
style={style} |
|
|
style={style} |
|
|
value={currentSelect} |
|
|
value={[currentSelect]} |
|
|
expandedKeys={defaultExpandedKey} |
|
|
expandedKeys={defaultExpandedKey} |
|
|
filterTreeNode={true} |
|
|
filterTreeNode={true} |
|
|
searchRender={false} |
|
|
searchRender={false} |
|
@ -225,21 +245,59 @@ const ResourceRepository = (props) => { |
|
|
</Col> |
|
|
</Col> |
|
|
{/* 右侧内容 */} |
|
|
{/* 右侧内容 */} |
|
|
<Col span={18} className='right'> |
|
|
<Col span={18} className='right'> |
|
|
<Row type="flex" justify="space-around" align="middle"> |
|
|
<Row> <span className="path-lable"><strong>当前文件夹:{currentSelect}</strong></span></Row> |
|
|
<Col span={18}> |
|
|
<Row className='search'> |
|
|
<Space> |
|
|
<Space> |
|
|
{currentSelect && currentSelect.includes("公司培训资料") && currentSelect.split("/").length == 3 ? <Button theme='solid' type='primary' onClick={() => { setUploadModalVisiable(true) }} >上传文件</Button> : null} |
|
|
{currentSelect && currentSelect.includes("公司培训资料") && currentSelect.split("/").length == 3 ? |
|
|
<span className="path-lable"><strong>当前文件夹:{currentSelect}</strong></span> |
|
|
<Button theme='solid' type='primary' onClick={() => { setUploadModalVisiable(true) }} >上传文件</Button> |
|
|
|
|
|
: null} |
|
|
|
|
|
<span className='search-label'>关键字</span> |
|
|
|
|
|
<Input |
|
|
|
|
|
style={{ width: 160 }} |
|
|
|
|
|
// suffix={<IconSearch />} |
|
|
|
|
|
showClear |
|
|
|
|
|
placeholder="文件名称" |
|
|
|
|
|
value={keyword} |
|
|
|
|
|
onChange={(value) => { setKeyword(value) }} |
|
|
|
|
|
></Input> |
|
|
|
|
|
<span className='search-label'>更新时间范围</span> |
|
|
|
|
|
<DatePicker |
|
|
|
|
|
style={{ width: 350 }} |
|
|
|
|
|
value={dataRange} |
|
|
|
|
|
type="dateTimeRange" |
|
|
|
|
|
density="compact" |
|
|
|
|
|
onChange={(data) => { setDataRange(data) }} |
|
|
|
|
|
onClear={() => { setDataRange(null) }} |
|
|
|
|
|
/> |
|
|
|
|
|
<Button onClick={handleSearch}>搜索</Button> |
|
|
</Space> |
|
|
</Space> |
|
|
</Col> |
|
|
|
|
|
<Col span={6} > |
|
|
|
|
|
<Input suffix={<IconSearch />} showClear placeholder="文件名称、更新时间"></Input> |
|
|
|
|
|
</Col> |
|
|
|
|
|
</Row> |
|
|
</Row> |
|
|
<Table |
|
|
<Table |
|
|
columns={columns} |
|
|
columns={columns} |
|
|
dataSource={resourceFilelist && resourceFilelist.rows || []} |
|
|
dataSource={resourceFilelist && resourceFilelist.rows || []} |
|
|
pagination={false} /> |
|
|
pagination={false} /> |
|
|
|
|
|
<div style={{ |
|
|
|
|
|
display: "flex", |
|
|
|
|
|
justifyContent: "space-between", |
|
|
|
|
|
padding: "20px 20px", |
|
|
|
|
|
}}> |
|
|
|
|
|
<div></div> |
|
|
|
|
|
<div style={{ display: 'flex', }}> |
|
|
|
|
|
<span style={{ lineHeight: "30px", fontSize: 13, color: 'rgba(0,90,189,0.8)' }}> |
|
|
|
|
|
共{resourceFilelist && resourceFilelist.count}条信息 |
|
|
|
|
|
</span> |
|
|
|
|
|
<Pagination |
|
|
|
|
|
total={resourceFilelist && resourceFilelist.count} |
|
|
|
|
|
showSizeChanger |
|
|
|
|
|
currentPage={paginationQuery.page + 1} |
|
|
|
|
|
pageSizeOpts={[10, 20, 30, 40]} |
|
|
|
|
|
onChange={(currentPage, pageSize) => { |
|
|
|
|
|
setPaginatioQuery({ limit: pageSize, page: currentPage - 1 }); |
|
|
|
|
|
getFile(currentSelect, { limit: pageSize, page: currentPage - 1 }); |
|
|
|
|
|
}} |
|
|
|
|
|
/> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
</Col> |
|
|
</Col> |
|
|
</Row> |
|
|
</Row> |
|
|
</Spin> |
|
|
</Spin> |
|
|