| 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, | 
|     useListContext, | 
|     useCreatePath, | 
|     TextField, | 
|     NumberField, | 
|     DateField, | 
|     BooleanField, | 
|     ReferenceField, | 
|     TextInput, | 
|     DateTimeInput, | 
|     DateInput, | 
|     SelectInput, | 
|     NumberInput, | 
|     ReferenceInput, | 
|     ReferenceArrayInput, | 
|     AutocompleteInput, | 
|     DeleteButton, | 
|     FunctionField, | 
|     Pagination, | 
| } from 'react-admin'; | 
| import { Box, Typography, Card, Stack } from '@mui/material'; | 
| import { styled } from '@mui/material/styles'; | 
| import ActionCreate from "./ActionCreate"; | 
| import ActionPanel from "./ActionPanel"; | 
| import EmptyData from "../components/EmptyData"; | 
| import MyCreateButton from "../components/MyCreateButton"; | 
| import MyExportButton from '../components/MyExportButton'; | 
| import PageDrawer from "../components/PageDrawer"; | 
| import MyField from "../components/MyField"; | 
| import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; | 
| import * as Common from '@/utils/common'; | 
|   | 
| const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({ | 
|     '& .css-1vooibu-MuiSvgIcon-root': { | 
|         height: '.9em' | 
|     }, | 
|     '& .RaDatagrid-row': { | 
|         cursor: 'auto' | 
|     }, | 
|     '& .column-busId': { | 
|         maxWidth: '8em', | 
|         overflow: 'hidden', | 
|         textOverflow: 'ellipsis', | 
|         whiteSpace: 'nowrap', | 
|     }, | 
|     '& .opt': { | 
|         width: 200 | 
|     }, | 
| })); | 
|   | 
| const filters = [ | 
|     // <SearchInput source="condition" alwaysOn />, | 
|     <TextInput source="groupId" label="table.field.action.groupId" alwaysOn resettable />, | 
|     <ReferenceInput source="agvId" label="table.field.action.agvId" reference="agv" alwaysOn> | 
|         <AutocompleteInput label="table.field.action.agvId" optionText="uuid" filterToQuery={(val) => ({ uuid: val })} /> | 
|     </ReferenceInput>, | 
|     <ReferenceInput source="busId" label="table.field.action.busId" reference="bus"> | 
|         <AutocompleteInput label="table.field.action.busId" optionText="busNo" filterToQuery={(val) => ({ seqNum: val })} /> | 
|     </ReferenceInput>, | 
|     <ReferenceInput source="taskId" label="table.field.action.taskId" reference="task" alwaysOn> | 
|         <AutocompleteInput label="table.field.action.taskId" optionText="seqNum" filterToQuery={(val) => ({ seqNum: val })} /> | 
|     </ReferenceInput>, | 
|     <DateInput label='common.time.after' source="timeStart" alwaysOn />, | 
|     <DateInput label='common.time.before' source="timeEnd" alwaysOn />, | 
|     <TextInput source="uuid" label="table.field.action.uuid" />, | 
|     // <TextInput source="seqNum" label="table.field.action.seqNum" />, | 
|     // <NumberInput source="priority" label="table.field.action.priority" />, | 
|     // <TextInput source="name" label="table.field.action.name" />, | 
|     <NumberInput source="val" label="table.field.action.val" />, | 
|     <TextInput source="code" label="table.field.action.code" />, | 
|     <TextInput source="params" label="table.field.action.params" />, | 
|     <ReferenceInput source="actionType" label="table.field.action.actionType" reference="actionType"> | 
|         <AutocompleteInput label="table.field.action.actionType" optionText="name" filterToQuery={(val) => ({ name: val })} /> | 
|     </ReferenceInput>, | 
|     <ReferenceInput source="actionSts" label="table.field.action.actionSts" reference="actionSts"> | 
|         <AutocompleteInput label="table.field.action.actionSts" optionText="name" filterToQuery={(val) => ({ name: val })} /> | 
|     </ReferenceInput>, | 
|     // <DateInput source="ioTime" label="table.field.action.ioTime" />, | 
|     // <DateInput source="startTime" label="table.field.action.startTime" />, | 
|     // <DateInput source="endTime" label="table.field.action.endTime" />, | 
|     // <DateInput source="errTime" label="table.field.action.errTime" />, | 
|     <TextInput source="errDesc" label="table.field.action.errDesc" />, | 
|   | 
|     <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' }, | 
|         ]} | 
|     />, | 
| ] | 
|   | 
| const ActionList = () => { | 
|     const translate = useTranslate(); | 
|   | 
|     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.action"} | 
|                 empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} | 
|                 filters={filters} | 
|                 sort={{ field: "io_time", order: "desc" }} | 
|                 actions={( | 
|                     <TopToolbar> | 
|                         <FilterButton /> | 
|                         {/* <MyCreateButton onClick={() => { setCreateDialog(true) }} /> */} | 
|                         <SelectColumnsButton preferenceKey='action' /> | 
|                         <MyExportButton /> | 
|                     </TopToolbar> | 
|                 )} | 
|                 pagination={<Pagination rowsPerPageOptions={[10, 20, 50, 100]} />} | 
|                 perPage={50} | 
|             > | 
|                 <StyledDatagrid | 
|                     preferenceKey='action' | 
|                     bulkActionButtons={false} | 
|                     rowClick={(id, resource, record) => false} | 
|                     expand={() => <ActionPanel />} | 
|                     expandSingle={true} | 
|                     omit={['id', 'uuid', 'busId', 'startTime', 'endTime', 'errTime', 'errDesc', 'updateBy', 'updateTime', 'createTime', 'createBy', 'memo']} | 
|                 > | 
|                     <NumberField source="id" /> | 
|                     <TextField source="uuid" label="table.field.action.uuid" /> | 
|                     <TextField source="groupId" label="table.field.action.groupId" /> | 
|                     <ReferenceField source="agvId" label="table.field.action.agvId" reference="agv" link={false} sortable={false}> | 
|                         <TextField source="uuid" /> | 
|                     </ReferenceField> | 
|                     <ReferenceField source="busId" label="table.field.action.busId" reference="bus" link={false} sortable={false}> | 
|                         <TextField source="busNo" /> | 
|                     </ReferenceField> | 
|                     <ReferenceField source="taskId" label="table.field.action.taskId" reference="task" link={false} sortable={false}> | 
|                         <TextField source="seqNum" /> | 
|                     </ReferenceField> | 
|                     {/* <TextField source="seqNum" label="table.field.action.seqNum" /> */} | 
|                     <NumberField source="priority" label="table.field.action.priority" sortable={false} sx={{ fontWeight: 'bold' }} /> | 
|                     {/* <TextField source="name" label="table.field.action.name" /> */} | 
|                     <ReferenceField source="actionType" label="table.field.action.actionType" reference="actionType" link={false} sortable={false}> | 
|                         <TextField source="name" /> | 
|                     </ReferenceField> | 
|                     <TextField source="code" label="table.field.action.code" sortable={false} /> | 
|                     <NumberField source="val" label="table.field.action.val" sortable={false} /> | 
|                     <TextField source="params" label="table.field.action.params" sortable={false} /> | 
|                     <ReferenceField source="actionSts" label="table.field.action.actionSts" reference="actionSts" link={false} sortable={false}> | 
|                         <TextField source="name" /> | 
|                     </ReferenceField> | 
|                     <DateField source="ioTime" label="table.field.action.ioTime" showTime /> | 
|                     <DateField source="startTime" label="table.field.action.startTime" showTime /> | 
|                     <DateField source="endTime" label="table.field.action.endTime" showTime /> | 
|                     <DateField source="errTime" label="table.field.action.errTime" showTime /> | 
|                     <TextField source="errDesc" label="table.field.action.errDesc" /> | 
|   | 
|                     <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} /> | 
|                     {/* <FunctionField label="common.field.opt" cellClassName="opt" render={record => ( | 
|                         <> | 
|                         </> | 
|                     )} /> */} | 
|                 </StyledDatagrid> | 
|             </List> | 
|             <ActionCreate | 
|                 open={createDialog} | 
|                 setOpen={setCreateDialog} | 
|             /> | 
|             <PageDrawer | 
|                 title='Action Detail' | 
|                 drawerVal={drawerVal} | 
|                 setDrawerVal={setDrawerVal} | 
|             > | 
|             </PageDrawer> | 
|         </Box> | 
|     ) | 
| } | 
|   | 
| export default ActionList; |