|
|
|
@ -5,7 +5,6 @@ import * as React from 'react';
|
|
|
|
|
import { AutoCutting } from '../../../Add-on/BoardCutting/AutoCuttingReactor';
|
|
|
|
|
import { IsDoor, IsHandle, IsHinge } from '../../../Add-on/HideSelect/HideSelectUtils';
|
|
|
|
|
import { ITempTagProps, templateTagCommand } from '../../../Add-on/Template/TemplateTagCommand';
|
|
|
|
|
import { ReadAutoCutConfig, UploadAutoCutConfig } from '../../../Add-on/TemplateSearch';
|
|
|
|
|
import { R2bReplaceProps } from '../../../Add-on/twoD2threeD/R2bConfigComponent';
|
|
|
|
|
import { app } from '../../../ApplicationServices/Application';
|
|
|
|
|
import { EBoardKeyList } from '../../../Common/BoardKeyList';
|
|
|
|
@ -33,11 +32,12 @@ import { Box3Ext } from '../../../Geometry/Box';
|
|
|
|
|
import { ISpaceParse } from '../../../Geometry/SpaceParse/ISpaceParse';
|
|
|
|
|
import { Point2SpaceParse } from '../../../Geometry/SpaceParse/Point2SpaceParse';
|
|
|
|
|
import { PointSelectSpaceClamp } from '../../../Geometry/SpaceParse/PointSelectSpaceClamp';
|
|
|
|
|
import { BoardOpenDir, DrillType, IDrawBoardAutoCutOption } from '../../Store/BoardInterface';
|
|
|
|
|
import { BoardOpenDir, DrillType, IBaseOption, IDrawBoardAutoCutOption } from '../../Store/BoardInterface';
|
|
|
|
|
import { IDrawerDoorTempInfo } from '../../Store/DoorInterface';
|
|
|
|
|
import { kuGanStore } from '../../Store/KuGanStore';
|
|
|
|
|
import { ITemplateParam } from "../../Store/RightPanelStore/ITemplateParam";
|
|
|
|
|
import { TempalteEditorStore } from '../../Store/TemplateEditorStore';
|
|
|
|
|
import { tempalteManageStore } from '../../Store/TemplateManageStore';
|
|
|
|
|
import { AutoCutCheckbox } from '../Board/BoardCommon';
|
|
|
|
|
import { MenuItem } from '../ContextMenu/MenuItem';
|
|
|
|
|
import { ModalHeader } from '../Modal/ModalContainer';
|
|
|
|
@ -63,9 +63,21 @@ export interface ITemplateManage
|
|
|
|
|
type: "Administration" | "Collection"; //模板管理和收藏
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface TemplateManageUiOption
|
|
|
|
|
{
|
|
|
|
|
navigationWidth: string,
|
|
|
|
|
showTag: boolean;
|
|
|
|
|
};
|
|
|
|
|
export interface ITemplateManageOption extends IBaseOption
|
|
|
|
|
{
|
|
|
|
|
option: IGetRoomInfo;
|
|
|
|
|
autoCutOption: IDrawBoardAutoCutOption;
|
|
|
|
|
uiOption: TemplateManageUiOption;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@observer
|
|
|
|
|
export class TemplateManage extends React.Component<ITemplateManage, {}> {
|
|
|
|
|
@observable private option: IGetRoomInfo = {
|
|
|
|
|
private option: IGetRoomInfo = {
|
|
|
|
|
roomName: "",
|
|
|
|
|
cabName: "",
|
|
|
|
|
originCabName: "",
|
|
|
|
@ -79,19 +91,27 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
|
|
|
|
|
useMaterial: false,
|
|
|
|
|
openDir: BoardOpenDir.None,
|
|
|
|
|
};
|
|
|
|
|
private autoCutOption: IDrawBoardAutoCutOption = { isAutoCut: false, isRelevance: false };
|
|
|
|
|
private uiOption = { navigationWidth: "25%", showTag: true };
|
|
|
|
|
@observable templateManageOption: ITemplateManageOption = {
|
|
|
|
|
version: 1,
|
|
|
|
|
option: this.option,
|
|
|
|
|
autoCutOption: this.autoCutOption,
|
|
|
|
|
uiOption: this.uiOption
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private canCreateTemplate = observable.box(false);
|
|
|
|
|
@observable private currentProps: ITemplateParam[] = [];
|
|
|
|
|
@observable private currentTemplateInfo: IDrawerDoorTempInfo = { id: "", name: "", diy_logo: "" };
|
|
|
|
|
@observable private autoCutOption: IDrawBoardAutoCutOption = { isAutoCut: false, isRelevance: false };
|
|
|
|
|
private TemplateDrawHingeTool: TemplateDrawHingeTool;
|
|
|
|
|
commonPanel = React.createRef<CommonPanel>();
|
|
|
|
|
|
|
|
|
|
constructor(props)
|
|
|
|
|
{
|
|
|
|
|
super(props);
|
|
|
|
|
this.option.roomName = localStorage.getItem(StoreageKeys.RoomName) || "";
|
|
|
|
|
this.option.cabName = "标准柜";
|
|
|
|
|
this.option.originCabName = "标准柜";
|
|
|
|
|
this.templateManageOption.option.roomName = localStorage.getItem(StoreageKeys.RoomName) || "";
|
|
|
|
|
this.templateManageOption.option.cabName = "标准柜";
|
|
|
|
|
this.templateManageOption.option.originCabName = "标准柜";
|
|
|
|
|
}
|
|
|
|
|
private renderNav = () =>
|
|
|
|
|
{
|
|
|
|
@ -263,7 +283,7 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
|
|
|
|
|
|
|
|
|
|
app.Editor.ModalManage.ToggleShow();
|
|
|
|
|
app.Editor.MaskManage.Clear();
|
|
|
|
|
localStorage.setItem(StoreageKeys.RoomName, this.option.roomName);
|
|
|
|
|
localStorage.setItem(StoreageKeys.RoomName, this.templateManageOption.option.roomName);
|
|
|
|
|
await CommandWrap(async () =>
|
|
|
|
|
{
|
|
|
|
|
if (isByBasePt)
|
|
|
|
@ -271,10 +291,10 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
|
|
|
|
|
else
|
|
|
|
|
await this.handleInsertBySpace();
|
|
|
|
|
|
|
|
|
|
if (this.autoCutOption.isAutoCut)
|
|
|
|
|
await AutoCutting(this.autoCutOption.isRelevance);
|
|
|
|
|
if (this.templateManageOption.autoCutOption.isAutoCut)
|
|
|
|
|
await AutoCutting(this.templateManageOption.autoCutOption.isRelevance);
|
|
|
|
|
}, "插入模块");
|
|
|
|
|
this.option.cabName = this.option.originCabName + (++this.option.cabIndex);
|
|
|
|
|
this.templateManageOption.option.cabName = this.templateManageOption.option.originCabName + (++this.templateManageOption.option.cabIndex);
|
|
|
|
|
app.Editor.ModalManage.ToggleShow();
|
|
|
|
|
app.Editor.MaskManage.ShowMask();
|
|
|
|
|
// app.Editor.MaskManage.OnFocusEvent();
|
|
|
|
@ -287,14 +307,14 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
|
|
|
|
|
|
|
|
|
|
await template.UpdateTemplateTree();
|
|
|
|
|
|
|
|
|
|
await InsertTemplateByBasePoint(template, this.option);
|
|
|
|
|
await InsertTemplateByBasePoint(template, this.templateManageOption.option);
|
|
|
|
|
};
|
|
|
|
|
private SetRootCabName = (template: TemplateRecord, parse: ISpaceParse) =>
|
|
|
|
|
{
|
|
|
|
|
let nents = template.AllEntitys;
|
|
|
|
|
|
|
|
|
|
//设置房名和柜名
|
|
|
|
|
let [roomName, cabName] = [this.option.roomName, this.option.cabName];
|
|
|
|
|
let [roomName, cabName] = [this.templateManageOption.option.roomName, this.templateManageOption.option.cabName];
|
|
|
|
|
|
|
|
|
|
if (!parse.VisualSpaceBox && !(parse instanceof Point2SpaceParse))
|
|
|
|
|
{
|
|
|
|
@ -351,7 +371,7 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
|
|
|
|
|
template.WParam.expr = "";
|
|
|
|
|
template.HParam.expr = "";
|
|
|
|
|
|
|
|
|
|
await SetTemplatePositionAndSetParent(parse, template, true, this.option);
|
|
|
|
|
await SetTemplatePositionAndSetParent(parse, template, true, this.templateManageOption.option);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
@ -512,14 +532,14 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
|
|
|
|
|
for (let en of (ens as Board[]))
|
|
|
|
|
{
|
|
|
|
|
let template = app.Database.WblockCloneObejcts([temp], app.Database.TemplateTable, new Map(), DuplicateRecordCloning.Ignore)[0] as TemplateRecord;
|
|
|
|
|
if (this.option.useMaterial)
|
|
|
|
|
if (this.templateManageOption.option.useMaterial)
|
|
|
|
|
{
|
|
|
|
|
this.option.material = en.BoardProcessOption.material;
|
|
|
|
|
this.option.color = en.BoardProcessOption.color;
|
|
|
|
|
this.option.brMat = en.BoardProcessOption.boardName;
|
|
|
|
|
this.templateManageOption.option.material = en.BoardProcessOption.material;
|
|
|
|
|
this.templateManageOption.option.color = en.BoardProcessOption.color;
|
|
|
|
|
this.templateManageOption.option.brMat = en.BoardProcessOption.boardName;
|
|
|
|
|
}
|
|
|
|
|
this.option.openDir = en.OpenDir;
|
|
|
|
|
followAttribute(this.option, template); //板名、柜名、房名跟随
|
|
|
|
|
this.templateManageOption.option.openDir = en.OpenDir;
|
|
|
|
|
followAttribute(this.templateManageOption.option, template); //板名、柜名、房名跟随
|
|
|
|
|
en.IsChaiDan = false;
|
|
|
|
|
en.BoardProcessOption.drillType = DrillType.None; //使替换的模块不排钻
|
|
|
|
|
let pos = new PositioningBoardSpace();
|
|
|
|
@ -582,7 +602,7 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
|
|
|
|
|
intent: Intent.SUCCESS
|
|
|
|
|
}, "替换空间");
|
|
|
|
|
}
|
|
|
|
|
await ReplaceTemplate(oldTemp, template, isKeepChildren, true, this.option);
|
|
|
|
|
await ReplaceTemplate(oldTemp, template, isKeepChildren, true, this.templateManageOption.option);
|
|
|
|
|
|
|
|
|
|
//应用用户输入的参数
|
|
|
|
|
for (let index = 0; index < this.currentProps.length; index++)
|
|
|
|
@ -788,7 +808,7 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
|
|
|
|
|
return <TemplateCollection
|
|
|
|
|
currentProps={this.currentProps}
|
|
|
|
|
currentTemplateInfo={this.currentTemplateInfo}
|
|
|
|
|
cabOption={this.option}
|
|
|
|
|
cabOption={this.templateManageOption.option}
|
|
|
|
|
insert={this.handleInsert}
|
|
|
|
|
/>;
|
|
|
|
|
};
|
|
|
|
@ -805,7 +825,8 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
|
|
|
|
|
deleteUrl={TemplateUrls.delete}
|
|
|
|
|
maxDirLength={2}
|
|
|
|
|
currentTag={this.props.currentTag}
|
|
|
|
|
isTemplateTag={true}
|
|
|
|
|
currentInfo={this.currentTemplateInfo}
|
|
|
|
|
uiOption={this.templateManageOption.uiOption}
|
|
|
|
|
clickTree={() =>
|
|
|
|
|
{
|
|
|
|
|
this.currentTemplateInfo.id = "";
|
|
|
|
@ -817,7 +838,7 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
|
|
|
|
|
currentProps={this.currentProps}
|
|
|
|
|
currentInfo={this.currentTemplateInfo}
|
|
|
|
|
editor={this.handleEditor}
|
|
|
|
|
cabOption={this.option}
|
|
|
|
|
cabOption={this.templateManageOption.option}
|
|
|
|
|
insert={this.handleInsert}
|
|
|
|
|
isShowDetail={true}
|
|
|
|
|
/>
|
|
|
|
@ -864,13 +885,14 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
|
|
|
|
|
};
|
|
|
|
|
componentDidMount()
|
|
|
|
|
{
|
|
|
|
|
ReadAutoCutConfig(TemplateManage.name, this.autoCutOption, this.option);
|
|
|
|
|
//分离配置实现,但保持原来的实现方式(通过传参修改),这里的option引用太多了本来只需要保存roomName和useCabName,但他已经把option所有配置都保存了,没办法
|
|
|
|
|
tempalteManageStore.UpdateOption(this.templateManageOption);
|
|
|
|
|
document.addEventListener('keyup', this.handleHotKey);
|
|
|
|
|
}
|
|
|
|
|
componentWillUnmount()
|
|
|
|
|
{
|
|
|
|
|
templateTagCommand.UploadTagList();
|
|
|
|
|
UploadAutoCutConfig(TemplateManage.name, this.autoCutOption, this.option);
|
|
|
|
|
tempalteManageStore.SaveConfig(this.templateManageOption); //保存模板管理配置
|
|
|
|
|
document.removeEventListener('keyup', this.handleHotKey);
|
|
|
|
|
}
|
|
|
|
|
public render()
|
|
|
|
@ -891,15 +913,15 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
|
|
|
|
|
this.renderBody()
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
<div className={Classes.DIALOG_FOOTER} >
|
|
|
|
|
<div className={Classes.DIALOG_FOOTER + ` ${!this.props.R2bReplace && "flex-between"}`} >
|
|
|
|
|
{
|
|
|
|
|
!this.props.R2bReplace ?
|
|
|
|
|
<>
|
|
|
|
|
<GetRoomCabName
|
|
|
|
|
option={this.option}
|
|
|
|
|
option={this.templateManageOption.option}
|
|
|
|
|
needBoardName
|
|
|
|
|
/>
|
|
|
|
|
<AutoCutCheckbox isFlex={false} autoCutOption={this.autoCutOption} />
|
|
|
|
|
<AutoCutCheckbox isFlex={false} autoCutOption={this.templateManageOption.autoCutOption} />
|
|
|
|
|
<div className={Classes.DIALOG_FOOTER_ACTIONS}>
|
|
|
|
|
{
|
|
|
|
|
<Button
|
|
|
|
|