| | |
| | | Box, |
| | | Autocomplete, |
| | | Checkbox, |
| | | Chip, |
| | | } from '@mui/material'; |
| | | import CheckBoxOutlineBlankIcon from '@mui/icons-material/CheckBoxOutlineBlank'; |
| | | import CheckBoxIcon from '@mui/icons-material/CheckBox'; |
| | |
| | | agvOptions, |
| | | agvList, |
| | | setAgvList, |
| | | codeListText, |
| | | codeList, |
| | | onSave, |
| | | disableSave, |
| | | }) => { |
| | |
| | | const checkedIcon = <CheckBoxIcon fontSize="small" />; |
| | | |
| | | const getOptionLabel = (option) => { |
| | | if (typeof option === 'string') { |
| | | return option; |
| | | if (option == null) { |
| | | return ''; |
| | | } |
| | | return option?.label ?? option?.name ?? option?.agvNo ?? option?.value ?? option?.id ?? ''; |
| | | if (typeof option === 'string' || typeof option === 'number') { |
| | | return String(option); |
| | | } |
| | | const label = |
| | | option?.label ?? |
| | | option?.uuid ?? |
| | | option?.name ?? |
| | | option?.agvNo ?? |
| | | option?.value ?? |
| | | option?.id ?? |
| | | ''; |
| | | return label != null ? String(label) : ''; |
| | | }; |
| | | |
| | | const getOptionId = (option) => { |
| | | if (typeof option === 'string') { |
| | | return option; |
| | | if (option == null) { |
| | | return ''; |
| | | } |
| | | return option?.value ?? option?.id ?? option?.agvNo ?? option?.code ?? option?.name ?? ''; |
| | | if (typeof option === 'string' || typeof option === 'number') { |
| | | return String(option); |
| | | } |
| | | const identifier = |
| | | option?.value ?? |
| | | option?.id ?? |
| | | option?.uuid ?? |
| | | option?.agvNo ?? |
| | | option?.code ?? |
| | | option?.name ?? |
| | | ''; |
| | | return identifier != null ? String(identifier) : ''; |
| | | }; |
| | | |
| | | return ( |
| | |
| | | <Stack direction="row" spacing={1} alignItems="center"> |
| | | <TextField |
| | | label={translate('page.map.area.name', { _: '名称' })} |
| | | size="small" |
| | | fullWidth |
| | | value={name} |
| | | onChange={(e) => setName(e.target.value)} |
| | |
| | | onChange={(event, newValue) => { |
| | | setAgvList(newValue); |
| | | }} |
| | | renderOption={(props, option, { selected }) => ( |
| | | <li {...props}> |
| | | <Checkbox |
| | | icon={icon} |
| | | checkedIcon={checkedIcon} |
| | | style={{ marginRight: 8 }} |
| | | checked={selected} |
| | | renderTags={(value, getTagProps) => |
| | | value.map((option, index) => ( |
| | | <Chip |
| | | {...getTagProps({ index })} |
| | | key={getOptionId(option)} |
| | | label={getOptionLabel(option)} |
| | | size="small" |
| | | sx={{ mr: 0.5 }} |
| | | /> |
| | | {getOptionLabel(option)} |
| | | </li> |
| | | )} |
| | | )) |
| | | } |
| | | ListboxProps={{ |
| | | sx: { |
| | | maxHeight: 240, |
| | | '& .MuiAutocomplete-option': { py: 0.5, fontSize: 13 }, |
| | | }, |
| | | }} |
| | | renderOption={(props, option, { selected }) => { |
| | | const { key, ...optionProps } = props; |
| | | return ( |
| | | <li |
| | | key={key} |
| | | {...optionProps} |
| | | style={{ |
| | | fontSize: 13, |
| | | display: 'flex', |
| | | alignItems: 'center', |
| | | ...(optionProps.style || {}), |
| | | }} |
| | | > |
| | | <Checkbox |
| | | icon={icon} |
| | | checkedIcon={checkedIcon} |
| | | sx={{ mr: 1, '& .MuiSvgIcon-root': { fontSize: 18 } }} |
| | | checked={selected} |
| | | /> |
| | | <Typography variant="body2">{getOptionLabel(option)}</Typography> |
| | | </li> |
| | | ); |
| | | }} |
| | | renderInput={(params) => ( |
| | | <TextField |
| | | {...params} |
| | | size="small" |
| | | placeholder={translate('page.map.area.agv.placeholder', { _: '选择AGV' })} |
| | | /> |
| | | )} |
| | | ListboxProps={{ sx: { maxHeight: 280 } }} |
| | | /> |
| | | </Box> |
| | | |
| | |
| | | multiline |
| | | minRows={6} |
| | | maxRows={10} |
| | | value={codeListText} |
| | | value={(codeList || []).join('\n')} |
| | | InputProps={{ readOnly: true }} |
| | | /> |
| | | </Box> |