|  |  |  | 
|---|
|  |  |  | 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, SelectInput, NumberField, WrapperField, EditButton, DeleteButton, TextField, DateField, TextInput, BooleanField, NumberInput, ReferenceField, SearchInput, SelectColumnsButton, DatagridConfigurable, Button } from "react-admin"; | 
|---|
|  |  |  | 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'; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const filters = [ | 
|---|
|  |  |  | <SearchInput source="condition" alwaysOn />, | 
|---|
|  |  |  | <NumberInput source="type" label="table.field.deviceSite.type" />, | 
|---|
|  |  |  | <TextInput source="site" label="table.field.deviceSite.site" />, | 
|---|
|  |  |  | <TextInput source="name" label="table.field.deviceSite.name" />, | 
|---|
|  |  |  | <TextInput source="wcsCode" label="table.field.deviceSite.wcsCode" />, | 
|---|
|  |  |  | <TextInput source="label" label="table.field.deviceSite.label" />, | 
|---|
|  |  |  | <TextInput source="device" label="table.field.deviceSite.device" />, | 
|---|
|  |  |  | <TextInput source="deviceCode" label="table.field.deviceSite.deviceCode" />, | 
|---|
|  |  |  | <TextInput source="deviceSite" label="table.field.deviceSite.deviceSite" />, | 
|---|
|  |  |  | <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 | 
|---|
|  |  |  | /> | 
|---|
|  |  |  | ] | 
|---|
|  |  |  | import request from '@/utils/request'; | 
|---|
|  |  |  | const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|---|
|  |  |  | '& .css-1vooibu-MuiSvgIcon-root': { | 
|---|
|  |  |  | height: '.9em' | 
|---|
|  |  |  | 
|---|
|  |  |  | }, | 
|---|
|  |  |  | })); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const SelectSiteButton = (props) => { | 
|---|
|  |  |  | const { source, setOpen, refresh, notify } = props; | 
|---|
|  |  |  | const record = useRecordContext(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const handleClick = async () => { | 
|---|
|  |  |  | setOpen(false); | 
|---|
|  |  |  | const id = record.id; | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Button label="toolbar.selectSite" onClick={handleClick} /> | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | const SelectSiteModel = (props) => { | 
|---|
|  |  |  | const { open, setOpen, record } = 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ( | 
|---|
|  |  |  | <Box> | 
|---|
|  |  |  | <Dialog | 
|---|
|  |  |  | sx={{width: '100%'}} | 
|---|
|  |  |  | open={open} | 
|---|
|  |  |  | onClose={handleClose} | 
|---|
|  |  |  | fullWidth | 
|---|
|  |  |  | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <DialogTitle> | 
|---|
|  |  |  | {translate('toolbar.selectSite')} | 
|---|
|  |  |  | <DialogCloseButton onClose={() => setOpen(false)} /> | 
|---|
|  |  |  | </DialogTitle> | 
|---|
|  |  |  | <DialogContent> | 
|---|
|  |  |  | <List | 
|---|
|  |  |  | resource='deviceSite' | 
|---|
|  |  |  | filter={{type : 1}} | 
|---|
|  |  |  | sx={{ | 
|---|
|  |  |  | flexGrow: 1, | 
|---|
|  |  |  | transition: (theme) => | 
|---|
|  |  |  | 
|---|
|  |  |  | }} | 
|---|
|  |  |  | title={"menu.deviceSite"} | 
|---|
|  |  |  | empty={false} | 
|---|
|  |  |  | filters={filters} | 
|---|
|  |  |  | sort={{ field: "create_time", order: "desc" }} | 
|---|
|  |  |  | actions={( | 
|---|
|  |  |  | <TopToolbar> | 
|---|
|  |  |  | <FilterButton /> | 
|---|
|  |  |  | <SelectColumnsButton preferenceKey='deviceSite' /> | 
|---|
|  |  |  | </TopToolbar> | 
|---|
|  |  |  | )} | 
|---|
|  |  |  | 
|---|
|  |  |  | <StyledDatagrid | 
|---|
|  |  |  | preferenceKey='deviceSite' | 
|---|
|  |  |  | bulkActionButtons={false} | 
|---|
|  |  |  | rowClick={(id, resource, record) => false} | 
|---|
|  |  |  | omit={['id', 'createTime', 'createBy', 'memo', 'updateBy$', 'createBy$', 'createTime', 'updateTime']} | 
|---|
|  |  |  | rowClick={false} | 
|---|
|  |  |  | omit={['id','name', 'createTime','label', 'createBy', 'memo', 'updateBy$', 'createBy$', 'createTime', 'updateTime']} | 
|---|
|  |  |  | > | 
|---|
|  |  |  | <NumberField source="id" /> | 
|---|
|  |  |  | <TextField source="name" label="table.field.deviceSite.name" /> | 
|---|
|  |  |  | 
|---|
|  |  |  | <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"> | 
|---|
|  |  |  | <SelectSiteButton source={source} setOpen={setOpen} refresh={refresh} notify={notify} /> | 
|---|
|  |  |  | </WrapperField> | 
|---|
|  |  |  | </StyledDatagrid> | 
|---|
|  |  |  | </List> | 
|---|
|  |  |  | </DialogContent> | 
|---|
|  |  |  | </DialogContent> | 
|---|
|  |  |  | </Dialog> | 
|---|
|  |  |  | </Box> | 
|---|
|  |  |  | ) | 
|---|