| | |
| | | import React from 'react'; |
| | | import React, { useMemo } from 'react'; |
| | | import { |
| | | Stack, |
| | | TextField, |
| | |
| | | codeList, |
| | | onSave, |
| | | disableSave, |
| | | onDelete, |
| | | canDelete = false, |
| | | }) => { |
| | | const translate = useTranslate(); |
| | | const icon = <CheckBoxOutlineBlankIcon fontSize="small" />; |
| | |
| | | |
| | | 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 ( |
| | |
| | | </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> |
| | | ); |