transform matter pages class arrow function to class method function.

This commit is contained in:
Simba
2021-01-05 23:18:00 +08:00
parent 2c835ea42f
commit 419789401f
10 changed files with 143 additions and 144 deletions
+5 -5
View File
@@ -45,7 +45,7 @@ export default class Detail extends TankComponent<IProps, IState> {
});
}
copyLink = () => {
copyLink() {
const { privacy } = this.matter;
const textToCopy = this.matter.getDownloadUrl(
privacy ? this.downloadToken.uuid! : undefined
@@ -55,7 +55,7 @@ export default class Detail extends TankComponent<IProps, IState> {
});
};
recovery = () => {
recovery() {
this.matter.httpRecovery(() => {
this.matter.httpDetail(() => {
this.updateUI();
@@ -114,13 +114,13 @@ export default class Detail extends TankComponent<IProps, IState> {
<a onClick={() => matter.preview()}>
{Lang.t("matter.preview")}
</a>
<a onClick={this.copyLink}>
<a onClick={() => this.copyLink()}>
{matter.privacy
? Lang.t("matter.oneTimeLink")
: Lang.t("matter.copyPath")}
</a>
{matter.deleted ? (
<a onClick={this.recovery}>
<a onClick={() => this.recovery()}>
{Lang.t("matter.recovery")}
</a>
) : null}
@@ -130,7 +130,7 @@ export default class Detail extends TankComponent<IProps, IState> {
) : null}
{matter.dir && matter.deleted && (
<InfoCell name={Lang.t("matter.operations")}>
<a onClick={this.recovery}>{Lang.t("matter.recovery")}</a>
<a onClick={() => this.recovery()}>{Lang.t("matter.recovery")}</a>
</InfoCell>
)}
</div>
+86 -86
View File
@@ -1,5 +1,5 @@
import React, {Children} from "react";
import {RouteComponentProps} from "react-router-dom";
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";
@@ -35,7 +35,7 @@ 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 { UserRole } from "../../common/model/user/UserRole";
import StringUtil from "../../common/util/StringUtil";
import MoveBatchModal from "./widget/MoveBatchModal";
import ShareOperationModal from "./widget/ShareOperationModal";
@@ -48,12 +48,11 @@ import Lang from "../../common/model/global/Lang";
import FileUtil from "../../common/util/FileUtil";
import SafeUtil from "../../common/util/SafeUtil";
import MatterSortPanel from "./widget/MatterSortPanel";
import { RcCustomRequestOptions } from "antd/lib/upload/interface";
interface IProps extends RouteComponentProps {
}
interface IProps extends RouteComponentProps {}
interface IState {
}
interface IState {}
export default class List extends TankComponent<IProps, IState> {
//当前文件夹信息。
@@ -90,12 +89,12 @@ export default class List extends TankComponent<IProps, IState> {
static uploadMatters: Matter[] = [];
//持有全局唯一的实例。
static instance: List | null = null
static instance: List | null = null;
constructor(props: IProps) {
super(props);
List.instance = this
List.instance = this;
}
//拖拽上传
@@ -148,7 +147,6 @@ export default class List extends TankComponent<IProps, IState> {
};
componentDidMount() {
//刷新一下列表
if (this.user.role === UserRole.ADMINISTRATOR) {
this.pager.getFilter("userUuid")!.visible = true;
@@ -171,16 +169,16 @@ export default class List extends TankComponent<IProps, IState> {
this.drag.remove();
}
refresh = () => {
refresh() {
// 清空暂存区
this.selectedMatters = [];
// 刷新文件列表
this.refreshPager();
// 刷新面包屑
this.refreshBreadcrumbs();
};
}
refreshPager = () => {
refreshPager() {
// 初始化当前matter uuid
if (this.matter.uuid !== this.pager.getFilterValue("puuid")) {
this.matter.uuid =
@@ -199,9 +197,9 @@ export default class List extends TankComponent<IProps, IState> {
this.pager.setFilterValue("deleted", false);
this.pager.httpList();
};
}
checkMatter = (matter?: Matter) => {
checkMatter(matter?: Matter) {
if (matter) {
if (matter.check) {
this.selectedMatters.push(matter);
@@ -221,23 +219,23 @@ export default class List extends TankComponent<IProps, IState> {
});
}
this.updateUI();
};
}
checkAll = () => {
checkAll() {
this.pager.data.forEach((i) => {
i.check = true;
});
this.checkMatter();
};
}
checkNone = () => {
checkNone() {
this.pager.data.forEach((i) => {
i.check = false;
});
this.checkMatter();
};
}
deleteBatch = () => {
deleteBatch() {
const uuids = this.selectedMatters.map((i) => i.uuid).toString();
MatterDeleteModal.open(
() => {
@@ -253,14 +251,14 @@ export default class List extends TankComponent<IProps, IState> {
});
}
);
};
}
downloadZip = () => {
downloadZip() {
const uuids = this.selectedMatters.map((i) => i.uuid).toString();
Matter.downloadZip(uuids);
};
}
toggleMoveBatch = () => {
toggleMoveBatch() {
MoveBatchModal.open((targetUuid) => {
const uuids = this.selectedMatters.map((i) => i.uuid).join(",");
this.matter.httpMove(uuids, targetUuid, () => {
@@ -268,24 +266,24 @@ export default class List extends TankComponent<IProps, IState> {
this.refresh();
});
});
};
}
triggerUpload = (fileObj: any) => {
const {file} = fileObj;
triggerUpload(fileObj: RcCustomRequestOptions) {
const { file } = fileObj;
if (file) this.launchUpload(file);
};
}
debounce = (func: Function, wait: number) => {
debounce(func: Function, wait: number) {
let timer: any = null;
return (fileObj: any) => {
const {file} = fileObj;
const { file } = fileObj;
this.tempUploadList.push(file);
if (timer) {
clearTimeout(timer);
}
timer = setTimeout(func, wait);
};
};
}
triggerUploadDir = this.debounce(async () => {
await this.uploadDirectory();
@@ -296,7 +294,7 @@ export default class List extends TankComponent<IProps, IState> {
const url = FileUtil.getErrorLogsToCSVUrl(this.uploadErrorLogs);
Modal.confirm({
title: Lang.t("matter.uploadInfo"),
icon: <ExclamationCircleFilled twoToneColor="#FFDC00"/>,
icon: <ExclamationCircleFilled twoToneColor="#FFDC00" />,
content: Lang.t("matter.uploadErrorInfo"),
okText: Lang.t("matter.exportCSV"),
onOk: () => {
@@ -313,7 +311,7 @@ export default class List extends TankComponent<IProps, IState> {
this.refresh();
}, 0);
uploadDirectory = async () => {
async uploadDirectory() {
const dirPathUuidMap: any = {}; // 存储已经创建好的文件夹map
for (let i = 0; i < this.tempUploadList.length; i++) {
const file: File = this.tempUploadList[i];
@@ -358,14 +356,13 @@ export default class List extends TankComponent<IProps, IState> {
});
}
}
};
}
launchUpload = (
launchUpload(
f: File | FileList,
puuid = this.matter.uuid!,
errHandle = () => {
}
) => {
errHandle = () => {}
) {
const files = f instanceof FileList ? f : [f];
for (let i = 0; i < files.length; i++) {
const file = files[i];
@@ -401,9 +398,9 @@ export default class List extends TankComponent<IProps, IState> {
List.uploadMatters.push(m);
}
};
}
shareBatch = () => {
shareBatch() {
const uuids = this.selectedMatters.map((i) => i.uuid).join(",");
ShareOperationModal.open((share: Share) => {
share.httpCreate(uuids, () => {
@@ -412,7 +409,7 @@ export default class List extends TankComponent<IProps, IState> {
});
};
searchFile = (value?: string) => {
searchFile(value?: string) {
this.pager.resetFilter();
if (value) {
this.pager.setFilterValue("orderCreateTime", SortDirection.DESC);
@@ -424,17 +421,17 @@ export default class List extends TankComponent<IProps, IState> {
}
};
changeSearch = (e: any) => {
changeSearch(e: any) {
if (!e.currentTarget.value) this.searchFile();
};
changePage = (page: number) => {
changePage(page: number) {
this.pager.page = page - 1; // page的页数0基
this.pager.httpList();
this.updateUI();
};
createDirectory = () => {
createDirectory() {
this.newMatter.name = "matter.allFiles";
this.newMatter.dir = true;
this.newMatter.editMode = true;
@@ -446,7 +443,7 @@ export default class List extends TankComponent<IProps, IState> {
setTimeout(() => this.newMatterRef.current!.highLight());
};
previewImage = (matter: Matter) => {
previewImage(matter: Matter) {
let imageArray: string[] = [];
let startIndex = -1;
this.pager.data.forEach((item) => {
@@ -461,17 +458,17 @@ export default class List extends TankComponent<IProps, IState> {
ImagePreviewer.showMultiPhoto(imageArray, startIndex);
};
goToDirectory = (id: string) => {
goToDirectory(id: string) {
this.searchText = null;
this.pager.setFilterValue("puuid", id);
this.pager.page = 0;
const query = this.pager.getParams();
Sun.navigateQueryTo({path: "/matter/list", query});
Sun.navigateQueryTo({ path: "/matter/list", query });
this.refresh();
};
//刷新面包屑
refreshBreadcrumbs = () => {
refreshBreadcrumbs() {
const uuid = this.pager.getFilterValue("puuid") || Matter.MATTER_ROOT;
//根目录简单处理即可。
@@ -522,27 +519,26 @@ export default class List extends TankComponent<IProps, IState> {
};
render() {
const {
pager,
director,
selectedMatters,
dragEnterCount,
} = this;
const { pager, director, selectedMatters, dragEnterCount } = this;
return (
<div className="matter-list">
{dragEnterCount > 0 ? (
<div className="obscure">
<CloudUploadOutlined className="white f50"/>
<CloudUploadOutlined className="white f50" />
</div>
) : null}
<BreadcrumbPanel breadcrumbModels={this.breadcrumbModels}/>
<BreadcrumbPanel breadcrumbModels={this.breadcrumbModels} />
<Row className="mt10">
<Col xs={24} sm={24} md={14} lg={16}>
<Space className="buttons">
{selectedMatters.length !== pager.data.length ? (
<Button type="primary" className="mb10" onClick={this.checkAll}>
<PlusSquareOutlined/>
<Button
type="primary"
className="mb10"
onClick={() => this.checkAll()}
>
<PlusSquareOutlined />
{Lang.t("selectAll")}
</Button>
) : null}
@@ -551,9 +547,9 @@ export default class List extends TankComponent<IProps, IState> {
<Button
type="primary"
className="mb10"
onClick={this.checkNone}
onClick={() => this.checkNone()}
>
<MinusSquareOutlined/>
<MinusSquareOutlined />
{Lang.t("cancel")}
</Button>
) : null}
@@ -562,36 +558,36 @@ export default class List extends TankComponent<IProps, IState> {
<Button
type="primary"
className="mb10"
onClick={this.deleteBatch}
onClick={() => this.deleteBatch()}
>
<DeleteOutlined/>
<DeleteOutlined />
{Lang.t("delete")}
</Button>
<Button
type="primary"
className="mb10"
onClick={this.downloadZip}
onClick={() => this.downloadZip()}
>
<DownloadOutlined/>
<DownloadOutlined />
{Lang.t("download")}
</Button>
<Button
type="primary"
className="mb10"
onClick={this.toggleMoveBatch}
onClick={() => this.toggleMoveBatch()}
>
<DragOutlined/>
<DragOutlined />
{Lang.t("matter.move")}
</Button>
<Button
type="primary"
className="mb10"
onClick={this.shareBatch}
onClick={() => this.shareBatch()}
>
<ShareAltOutlined/>
<ShareAltOutlined />
{Lang.t("matter.share")}
</Button>
</>
@@ -599,12 +595,12 @@ export default class List extends TankComponent<IProps, IState> {
<Upload
className="ant-upload"
customRequest={this.triggerUpload}
customRequest={(e) => this.triggerUpload(e)}
showUploadList={false}
multiple
>
<Button type="primary" className="mb10">
<CloudUploadOutlined/>
<CloudUploadOutlined />
{Lang.t("matter.upload")}
</Button>
</Upload>
@@ -615,21 +611,25 @@ export default class List extends TankComponent<IProps, IState> {
directory
>
<Button type="primary" className="mb10">
<CloudUploadOutlined/>
<CloudUploadOutlined />
{Lang.t("matter.uploadDir")}
</Button>
</Upload>
<Button
type="primary"
className="mb10"
onClick={this.createDirectory}
onClick={() => this.createDirectory()}
>
<FolderOutlined/>
<FolderOutlined />
{Lang.t("matter.create")}
</Button>
<Button type="primary" className="mb10" onClick={this.refresh}>
<SyncOutlined/>
<Button
type="primary"
className="mb10"
onClick={() => this.refresh()}
>
<SyncOutlined />
{Lang.t("refresh")}
</Button>
</Space>
@@ -639,18 +639,18 @@ export default class List extends TankComponent<IProps, IState> {
className="mb10"
placeholder={Lang.t("matter.searchFile")}
onSearch={(value) => this.searchFile(value)}
onChange={this.changeSearch}
onChange={e => this.changeSearch(e)}
enterButton
/>
</Col>
</Row>
{Children.toArray(
List.uploadMatters.map((m) => <UploadMatterPanel matter={m}/>)
List.uploadMatters.map((m) => <UploadMatterPanel matter={m} />)
)}
{pager.data.length ? (
<MatterSortPanel pager={pager} refresh={() => this.refresh()}/>
<MatterSortPanel pager={pager} refresh={() => this.refresh()} />
) : null}
{director.createMode ? (
@@ -658,7 +658,7 @@ export default class List extends TankComponent<IProps, IState> {
ref={this.newMatterRef}
matter={this.newMatter}
director={director}
onCreateDirectoryCallback={this.refresh}
onCreateDirectoryCallback={() => this.refresh()}
/>
) : null}
<div>
@@ -668,19 +668,19 @@ export default class List extends TankComponent<IProps, IState> {
key={matter.uuid!}
director={director}
matter={matter}
onGoToDirectory={this.goToDirectory}
onDeleteSuccess={this.refresh}
onCheckMatter={this.checkMatter}
onPreviewImage={this.previewImage}
onGoToDirectory={id => this.goToDirectory(id)}
onDeleteSuccess={() => this.refresh()}
onCheckMatter={m => this.checkMatter(m)}
onPreviewImage={m => this.previewImage(m)}
/>
))
) : (
<Empty description={Lang.t("matter.noContentYet")}/>
<Empty description={Lang.t("matter.noContentYet")} />
)}
</div>
<Pagination
className="mt10 pull-right"
onChange={this.changePage}
onChange={page => this.changePage(page)}
current={pager.page + 1}
total={pager.totalItems}
pageSize={pager.pageSize}
+7 -6
View File
@@ -9,6 +9,7 @@ import "./MatterImage.less";
import MessageBoxUtil from "../../../common/util/MessageBoxUtil";
import SafeUtil from "../../../common/util/SafeUtil";
import Lang from "../../../common/model/global/Lang";
import {RcCustomRequestOptions} from "antd/lib/upload/interface";
interface IProps {
value?: string;
@@ -31,11 +32,11 @@ export default class MatterImage extends TankComponent<IProps, IState> {
super(props);
}
changeLink = (e: any) => {
changeLink(e: any) {
SafeUtil.safeCallback(this.props.onChange)(e.target.value);
};
triggerUpload = (fileObj: any) => {
triggerUpload(fileObj: RcCustomRequestOptions) {
const { file } = fileObj;
const { filter = "image", uploadHint = "" } = this.props;
if (file) {
@@ -68,7 +69,7 @@ export default class MatterImage extends TankComponent<IProps, IState> {
}
};
toggleHandle = () => {
toggleHandle() {
this.manual = !this.manual;
this.updateUI();
};
@@ -100,18 +101,18 @@ export default class MatterImage extends TankComponent<IProps, IState> {
className="content"
placeholder={Lang.t("matter.fillInPicLink")}
value={value}
onChange={this.changeLink}
onChange={e => this.changeLink(e)}
/>
) : (
<Upload
className="content"
customRequest={this.triggerUpload}
customRequest={e => this.triggerUpload(e)}
showUploadList={false}
>
<Button className="wp100 border-short">{Lang.t("matter.chooseImage")}</Button>
</Upload>
)}
<Button className="handle" type="primary" onClick={this.toggleHandle}>
<Button className="handle" type="primary" onClick={() => this.toggleHandle()}>
{manual ? Lang.t("matter.uploadMode") : Lang.t("matter.fillMode")}
</Button>
</div>
+21 -21
View File
@@ -58,7 +58,7 @@ export default class MatterPanel extends TankComponent<IProps, IState> {
this.state = {};
}
prepareRename = () => {
prepareRename() {
const { matter, director } = this.props;
if (director!.isEditing()) {
console.error("导演正忙着,不予执行");
@@ -86,14 +86,14 @@ export default class MatterPanel extends TankComponent<IProps, IState> {
});
};
clipboard = () => {
clipboard() {
let textToCopy = this.props.matter.getDownloadUrl();
ClipboardUtil.copy(textToCopy, () => {
MessageBoxUtil.success(Lang.t("operationSuccess"));
});
};
deleteMatter = () => {
deleteMatter() {
MatterDeleteModal.open(
() => {
this.props.matter.httpSoftDelete(() => {
@@ -110,7 +110,7 @@ export default class MatterPanel extends TankComponent<IProps, IState> {
);
};
hardDeleteMatter = () => {
hardDeleteMatter() {
Modal.confirm({
title: Lang.t("actionCanNotRevertConfirm"),
icon: <ExclamationCircleFilled twoToneColor="#FFDC00" />,
@@ -123,7 +123,7 @@ export default class MatterPanel extends TankComponent<IProps, IState> {
});
};
recoveryMatter = () => {
recoveryMatter() {
Modal.confirm({
title: Lang.t("actionRecoveryConfirm"),
icon: <ExclamationCircleFilled twoToneColor="#FFDC00" />,
@@ -136,12 +136,12 @@ export default class MatterPanel extends TankComponent<IProps, IState> {
});
};
changeMatterName = (e: any) => {
changeMatterName(e: any) {
this.renameMatterName = e.currentTarget.value;
this.updateUI();
};
finishRename = () => {
finishRename() {
//有可能按enter的时候和blur同时了。
if (this.renamingLoading) {
return;
@@ -169,7 +169,7 @@ export default class MatterPanel extends TankComponent<IProps, IState> {
);
};
finishCreateDirectory = () => {
finishCreateDirectory() {
const { matter, director, onCreateDirectoryCallback } = this.props;
matter.name = this.renameMatterName;
matter.httpCreateDirectory(
@@ -187,7 +187,7 @@ export default class MatterPanel extends TankComponent<IProps, IState> {
);
};
blurTrigger = () => {
blurTrigger() {
const { matter, director } = this.props;
if (matter.editMode) {
if (director!.createMode) {
@@ -198,28 +198,28 @@ export default class MatterPanel extends TankComponent<IProps, IState> {
}
};
enterTrigger = (e: any) => {
enterTrigger(e: any) {
if (e.key.toLowerCase() === "enter") {
this.inputRef.current!.blur();
}
};
changePrivacy = (privacy: boolean) => {
changePrivacy(privacy: boolean) {
this.props.matter.httpChangePrivacy(privacy, () => {
this.updateUI();
});
};
checkToggle = (e: CheckboxChangeEvent) => {
checkToggle(e: CheckboxChangeEvent) {
this.props.matter.check = e.target.checked;
this.props.onCheckMatter!(this.props.matter);
};
highLight = () => {
highLight() {
this.inputRef.current!.select();
};
clickRow = () => {
clickRow() {
const {
matter,
recycleMode = false,
@@ -245,12 +245,12 @@ export default class MatterPanel extends TankComponent<IProps, IState> {
}
};
toggleHandles = () => {
toggleHandles() {
this.showMore = !this.showMore;
this.updateUI();
};
renderPcOperation = () => {
renderPcOperation() {
const { matter, recycleMode = false } = this.props;
// 文件操作在正常模式 or 回收站模式下不同,其中回收站模式只保留查看信息与彻底删除操作
@@ -371,7 +371,7 @@ export default class MatterPanel extends TankComponent<IProps, IState> {
);
};
renderMobileOperation = () => {
renderMobileOperation() {
const { matter, recycleMode = false } = this.props;
// 文件操作在正常模式 or 回收站模式下不同,其中回收站模式只保留查看信息与彻底删除操作
@@ -507,7 +507,7 @@ export default class MatterPanel extends TankComponent<IProps, IState> {
>
<Checkbox
checked={matter.check}
onChange={this.checkToggle}
onChange={e => this.checkToggle(e)}
/>
</span>
<span className="cell">
@@ -540,10 +540,10 @@ export default class MatterPanel extends TankComponent<IProps, IState> {
ref={this.inputRef}
className={matter.uuid!}
value={this.renameMatterName}
onChange={this.changeMatterName.bind(this)}
onChange={e => this.changeMatterName(e)}
placeholder={Lang.t("matter.enterName")}
onBlur={this.blurTrigger.bind(this)}
onKeyUp={this.enterTrigger.bind(this)}
onBlur={() => this.blurTrigger()}
onKeyUp={e => this.enterTrigger(e)}
/>
</span>
) : (
+1 -1
View File
@@ -18,7 +18,7 @@ export default class MatterSortPanel extends TankComponent<IProps, IState> {
static sortAutomaton = [SortDirection.ASC, SortDirection.DESC, null]; // 排序状态自动机:ASC -> DESC -> null -> ASC...
changeFilterOrder = (orderName: string) => {
changeFilterOrder(orderName: string) {
const {pager} = this.props;
["orderName", "orderSize", "orderUpdateTime"]
.filter((name) => name !== orderName)
+5 -5
View File
@@ -57,7 +57,7 @@ export default class MoveBatchModal extends TankComponent<IProps, IState> {
});
}
fetchData = (treeNode: any, success: () => any) => {
fetchData(treeNode: any, success: () => any) {
const { data: origin } = treeNode.props;
this.pager.setFilterValue("puuid", treeNode.key);
this.pager.httpList((response: any) => {
@@ -78,7 +78,7 @@ export default class MoveBatchModal extends TankComponent<IProps, IState> {
});
};
onLoadData = (treeNode: any) => {
onLoadData(treeNode: any) {
return new Promise((resolve) => {
if (treeNode.props.children) {
resolve();
@@ -91,7 +91,7 @@ export default class MoveBatchModal extends TankComponent<IProps, IState> {
});
};
onSelect = (selectedKeys: any) => {
onSelect(selectedKeys: any) {
if (selectedKeys.length) {
this.targetUuid = selectedKeys[0];
this.updateUI();
@@ -106,8 +106,8 @@ export default class MoveBatchModal extends TankComponent<IProps, IState> {
treeData={this.treeData}
defaultExpandedKeys={["root"]}
selectedKeys={[this.targetUuid]}
loadData={this.onLoadData}
onSelect={this.onSelect}
loadData={e => this.onLoadData(e)}
onSelect={e => this.onSelect(e)}
icon={e => e.expanded ? <FolderOpenFilled className="text-primary f20" /> : <FolderFilled className="text-primary f20" />}
/>
<div className="mt10 text-right">
@@ -48,7 +48,7 @@ export default class ShareOperationModal extends TankComponent<IProps, IState> {
});
};
selectChange = (value: ShareExpireOption) => {
selectChange(value: ShareExpireOption) {
this.share.expireOption = value;
this.updateUI();
};
@@ -63,7 +63,7 @@ export default class ShareOperationModal extends TankComponent<IProps, IState> {
<Select
className="wp100"
value={share.expireOption}
onChange={this.selectChange}
onChange={e => this.selectChange(e)}
>
{ShareExpireOptionList.map((option) => (
<Select.Option key={option.value} value={option.value}>
@@ -19,7 +19,7 @@ export default class UploadMatterPanel extends TankComponent<IProps, IState> {
this.state = {};
}
format = (percent: number) => {
format(percent: number) {
return `${percent.toFixed(1)}%`;
};
@@ -32,7 +32,7 @@ export default class ImageCacheList extends TankComponent<IProps, IState> {
this.refresh();
}
deleteBatch = () => {
deleteBatch() {
Modal.confirm({
title: Lang.t("actionCanNotRevertConfirm"),
icon: <ExclamationCircleFilled twoToneColor="#FFDC00"/>,
@@ -47,14 +47,14 @@ export default class ImageCacheList extends TankComponent<IProps, IState> {
});
};
checkBatch = (check: boolean) => {
checkBatch(check: boolean) {
this.pager.data.forEach((i) => {
i.check = check;
});
this.checkImageCache();
};
refresh = () => {
refresh() {
const {initFilter} = this.props;
if (initFilter) {
for (let key in initFilter) {
@@ -68,7 +68,7 @@ export default class ImageCacheList extends TankComponent<IProps, IState> {
this.selectedImageCaches = [];
};
checkImageCache = (imageCache?: ImageCache) => {
checkImageCache(imageCache?: ImageCache) {
if (imageCache) {
if (imageCache.check) {
this.selectedImageCaches.push(imageCache);
@@ -89,7 +89,7 @@ export default class ImageCacheList extends TankComponent<IProps, IState> {
this.updateUI();
};
previewImageCache = (imageCache: ImageCache) => {
previewImageCache(imageCache: ImageCache) {
//从matter开始预览图片
const imageArray: string[] = [];
let startIndex = -1;
@@ -103,7 +103,7 @@ export default class ImageCacheList extends TankComponent<IProps, IState> {
ImagePreviewer.showMultiPhoto(imageArray, startIndex);
};
changePage = (page: number) => {
changePage(page: number) {
this.pager.page = page - 1; // page的页数0基
this.pager.httpList();
this.updateUI();
@@ -120,7 +120,7 @@ export default class ImageCacheList extends TankComponent<IProps, IState> {
<div>
<Space>
{selectedImageCaches.length ? (
<Button type="primary" onClick={this.deleteBatch}>
<Button type="primary" onClick={() => this.deleteBatch()}>
<DeleteOutlined/>
{Lang.t("delete")}
</Button>
@@ -148,9 +148,9 @@ export default class ImageCacheList extends TankComponent<IProps, IState> {
<ImageCachePanel
key={imageCache.uuid!}
imageCache={imageCache}
onDeleteSuccess={this.refresh}
onCheckImageCache={this.checkImageCache}
onPreviewImageCache={this.previewImageCache}
onDeleteSuccess={() => this.refresh()}
onCheckImageCache={e => this.checkImageCache(e)}
onPreviewImageCache={e => this.previewImageCache(e)}
/>
))}
@@ -158,7 +158,7 @@ export default class ImageCacheList extends TankComponent<IProps, IState> {
<Pagination
className="mt10 pull-right"
onChange={this.changePage}
onChange={page => this.changePage(page)}
current={pager.page + 1}
total={pager.totalItems}
pageSize={pager.pageSize}
@@ -28,18 +28,16 @@ interface IProps {
interface IState {}
export default class ImageCachePanel extends TankComponent<IProps, IState> {
//正在向服务器提交rename的请求
renamingLoading = false;
// 小屏幕下操作栏
showMore = false;
checkToggle = (e: CheckboxChangeEvent) => {
checkToggle(e: CheckboxChangeEvent) {
const { imageCache, onCheckImageCache } = this.props;
imageCache.check = e.target.checked;
onCheckImageCache(imageCache);
};
deleteImageCache = () => {
deleteImageCache() {
Modal.confirm({
title: Lang.t("actionCanNotRevertConfirm"),
icon: <ExclamationCircleFilled twoToneColor="#FFDC00" />,
@@ -52,7 +50,7 @@ export default class ImageCachePanel extends TankComponent<IProps, IState> {
});
};
toggleHandles = () => {
toggleHandles() {
this.showMore = !this.showMore;
this.updateUI();
};
@@ -76,7 +74,7 @@ export default class ImageCachePanel extends TankComponent<IProps, IState> {
<Checkbox
onClick={(e) => SafeUtil.stopPropagationWrap(e)}
checked={imageCache.check}
onChange={this.checkToggle}
onChange={e => this.checkToggle(e)}
/>
</span>
<span className="basic-span">