log.tsx 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { useAjax } from "@/Hook/useAjax"
  2. import { getTaskV3LogListApi } from "@/services/adqV3"
  3. import { Button, Drawer, Space, Table, Tag } from "antd"
  4. import React, { useEffect, useState } from "react"
  5. import { columnsLog } from "./tableConfig"
  6. import DynamicLog from "./dynamicLog"
  7. interface Props {
  8. data: any
  9. visible?: boolean,
  10. onClose?: () => void
  11. }
  12. /**
  13. * 创建日志
  14. * @returns
  15. */
  16. const Log: React.FC<Props> = (props) => {
  17. /*****************************/
  18. const { data, visible, onClose } = props
  19. console.log(data)
  20. const { id, taskName } = data
  21. const [queryForm, setQueryForm] = useState<PULLIN.GetTaskV3LogProps>({ pageNum: 1, pageSize: 20 })
  22. const getTaskV3LogList = useAjax((params) => getTaskV3LogListApi(params), { formatResult: true })
  23. /*****************************/
  24. useEffect(() => {
  25. getList()
  26. }, [queryForm, id])
  27. /** 获取列表 */
  28. const getList = () => {
  29. if (id) {
  30. getTaskV3LogList.run({ ...queryForm, taskId: id })
  31. }
  32. }
  33. return <Drawer
  34. bodyStyle={{ padding: 0 }}
  35. title={<Space>
  36. <span>{taskName + ' 日志'}</span>
  37. <Button type="link" onClick={() => getTaskV3LogList.refresh()}>刷新</Button>
  38. </Space>}
  39. width={1400}
  40. placement="right"
  41. onClose={() => { onClose && onClose() }}
  42. visible={visible}
  43. >
  44. <Table
  45. columns={columnsLog()}
  46. dataSource={getTaskV3LogList?.data?.data?.records}
  47. size="small"
  48. loading={getTaskV3LogList?.loading}
  49. scroll={{ y: 600 }}
  50. bordered
  51. rowKey={'id'}
  52. pagination={{
  53. pageSize: queryForm.pageSize,
  54. current: queryForm.pageNum,
  55. total: getTaskV3LogList?.data?.data?.total || 0,
  56. showTotal: (total) => <Tag color="cyan">总共{total}数据</Tag>
  57. }}
  58. onChange={(pagination) => {
  59. let { current, pageSize } = pagination
  60. let newQueryForm = JSON.parse(JSON.stringify(queryForm))
  61. newQueryForm.pageNum = current
  62. newQueryForm.pageSize = pageSize
  63. setQueryForm(newQueryForm)
  64. }}
  65. expandable={{
  66. expandedRowRender: record => <DynamicLog record={record} />
  67. }}
  68. />
  69. </Drawer>
  70. }
  71. export default React.memo(Log)