| 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, | 
|     useRefresh | 
| } from 'react-admin'; | 
| import { Box, Typography, Card, Stack } from '@mui/material'; | 
| import { styled } from '@mui/material/styles'; | 
| import WaitPakinCreate from "./WaitPakinCreate"; | 
| import ConfirmButton from "../components/ConfirmButton"; | 
| import EmptyData from "../components/EmptyData"; | 
| import MyExportButton from '../components/MyExportButton'; | 
| import PageDrawer from "../components/PageDrawer"; | 
| import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; | 
| import AddIcon from '@mui/icons-material/Add'; | 
| import SelectSiteModel from "./SelectSiteModel"; | 
|   | 
| const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|     '& .css-1vooibu-MuiSvgIcon-root': { | 
|         height: '.9em' | 
|     }, | 
|     '& .RaDatagrid-row': { | 
|         cursor: 'auto' | 
|     }, | 
|     '& .column-name': { | 
|     }, | 
|     '& .column-statusBool': { | 
|         width: 90 | 
|     }, | 
|     '& .opt': { | 
|         width: 210 | 
|     }, | 
|     '& .MuiTableCell-root': { | 
|     whiteSpace: 'nowrap', | 
|     overflow: 'visible', | 
|     textOverflow: 'unset' | 
|   } | 
| })); | 
|   | 
| const filters = [ | 
|     <SearchInput source="condition" alwaysOn />, | 
|     <TextInput source="code" label="table.field.waitPakin.code" />, | 
|     <TextInput source="barcode" label="table.field.waitPakin.barcode" />, | 
|     <NumberInput source="anfme" label="table.field.waitPakin.anfme" />, | 
|     <SelectInput source="ioStatus" label="table.field.waitPakin.ioStatus" | 
|         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 WaitPakinList = () => { | 
|     const translate = useTranslate(); | 
|     const [createDialog, setCreateDialog] = useState(false); | 
|     const [siteDialog, setSiteDialog] = useState(false); | 
|     const [source, setSource] = useState(false); | 
|     const [drawerVal, setDrawerVal] = useState(false); | 
|   | 
|     const CreateTaskButton = () => { | 
|         const record = useRecordContext(); | 
|         const notify = useNotify(); | 
|         const refresh = useRefresh(); | 
|         const { selectedIds, onUnselectItems, data } = useListContext(); | 
|         const rows = data.filter(map => selectedIds.includes(map.id)); | 
|         const createTask = () => { | 
|             setSiteDialog(true) | 
|             setSource(rows) | 
|             onUnselectItems() | 
|             refresh() | 
|         } | 
|   | 
|         return ( | 
|             <> | 
|                 <Button onClick={() => createTask()} label={"toolbar.createTask"}> | 
|                     <AddIcon /> | 
|                 </Button> | 
|             </> | 
|         ) | 
|     } | 
|   | 
|     const CreateTaskRowButton = () => { | 
|         const record = useRecordContext(); | 
|         const refresh = useRefresh(); | 
|   | 
|         const createTask = (event) => { | 
|             event.stopPropagation(); | 
|             setSiteDialog(true) | 
|             setSource([record]) | 
|             refresh() | 
|         } | 
|   | 
|         return ( | 
|             <> | 
|                 <Button onClick={(event) => createTask(event)} label={"toolbar.createTask"}> | 
|                     <AddIcon /> | 
|                 </Button> | 
|             </> | 
|         ) | 
|     } | 
|   | 
|     return ( | 
|         <Box display="flex"> | 
|             <List | 
|                 resource="waitPakin" | 
|                 sx={{ | 
|                     flexGrow: 1, | 
|                     transition: (theme) => | 
|                         theme.transitions.create(['all'], { | 
|                             duration: theme.transitions.duration.enteringScreen, | 
|                         }), | 
|                     marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, | 
|                 }} | 
|                 title={"menu.waitPakin"} | 
|                 empty={false} | 
|                 filters={filters} | 
|                 sort={{ field: "create_time", order: "desc" }} | 
|                 actions={( | 
|                     <TopToolbar> | 
|                         <FilterButton /> | 
|                         <SelectColumnsButton preferenceKey='waitPakin' /> | 
|                         <MyExportButton /> | 
|                     </TopToolbar> | 
|                 )} | 
|                 perPage={DEFAULT_PAGE_SIZE} | 
|             > | 
|                 <StyledDatagrid | 
|                     preferenceKey='waitPakin' | 
|                     bulkActionButtons={ | 
|                         <> | 
|                             <CreateTaskButton /> | 
|                             {/* <BulkDeleteButton mutationMode={OPERATE_MODE} /> */} | 
|                         </>} | 
|                     rowClick={false} | 
|                     omit={['id', 'createTime', 'createBy', 'memo','statusBool']} | 
|                 > | 
|                     <NumberField source="id" /> | 
|                     <TextField source="code" label="table.field.waitPakin.code" /> | 
|                     <TextField source="barcode" label="table.field.waitPakin.barcode" /> | 
|                     <NumberField source="anfme" label="table.field.waitPakin.anfme" /> | 
|                     <TextField source="ioStatus$" label="table.field.waitPakin.ioStatus" sortable={false} /> | 
|                     <TextField source="updateBy$" label="common.field.updateBy" /> | 
|                     <DateField source="updateTime" label="common.field.updateTime" showTime /> | 
|                     <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 label="toolbar.detail" sx={{ padding: '1px', fontSize: '.75rem' }} /> | 
|                         <CreateTaskRowButton /> | 
|                         <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> | 
|                     </WrapperField> | 
|                 </StyledDatagrid> | 
|             </List> | 
|             <SelectSiteModel open={siteDialog} setOpen={setSiteDialog} source={source} /> | 
|             <WaitPakinCreate | 
|                 open={createDialog} | 
|                 setOpen={setCreateDialog} | 
|             /> | 
|             <PageDrawer | 
|                 title='WaitPakin Detail' | 
|                 drawerVal={drawerVal} | 
|                 setDrawerVal={setDrawerVal} | 
|             > | 
|             </PageDrawer> | 
|         </Box> | 
|     ) | 
| } | 
|   | 
| export default WaitPakinList; |