| 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, | 
|     useRefresh, | 
|     Button | 
| } from 'react-admin'; | 
| import { Box, Typography, Card, Stack } from '@mui/material'; | 
| import { styled } from '@mui/material/styles'; | 
| import WarehouseAreasCreate from "./WarehouseAreasCreate"; | 
| import WarehouseAreasPanel from "./WarehouseAreasPanel"; | 
| import EmptyData from "../components/EmptyData"; | 
| import MyCreateButton from "../components/MyCreateButton"; | 
| import MyExportButton from '../components/MyExportButton'; | 
| import PageDrawer from "../components/PageDrawer"; | 
| import BatchModal from "./BatchModal"; | 
| import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; | 
| import * as Common from '@/utils/common'; | 
| import EditIcon from '@mui/icons-material/Edit'; | 
|   | 
| const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|     '& .css-1vooibu-MuiSvgIcon-root': { | 
|         height: '.9em' | 
|     }, | 
|     '& .RaDatagrid-row': { | 
|         cursor: 'auto' | 
|     }, | 
|     '& .column-name': { | 
|     }, | 
|     '& .opt': { | 
|         width: 200 | 
|     }, | 
|     '& .MuiTableCell-root': { | 
|         whiteSpace: 'nowrap', | 
|         overflow: 'visible', | 
|         textOverflow: 'unset' | 
|     } | 
| })); | 
|   | 
| const filters = [ | 
|     <SearchInput source="condition" alwaysOn />, | 
|     <ReferenceInput | 
|         source="warehouseId" | 
|         label="table.field.loc.warehouseId" | 
|         reference="warehouse" | 
|     > | 
|         <AutocompleteInput | 
|             label="table.field.loc.warehouseId" | 
|             optionText="name" | 
|             filterToQuery={(val) => ({ name: val })} | 
|         /> | 
|     </ReferenceInput>, | 
|     <TextInput source="uuid" label="table.field.warehouseAreas.uuid" />, | 
|     <TextInput source="name" label="table.field.warehouseAreas.name" />, | 
|     <TextInput source="code" label="table.field.warehouseAreas.code" />, | 
|     <ReferenceInput source="shipperId" label="table.field.warehouseAreas.shipperId" reference="shipper"> | 
|         <AutocompleteInput label="table.field.warehouseAreas.shipperId" optionText="name" filterToQuery={(val) => ({ name: val })} /> | 
|     </ReferenceInput>, | 
|     <NumberInput source="supplierId" label="table.field.warehouseAreas.supplierId" />, | 
|     <SelectInput source="flagMinus" label="table.field.warehouseAreas.flagMinus" | 
|         choices={[ | 
|             { id: 0, name: '否' }, | 
|             { id: 1, name: '是' }, | 
|         ]} | 
|     />, | 
|     <SelectInput source="flagLabelMange" label="table.field.warehouseAreas.flagLabelMange" | 
|         choices={[ | 
|             { id: 0, name: ' 否' }, | 
|             { id: 1, name: ' 是' }, | 
|         ]} | 
|     />, | 
|     <SelectInput source="flagMix" label="table.field.warehouseAreas.flagMix" | 
|         choices={[ | 
|             { id: 0, name: '否' }, | 
|             { id: 1, 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 WarehouseAreasList = () => { | 
|     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.warehouseAreas"} | 
|                 empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} | 
|                 filters={filters} | 
|                 sort={{ field: "warehouseId", order: "desc" }} | 
|                 actions={( | 
|                     <TopToolbar> | 
|                         <FilterButton /> | 
|                         <MyCreateButton onClick={() => { setCreateDialog(true) }} /> | 
|                         <SelectColumnsButton preferenceKey='warehouseAreas' /> | 
|                         <MyExportButton /> | 
|                     </TopToolbar> | 
|                 )} | 
|                 perPage={DEFAULT_PAGE_SIZE} | 
|             >  | 
|              | 
|   | 
|              | 
|                 <StyledDatagrid                                     | 
|                     preferenceKey='warehouseAreas' | 
|                     bulkActionButtons={ | 
|                         <> | 
|                             {/* <WareButton /> | 
|                             <MixButton /> | 
|                             <StatusButton /> */} | 
|                             <BulkDeleteButton mutationMode={OPERATE_MODE} /> | 
|                         </> | 
|                     } | 
|                     rowClick={(id, resource, record) => false} | 
|                     omit={['id', 'createTime', 'createBy', 'memo','statusBool','flagMix$','flagLabelMange$','shipperId$','supplierId']} | 
|                 > | 
|                     <NumberField source="id" /> | 
|                     {/* <TextField source="uuid" label="table.field.warehouseAreas.uuid" /> */} | 
|                     <TextField source="code" label="table.field.warehouseAreas.code" /> | 
|                     <TextField source="name" label="table.field.warehouseAreas.name" /> | 
|                     | 
|                     <TextField source="type$" label="table.field.warehouseAreas.type"/> | 
|                     {/* <ReferenceField source="shipperId" label="table.field.warehouseAreas.shipperId" reference="shipper" link={false} sortable={false}> | 
|                         <TextField source="name" /> | 
|                     </ReferenceField> */} | 
|                     <TextField source="warehouseId$" label="table.field.warehouseAreas.wareId" /> | 
|                     <TextField source="shipperId$" label="table.field.warehouseAreas.shipperId" /> | 
|                     <NumberField source="supplierId" label="table.field.warehouseAreas.supplierId" /> | 
|                     <TextField source="flagMinus$" label="table.field.warehouseAreas.flagMinus" sortable={false} /> | 
|                     <TextField source="flagLabelMange$" label="table.field.warehouseAreas.flagLabelMange" sortable={false} /> | 
|                     <TextField source="flagMix$" label="table.field.warehouseAreas.flagMix" 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> | 
|             <WarehouseAreasCreate | 
|                 open={createDialog} | 
|                 setOpen={setCreateDialog} | 
|             /> | 
|             <PageDrawer | 
|                 title='WarehouseAreas Detail' | 
|                 drawerVal={drawerVal} | 
|                 setDrawerVal={setDrawerVal} | 
|             > | 
|             </PageDrawer> | 
|         </Box> | 
|     ) | 
| } | 
|   | 
| export default WarehouseAreasList; | 
|   | 
|   | 
| const MixButton = () => { | 
|     const record = useRecordContext(); | 
|     const notify = useNotify(); | 
|     const refresh = useRefresh(); | 
|   | 
|   | 
|     const [createDialog, setCreateDialog] = useState(false); | 
|   | 
|     return ( | 
|         <> | 
|             <Button onClick={() => setCreateDialog(true)} label={"toolbar.batchMix"}> | 
|                 <EditIcon /> | 
|             </Button> | 
|   | 
|             <BatchModal | 
|                 open={createDialog} | 
|                 setOpen={setCreateDialog} | 
|                 fieldType={'flagMix'} | 
|             /> | 
|         </> | 
|   | 
|     ) | 
| } | 
|   | 
| const WareButton = () => { | 
|     const record = useRecordContext(); | 
|     const notify = useNotify(); | 
|     const refresh = useRefresh(); | 
|   | 
|   | 
|     const [createDialog, setCreateDialog] = useState(false); | 
|   | 
|     return ( | 
|         <> | 
|             <Button onClick={() => setCreateDialog(true)} label={"toolbar.batchWarehouse"}> | 
|                 <EditIcon /> | 
|             </Button> | 
|   | 
|             <BatchModal | 
|                 open={createDialog} | 
|                 setOpen={setCreateDialog} | 
|                 fieldType={'wareId'} | 
|             /> | 
|         </> | 
|   | 
|     ) | 
| } | 
|   | 
| const StatusButton = () => { | 
|     const record = useRecordContext(); | 
|     const notify = useNotify(); | 
|     const refresh = useRefresh(); | 
|   | 
|   | 
|     const [createDialog, setCreateDialog] = useState(false); | 
|   | 
|     return ( | 
|         <> | 
|             <Button onClick={() => setCreateDialog(true)} label={"toolbar.batchStatus"}> | 
|                 <EditIcon /> | 
|             </Button> | 
|   | 
|             <BatchModal | 
|                 open={createDialog} | 
|                 setOpen={setCreateDialog} | 
|                 fieldType={'status'} | 
|             /> | 
|         </> | 
|   | 
|     ) | 
| } |