| | |
| | | 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}> |
| | |
| | | <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> |
| | | |
| | |
| | | minRows={6} |
| | | maxRows={10} |
| | | value={barcodeList} |
| | | onChange={(e) => setBarcodeList(e.target.value)} |
| | | InputProps={{ readOnly: true }} |
| | | /> |
| | | </Box> |
| | | </Stack> |