!1584 功能:模板列表搜索结果的文件可以打开所在目录

pull/1590/MERGE
林三 3 years ago committed by ChenX
parent f7b45036ba
commit 4abe8b4576

@ -9,6 +9,7 @@ import { DirUrl, FileUrls, MaterialUrls, SendTemplateUrl, TemplateUrls, ToplineU
import { KeyBoard, MouseKey } from '../../../Common/KeyEnum';
import { DirectoryId, PostJson, RequestStatus } from '../../../Common/Request';
import { isNum } from '../../../Common/Utils';
import { IFileInfo } from '../../../DatabaseServices/FileServer';
import { AppConfirm } from '../Common/Confirm';
import { AppToaster } from '../Toaster';
import { HandleDirComponent } from './HandleDirComponent';
@ -50,6 +51,13 @@ interface ICommonPanelProps
loadCacheDirKey?: string;
}
interface IDir
{
dir_id: string;
dir_name: string;
childs: IDir[];
}
enum EOrderType
{
ByCreate = "create_date desc",
@ -366,6 +374,8 @@ export class CommonPanel extends React.Component<ICommonPanelProps, ICommonPanel
copy: this.copy,
paste: this.paste,
copyIds: this.copyIds,
searchStr: this.state.searchStr,
searchDir: this.state.searchDir,
})
)
}
@ -826,11 +836,21 @@ export class CommonPanel extends React.Component<ICommonPanelProps, ICommonPanel
query.dir_id = DirectoryId.None;
let data = await PostJson(this.props.getUrl, query);
if (data.err_code === RequestStatus.Ok && Number(data.count))
{
let dataList: any[] = data.images || data.materials || data.toplines || data.files || data.modules || [];
dataList.forEach(d => d.isChecked = false);
this.dataList.replace(dataList);
if (this.props.defaultDirId === DirectoryId.TemplateDir && this.state.searchStr) //模板列表 搜索的data值 路径处理
{
let dataList: any[] = data.modules || [];
await this.AddPathByFileInfos(dataList);
observable(this.dataList).replace(dataList);
}
else
{
let dataList: any[] = data.images || data.materials || data.toplines || data.files || data.modules || [];
dataList.forEach(d => d.isChecked = false);
this.dataList.replace(dataList);
}
}
else
this.dataList.length = 0;
@ -839,6 +859,63 @@ export class CommonPanel extends React.Component<ICommonPanelProps, ICommonPanel
this.setState({ isSelectAll: false });
this.loading = false;
};
//模板列表搜索返回的数据获取相对应目录路径--- 开始 ---
private async AddPathByFileInfos(files: IFileInfo[])
{
if (files.length === 0) return;
let data = await PostJson(DirUrl.query, { dir_type: this.props.defaultDirId });
if (data.err_code === RequestStatus.Ok && data.dirs)
{
let dirs = data.dirs;
for (let file of files)
{
let info = this.getPath(dirs, file);
file.path = info.pathString;
file.pathNum = info.pathNum;
}
}
}
private getPath(dirs: IDir[], file: IFileInfo)
{
let pathNum: number[] = [];
let pathString = "";
if (file.dir_id === this.props.defaultDirId)
{
return {
pathString: "/",
pathNum: [],
};
}
for (let i = 0; i < dirs.length; i++)
{
const dir = dirs[i];
if (dir.dir_id === file.dir_id)
{
pathNum.push(i);
pathString += dir.dir_name + "/";
return { pathString, pathNum };
}
else
{
if (dir.childs.length > 0)
{
let data = this.getPath(dir.childs, file);
if (data.pathNum.length > 0)
{
pathNum.push(i);
pathString += dir.dir_name + "/";
pathNum.push(...data.pathNum);
pathString += data.pathString;
}
}
}
}
return { pathString, pathNum };
}
//模板列表搜索返回的数据获取相对应目录路径--- 结束 ---
private getSelectDataIds = () =>
{
if (this.state.isSelectAll)
@ -879,7 +956,6 @@ export class CommonPanel extends React.Component<ICommonPanelProps, ICommonPanel
if (this.props.delete)
this.props.delete(query);
};
//点击节点容器的动作
private handleTreeMouseDown = (e: MouseEvent) =>
{

@ -3,18 +3,21 @@ import { IObservableValue, observable, reaction } from 'mobx';
import { observer } from 'mobx-react';
import * as React from 'react';
import { templateTagCommand } from '../../../Add-on/Template/TemplateTagCommand';
import { app } from '../../../ApplicationServices/Application';
import { CommandNames } from '../../../Common/CommandNames';
import { FileSystem } from '../../../Common/FileSystem';
import { PublishTemplateUrl, TemplateUrls } from '../../../Common/HostUrl';
import { MouseKey } from '../../../Common/KeyEnum';
import { Post, PostJson, RequestStatus } from '../../../Common/Request';
import { DirectoryId, Post, PostJson, RequestStatus } from '../../../Common/Request';
import { GetEntitysLogo, inflate, TemplateParamsIn } from '../../../Common/SerializeMaterial';
import { TemplateParam } from '../../../DatabaseServices/Template/Param/TemplateParam';
import { GetOnlineTemplate } from '../../../DatabaseServices/Template/TempateUtils';
import { commandMachine } from '../../../Editor/CommandMachine';
import { DisableChangeParName, DrawerTempParName, IDrawerDoorTempInfo, ISelectTempInfo } from '../../Store/DoorInterface';
import { ITemplateParam } from '../../Store/RightPanelStore/TemplateParamPanelStore';
import { TempalteEditorStore } from '../../Store/TemplateEditorStore';
import { DataList } from '../Common/Datalist';
import { IDirectoryProps } from '../SourceManage/CommonPanel';
import { CommonPanel, IDirectoryProps } from '../SourceManage/CommonPanel';
import { AppToaster } from '../Toaster';
import { IGetRoomInfo } from './GetRoomCabName';
import { TemplateDetail } from './TemplateDetail';
@ -41,6 +44,8 @@ export interface ITemplateListProps
selectIds?: Set<string>;
showInfos?: boolean;
insert?: (bool: boolean) => void;
searchStr?: string;
searchDir?: boolean;
}
export interface ITempItemBack
@ -51,6 +56,8 @@ export interface ITempItemBack
name: string;
logo: string;
dir_id: string;
path: string;
pathNum: number[];
}
@observer
@ -220,6 +227,13 @@ export class TemplateList extends React.Component<ITemplateListProps> {
onClick={this.undoCover}
/> : null
}
{
this.props.searchStr && !this.props.searchDir && < MenuItem
icon="folder-open"
text="打开文件所在目录"
onClick={() => this.openDir(temp)}
/>
}
</Menu>,
{ left: e.clientX, top: e.clientY },
() => this.setState({ isContextMenuOpen: false }),
@ -293,4 +307,11 @@ export class TemplateList extends React.Component<ITemplateListProps> {
if (this.props.insert)
this.props.insert(false);
};
//打开目录(针对模板列表搜索结果的对象)
private openDir = (temp: ITempItemBack) =>
{
CommonPanel.CurrentDirCache.set(DirectoryId.TemplateDir, { id: temp.dir_id, path: temp.path, pathNum: temp.pathNum });
app.Editor.ModalManage.Destory();
commandMachine.ExecCommand(CommandNames.Template);
};
}

Loading…
Cancel
Save