!662 优化抽屉上下留空参数的更新机制

pull/662/MERGE
ZoeLeeFZ 5 years ago committed by ChenX
parent 9f72e623c2
commit 2a111f980d

@ -46,9 +46,9 @@ export class DrawDoorTool
for (let info of doorInfos) for (let info of doorInfos)
{ {
if (info.tempInfo.temp.id) if (info.tempInfo && info.tempInfo.temp.id)
tempIds.add(info.tempInfo.temp.id); tempIds.add(info.tempInfo.temp.id);
if (info.tempInfo.handleTemp.id) if (info.tempInfo && info.tempInfo.handleTemp.id)
tempIds.add(info.tempInfo.handleTemp.id); tempIds.add(info.tempInfo.handleTemp.id);
let key = (row - info.row - 1).toString() + "-" + info.col.toString(); let key = (row - info.row - 1).toString() + "-" + info.col.toString();

@ -20,7 +20,6 @@ import { TemplateSizeBoard } from "../../DatabaseServices/Template/ProgramTempat
import { ISpaceParse } from "../../Geometry/SpaceParse/ISpaceParse"; import { ISpaceParse } from "../../Geometry/SpaceParse/ISpaceParse";
import { EBoardKeyList } from "../../Common/BoardKeyList"; import { EBoardKeyList } from "../../Common/BoardKeyList";
import { BoardModalType } from "../../UI/Components/Board/BoardModal"; import { BoardModalType } from "../../UI/Components/Board/BoardModal";
import { INeedUpdateParams } from "../../UI/Components/Template/TemplateComponent";
export class DrawDrawrer implements Command export class DrawDrawrer implements Command
{ {
@ -96,6 +95,11 @@ export class DrawDrawrer implements Command
for (let id of [...tempIds]) for (let id of [...tempIds])
{ {
let temp = await GetOnlineTemplate(id); let temp = await GetOnlineTemplate(id);
if (!temp)
{
console.warn(temp.Name, temp.Id, "这个抽屉不能用");
continue;
}
let ens = temp.Db.ModelSpace.Entitys; let ens = temp.Db.ModelSpace.Entitys;
if (surroundOption) if (surroundOption)
for (let en of ens) for (let en of ens)
@ -143,7 +147,18 @@ export class DrawDrawrer implements Command
let depthTemp = GetDeepestTemplate(tbrs); let depthTemp = GetDeepestTemplate(tbrs);
let templateSpace = this.GetRootTemplate(spaceParse, store.m_Option, store.currentRotationExpr); //根空间
let rootSpaceTemplate = this.GetTotalSpaceTemplate(spaceParse);
let isLockHeigt = store.IsLockDrawerHeight;
let xlkSpace = this.GetLkSpace(store.m_Option.isLockBottomOffset || !isLockHeigt || !store.m_Option.isLockTopOffset, store.m_Option.bottomOffset, false);
rootSpaceTemplate.Children.push(xlkSpace.Id);
//抽屉根空间
let templateSpace = this.GetRootTemplate(spaceParse, store, isLockHeigt);
rootSpaceTemplate.Children.push(templateSpace.Id);
let slkSpace = this.GetLkSpace(store.m_Option.isLockTopOffset || !isLockHeigt, store.m_Option.topOffset, true);
rootSpaceTemplate.Children.push(slkSpace.Id);
for (let i = 0; i < col; i++) for (let i = 0; i < col; i++)
{ {
@ -171,8 +186,8 @@ export class DrawDrawrer implements Command
} }
} }
if (depthTemp) if (depthTemp)
depthTemp.Children.push(templateSpace.Id); depthTemp.Children.push(rootSpaceTemplate.Id);
await templateSpace.UpdateTemplateTree(); await rootSpaceTemplate.UpdateTemplateTree();
} }
} }
private AppendTemplateParam(name: string, value: number, des: string, temp: TemplateRecord) private AppendTemplateParam(name: string, value: number, des: string, temp: TemplateRecord)
@ -183,17 +198,19 @@ export class DrawDrawrer implements Command
par.description = des; par.description = des;
temp.Params.push(par); temp.Params.push(par);
} }
private GetRootTemplate(spaceParse: ISpaceParse, option: IDrawerConfigOption, roInfos: INeedUpdateParams[]) private GetRootTemplate(spaceParse: ISpaceParse, store: DrawerStore, isLock: boolean)
{ {
const roInfos = store.currentRotationExpr;
const option = store.m_Option;
let templateSpace = new TemplateRecord().InitBaseParams(); let templateSpace = new TemplateRecord().InitBaseParams();
templateSpace.Name = "根空间"; templateSpace.Name = "抽屉根空间";
templateSpace.SplitType = TemplateSplitType.X; templateSpace.SplitType = TemplateSplitType.X;
for (let info of roInfos) for (let info of roInfos)
templateSpace.GetParam(info.name).expr = info.expr; templateSpace.GetParam(info.name).expr = info.expr;
templateSpace.HParam.expr = `H-SLK-XLK`; templateSpace.HParam.expr = isLock ? spaceParse.Size.z - option.topOffset - option.bottomOffset : "_DIV";
templateSpace.PZParam.expr = "XLK";
templateSpace.PYParam.expr = "MBH"; templateSpace.PYParam.expr = "MBH";
let depth = (option.drawerTotalDepth > 0 && option.depth > option.drawerTotalDepth) ? option.drawerTotalDepth : option.depth; let depth = (option.drawerTotalDepth > 0 && option.depth > option.drawerTotalDepth) ? option.drawerTotalDepth : option.depth;
@ -202,9 +219,6 @@ export class DrawDrawrer implements Command
this.AppendTemplateParam("DWDEEPTH", depth, "抽屉深度", templateSpace); this.AppendTemplateParam("DWDEEPTH", depth, "抽屉深度", templateSpace);
this.AppendTemplateParam("MBH", option.offset, "抽屉内缩", templateSpace); this.AppendTemplateParam("MBH", option.offset, "抽屉内缩", templateSpace);
this.AppendTemplateParam("SLK", option.topOffset, "上留空", templateSpace);
this.AppendTemplateParam("XLK", option.bottomOffset, "下留空", templateSpace);
this.AppendTemplateParam("SYS", option.topExt, "上延伸", templateSpace); this.AppendTemplateParam("SYS", option.topExt, "上延伸", templateSpace);
this.AppendTemplateParam("XYS", option.bottomExt, "下延伸", templateSpace); this.AppendTemplateParam("XYS", option.bottomExt, "下延伸", templateSpace);
this.AppendTemplateParam("YYS", option.rightExt, "右延伸", templateSpace); this.AppendTemplateParam("YYS", option.rightExt, "右延伸", templateSpace);
@ -224,18 +238,9 @@ export class DrawDrawrer implements Command
this.AppendTemplateParam("YJ", option.horSpacing, "拉手右距", templateSpace); this.AppendTemplateParam("YJ", option.horSpacing, "拉手右距", templateSpace);
this.AppendTemplateParam("ZJ", option.horSpacing, "拉手左距", templateSpace); this.AppendTemplateParam("ZJ", option.horSpacing, "拉手左距", templateSpace);
if (spaceParse instanceof ClampSpaceParse) templateSpace.LParam.expr = "_L";
{ templateSpace.WParam.expr = "_W";
let positioning = new PositioningClampSpace(); templateSpace.PZParam.expr = "_POS";
positioning.FromSpaceParse(spaceParse);
templateSpace.Positioning = positioning;
}
else
{
templateSpace.LParam.expr = spaceParse.Size.x;
templateSpace.WParam.expr = spaceParse.Size.y;
templateSpace.HParam.expr = spaceParse.Size.z;
}
app.Database.TemplateTable.Append(templateSpace); app.Database.TemplateTable.Append(templateSpace);
return templateSpace; return templateSpace;
@ -433,4 +438,35 @@ export class DrawDrawrer implements Command
verTemp.PZParam.expr = "-_XLK"; verTemp.PZParam.expr = "-_XLK";
return verTemp; return verTemp;
} }
private GetTotalSpaceTemplate(spaceParse: ISpaceParse)
{
let templateSpace = new TemplateRecord().InitBaseParams();
templateSpace.Name = "抽屉总空间";
templateSpace.SplitType = TemplateSplitType.Z;
app.Database.TemplateTable.Append(templateSpace);
if (spaceParse instanceof ClampSpaceParse)
{
let positioning = new PositioningClampSpace();
positioning.FromSpaceParse(spaceParse);
templateSpace.Positioning = positioning;
}
else
{
templateSpace.LParam.expr = spaceParse.Size.x;
templateSpace.WParam.expr = spaceParse.Size.y;
templateSpace.HParam.expr = spaceParse.Size.z;
}
return templateSpace;
}
/**获取上下留空空间模板 */
private GetLkSpace(isLock: boolean, height: number, isSLK: boolean)
{
let templateSpace = new TemplateRecord().InitBaseParams();
templateSpace.Name = isSLK ? "上留空空间" : "下留空空间";
templateSpace.HParam.expr = isLock ? height : `_DIV`;
templateSpace.LParam.expr = "_L";
templateSpace.WParam.expr = "_W";
app.Database.TemplateTable.Append(templateSpace);
return templateSpace;
}
} }

