|
|
|
@ -3,9 +3,11 @@ import { observable } from 'mobx';
|
|
|
|
|
import { inject, observer } from 'mobx-react';
|
|
|
|
|
import * as React from 'react';
|
|
|
|
|
import { ImgsUrl } from '../../../Common/HostUrl';
|
|
|
|
|
import { DirectoryId } from '../../../Common/Request';
|
|
|
|
|
import { DirectoryId, PostJson, RequestStatus } from '../../../Common/Request';
|
|
|
|
|
import { AppToaster } from '../../Components/Toaster';
|
|
|
|
|
import { MaterialStore } from '../../Store/MaterialStore';
|
|
|
|
|
import { CommonPanel } from './CommonPanel';
|
|
|
|
|
import { HandleDirComponent } from './HandleDirComponent';
|
|
|
|
|
import { ImgList } from './ImgList';
|
|
|
|
|
import { UploadComponent } from './UploadCom';
|
|
|
|
|
|
|
|
|
@ -24,15 +26,20 @@ interface ITexturePanelProps
|
|
|
|
|
@observer
|
|
|
|
|
export class TexturePanel extends React.Component<ITexturePanelProps, ITexturePanelState>
|
|
|
|
|
{
|
|
|
|
|
private startUpload = observable.box(false); //是否开始上传
|
|
|
|
|
private isApplyPanel: boolean = false;
|
|
|
|
|
_CommonPanel: CommonPanel;
|
|
|
|
|
_StartUpload = observable.box(false); //是否开始上传
|
|
|
|
|
_IsApplyPanel: boolean = false;
|
|
|
|
|
_CurrentFileInfo = { fid: null, name: null };
|
|
|
|
|
_CanCreateFile = observable.box(false);
|
|
|
|
|
|
|
|
|
|
constructor(props)
|
|
|
|
|
{
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {};
|
|
|
|
|
this.isApplyPanel = this.props.store instanceof MaterialStore;
|
|
|
|
|
this._IsApplyPanel = this.props.store instanceof MaterialStore;
|
|
|
|
|
}
|
|
|
|
|
private renderNav = () =>
|
|
|
|
|
|
|
|
|
|
_RenderNav = () =>
|
|
|
|
|
{
|
|
|
|
|
return (
|
|
|
|
|
<Button
|
|
|
|
@ -42,33 +49,74 @@ export class TexturePanel extends React.Component<ITexturePanelProps, ITexturePa
|
|
|
|
|
}}
|
|
|
|
|
text="上传"
|
|
|
|
|
intent={Intent.SUCCESS}
|
|
|
|
|
onClick={() => this.startUpload.set(true)}
|
|
|
|
|
onClick={() => this._StartUpload.set(true)}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
private renderMenuItems = () =>
|
|
|
|
|
|
|
|
|
|
_HandleFile = async (name: string) =>
|
|
|
|
|
{
|
|
|
|
|
if (name !== "")
|
|
|
|
|
{
|
|
|
|
|
if (name.replace(/\s/g, "") === "")
|
|
|
|
|
{
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
message: "名称不能为空",
|
|
|
|
|
timeout: 5000,
|
|
|
|
|
intent: Intent.DANGER,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
else if (name !== this._CurrentFileInfo.name)
|
|
|
|
|
{
|
|
|
|
|
let res = await PostJson(ImgsUrl.update, { image_id: this._CurrentFileInfo.fid, name });
|
|
|
|
|
|
|
|
|
|
if (res.err_code === RequestStatus.Ok)
|
|
|
|
|
AppToaster.show({
|
|
|
|
|
message: "修改成功!",
|
|
|
|
|
timeout: 5000,
|
|
|
|
|
intent: Intent.SUCCESS,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
await this._CommonPanel.handleGetData();
|
|
|
|
|
Object.assign(this._CurrentFileInfo, { fid: null, name: null });
|
|
|
|
|
this._CanCreateFile.set(false);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
_RenderMenuItems = () =>
|
|
|
|
|
{
|
|
|
|
|
return (
|
|
|
|
|
<MenuItem icon="cloud-upload" text="上传贴图"
|
|
|
|
|
onClick={() => this.startUpload.set(true)}
|
|
|
|
|
onClick={() => this._StartUpload.set(true)}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render()
|
|
|
|
|
{
|
|
|
|
|
return (
|
|
|
|
|
<CommonPanel
|
|
|
|
|
ref={com => this._CommonPanel = com}
|
|
|
|
|
defaultDirId={DirectoryId.ImgDir}
|
|
|
|
|
renderNav={this.renderNav}
|
|
|
|
|
renderMenuItems={this.renderMenuItems}
|
|
|
|
|
canDelete={!this.isApplyPanel}
|
|
|
|
|
renderNav={this._RenderNav}
|
|
|
|
|
renderMenuItems={this._RenderMenuItems}
|
|
|
|
|
canDelete={!this._IsApplyPanel}
|
|
|
|
|
getUrl={ImgsUrl.get}
|
|
|
|
|
deleteUrl={ImgsUrl.delete}
|
|
|
|
|
canOrder={false}
|
|
|
|
|
handleDirComponent={
|
|
|
|
|
this._CanCreateFile.get() && <HandleDirComponent
|
|
|
|
|
defualtValue={this._CurrentFileInfo.name || ""}
|
|
|
|
|
isReset={false}
|
|
|
|
|
isOpen={this._CanCreateFile}
|
|
|
|
|
handleFunc={this._HandleFile}
|
|
|
|
|
title="输入文件名称"
|
|
|
|
|
/>
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
<ImgList isShowSize={this.props.isShowSize} />
|
|
|
|
|
<ImgList isShowSize={this.props.isShowSize} isRename={this._CanCreateFile} info={this._CurrentFileInfo} />
|
|
|
|
|
<UploadComponent
|
|
|
|
|
isOpen={this.startUpload}
|
|
|
|
|
isOpen={this._StartUpload}
|
|
|
|
|
/>
|
|
|
|
|
</CommonPanel>
|
|
|
|
|
);
|
|
|
|
|