| import { Dialog, DialogTitle, Box, DialogActions, DialogContent } from "@mui/material"; | 
| import React, { useState, useRef, useEffect, useMemo, useCallback, Form } from "react"; | 
| import { styled } from '@mui/material/styles'; | 
| import { FilterButton, TopToolbar, Toolbar, useTranslate, SaveButton, List, useRecordSelection, SelectInput, NumberField, WrapperField, EditButton, DeleteButton, TextField, DateField, TextInput, BooleanField, NumberInput, ReferenceField, SearchInput, SelectColumnsButton, DatagridConfigurable, Button, useRefresh, useRecordContext, useNotify } from "react-admin"; | 
| import DialogCloseButton from "../components/DialogCloseButton"; | 
| import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_ITEM_PAGE_SIZE } from '@/config/setting'; | 
| import request from '@/utils/request'; | 
| const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|     '& .css-1vooibu-MuiSvgIcon-root': { | 
|         height: '.9em' | 
|     }, | 
|     '& .RaDatagrid-row': { | 
|         cursor: 'auto' | 
|     }, | 
|     '& .column-name': { | 
|     }, | 
|     '& .opt': { | 
|         width: 200 | 
|     }, | 
| })); | 
|   | 
| const SelectSiteModel = (props) => { | 
|     const { open, setOpen, source } = props; | 
|     const translate = useTranslate(); | 
|     const [drawerVal, setDrawerVal] = useState(false); | 
|     const refresh = useRefresh(); | 
|     const notify = useNotify(); | 
|     const handleClose = (event, reason) => { | 
|         if (reason !== "backdropClick") { | 
|             setOpen(false); | 
|         } | 
|     }; | 
|     console.log(source); | 
|     return ( | 
|         <Box> | 
|             <Dialog | 
|             sx={{width: '90%'}} | 
|                 open={open} | 
|                 onClose={handleClose} | 
|                 fullWidth | 
|                 disableRestoreFocus | 
|                 maxWidth="md" | 
|             > | 
|                 <DialogTitle> | 
|                     {translate('toolbar.selectSite')} | 
|                 </DialogTitle> | 
|                 <DialogContent> | 
|                     <List | 
|                         resource='deviceSite' | 
|                         sx={{ | 
|                             flexGrow: 1, | 
|                             transition: (theme) => | 
|                                 theme.transitions.create(['all'], { | 
|                                     duration: theme.transitions.duration.enteringScreen, | 
|                                 }), | 
|                             marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, | 
|                         }} | 
|                         title={"menu.deviceSite"} | 
|                         empty={false} | 
|                         sort={{ field: "create_time", order: "desc" }} | 
|                         actions={( | 
|                             <TopToolbar> | 
|                                 <SelectColumnsButton preferenceKey='deviceSite' /> | 
|                             </TopToolbar> | 
|                         )} | 
|                         perPage={DEFAULT_ITEM_PAGE_SIZE} | 
|                     > | 
|                         <StyledDatagrid | 
|                             preferenceKey='deviceSite' | 
|                             bulkActionButtons={false} | 
|                             rowClick='toggleSelection' | 
|                             onToggleItem={async (id)=>{ | 
|                                 setOpen(false); | 
|                                 const res = await request.post(`/waitPakin/merge`, {waitPakins: source, siteId: id}); | 
|                                 if (res?.data?.code === 200) { | 
|                                     refresh(); | 
|                                     notify(res.data.msg); | 
|                                 } else { | 
|                                     notify(res.data.msg); | 
|                                 } | 
|                             }} | 
|                             omit={['id','name', 'createTime','label', 'createBy', 'memo', 'updateBy$', 'createBy$', 'createTime', 'updateTime']} | 
|                         > | 
|                             <NumberField source="id" /> | 
|                             <TextField source="name" label="table.field.deviceSite.name" /> | 
|                             <NumberField source="type$" label="table.field.deviceSite.type" /> | 
|                             <TextField source="site" label="table.field.deviceSite.site" /> | 
|                             <TextField source="wcsCode" label="table.field.deviceSite.wcsCode" /> | 
|                             <TextField source="label" label="table.field.deviceSite.label" /> | 
|                             <TextField source="device$" label="table.field.deviceSite.device" /> | 
|                             <TextField source="deviceCode" label="table.field.deviceSite.deviceCode" /> | 
|                             <TextField source="deviceSite" label="table.field.deviceSite.deviceSite" /> | 
|                             <TextField source="updateBy$" label="common.field.updateBy" /> | 
|                             <DateField source="updateTime" label="common.field.updateTime" showTime /> | 
|                             <TextField source="createBy$" label="common.field.createBy" /> | 
|                             <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"> | 
|                                 <Button label="toolbar.selectSite" onClick={(event)=>{  | 
|                                     setOpen(false) | 
|                                  }}/> | 
|                             </WrapperField> | 
|                         </StyledDatagrid> | 
|                     </List> | 
|                 </DialogContent> | 
|             </Dialog> | 
|         </Box> | 
|     ) | 
| } | 
|   | 
| export default SelectSiteModel; |