!2209 功能:看图王默认按房间选中所有柜子及判断参数props是否展示物料明细 Story #286

pull/2203/MERGE
ChenX 1 year ago
parent e53fe8cc96
commit e26c6f54ee

@ -3,9 +3,9 @@ import { HostApplicationServices } from "../../ApplicationServices/HostApplicati
import { CommandNames } from "../../Common/CommandNames";
import { ErrorMonitoring } from "../../Common/ErrorMonitoring";
import { CURRENT_HOST } from "../../Common/HostUrl";
import { inflateBase64 } from "../../Common/inflate";
import { LogEnable, ReportErrorWrap } from "../../Common/Log";
import { RequestStatus } from "../../Common/Request";
import { inflateBase64 } from "../../Common/inflate";
import { CADFiler } from "../../DatabaseServices/CADFiler";
import { commandMachine } from "../../Editor/CommandMachine";
import { userConfig } from "../../Editor/UserConfig";
@ -219,12 +219,21 @@ window.onload = function ()
ChangeThemeColor("light");
layout.app.BoxCtrl.SetCabinetFormatData(obj);
layout.app.BoxCtrl.SetBoxVisible(layout.app.BoxCtrl.BoxList.length - 1, false);
layout.app.BoxCtrl.SetBoxVisible(0, true);
boxStore.RoomName = Object.keys(obj)[0];
// 展示第一个房间所有柜子
if (Object.keys(obj)[0])
{
const indexes = [];
obj[Object.keys(obj)[0]].forEach(item =>
{
indexes.push(item.index);
layout.app.BoxCtrl.SetBoxVisible(item.index, true);
});
boxStore.Index = indexes;
}
layout.app.Viewer.OnSize();
layout.app.Viewer.Render();
resetBoxView();
boxStore.RoomName = Object.keys(obj)[0];
boxStore.Index = [0];
el.remove();
}, 1000);
});
@ -270,6 +279,10 @@ async function LoadData()
let file = JSON.parse(inflateBase64(data.fileInfo.file));
document.title = data.fileInfo.name;
if (data.fileInfo.props && Object.prototype.toString.call(data.fileInfo.props) === '[object Object]')
{
boxStore.Props = data.fileInfo.props;
}
return new CADFiler(file);
} else
{

@ -3,6 +3,12 @@ import { observable } from "mobx";
import { Singleton } from "../../Common/Singleton";
import { Board } from "../../DatabaseServices/Entity/Board";
interface IProps
{
/* 是否展示物料明细 */
IsMaterialDetails?: boolean | null;
}
export class BoxStore extends Singleton
{
@observable
@ -23,4 +29,8 @@ export class BoxStore extends Singleton
// 纪录上一次
@observable
ThemeLog: 'light' | 'dark' | string = '';
// 后台配置数据
@observable
Props: IProps = {}
}

@ -5,6 +5,7 @@ import { commandMachine } from "../../../Editor/CommandMachine";
import { shareViewApp } from "../Service";
import { BoxStore } from "../Store";
import { resetBoxView } from "../Util";
import { CheckEmptySvg, CheckedSvg } from "./CommonSvgs";
import { SPToaster } from "./SPToater";
@ -23,6 +24,29 @@ const CabinetBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
const [list, setList] = useState<any>({});
const [key, setKey] = useState<number>(0);
const boxStore: BoxStore = BoxStore.GetInstance();
const [selectAll, setSelectAll] = useState(false);
// 判断是否全选状态
function isSelectAll(roomName: string)
{
let obj = shareViewApp.BoxCtrl.CabinetFormatData || {};
if (obj[roomName].length != boxStore.Index.length)
{
setSelectAll(false);
} else
{
let flag = true;
for (const el of obj[roomName])
{
if (!boxStore.Index.includes(el.index))
{
flag = false;
break;
}
}
setSelectAll(flag);
}
}
useImperativeHandle(ref, () => (
{
@ -42,6 +66,7 @@ const CabinetBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
{
SPToaster.show({ message: "没有柜体" });
}
isSelectAll(boxStore.RoomName);
},
})
);
@ -80,6 +105,23 @@ const CabinetBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
}
}
async function showCabinet()
{
await props.reset();
await commandMachine.ExecCommand(CommandNames.Esc);
await commandMachine.ExecCommand(CommandNames.SelectAll);
await commandMachine.ExecCommand(CommandNames.HideSelect);
await commandMachine.ExecCommand(CommandNames.Swiso);
boxStore.Index.forEach((el) =>
{
shareViewApp.BoxCtrl.SetBoxVisible(el, true);
});
shareViewApp.Editor.UpdateScreen();
resetBoxView();
setKey(key + 1);
boxStore.SelectedBoard = null;
}
return (
<>
<div className={`sp-cabinet-bottom-sheet-msak ${visible ? 'open' : ""}`}
@ -88,7 +130,46 @@ const CabinetBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
</div>
<div className={`sp-cabinet-bottom-sheet ${visible ? 'open' : ''}`}>
<div className="sp-bottom-sheet-title">
<div></div>
<div style={{ display: "flex", alignItems: "center", justifyContent: "center" }}>
<span></span>
<span
style={{
display: "flex",
alignItems: "center",
justifyContent: "center",
fontWeight: "normal",
marginLeft: 12,
color: "#1890ff",
fontSize: 14,
cursor: "pointer",
}}
onClick={async () =>
{
if (list[selectedTab])
{
const indexes = [];
if (selectAll)
{
indexes.push(list[selectedTab][0].index);
} else
{
list[selectedTab].forEach(item =>
{
indexes.push(item.index);
});
}
boxStore.Index = indexes;
boxStore.RoomName = selectedTab;
await showCabinet();
setSelectAll(!selectAll);
}
}}>
{
selectAll ? <CheckedSvg></CheckedSvg> : <CheckEmptySvg></CheckEmptySvg>
}
</span>
</div>
<Icon className="sp-bottom-sheet-close" onClick={closeSheet} icon="cross"></Icon>
</div>
<div className="sp-tab-bar" >
@ -102,6 +183,7 @@ const CabinetBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
{
scrollCenter(i, 'tabbar');
setSelectedTab(key);
isSelectAll(key);
}}
>{key}</div>
);
@ -120,11 +202,6 @@ const CabinetBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
${boxStore.RoomName == selectedTab && boxStore.Index.includes(item.index) ? 'active' : ''}`}
onClick={async () =>
{
await props.reset();
await commandMachine.ExecCommand(CommandNames.Esc);
await commandMachine.ExecCommand(CommandNames.SelectAll);
await commandMachine.ExecCommand(CommandNames.HideSelect);
await commandMachine.ExecCommand(CommandNames.Swiso);
if (boxStore.RoomName == item.roomName)
{
if (boxStore.Index.includes(item.index))
@ -142,14 +219,8 @@ const CabinetBottomSheet: React.FC<IProps> = forwardRef((props, ref) =>
boxStore.RoomName = item.roomName;
boxStore.Index = [item.index];
}
boxStore.Index.forEach((el) =>
{
shareViewApp.BoxCtrl.SetBoxVisible(el, true);
});
shareViewApp.Editor.UpdateScreen();
resetBoxView();
setKey(key + 1);
boxStore.SelectedBoard = null;
await showCabinet();
setSelectAll(boxStore.Index.length == list[item.roomName].length);
}}
>
<div className="sp-tab-view-item-logo">

@ -0,0 +1,21 @@
import React from 'react';
export const CheckedSvg = () =>
{
return (
<svg viewBox="0 0 1024 1024" width="32" height="32">
<path d="M433.1 657.7c12.7 17.7 39 17.7 51.7 0l210.6-292c3.8-5.3 0-12.7-6.5-12.7H642c-10.2 0-19.9 4.9-25.9 13.3L459 584.3l-71.2-98.8c-6-8.3-15.6-13.3-25.9-13.3H315c-6.5 0-10.3 7.4-6.5 12.7l124.6 172.8z" fill="#1890ff"></path>
<path d="M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32z m-40 728H184V184h656v656z" fill="#1890ff"></path>
</svg>
);
};
export const CheckEmptySvg = () =>
{
return (
<svg viewBox="0 0 1024 1024" width="32" height="32">
<path d="M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32z m-40 728H184V184h656v656z" fill="#1890ff"></path>
</svg>
);
};

@ -1,20 +1,20 @@
import { Provider } from "mobx-react";
import { Provider, useObserver } 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 { IsDoor, IsDrawer, IsHandle, IsLattice } from "../../HideSelect/HideSelectUtils";
import "../index.less";
import { shareViewApp } from "../Service";
import { BoxStore } from "../Store";
import { ChangeThemeColor, CreateBoxDim, DeleteBoxDim, ForbiddenToaster, resetBoxView, SwitchDoor } from "../Util";
import { ChangeThemeColor, CreateBoxDim, DeleteBoxDim, ForbiddenToaster, SwitchDoor, resetBoxView } from "../Util";
import "../index.less";
import BoardMessageWidget from "./BoardMessageWidget";
import CabinetBottomSheet from "./CabinetBottomSheet";
import ExplosionMapWidget from "./ExplosionMapWidget";
import MaterialBottomSheet from "./MaterialBottomSheet";
import SideBar from "./SideBar";
import { SPToaster } from "./SPToater";
import SideBar from "./SideBar";
import ViewAngle from "./ViewAngle";
import ViewIDErrorWidget from "./ViewIDErrorWidget";
import ViewStyle from "./ViewStyle";
@ -226,6 +226,28 @@ export function ShareViewUI()
resetBoxView();
}
// 判断是否展示物料明细
function showMaterialDetails()
{
return useObserver(() =>
{
return (
<>
{boxStore.Props.IsMaterialDetails == false ? null : (
<div
// className={`${selectMaterial ? 'active' : ''}`}
onClick={() =>
{
materialBottomSheetRef.current.show();
}}
>{boxStore.Props.IsMaterialDetails}</div>
)}
</>
);
});
}
return (
<React.Fragment>
<Provider store={BoxStore}>
@ -239,13 +261,7 @@ export function ShareViewUI()
cabinetBottomSheetRef.current.show();
}}
></div>
<div
// className={`${selectMaterial ? 'active' : ''}`}
onClick={() =>
{
materialBottomSheetRef.current.show();
}}
></div>
{showMaterialDetails()}
<div onClick={doorOpenOrClose} className={`${doorOpen ? 'active' : ''}`}>{doorOpen ? '关门' : '开门'}</div>
<div onClick={doorShowOrHide} className={`${doorShow ? '' : 'active'}`}>{doorShow ? '隐藏' : '显示'}</div>
<ExplosionMapWidget

@ -599,6 +599,7 @@ canvas {
color: #fff;
font-size: 16px;
flex-direction: column;
cursor: default;
svg {
width: 70px;

Loading…
Cancel
Save