zhang
2025-05-20 1313906bb1eb983d3beece810035e7fc28d6a92f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
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;