@ -326,7 +326,7 @@ export const DefaultDoorOption = {
Object.freeze(DefaultDoorOption); Object.freeze(DefaultDoorOption);
export const DefaultDrawerOption: IDrawerConfigOption = { export const DefaultDrawerOption: IDrawerConfigOption = {
version: 1, version: 2,
col: 1, col: 1,
row: 1, row: 1,
isAllSelect: true, isAllSelect: true,
@ -355,6 +355,8 @@ export const DefaultDrawerOption: IDrawerConfigOption = {
drawerTotalDepth: 0, drawerTotalDepth: 0,
trackDepth: 0, trackDepth: 0,
isAutoSelectTrack: true, isAutoSelectTrack: true,
isLockTopOffset: false,
isLockBottomOffset: false,
}; };
Object.freeze(DefaultDrawerOption); Object.freeze(DefaultDrawerOption);

@ -40,7 +40,7 @@ interface ISetBlockOption
uiOption?: Object; uiOption?: Object;
className?: string; className?: string;
isInline?: boolean; isInline?: boolean;
onChange?: Function; onChange?: (e, ...arg) => void;
disabled?: boolean; disabled?: boolean;
children?: React.ReactNode; children?: React.ReactNode;
} }
@ -82,6 +82,9 @@ export class SetBoardDataItem extends React.Component<ISetItemOption, {}>
<ToasterInput <ToasterInput
{...props} {...props}
/> />
{
props.children
}
</div> </div>
); );
} }
@ -93,18 +96,11 @@ export const SetBoardDataBlock = observer(
{ {
props.pars.map(([k, v]) => props.pars.map(([k, v]) =>
<SetBoardDataItem <SetBoardDataItem
type={props.type}
key={k} key={k}
optKey={k} optKey={k}
option={props.option}
uiOption={props.uiOption}
title={v} title={v}
isDisabled={props.disabled} isDisabled={props.disabled}
onChange={(e, oldValue) => {...props}
{
if (props.onChange)
props.onChange(k, oldValue);
}}
/> />
) )
} }

@ -1,4 +1,4 @@
import { Checkbox, Divider, H5, H6, Radio, RadioGroup, Intent } from '@blueprintjs/core'; import { Checkbox, Divider, H5, H6, Radio, RadioGroup, Intent, Button } from '@blueprintjs/core';
import { observer } from 'mobx-react'; import { observer } from 'mobx-react';
import * as React from 'react'; import * as React from 'react';
import { CheckObjectType } from '../../../../Common/CheckoutVaildValue'; import { CheckObjectType } from '../../../../Common/CheckoutVaildValue';
@ -12,7 +12,7 @@ import { DrawerStore } from '../../../Store/DoorDrawerStore/DrawerStore';
import { log } from '../../../../Common/Utils'; import { log } from '../../../../Common/Utils';
@observer @observer
export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore }> export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore; }>
{ {
private uiOption; private uiOption;
private isDoor: boolean = true; private isDoor: boolean = true;
@ -52,7 +52,7 @@ export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore }
} }
this.handleDrawerDepth(); this.handleDrawerDepth();
store.CalcInfos(true); store.CalcInfos(true);
} };
private handleDrawerDepth = () => private handleDrawerDepth = () =>
{ {
const store = this.props.store; const store = this.props.store;
@ -63,7 +63,7 @@ export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore }
store.m_Option.depth = val; store.m_Option.depth = val;
this.uiOption.depth = val.toString(); this.uiOption.depth = val.toString();
} }
} };
private toggleSelected = () => private toggleSelected = () =>
{ {
const option = this.props.store.m_Option; const option = this.props.store.m_Option;
@ -73,16 +73,18 @@ export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore }
{ {
info.isSelect = option.isAllSelect; info.isSelect = option.isAllSelect;
} }
} };
private handleTBOffset = (par: string, oldValue: string | number) => private handleTBOffset = (e, oldValue: string | number, par: string) =>
{ {
const store = this.props.store; const store = this.props.store as DrawerStore;
if (store.restHeight) const option = store.m_Option;
if (store.restHeight && store.IsLockDrawerHeight)
{ {
let val = store.restHeight - store.m_Option[par]; let val = store.restHeight - option[par];
if (val < 0) if (val < 0)
{ {
store.m_Option[par] = Number(oldValue) || 0; option[par] = Number(oldValue) || 0;
AppToaster.show({ AppToaster.show({
message: "上下留空过大,值无效,请修正", message: "上下留空过大,值无效,请修正",
timeout: 1500, timeout: 1500,
@ -93,19 +95,19 @@ export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore }
} }
if (par === "topOffset") if (par === "topOffset")
{ {
store.m_Option.bottomOffset = val; option.bottomOffset = val;
this.uiOption.bottomOffset = val.toString(); this.uiOption.bottomOffset = val.toString();
} }
else else
{ {
store.m_Option.topOffset = val; option.topOffset = val;
this.uiOption.topOffset = val.toString(); this.uiOption.topOffset = val.toString();
} }
store.CalcInfos(true); store.CalcInfos(true);
} }
else else
{ {
if (store.m_Option.topOffset + store.m_Option.bottomOffset < store.totalHeight) if (option.topOffset + option.bottomOffset < store.totalHeight)
store.CalcInfos(true); store.CalcInfos(true);
else else
{ {
@ -115,10 +117,53 @@ export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore }
timeout: 1500, timeout: 1500,
intent: Intent.DANGER intent: Intent.DANGER
}); });
store.m_Option[par] = Number(oldValue) || 0; option[par] = Number(oldValue) || 0;
}
}
let isLockHeight = store.IsLockDrawerHeight;
if (par === "topOffset")
{
if (!option.isLockTopOffset && (!option.isLockBottomOffset || !isLockHeight))
option.isLockTopOffset = true;
}
else
{
if (!option.isLockBottomOffset && (!option.isLockTopOffset || !isLockHeight))
option.isLockBottomOffset = true;
} }
};
private toggleLockLiuKong = (isTop: boolean) =>
{
const store = this.props.store as DrawerStore;
let isLockHeight = store.IsLockDrawerHeight;
if (isTop)
{
if (isLockHeight && store.m_Option.isLockBottomOffset && !store.m_Option.isLockTopOffset)
{
AppToaster.show({
message: "上下留空和抽屉空间无法全部锁定",
timeout: 2000,
intent: Intent.DANGER,
});
return;
} }
store.m_Option.isLockTopOffset = !store.m_Option.isLockTopOffset;
} }
else
{
if (isLockHeight && store.m_Option.isLockTopOffset && !store.m_Option.isLockBottomOffset)
{
AppToaster.show({
message: "上下留空和抽屉空间无法全部锁定",
timeout: 2000,
intent: Intent.DANGER,
});
return;
}
store.m_Option.isLockBottomOffset = !store.m_Option.isLockBottomOffset;
}
};
UNSAFE_componentWillMount() UNSAFE_componentWillMount()
{ {
this.uiOption = this.props.store.UIOption; this.uiOption = this.props.store.UIOption;
@ -172,14 +217,46 @@ export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore }
/> />
</div> </div>
<Divider /> <Divider />
<SetBoardDataBlock <div className="flexWrap">
<SetBoardDataItem
className="tb-offset"
inline
type={CheckObjectType.Do} type={CheckObjectType.Do}
className="flexWrap" optKey="topOffset"
pars={[["topOffset", "上留空"], ["bottomOffset", "下留空"]]}
option={store.m_Option} option={store.m_Option}
uiOption={this.uiOption} uiOption={this.uiOption}
onChange={this.handleTBOffset} onChange={this.handleTBOffset}
title="上留空"
>
{
store instanceof DrawerStore &&
<Button
icon={store.m_Option.isLockTopOffset ? "lock" : "unlock"}
minimal
onClick={() => this.toggleLockLiuKong(true)}
/> />
}
</SetBoardDataItem>
<SetBoardDataItem
className="tb-offset"
inline
type={CheckObjectType.Do}
optKey="bottomOffset"
option={store.m_Option}
uiOption={this.uiOption}
onChange={this.handleTBOffset}
title="下留空"
>
{
store instanceof DrawerStore &&
<Button
icon={store.m_Option.isLockBottomOffset ? "lock" : "unlock"}
minimal
onClick={() => this.toggleLockLiuKong(false)}
/>
}
</SetBoardDataItem>
</div>
<Divider /> <Divider />
<div> <div>
<div> <div>
@ -431,6 +508,6 @@ export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore }
</> : null </> : null
} }
</> </>
) );
} }
} }

