#
luxiaotao1123
2024-10-21 ce79f7c56c3832d1a4ebdb1d7d1c2bbd87d8b004
zy-acs-flow/src/map/tool.js
@@ -7,7 +7,11 @@
    DEVICE_SPRITE_TINT,
    DEVICE_SELECTED_EFFECT_PADDING,
    DEVICE_SELECTED_EFFECT_COLOR,
    POINT_ROUTE_DIRECTION,
    DEVICE_SPRITE_TINT_DARK,
} from './constants';
import { getRouteList } from './http';
import PointRoute from "./PointRoute";
import shelf from '/map/shelf.svg';
import charge from '/map/charge.svg';
@@ -48,6 +52,21 @@
export function setThemeMode(param) {
    themeMode = param;
    if (mapContainer) {
        // mapContainer.children.forEach(child => {
        //     const deviceType = child.data?.type;
        //     if (deviceType) {
        //         if (themeMode === 'dark') {
        //             const tint = DEVICE_SPRITE_TINT_DARK[deviceType]
        //             if (tint) {
        //                 child.tint = tint;
        //             }
        //         } else {
        //             DEVICE_SPRITE_TINT[deviceType] != null && (child.tint = DEVICE_SPRITE_TINT[deviceType]);
        //         }
        //     }
        // })
    }
}
@@ -105,7 +124,8 @@
        default:
            break;
    }
    DEVICE_SPRITE_TINT[deviceType] != null && (sprite.tint = DEVICE_SPRITE_TINT[deviceType]);
    const tintType = themeMode === 'dark' ? DEVICE_SPRITE_TINT_DARK : DEVICE_SPRITE_TINT;
    tintType[deviceType] != null && (sprite.tint = tintType[deviceType]);
    if (sprite && deviceType !== DEVICE_TYPE.AGV) {
        sprite.blendMode = PIXI.BLEND_MODES.MULTIPLY;
@@ -224,6 +244,8 @@
}
export const beInsight = (sprite, setCurSprite) => {
    if (!sprite?.data?.type) { return }
    sprite.off('pointerup');
    sprite.off('pointermove');
    sprite.off('pointerdown');
@@ -238,7 +260,6 @@
    sprite.on('pointerover', onSpriteMouseOver);
    sprite.on('pointermove', onSpriteMouseMove);
    sprite.on('pointerout', onSpriteMouseOut);
}
export const beMovable = (sprite) => {
@@ -281,6 +302,8 @@
}
export const beSettings = (sprite, setSpriteSettings) => {
    if (!sprite?.data?.type) { return }
    sprite.off('pointerup');
    sprite.off('pointermove');
    sprite.off('pointerdown');
@@ -295,40 +318,38 @@
    sprite.on('pointerover', onSpriteMouseOver);
    sprite.on('pointermove', onSpriteMouseMove);
    sprite.on('pointerout', onSpriteMouseOut);
}
const createSpriteTooltip = (sprite) => {
    const style = new PIXI.TextStyle({
        fontFamily: 'Microsoft YaHei',
        fontSize: 16,
        fill: '#ffffff',
        stroke: '#4a1850',
        strokeThickness: 2,
        dropShadow: true,
        dropShadowColor: '#000000',
        dropShadowBlur: 4,
        dropShadowAngle: Math.PI / 6,
        dropShadowDistance: 6,
        fontFamily: 'Roboto',
        fontSize: 12,
        fill: themeMode === 'light' ? '#000' : '#eee',
    });
    const text = new PIXI.Text(`编号: ${sprite.data.no}`, style);
    const text = new PIXI.Text(`${sprite.data?.type} ${sprite.data?.no}`, style);
    const background = new PIXI.Graphics();
    background.beginFill(0x000000, 0.7);
    background.drawRoundedRect(0, 0, text.width + 20, text.height + 20, 10);
    // shadow
    background.beginFill(themeMode === 'light' ? '#000' : '#eee', 0.1);
    background.drawRoundedRect(4, 4, text.width + 6, text.height + 6, 4);
    background.endFill();
    // background
    background.beginFill(themeMode === 'light' ? '#fff' : '#333', 1);
    background.drawRoundedRect(0, 0, text.width + 8, text.height + 8, 4);
    background.endFill();
    text.x = 10;
    text.y = 10;
    text.x = 5;
    text.y = 3;
    background.addChild(text);
    tooltip = new PIXI.Container();
    tooltip.name = "tooltip";
    tooltip.addChild(background);
    return tooltip;
}
function onSpriteMouseOver(event) {
    if (tooltip) {
        app.stage.removeChild(tooltip);
    }
    tooltip = createSpriteTooltip(this);// this => sprite
    tooltip.x = event.data.global.x + 10;
    tooltip.y = event.data.global.y + 10;
@@ -470,6 +491,34 @@
    effectCircle.position.set(selectedSprite.x, selectedSprite.y);
};
export const showRoutes = (curZone, setShowRoutes) => {
    setShowRoutes(true);
    getRouteList(curZone, (routeList) => {
        routeList.forEach(route => {
            const startPoint = querySprite(DEVICE_TYPE.POINT, route.startCodeStr);
            const endPoint = querySprite(DEVICE_TYPE.POINT, route.endCodeStr);
            const pointRoute = new PointRoute(POINT_ROUTE_DIRECTION[route.direction]);
            pointRoute.setPoint(startPoint, endPoint);
            pointRoute.clear();
            pointRoute.lineStyle(8, themeMode === 'light' ? '#2d3436' : '#dcdde1');
            pointRoute.moveTo(startPoint.position.x, startPoint.position.y);
            pointRoute.lineTo(endPoint.position.x, endPoint.position.y);
            pointRoute.alpha = 1;
            mapContainer.addChild(pointRoute);
        })
    })
};
export const hideRoutes = (curZone, setShowRoutes) => {
    setShowRoutes(false);
    for (let i = mapContainer.children.length - 1; i >= 0; i--) {
        const child = mapContainer.children[i];
        if (child?.type === DEVICE_TYPE.ROUTE) {
            mapContainer.removeChild(child);
        }
    }
}
export const multipleSelectEnhancer = (selectedSprites, setCurSprite, setBatchSprites) => {
    selectedSprites = selectedSprites.filter(sprite => sprite.data?.type);