| | |
| | | codeList, |
| | | onSave, |
| | | disableSave, |
| | | onDelete, |
| | | canDelete = false, |
| | | }) => { |
| | | const translate = useTranslate(); |
| | | const icon = <CheckBoxOutlineBlankIcon fontSize="small" />; |
| | | const checkedIcon = <CheckBoxIcon fontSize="small" />; |
| | | |
| | | const normalizeAgvId = (agv) => { |
| | | if (agv == null) { |
| | | return ''; |
| | | } |
| | | if (typeof agv === 'object') { |
| | | return String(agv.id ?? ''); |
| | | } |
| | | return String(agv); |
| | | }; |
| | | |
| | | const getOptionId = (option) => { |
| | | return normalizeAgvId(option) |
| | | }; |
| | | |
| | | const getOptionLabel = (option) => { |
| | | return option?.uuid ?? ''; |
| | | }; |
| | | |
| | | const getOptionId = (option) => { |
| | | return option?.id; |
| | | const handleSaveClick = () => { |
| | | if (disableSave) { |
| | | return; |
| | | } |
| | | const confirmMsg = translate('page.map.area.saveConfirm', { _: '确认保存当前修改?' }); |
| | | if (window.confirm(confirmMsg)) { |
| | | onSave?.(); |
| | | } |
| | | }; |
| | | |
| | | const handleDeleteClick = () => { |
| | | if (!canDelete) { |
| | | return; |
| | | } |
| | | const confirmMsg = translate('page.map.area.deleteConfirm', { _: '删除后将无法恢复,确认删除?' }); |
| | | if (window.confirm(confirmMsg)) { |
| | | onDelete?.(); |
| | | } |
| | | }; |
| | | |
| | | return ( |
| | |
| | | options={agvOptions || []} |
| | | value={agvList || []} |
| | | getOptionLabel={getOptionLabel} |
| | | isOptionEqualToValue={(option, value) => getOptionId(option) === getOptionId(value)} |
| | | isOptionEqualToValue={(option, value) => { |
| | | return getOptionId(option) === getOptionId(value); |
| | | }} |
| | | onChange={(event, newValue) => { |
| | | setAgvList(newValue); |
| | | }} |
| | |
| | | value.map((option, index) => ( |
| | | <Chip |
| | | {...getTagProps({ index })} |
| | | key={getOptionId(option)} |
| | | label={getOptionLabel(option)} |
| | | key={getOptionId(option) || index} |
| | | label={normalizeAgvId(option)} |
| | | size="small" |
| | | sx={{ mr: 0.5, fontWeight: 'bold' }} |
| | | /> |
| | |
| | | |
| | | <Box> |
| | | <Typography variant="subtitle2" gutterBottom> |
| | | {translate('page.map.area.barcodes', { _: '区域内条码集合' })} |
| | | {translate('page.map.area.barcodes', { _: '区域内条码集合' }) + " (" + codeList.length + ")"} |
| | | </Typography> |
| | | <Paper |
| | | variant="outlined" |
| | |
| | | </Paper> |
| | | </Box> |
| | | |
| | | <Box display="flex" justifyContent="flex-start"> |
| | | <Button variant="contained" onClick={onSave} disabled={disableSave}> |
| | | <Box display="flex" justifyContent="space-between" alignItems="center"> |
| | | <Button variant="contained" onClick={handleSaveClick} disabled={disableSave}> |
| | | {translate('common.action.save', { _: '保存' })} |
| | | </Button> |
| | | <Button variant="text" color="error" onClick={handleDeleteClick} disabled={!canDelete}> |
| | | {translate('common.action.delete', { _: '删除' })} |
| | | </Button> |
| | | </Box> |
| | | </Stack> |
| | | ); |