@ -24,8 +24,8 @@ const getCalcStyles = (info: IDoorInfo, store: DoorDrawerStore): React.CSSProper
height: info.divHeight + "px", height: info.divHeight + "px",
marginRight: info.col === store.m_Option.col - 1 ? "0" : "2px", marginRight: info.col === store.m_Option.col - 1 ? "0" : "2px",
marginBottom: info.row === store.m_Option.row - 1 ? "0" : "2px", marginBottom: info.row === store.m_Option.row - 1 ? "0" : "2px",
} };
} };
//预览图门板比较大时渲染 //预览图门板比较大时渲染
@observer @observer
@ -62,7 +62,7 @@ export class DoorPreviewLgItem extends React.Component<IDoorPreviewItemProps, {}
checked={info.isDrawVer} checked={info.isDrawVer}
onChange={() => onChange={() =>
{ {
info.isDrawVer = !info.isDrawVer info.isDrawVer = !info.isDrawVer;
}} }}
/> />
} }
@ -119,7 +119,7 @@ export class DoorPreviewLgItem extends React.Component<IDoorPreviewItemProps, {}
}} }}
onChange={() => onChange={() =>
{ {
info.isDrawLayer = !info.isDrawLayer info.isDrawLayer = !info.isDrawLayer;
}} }}
/> />
} }
@ -191,14 +191,14 @@ export class DoorPreviewLgItem extends React.Component<IDoorPreviewItemProps, {}
{ {
if (d.name && d.id) if (d.name && d.id)
{ {
return <li>{d.name}</li> return <li>{d.name}</li>;
} }
}) })
} }
</ul> </ul>
</div> </div>
</div> </div>
) );
} }
} }
@ -276,13 +276,13 @@ export class DoorPreviewSmItem extends React.Component<IDoorPreviewItemProps, {}
{ {
if (d.name && d.id) if (d.name && d.id)
{ {
return <li>{d.name}</li> return <li>{d.name}</li>;
} }
}) })
} }
</ul> </ul>
</div> </div>
) );
} }
} }
@ -311,7 +311,7 @@ export class DoorPreviewItem extends React.Component<IDoorPreviewItemProps, {}>{
(e.parentElement.firstElementChild as HTMLDivElement).onclick = () => (e.parentElement.firstElementChild as HTMLDivElement).onclick = () =>
{ {
this.isOpen = false; this.isOpen = false;
} };
e.tabIndex = -1; e.tabIndex = -1;
e.focus(); e.focus();
e.addEventListener('keydown', this.handleKeydown); e.addEventListener('keydown', this.handleKeydown);
@ -344,7 +344,7 @@ export class DoorPreviewItem extends React.Component<IDoorPreviewItemProps, {}>{
> >
</Popover> </Popover>
</div> </div>
) );
} }
private RenderRadiusOption(isDoor: boolean, info: IDoorInfo, store: DoorDrawerStore) private RenderRadiusOption(isDoor: boolean, info: IDoorInfo, store: DoorDrawerStore)
@ -362,7 +362,7 @@ export class DoorPreviewItem extends React.Component<IDoorPreviewItemProps, {}>{
<Radio label="上开门" value={DoorOpenDir.Top} /> <Radio label="上开门" value={DoorOpenDir.Top} />
<Radio label="下开门" value={DoorOpenDir.Bottom} /> <Radio label="下开门" value={DoorOpenDir.Bottom} />
<Radio label="无类型" value={DoorOpenDir.None} /> <Radio label="无类型" value={DoorOpenDir.None} />
</RadioGroup>) </RadioGroup>);
} }
private RenderInputAndLock(info: IDoorInfo, store: DoorDrawerStore, isDoor: boolean): React.ReactNode private RenderInputAndLock(info: IDoorInfo, store: DoorDrawerStore, isDoor: boolean): React.ReactNode
{ {
@ -443,7 +443,7 @@ export class DoorPreviewItem extends React.Component<IDoorPreviewItemProps, {}>{
info.isSelect = !info.isSelect; info.isSelect = !info.isSelect;
observable(this.props.store.currentTempProp).replace(toJS(info.tempInfo.temp.props)); observable(this.props.store.currentTempProp).replace(toJS(info.tempInfo.temp.props));
}, 200); }, 200);
} };
private handleKeydown = (ev: KeyboardEvent) => private handleKeydown = (ev: KeyboardEvent) =>
{ {
if (ev.keyCode === KeyBoard.Escape) if (ev.keyCode === KeyBoard.Escape)
@ -451,5 +451,5 @@ export class DoorPreviewItem extends React.Component<IDoorPreviewItemProps, {}>{
this.isOpen = false; this.isOpen = false;
ev.stopPropagation(); ev.stopPropagation();
} }
} };
} }

