#
luxiaotao1123
2024-10-16 dc31d8c4e1e45d6f932050a0da4e18a09d8dfd07
zy-acs-flow/src/map/insight/shelf/ShelfMain.jsx
@@ -12,8 +12,8 @@
    Stack,
} from '@mui/material';
import ShelfThree from './ShelfThree';
import request from '@/utils/request';
import { getLocGroup } from '../../http';
import { grey } from '@mui/material/colors';
let shelfThree;
@@ -41,30 +41,22 @@
                        mesh.position.set(0, singleHeight * (lev - 1), 0);
                        mesh.scale.set(5, 5, 5);
                        mesh.name = item.locNo;
                        mesh.traverse(function (child) {
                        mesh.traverse((child) => {
                            if (child.isMesh) {
                                if (child.name === '货架') {
                                    child.material.color.set(0x4680BF);
                                }
                                let palletVisible = true, cargoVisible = true;
                                switch (item.locStsEl) {
                                    case 'STOCK':
                                        cargoVisible = false;
                                switch (child.name) {
                                    case '货架':
                                        child.material.color.set(0x4680BF);
                                        break;
                                    case 'IDLE':
                                        palletVisible = false;
                                        cargoVisible = false;
                                    case '托盘':
                                        child.visible = item.locStsEl === 'STOCK' || item.locStsEl === 'PAKOUT';
                                        child.material.color.set(0xBEBEBE);
                                        break;
                                    case '不规则':
                                        child.visible = item.locStsEl === 'STOCK' || item.locStsEl === 'PAKOUT';
                                        child.material.color.set(0xE8B67E);
                                        break;
                                    default:
                                        break;
                                }
                                if (child.name === '托盘') {
                                    child.visible = palletVisible;
                                    child.material.color.set(0xBEBEBE);
                                }
                                if (child.name === '不规则') {
                                    child.visible = cargoVisible;
                                    child.material.color.set(0xE8B67E);
                                }
                                child.name = item.locNo
                                child.castShadow = true;
@@ -84,7 +76,6 @@
            }).catch(error => {
                console.error(error);
            });
        })
    }
}
@@ -94,10 +85,7 @@
    const translate = useTranslate();
    const containerRef = useRef();
    const [loading, setLoading] = useState(true);
    const [shelfThree, setShelfThree] = useState(null);
    const [info, setInfo] = useState(null);
    useEffect(() => {
        if (data) {
@@ -112,7 +100,6 @@
        if (info) {
            endThree();
            setLoading(true);
            setTimeout(() => {
                startThree(containerRef.current);
                shelfThree.handleClick = (objName) => {
@@ -121,42 +108,15 @@
                renderThree(info, curLocNo);
                setLoading(false);
            }, 300)
        }
        return endThree;
    }, [info]);
    useEffect(() => {
        const initThree = () => {
            const shelfThreeInstance = new ShelfThree(containerRef.current);
            shelfThreeInstance.startup();
            shelfThreeInstance.handleClick = (objName) => {
                setCurLocNo(objName);
            };
            setShelfThree(shelfThreeInstance);
            setLoading(false);
            // Fetch initial data
        };
        initThree();
        return () => {
            if (shelfThree) {
                shelfThree.destroy();
            }
        };
    }, []);
    return (
        <Box display="flex" height="500px">
        <Box display="flex" height="100%">
            <Box
                position="relative"
                width="60%"
                width="50%"
                height="100%"
                ref={containerRef}
                style={{ backgroundColor: '#7a7a7a' }}
@@ -168,11 +128,11 @@
                        left="50%"
                        style={{ transform: 'translate(-50%, -50%)' }}
                    >
                        <CircularProgress />
                        <CircularProgress sx={{ color: grey[50] }} />
                    </Box>
                )}
            </Box>
            <Box width="40%" height="100%" overflow="auto" p={2}>
            <Box width="50%" height="100%" overflow="auto" p={2}>
                {/* <Paper elevation={3} style={{ padding: '16px' }}>
                    <Typography variant="h6" gutterBottom>
                        {translate('map.loc.no', { defaultMessage: '库位号' })}: {curLocNo}