|  |  | 
 |  |  | import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; | 
 |  |  | import { useNavigate } from 'react-router-dom'; | 
 |  |  | import { useNavigate, useLocation } 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, | 
 |  |  |   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 MyField from "../components/MyField"; | 
 |  |  | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; | 
 |  |  | import * as Common from '@/utils/common'; | 
 |  |  | import CustomerTopToolBar from "../components/EditTopToolBar"; | 
 |  |  |  | 
 |  |  | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
 |  |  |     '& .css-1vooibu-MuiSvgIcon-root': { | 
 |  |  |         height: '.9em' | 
 |  |  |     }, | 
 |  |  |     '& .RaDatagrid-row': { | 
 |  |  |         cursor: 'auto' | 
 |  |  |     }, | 
 |  |  |     '& .column-name': { | 
 |  |  |     }, | 
 |  |  |     '& .opt': { | 
 |  |  |         width: 200 | 
 |  |  |     }, | 
 |  |  |   '& .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 />, | 
 |  |  |   <SearchInput source="condition" alwaysOn />, | 
 |  |  |  | 
 |  |  |     <NumberInput source="purchaseId" label="table.field.purchaseItem.purchaseId" />, | 
 |  |  |     <TextInput source="platItemId" label="table.field.purchaseItem.platItemId" />, | 
 |  |  |     <TextInput source="matnrCode" label="table.field.purchaseItem.matnrCode" />, | 
 |  |  |     <TextInput source="matnrName" label="table.field.purchaseItem.matnrName" />, | 
 |  |  |     <TextInput source="unit" label="table.field.purchaseItem.unit" />, | 
 |  |  |     <NumberInput source="anfme" label="table.field.purchaseItem.anfme" />, | 
 |  |  |     <NumberInput source="qty" label="table.field.purchaseItem.qty" />, | 
 |  |  |     <NumberInput source="nromQty" label="table.field.purchaseItem.nromQty" />, | 
 |  |  |     <NumberInput source="asnQty" label="table.field.purchaseItem.asnQty" />, | 
 |  |  |     <NumberInput source="printQty" label="table.field.purchaseItem.printQty" />, | 
 |  |  |     <TextInput source="splrName" label="table.field.purchaseItem.splrName" />, | 
 |  |  |     <TextInput source="splrCode" label="table.field.purchaseItem.splrCode" />, | 
 |  |  |     <TextInput source="splrBatch" label="table.field.purchaseItem.splrBatch" />, | 
 |  |  |   <NumberInput source="purchaseId" label="table.field.purchaseItem.purchaseId" />, | 
 |  |  |   <TextInput source="platItemId" label="table.field.purchaseItem.platItemId" />, | 
 |  |  |   <TextInput source="matnrCode" label="table.field.purchaseItem.matnrCode" />, | 
 |  |  |   <TextInput source="matnrName" label="table.field.purchaseItem.matnrName" />, | 
 |  |  |   <TextInput source="unit" label="table.field.purchaseItem.unit" />, | 
 |  |  |   <NumberInput source="anfme" label="table.field.purchaseItem.anfme" />, | 
 |  |  |   <NumberInput source="qty" label="table.field.purchaseItem.qty" />, | 
 |  |  |   <NumberInput source="nromQty" label="table.field.purchaseItem.nromQty" />, | 
 |  |  |   <NumberInput source="asnQty" label="table.field.purchaseItem.asnQty" />, | 
 |  |  |   <NumberInput source="printQty" label="table.field.purchaseItem.printQty" />, | 
 |  |  |   <TextInput source="splrName" label="table.field.purchaseItem.splrName" />, | 
 |  |  |   <TextInput source="splrCode" label="table.field.purchaseItem.splrCode" />, | 
 |  |  |   <TextInput source="splrBatch" label="table.field.purchaseItem.splrBatch" />, | 
 |  |  |  | 
 |  |  |     <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 | 
 |  |  |     />, | 
 |  |  |   <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 PurchaseItemList = () => { | 
 |  |  |     const translate = useTranslate(); | 
 |  |  |   const translate = useTranslate(); | 
 |  |  |  | 
 |  |  |     const [createDialog, setCreateDialog] = useState(false); | 
 |  |  |     const [drawerVal, setDrawerVal] = useState(false); | 
 |  |  |   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.purchaseItem"} | 
 |  |  |                 empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} | 
 |  |  |                 filters={filters} | 
 |  |  |                 sort={{ field: "create_time", order: "desc" }} | 
 |  |  |                 actions={( | 
 |  |  |                     <TopToolbar> | 
 |  |  |                         <FilterButton /> | 
 |  |  |                         <MyCreateButton onClick={() => { setCreateDialog(true) }} /> | 
 |  |  |                         <SelectColumnsButton preferenceKey='purchaseItem' /> | 
 |  |  |                         <MyExportButton /> | 
 |  |  |                     </TopToolbar> | 
 |  |  |                 )} | 
 |  |  |                 perPage={DEFAULT_PAGE_SIZE} | 
 |  |  |             > | 
 |  |  |                 <StyledDatagrid | 
 |  |  |                     preferenceKey='purchaseItem' | 
 |  |  |                     bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} | 
 |  |  |                     rowClick={(id, resource, record) => false} | 
 |  |  |                     expand={() => <PurchaseItemPanel />} | 
 |  |  |                     expandSingle={true} | 
 |  |  |                     omit={['id', 'createTime', 'createBy', 'memo']} | 
 |  |  |                 > | 
 |  |  |                     <NumberField source="id" /> | 
 |  |  |                     <NumberField source="purchaseId" label="table.field.purchaseItem.purchaseId" /> | 
 |  |  |                     <TextField source="platItemId" label="table.field.purchaseItem.platItemId" /> | 
 |  |  |                     <TextField source="matnrCode" label="table.field.purchaseItem.matnrCode" /> | 
 |  |  |                     <TextField source="matnrName" label="table.field.purchaseItem.matnrName" /> | 
 |  |  |                     <TextField source="unit" label="table.field.purchaseItem.unit" /> | 
 |  |  |                     <NumberField source="anfme" label="table.field.purchaseItem.anfme" /> | 
 |  |  |                     <NumberField source="qty" label="table.field.purchaseItem.qty" /> | 
 |  |  |                     <NumberField source="nromQty" label="table.field.purchaseItem.nromQty" /> | 
 |  |  |                     <NumberField source="asnQty" label="table.field.purchaseItem.asnQty" /> | 
 |  |  |                     <NumberField source="printQty" label="table.field.purchaseItem.printQty" /> | 
 |  |  |                     <TextField source="splrName" label="table.field.purchaseItem.splrName" /> | 
 |  |  |                     <TextField source="splrCode" label="table.field.purchaseItem.splrCode" /> | 
 |  |  |                     <TextField source="splrBatch" label="table.field.purchaseItem.splrBatch" /> | 
 |  |  |   const location = useLocation(); | 
 |  |  |   const queryParams = new URLSearchParams(location.search); | 
 |  |  |   const poId = queryParams.get("poId"); | 
 |  |  |  | 
 |  |  |                     <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> | 
 |  |  |             <PurchaseItemCreate | 
 |  |  |                 open={createDialog} | 
 |  |  |                 setOpen={setCreateDialog} | 
 |  |  |             /> | 
 |  |  |             <PageDrawer | 
 |  |  |                 title='PurchaseItem Detail' | 
 |  |  |                 drawerVal={drawerVal} | 
 |  |  |                 setDrawerVal={setDrawerVal} | 
 |  |  |             > | 
 |  |  |             </PageDrawer> | 
 |  |  |         </Box> | 
 |  |  |     ) | 
 |  |  |   return ( | 
 |  |  |     <> | 
 |  |  |       {poId && <CustomerTopToolBar backPrevious={true} />} | 
 |  |  |       <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.purchaseItem"} | 
 |  |  |           empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} | 
 |  |  |           filters={filters} | 
 |  |  |           sort={{ field: "create_time", order: "desc" }} | 
 |  |  |           actions={( | 
 |  |  |             <TopToolbar> | 
 |  |  |               <FilterButton /> | 
 |  |  |               <MyCreateButton onClick={() => { setCreateDialog(true) }} /> | 
 |  |  |               <SelectColumnsButton preferenceKey='purchaseItem' /> | 
 |  |  |               <MyExportButton /> | 
 |  |  |             </TopToolbar> | 
 |  |  |           )} | 
 |  |  |           perPage={DEFAULT_PAGE_SIZE} | 
 |  |  |         > | 
 |  |  |           <StyledDatagrid | 
 |  |  |             preferenceKey='purchaseItem' | 
 |  |  |             bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} | 
 |  |  |             rowClick={(id, resource, record) => false} | 
 |  |  |             omit={['id', 'createTime', 'createBy', 'memo']} | 
 |  |  |           > | 
 |  |  |             <NumberField source="id" /> | 
 |  |  |             <NumberField source="purchaseId" label="table.field.purchaseItem.purchaseId" /> | 
 |  |  |             <TextField source="platItemId" label="table.field.purchaseItem.platItemId" /> | 
 |  |  |             <TextField source="matnrCode" label="table.field.purchaseItem.matnrCode" /> | 
 |  |  |             <TextField source="matnrName" label="table.field.purchaseItem.matnrName" /> | 
 |  |  |             <TextField source="unit" label="table.field.purchaseItem.unit" /> | 
 |  |  |             <NumberField source="anfme" label="table.field.purchaseItem.anfme" /> | 
 |  |  |             <NumberField source="qty" label="table.field.purchaseItem.qty" /> | 
 |  |  |             <NumberField source="nromQty" label="table.field.purchaseItem.nromQty" /> | 
 |  |  |             <NumberField source="asnQty" label="table.field.purchaseItem.asnQty" /> | 
 |  |  |             <NumberField source="printQty" label="table.field.purchaseItem.printQty" /> | 
 |  |  |             <TextField source="splrName" label="table.field.purchaseItem.splrName" /> | 
 |  |  |             <TextField source="splrCode" label="table.field.purchaseItem.splrCode" /> | 
 |  |  |             <TextField source="splrBatch" label="table.field.purchaseItem.splrBatch" /> | 
 |  |  |  | 
 |  |  |             <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> | 
 |  |  |         <PurchaseItemCreate | 
 |  |  |           open={createDialog} | 
 |  |  |           setOpen={setCreateDialog} | 
 |  |  |           row={{ poId }} | 
 |  |  |         /> | 
 |  |  |         <PageDrawer | 
 |  |  |           title='PurchaseItem Detail' | 
 |  |  |           drawerVal={drawerVal} | 
 |  |  |           setDrawerVal={setDrawerVal} | 
 |  |  |         > | 
 |  |  |         </PageDrawer> | 
 |  |  |       </Box></> | 
 |  |  |   ) | 
 |  |  | } | 
 |  |  |  | 
 |  |  | export default PurchaseItemList; |