#
vincentlu
2025-12-15 e246aa751c6a8b36721e8acf70acc238188f49dc
zy-acs-flow/src/map/areaSettings/AreaBasicTab.jsx
@@ -1,17 +1,43 @@
import React from 'react';
import { Stack, TextField, Button, Typography, Box } from '@mui/material';
import {
    Stack,
    TextField,
    Button,
    Typography,
    Box,
    Autocomplete,
    Checkbox,
} from '@mui/material';
import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank';
import CheckBoxIcon from '@mui/icons-material/CheckBox';
import { useTranslate } from 'react-admin';
const AreaBasicTab = ({
    areaName,
    setAreaName,
    agvList,
    setAgvList,
    agvOptions,
    selectedAgvs,
    setSelectedAgvs,
    barcodeList,
    setBarcodeList,
    onSave,
}) => {
    const translate = useTranslate();
    const icon = <CheckBoxOutlineBlankIcon fontSize="small" />;
    const checkedIcon = <CheckBoxIcon fontSize="small" />;
    const getOptionLabel = (option) => {
        if (typeof option === 'string') {
            return option;
        }
        return option?.label ?? option?.name ?? option?.agvNo ?? option?.value ?? option?.id ?? '';
    };
    const getOptionId = (option) => {
        if (typeof option === 'string') {
            return option;
        }
        return option?.value ?? option?.id ?? option?.agvNo ?? option?.code ?? option?.name ?? '';
    };
    return (
        <Stack spacing={2}>
@@ -31,13 +57,34 @@
                <Typography variant="subtitle2" gutterBottom>
                    {translate('page.map.area.agv', { _: '添加AGV小车' })}
                </Typography>
                <TextField
                    placeholder={translate('page.map.area.agv.placeholder', { _: '用逗号分隔:agv01, agv02' })}
                    fullWidth
                    multiline
                    minRows={3}
                    value={agvList}
                    onChange={(e) => setAgvList(e.target.value)}
                <Autocomplete
                    multiple
                    disableCloseOnSelect
                    options={agvOptions || []}
                    value={selectedAgvs || []}
                    getOptionLabel={getOptionLabel}
                    isOptionEqualToValue={(option, value) => getOptionId(option) === getOptionId(value)}
                    onChange={(event, newValue) => {
                        setSelectedAgvs(newValue);
                    }}
                    renderOption={(props, option, { selected }) => (
                        <li {...props}>
                            <Checkbox
                                icon={icon}
                                checkedIcon={checkedIcon}
                                style={{ marginRight: 8 }}
                                checked={selected}
                            />
                            {getOptionLabel(option)}
                        </li>
                    )}
                    renderInput={(params) => (
                        <TextField
                            {...params}
                            placeholder={translate('page.map.area.agv.placeholder', { _: '选择AGV' })}
                        />
                    )}
                    ListboxProps={{ sx: { maxHeight: 280 } }}
                />
            </Box>
@@ -52,7 +99,7 @@
                    minRows={6}
                    maxRows={10}
                    value={barcodeList}
                    onChange={(e) => setBarcodeList(e.target.value)}
                    InputProps={{ readOnly: true }}
                />
            </Box>
        </Stack>