add space file list

This commit is contained in:
seaheart
2023-06-16 23:03:07 +08:00
parent 57237c254a
commit 792bb5ddaf
9 changed files with 156 additions and 90 deletions
+19 -8
View File
@@ -16,6 +16,7 @@ import SafeUtil from '../../util/SafeUtil';
import ImagePreviewer from '../../../pages/widget/previewer/ImagePreviewer';
import MessageBoxUtil from '../../util/MessageBoxUtil';
import PreviewerHelper from '../../../pages/widget/previewer/PreviewerHelper';
import HttpBase from '../base/HttpBase';
export default class Matter extends BaseEntity {
puuid: string = '';
@@ -34,6 +35,7 @@ export default class Matter extends BaseEntity {
// 文件是否被软删除
deleted: boolean = false;
deleteTime: Date | null = null;
spaceUuid: string | null = null;
/*
这部分是辅助UI的字段信息
@@ -129,6 +131,7 @@ export default class Matter extends BaseEntity {
new InputFilter('提取码', 'shareCode'),
new InputFilter('分享根目录', 'shareRootUuid'),
new SortFilter('删除时间排序', 'orderDeleteTime'),
new InputFilter('空间uuid', 'spaceUuid'),
];
}
@@ -240,12 +243,12 @@ export default class Matter extends BaseEntity {
);
}
httpSoftDeleteBatch(
static httpSoftDeleteBatch(
uuids: string,
successCallback?: any,
errorCallback?: any
) {
this.httpPost(
new HttpBase().httpPost(
Matter.URL_MATTER_SOFT_DELETE_BATCH,
{ uuids: uuids },
function (response: any) {
@@ -266,8 +269,12 @@ export default class Matter extends BaseEntity {
);
}
httpDeleteBatch(uuids: string, successCallback?: any, errorCallback?: any) {
this.httpPost(
static httpDeleteBatch(
uuids: string,
successCallback?: any,
errorCallback?: any
) {
new HttpBase().httpPost(
Matter.URL_MATTER_DELETE_BATCH,
{ uuids: uuids },
function (response: any) {
@@ -288,8 +295,12 @@ export default class Matter extends BaseEntity {
);
}
httpRecoveryBatch(uuids: string, successCallback?: any, errorCallback?: any) {
this.httpPost(
static httpRecoveryBatch(
uuids: string,
successCallback?: any,
errorCallback?: any
) {
new HttpBase().httpPost(
Matter.URL_MATTER_RECOVERY_BATCH,
{ uuids: uuids },
function (response: any) {
@@ -340,7 +351,7 @@ export default class Matter extends BaseEntity {
);
}
httpMove(
static httpMove(
srcUuids: string,
destUuid: string,
successCallback?: any,
@@ -352,7 +363,7 @@ export default class Matter extends BaseEntity {
} else {
form.destUuid = 'root';
}
this.httpPost(
new HttpBase().httpPost(
Matter.URL_MATTER_MOVE,
form,
function (response: any) {
+6
View File
@@ -46,6 +46,7 @@ import ContentLayout from './layout/ContentLayout';
import SpaceList from './space/List';
import SpaceMemberList from './space/member/List';
import SpaceMatterList from './space/matter/List';
interface IProps extends RouteComponentProps<{}> {}
@@ -182,6 +183,11 @@ class RawFrame extends TankComponent<IProps, IState> {
exact
component={SpaceMemberList}
/>
<Route
path="/space/:spaceUuid/matter/list"
exact
component={SpaceMatterList}
/>
</div>
) : (
<div className="pages-content">
+2 -2
View File
@@ -120,7 +120,7 @@ export default class List extends TankComponent<IProps, IState> {
icon: <ExclamationCircleFilled twoToneColor="#FFDC00" />,
onOk: () => {
const uuids = this.selectedMatters.map((i) => i.uuid).toString();
this.matter.httpDeleteBatch(uuids, () => {
Matter.httpDeleteBatch(uuids, () => {
MessageBoxUtil.success(Lang.t('operationSuccess'));
this.refresh();
});
@@ -134,7 +134,7 @@ export default class List extends TankComponent<IProps, IState> {
icon: <ExclamationCircleFilled twoToneColor="#FFDC00" />,
onOk: () => {
const uuids = this.selectedMatters.map((i) => i.uuid).toString();
this.matter.httpRecoveryBatch(uuids, () => {
Matter.httpRecoveryBatch(uuids, () => {
MessageBoxUtil.success(Lang.t('operationSuccess'));
this.refresh();
});
+3
View File
@@ -24,4 +24,7 @@
display: flex;
flex-wrap: wrap;
}
.matter-pagination {
margin-top: 10px;
}
}
+85 -74
View File
@@ -1,5 +1,4 @@
import React, { Children } from 'react';
import { RouteComponentProps } from 'react-router-dom';
import './List.less';
import TankComponent from '../../common/component/TankComponent';
import Pager from '../../common/model/base/Pager';
@@ -17,7 +16,7 @@ import {
Modal,
Pagination,
Row,
Space,
Space as AntdSpace,
Upload,
} from 'antd';
import MessageBoxUtil from '../../common/util/MessageBoxUtil';
@@ -35,7 +34,6 @@ import {
} from '@ant-design/icons';
import ImagePreviewer from '../widget/previewer/ImagePreviewer';
import Sun from '../../common/model/global/Sun';
import { UserRole } from '../../common/model/user/UserRole';
import StringUtil from '../../common/util/StringUtil';
import MoveBatchModal from './widget/MoveBatchModal';
import ShareOperationModal from './widget/ShareOperationModal';
@@ -50,15 +48,22 @@ import SafeUtil from '../../common/util/SafeUtil';
import MatterSortPanel from './widget/MatterSortPanel';
import { UploadRequestOption as RcCustomRequestOptions } from 'rc-upload/lib/interface';
import Capacity from '../layout/widget/Capacity';
import Space from '../../common/model/space/Space';
interface IProps extends RouteComponentProps {}
interface IProps {
spaceUuid?: string;
}
interface IState {}
// todo matter list 空间结构需要变更
export default class List extends TankComponent<IProps, IState> {
//当前文件夹信息。
matter = new Matter();
//准备新建的文件。
// 当前空间
space = new Space();
// 当前目录
currentDirectory = new Matter();
//准备新建的文件
newMatter = new Matter();
//当前选中的文件
@@ -137,22 +142,24 @@ export default class List extends TankComponent<IProps, IState> {
},
};
componentDidMount() {
//刷新一下列表
if (this.user.role === UserRole.ADMINISTRATOR) {
this.pager.getFilter('userUuid')!.visible = true;
} else {
this.pager.setFilterValue('userUuid', this.user.uuid);
}
async componentDidMount() {
this.initSpace();
this.pager.enableHistory();
this.refresh();
this.refreshBreadcrumbs();
this.drag.register();
}
componentWillReceiveProps(nextProps: Readonly<IProps>, nextContext: any) {
if (this.props.location.search !== nextProps.location.search) {
this.pager.enableHistory();
this.refresh();
componentWillReceiveProps() {
this.pager.enableHistory();
this.refresh();
this.refreshBreadcrumbs();
}
initSpace() {
if (this.props.spaceUuid) {
this.space.uuid = this.props.spaceUuid;
this.space.httpDetail(() => this.updateUI());
}
}
@@ -161,19 +168,13 @@ export default class List extends TankComponent<IProps, IState> {
this.selectedMatters = [];
// 刷新文件列表
this.refreshPager();
// 刷新面包屑
this.refreshBreadcrumbs();
}
refreshPager() {
// 初始化当前matter uuid
if (this.matter.uuid !== this.pager.getFilterValue('puuid')) {
this.matter.uuid =
this.pager.getFilterValue('puuid') || Matter.MATTER_ROOT;
if (!this.pager.getFilterValue('puuid')) {
this.pager.setFilterValue('puuid', Matter.MATTER_ROOT);
}
this.pager.setFilterValue('puuid', this.matter.uuid);
//如果没有任何的排序,默认使用时间倒序和文件夹在顶部
if (!this.pager.getCurrentSortFilter()) {
this.pager.setFilterValue('orderCreateTime', SortDirection.DESC);
@@ -183,6 +184,11 @@ export default class List extends TankComponent<IProps, IState> {
// 过滤掉被软删除的文件
this.pager.setFilterValue('deleted', false);
// 空间下的文件
if (this.props.spaceUuid) {
this.pager.setFilterValue('spaceUuid', this.props.spaceUuid);
}
this.pager.httpList();
}
@@ -226,14 +232,14 @@ export default class List extends TankComponent<IProps, IState> {
const uuids = this.selectedMatters.map((i) => i.uuid).toString();
MatterDeleteModal.open(
() => {
this.matter.httpSoftDeleteBatch(uuids, () => {
Matter.httpSoftDeleteBatch(uuids, () => {
MessageBoxUtil.success(Lang.t('operationSuccess'));
Capacity.instance?.refresh();
this.refresh();
});
},
() => {
this.matter.httpDeleteBatch(uuids, () => {
Matter.httpDeleteBatch(uuids, () => {
MessageBoxUtil.success(Lang.t('operationSuccess'));
Capacity.instance?.refresh();
this.refresh();
@@ -250,7 +256,7 @@ export default class List extends TankComponent<IProps, IState> {
toggleMoveBatch() {
MoveBatchModal.open((targetUuid) => {
const uuids = this.selectedMatters.map((i) => i.uuid).join(',');
this.matter.httpMove(uuids, targetUuid, () => {
Matter.httpMove(uuids, targetUuid, () => {
MessageBoxUtil.success(Lang.t('operationSuccess'));
this.refresh();
});
@@ -318,7 +324,7 @@ export default class List extends TankComponent<IProps, IState> {
m.puuid =
j > 1
? dirPathUuidMap[midPaths.slice(0, j - 1).join('/')]
: this.matter.uuid!;
: this.currentDirectory.uuid!;
m.userUuid = this.user.uuid!;
await m.httpCreateDirectory(
() => {
@@ -349,13 +355,12 @@ export default class List extends TankComponent<IProps, IState> {
launchUpload(
f: File | FileList,
puuid = this.matter.uuid!,
puuid = this.currentDirectory.uuid!,
errHandle = () => {}
) {
const files = f instanceof FileList ? f : [f];
for (let i = 0; i < files.length; i++) {
const file = files[i];
console.log(file);
// 判断文件是否是文件夹,是的话则停止上传
const fileReader = new FileReader();
fileReader.readAsDataURL(files[i].slice(0, 3));
@@ -412,15 +417,9 @@ export default class List extends TankComponent<IProps, IState> {
}
searchFile(value?: string) {
this.pager.resetFilter();
if (value) {
this.pager.setFilterValue('orderCreateTime', SortDirection.DESC);
this.pager.setFilterValue('orderDir', SortDirection.DESC);
this.pager.setFilterValue('name', value);
this.pager.httpList();
} else {
this.refresh();
}
this.pager.setFilterValue('name', value);
this.pager.setFilterValue('page', 0);
this.refresh();
}
changeSearch(e: any) {
@@ -437,8 +436,7 @@ export default class List extends TankComponent<IProps, IState> {
this.newMatter.name = 'matter.allFiles';
this.newMatter.dir = true;
this.newMatter.editMode = true;
this.newMatter.puuid = this.matter.uuid || 'root';
this.newMatter.userUuid = this.user.uuid!;
this.newMatter.puuid = this.currentDirectory.uuid || Matter.MATTER_ROOT;
this.director.createMode = true;
this.updateUI();
@@ -468,33 +466,37 @@ export default class List extends TankComponent<IProps, IState> {
goToDirectory(id: string) {
this.searchText = null;
this.pager.setFilterValue('puuid', id);
this.pager.setFilterValue('name', null);
this.pager.removeFilter('name');
this.pager.page = 0;
const query = this.pager.getParams();
Sun.navigateQueryTo({ path: '/matter/list', query });
this.refresh();
Sun.navigateQueryTo({ path: this.getMatterListPath(), query });
}
getMatterListPath() {
if (this.props.spaceUuid)
return `/space/${this.props.spaceUuid}/matter/list`;
return '/matter/list';
}
//刷新面包屑
refreshBreadcrumbs() {
const uuid = this.pager.getFilterValue('puuid') || Matter.MATTER_ROOT;
this.currentDirectory.uuid =
this.pager.getFilterValue('puuid') || Matter.MATTER_ROOT;
const isRootDirectory = this.currentDirectory.uuid === Matter.MATTER_ROOT;
//根目录简单处理即可。
if (uuid === Matter.MATTER_ROOT) {
this.matter.uuid = Matter.MATTER_ROOT;
this.breadcrumbModels = [
{
name: Lang.t('matter.allFiles'),
path: '/matter/list',
query: {},
displayDirect: true,
},
];
} else {
this.matter.uuid = uuid;
this.matter.httpDetail(() => {
const rootBreadcrumb = {
name: Lang.t('matter.allFiles'),
path: this.getMatterListPath(),
query: {},
displayDirect: isRootDirectory,
};
this.breadcrumbModels = [rootBreadcrumb];
if (!isRootDirectory) {
this.currentDirectory.httpDetail(() => {
const arr = [];
let cur: Matter | null = this.matter;
let cur: Matter | null = this.currentDirectory;
do {
arr.push(cur);
cur = cur.parent;
@@ -506,26 +508,35 @@ export default class List extends TankComponent<IProps, IState> {
query['puuid'] = item.uuid!;
t.push({
name: item.name,
path: '/matter/list',
path: this.getMatterListPath(),
query: query,
displayDirect: !i, // 当前目录不需要导航
});
return t;
},
[
{
name: Lang.t('matter.allFiles'),
path: '/matter/list',
query: {},
displayDirect: false,
},
]
[rootBreadcrumb]
);
this.updateUI();
});
}
}
getBreadcrumbModels(): BreadcrumbModel[] {
if (this.props.spaceUuid) {
if (!this.space.name) return [];
return [
{
name: this.space.name,
path: `/space/${this.space.uuid}/matter/list`,
query: {},
displayDirect: true,
},
].concat(this.breadcrumbModels);
}
return this.breadcrumbModels;
}
render() {
const { pager, director, selectedMatters, dragEnterCount } = this;
return (
@@ -535,11 +546,11 @@ export default class List extends TankComponent<IProps, IState> {
<CloudUploadOutlined className="white f50" />
</div>
) : null}
<BreadcrumbPanel breadcrumbModels={this.breadcrumbModels} />
<BreadcrumbPanel breadcrumbModels={this.getBreadcrumbModels()} />
<Row>
<Col xs={24} sm={24} md={14} lg={16} className="mt10">
<Space className="buttons">
<AntdSpace className="buttons">
{selectedMatters.length !== pager.data.length ? (
<Button
type="primary"
@@ -640,7 +651,7 @@ export default class List extends TankComponent<IProps, IState> {
<SyncOutlined />
{Lang.t('refresh')}
</Button>
</Space>
</AntdSpace>
</Col>
<Col xs={24} sm={24} md={10} lg={8} className="mt10">
<Input.Search
@@ -687,7 +698,7 @@ export default class List extends TankComponent<IProps, IState> {
)}
</div>
<Pagination
className="mt10 pull-right"
className="matter-pagination pull-right"
onChange={(page) => this.changePage(page)}
current={pager.page + 1}
total={pager.totalItems}
+1
View File
@@ -4,6 +4,7 @@
min-height: 100%;
.space-item {
width: 100%;
cursor: pointer;
&-name-wrapper {
position: relative;
display: flex;
+25 -4
View File
@@ -27,6 +27,7 @@ import {
} from '@ant-design/icons';
import { DeleteOutlined } from '@ant-design/icons/lib';
import Color from '../../common/model/base/option/Color';
import SafeUtil from '../../common/util/SafeUtil';
interface IProps extends RouteComponentProps {}
@@ -113,6 +114,10 @@ export default class List extends TankComponent<IProps, IState> {
this.props.history.push(`/space/${space.uuid}/member`);
}
handleSpaceMatterList(space: Space) {
this.props.history.push(`/space/${space.uuid}/matter/list`);
}
render() {
const { pager, modalState } = this;
@@ -130,7 +135,11 @@ export default class List extends TankComponent<IProps, IState> {
return (
<Col xs={24} sm={24} md={12} lg={8} key={space.uuid}>
<Card className="space-item" size="small">
<Card
className="space-item"
size="small"
onClick={() => this.handleSpaceMatterList(space)}
>
<div className="space-item-name-wrapper mb10">
<div
className="space-item-name one-line"
@@ -141,15 +150,27 @@ export default class List extends TankComponent<IProps, IState> {
<AntdSpace className="space-item-icons">
<TeamOutlined
className="btn-action btn-member"
onClick={() => this.handleSpaceMember(space)}
onClick={(e) =>
SafeUtil.stopPropagationWrap(e)(
this.handleSpaceMember(space)
)
}
/>
<EditOutlined
className="btn-action btn-edit"
onClick={() => this.handleEdit(space)}
onClick={(e) =>
SafeUtil.stopPropagationWrap(e)(
this.handleEdit(space)
)
}
/>
<DeleteOutlined
className="btn-action btn-del"
onClick={() => this.handleDelete(space)}
onClick={(e) =>
SafeUtil.stopPropagationWrap(e)(
this.handleDelete(space)
)
}
/>
</AntdSpace>
</div>
+13
View File
@@ -0,0 +1,13 @@
import React from 'react';
import List from '../../matter/List';
import { useParams } from 'react-router';
const SpaceMatterList = () => {
const params = useParams<{
spaceUuid: string;
}>();
return <List spaceUuid={params.spaceUuid} />;
};
export default SpaceMatterList;
+2 -2
View File
@@ -22,14 +22,14 @@ export default class BreadcrumbPanel extends TankComponent<IProps, IState> {
render() {
return (
<Breadcrumb>
<Breadcrumb.Item>
{/*<Breadcrumb.Item>
<HomeOutlined
className="cursor"
onClick={() => {
Sun.navigateTo('/');
}}
/>
</Breadcrumb.Item>
</Breadcrumb.Item>*/}
{this.props.breadcrumbModels.map(
(item: BreadcrumbModel, index: number) => {