!1097 功能:绘制裤杆

pull/1097/MERGE
ZoeLeeFZ 4 years ago committed by ChenX
parent 5f4466e3d5
commit 21438b50c7

@ -191,7 +191,7 @@ class LookOverBoardInfosTool
let c = safeEval(d.HardwareOption.count, { L: size.x, W: size.y, H: size.z }) ?? 0;
return v + c;
}, 0);
hardwareCount.push({ name: k.split(",")[0], count: v.length, entity: v[0], count2 });
hardwareCount.push({ name: k.split(",")[0], count: v.length, entity: v[0], count2: FixedNotZero(count2, 2) });
}
else
{

@ -144,6 +144,7 @@ async function PrintImage(ens: Entity[])
//等待字体加载完
await Sleep(10);
app.Viewer.CameraCtrl.LookAt(new Vector3(0, 0, -1));
app.Viewer.ZoomAll(false);
app.Viewer.Zoom(1);

@ -22,6 +22,7 @@ export class TemplateTagCommand
{
//标签-id
private _tagList: ITempTagProps[] = [];
private _needUpload = false;
get TagList()
{
return this._tagList;
@ -91,6 +92,7 @@ export class TemplateTagCommand
timeout: 3000,
intent: Intent.SUCCESS,
});
this._needUpload = true;
}
RemoveTag(tagName: string)
{
@ -101,9 +103,12 @@ export class TemplateTagCommand
timeout: 3000,
intent: Intent.SUCCESS,
});
this._needUpload = true;
}
async UploadTagList()
{
if (!this._needUpload) return;
let data = await PostJson(ConfigUrls.Edit, { key: TemplateTagCommand.name, value: JSON.stringify(this._tagList) });
if (data.err_code === RequestStatus.Ok)
{
@ -111,6 +116,7 @@ export class TemplateTagCommand
dbStore.Put(StoreName.ConfigData, GetIndexDBID(TemplateTagCommand.name), this._tagList.slice());
dbStore.Put(StoreName.ConfigVersion, GetIndexDBID(TemplateTagCommand.name), data.version);
}
this._needUpload = false;
}
ReadTagList(tags: ITempTagProps[])
{
@ -121,7 +127,7 @@ export class TemplateTagCommand
commandMachine.RegisterCommand(tag.tagName, new ShowTemplate(tag));
}
}
ModifyTagName(tagName: string, newName: string)
ModifyTagName(tagName: string, newName: string, desc?: string)
{
if (!this.CheckTagName(newName)) return;
@ -129,8 +135,16 @@ export class TemplateTagCommand
if (tag)
{
commandMachine.RemoveCommand(tagName);
tag.tagName = newName;
commandMachine.RegisterCommand(newName, new ShowTemplate(tag));
if (newName)
{
tag.tagName = newName;
commandMachine.RegisterCommand(newName, new ShowTemplate(tag));
}
else
{
tag.description = desc;
}
this._needUpload = true;
}
}
ClearTagList()

