| New file | 
 |  |  | 
 |  |  | 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, | 
 |  |  | } from 'react-admin'; | 
 |  |  | import { Box, Typography, Card, Stack } from '@mui/material'; | 
 |  |  | import { styled } from '@mui/material/styles'; | 
 |  |  | import StockItemCreate from "./StockItemCreate"; | 
 |  |  | import StockItemPanel from "./StockItemPanel"; | 
 |  |  | 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'; | 
 |  |  |  | 
 |  |  | 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 />, | 
 |  |  |     <DateInput label='common.time.after' source="timeStart" alwaysOn />, | 
 |  |  |     <DateInput label='common.time.before' source="timeEnd" alwaysOn />, | 
 |  |  |  | 
 |  |  |     <NumberInput source="stockId" label="table.field.stockItem.stockId" />, | 
 |  |  |     <TextInput source="stockCode" label="table.field.stockItem.stockCode" />, | 
 |  |  |     <NumberInput source="sourceItemId" label="table.field.stockItem.sourceItemId" />, | 
 |  |  |     <NumberInput source="matnrId" label="table.field.stockItem.matnrId" />, | 
 |  |  |     <TextInput source="matnrCode" label="table.field.stockItem.matnrCode" />, | 
 |  |  |     <TextInput source="maktx" label="table.field.stockItem.maktx" />, | 
 |  |  |     <NumberInput source="anfme" label="table.field.stockItem.anfme" />, | 
 |  |  |     <TextInput source="stockUnit" label="table.field.stockItem.stockUnit" />, | 
 |  |  |     <NumberInput source="workQty" label="table.field.stockItem.workQty" />, | 
 |  |  |     <NumberInput source="purQty" label="table.field.stockItem.purQty" />, | 
 |  |  |     <TextInput source="purUnit" label="table.field.stockItem.purUnit" />, | 
 |  |  |     <NumberInput source="qty" label="table.field.stockItem.qty" />, | 
 |  |  |     <TextInput source="splrCode" label="table.field.stockItem.splrCode" />, | 
 |  |  |     <TextInput source="batch" label="table.field.stockItem.batch" />, | 
 |  |  |     <TextInput source="splrBatch" label="table.field.stockItem.splrBatch" />, | 
 |  |  |     <TextInput source="splrName" label="table.field.stockItem.splrName" />, | 
 |  |  |     <TextInput source="trackCode" label="table.field.stockItem.trackCode" />, | 
 |  |  |     <TextInput source="barcode" label="table.field.stockItem.barcode" />, | 
 |  |  |     <TextInput source="prodTime" label="table.field.stockItem.prodTime" />, | 
 |  |  |     <TextInput source="packName" label="table.field.stockItem.packName" />, | 
 |  |  |  | 
 |  |  |     <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 StockItemList = () => { | 
 |  |  |     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.stockItem"} | 
 |  |  |                 empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} | 
 |  |  |                 filters={filters} | 
 |  |  |                 sort={{ field: "create_time", order: "desc" }} | 
 |  |  |                 actions={( | 
 |  |  |                     <TopToolbar> | 
 |  |  |                         <FilterButton /> | 
 |  |  |                         <MyCreateButton onClick={() => { setCreateDialog(true) }} /> | 
 |  |  |                         <SelectColumnsButton preferenceKey='stockItem' /> | 
 |  |  |                         <MyExportButton /> | 
 |  |  |                     </TopToolbar> | 
 |  |  |                 )} | 
 |  |  |                 perPage={DEFAULT_PAGE_SIZE} | 
 |  |  |             > | 
 |  |  |                 <StyledDatagrid | 
 |  |  |                     preferenceKey='stockItem' | 
 |  |  |                     bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} | 
 |  |  |                     rowClick={(id, resource, record) => false} | 
 |  |  |                     expand={() => <StockItemPanel />} | 
 |  |  |                     expandSingle={true} | 
 |  |  |                     omit={['id', 'createTime', 'createBy', 'memo']} | 
 |  |  |                 > | 
 |  |  |                     <NumberField source="id" /> | 
 |  |  |                     <NumberField source="stockId" label="table.field.stockItem.stockId" /> | 
 |  |  |                     <TextField source="stockCode" label="table.field.stockItem.stockCode" /> | 
 |  |  |                     <NumberField source="sourceItemId" label="table.field.stockItem.sourceItemId" /> | 
 |  |  |                     <NumberField source="matnrId" label="table.field.stockItem.matnrId" /> | 
 |  |  |                     <TextField source="matnrCode" label="table.field.stockItem.matnrCode" /> | 
 |  |  |                     <TextField source="maktx" label="table.field.stockItem.maktx" /> | 
 |  |  |                     <NumberField source="anfme" label="table.field.stockItem.anfme" /> | 
 |  |  |                     <TextField source="stockUnit" label="table.field.stockItem.stockUnit" /> | 
 |  |  |                     <NumberField source="workQty" label="table.field.stockItem.workQty" /> | 
 |  |  |                     <NumberField source="purQty" label="table.field.stockItem.purQty" /> | 
 |  |  |                     <TextField source="purUnit" label="table.field.stockItem.purUnit" /> | 
 |  |  |                     <NumberField source="qty" label="table.field.stockItem.qty" /> | 
 |  |  |                     <TextField source="splrCode" label="table.field.stockItem.splrCode" /> | 
 |  |  |                     <TextField source="batch" label="table.field.stockItem.batch" /> | 
 |  |  |                     <TextField source="splrBatch" label="table.field.stockItem.splrBatch" /> | 
 |  |  |                     <TextField source="splrName" label="table.field.stockItem.splrName" /> | 
 |  |  |                     <TextField source="trackCode" label="table.field.stockItem.trackCode" /> | 
 |  |  |                     <TextField source="barcode" label="table.field.stockItem.barcode" /> | 
 |  |  |                     <TextField source="prodTime" label="table.field.stockItem.prodTime" /> | 
 |  |  |                     <TextField source="packName" label="table.field.stockItem.packName" /> | 
 |  |  |  | 
 |  |  |                     <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> | 
 |  |  |             <StockItemCreate | 
 |  |  |                 open={createDialog} | 
 |  |  |                 setOpen={setCreateDialog} | 
 |  |  |             /> | 
 |  |  |             <PageDrawer | 
 |  |  |                 title='StockItem Detail' | 
 |  |  |                 drawerVal={drawerVal} | 
 |  |  |                 setDrawerVal={setDrawerVal} | 
 |  |  |             > | 
 |  |  |             </PageDrawer> | 
 |  |  |         </Box> | 
 |  |  |     ) | 
 |  |  | } | 
 |  |  |  | 
 |  |  | export default StockItemList; |