@ -174,4 +174,10 @@
text-align: center text-align: center
} }
} }
.tb-offset {
&>span {
line-height: 30px;
}
}
} }

@ -69,7 +69,7 @@ export class ToasterInput extends React.Component<IToasterInputProps, {}>
} }
//值有效才运行change函数 //值有效才运行change函数
if (this.hideErrorMsg && this.props.onChange) if (this.hideErrorMsg && this.props.onChange)
this.props.onChange(e, oldValue); this.props.onChange(e, oldValue, this.props.optKey);
}; };
handleClick = e => handleClick = e =>
{ {

@ -299,12 +299,16 @@ export class LayerBoardStore extends BoardStore
if (this.uiLayerNailOption) if (this.uiLayerNailOption)
Object.assign(this.uiLayerNailOption, DataAdapter.ConvertUIData(this.layerNailOption)); Object.assign(this.uiLayerNailOption, DataAdapter.ConvertUIData(this.layerNailOption));
if (cof.option["version"] === undefined) if (this.m_Option.version === undefined)
{
this.m_Option.version = 1;
if (this.m_Option.calcHeight === "L")
{ {
this.m_Option.calcHeight = "W"; this.m_Option.calcHeight = "W";
this.UIOption.calcHeight = "W"; this.UIOption.calcHeight = "W";
} }
} }
}
HasInvailValue() HasInvailValue()
{ {
return super.HasInvailValue() || !Object.keys(this.layerNailOption).every(k => return super.HasInvailValue() || !Object.keys(this.layerNailOption).every(k =>

@ -5,7 +5,6 @@ import { IConfigOption } from "../../Components/Board/UserConfig";
import { BoardStore } from "../BoardStore"; import { BoardStore } from "../BoardStore";
import { IDoorAndDrawerConfigOption, IDrawerInfo, ISelectTempInfo } from "../DoorInterface"; import { IDoorAndDrawerConfigOption, IDrawerInfo, ISelectTempInfo } from "../DoorInterface";
import { INeedUpdateParams } from "../../Components/Template/TemplateComponent"; import { INeedUpdateParams } from "../../Components/Template/TemplateComponent";
import { Vector3 } from "three";
import { AppToaster } from "../../Components/Toaster"; import { AppToaster } from "../../Components/Toaster";
import { Intent } from "@blueprintjs/core"; import { Intent } from "@blueprintjs/core";
@ -36,6 +35,16 @@ export class DoorDrawerStore extends BoardStore
name: "RY", value: "", description: "" name: "RY", value: "", description: ""
}, { name: "RZ", value: "", description: "" }]; }, { name: "RZ", value: "", description: "" }];
@observable selectTemplateInfo: ISelectTempInfo; @observable selectTemplateInfo: ISelectTempInfo;
get IsLockDrawerHeight()
{
for (let info of this.doorDrawersInfo)
{
if (info.col === 0)
if (!info.isLockHeight)
return false;
}
return true;
}
InitInfos() { } InitInfos() { }
/**更新预览图大小,空间信息大小,平均门板长宽 */ /**更新预览图大小,空间信息大小,平均门板长宽 */
@ -111,6 +120,7 @@ export class DoorDrawerStore extends BoardStore
this.doorWidth = this.spaceWidth / col; this.doorWidth = this.spaceWidth / col;
this.doorHeight = this.spaceHeight / row; this.doorHeight = this.spaceHeight / row;
} }
protected HandleTopBottomOffset() { }
/**计算锁定后尺寸信息*/ /**计算锁定后尺寸信息*/
CalcInfos(isUpdateSpace: boolean = false) CalcInfos(isUpdateSpace: boolean = false)
{ {
@ -183,11 +193,9 @@ export class DoorDrawerStore extends BoardStore
//高全部锁定,剩余高度减去上留空后给下留空 //高全部锁定,剩余高度减去上留空后给下留空
if (row === lockHeightInfos.length) if (row === lockHeightInfos.length)
{ {
retHeight = this.totalHeight - setHeight - this.m_Option.topSpace - this.m_Option.bottomSpace - (this.m_Option.midSpace) * this.m_Option.row - 1 + this.m_Option.bottomExt; retHeight = this.totalHeight - setHeight;
this.m_Option.bottomOffset = retHeight - this.m_Option.topOffset;
this.UIOption["bottomOffset"] = (retHeight - this.m_Option.topOffset).toString();
this.restHeight = retHeight; this.restHeight = retHeight;
this.UpdateSpace(); this.HandleTopBottomOffset();
} }
else else
this.restHeight = undefined; this.restHeight = undefined;
@ -234,14 +242,22 @@ export class DoorDrawerStore extends BoardStore
CheckLockSize(isWidth: boolean) CheckLockSize(isWidth: boolean)
{ {
let size = 0; let size = 0;
let refSize = isWidth ? this.spaceWidth : this.spaceHeight; let refSize = isWidth ? this.spaceWidth : (this.totalHeight - this.m_Option.topOffset - this.m_Option.bottomOffset);
for (let info of this.doorDrawersInfo) for (let info of this.doorDrawersInfo)
{ {
let refRet = isWidth ? let refRet = isWidth ?
(info.row === 0 && info.isLockWidth) : (info.col === 0 && info.isLockHeight) (info.row === 0 && info.isLockWidth) : (info.col === 0 && info.isLockHeight);
if (refRet) if (refRet)
size += isWidth ? info.width : info.height; size += isWidth ? info.width : info.height;
} }
if (size > refSize)
{
AppToaster.show({
message: "输入尺寸大于空间尺寸",
timeout: 2000,
intent: Intent.DANGER,
});
}
return size <= refSize; return size <= refSize;
} }
@ -264,7 +280,7 @@ export class DoorDrawerStore extends BoardStore
message: "宽度锁定失败,锁定宽度太大", message: "宽度锁定失败,锁定宽度太大",
timeout: 1500, timeout: 1500,
intent: Intent.DANGER intent: Intent.DANGER
}) });
return; return;
} }
} }
@ -274,23 +290,24 @@ export class DoorDrawerStore extends BoardStore
else else
{ {
let allHeight = 0; let allHeight = 0;
let isAllLock = true;
if (!info.isLockHeight) if (!info.isLockHeight)
for (let inf of this.doorDrawersInfo) for (let inf of this.doorDrawersInfo)
{ {
if (inf.col && !inf.isLockHeight)
isAllLock = false;
if (inf.col === 0 && (inf === info || inf.isLockHeight)) if (inf.col === 0 && (inf === info || inf.isLockHeight))
allHeight += inf.height; allHeight += inf.height;
if (allHeight > this.totalHeight) if (allHeight > this.totalHeight - this.m_Option.topOffset - this.m_Option.bottomOffset)
{ {
AppToaster.show({ AppToaster.show({
message: "高度锁定失败,锁定高度太大", message: "高度锁定失败,锁定高度太大",
timeout: 1500, timeout: 1500,
intent: Intent.DANGER intent: Intent.DANGER
}) });
return; return;
} }
} }
info.isLockHeight = !info.isLockHeight; info.isLockHeight = !info.isLockHeight;
} }
this.CalcInfos(); this.CalcInfos();
@ -322,12 +339,26 @@ export class DoorDrawerStore extends BoardStore
} }
if (cof.doorsInfo && cof.doorsInfo.length > 0) if (cof.doorsInfo && cof.doorsInfo.length > 0)
{ {
for (let info of cof.doorsInfo)
{
if (info.version === undefined)
{
info.version = 1;
if (!info.tempInfo)
info.tempInfo = {
temp: { id: "", name: "" },
handleTemp: { id: "", name: "" },
};
}
}
observable(this.doorDrawersInfo).replace(cof.doorsInfo); observable(this.doorDrawersInfo).replace(cof.doorsInfo);
this.CalcInfos(true); this.CalcInfos(true);
} }
else
this.InitInfos();
} }
HasInvailValue() HasInvailValue()
{ {
return CheckoutValid.HasInvailValue(this.UIOption, CheckObjectType.Do) return CheckoutValid.HasInvailValue(this.UIOption, CheckObjectType.Do);
} }
} }

