| import { Dialog, DialogActions, DialogContent, DialogTitle, Box } from "@mui/material"; | 
| import React, { useState, useRef, useEffect, useMemo } from "react"; | 
| import { | 
|     List, | 
|     DatagridConfigurable, | 
|     SearchInput, | 
|     TopToolbar, | 
|     Button, | 
|     SelectColumnsButton, | 
|     EditButton, | 
|     FilterButton, | 
|     CreateButton, | 
|     ExportButton, | 
|     BulkDeleteButton, | 
|     WrapperField, | 
|     Toolbar, | 
|     useRecordContext, | 
|     useTranslate, | 
|     useNotify, | 
|     useListContext, | 
|     FunctionField, | 
|     TextField, | 
|     NumberField, | 
|     DateField, | 
|     BooleanField, | 
|     ReferenceField, | 
|     TextInput, | 
|     DateTimeInput, | 
|     DateInput, | 
|     SelectInput, | 
|     NumberInput, | 
|     ReferenceInput, | 
|     ReferenceArrayInput, | 
|     AutocompleteInput, | 
|     DeleteButton, | 
|     Form, | 
|     SaveButton, | 
|     useRefresh, | 
|     useGetList, | 
| } from 'react-admin'; | 
| import DialogCloseButton from "../../components/DialogCloseButton"; | 
| import { styled } from '@mui/material/styles'; | 
| import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; | 
| import { Grid, Stack, width } from "@mui/system"; | 
| import request from '@/utils/request'; | 
| import SaveIcon from '@mui/icons-material/Save'; | 
| import CheckCircleIcon from '@mui/icons-material/CheckCircle'; | 
| import POItemModal from "./POItemModal"; | 
|   | 
| const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|     '& .css-1vooibu-MuiSvgIcon-root': { | 
|         height: '.9em' | 
|     }, | 
|     '& .RaDatagrid-row': { | 
|         cursor: 'auto' | 
|     }, | 
|     '& .status': { | 
|         width: 90 | 
|     }, | 
| })); | 
|   | 
| const AsnCreateByPoModal = (props) => { | 
|     const { open, setOpen, record } = props; | 
|     const translate = useTranslate(); | 
|     const [params, setParams] = useState({}); | 
|     const [item, setItem] = useState({}); | 
|     const [poItemDialog, setPoItemDialog] = useState(false); | 
|     const [drawerVal, setDrawerVal] = useState(false); | 
|     const refresh = useRefresh(); | 
|   | 
|     const handleClose = (event, reason) => { | 
|         if (reason !== "backdropClick") { | 
|             setOpen(false); | 
|         } | 
|     }; | 
|     // const CustomFilter = () => { | 
|     //     const { filterValues, setFilters, refetch } = useListContext('deliveryItem'); | 
|     //     const [formValues, setFormValues] = useState(filterValues); | 
|     //     const handleChange = (event) => { | 
|     //         if (event.target == undefined || event.target == null) { return } | 
|     //         setFormValues(formValues => ({ | 
|     //             ...formValues, | 
|     //             [event.target.name]: event.target.value | 
|     //         })); | 
|     //     }; | 
|   | 
|     //     const handleSubmit = (event) => { | 
|     //         setParams(formValues) | 
|     //     }; | 
|   | 
|     //     return ( | 
|     //         <Box sx={{ width: '100%', margin: 1, marginBottom: 8, "& .MuiDialogActions-root": { padding: 0 } }}> | 
|     //             <Form> | 
|     //                 <Grid container rowSpacing={2} columnSpacing={2} sx={{ padding: 2 }}> | 
|     //                     <Stack> | 
|     //                         <TextInput | 
|     //                             source="condition" | 
|     //                             label="common.action.search" | 
|     //                             resettable | 
|     //                             defaultValue={params?.condition} | 
|     //                             onChange={handleChange} /> | 
|     //                     </Stack> | 
|     //                 </Grid> | 
|     //                 <DialogActions> | 
|     //                     <Toolbar sx={{ width: '100%', justifyContent: 'end' }}  > | 
|     //                         <SaveButton onClick={handleSubmit} label={"toolbar.query"} /> | 
|     //                     </Toolbar> | 
|     //                 </DialogActions> | 
|     //             </Form> | 
|     //         </Box> | 
|     //     ); | 
|     // }; | 
|     return ( | 
|         <Box> | 
|             <Dialog | 
|                 open={open} | 
|                 onClose={handleClose} | 
|                 aria-labelledby="form-dialog-title" | 
|                 aria-hidden | 
|                 fullWidth | 
|                 disableRestoreFocus | 
|                 maxWidth="lg" | 
|             > | 
|                 <DialogTitle id="form-dialog-title" sx={{ | 
|                     position: 'sticky', | 
|                     top: 0, | 
|                     backgroundColor: 'background.paper', | 
|                     zIndex: 1000 | 
|                 }}> | 
|                     <Box sx={{ position: 'absolute', top: 8, right: 8, zIndex: 1001 }}> | 
|                         <DialogCloseButton onClose={handleClose} /> | 
|                     </Box> | 
|                 </DialogTitle> | 
|                 <Grid container rowSpacing={2} columnSpacing={2}> | 
|                     <DialogContent> | 
|                         <Grid item sx={24}> | 
|                             <List | 
|                                 storeKey="selectPurchase" | 
|                                 resource="purchase/filters" | 
|                                 sx={{ | 
|                                     flexGrow: 1, | 
|                                     marginTop: 8, | 
|                                     height: 500, | 
|                                     transition: (theme) => | 
|                                         theme.transitions.create(['all'], { | 
|                                             duration: theme.transitions.duration.enteringScreen, | 
|                                         }), | 
|                                     marginRight: 0, | 
|                                 }} | 
|                                 // filters={<CustomFilter />} | 
|                                 queryOptions={{ meta: { ...params } }} | 
|                                 empty={false} | 
|                                 sort={{ field: "create_time", order: "desc" }} | 
|                                 actions={false} | 
|                                 perPage={DEFAULT_PAGE_SIZE} | 
|                             > | 
|                                 <StyledDatagrid | 
|                                     preferenceKey='selectPurchase' | 
|                                     bulkActionButtons={ | 
|                                         <> | 
|                                             <ConfirmSelectButton | 
|                                                 setOpen={setOpen} | 
|                                                 setPoItemDialog={setPoItemDialog} | 
|                                                 setItem={setItem} | 
|                                                 mutationMode="pessimistic" /> | 
|                                         </> | 
|                                     } | 
|                                     rowClick={false} | 
|                                     expand={false} | 
|                                     expandSingle={true} | 
|                                     omit={['id', 'createTime', 'createBy', 'channel', 'platCode', 'memo', 'channel', 'startTime', 'workQty', 'endTime']} | 
|                                 > | 
|                                     <NumberField source="id" /> | 
|                                     <TextField source="code" label="table.field.purchase.code" /> | 
|                                     <TextField source="type$" label="table.field.purchase.type" /> | 
|                                     <TextField source="wkType$" label="table.field.purchase.wkType" /> | 
|                                     <TextField source="source" label="table.field.purchase.source" /> | 
|                                     <NumberField source="anfme" label="table.field.purchase.anfme" /> | 
|                                     <NumberField source="qty" label="table.field.purchase.qty" /> | 
|                                     <TextField source="channel" label="table.field.purchase.channel" /> | 
|                                     <TextField source="platCode" label="table.field.purchase.platCode" /> | 
|                                     <DateField source="preArr" label="table.field.purchase.preArr" showTime /> | 
|                                     <DateField source="startTime" label="table.field.purchase.startTime" showTime /> | 
|                                     <DateField source="endTime" label="table.field.purchase.endTime" showTime /> | 
|                                     <TextField source="project" label="table.field.purchase.project" /> | 
|                                     <TextField source="memo" label="common.field.memo" sortable={false} /> | 
|                                 </StyledDatagrid> | 
|                             </List> | 
|                         </Grid> | 
|                     </DialogContent> | 
|                 </Grid> | 
|             </Dialog > | 
|             <POItemModal open={poItemDialog} setOpen={setPoItemDialog} record={item} /> | 
|         </Box> | 
|     ) | 
| } | 
|   | 
| export default AsnCreateByPoModal; | 
|   | 
|   | 
| const ConfirmSelectButton = ({ setOpen, setPoItemDialog, setItem }) => { | 
|     const { selectedIds, onUnselectItems } = useListContext(); | 
|     const confirmSelect = async (event) => { | 
|         setItem(selectedIds[0]) | 
|         onUnselectItems(); | 
|         setPoItemDialog(true) | 
|         setOpen(false); | 
|     } | 
|   | 
|     return ( | 
|         <Button label={"toolbar.confirm"} variant="contained" color="primary" size="medium" startIcon={<SaveIcon />} onClick={confirmSelect} /> | 
|     ) | 
| } |