| | |
| | | DeleteButton, |
| | | Button |
| | | } from 'react-admin'; |
| | | import { Box, Typography, Card, Stack } from '@mui/material'; |
| | | import { Box, Typography, Card, Stack, Button as MuiButton } from '@mui/material'; |
| | | import { styled } from '@mui/material/styles'; |
| | | import DeviceSiteCreate from "./DeviceSiteCreate"; |
| | | import DeviceSitePanel from "./DeviceSitePanel"; |
| | |
| | | import * as Common from '@/utils/common'; |
| | | import InitModal from "./InitModal"; |
| | | import CabinIcon from '@mui/icons-material/Cabin'; |
| | | import ContentCopyIcon from '@mui/icons-material/ContentCopy'; |
| | | |
| | | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ |
| | | '& .css-1vooibu-MuiSvgIcon-root': { |
| | |
| | | '& .column-name': { |
| | | }, |
| | | '& .opt': { |
| | | width: 200 |
| | | width: 260, |
| | | minWidth: 260, |
| | | overflow: 'visible', |
| | | '& > *': { flexShrink: 0 } |
| | | }, |
| | | })); |
| | | |
| | |
| | | <TextInput source="device" label="table.field.deviceSite.device" />, |
| | | <TextInput source="deviceCode" label="table.field.deviceSite.deviceCode" />, |
| | | <TextInput source="deviceSite" label="table.field.deviceSite.deviceSite" />, |
| | | <NumberInput source="deviceSite" label="table.field.deviceSite.areaIdStart" />, |
| | | <NumberInput source="deviceSite" label="table.field.deviceSite.areaIdEnd" />, |
| | | |
| | | <TextInput label="common.field.memo" source="memo" />, |
| | | <SelectInput |
| | |
| | | />, |
| | | ] |
| | | |
| | | const CopyButton = ({ setInitCopyData, setInitDialogOpen }) => { |
| | | const record = useRecordContext(); |
| | | const translate = useTranslate(); |
| | | if (!record) return null; |
| | | const label = translate('toolbar.copy') || '复制'; |
| | | return ( |
| | | <MuiButton |
| | | size="small" |
| | | color="primary" |
| | | sx={{ |
| | | padding: '2px 8px', |
| | | fontSize: '.75rem', |
| | | minWidth: 'auto', |
| | | flexShrink: 0, |
| | | '& .MuiButton-startIcon': { marginRight: 0.5 }, |
| | | }} |
| | | startIcon={<ContentCopyIcon fontSize="small" />} |
| | | onClick={(e) => { |
| | | e.stopPropagation(); |
| | | setInitCopyData({ |
| | | rows: [{ |
| | | deviceSiteName: record.deviceSite ?? '', |
| | | siteName: record.site ?? '', |
| | | target: record.target ?? '', |
| | | }], |
| | | channel: record.channel != null ? String(record.channel) : '', |
| | | type: record.type, |
| | | typeIds: record.type != null ? [record.type] : [], |
| | | deviceType: record.device ?? '', |
| | | deviceCode: record.deviceCode ?? '', |
| | | areaIdStart: record.areaIdStart, |
| | | areaIdEnd: record.areaIdEnd, |
| | | name: record.name ?? '', |
| | | wcsCode: record.target ?? '', |
| | | label: record.label ?? '', |
| | | }); |
| | | setInitDialogOpen(true); |
| | | }} |
| | | > |
| | | <span style={{ whiteSpace: 'nowrap' }}>{label}</span> |
| | | </MuiButton> |
| | | ); |
| | | }; |
| | | |
| | | const DeviceSiteList = () => { |
| | | const translate = useTranslate(); |
| | | |
| | | const [createDialog, setCreateDialog] = useState(false); |
| | | const [drawerVal, setDrawerVal] = useState(false); |
| | | const [initDialog, setInitDialog] = useState(false); |
| | | const [initCopyData, setInitCopyData] = useState(null); |
| | | |
| | | return ( |
| | | <Box display="flex"> |
| | |
| | | mt: 2 |
| | | }} |
| | | onClick={() => { setInitDialog(true) }}> |
| | | {translate('toolbar.siteInit')} |
| | | {translate('toolbar.pathInit')} |
| | | </Button> |
| | | </Box> |
| | | } |
| | |
| | | actions={( |
| | | <TopToolbar> |
| | | <FilterButton /> |
| | | <InitButton /> |
| | | <MyCreateButton onClick={() => { setCreateDialog(true) }} /> |
| | | <InitButton /> |
| | | <SelectColumnsButton preferenceKey='deviceSite' /> |
| | | <MyExportButton /> |
| | | </TopToolbar> |
| | |
| | | preferenceKey='deviceSite' |
| | | bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} |
| | | rowClick={(id, resource, record) => false} |
| | | omit={['id', 'createTime', 'createBy', 'memo', 'label']} |
| | | omit={['id', 'createTime', 'createBy', 'memo', 'statusBool', 'updateBy']} |
| | | > |
| | | <NumberField source="id" /> |
| | | <TextField source="site" label="table.field.deviceSite.site" /> |
| | | <TextField source="name" label="table.field.deviceSite.name" /> |
| | | <NumberField source="type$" label="table.field.deviceSite.type" /> |
| | | <TextField source="site" label="table.field.deviceSite.site" /> |
| | | <TextField source="target" label="table.field.deviceSite.target" /> |
| | | <TextField source="label" label="table.field.deviceSite.label" /> |
| | | <TextField source="device$" label="table.field.deviceSite.device" /> |
| | | <TextField source="deviceCode" label="table.field.deviceSite.deviceCode" /> |
| | | <TextField source="channel" label="table.field.deviceSite.channel" /> |
| | | <TextField source="deviceSite" label="table.field.deviceSite.deviceSite" /> |
| | | <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | |
| | | <BooleanField source="statusBool" label="common.field.status" sortable={false} /> |
| | | <TextField source="memo" label="common.field.memo" sortable={false} /> |
| | | <WrapperField cellClassName="opt" label="common.field.opt"> |
| | | <CopyButton setInitCopyData={setInitCopyData} setInitDialogOpen={setInitDialog} /> |
| | | <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> |
| | | <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> |
| | | </WrapperField> |
| | |
| | | <InitModal |
| | | open={initDialog} |
| | | setOpen={setInitDialog} |
| | | initialData={initCopyData} |
| | | onClose={() => setInitCopyData(null)} |
| | | /> |
| | | </Box> |
| | | ) |
| | |
| | | |
| | | return ( |
| | | <> |
| | | <Button onClick={() => setCreateDialog(true)} label={"toolbar.siteInit"}> |
| | | <Button onClick={() => setCreateDialog(true)} label={"toolbar.pathInit"}> |
| | | <CabinIcon /> |
| | | </Button> |
| | | <InitModal |