| import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; | 
| import { useNavigate } from 'react-router-dom'; | 
| import { | 
|     List, | 
|     DatagridConfigurable, | 
|     SearchInput, | 
|     TopToolbar, | 
|     SelectColumnsButton, | 
|     EditButton, | 
|     FilterButton, | 
|     CreateButton, | 
|     ExportButton, | 
|     BulkDeleteButton, | 
|     WrapperField, | 
|     useRecordContext, | 
|     useTranslate, | 
|     useNotify, | 
|     useListContext, | 
|     FunctionField, | 
|     TextField, | 
|     NumberField, | 
|     DateField, | 
|     BooleanField, | 
|     ReferenceField, | 
|     TextInput, | 
|     DateTimeInput, | 
|     DateInput, | 
|     SelectInput, | 
|     NumberInput, | 
|     ReferenceInput, | 
|     ReferenceArrayInput, | 
|     AutocompleteInput, | 
|     DeleteButton, | 
|     Button | 
| } from 'react-admin'; | 
| import { Box, Typography, Card, Stack } from '@mui/material'; | 
| import { styled } from '@mui/material/styles'; | 
| import DeviceSiteCreate from "./DeviceSiteCreate"; | 
| import DeviceSitePanel from "./DeviceSitePanel"; | 
| import EmptyData from "../../components/EmptyData"; | 
| import MyCreateButton from "../../components/MyCreateButton"; | 
| import MyExportButton from '../../components/MyExportButton'; | 
| import PageDrawer from "../../components/PageDrawer"; | 
| import MyField from "../../components/MyField"; | 
| import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; | 
| import * as Common from '@/utils/common'; | 
| import InitModal from "./InitModal"; | 
| import CabinIcon from '@mui/icons-material/Cabin'; | 
|   | 
| const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|     '& .css-1vooibu-MuiSvgIcon-root': { | 
|         height: '.9em' | 
|     }, | 
|     '& .RaDatagrid-row': { | 
|         cursor: 'auto' | 
|     }, | 
|     '& .column-name': { | 
|     }, | 
|     '& .opt': { | 
|         width: 200 | 
|     }, | 
| })); | 
|   | 
| const filters = [ | 
|     <SearchInput source="condition" alwaysOn />, | 
|   | 
|     <NumberInput source="type" label="table.field.deviceSite.type" />, | 
|     <TextInput source="site" label="table.field.deviceSite.site" />, | 
|     <TextInput source="name" label="table.field.deviceSite.name" />, | 
|     <TextInput source="wcsCode" label="table.field.deviceSite.wcsCode" />, | 
|     <TextInput source="label" label="table.field.deviceSite.label" />, | 
|     <TextInput source="device" label="table.field.deviceSite.device" />, | 
|     <TextInput source="deviceCode" label="table.field.deviceSite.deviceCode" />, | 
|     <TextInput source="deviceSite" label="table.field.deviceSite.deviceSite" />, | 
|   | 
|     <TextInput label="common.field.memo" source="memo" />, | 
|     <SelectInput | 
|         label="common.field.status" | 
|         source="status" | 
|         choices={[ | 
|             { id: '1', name: 'common.enums.statusTrue' }, | 
|             { id: '0', name: 'common.enums.statusFalse' }, | 
|         ]} | 
|         resettable | 
|     />, | 
| ] | 
|   | 
| const DeviceSiteList = () => { | 
|     const translate = useTranslate(); | 
|   | 
|     const [createDialog, setCreateDialog] = useState(false); | 
|     const [drawerVal, setDrawerVal] = useState(false); | 
|     const [initDialog, setInitDialog] = useState(false); | 
|   | 
|     return ( | 
|         <Box display="flex"> | 
|             <List | 
|                 sx={{ | 
|                     flexGrow: 1, | 
|                     transition: (theme) => | 
|                         theme.transitions.create(['all'], { | 
|                             duration: theme.transitions.duration.enteringScreen, | 
|                         }), | 
|                     marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, | 
|                 }} | 
|                 title={"menu.deviceSite"} | 
|                 empty={<EmptyData | 
|                     children={ | 
|                         <Box sx={{ gap: 2, display: 'flex' }}> | 
|                             <Button | 
|                                 variant="contained" | 
|                                 color="primary" | 
|                                 sx={{ | 
|                                     fontSize: '1em', | 
|                                     mt: 2 | 
|                                 }} | 
|                                 onClick={() => { setCreateDialog(true) }}> | 
|                                 {translate('create.empty.button')} | 
|                             </Button> | 
|   | 
|                             <Button | 
|                                 variant="contained" | 
|                                 color="primary" | 
|                                 sx={{ | 
|                                     fontSize: '1em', | 
|                                     mt: 2 | 
|                                 }} | 
|                                 onClick={() => { setInitDialog(true) }}> | 
|                                 {translate('toolbar.siteInit')} | 
|                             </Button> | 
|                         </Box> | 
|                     } | 
|                     onClick={() => { }} />} | 
|                 filters={filters} | 
|                 sort={{ field: "create_time", order: "desc" }} | 
|                 actions={( | 
|                     <TopToolbar> | 
|                         <FilterButton /> | 
|                         <InitButton />                         | 
|                         <SelectColumnsButton preferenceKey='deviceSite' /> | 
|                         <MyExportButton /> | 
|                     </TopToolbar> | 
|                 )} | 
|                 perPage={DEFAULT_PAGE_SIZE} | 
|             > | 
|                 <StyledDatagrid | 
|                     preferenceKey='deviceSite' | 
|                     bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} | 
|                     rowClick={(id, resource, record) => false} | 
|                     omit={['id', 'createTime', 'createBy', 'memo', 'label','name','target','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="target" label="table.field.deviceSite.target" /> | 
|                     <TextField source="label" label="table.field.deviceSite.label" /> | 
|                     <TextField source="device$" label="table.field.deviceSite.device" /> | 
|                     <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" /> | 
|                     </ReferenceField> | 
|                     <DateField source="updateTime" label="common.field.updateTime" showTime /> | 
|                     <ReferenceField source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false}> | 
|                         <TextField source="nickname" /> | 
|                     </ReferenceField> | 
|                     <DateField source="createTime" label="common.field.createTime" showTime /> | 
|                     <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"> | 
|                         <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> | 
|                         <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> | 
|                     </WrapperField> | 
|                 </StyledDatagrid> | 
|             </List> | 
|             <DeviceSiteCreate | 
|                 open={createDialog} | 
|                 setOpen={setCreateDialog} | 
|             /> | 
|             <PageDrawer | 
|                 title='DeviceSite Detail' | 
|                 drawerVal={drawerVal} | 
|                 setDrawerVal={setDrawerVal} | 
|             > | 
|             </PageDrawer> | 
|   | 
|             <InitModal | 
|                 open={initDialog} | 
|                 setOpen={setInitDialog} | 
|             /> | 
|         </Box> | 
|     ) | 
| } | 
|   | 
| export default DeviceSiteList; | 
|   | 
| const InitButton = () => { | 
|     const record = useRecordContext(); | 
|     const notify = useNotify(); | 
|   | 
|     const [createDialog, setCreateDialog] = useState(false); | 
|   | 
|     return ( | 
|         <> | 
|             <Button onClick={() => setCreateDialog(true)} label={"toolbar.siteInit"}> | 
|                 <CabinIcon /> | 
|             </Button> | 
|             <InitModal | 
|                 open={createDialog} | 
|                 setOpen={setCreateDialog} | 
|             /> | 
|         </> | 
|   | 
|     ) | 
| } |