| | |
| | | import React, { useState, useRef, useEffect, useMemo, useCallback } from "react"; |
| | | import { useNavigate } from 'react-router-dom'; |
| | | import request from '@/utils/request'; |
| | | |
| | | import { |
| | | List, |
| | | DatagridConfigurable, |
| | | SearchInput, |
| | | TopToolbar, |
| | | SelectColumnsButton, |
| | | EditButton, |
| | | FilterButton, |
| | | CreateButton, |
| | | ExportButton, |
| | | BulkDeleteButton, |
| | | WrapperField, |
| | | useRecordContext, |
| | | useTranslate, |
| | | useNotify, |
| | | useListContext, |
| | | FunctionField, |
| | | useRefresh, |
| | | TextField, |
| | | NumberField, |
| | | DateField, |
| | | BooleanField, |
| | | ReferenceField, |
| | | TextInput, |
| | | DateTimeInput, |
| | | DateInput, |
| | | SelectInput, |
| | | NumberInput, |
| | | ReferenceInput, |
| | | ReferenceArrayInput, |
| | | AutocompleteInput, |
| | | DeleteButton, |
| | | |
| | | Button, |
| | | } from 'react-admin'; |
| | | import { Box, Typography, Card, Stack } from '@mui/material'; |
| | | import { Box, Typography, Card, Stack, Drawer } from '@mui/material'; |
| | | import { styled } from '@mui/material/styles'; |
| | | import TaskCreate from "./TaskCreate"; |
| | | import TaskPanel from "./TaskPanel"; |
| | |
| | | '& .column-name': { |
| | | }, |
| | | '& .opt': { |
| | | width: 200 |
| | | width: 248 |
| | | }, |
| | | })); |
| | | |
| | | const filters = [ |
| | | <SearchInput source="condition" alwaysOn />, |
| | | <DateInput label='common.time.after' source="timeStart" alwaysOn />, |
| | | <DateInput label='common.time.before' source="timeEnd" alwaysOn />, |
| | | <DateInput label='common.time.after' source="timeStart" />, |
| | | <DateInput label='common.time.before' source="timeEnd" />, |
| | | <TextInput source="taskCode" label="table.field.task.taskCode" />, |
| | | <NumberInput source="taskStatus" label="table.field.task.taskStatus" />, |
| | | <NumberInput source="taskType" label="table.field.task.taskType" />, |
| | |
| | | />, |
| | | ] |
| | | |
| | | const TaskList = () => { |
| | | const TaskList = (props) => { |
| | | const translate = useTranslate(); |
| | | const [createDialog, setCreateDialog] = useState(false); |
| | | const [drawerVal, setDrawerVal] = useState(false); |
| | | |
| | | return ( |
| | | <Box display="flex"> |
| | | <List |
| | |
| | | marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0, |
| | | }} |
| | | title={"menu.task"} |
| | | // empty={<EmptyData onClick={() => { setCreateDialog(true) }} />} |
| | | empty={false} |
| | | filters={filters} |
| | | sort={{ field: "create_time", order: "desc" }} |
| | | sort={{ field: "sort", order: "desc" }} |
| | | actions={( |
| | | <TopToolbar> |
| | | <FilterButton /> |
| | | {/* <MyCreateButton onClick={() => { setCreateDialog(true) }} /> */} |
| | | <SelectColumnsButton preferenceKey='task' /> |
| | | {/* <MyExportButton /> */} |
| | | </TopToolbar> |
| | | )} |
| | | perPage={DEFAULT_PAGE_SIZE} |
| | | > |
| | | <StyledDatagrid |
| | | preferenceKey='task' |
| | | // bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />} |
| | | bulkActionButtons={ |
| | | <> |
| | | <BulkResortButton /> |
| | |
| | | <BulkDeleteButton mutationMode={OPERATE_MODE} /> |
| | | </> |
| | | } |
| | | rowClick={(id, resource, record) => false} |
| | | // expand={() => <TaskPanel />} |
| | | // expandSingle={true} |
| | | omit={['id', 'createTime', 'createBy', 'memo', 'robotCode', 'exceStatus', 'expDesc', 'expCode', 'sort']} |
| | | rowClick={'edit'} |
| | | expand={false} |
| | | expandSingle={true} |
| | | omit={['id', 'createTime', 'createBy', 'memo', 'robotCode', 'exceStatus', 'expDesc', 'expCode', 'status', 'sort']} |
| | | > |
| | | <NumberField source="id" /> |
| | | <TextField source="taskCode" label="table.field.task.taskCode" /> |
| | |
| | | <TextField source="expDesc" label="table.field.task.expDesc" /> |
| | | <NumberField source="sort" label="table.field.task.sort" /> |
| | | <TextField source="expCode" label="table.field.task.expCode" /> |
| | | <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}> |
| | | <TextField source="nickname" /> |
| | | </ReferenceField> |
| | | <TextField source="updateBy$" label="common.field.updateBy" /> |
| | | <TextField source="createBy$" label="common.field.createBy" /> |
| | | <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} /> |
| | | {/* <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' }} /> */} |
| | | <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 |
| | | open={createDialog} |
| | | setOpen={setCreateDialog} |
| | | /> */} |
| | | <PageDrawer |
| | | title='Task Detail' |
| | | drawerVal={drawerVal} |
| | |
| | | } |
| | | |
| | | export default TaskList; |
| | | |
| | | |
| | | /** |
| | | * 完成操作 |
| | | * @returns |
| | | */ |
| | | const DoneButton = () => { |
| | | const DoneButton = (props) => { |
| | | const record = useRecordContext(); |
| | | const clickComplete = () => { |
| | | completeTask([record]) |
| | | const notify = useNotify(); |
| | | const refresh = useRefresh(); |
| | | const clickComplete = (event) => { |
| | | event.stopPropagation(); |
| | | completeTask(record) |
| | | }; |
| | | //完成任务 |
| | | const completeTask = async (row) => { } |
| | | const completeTask = async (row) => { |
| | | console.log(row.id); |
| | | const { data: { code, data, msg } } = await request.post(`task/complete/` + row.id); |
| | | if (code === 200) { |
| | | notify(msg); |
| | | refresh(); |
| | | } else { |
| | | notify(msg); |
| | | } |
| | | } |
| | | return ( |
| | | <Button |
| | | onClick={clickComplete} |
| | |
| | | */ |
| | | const CancelButton = () => { |
| | | const record = useRecordContext(); |
| | | const notify = useNotify(); |
| | | const refresh = useRefresh(); |
| | | const clickCancel = () => { |
| | | cancleTask([record]) |
| | | cancleTask(record) |
| | | }; |
| | | //取消任务 |
| | | const cancleTask = async (row) => {} |
| | | 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} |
| | |
| | | */ |
| | | const SetTopButton = () => { |
| | | const record = useRecordContext(); |
| | | const notify = useNotify(); |
| | | const refresh = useRefresh(); |
| | | const clickTop = () => { |
| | | topTask([record]) |
| | | topTask(record) |
| | | }; |
| | | //置顶任务 |
| | | const topTask = async (row) => { } |
| | | 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} |
| | |
| | | cancleTask([record]) |
| | | }; |
| | | //取消任务 |
| | | const cancleTask = async (row) => {} |
| | | const cancleTask = async (row) => { } |
| | | return ( |
| | | <Button |
| | | onClick={clickCancel} |
| | |
| | | <SwapVertIcon /> |
| | | </Button> |
| | | ) |
| | | |
| | | } |