executeLog.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { useAjax } from "@/Hook/useAjax"
  2. import { getSelectAdTaskLogListApi } from "@/services/adqV3"
  3. import { Button, Modal, Space, Table, Tag } from "antd"
  4. import React, { useEffect, useState } from "react"
  5. import { columnsExecuteLog } from "./tableConfig"
  6. interface Props {
  7. data: any
  8. visible?: boolean,
  9. onClose?: () => void
  10. }
  11. /**
  12. * 任务执行记录
  13. * @param param0
  14. * @returns
  15. */
  16. const ExecuteLog: React.FC<Props> = ({ data, visible, onClose }) => {
  17. /*************************************/
  18. const { id, taskName } = data
  19. const [queryForm, setQueryForm] = useState<PULLIN.GetTaskV3LogProps>({ pageNum: 1, pageSize: 20 })
  20. const getSelectAdTaskLogList = useAjax((params) => getSelectAdTaskLogListApi(params), { formatResult: true })
  21. /*************************************/
  22. useEffect(() => {
  23. getList()
  24. }, [queryForm, id])
  25. /** 获取列表 */
  26. const getList = () => {
  27. if (id) {
  28. getSelectAdTaskLogList.run({ ...queryForm, taskId: id })
  29. }
  30. }
  31. return <Modal
  32. title={<Space>
  33. <strong>{taskName + ' 执行记录'}</strong>
  34. <Button type="link" loading={getSelectAdTaskLogList.loading} onClick={() => getSelectAdTaskLogList.refresh()}>刷新</Button>
  35. </Space>}
  36. className="modalResetCss"
  37. open={visible}
  38. width={750}
  39. onCancel={onClose}
  40. footer={null}
  41. >
  42. <Table
  43. columns={columnsExecuteLog()}
  44. dataSource={getSelectAdTaskLogList?.data?.data?.records}
  45. size="small"
  46. loading={getSelectAdTaskLogList?.loading}
  47. scroll={{ y: 600 }}
  48. bordered
  49. rowKey={'id'}
  50. pagination={{
  51. pageSize: queryForm.pageSize,
  52. current: queryForm.pageNum,
  53. total: getSelectAdTaskLogList?.data?.data?.total || 0,
  54. showTotal: (total) => <Tag color="cyan">总共{total}数据</Tag>
  55. }}
  56. onChange={(pagination) => {
  57. let { current, pageSize } = pagination
  58. let newQueryForm = JSON.parse(JSON.stringify(queryForm))
  59. newQueryForm.pageNum = current
  60. newQueryForm.pageSize = pageSize
  61. setQueryForm(newQueryForm)
  62. }}
  63. />
  64. </Modal>
  65. }
  66. export default React.memo(ExecuteLog)