|  |  | 
 |  |  | import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; | 
 |  |  | import { useNavigate } from 'react-router-dom'; | 
 |  |  | import request from '@/utils/request'; | 
 |  |  |  | 
 |  |  | import { | 
 |  |  |     List, | 
 |  |  |     DatagridConfigurable, | 
 |  |  | 
 |  |  |     useRecordContext, | 
 |  |  |     useTranslate, | 
 |  |  |     useNotify, | 
 |  |  |     useRefresh, | 
 |  |  |     useListContext, | 
 |  |  |     FunctionField, | 
 |  |  |     TextField, | 
 |  |  | 
 |  |  |     ReferenceArrayInput, | 
 |  |  |     AutocompleteInput, | 
 |  |  |     DeleteButton, | 
 |  |  |     Button, | 
 |  |  | } from 'react-admin'; | 
 |  |  | import { Box, Typography, Card, Stack } from '@mui/material'; | 
 |  |  | import { styled } from '@mui/material/styles'; | 
 |  |  | 
 |  |  | import EmptyData from "../components/EmptyData"; | 
 |  |  | import MyCreateButton from "../components/MyCreateButton"; | 
 |  |  | import MyExportButton from '../components/MyExportButton'; | 
 |  |  | import SwapVertIcon from '@mui/icons-material/SwapVert'; | 
 |  |  | import AlignVerticalTopIcon from '@mui/icons-material/AlignVerticalTop'; | 
 |  |  | import TaskAltIcon from '@mui/icons-material/TaskAlt'; | 
 |  |  | import CancelIcon from '@mui/icons-material/Cancel'; | 
 |  |  | import PageDrawer from "../components/PageDrawer"; | 
 |  |  | import MyField from "../components/MyField"; | 
 |  |  | import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting'; | 
 |  |  | 
 |  |  |     <SearchInput source="condition" alwaysOn />, | 
 |  |  |     <DateInput label='common.time.after' source="timeStart" alwaysOn />, | 
 |  |  |     <DateInput label='common.time.before' source="timeEnd" alwaysOn />, | 
 |  |  |  | 
 |  |  |     <TextInput source="taskCode" label="table.field.task.taskCode" />, | 
 |  |  |     <NumberInput source="taskStatus" label="table.field.task.taskStatus" />, | 
 |  |  |     <NumberInput source="taskType" label="table.field.task.taskType" />, | 
 |  |  | 
 |  |  |     <TextInput source="expCode" label="table.field.task.expCode" />, | 
 |  |  |     <DateInput source="startTime" label="table.field.task.startTime" />, | 
 |  |  |     <DateInput source="endTime" label="table.field.task.endTime" />, | 
 |  |  |  | 
 |  |  |     <TextInput label="common.field.memo" source="memo" />, | 
 |  |  |     <SelectInput | 
 |  |  |         label="common.field.status" | 
 |  |  | 
 |  |  |  | 
 |  |  | const TaskList = () => { | 
 |  |  |     const translate = useTranslate(); | 
 |  |  |  | 
 |  |  |     const [createDialog, setCreateDialog] = useState(false); | 
 |  |  |     const [drawerVal, setDrawerVal] = useState(false); | 
 |  |  |  | 
 |  |  | 
 |  |  |                     marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, | 
 |  |  |                 }} | 
 |  |  |                 title={"menu.task"} | 
 |  |  |                 empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} | 
 |  |  |                 empty={<EmptyData onClick={() => { }} />} | 
 |  |  |                 filters={filters} | 
 |  |  |                 sort={{ field: "create_time", order: "desc" }} | 
 |  |  |                 sort={{ field: "sort", order: "desc" }} | 
 |  |  |                 actions={( | 
 |  |  |                     <TopToolbar> | 
 |  |  |                         <FilterButton /> | 
 |  |  |                         <MyCreateButton onClick={() => { setCreateDialog(true) }} /> | 
 |  |  |                         {/* <MyCreateButton onClick={() => { setCreateDialog(true) }} /> */} | 
 |  |  |                         <SelectColumnsButton preferenceKey='task' /> | 
 |  |  |                         <MyExportButton /> | 
 |  |  |                         {/* <MyExportButton /> */} | 
 |  |  |                     </TopToolbar> | 
 |  |  |                 )} | 
 |  |  |                 perPage={DEFAULT_PAGE_SIZE} | 
 |  |  |             > | 
 |  |  |                 <StyledDatagrid | 
 |  |  |                     preferenceKey='task' | 
 |  |  |                     bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} | 
 |  |  |                     // bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} | 
 |  |  |                     bulkActionButtons={ | 
 |  |  |                         <> | 
 |  |  |                             <BulkResortButton /> | 
 |  |  |                             <BulkCancelButton /> | 
 |  |  |                             <BulkDeleteButton mutationMode={OPERATE_MODE} /> | 
 |  |  |                         </> | 
 |  |  |                     } | 
 |  |  |                     rowClick={(id, resource, record) => false} | 
 |  |  |                     expand={() => <TaskPanel />} | 
 |  |  |                     expandSingle={true} | 
 |  |  |                     omit={['id', 'createTime', 'createBy', 'memo']} | 
 |  |  |                     // expand={() => <TaskPanel />} | 
 |  |  |                     // expandSingle={true} | 
 |  |  |                     omit={['id', 'createTime', 'createBy', 'memo', 'robotCode', 'exceStatus', 'expDesc', 'expCode', 'sort']} | 
 |  |  |                 > | 
 |  |  |                     <NumberField source="id" /> | 
 |  |  |                     <TextField source="taskCode" label="table.field.task.taskCode" /> | 
 |  |  |                     <NumberField source="taskStatus" label="table.field.task.taskStatus" /> | 
 |  |  |                     <NumberField source="taskType" label="table.field.task.taskType" /> | 
 |  |  |                     <NumberField source="taskStatus$" label="table.field.task.taskStatus" /> | 
 |  |  |                     <NumberField source="taskType$" label="table.field.task.taskType" /> | 
 |  |  |                     <TextField source="orgLoc" label="table.field.task.orgLoc" /> | 
 |  |  |                     <TextField source="orgSite" label="table.field.task.orgSite" /> | 
 |  |  |                     <TextField source="targLoc" label="table.field.task.targLoc" /> | 
 |  |  | 
 |  |  |                     <TextField source="expDesc" label="table.field.task.expDesc" /> | 
 |  |  |                     <NumberField source="sort" label="table.field.task.sort" /> | 
 |  |  |                     <TextField source="expCode" label="table.field.task.expCode" /> | 
 |  |  |                     <DateField source="startTime" label="table.field.task.startTime" showTime /> | 
 |  |  |                     <DateField source="endTime" label="table.field.task.endTime" showTime /> | 
 |  |  |  | 
 |  |  |                     <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> | 
 |  |  |                         <TextField source="nickname" /> | 
 |  |  |                     </ReferenceField> | 
 |  |  | 
 |  |  |                     <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"> | 
 |  |  |                         <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> | 
 |  |  |                         <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> | 
 |  |  |                         {/* <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} /> */} | 
 |  |  |                         <DoneButton sx={{ padding: '1px', fontSize: '.75rem' }} ></DoneButton> | 
 |  |  |                         <CancelButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} /> | 
 |  |  |                         <SetTopButton sx={{ padding: '1px', fontSize: '.75rem' }} ></SetTopButton> | 
 |  |  |                     </WrapperField> | 
 |  |  |                 </StyledDatagrid> | 
 |  |  |             </List> | 
 |  |  |             <TaskCreate | 
 |  |  |             {/* <TaskCreate | 
 |  |  |                 open={createDialog} | 
 |  |  |                 setOpen={setCreateDialog} | 
 |  |  |             /> | 
 |  |  |             /> */} | 
 |  |  |             <PageDrawer | 
 |  |  |                 title='Task Detail' | 
 |  |  |                 drawerVal={drawerVal} | 
 |  |  | 
 |  |  | } | 
 |  |  |  | 
 |  |  | export default TaskList; | 
 |  |  | /** | 
 |  |  |  * 完成操作 | 
 |  |  |  * @returns  | 
 |  |  |  */ | 
 |  |  | const DoneButton = () => { | 
 |  |  |     const record = useRecordContext(); | 
 |  |  |     const clickComplete = () => { | 
 |  |  |         completeTask([record]) | 
 |  |  |     }; | 
 |  |  |     //完成任务 | 
 |  |  |     const completeTask = async (row) => { } | 
 |  |  |     return ( | 
 |  |  |         <Button | 
 |  |  |             onClick={clickComplete} | 
 |  |  |             label="toolbar.complete"> | 
 |  |  |             <TaskAltIcon /> | 
 |  |  |         </Button> | 
 |  |  |     ) | 
 |  |  | } | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * 取消按钮 | 
 |  |  |  * @returns  | 
 |  |  |  */ | 
 |  |  | const CancelButton = () => { | 
 |  |  |     const record = useRecordContext(); | 
 |  |  |     const notify = useNotify(); | 
 |  |  |     const refresh = useRefresh(); | 
 |  |  |     const clickCancel = () => { | 
 |  |  |         cancleTask(record) | 
 |  |  |     }; | 
 |  |  |     //取消任务 | 
 |  |  |     const cancleTask = async (row) => { | 
 |  |  |         console.log(row); | 
 |  |  |         const { data: { code, data, msg } } = await request.post(`/task/remove/` + row.id); | 
 |  |  |         if (code === 200) { | 
 |  |  |             notify(msg); | 
 |  |  |             refresh(); | 
 |  |  |         } else { | 
 |  |  |             notify(msg); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |     return ( | 
 |  |  |         <Button | 
 |  |  |             onClick={clickCancel} | 
 |  |  |             label="toolbar.cancel"> | 
 |  |  |             <CancelIcon /> | 
 |  |  |         </Button> | 
 |  |  |     ) | 
 |  |  | } | 
 |  |  | /** | 
 |  |  |  *  置顶操作 | 
 |  |  |  * @returns  | 
 |  |  |  */ | 
 |  |  | const SetTopButton = () => { | 
 |  |  |     const record = useRecordContext(); | 
 |  |  |     const notify = useNotify(); | 
 |  |  |     const refresh = useRefresh(); | 
 |  |  |     const clickTop = () => { | 
 |  |  |         topTask(record) | 
 |  |  |     }; | 
 |  |  |     //置顶任务 | 
 |  |  |     const topTask = async (row) => { | 
 |  |  |         const { data: { code, data, msg } } = await request.post(`/task/top/` + row.id); | 
 |  |  |         if (code === 200) { | 
 |  |  |             notify(msg); | 
 |  |  |             refresh(); | 
 |  |  |         } else { | 
 |  |  |             notify(msg); | 
 |  |  |         } | 
 |  |  |      } | 
 |  |  |     return ( | 
 |  |  |         <Button | 
 |  |  |             onClick={clickTop} | 
 |  |  |             label="toolbar.top"> | 
 |  |  |             <AlignVerticalTopIcon /> | 
 |  |  |         </Button> | 
 |  |  |     ) | 
 |  |  | } | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * 批量取消 | 
 |  |  |  * @returns  | 
 |  |  |  */ | 
 |  |  | const BulkCancelButton = () => { | 
 |  |  |     const record = useRecordContext(); | 
 |  |  |     const clickCancel = () => { | 
 |  |  |         cancleTask([record]) | 
 |  |  |     }; | 
 |  |  |     //取消任务 | 
 |  |  |     const cancleTask = async (row) => { } | 
 |  |  |     return ( | 
 |  |  |         <Button | 
 |  |  |             onClick={clickCancel} | 
 |  |  |             label="toolbar.cancel"> | 
 |  |  |             <CancelIcon /> | 
 |  |  |         </Button> | 
 |  |  |     ) | 
 |  |  | } | 
 |  |  |  | 
 |  |  | /** | 
 |  |  |  * 批量排序 | 
 |  |  |  * @returns  | 
 |  |  |  */ | 
 |  |  | const BulkResortButton = () => { | 
 |  |  |     const record = useRecordContext(); | 
 |  |  |     const bulkResort = () => { | 
 |  |  |         resortTask([record]) | 
 |  |  |     }; | 
 |  |  |     //批量排序 | 
 |  |  |     const resortTask = async (row) => { } | 
 |  |  |     return ( | 
 |  |  |         <Button | 
 |  |  |             onClick={bulkResort} | 
 |  |  |             label="toolbar.resort"> | 
 |  |  |             <SwapVertIcon /> | 
 |  |  |         </Button> | 
 |  |  |     ) | 
 |  |  | } |