From 2a111f980d247e26b95ed1a9393fb145b771a8d6 Mon Sep 17 00:00:00 2001 From: ZoeLeeFZ Date: Thu, 19 Dec 2019 10:07:46 +0800 Subject: [PATCH] =?UTF-8?q?!662=20=E4=BC=98=E5=8C=96=E6=8A=BD=E5=B1=89?= =?UTF-8?q?=E4=B8=8A=E4=B8=8B=E7=95=99=E7=A9=BA=E5=8F=82=E6=95=B0=E7=9A=84?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DrawDoorDrawer/DrawDoorDrawerTool.ts | 4 +- src/Add-on/DrawBoard/DrawDrawer.ts | 82 ++++++++---- src/Editor/DefaultConfig.ts | 4 +- src/UI/Components/Board/BoardCommon.tsx | 14 +- .../Components/Board/Door/DoorConfigModal.tsx | 125 ++++++++++++++---- .../Components/Board/Door/DoorPreviewItem.tsx | 26 ++-- .../Modal/ModalStyle/DoorModal.less | 6 + src/UI/Components/Toaster.tsx | 2 +- src/UI/Store/BoardStore.ts | 10 +- .../Store/DoorDrawerStore/DoorDrawerStore.ts | 61 ++++++--- src/UI/Store/DoorDrawerStore/DoorStore.ts | 9 +- src/UI/Store/DoorDrawerStore/DrawerStore.ts | 81 +++++++++++- src/UI/Store/DoorInterface.ts | 4 +- 13 files changed, 332 insertions(+), 96 deletions(-) diff --git a/src/Add-on/DrawBoard/DrawDoorDrawer/DrawDoorDrawerTool.ts b/src/Add-on/DrawBoard/DrawDoorDrawer/DrawDoorDrawerTool.ts index 3c9fc0b62..c15159933 100644 --- a/src/Add-on/DrawBoard/DrawDoorDrawer/DrawDoorDrawerTool.ts +++ b/src/Add-on/DrawBoard/DrawDoorDrawer/DrawDoorDrawerTool.ts @@ -46,9 +46,9 @@ export class DrawDoorTool for (let info of doorInfos) { - if (info.tempInfo.temp.id) + if (info.tempInfo && 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); let key = (row - info.row - 1).toString() + "-" + info.col.toString(); diff --git a/src/Add-on/DrawBoard/DrawDrawer.ts b/src/Add-on/DrawBoard/DrawDrawer.ts index 17c86726e..f9517840d 100644 --- a/src/Add-on/DrawBoard/DrawDrawer.ts +++ b/src/Add-on/DrawBoard/DrawDrawer.ts @@ -20,7 +20,6 @@ import { TemplateSizeBoard } from "../../DatabaseServices/Template/ProgramTempat import { ISpaceParse } from "../../Geometry/SpaceParse/ISpaceParse"; import { EBoardKeyList } from "../../Common/BoardKeyList"; import { BoardModalType } from "../../UI/Components/Board/BoardModal"; -import { INeedUpdateParams } from "../../UI/Components/Template/TemplateComponent"; export class DrawDrawrer implements Command { @@ -96,6 +95,11 @@ export class DrawDrawrer implements Command for (let id of [...tempIds]) { let temp = await GetOnlineTemplate(id); + if (!temp) + { + console.warn(temp.Name, temp.Id, "这个抽屉不能用"); + continue; + } let ens = temp.Db.ModelSpace.Entitys; if (surroundOption) for (let en of ens) @@ -143,7 +147,18 @@ export class DrawDrawrer implements Command 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++) { @@ -171,8 +186,8 @@ export class DrawDrawrer implements Command } } if (depthTemp) - depthTemp.Children.push(templateSpace.Id); - await templateSpace.UpdateTemplateTree(); + depthTemp.Children.push(rootSpaceTemplate.Id); + await rootSpaceTemplate.UpdateTemplateTree(); } } private AppendTemplateParam(name: string, value: number, des: string, temp: TemplateRecord) @@ -183,17 +198,19 @@ export class DrawDrawrer implements Command par.description = des; 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(); - templateSpace.Name = "根空间"; + templateSpace.Name = "抽屉根空间"; templateSpace.SplitType = TemplateSplitType.X; for (let info of roInfos) templateSpace.GetParam(info.name).expr = info.expr; - templateSpace.HParam.expr = `H-SLK-XLK`; - templateSpace.PZParam.expr = "XLK"; + templateSpace.HParam.expr = isLock ? spaceParse.Size.z - option.topOffset - option.bottomOffset : "_DIV"; templateSpace.PYParam.expr = "MBH"; 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("MBH", option.offset, "抽屉内缩", templateSpace); - this.AppendTemplateParam("SLK", option.topOffset, "上留空", templateSpace); - this.AppendTemplateParam("XLK", option.bottomOffset, "下留空", templateSpace); - this.AppendTemplateParam("SYS", option.topExt, "上延伸", templateSpace); this.AppendTemplateParam("XYS", option.bottomExt, "下延伸", templateSpace); this.AppendTemplateParam("YYS", option.rightExt, "右延伸", templateSpace); @@ -224,18 +238,9 @@ export class DrawDrawrer implements Command this.AppendTemplateParam("YJ", option.horSpacing, "拉手右距", templateSpace); this.AppendTemplateParam("ZJ", option.horSpacing, "拉手左距", 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; - } + templateSpace.LParam.expr = "_L"; + templateSpace.WParam.expr = "_W"; + templateSpace.PZParam.expr = "_POS"; app.Database.TemplateTable.Append(templateSpace); return templateSpace; @@ -433,4 +438,35 @@ export class DrawDrawrer implements Command verTemp.PZParam.expr = "-_XLK"; 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; + } } diff --git a/src/Editor/DefaultConfig.ts b/src/Editor/DefaultConfig.ts index a4511597c..d81a1cd46 100644 --- a/src/Editor/DefaultConfig.ts +++ b/src/Editor/DefaultConfig.ts @@ -326,7 +326,7 @@ export const DefaultDoorOption = { Object.freeze(DefaultDoorOption); export const DefaultDrawerOption: IDrawerConfigOption = { - version: 1, + version: 2, col: 1, row: 1, isAllSelect: true, @@ -355,6 +355,8 @@ export const DefaultDrawerOption: IDrawerConfigOption = { drawerTotalDepth: 0, trackDepth: 0, isAutoSelectTrack: true, + isLockTopOffset: false, + isLockBottomOffset: false, }; Object.freeze(DefaultDrawerOption); diff --git a/src/UI/Components/Board/BoardCommon.tsx b/src/UI/Components/Board/BoardCommon.tsx index ef22ef64c..04f20fefa 100644 --- a/src/UI/Components/Board/BoardCommon.tsx +++ b/src/UI/Components/Board/BoardCommon.tsx @@ -40,7 +40,7 @@ interface ISetBlockOption uiOption?: Object; className?: string; isInline?: boolean; - onChange?: Function; + onChange?: (e, ...arg) => void; disabled?: boolean; children?: React.ReactNode; } @@ -82,6 +82,9 @@ export class SetBoardDataItem extends React.Component + { + props.children + } ); } @@ -93,18 +96,11 @@ export const SetBoardDataBlock = observer( { props.pars.map(([k, v]) => - { - if (props.onChange) - props.onChange(k, oldValue); - }} + {...props} /> ) } diff --git a/src/UI/Components/Board/Door/DoorConfigModal.tsx b/src/UI/Components/Board/Door/DoorConfigModal.tsx index c5fa9f02d..1a3a226ad 100644 --- a/src/UI/Components/Board/Door/DoorConfigModal.tsx +++ b/src/UI/Components/Board/Door/DoorConfigModal.tsx @@ -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 * as React from 'react'; import { CheckObjectType } from '../../../../Common/CheckoutVaildValue'; @@ -12,7 +12,7 @@ import { DrawerStore } from '../../../Store/DoorDrawerStore/DrawerStore'; import { log } from '../../../../Common/Utils'; @observer -export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore }> +export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore; }> { private uiOption; private isDoor: boolean = true; @@ -52,7 +52,7 @@ export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore } } this.handleDrawerDepth(); store.CalcInfos(true); - } + }; private handleDrawerDepth = () => { const store = this.props.store; @@ -63,7 +63,7 @@ export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore } store.m_Option.depth = val; this.uiOption.depth = val.toString(); } - } + }; private toggleSelected = () => { const option = this.props.store.m_Option; @@ -73,16 +73,18 @@ export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore } { info.isSelect = option.isAllSelect; } - } - private handleTBOffset = (par: string, oldValue: string | number) => + }; + private handleTBOffset = (e, oldValue: string | number, par: string) => { - const store = this.props.store; - if (store.restHeight) + const store = this.props.store as DrawerStore; + 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) { - store.m_Option[par] = Number(oldValue) || 0; + option[par] = Number(oldValue) || 0; AppToaster.show({ message: "上下留空过大,值无效,请修正", timeout: 1500, @@ -93,19 +95,19 @@ export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore } } if (par === "topOffset") { - store.m_Option.bottomOffset = val; + option.bottomOffset = val; this.uiOption.bottomOffset = val.toString(); } else { - store.m_Option.topOffset = val; + option.topOffset = val; this.uiOption.topOffset = val.toString(); } store.CalcInfos(true); } else { - if (store.m_Option.topOffset + store.m_Option.bottomOffset < store.totalHeight) + if (option.topOffset + option.bottomOffset < store.totalHeight) store.CalcInfos(true); else { @@ -115,10 +117,53 @@ export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore } timeout: 1500, 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() { this.uiOption = this.props.store.UIOption; @@ -172,14 +217,46 @@ export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore } /> - +
+ + { + store instanceof DrawerStore && +
@@ -431,6 +508,6 @@ export class DoorConfigModal extends React.Component<{ store?: DoorDrawerStore } : null } - ) + ); } } diff --git a/src/UI/Components/Board/Door/DoorPreviewItem.tsx b/src/UI/Components/Board/Door/DoorPreviewItem.tsx index 7507205db..fe41d0520 100644 --- a/src/UI/Components/Board/Door/DoorPreviewItem.tsx +++ b/src/UI/Components/Board/Door/DoorPreviewItem.tsx @@ -24,8 +24,8 @@ const getCalcStyles = (info: IDoorInfo, store: DoorDrawerStore): React.CSSProper height: info.divHeight + "px", marginRight: info.col === store.m_Option.col - 1 ? "0" : "2px", marginBottom: info.row === store.m_Option.row - 1 ? "0" : "2px", - } -} + }; +}; //预览图门板比较大时渲染 @observer @@ -62,7 +62,7 @@ export class DoorPreviewLgItem extends React.Component { - info.isDrawVer = !info.isDrawVer + info.isDrawVer = !info.isDrawVer; }} /> } @@ -119,7 +119,7 @@ export class DoorPreviewLgItem extends React.Component { - info.isDrawLayer = !info.isDrawLayer + info.isDrawLayer = !info.isDrawLayer; }} /> } @@ -191,14 +191,14 @@ export class DoorPreviewLgItem extends React.Component{d.name} + return
  • {d.name}
  • ; } }) }
    - ) + ); } } @@ -276,13 +276,13 @@ export class DoorPreviewSmItem extends React.Component{d.name} + return
  • {d.name}
  • ; } }) } - ) + ); } } @@ -311,7 +311,7 @@ export class DoorPreviewItem extends React.Component{ (e.parentElement.firstElementChild as HTMLDivElement).onclick = () => { this.isOpen = false; - } + }; e.tabIndex = -1; e.focus(); e.addEventListener('keydown', this.handleKeydown); @@ -344,7 +344,7 @@ export class DoorPreviewItem extends React.Component{ > - ) + ); } private RenderRadiusOption(isDoor: boolean, info: IDoorInfo, store: DoorDrawerStore) @@ -362,7 +362,7 @@ export class DoorPreviewItem extends React.Component{ - ) + ); } private RenderInputAndLock(info: IDoorInfo, store: DoorDrawerStore, isDoor: boolean): React.ReactNode { @@ -443,7 +443,7 @@ export class DoorPreviewItem extends React.Component{ info.isSelect = !info.isSelect; observable(this.props.store.currentTempProp).replace(toJS(info.tempInfo.temp.props)); }, 200); - } + }; private handleKeydown = (ev: KeyboardEvent) => { if (ev.keyCode === KeyBoard.Escape) @@ -451,5 +451,5 @@ export class DoorPreviewItem extends React.Component{ this.isOpen = false; ev.stopPropagation(); } - } + }; } diff --git a/src/UI/Components/Modal/ModalStyle/DoorModal.less b/src/UI/Components/Modal/ModalStyle/DoorModal.less index deb9039b4..08b22e8f6 100644 --- a/src/UI/Components/Modal/ModalStyle/DoorModal.less +++ b/src/UI/Components/Modal/ModalStyle/DoorModal.less @@ -174,4 +174,10 @@ text-align: center } } + + .tb-offset { + &>span { + line-height: 30px; + } + } } diff --git a/src/UI/Components/Toaster.tsx b/src/UI/Components/Toaster.tsx index 42bde2e43..2d2035d06 100644 --- a/src/UI/Components/Toaster.tsx +++ b/src/UI/Components/Toaster.tsx @@ -69,7 +69,7 @@ export class ToasterInput extends React.Component } //值有效才运行change函数 if (this.hideErrorMsg && this.props.onChange) - this.props.onChange(e, oldValue); + this.props.onChange(e, oldValue, this.props.optKey); }; handleClick = e => { diff --git a/src/UI/Store/BoardStore.ts b/src/UI/Store/BoardStore.ts index 7fa9d4d3e..b267abb6c 100644 --- a/src/UI/Store/BoardStore.ts +++ b/src/UI/Store/BoardStore.ts @@ -299,10 +299,14 @@ export class LayerBoardStore extends BoardStore if (this.uiLayerNailOption) Object.assign(this.uiLayerNailOption, DataAdapter.ConvertUIData(this.layerNailOption)); - if (cof.option["version"] === undefined) + if (this.m_Option.version === undefined) { - this.m_Option.calcHeight = "W"; - this.UIOption.calcHeight = "W"; + this.m_Option.version = 1; + if (this.m_Option.calcHeight === "L") + { + this.m_Option.calcHeight = "W"; + this.UIOption.calcHeight = "W"; + } } } HasInvailValue() diff --git a/src/UI/Store/DoorDrawerStore/DoorDrawerStore.ts b/src/UI/Store/DoorDrawerStore/DoorDrawerStore.ts index 40d01fe71..0bb1e804d 100644 --- a/src/UI/Store/DoorDrawerStore/DoorDrawerStore.ts +++ b/src/UI/Store/DoorDrawerStore/DoorDrawerStore.ts @@ -5,7 +5,6 @@ import { IConfigOption } from "../../Components/Board/UserConfig"; import { BoardStore } from "../BoardStore"; import { IDoorAndDrawerConfigOption, IDrawerInfo, ISelectTempInfo } from "../DoorInterface"; import { INeedUpdateParams } from "../../Components/Template/TemplateComponent"; -import { Vector3 } from "three"; import { AppToaster } from "../../Components/Toaster"; import { Intent } from "@blueprintjs/core"; @@ -36,6 +35,16 @@ export class DoorDrawerStore extends BoardStore name: "RY", value: "", description: "" }, { name: "RZ", value: "", description: "" }]; @observable selectTemplateInfo: ISelectTempInfo; + get IsLockDrawerHeight() + { + for (let info of this.doorDrawersInfo) + { + if (info.col === 0) + if (!info.isLockHeight) + return false; + } + return true; + } InitInfos() { } /**更新预览图大小,空间信息大小,平均门板长宽 */ @@ -111,6 +120,7 @@ export class DoorDrawerStore extends BoardStore this.doorWidth = this.spaceWidth / col; this.doorHeight = this.spaceHeight / row; } + protected HandleTopBottomOffset() { } /**计算锁定后尺寸信息*/ CalcInfos(isUpdateSpace: boolean = false) { @@ -183,11 +193,9 @@ export class DoorDrawerStore extends BoardStore //高全部锁定,剩余高度减去上留空后给下留空 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; - this.m_Option.bottomOffset = retHeight - this.m_Option.topOffset; - this.UIOption["bottomOffset"] = (retHeight - this.m_Option.topOffset).toString(); + retHeight = this.totalHeight - setHeight; this.restHeight = retHeight; - this.UpdateSpace(); + this.HandleTopBottomOffset(); } else this.restHeight = undefined; @@ -227,21 +235,29 @@ export class DoorDrawerStore extends BoardStore spaceSize = refSize; return divSize / spaceSize * size; } - /** - * + /** + * * 检查锁定是否有效 */ CheckLockSize(isWidth: boolean) { 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) { 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) size += isWidth ? info.width : info.height; } + if (size > refSize) + { + AppToaster.show({ + message: "输入尺寸大于空间尺寸", + timeout: 2000, + intent: Intent.DANGER, + }); + } return size <= refSize; } @@ -264,7 +280,7 @@ export class DoorDrawerStore extends BoardStore message: "宽度锁定失败,锁定宽度太大", timeout: 1500, intent: Intent.DANGER - }) + }); return; } } @@ -274,23 +290,24 @@ export class DoorDrawerStore extends BoardStore else { let allHeight = 0; - + let isAllLock = true; if (!info.isLockHeight) for (let inf of this.doorDrawersInfo) { + if (inf.col && !inf.isLockHeight) + isAllLock = false; if (inf.col === 0 && (inf === info || inf.isLockHeight)) allHeight += inf.height; - if (allHeight > this.totalHeight) + if (allHeight > this.totalHeight - this.m_Option.topOffset - this.m_Option.bottomOffset) { AppToaster.show({ message: "高度锁定失败,锁定高度太大", timeout: 1500, intent: Intent.DANGER - }) + }); return; } } - info.isLockHeight = !info.isLockHeight; } this.CalcInfos(); @@ -322,12 +339,26 @@ export class DoorDrawerStore extends BoardStore } 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); this.CalcInfos(true); } + else + this.InitInfos(); } HasInvailValue() { - return CheckoutValid.HasInvailValue(this.UIOption, CheckObjectType.Do) + return CheckoutValid.HasInvailValue(this.UIOption, CheckObjectType.Do); } } diff --git a/src/UI/Store/DoorDrawerStore/DoorStore.ts b/src/UI/Store/DoorDrawerStore/DoorStore.ts index 012fe1384..428494a71 100644 --- a/src/UI/Store/DoorDrawerStore/DoorStore.ts +++ b/src/UI/Store/DoorDrawerStore/DoorStore.ts @@ -41,6 +41,7 @@ export class DoorStore extends DoorDrawerStore { if (isReset) this.doorDrawersInfo.push({ + version: 1, row: i, col: j, openDir: (j & 1) === 1 || j === col - 1 ? DoorOpenDir.Right : DoorOpenDir.Left, @@ -70,7 +71,7 @@ export class DoorStore extends DoorDrawerStore } } } - /** + /** * 改变开门类型 */ ChangeOpenDir(info: IDoorInfo) @@ -119,4 +120,10 @@ export class DoorStore extends DoorDrawerStore super.InitOption(); 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(); + } } diff --git a/src/UI/Store/DoorDrawerStore/DrawerStore.ts b/src/UI/Store/DoorDrawerStore/DrawerStore.ts index badc50b1c..ac773983b 100644 --- a/src/UI/Store/DoorDrawerStore/DrawerStore.ts +++ b/src/UI/Store/DoorDrawerStore/DrawerStore.ts @@ -1,13 +1,15 @@ import { observable } from "mobx"; import { FixedNotZero } from "../../../Common/Utils"; -import { DoorPosType, HandleHorPos, HandleVePos, IDrawerConfigOption } from "../DoorInterface"; +import { IDrawerConfigOption, IDrawerInfo } from "../DoorInterface"; import { DoorDrawerStore } from "./DoorDrawerStore"; 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 { title = "抽屉"; @observable m_Option: IDrawerConfigOption = Object.assign({}, DefaultDrawerOption); - InitInfos() { this.UpdateSpace(); @@ -28,6 +30,7 @@ export class DrawerStore extends DoorDrawerStore for (let j = 0; j < col; j++) { this.doorDrawersInfo.push({ + version: 1, row: i, col: j, divWidth: rectWidth, @@ -40,7 +43,7 @@ export class DrawerStore extends DoorDrawerStore isLockHeight: false, isSelect: this.m_Option.isAllSelect, tempInfo: { temp: { id: "", name: "" }, handleTemp: { id: "", name: "" } } - }) + }); } } } @@ -50,4 +53,76 @@ export class DrawerStore extends DoorDrawerStore super.InitOption(); 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); + } } diff --git a/src/UI/Store/DoorInterface.ts b/src/UI/Store/DoorInterface.ts index 932f579ec..45f393f64 100644 --- a/src/UI/Store/DoorInterface.ts +++ b/src/UI/Store/DoorInterface.ts @@ -57,6 +57,8 @@ export interface IDrawerConfigOption extends IDoorAndDrawerConfigOption drawerTotalDepth: number; //抽屉总深 trackDepth: number; //轨道深度 isAutoSelectTrack: boolean; + isLockTopOffset: boolean; + isLockBottomOffset: boolean; } //门板位置类型 @@ -89,7 +91,7 @@ export enum DoorOpenDir } //抽屉门板信息 -export interface IDrawerInfo +export interface IDrawerInfo extends IBaseOption { row: number, col: number,