@ -41,6 +41,7 @@ export class DoorStore extends DoorDrawerStore
{ {
if (isReset) if (isReset)
this.doorDrawersInfo.push({ this.doorDrawersInfo.push({
version: 1,
row: i, row: i,
col: j, col: j,
openDir: (j & 1) === 1 || j === col - 1 ? DoorOpenDir.Right : DoorOpenDir.Left, openDir: (j & 1) === 1 || j === col - 1 ? DoorOpenDir.Right : DoorOpenDir.Left,
@ -119,4 +120,10 @@ export class DoorStore extends DoorDrawerStore
super.InitOption(); super.InitOption();
this.InitInfos(); this.InitInfos();
} }
protected HandleTopBottomOffset()
{
this.m_Option.bottomOffset = this.restHeight - this.m_Option.topOffset;
this.UIOption["bottomOffset"] = (this.restHeight - this.m_Option.topOffset).toString();
this.UpdateSpace();
}
} }

@ -1,13 +1,15 @@
import { observable } from "mobx"; import { observable } from "mobx";
import { FixedNotZero } from "../../../Common/Utils"; import { FixedNotZero } from "../../../Common/Utils";
import { DoorPosType, HandleHorPos, HandleVePos, IDrawerConfigOption } from "../DoorInterface"; import { IDrawerConfigOption, IDrawerInfo } from "../DoorInterface";
import { DoorDrawerStore } from "./DoorDrawerStore"; import { DoorDrawerStore } from "./DoorDrawerStore";
import { DefaultDrawerOption } from "../../../Editor/DefaultConfig"; import { DefaultDrawerOption } from "../../../Editor/DefaultConfig";
import { IConfigOption } from "../../Components/Board/UserConfig";
import { AppToaster } from "../../Components/Toaster";
import { Intent } from "@blueprintjs/core";
export class DrawerStore extends DoorDrawerStore export class DrawerStore extends DoorDrawerStore
{ {
title = "抽屉"; title = "抽屉";
@observable m_Option: IDrawerConfigOption = Object.assign({}, DefaultDrawerOption); @observable m_Option: IDrawerConfigOption = Object.assign({}, DefaultDrawerOption);
InitInfos() InitInfos()
{ {
this.UpdateSpace(); this.UpdateSpace();
@ -28,6 +30,7 @@ export class DrawerStore extends DoorDrawerStore
for (let j = 0; j < col; j++) for (let j = 0; j < col; j++)
{ {
this.doorDrawersInfo.push({ this.doorDrawersInfo.push({
version: 1,
row: i, row: i,
col: j, col: j,
divWidth: rectWidth, divWidth: rectWidth,
@ -40,7 +43,7 @@ export class DrawerStore extends DoorDrawerStore
isLockHeight: false, isLockHeight: false,
isSelect: this.m_Option.isAllSelect, isSelect: this.m_Option.isAllSelect,
tempInfo: { temp: { id: "", name: "" }, handleTemp: { id: "", name: "" } } tempInfo: { temp: { id: "", name: "" }, handleTemp: { id: "", name: "" } }
}) });
} }
} }
} }
@ -50,4 +53,76 @@ export class DrawerStore extends DoorDrawerStore
super.InitOption(); super.InitOption();
this.InitInfos(); this.InitInfos();
} }
UpdateOption(cof: IConfigOption)
{
let opt = cof.option as IDrawerConfigOption;
if (opt && (opt.version === undefined || opt.version < 2))
{
opt.version = 2;
opt.isLockTopOffset = false;
opt.isLockBottomOffset = false;
}
super.UpdateOption(cof);
}
ChangeLockStatus(info: IDrawerInfo, isWidth: boolean)
{
if (!isWidth)
{
let lockHeightCount = 0;
for (let info of this.doorDrawersInfo)
{
if (info.col === 0 && info.isLockHeight)
lockHeightCount++;
}
if (lockHeightCount + 1 === this.m_Option.row && this.m_Option.isLockTopOffset && this.m_Option.isLockBottomOffset)
{
AppToaster.show({
message: "上下留空空间已锁定",
timeout: 2000,
intent: Intent.DANGER,
});
return;
}
}
super.ChangeLockStatus(info, isWidth);
}
protected HandleTopBottomOffset()
{
if (this.IsLockDrawerHeight)
{
if (this.m_Option.isLockBottomOffset)
{
this.m_Option.topOffset = this.restHeight - this.m_Option.bottomOffset;
this.UIOption["topOffset"] = (this.restHeight - this.m_Option.bottomOffset).toString();
}
else if (this.m_Option.isLockTopOffset)
{
this.m_Option.bottomOffset = this.restHeight - this.m_Option.topOffset;
this.UIOption["bottomOffset"] = (this.restHeight - this.m_Option.topOffset).toString();
}
else
{
this.m_Option.isLockBottomOffset = true;
this.m_Option.bottomOffset = this.restHeight - this.m_Option.topOffset;
this.UIOption["bottomOffset"] = (this.restHeight - this.m_Option.topOffset).toString();
}
this.UpdateSpace();
}
}
CheckLockSize(isWidth: boolean)
{
if (!isWidth && this.m_Option.isLockBottomOffset && this.m_Option.isLockTopOffset && this.IsLockDrawerHeight)
{
AppToaster.show({
message: "上下留空已经锁定",
timeout: 2000,
intent: Intent.DANGER,
});
return false;
}
return super.CheckLockSize(isWidth);
}
} }

@ -57,6 +57,8 @@ export interface IDrawerConfigOption extends IDoorAndDrawerConfigOption
drawerTotalDepth: number; //抽屉总深 drawerTotalDepth: number; //抽屉总深
trackDepth: number; //轨道深度 trackDepth: number; //轨道深度
isAutoSelectTrack: boolean; isAutoSelectTrack: boolean;
isLockTopOffset: boolean;
isLockBottomOffset: boolean;
} }
//门板位置类型 //门板位置类型
@ -89,7 +91,7 @@ export enum DoorOpenDir
} }
//抽屉门板信息 //抽屉门板信息
export interface IDrawerInfo export interface IDrawerInfo extends IBaseOption
{ {
row: number, row: number,
col: number, col: number,

Loading…
Cancel
Save