|
|
@ -1,7 +1,7 @@ |
|
|
|
import React, { useEffect, useState, useMemo } from 'react'; |
|
|
|
import { connect } from 'react-redux'; |
|
|
|
import { Input, Button, Tree, Modal, Table, Upload, Pagination, Popconfirm } from '@douyinfe/semi-ui'; |
|
|
|
import { IconDeleteStroked, IconEditStroked, IconUpload, IconAlertCircle } from '@douyinfe/semi-icons'; |
|
|
|
import { IconDeleteStroked, IconEditStroked, IconUpload, IconAlertCircle, IconSearch } from '@douyinfe/semi-icons'; |
|
|
|
import SimpleBar from 'simplebar-react'; |
|
|
|
import FileModal from '../components/fileModal'; |
|
|
|
import moment from 'moment'; |
|
|
@ -29,12 +29,12 @@ const Rest = (props) => { |
|
|
|
const [videoModalV, setVideoModalV] = useState(false); |
|
|
|
const [videoUrl, setvideoUrl] = useState(null); |
|
|
|
const [hint, setHint] = useState(false); |
|
|
|
const [fileLists, setFileLists] = useState([]) |
|
|
|
const [fileSearch, setFileSearch] = useState([]) //文件搜索 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
dispatch(install.getProjectPoms({ global: 4 })).then((res => { |
|
|
|
dispatch(install.getProjectPoms({ global: 1 })).then((res => { |
|
|
|
if (res.success) { |
|
|
|
let data = res.payload.data?.rows?.filter(v => v.pepProjectIsDelete !== 1)?.map(v => ({ pepProjectId: v.id, pepProjectName: v.pepProjectName || v.name })) |
|
|
|
setPomsList(data) |
|
|
@ -56,6 +56,9 @@ const Rest = (props) => { |
|
|
|
setShowPomsList(data) |
|
|
|
setPepProjectId(data[0]?.pepProjectId) |
|
|
|
fileList(data[0]?.pepProjectId) |
|
|
|
setDataSource([]) |
|
|
|
setFileId('') |
|
|
|
setFileSearch('') |
|
|
|
}, [projectSearch]) |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
@ -69,25 +72,29 @@ const Rest = (props) => { |
|
|
|
setShowPomsList(data) |
|
|
|
setPepProjectId(data[0]?.pepProjectId) |
|
|
|
fileList(data[0]?.pepProjectId) |
|
|
|
setDataSource([]) |
|
|
|
setFileId('') |
|
|
|
setFileSearch('') |
|
|
|
}, [overallProjectId]) |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
if (fileId) { |
|
|
|
filfolderFileListe() |
|
|
|
setQuery({ limit: 10, page: 0 }) |
|
|
|
setFileSearch('') |
|
|
|
} |
|
|
|
}, [fileId]) |
|
|
|
|
|
|
|
const fileList = (id) => { |
|
|
|
|
|
|
|
dispatch(means.fileList({ projectId: id, type: 1 })).then((res => { |
|
|
|
|
|
|
|
dispatch(means.fileList({ projectId: id, type: 4 })).then((res => { |
|
|
|
if (res.success) { |
|
|
|
let data = res.payload.data |
|
|
|
let oneLevel = res.payload.data?.filter(f => !f.higherFileId) || [] |
|
|
|
setHigherFile(data?.map(d => ({ name: d.fileName, value: d.id }))) |
|
|
|
dispatch(means.folderFileList({ fileId: JSON.stringify(data?.map(d => d.id)) })).then((s => { |
|
|
|
if (s.success) { |
|
|
|
setFileLists(s.payload.data?.rows) |
|
|
|
// setFileLists(s.payload.data?.rows) |
|
|
|
settreeData(listErgodic(oneLevel, data, s.payload.data?.rows)) |
|
|
|
} |
|
|
|
})) |
|
|
@ -113,7 +120,7 @@ const Rest = (props) => { |
|
|
|
} |
|
|
|
treeDataList(treeData) |
|
|
|
let datas = params || query |
|
|
|
dispatch(means.folderFileList({ fileId: JSON.stringify(fileIds), ...datas })).then((res => { |
|
|
|
dispatch(means.folderFileList({ keyword: fileSearch, fileId: JSON.stringify(fileIds), ...datas, })).then((res => { |
|
|
|
if (res.success) { |
|
|
|
setDataSource(res.payload.data?.rows || []) |
|
|
|
setCount(res.payload.data?.count) |
|
|
@ -277,6 +284,8 @@ const Rest = (props) => { |
|
|
|
onClick={() => { |
|
|
|
setPepProjectId(v.pepProjectId) |
|
|
|
fileList(v.pepProjectId) |
|
|
|
setDataSource([]) |
|
|
|
setFileId('') |
|
|
|
}}> |
|
|
|
<img src="/assets/images/icon/project-icon.png" style={{ width: 14, marginRight: 8 }} /> |
|
|
|
<div style={{ fontSize: 14, width: 152, whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}> {v.pepProjectName}</div> |
|
|
@ -301,7 +310,7 @@ const Rest = (props) => { |
|
|
|
editData={editData} |
|
|
|
higherFile={higherFile} |
|
|
|
pepProjectId={pepProjectId} |
|
|
|
type={4} |
|
|
|
type={1} |
|
|
|
close={() => { |
|
|
|
setIsFileModal(false) |
|
|
|
setEditData({}) |
|
|
@ -315,10 +324,11 @@ const Rest = (props) => { |
|
|
|
<Tree |
|
|
|
treeData={treeData} |
|
|
|
defaultExpandAll |
|
|
|
// labelEllipsis={true} |
|
|
|
value={fileId} |
|
|
|
// style={style} |
|
|
|
onSelect={(selectedKey, selected, selectedNode) => { |
|
|
|
setFileId(selectedKey) |
|
|
|
setFileSearch('') |
|
|
|
}} |
|
|
|
/> |
|
|
|
</SimpleBar> |
|
|
@ -329,13 +339,27 @@ const Rest = (props) => { |
|
|
|
flex: 1, height: '100%', |
|
|
|
// border: '1px solid rgb(24 22 22)' |
|
|
|
}}> |
|
|
|
<div style={{ margin: '20px 0 10px 10px', display: 'flex', alignItems: 'center' }}> |
|
|
|
<Button theme='solid' type='primary' style={{ width: 80, background: '#005ABD', marginRight: 10 }} onClick={() => { |
|
|
|
if (higherFile?.filter(c => c.value == fileId)?.length) { |
|
|
|
setUploadModal(true) |
|
|
|
} |
|
|
|
}}> 上传 </Button> |
|
|
|
<div style={{ display: 'flex' }}>当前文件夹:{higherFile?.filter(c => c.value == fileId)[0]?.name || <div style={{ color: '#c31515' }}>请选择文件夹</div>}</div> |
|
|
|
<div style={{ margin: '20px 0 10px 10px', display: 'flex', alignItems: 'center', width: 'calc(100% - 20px)' }}> |
|
|
|
<div style={{ width: '100%', display: 'flex', justifyContent: 'space-between' }}> |
|
|
|
<div style={{ display: 'flex', alignItems: 'center' }}> |
|
|
|
<Button theme='solid' type='primary' style={{ width: 80, background: '#005ABD', marginRight: 10 }} onClick={() => { |
|
|
|
if (higherFile?.filter(c => c.value == fileId)?.length) { |
|
|
|
setUploadModal(true) |
|
|
|
} |
|
|
|
}}> 上传 </Button> |
|
|
|
<div style={{ display: 'flex' }}>当前文件夹:{higherFile?.filter(c => c.value == fileId)[0]?.name || <div style={{ color: '#c31515' }}>请选择文件夹</div>}</div> |
|
|
|
</div> |
|
|
|
<Input placeholder='请输入文件名称' |
|
|
|
style={{ width: 220 }} |
|
|
|
suffix={<IconSearch />} |
|
|
|
value={fileSearch} |
|
|
|
onChange={v => { |
|
|
|
setFileSearch(v) |
|
|
|
filfolderFileListe({ keyword: v, limit: 10, page: 0 }) |
|
|
|
setQuery({ limit: 10, page: 0 }) |
|
|
|
}} /> |
|
|
|
</div> |
|
|
|
|
|
|
|
{uploadModal ? |
|
|
|
<Modal |
|
|
|
title={'上传文件'} |
|
|
@ -370,7 +394,7 @@ const Rest = (props) => { |
|
|
|
style={{ display: 'inline-block' }} |
|
|
|
action="/_upload/attachments" |
|
|
|
accept={'.txt, .doc, .docx, .xls, .xlsx, .pdf, .png, .jpg, .rar, .zip'} |
|
|
|
limit={1} |
|
|
|
limit={4} |
|
|
|
maxSize={51200} |
|
|
|
onRemove={() => { |
|
|
|
setUploadData({}) |
|
|
@ -441,6 +465,7 @@ const Rest = (props) => { |
|
|
|
total={count} |
|
|
|
showSizeChanger |
|
|
|
currentPage={(query?.page || 0) + 1} |
|
|
|
pageSize={query?.limit || 10} |
|
|
|
pageSizeOpts={[10, 20, 50]} |
|
|
|
onChange={(currentPage, pageSize) => { |
|
|
|
setQuery({ limit: pageSize, page: currentPage - 1 }); |
|
|
|