| 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 ContainerCreate from "./ContainerCreate"; | 
| import ContainerPanel from "./ContainerPanel"; | 
| 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 AllInclusiveIcon from '@mui/icons-material/AllInclusive'; | 
|   | 
| 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 />, | 
|   | 
|     <TextInput source="code" label="table.field.container.code" />, | 
|     <TextInput source="name" label="table.field.container.name" />, | 
|     <NumberInput source="typeId" label="table.field.container.typeId" />, | 
|     <NumberInput source="used" label="table.field.container.used" />, | 
|     <NumberInput source="lenght" label="table.field.container.lenght" />, | 
|     <NumberInput source="width" label="table.field.container.width" />, | 
|     <NumberInput source="height" label="table.field.container.height" />, | 
|     <NumberInput source="rstLen" label="table.field.container.rstLen" />, | 
|     <NumberInput source="rstWid" label="table.field.container.rstWid" />, | 
|     <NumberInput source="rstWei" label="table.field.container.rstWei" />, | 
|     <NumberInput source="rstHei" label="table.field.container.rstHei" />, | 
|     <NumberInput source="panrentId" label="table.field.container.panrentId" />, | 
|     <DateInput source="vaildTime" label="table.field.container.vaildTime" />, | 
|     <SelectInput source="flagRycle" label="table.field.container.flagRycle" | 
|         choices={[ | 
|             { id: 1, name: '是' }, | 
|             { id: 0, name: '否' }, | 
|         ]} | 
|     />, | 
|     <SelectInput source="flagLogic" label="table.field.container.flagLogic" | 
|         choices={[ | 
|             { id: 1, name: '是' }, | 
|             { id: 0, name: '否' }, | 
|         ]} | 
|     />, | 
|   | 
|     <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 ContainerList = () => { | 
|     const translate = useTranslate(); | 
|   | 
|     const [createDialog, setCreateDialog] = useState(false); | 
|     const [drawerVal, setDrawerVal] = 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.container"} | 
|                 empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} | 
|                 filters={filters} | 
|                 sort={{ field: "create_time", order: "desc" }} | 
|                 actions={( | 
|                     <TopToolbar> | 
|                         <InitButton /> | 
|                         <FilterButton /> | 
|                         <MyCreateButton onClick={() => { setCreateDialog(true) }} /> | 
|                         <SelectColumnsButton preferenceKey='container' /> | 
|                         <MyExportButton /> | 
|                     </TopToolbar> | 
|                 )} | 
|                 perPage={DEFAULT_PAGE_SIZE} | 
|             > | 
|                 <StyledDatagrid | 
|                     preferenceKey='container' | 
|                     bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} | 
|                     rowClick={(id, resource, record) => false} | 
|                     omit={['id', 'createTime', 'createBy', 'memo','statusBool','updateBy']} | 
|                 > | 
|                     <NumberField source="id" /> | 
|                     {/* <TextField source="code" label="table.field.container.code" /> */} | 
|                     <TextField source="name" label="table.field.container.name" /> | 
|                     <NumberField source="type" label="table.field.container.typeId" /> | 
|                     <NumberField source="used" label="table.field.container.used" /> | 
|                     <NumberField source="length" label="table.field.container.lenght" /> | 
|                     <NumberField source="width" label="table.field.container.width" /> | 
|                     <NumberField source="height" label="table.field.container.height" /> | 
|                     <NumberField source="rstLen" label="table.field.container.rstLen" /> | 
|                     <NumberField source="rstWid" label="table.field.container.rstWid" /> | 
|                     <NumberField source="rstWei" label="table.field.container.rstWei" /> | 
|                     <NumberField source="rstHei" label="table.field.container.rstHei" /> | 
|                     <NumberField source="panrentId" label="table.field.container.panrentId" /> | 
|                     <DateField source="vaildTime" label="table.field.container.vaildTime" showTime /> | 
|                     <TextField source="flagRycle$" label="table.field.container.flagRycle" sortable={false} /> | 
|                     <TextField source="flagLogic$" label="table.field.container.flagLogic" sortable={false} /> | 
|   | 
|                     <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> | 
|             <ContainerCreate | 
|                 open={createDialog} | 
|                 setOpen={setCreateDialog} | 
|             /> | 
|             <PageDrawer | 
|                 title='Container Detail' | 
|                 drawerVal={drawerVal} | 
|                 setDrawerVal={setDrawerVal} | 
|             > | 
|             </PageDrawer> | 
|         </Box> | 
|     ) | 
| } | 
|   | 
| //初始化按钮 | 
| const InitButton = ({ setOpen }) => { | 
|     const close = () => { | 
|         setOpen(false) | 
|     } | 
|     return ( | 
|         <Button | 
|             label="toolbar.init" | 
|             variant="outlined" | 
|             size="medium" | 
|             onClick={close} | 
|             startIcon={<AllInclusiveIcon />} | 
|             sx={{ margin: '3.5em' }} /> | 
|     ) | 
| } | 
|   | 
|   | 
|   | 
| export default ContainerList; |