@ -2,6 +2,7 @@ import { ApplicationService, app } from "../ApplicationServices/Application";
import { CADObject } from "./CADObject";
import { Board } from "./Entity/Board";
import { LinesType } from "../UI/Store/BoardInterface";
import { userConfig } from "../Editor/UserConfig";
export class BoardLinesReactor
{
@ -45,10 +46,11 @@ const linesName = ["正纹", "反纹", "可翻转"];
function IsLong(br: Board, lines = br.BoardProcessOption.lines): boolean
{
const { width, height } = userConfig.maxSize;
if (lines === LinesType.Positive)
return br.Width > 1220 || br.Height > 2440;
return br.Width > width || br.Height > height;
else if (lines === LinesType.Reverse)
return br.Height > 1220 || br.Width > 2440;
return br.Height > width || br.Width > height;
else
return br.Height > 2440 || br.Width > 2440 || (br.Width > 1220 && br.Height > 1220);
return br.Height > height || br.Width > height || (br.Width > width && br.Height > width);
}

@ -713,11 +713,11 @@ export class Board extends ExtrudeSolid
{
case LinesType.Positive:
len = this.height / 3;
width = len / 10;
width = Math.min(this.width, this.height) / 8;
break;
case LinesType.Reverse:
len = this.width / 2;
width = len / 10;
width = Math.min(this.width, this.height) / 8;
break;
case LinesType.CanReversal:
len = this.height / 3;

@ -579,3 +579,13 @@ export const DefaultUpdateInfoOption: IUpdateBoardInfosOption = {
};
Object.freeze(DefaultUpdateInfoOption);
export const DefaultKuGanOption = {
count: 1,
isHor: false,
depth: 0,
isDefault: true,
leftDist: 0,
rightDist: 0,
};
Object.freeze(DefaultKuGanOption);

@ -83,7 +83,7 @@ export class Editor
this.MaskManage = new MaskManage();
this.ModalManage = new ModalManage(this);
this.CommandInput = new CommandInputManage();
new SpeechBoxManage();
// new SpeechBoxManage();
this.InteractiveServices = [
this.SnapDragServices,

@ -143,8 +143,7 @@ export class PointShapeUtils
];
else
{
let w1 = width / 10;
let l1 = len / 10;
let w1 = Math.min(len, width) / 5;
return [
new Vector3(0, len / 2), new Vector3(0, -len / 2),
@ -155,10 +154,10 @@ export class PointShapeUtils
new Vector3(width / 2), new Vector3(width / 2 - w1, w1),
new Vector3(width / 2), new Vector3(width / 2 - w1, -w1),
new Vector3(0, len / 2), new Vector3(-l1, len / 2 - l1),
new Vector3(0, len / 2), new Vector3(l1, len / 2 - l1),
new Vector3(0, -len / 2), new Vector3(-l1, -len / 2 + l1),
new Vector3(0, -len / 2), new Vector3(l1, -len / 2 + l1),
new Vector3(0, len / 2), new Vector3(-w1, len / 2 - w1),
new Vector3(0, len / 2), new Vector3(w1, len / 2 - w1),
new Vector3(0, -len / 2), new Vector3(-w1, -len / 2 + w1),
new Vector3(0, -len / 2), new Vector3(w1, -len / 2 + w1),
];
}
}

@ -4,10 +4,10 @@ import { observer } from 'mobx-react';
import React, { Component } from 'react';
import { Box3, Mesh, MeshBasicMaterial, Vector3 } from 'three';
import { app } from '../../../ApplicationServices/Application';
import { Solid3D } from '../../../Common/InterfereUtil';
import { ColorMaterial } from './../../../Common/ColorPalette';
import { FixIndex } from './../../../Common/Utils';
import { CommonModal } from './ModalContainer';
import { Solid3D } from '../../../Common/InterfereUtil';
interface IInterfereProps
{

@ -9,6 +9,7 @@ import { ToasterInput } from '../../Toaster';
import { CheckObjectType } from '../../../../Common/CheckoutVaildValue';
import { IUiOption } from '../../../Store/BoardInterface';
import { Board } from '../../../../DatabaseServices/Entity/Board';
import { CompositeEntity } from '../../../../DatabaseServices/Entity/CompositeEntity';
interface IConfigProps
{
@ -25,11 +26,16 @@ export class DrawConfigPanel extends React.Component<IConfigProps, {}> {
userConfig.openDrillingReactor = !userConfig.openDrillingReactor;
app._drillingReactor.Enable = userConfig.openDrillingReactor;
};
private toggleAutoCuttingReactor = () =>
UpdateBoard(cm: CompositeEntity)
{
const userConfig = this.props.store;
userConfig.openAutoCuttingReactor = !userConfig.openAutoCuttingReactor;
};
for (let en of cm.Entitys)
{
if (en instanceof Board)
en.Update();
else if (en instanceof CompositeEntity)
this.UpdateBoard(en);
}
}
UNSAFE_componentWillMount()
{
const cof = this.props.store;
@ -40,7 +46,17 @@ export class DrawConfigPanel extends React.Component<IConfigProps, {}> {
{
if (this.oldShowLine !== userConfig.showLines)
{
app.Database.ModelSpace.Entitys.forEach(e => !e.IsErase && e instanceof Board && e.Update());
for (let en of app.Database.ModelSpace.Entitys)
{
if (!en.IsErase)
{
if (en instanceof Board)
en.Update();
else if (en instanceof CompositeEntity)
this.UpdateBoard(en);
}
}
app.Editor.UpdateScreen();
}
}
public render()

@ -328,7 +328,7 @@ export class ProcessingGroupModal extends React.Component<{ store: ProcessingGro
{
let leftTN: ITreeNode = {
id: this.getNodeID.nextID,
label: `${pgs}`,
label: <span title={pgs}> {pgs}</span>,
childNodes: [],
nodeData: "p" + pgs,
hasCaret: false

@ -0,0 +1,93 @@
import { Checkbox, Classes, Label, Spinner } from '@blueprintjs/core';
import { observer } from 'mobx-react';
import * as React from 'react';
import { CheckObjectType } from '../../../Common/CheckoutVaildValue';
import { KuGanStore } from '../../Store/KuGanStore';
import { ToasterInput } from '../Toaster';
import { observable } from 'mobx';
interface IKuGanDetailProps
{
store: KuGanStore;
}
@observer
export class KuGanDetail extends React.Component<IKuGanDetailProps> {
@observable private isLoading = true;
async componentDidMount()
{
await this.props.store.Load();
this.isLoading = false;
this.props.store.Watch();
}
componentWillUnmount()
{
this.props.store.StopWatch();
}
public render()
{
const store = this.props.store;
const option = store.option;
if (this.isLoading)
return <Spinner />;
return (
<div className="kugan">
<div className="flex">
<Label className={Classes.INLINE}>
<span>:</span>
<ToasterInput
optKey="count"
option={option}
uiOption={store.UIOption}
type={CheckObjectType.BR}
/>
</Label>
<Checkbox
checked={option.isHor}
inline
label="横插"
onChange={() => option.isHor = !option.isHor}
/>
</div>
<div className="flex">
<Label className={Classes.INLINE}>
<span>:</span>
<ToasterInput
isDisabled={option.isDefault}
optKey="depth"
option={option}
uiOption={store.UIOption}
type={CheckObjectType.BR}
/>
</Label>
<Checkbox
checked={option.isDefault}
inline
label="默认(板厚一半)"
onChange={() => option.isDefault = !option.isDefault}
/>
</div>
<div className="flex">
<Label className={Classes.INLINE}>
<span>{option.isHor ? "前距:" : "左距:"}</span>
<ToasterInput
optKey="leftDist"
option={option}
uiOption={store.UIOption}
type={CheckObjectType.OnlyNumber}
/>
</Label>
<Label className={Classes.INLINE}>
<span>{option.isHor ? "后距:" : "右距:"}</span>
<ToasterInput
optKey="rightDist"
option={option}
uiOption={store.UIOption}
type={CheckObjectType.OnlyNumber}
/>
</Label>
</div>
</div>
);
}
}

@ -97,6 +97,32 @@
}
}
}
}
}
.kugan {
margin-top: 20px;
&>div {
&>label {
display: flex;
align-items: center;
text-align: left;
flex: 1;
}
&>label:first-child {
span {
width: 60px;
}
margin-right: 10px;
}
.bp3-checkbox {
margin: 0;
}
}
}

@ -32,13 +32,19 @@ import { IDrawerDoorTempInfo, HandleHorPos, HandleVePos } from '../../Store/Door
import { BoardOpenDir, IDrawBoardAutoCutOption } from '../../Store/BoardInterface';
import { DoorStore } from '../../Store/DoorDrawerStore/DoorStore';
import { TemplateTagCom } from './TemplateTagCom';
import { ReadAutoCutConfig } from '../../../Add-on/TemplateSearch';
import { ReadAutoCutConfig, UploadAutoCutConfig } from '../../../Add-on/TemplateSearch';
import { AutoCutting } from '../../../Add-on/BoardCutting/AutoCuttingReactor';
import { AutoCutCheckbox } from '../Board/BoardCommon';
import { templateTagCommand, ITempTagProps } from '../../../Add-on/Template/TemplateTagCommand';
import { KeyBoard } from '../../../Common/KeyEnum';
import { Filter } from '../../../Editor/SelectFilter';
import { PositioningBoardSpace } from '../../../DatabaseServices/Template/Positioning/PositioningBoardSpace';
import { kuGanStore } from '../../Store/KuGanStore';
import { ISpaceParse } from '../../../Geometry/SpaceParse/ISpaceParse';
import { TemplateSplitType } from '../../../DatabaseServices/Template/TemplateType';
import { Point2SpaceParse } from '../../../Geometry/SpaceParse/Point2SpaceParse';
import { HardwareCompositeEntity } from '../../../DatabaseServices/Hardware/HardwareCompositeEntity';
import { HardwareTopline } from '../../../DatabaseServices/Hardware/HardwareTopline';
export interface INeedUpdateParams
{
@ -241,6 +247,19 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
};
private handleInsert = async (isByBasePt: boolean) =>
{
if (!isByBasePt && this.currentTemplateInfo.isKuGan)
{
if (kuGanStore.HasInvailValue())
{
AppToaster.show({
message: "存在无效数值,请修正",
timeout: 3000,
intent: Intent.DANGER
});
return;
}
}
app.Editor.ModalManage.ToggleShow();
app.Editor.MaskManage.Clear();
localStorage.setItem(StoreageKeys.RoomName, this.option.roomName);
@ -320,6 +339,12 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
if (!isVsTemp)
b.BoardProcessOption[EBoardKeyList.CabinetName] = this.option.cabName;
}
else if (b instanceof HardwareCompositeEntity || b instanceof HardwareTopline)
{
b.HardwareOption[EBoardKeyList.RoomName] = this.option.roomName;
if (!isVsTemp)
b.HardwareOption[EBoardKeyList.CabinetName] = this.option.cabName;
}
}
mtx.setPosition(ptRes.Point.sub(baseP));
for (let e of ents)
@ -339,6 +364,36 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
else break;
}
};
private SetRootCabName = (template: TemplateRecord, parse: ISpaceParse) =>
{
let nents = template.AllEntitys;
//设置房名和柜名
let [roomName, cabName] = [this.option.roomName, this.option.cabName];
if (!parse.VisualSpaceBox && !(parse instanceof Point2SpaceParse))
{
if (parse.Boards.length > 0)
{
let process = parse.Boards[0].BoardProcessOption;
[roomName, cabName] = [process[EBoardKeyList.RoomName], process[EBoardKeyList.CabinetName]];
}
}
for (let b of nents)
{
if (b instanceof Board)
{
b.BoardProcessOption[EBoardKeyList.RoomName] = roomName;
b.BoardProcessOption[EBoardKeyList.CabinetName] = cabName;
}
else if (b instanceof HardwareCompositeEntity || b instanceof HardwareTopline)
{
b.HardwareOption[EBoardKeyList.RoomName] = roomName;
b.HardwareOption[EBoardKeyList.CabinetName] = cabName;
}
}
};
private handleInsertBySpace = async () =>
{
let orgTemplate = await GetOnlineTemplate(this.currentTemplateInfo.id, this.currentProps);
@ -357,31 +412,93 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
let parse = selectSpace.SpaceParse;
let template = app.Database.WblockCloneObejcts([orgTemplate], app.Database.TemplateTable, new Map(), DuplicateRecordCloning.Ignore)[0] as TemplateRecord;
let nents = template.AllEntitys;
if (this.currentTemplateInfo.isKuGan)
{
this.DrawKuGanBySpace(parse, orgTemplate);
}
else
{
let template = app.Database.WblockCloneObejcts([orgTemplate], app.Database.TemplateTable, new Map(), DuplicateRecordCloning.Ignore)[0] as TemplateRecord;
//设置房名和柜名
let [roomName, cabName] = [this.option.roomName, this.option.cabName];
this.SetRootCabName(template, parse);
if (!parse.VisualSpaceBox)
{
if (parse.Boards.length > 0)
{
let process = parse.Boards[0].BoardProcessOption;
[roomName, cabName] = [process[EBoardKeyList.RoomName], process[EBoardKeyList.CabinetName]];
}
await SetTemplatePositionAndSetParent(parse, template);
}
}
};
private DrawKuGanBySpace = async (space: ISpaceParse, kugan: TemplateRecord) =>
{
kuGanStore.Upload();
const option = kuGanStore.option;
const { isHor, isDefault, leftDist, rightDist, depth } = option;
const kuGanSpace = new TemplateRecord().InitBaseParams();
kuGanSpace.Name = "裤杆空间";
app.Database.TemplateTable.Append(kuGanSpace);
kuGanSpace.SplitType = TemplateSplitType.X;
if (space.Boards.some(e => e.Template))
kuGanSpace.GetParam("BH").expr = "_BH";
else
{
kuGanSpace.GetParam("BH").value = space.Boards[0]?.Thickness ?? 18;
AppToaster.show({
message: "该空间不存在模板,可能造成未知问题",
timeout: 5000,
intent: Intent.WARNING,
});
}
kuGanSpace.LParam.value = space.Size.x;
kuGanSpace.WParam.value = space.Size.y;
kuGanSpace.HParam.value = space.Size.z;
kugan.WParam.expr = isDefault ? "_W+_BH" : "_W+" + depth * 2;
kugan.PZParam.expr = "_H*0.5";
let count = option.count + 1;
if (leftDist && rightDist)
count = option.count - 1;
else if (leftDist || rightDist)
{
count = option.count;
}
this.SetRootCabName(kugan, space);
for (let b of nents)
for (let i = 0; i < option.count; i++)
{
let kg = app.Database.WblockCloneObejcts([kugan], app.Database.TemplateTable, new Map(), DuplicateRecordCloning.Ignore)[0] as TemplateRecord;
kg.PYParam.expr = isDefault ? "-_BH*0.5" : -depth;
if (i === 0 && leftDist)
{
if (b instanceof Board)
{
b.BoardProcessOption[EBoardKeyList.RoomName] = roomName;
b.BoardProcessOption[EBoardKeyList.CabinetName] = cabName;
}
kg.PXParam.expr = leftDist;
}
else
{
let expr = leftDist ? `${leftDist}+` : "";
expr += (leftDist || rightDist) ? (`(_L${leftDist ? ("-" + leftDist) : ""}${rightDist ? ("-" + rightDist) : ""})`) : "_L";
expr += `/${count}*${leftDist ? i : (i + 1)}`;
kg.PXParam.expr = expr;
}
kuGanSpace.Children.push(kg.Id);
}
if (isHor)
space.Rotation.z += 90;
await SetTemplatePositionAndSetParent(parse, template);
await SetTemplatePositionAndSetParent(space, kuGanSpace);
if (kuGanSpace.Parent)
{
let parTemp = kuGanSpace.Parent.Object as TemplateRecord;
let parBh = parTemp.GetParam("BH");
if (!parBh)
{
AppToaster.show({
message: "裤杆上层模板没有板厚参数,请添加!",
timeout: 5000,
intent: Intent.WARNING,
});
}
}
};
private handleEditor = async () =>
@ -712,6 +829,7 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
componentWillUnmount()
{
templateTagCommand.UploadTagList();
UploadAutoCutConfig(TemplateManage.name, this.autoCutOption);
}
public render()
{
@ -765,7 +883,7 @@ export class TemplateManage extends React.Component<ITemplateManage, {}> {
className={Classes.INTENT_PRIMARY}
text="模块替换"
onClick={this.handleReplace}
disabled={!this.currentTemplateInfo.id}
disabled={!this.currentTemplateInfo.id || this.currentTemplateInfo.isKuGan}
/>
</div>
</div>

@ -15,6 +15,8 @@ import { safeEval } from '../../../Common/eval';
import { SetBoardDataItem } from '../Board/BoardCommon';
import { templateTagCommand } from '../../../Add-on/Template/TemplateTagCommand';
import { IDirectoryProps } from '../SourceManage/CommonPanel';
import { KuGanDetail } from './KuGanDetail';
import { kuGanStore } from '../../Store/KuGanStore';
export interface ITemplateDetailProps
{
@ -52,6 +54,80 @@ export class TemplateDetail extends React.Component<ITemplateDetailProps> {
static defaultProps = {
isShowTag: true
};
private renderHandleConfig = () =>
{
const store = DoorStore.GetInstance() as DoorStore;
return (
<div style={{ textAlign: "left" }}>
<Divider />
<H5></H5>
<Checkbox
label="根据开门方向识别位置(需先设置开门方向)"
checked={store.byOpenDir}
onChange={() => store.byOpenDir = !store.byOpenDir}
/>
<div>
<RadioGroup
className="door-pos-type"
inline={true}
selectedValue={store.m_Option.handleHorPos}
onChange={e =>
{
store.m_Option.handleHorPos = safeEval(e.currentTarget.value) as HandleHorPos;
}}
>
<Radio label="左距" value={HandleHorPos.Left} />
<Radio label="右距" value={HandleHorPos.Right} />
<Radio label="居中" value={HandleHorPos.Mid} />
</RadioGroup>
<ToasterInput
type={CheckObjectType.Do}
optKey="horSpacing"
option={store.m_Option}
uiOption={store.UIOption}
inline={true}
inputClassName="detail-pos"
/>
</div>
<div>
<RadioGroup
className="door-pos-type"
inline={true}
selectedValue={store.m_Option.handleVePos}
onChange={e =>
{
store.m_Option.handleVePos = safeEval(e.currentTarget.value) as HandleVePos;
}}
>
<Radio label="上距" value={HandleVePos.Top} />
<Radio label="下距" value={HandleVePos.Bottom} />
<Radio label="居中" value={HandleVePos.Mid} />
</RadioGroup>
<ToasterInput
type={CheckObjectType.Do}
optKey="veSpacing"
option={store.m_Option}
uiOption={store.UIOption}
inline={true}
inputClassName="detail-pos"
/>
</div>
<SetBoardDataItem
type={CheckObjectType.Do}
optKey="handleAngle"
option={store.m_Option}
uiOption={store.UIOption}
title="旋转角"
/>
</div>
);
};
private renderKuGanggConfigs = () =>
{
return (
<KuGanDetail store={kuGanStore} />
);
};
public render()
{
let disabledKeys = this.props.disableKeys || [];
@ -193,69 +269,10 @@ export class TemplateDetail extends React.Component<ITemplateDetailProps> {
</div>
}
{
!this.props.showSelectTemp && this.props.currentInfo?.id && this.props.currentInfo.isHandle &&
<div style={{ textAlign: "left" }}>
<Divider />
<H5></H5>
<Checkbox
label="根据开门方向识别位置(需先设置开门方向)"
checked={store.byOpenDir}
onChange={() => store.byOpenDir = !store.byOpenDir}
/>
<div>
<RadioGroup
className="door-pos-type"
inline={true}
selectedValue={store.m_Option.handleHorPos}
onChange={e =>
{
store.m_Option.handleHorPos = safeEval(e.currentTarget.value) as HandleHorPos;
}}
>
<Radio label="左距" value={HandleHorPos.Left} />
<Radio label="右距" value={HandleHorPos.Right} />
<Radio label="居中" value={HandleHorPos.Mid} />
</RadioGroup>
<ToasterInput
type={CheckObjectType.Do}
optKey="horSpacing"
option={store.m_Option}
uiOption={store.UIOption}
inline={true}
inputClassName="detail-pos"
/>
</div>
<div>
<RadioGroup
className="door-pos-type"
inline={true}
selectedValue={store.m_Option.handleVePos}
onChange={e =>
{
store.m_Option.handleVePos = safeEval(e.currentTarget.value) as HandleVePos;
}}
>
<Radio label="上距" value={HandleVePos.Top} />
<Radio label="下距" value={HandleVePos.Bottom} />
<Radio label="居中" value={HandleVePos.Mid} />
</RadioGroup>
<ToasterInput
type={CheckObjectType.Do}
optKey="veSpacing"
option={store.m_Option}
uiOption={store.UIOption}
inline={true}
inputClassName="detail-pos"
/>
</div>
<SetBoardDataItem
type={CheckObjectType.Do}
optKey="handleAngle"
option={store.m_Option}
uiOption={store.UIOption}
title="旋转角"
/>
</div>
!this.props.showSelectTemp && this.props.currentInfo?.id && this.props.currentInfo.isHandle && this.renderHandleConfig()
}
{
!this.props.showSelectTemp && this.props.currentInfo?.id && this.props.currentInfo.isKuGan && this.renderKuGanggConfigs()
}
</div>
);

@ -0,0 +1,10 @@
export interface IKuGangDrawOption
{
count: number;
isHor: boolean;
depth: number;
isDefault: boolean;
leftDist: number;
rightDist: number;
}

@ -154,6 +154,7 @@ export class TemplateList extends React.Component<ITemplateListProps> {
this.props.currentInfo.name = temp.name;
this.props.currentInfo.logo = temp.logo;
this.props.currentInfo.isHandle = this.props.currentDir.path.includes("拉手");
this.props.currentInfo.isKuGan = this.props.currentDir.path.includes("裤杆");
let pars = TemplateParamsIn(JSON.parse(inflate(temp.props)));
this._params = pars;
observable(this.props.currentProps).replace(pars.map(p =>
@ -184,12 +185,12 @@ export class TemplateList extends React.Component<ITemplateListProps> {
//选择的模板信息
if (this.props.selectInfo)
{
if (this.props.currentDir.path.includes("拉手"))
if (this.props.currentDir.path.startsWith("拉手"))
{
Object.assign(this.props.selectInfo.handleTemp, this.props.currentInfo, { props: [...this.props.currentProps] });
return;
}
if (this.props.selectInfo.hingeTemp && this.props.currentDir.path.includes("铰链"))
if (this.props.selectInfo.hingeTemp && this.props.currentDir.path.startsWith("铰链"))
{
Object.assign(this.props.selectInfo.hingeTemp, this.props.currentInfo);
return;

@ -38,17 +38,13 @@ export class TemplateTagCom extends React.Component<ITemplateTagComProps> {
private isDesc = true;
async UNSAFE_componentWillMount()
{
this.currentTag = this.props.currentTag;
Object.assign(this.currentTag, this.props.currentTag);
await this.readTemplateInfo();
}
componentWillUnmount()
{
templateTagCommand.UploadTagList();
}
public render()
{
return (
<Card tabIndex={-1} className="flex" style={{ height: "100%" }}>
<Card tabIndex={-1} className="flex" style={{ height: "100%", outline: "none" }}>
<ul className="tag-name-list">
{
templateTagCommand.TagList.map(tag =>
@ -153,6 +149,9 @@ export class TemplateTagCom extends React.Component<ITemplateTagComProps> {
this.props.currentTemplateInfo.id = mid;
this.props.currentTemplateInfo.name = name;
this.props.currentTemplateInfo.isHandle = this.currentTag.description.includes("拉手");
this.props.currentTemplateInfo.isKuGan = this.currentTag.description.includes("裤杆");
if (!this.props.cabOption.useCabName)
{
this.props.cabOption.cabName = data.name;
@ -228,9 +227,15 @@ export class TemplateTagCom extends React.Component<ITemplateTagComProps> {
private addTagDesc = (val: string) =>
{
if (this.isDesc)
templateTagCommand.GetTagByName(this.currentTag.tagName).description = val;
{
templateTagCommand.ModifyTagName(this.currentTag.tagName, undefined, val);
this.currentTag.description = val;
}
else
{
templateTagCommand.ModifyTagName(this.currentTag.tagName, val.toUpperCase());
this.currentTag.tagName = val.toUpperCase();
}
this.canInput.set(false);
};
}

@ -11,10 +11,9 @@
}
.bp3-card.newDir.style2 {
position: fixed;
position: absolute;
top: 40%;
left: -10%;
width: 120%;
left: 10%;
z-index: 25;
.bp3-label.bp3-inline {
@ -64,6 +63,10 @@
}
}
}
.bp3-tree-node-caret-none {
min-width: 0;
}
}
.right {

@ -127,6 +127,7 @@ export interface IDrawerDoorTempInfo
title?: string;
isHandle?: boolean;
tagName?: string;
isKuGan?: boolean;
}
/**选择的模板信息,temp-抽屉或门板,handletemp-拉手模板,其他是铰链模板 */

@ -0,0 +1,89 @@
import { IKuGangDrawOption } from "../Components/Template/TemplateInterface";
import { DefaultKuGanOption } from "../../Editor/DefaultConfig";
import { IUiOption } from "./BoardInterface";
import { DataAdapter } from "../../Common/DataAdapter";
import { observable, toJS, autorun, reaction, action } from "mobx";
import { safeEval } from "../../Common/eval";
import { PostJson, RequestStatus } from "../../Common/Request";
import { ConfigUrls } from "../../Common/HostUrl";
import { appCache } from "../../Common/AppCache";
export class KuGanStore
{
@observable option: IKuGangDrawOption = { ...DefaultKuGanOption };
@observable uiOption: IUiOption<IKuGangDrawOption>;
private watch: Function;
private needUpdate = false;
get UIOption()
{
if (!this.uiOption)
this.uiOption = DataAdapter.ConvertUIData(this.option);
return this.uiOption;
}
Watch()
{
this.watch = reaction(() => Object.keys(this.option).map(k => this.option[k]), () =>
{
this.needUpdate = true;
});
}
StopWatch()
{
this.watch();
this.watch = undefined;
}
HasInvailValue()
{
let uiOption = this.UIOption;
let count = safeEval(uiOption.count);
if (!count || count < 0) return true;
for (let k in uiOption)
{
if (k !== "count" && typeof uiOption[k] === 'string')
{
let v = safeEval(uiOption[k]);
if (isNaN(v))
return true;
}
}
return false;
}
async Upload()
{
if (!this.needUpdate) return;
if (this.HasInvailValue()) return;
let data = await PostJson(ConfigUrls.Edit, { key: KuGanStore.name, value: JSON.stringify(toJS(this.option)) });
if (data.err_code === RequestStatus.Ok)
{
appCache.set(KuGanStore.name, toJS(this.option));
}
this.needUpdate = false;
}
@action
async Load()
{
if (appCache.has(KuGanStore.name))
{
Object.assign(this.option, appCache.get(KuGanStore.name));
Object.assign(this.UIOption, DataAdapter.ConvertUIData(appCache.get(KuGanStore.name)));
}
else
{
let data = await PostJson(ConfigUrls.Get, { key: KuGanStore.name }, false);
if (data.err_code === RequestStatus.Ok && data.value)
{
let config = JSON.parse(data.value);
appCache.set(KuGanStore.name, JSON.parse(data.value));
Object.assign(this.option, config);
Object.assign(this.UIOption, DataAdapter.ConvertUIData(config));
}
}
}
}
export const kuGanStore = new KuGanStore();
Loading…
Cancel
Save