diff --git a/src/Add-on/ShareView/ShareViewRules.ts b/src/Add-on/ShareView/ShareViewRules.ts index ba195928d..cd1af4147 100644 --- a/src/Add-on/ShareView/ShareViewRules.ts +++ b/src/Add-on/ShareView/ShareViewRules.ts @@ -74,7 +74,7 @@ export const ViewStyleTypes = [ renderType: RenderType.ConceptualTransparent, }, { - title: "自定义编号", + title: "板号", cmd: CommandNames.VisualStyle_CustomNumber, renderType: RenderType.CustomNumber, }, diff --git a/src/Add-on/ShareView/ShareViewStore.ts b/src/Add-on/ShareView/ShareViewStore.ts index 6468df52b..0081815d8 100644 --- a/src/Add-on/ShareView/ShareViewStore.ts +++ b/src/Add-on/ShareView/ShareViewStore.ts @@ -13,6 +13,16 @@ interface IProps showBom?: boolean | null; } +interface IOperations +{ + showDoor: boolean; + showDrawer: boolean; + showExplosion: boolean; + showCustomNumber: boolean; + showDimension: boolean; + isDoorOpen: boolean; +} + export class ShareViewStore extends Singleton implements IConfigStore { //当前选中柜子的索引列表 @@ -54,4 +64,14 @@ export class ShareViewStore extends Singleton implements IConfigStore { Object.assign(this.m_Option, cof.option); } + + /** 隐蔽组件按钮操作 */ + @observable operations: IOperations = { + showDoor: true, // 是否显示门板 + showDrawer: true, // 是否显示抽屉 + showExplosion: false, // 是否展示爆炸图 + showCustomNumber: false, // 是否显示板编号 + showDimension: false, // 是否显示标注 + isDoorOpen: false, // 是否门是开着 + }; } diff --git a/src/Add-on/ShareView/ShareViewStyle.less b/src/Add-on/ShareView/ShareViewStyle.less index cd4256ed4..08a9ab7e2 100644 --- a/src/Add-on/ShareView/ShareViewStyle.less +++ b/src/Add-on/ShareView/ShareViewStyle.less @@ -50,6 +50,7 @@ display: flex; align-items: center; justify-content: center; + transition: all 0.3s; &.active { background-color: var(--bottomBtnActiveBgColor); @@ -68,7 +69,7 @@ canvas { font-family: var(--font-family); // bottom: calc(50px + constant(safe-area-inset-bottom)); // bottom: calc(50px + env(safe-area-inset-bottom)); - top: 12px; + top: 4px; >div, .sp-view-angle-icon, @@ -189,7 +190,6 @@ canvas { } .sp-top-btn { - display: inline-block; height: 40px; padding: 0 16px; background-color: var(--btn-background-color); @@ -200,6 +200,7 @@ canvas { justify-content: center; align-items: center; cursor: pointer; + transition: all 0.3s; } * { @@ -426,7 +427,6 @@ canvas { border-spacing: 0; border-collapse: separate; width: 100%; - font-size: var(--font-size); font-family: var(--font-family); border-left: 1px solid #ddd; border-right: 1px solid #ddd; diff --git a/src/Add-on/ShareView/ShareViewUtil.ts b/src/Add-on/ShareView/ShareViewUtil.ts index ec0423300..0a87b53d5 100644 --- a/src/Add-on/ShareView/ShareViewUtil.ts +++ b/src/Add-on/ShareView/ShareViewUtil.ts @@ -1,6 +1,8 @@ import { IToastProps } from "@blueprintjs/core"; -import { Vector3 } from "three"; +import { Object3D, Vector3 } from "three"; +import { app } from "../../ApplicationServices/Application"; import { CommandNames } from "../../Common/CommandNames"; +import { CylinderHole } from "../../DatabaseServices/3DSolid/CylinderHole"; import { AlignedDimension } from "../../DatabaseServices/Dimension/AlignedDimension"; import { Board } from "../../DatabaseServices/Entity/Board"; import { Entity } from "../../DatabaseServices/Entity/Entity"; @@ -9,13 +11,15 @@ import { HardwareTopline } from "../../DatabaseServices/Hardware/HardwareTopline import { TemplateRecord } from "../../DatabaseServices/Template/TemplateRecord"; import { commandMachine } from "../../Editor/CommandMachine"; import { PromptStatus } from "../../Editor/PromptResult"; +import { Box3Ext } from "../../Geometry/Box"; import { GetBox, GetBoxArr } from "../../Geometry/GeUtils"; import { CameraType } from "../../GraphicsSystem/CameraUpdate"; +import { arrayRemoveIf } from "../../Nest/Common/ArrayExt"; import { Production } from "../../Production/Product"; import { ICompHardwareOption, IToplineOption } from "../../UI/Components/RightPanel/RightPanelInterface"; import { AppToaster } from "../../UI/Components/Toaster"; import { autoDimBrsStore } from "../DrawDim/AutoDimBrsStore"; -import { IsDoor, IsHinge } from "../HideSelect/HideSelectUtils"; +import { IsDoor, IsDrawer, IsHinge, IsLattice } from "../HideSelect/HideSelectUtils"; import { CabinetInfo, shareViewApp } from "./ShareViewService"; import { ShareViewStore } from "./ShareViewStore"; @@ -42,23 +46,16 @@ export async function ExplosionView(index: number, distance: number) if (!(explosionDic[index] && explosionDic[index].length > 0)) { let moveObjs = []; - await commandMachine.ExecCommand(CommandNames.SelectAll); - let brs = await shareViewApp.Editor.GetSelection({ - UseSelect: true, - Msg: "请选择需要展示爆炸图的板件", - Filter: { - filterTypes: [Entity], - }, - AllowNone: false, - }); - if (brs.Status !== PromptStatus.OK) return; - - let box = GetBoxArr(brs.SelectSet.SelectObjectList); + let objLists: Object3D[] = []; + for (let ent of shareViewApp.BoxCtrl.GetCabinetEntities(index)) + objLists.push(ent.DrawObject); + + let box = GetBoxArr(objLists); let size = box.getSize(new Vector3()); let cen = box.getCenter(new Vector3()); - for (let obj of brs.SelectSet.SelectObjectList) + for (let obj of objLists) { - if (obj.userData && obj.userData.Entity) + if (obj.userData?.Entity) { let objCen = GetBox(obj).getCenter(new Vector3()); let v = objCen.clone().sub(cen); @@ -166,12 +163,12 @@ export function GetBoxItemInfo(entites: Entity[]) return { boardList, hardwareCompositeList, hardwareToplineList }; } -export async function SwitchDoor(visible: boolean) +export async function SwitchDoorOrDrawer(visible: boolean, isDoor: boolean = true) { const DoorCache: Set = new Set(); let vp = shareViewApp.Viewer.CurrentViewport; - let ens: Entity[] = []; + let entitys: Entity[] = []; const ToggleObject = (temp: TemplateRecord) => { @@ -182,7 +179,7 @@ export async function SwitchDoor(visible: boolean) { let en = id2.Object as Entity; DoorCache.add(id2.Index); - ens.push(en); + entitys.push(en); } } }; @@ -196,6 +193,11 @@ export async function SwitchDoor(visible: boolean) } }; let totalEntitys: Entity[] = []; + + let cylinderHoles: Entity[] = app.Database.ModelSpace.Entitys.filter((e) => (!e.IsErase && e instanceof CylinderHole)); //排钻 + + let lattices: Entity[] = []; //格子抽 + for (const i of ShareViewStore.GetInstance().CurSelectCabinetIndexs) { for (const item of shareViewApp.BoxCtrl.GetCabinetEntities(i)) @@ -204,17 +206,17 @@ export async function SwitchDoor(visible: boolean) } } - for (let en of totalEntitys) + for (let totalEnt of totalEntitys) { - if (!en || DoorCache.has(en.Id.Index)) continue; - if (en.IsErase) continue; + if (!totalEnt || DoorCache.has(totalEnt.Id.Index)) continue; + if (totalEnt.IsErase) continue; - if (IsDoor(en)) + if (isDoor ? IsDoor(totalEnt) : IsDrawer(totalEnt)) { - ens.push(en); - let temp = en.Template?.Object as TemplateRecord; + entitys.push(totalEnt); + let temp = totalEnt.Template?.Object as TemplateRecord; if (!temp) continue; - let doorSpaceTemp = temp.Parent?.Object as TemplateRecord;; + let doorSpaceTemp = temp.Parent?.Object as TemplateRecord; if (doorSpaceTemp) { for (let id of doorSpaceTemp.Children) @@ -250,33 +252,70 @@ export async function SwitchDoor(visible: boolean) ToggleChildren(childrenTemp); } } - if (en instanceof Board) + if (totalEnt instanceof Board) { - for (let hinge of en.RelativeHardware) + for (let hinge of totalEnt.RelativeHardware) { let hardWare = hinge.Object as HardwareCompositeEntity; if (IsHinge(hardWare)) - ens.push(hardWare); + entitys.push(hardWare); } } - else if (en instanceof HardwareCompositeEntity) + else if (totalEnt instanceof HardwareCompositeEntity) { //复合门板待开发 } } } + else if (!isDoor) + { + //排钻和格子抽 + if (IsLattice(totalEnt)) + lattices.push(totalEnt); + } + } + + + if (!isDoor) + { + //隐藏显示抽屉内的排钻和格子抽 + for (let ent of entitys) + { + let entBox = ent.BoundingBox as Box3Ext; + arrayRemoveIf(cylinderHoles, (cylinderHole: Entity) => + { + let cylinderHoleBox = cylinderHole.BoundingBox; + if (entBox.intersectsBox(cylinderHoleBox, 10)) + { + entitys.push(cylinderHole); + return true; + } + return false; + }); + + arrayRemoveIf(lattices, (lattice: Entity) => + { + let latticeBox = lattice.BoundingBox; + if (entBox.intersectsBox(latticeBox, 10)) + { + entitys.push(lattice); + return true; + } + return false; + }); + } } if (vp) { if (visible) - shareViewApp.LayoutTool.ShowViewportEntitys(ens); + shareViewApp.LayoutTool.ShowViewportEntitys(entitys); else - shareViewApp.LayoutTool.HideViewportEntitys(ens); + shareViewApp.LayoutTool.HideViewportEntitys(entitys); } else - ens.forEach(e => e.Visible = visible); + entitys.forEach(e => e.Visible = visible); shareViewApp.Viewer.UpdateRender(); } diff --git a/src/Add-on/ShareView/components/CabinetBottomSheet.tsx b/src/Add-on/ShareView/components/CabinetBottomSheet.tsx index ded3abe4e..73733abde 100644 --- a/src/Add-on/ShareView/components/CabinetBottomSheet.tsx +++ b/src/Add-on/ShareView/components/CabinetBottomSheet.tsx @@ -4,15 +4,15 @@ import { app } from "../../../ApplicationServices/Application"; import { ICabinetFormatData, shareViewApp } from "../ShareViewService"; import { ShareViewStore } from "../ShareViewStore"; import { resetBoxView } from "../ShareViewUtil"; -import { CheckedSvg, CheckEmptySvg } from "./CommonSvgs"; +import { CheckEmptySvg, CheckedSvg } from "./CommonSvgs"; import { SPToaster } from "./SPToater"; - interface IProps { - reset: Function; // 重置函数 + reset: () => Promise; // 重置函数 ref: React.Ref; - cancelCallback: Function; + /** 关闭BottomSheet时回调函数 */ + cancelCallback?: () => void; } // 选择柜体 @@ -79,7 +79,10 @@ const CabinetBottomSheet: React.FC = forwardRef((props, ref) => function closeSheet() { setVisible(false); - props.cancelCallback(); + if (props.cancelCallback) + { + props.cancelCallback(); + } } function scrollCenter(index: number, type: string) @@ -113,7 +116,6 @@ const CabinetBottomSheet: React.FC = forwardRef((props, ref) => //渲染当前选择的柜子列表 async function showCabinet() { - await props.reset(); //隐藏所有的实体 for (let e of app.Database.ModelSpace.Entitys) if (!e.IsErase) @@ -157,6 +159,7 @@ const CabinetBottomSheet: React.FC = forwardRef((props, ref) => }} onClick={async () => { + await props.reset(); if (list[selectedTab]) { const indexes = []; @@ -195,9 +198,11 @@ const CabinetBottomSheet: React.FC = forwardRef((props, ref) => }} onClick={async () => { + await props.reset(); setSelectSinge(!isSelectSingle); if (shareViewStore.CurSelectCabinetIndexs.length > 1) shareViewStore.CurSelectCabinetIndexs.length = 1; + showCabinet(); }}> { isSelectSingle ? : @@ -237,6 +242,7 @@ const CabinetBottomSheet: React.FC = forwardRef((props, ref) => ${shareViewStore.RoomName == selectedTab && shareViewStore.CurSelectCabinetIndexs.includes(item.index) ? 'active' : ''}`} onClick={async () => { + await props.reset(); if (shareViewStore.RoomName == item.roomName && !isSelectSingle) { if (shareViewStore.CurSelectCabinetIndexs.includes(item.index)) diff --git a/src/Add-on/ShareView/components/ExplosionMapWidget.tsx b/src/Add-on/ShareView/components/ExplosionMapWidget.tsx deleted file mode 100644 index 7ddaa40f1..000000000 --- a/src/Add-on/ShareView/components/ExplosionMapWidget.tsx +++ /dev/null @@ -1,65 +0,0 @@ -import React, { forwardRef, useImperativeHandle, useRef, useState } from "react"; -import { ShareViewStore } from "../ShareViewStore"; -import { ExplosionView } from "../ShareViewUtil"; - -interface IProps -{ - ref: React.Ref; - loading: (val: boolean) => void; - reset: () => void; - -} - -const ExplosionMapWidget: React.FC = forwardRef((props, ref) => -{ - const [state, setState] = useState(false); - const loadingRef = useRef(false); - const shareViewStore: ShareViewStore = ShareViewStore.GetInstance(); - - async function changeDoorState(num: number) - { - for (const i of shareViewStore.CurSelectCabinetIndexs) - { - await ExplosionView(i, num); - } - } - - async function openOrClose() - { - shareViewStore.SelectedBoard = null; - if (loadingRef.current) return; - props.loading(true); - loadingRef.current = true; - await props.reset(); - if (state) - { - await changeDoorState(400); - } else - { - await changeDoorState(-400); - } - - setState(!state); - props.loading(false); - loadingRef.current = false; - } - - - useImperativeHandle(ref, () => ({ - reset: async () => - { - if (state) - { - changeDoorState(400); - setState(!state); - } - } - })); - - - return ( -
{state ? '聚合图' : '爆炸图'}
- ); -}); - -export default ExplosionMapWidget; diff --git a/src/Add-on/ShareView/components/HideComponentsMenu/index.less b/src/Add-on/ShareView/components/HideComponentsMenu/index.less new file mode 100644 index 000000000..2ac05d5a8 --- /dev/null +++ b/src/Add-on/ShareView/components/HideComponentsMenu/index.less @@ -0,0 +1,53 @@ +.HideComponentsMenu { + position: absolute; + left: 0; + bottom: 44px; + background-color: var(--btn-background-color); + width: 100%; + box-sizing: border-box; + margin: 0; + padding: 0; + display: block; + border-radius: 4px; + z-index: -1; + visibility: hidden; + transform: translateY(-20px); + opacity: 0; + transition: transform var(--transitionTime), opacity var(--transitionTime), visibility var(--transitionTime); + pointer-events: none; + + >div { + display: flex; + justify-content: center; + align-items: center; + height: 44px; + white-space: nowrap; + position: relative; + } + + >div::after { + content: ''; + position: absolute; + height: 1px; + background-color: rgba(255, 255, 255, 0.7); + transform: scaleY(0.5); + width: 100%; + left: 0; + bottom: 0; + } + + >div:last-child::after { + height: 0; + } + + >div:active { + background-color: rgba(255, 255, 255, 0.1); + } + + &.open { + opacity: 1; + visibility: visible; + transform: translateY(0); + pointer-events: all; + } +} diff --git a/src/Add-on/ShareView/components/HideComponentsMenu/index.tsx b/src/Add-on/ShareView/components/HideComponentsMenu/index.tsx new file mode 100644 index 000000000..c23412f71 --- /dev/null +++ b/src/Add-on/ShareView/components/HideComponentsMenu/index.tsx @@ -0,0 +1,81 @@ +import { Observer } from 'mobx-react'; +import React, { useEffect, useRef, useState } from 'react'; +import { ShareViewStore } from '../../ShareViewStore'; +import './index.less'; + +interface IProps +{ + /** 显示隐藏 门板抽屉 */ + doorOrDrawerShowOrHide: (isDoor: boolean) => void; + /** 爆炸图 */ + changeExplosion: () => void; +} + +const HideComponentsMenu: React.FC = (props) => +{ + const shareViewStore: ShareViewStore = ShareViewStore.GetInstance(); + const [visible, setVisible] = useState(false); + const selectDivRef = useRef(); + + const hideSelect = (e: Event) => + { + if (e.target != selectDivRef.current) + setVisible(false); + }; + + useEffect(() => + { + document.addEventListener('click', hideSelect, false); + document.addEventListener('touchstart', hideSelect, false); + document.addEventListener('mousedown', hideSelect, false); + + return () => + { + document.removeEventListener('click', hideSelect, false); + document.removeEventListener('touchstart', hideSelect, false); + document.removeEventListener('mousedown', hideSelect, false); + }; + }, []); + + return ( +
setVisible(!visible)} + > + 隐藏组件 +
e.stopPropagation()} + onTouchStart={(e) => e.stopPropagation()} + onMouseDown={(e) => e.stopPropagation()} + > + + { + () => ( + <> +
+ { + props.changeExplosion(); + }} + >{shareViewStore.operations.showExplosion ? '聚合图' : '爆炸图'}
+
+ { + props.doorOrDrawerShowOrHide(true); + }}>{shareViewStore.operations.showDoor ? '隐藏' : '显示'}门板
+
+ { + props.doorOrDrawerShowOrHide(false); + }}>{shareViewStore.operations.showDrawer ? '隐藏' : '显示'}抽屉
+ + ) + } +
+
+
+ ); +}; + +export default HideComponentsMenu; diff --git a/src/Add-on/ShareView/components/MaterialBottomSheet.tsx b/src/Add-on/ShareView/components/MaterialBottomSheet.tsx index 8bcab66f8..cbbe044ec 100644 --- a/src/Add-on/ShareView/components/MaterialBottomSheet.tsx +++ b/src/Add-on/ShareView/components/MaterialBottomSheet.tsx @@ -10,8 +10,8 @@ import { GetBoxItemInfo, MaterialDetailScrollTo, SPGetSpiteSize } from "../Share interface IProps { ref: React.Ref; - cancelCallback: Function; - + /** 关闭BottomSheet时回调函数 */ + cancelCallback?: () => void; } // 物料明细 @@ -75,7 +75,10 @@ const MaterialBottomSheet: React.FC = forwardRef((props, ref) => { flagRef.current = false; setVisible(false); - props.cancelCallback(); + if (props.cancelCallback) + { + props.cancelCallback(); + } } function start(pageY) @@ -195,7 +198,7 @@ const MaterialBottomSheet: React.FC = forwardRef((props, ref) => - + @@ -242,7 +245,7 @@ const MaterialBottomSheet: React.FC = forwardRef((props, ref) =>
编号 名称 高度 宽度
- + diff --git a/src/Add-on/ShareView/components/ShareViewUI.tsx b/src/Add-on/ShareView/components/ShareViewUI.tsx index bd347e78e..09849e6a1 100644 --- a/src/Add-on/ShareView/components/ShareViewUI.tsx +++ b/src/Add-on/ShareView/components/ShareViewUI.tsx @@ -1,19 +1,19 @@ -import { observer, Provider, useObserver } from "mobx-react"; +import { Observer, observer, Provider } from "mobx-react"; import React, { useEffect, useRef, useState } from "react"; import { CommandNames } from "../../../Common/CommandNames"; import { Hole } from "../../../DatabaseServices/3DSolid/Hole"; import { commandMachine } from "../../../Editor/CommandMachine"; import { userConfig } from "../../../Editor/UserConfig"; import { RenderType } from "../../../GraphicsSystem/RenderType"; -import { IsDoor, IsDrawer, IsHandle, IsLattice } from "../../HideSelect/HideSelectUtils"; +import { IsDoor, IsDrawer, IsHandle } from "../../HideSelect/HideSelectUtils"; import { ViewStyleTypes } from "../ShareViewRules"; import { shareViewApp } from "../ShareViewService"; import { ShareViewStore } from "../ShareViewStore"; import "../ShareViewStyle.less"; -import { ChangeThemeColor, CreateBoxDim, DeleteBoxDim, ForbiddenToaster, resetBoxView, SwitchDoor } from "../ShareViewUtil"; +import { ChangeThemeColor, CreateBoxDim, DeleteBoxDim, ExplosionView, ForbiddenToaster, resetBoxView, SwitchDoorOrDrawer } from "../ShareViewUtil"; import BoardMessageWidget from "./BoardMessageWidget"; import CabinetBottomSheet from "./CabinetBottomSheet"; -import ExplosionMapWidget from "./ExplosionMapWidget"; +import HideComponentsMenu from "./HideComponentsMenu"; import MaterialBottomSheet from "./MaterialBottomSheet"; import SideBar from "./SideBar"; import { SPToaster } from "./SPToater"; @@ -28,25 +28,16 @@ function ShareViewUI() // const [selectCabinet, setSelectCabinet] = useState(false); // 选择柜体 // const [selectMaterial, setSelectMaterial] = useState(false); - // 门状态 - const [doorOpen, setDoorOpen] = useState(false); - // 显示门板 - const [doorShow, setDoorShow] = useState(true); - + // 页面遮罩 const [loading, setLoading] = useState(false); - // 显示隐藏标注 - const [dimBrsState, setDimBrsState] = useState(false); - // 显示隐藏板序号 - const [showCustomNumber, setShowCustomNumber] = useState(false); const cabinetBottomSheetRef = useRef(null); - const explosionMapWidgetRef = useRef(null); const materialBottomSheetRef = useRef(null); const shareViewStore: ShareViewStore = ShareViewStore.GetInstance(); // 点击板编号之前的样式 const beforeViewStyleRef = useRef(shareViewStore.viewUploadProps.VisualStyle); // 按下 esc - function escKeyDown(event) + function escKeyDown(event: KeyboardEvent) { if (event.code == "Escape") { @@ -62,7 +53,7 @@ function ShareViewUI() meta.name = "viewport"; meta.content = "width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no, viewport-fit=cover"; head.appendChild(meta); - setShowCustomNumber(shareViewStore.viewUploadProps.VisualStyle == RenderType.CustomNumber); + shareViewStore.operations.showCustomNumber = shareViewStore.viewUploadProps.VisualStyle == RenderType.CustomNumber; }, []); useEffect(() => @@ -73,7 +64,7 @@ function ShareViewUI() { document.removeEventListener('keydown', escKeyDown, false); }; - }, [doorOpen]); + }, [shareViewStore.operations.isDoorOpen]); // 检查是否有门 function checkHasDoor() @@ -81,8 +72,8 @@ function ShareViewUI() for (const el of shareViewStore.CurSelectCabinetIndexs) { let list = shareViewApp.BoxCtrl.GetCabinetEntities(el) - .filter((ent) => IsDrawer(ent) || IsLattice(ent) || IsDoor(ent) || IsHandle(ent) || (ent instanceof Hole && ent.ColorIndex !== 4)); - list = list.filter(ent => (IsDoor(ent) && ent.Template) || (IsDrawer(ent) || IsLattice(ent)) || (ent instanceof Hole)); + .filter((ent) => IsDrawer(ent) || IsDoor(ent) || IsHandle(ent) || (ent instanceof Hole && ent.ColorIndex !== 4)); + list = list.filter(ent => (IsDoor(ent) && ent.Template) || (IsDrawer(ent)) || (ent instanceof Hole)); if (list.length) return true; } return false; @@ -108,13 +99,13 @@ function ShareViewUI() // 关门 async function closeDoor() { - if (doorOpen) + if (shareViewStore.operations.isDoorOpen) { setLoading(true); shareViewApp.Editor.GetStringService.Cancel(); await checkDoorAnimationEnd(); setLoading(false); - setDoorOpen(false); + shareViewStore.operations.isDoorOpen = false; } else { return true; @@ -127,6 +118,7 @@ function ShareViewUI() if (loading) return; setLoading(true); await showDoor(); + await showDrawer(); let flag = checkHasDoor(); // console.log(flag); if (!flag) @@ -135,11 +127,13 @@ function ShareViewUI() SPToaster.show({ message: "当前柜体没有门" }); return; } - if (doorOpen) + if (shareViewStore.operations.isDoorOpen) { shareViewApp.Editor.GetStringService.Cancel(); } else { + // 自定义编号样式下无法开门, 还原之前的样式 + await resetCustomNumberToBeforeStyle(); shareViewStore.SelectedBoard = null; commandMachine.ExecCommand(CommandNames.SelectAll).then(() => { @@ -151,34 +145,50 @@ function ShareViewUI() } await checkDoorAnimationEnd(); setLoading(false); - setDoorOpen(!doorOpen); + shareViewStore.operations.isDoorOpen = !shareViewStore.operations.isDoorOpen; } // 显示隐藏门板 - let doorShowOrHide = async () => + const doorOrDrawerShowOrHide = async (isDoor: boolean = true) => { setLoading(true); - await explosionMapWidgetRef.current.reset(); - if (doorOpen) + await resetExplosionView(); + if (shareViewStore.operations.isDoorOpen) { shareViewApp.Editor.GetStringService.Cancel(); await checkDoorAnimationEnd(); - setDoorOpen(false); + shareViewStore.operations.isDoorOpen = false; } shareViewStore.SelectedBoard = null; - await SwitchDoor(!doorShow); + if (isDoor) + { + // 门板 + await SwitchDoorOrDrawer(!shareViewStore.operations.showDoor, isDoor); + shareViewStore.operations.showDoor = !shareViewStore.operations.showDoor; + } else + { + // 抽屉 + await SwitchDoorOrDrawer(!shareViewStore.operations.showDrawer, isDoor); + shareViewStore.operations.showDrawer = !shareViewStore.operations.showDrawer; + } setLoading(false); - setDoorShow(!doorShow); }; // 显示门板 - let showDoor = async () => + const showDoor = async () => + { + await SwitchDoorOrDrawer(true, true); + shareViewStore.operations.showDoor = true; + }; + + /** 显示抽屉 */ + const showDrawer = async () => { - await SwitchDoor(true); - setDoorShow(true); + await SwitchDoorOrDrawer(true, false); + shareViewStore.operations.showDrawer = true; }; - // 还原之前的主题背景色 + /** 还原之前的主题背景色 */ function resetPrevTheme() { if (shareViewStore.ThemeLog) @@ -188,32 +198,39 @@ function ShareViewUI() } } - // 标注显示 隐藏 + /** 临时设置成黑暗主题 */ + function setDrakThemeTemporary() + { + if (shareViewStore.Theme == 'light') + { + shareViewStore.ThemeLog = shareViewStore.Theme; + ChangeThemeColor('dark'); + shareViewStore.Theme = "dark"; + } + } + + /** 标注显示 隐藏 */ async function dimBrsShowOrHide() { shareViewStore.SelectedBoard = null; - if (dimBrsState) + if (shareViewStore.operations.showDimension) { resetPrevTheme(); await DeleteBoxDim(); } else { - if (shareViewStore.Theme == 'light') - { - shareViewStore.ThemeLog = shareViewStore.Theme; - ChangeThemeColor('dark'); - shareViewStore.Theme = "dark"; - } + setDrakThemeTemporary(); await CreateBoxDim(); } - setDimBrsState(!dimBrsState); + shareViewStore.operations.showDimension = !shareViewStore.operations.showDimension; } - // 显示/隐藏 板序号 - async function customNumberShowOrHide() + /** 还原点击自定义编号之前的样式或概念样式 */ + async function resetCustomNumberToBeforeStyle() { - if (showCustomNumber) + if (shareViewStore.operations.showCustomNumber) { + // resetPrevTheme(); let viewStyleIndex = ViewStyleTypes.findIndex(v => v.renderType === beforeViewStyleRef.current); if (viewStyleIndex == -1 || ViewStyleTypes[viewStyleIndex].renderType == RenderType.CustomNumber) { @@ -224,27 +241,41 @@ function ShareViewUI() await commandMachine.ExecCommand(ViewStyleTypes[viewStyleIndex].cmd); }); shareViewStore.viewUploadProps.VisualStyle = ViewStyleTypes[viewStyleIndex].renderType; + shareViewStore.operations.showCustomNumber = !shareViewStore.operations.showCustomNumber; + } + } + + /** 显示/隐藏 板编号 */ + async function customNumberShowOrHide() + { + await closeDoor(); + await resetExplosionView(); + if (shareViewStore.operations.showCustomNumber) + { + await resetCustomNumberToBeforeStyle(); } else { + // setDrakThemeTemporary(); beforeViewStyleRef.current = shareViewStore.viewUploadProps.VisualStyle; await commandMachine.ExecCommand(CommandNames.VisualStyle_CustomNumber); shareViewStore.viewUploadProps.VisualStyle = RenderType.CustomNumber; + shareViewStore.operations.showCustomNumber = !shareViewStore.operations.showCustomNumber; } - setShowCustomNumber(!showCustomNumber); } // 还原 async function resetAll() { shareViewStore.SelectedBoard = null; - if (dimBrsState) + if (shareViewStore.operations.showDimension) { await DeleteBoxDim(); - setDimBrsState(false); + shareViewStore.operations.showDimension = false; } await closeDoor(); - await explosionMapWidgetRef.current.reset(); + await resetExplosionView(); await showDoor(); + await showDrawer(); commandMachine.ExecCommand(CommandNames.Esc); shareViewStore.CurSelectCabinetIndexs.forEach(el => { @@ -256,27 +287,43 @@ function ShareViewUI() resetBoxView(); } - // 判断是否展示物料明细 - function showMaterialDetails() + /** 爆炸图 距离 */ + const explosionDistance = 600; + /** 还原爆炸图 */ + const resetExplosionView = async () => { - return useObserver(() => + if (shareViewStore.operations.showExplosion) { - return ( - <> - {shareViewStore.Props.showBom == false ? null : ( -
- { - materialBottomSheetRef.current.show(); - }} - >物料明细{shareViewStore.Props.showBom}
- )} - - ); - }); + await changeExplosionView(explosionDistance); + shareViewStore.operations.showExplosion = !shareViewStore.operations.showExplosion; + } + }; + + /** 打开/关闭 爆炸图 */ + async function changeExplosionView(distance: number) + { + for (const i of shareViewStore.CurSelectCabinetIndexs) + { + await ExplosionView(i, distance); + } } + const changeExplosion = async () => + { + setLoading(true); + shareViewStore.SelectedBoard = null; + await closeDoor(); + if (shareViewStore.operations.showExplosion) + { + await changeExplosionView(explosionDistance); + } else + { + await changeExplosionView(-explosionDistance); + } + shareViewStore.operations.showExplosion = !shareViewStore.operations.showExplosion; + setLoading(false); + }; + return ( @@ -290,23 +337,30 @@ function ShareViewUI() cabinetBottomSheetRef.current.show(); }} >选择柜体 - {showMaterialDetails()} -
{doorOpen ? '关门' : '开门'}
-
{doorShow ? '隐藏' : '显示'}门板
- - { - setLoading(val); - }} - reset={async () => - { - await closeDoor(); - }} - ref={explosionMapWidgetRef} - > -
还原
+ + {() => ( + <> + {shareViewStore.Props.showBom == false ? null : ( +
+ { + materialBottomSheetRef.current.show(); + }} + >物料明细{shareViewStore.Props.showBom}
+ )} +
+ {shareViewStore.operations.isDoorOpen ? '关门' : '开门'}
+ + )} +
+ +
还原
{/* 侧边栏 */} @@ -314,46 +368,48 @@ function ShareViewUI() {/* 顶部栏 */}
- + { await closeDoor(); - await explosionMapWidgetRef.current.reset(); - setShowCustomNumber(renderType == RenderType.CustomNumber); + await resetExplosionView(); + shareViewStore.operations.showCustomNumber = renderType == RenderType.CustomNumber; shareViewStore.viewUploadProps.VisualStyle = renderType; }} currentRenderType={shareViewStore.viewUploadProps.VisualStyle} /> -
标注
-
板编号
- {/*
编号
*/} + + {() => ( + <> +
标注
+
板号
+ + )} +
- { - // setSelectCabinet(false); - }} reset={async () => { - if (dimBrsState) + if (shareViewStore.operations.showDimension) { await DeleteBoxDim(); - setDimBrsState(false); + shareViewStore.operations.showDimension = false; } await closeDoor(); - await explosionMapWidgetRef.current.reset(); + await resetExplosionView(); await showDoor(); - setDimBrsState(false); - }} ref={cabinetBottomSheetRef} - /> - - { - // setSelectMaterial(false); + await showDrawer(); }} - ref={materialBottomSheetRef} + ref={cabinetBottomSheetRef} /> +
);
编号 配件 规格 数量