|  |  |  | 
|---|
|  |  |  | ReferenceArrayInput, | 
|---|
|  |  |  | AutocompleteInput, | 
|---|
|  |  |  | DeleteButton, | 
|---|
|  |  |  | Button, | 
|---|
|  |  |  | } from 'react-admin'; | 
|---|
|  |  |  | import { Box, Typography, Card, Stack } from '@mui/material'; | 
|---|
|  |  |  | import { styled } from '@mui/material/styles'; | 
|---|
|  |  |  | 
|---|
|  |  |  | 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 CrossZoneAreaField from "../basStation/CrossZoneAreaField"; | 
|---|
|  |  |  | import AllInclusiveIcon from '@mui/icons-material/AllInclusive'; | 
|---|
|  |  |  | import BasContainerInit from "./BasContainerInit"; | 
|---|
|  |  |  | import PrintModal from './PrintModal' | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|---|
|  |  |  | '& .css-1vooibu-MuiSvgIcon-root': { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const filters = [ | 
|---|
|  |  |  | <SearchInput source="condition" alwaysOn />, | 
|---|
|  |  |  | <DateInput label='common.time.after' source="timeStart" alwaysOn />, | 
|---|
|  |  |  | <DateInput label='common.time.before' source="timeEnd" alwaysOn />, | 
|---|
|  |  |  | <DateInput label='common.time.after' source="timeStart" />, | 
|---|
|  |  |  | <DateInput label='common.time.before' source="timeEnd" />, | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <NumberInput source="containerType" label="table.field.basContainer.containerType" />, | 
|---|
|  |  |  | <TextInput source="codeType" label="table.field.basContainer.codeType" />, | 
|---|
|  |  |  | 
|---|
|  |  |  | const [areaFieldDialog, setAreaFieldDialog] = useState(false); | 
|---|
|  |  |  | const [createDialog, setCreateDialog] = useState(false); | 
|---|
|  |  |  | const [drawerVal, setDrawerVal] = useState(false); | 
|---|
|  |  |  | const [open, setOpen] = useState(false); | 
|---|
|  |  |  | const [print, setPrint] = useState(false); | 
|---|
|  |  |  | const [selectPrints, setSelectPrints] = useState([]); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Box display="flex"> | 
|---|
|  |  |  | 
|---|
|  |  |  | marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, | 
|---|
|  |  |  | }} | 
|---|
|  |  |  | title={"menu.basContainer"} | 
|---|
|  |  |  | empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} | 
|---|
|  |  |  | empty={false} | 
|---|
|  |  |  | filters={filters} | 
|---|
|  |  |  | sort={{ field: "create_time", order: "desc" }} | 
|---|
|  |  |  | actions={( | 
|---|
|  |  |  | <TopToolbar> | 
|---|
|  |  |  | <InitButton setOpen={setOpen} /> | 
|---|
|  |  |  | <FilterButton /> | 
|---|
|  |  |  | <MyCreateButton onClick={() => { setCreateDialog(true) }} /> | 
|---|
|  |  |  | <SelectColumnsButton preferenceKey='basContainer' /> | 
|---|
|  |  |  | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <StyledDatagrid | 
|---|
|  |  |  | preferenceKey='basContainer' | 
|---|
|  |  |  | bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} | 
|---|
|  |  |  | rowClick={(id, resource, record) => false} | 
|---|
|  |  |  | bulkActionButtons={<> | 
|---|
|  |  |  | <BulkPrintBarcode setPrint={setPrint} setSelectPrints={setSelectPrints} /> | 
|---|
|  |  |  | <BulkDeleteButton mutationMode={OPERATE_MODE} /> | 
|---|
|  |  |  | </>} | 
|---|
|  |  |  | rowClick={(id, resource, record) => false} | 
|---|
|  |  |  | expandSingle={true} | 
|---|
|  |  |  | omit={['id', 'createTime', 'createBy', 'memo']} | 
|---|
|  |  |  | omit={['id', 'statusBool']} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <NumberField source="id" /> | 
|---|
|  |  |  | <NumberField source="containerType$" label="table.field.basContainer.containerType" /> | 
|---|
|  |  |  | <TextField source="code" label="table.field.basContainer.code" /> | 
|---|
|  |  |  | <TextField source="codeType" label="table.field.basContainer.codeType" /> | 
|---|
|  |  |  | <WrapperField cellClassName="areas" label="table.field.basContainer.areas"> | 
|---|
|  |  |  | <CrossZoneAreaField | 
|---|
|  |  |  | open={areaFieldDialog} | 
|---|
|  |  |  | setOpen={setAreaFieldDialog} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | </WrapperField> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> | 
|---|
|  |  |  | <TextField source="nickname" /> | 
|---|
|  |  |  | </ReferenceField> | 
|---|
|  |  |  | 
|---|
|  |  |  | open={createDialog} | 
|---|
|  |  |  | setOpen={setCreateDialog} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <BasContainerInit | 
|---|
|  |  |  | open={open} | 
|---|
|  |  |  | setOpen={setOpen} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <PrintModal | 
|---|
|  |  |  | open={print} | 
|---|
|  |  |  | setOpen={setPrint} | 
|---|
|  |  |  | rows={selectPrints} | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | <PageDrawer | 
|---|
|  |  |  | title='BasContainer Detail' | 
|---|
|  |  |  | drawerVal={drawerVal} | 
|---|
|  |  |  | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //初始化按钮 | 
|---|
|  |  |  | const InitButton = ({ setOpen }) => { | 
|---|
|  |  |  | const init = () => { | 
|---|
|  |  |  | setOpen(true) | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Button | 
|---|
|  |  |  | label="toolbar.init" | 
|---|
|  |  |  | variant="text" | 
|---|
|  |  |  | size="small" | 
|---|
|  |  |  | onClick={init} | 
|---|
|  |  |  | startIcon={<AllInclusiveIcon />} /> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const BulkPrintBarcode = ({ setPrint, setSelectPrints }) => { | 
|---|
|  |  |  | const { selectedIds } = useListContext(); | 
|---|
|  |  |  | //打印 | 
|---|
|  |  |  | const print = () => { | 
|---|
|  |  |  | setPrint(true); | 
|---|
|  |  |  | setSelectPrints(selectedIds); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Button | 
|---|
|  |  |  | label="toolbar.print" | 
|---|
|  |  |  | variant="text" | 
|---|
|  |  |  | size="small" | 
|---|
|  |  |  | onClick={print} | 
|---|
|  |  |  | startIcon={<AllInclusiveIcon />} /> | 
|---|
|  |  |  | ) | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | export default BasContainerList; | 
|---|