| | |
| | | import { formatDistance } from 'date-fns'; |
| | | import request from '@/utils/request'; |
| | | |
| | | export const AgvShowTask = ({ agvId }) => { |
| | | |
| | | export const AgvShowTask = ({ agvId, pageSize = 20 }) => { |
| | | const [currCount, setCurrCount] = useState(pageSize); |
| | | const [records, setRecords] = useState(null); |
| | | const [total, setTotal] = useState(0); |
| | | |
| | | useEffect(() => { |
| | | const http = async (agvId) => { |
| | | const res = await request.post('task/page', { agvId: agvId }); |
| | | const http = async () => { |
| | | const res = await request.post('task/page', { agvId: agvId, pageSize: currCount }); |
| | | const { code, msg, data } = res.data; |
| | | if (code === 200) { |
| | | setTotal(data.total); |
| | |
| | | setRecords(null); |
| | | } |
| | | } |
| | | if (agvId) { |
| | | http(agvId); |
| | | } |
| | | }, [agvId]); |
| | | if (agvId) { http(); } |
| | | }, [agvId, currCount]); |
| | | |
| | | if (!records) { |
| | | return ( |
| | |
| | | ); |
| | | } |
| | | |
| | | |
| | | return ( |
| | | <> |
| | | {records.length > 0 ? ( |
| | | records.map(record => { |
| | | return ( |
| | | <Typography> |
| | | {record.seqNum} |
| | | </Typography> |
| | | ) |
| | | }) |
| | | <Box> |
| | | {records.map(record => { |
| | | return ( |
| | | <TaskItem |
| | | key={record.id} |
| | | record={record} |
| | | /> |
| | | ) |
| | | })} |
| | | {currCount < total && ( |
| | | <Button |
| | | onClick={() => |
| | | setCurrCount( |
| | | currCount => |
| | | currCount + pageSize |
| | | ) |
| | | } |
| | | fullWidth |
| | | > |
| | | Load more activity |
| | | </Button> |
| | | )} |
| | | </Box> |
| | | ) : ( |
| | | <Typography> |
| | | no data found |
| | |
| | | |
| | | </> |
| | | ) |
| | | } |
| | | |
| | | const TaskItem = ({ record }) => { |
| | | |
| | | return ( |
| | | <> |
| | | <Typography |
| | | |
| | | > |
| | | {record.seqNum} |
| | | </Typography> |
| | | </> |
| | | ) |
| | | } |