index.tsx 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import { useAjax } from "@/Hook/useAjax"
  2. import { getLogListApi } from "@/services/launchAdq/adq"
  3. import { Col, Input, Row } from "antd"
  4. import React, { useEffect, useState } from "react"
  5. import TableData from "../../components/TableData"
  6. import tableConfig from "./tableConfig"
  7. type Props = {
  8. accountId: string,
  9. adAccountId: string,
  10. userId: string,
  11. queryParmas: {
  12. accountId?: string,//账户ID
  13. adgroupId?: string,//广告ID
  14. },
  15. tableIdClick: (props: {
  16. activeKey: string, parma: {
  17. accountId?: string,//账户ID
  18. campaignId?: string,//计划ID
  19. adgroupId?: string,//广告ID
  20. adcreativeId?: string,//创意ID
  21. pageId?: string,//落地页ID
  22. targetingId?: string,//定向ID
  23. }
  24. }) => void
  25. }
  26. /**
  27. * 操作记录
  28. */
  29. const Log: React.FC<Props> = (props) => {
  30. /**************************/
  31. let { tableIdClick, queryParmas, userId } = props
  32. const [queryparams, setQueryparams] = useState<{ accountId?: string, adgroupId?: string, adgroupName?: string, pageNum: number, pageSize: number, userId: string }>({ pageNum: 1, pageSize: 20, userId })
  33. const getLogList = useAjax((params) => getLogListApi(params), { formatResult: true })
  34. /**************************/
  35. useEffect(() => {
  36. if (queryParmas?.accountId || queryParmas?.adgroupId || userId) {
  37. setQueryparams({ ...queryparams, ...queryParmas, userId })
  38. }
  39. }, [queryParmas, userId])
  40. useEffect(() => {
  41. getLogList.run(queryparams)
  42. }, [queryparams])
  43. return <div>
  44. <TableData
  45. isCard={false}
  46. columns={() => tableConfig(tableIdClick)}
  47. ajax={getLogList}
  48. dataSource={getLogList?.data?.data?.records}
  49. loading={getLogList?.data?.loading}
  50. scroll={{ y: 550 }}
  51. total={getLogList?.data?.data?.total}
  52. page={getLogList?.data?.data?.current}
  53. pageSize={getLogList?.data?.data?.size}
  54. leftChild={<>
  55. <Row gutter={[10, 10]}>
  56. <Col>
  57. <Input
  58. placeholder='广告账号'
  59. allowClear
  60. style={{ width: 150 }}
  61. value={queryparams.accountId}
  62. onBlur={(e) => {
  63. let value = e.target.value
  64. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, accountId: value })
  65. }}
  66. onKeyDownCapture={(e: any) => {
  67. let key = e.key
  68. if (key === 'Enter') {
  69. let value = e.target.value
  70. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, accountId: value })
  71. }
  72. }}
  73. onChange={(e) => {
  74. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, accountId: e.target.value })
  75. }}
  76. />
  77. </Col>
  78. <Col>
  79. <Input
  80. placeholder='广告组id'
  81. allowClear
  82. style={{ width: 150 }}
  83. value={queryparams.adgroupId}
  84. onBlur={(e) => {
  85. let value = e.target.value
  86. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, adgroupId: value })
  87. }}
  88. onKeyDownCapture={(e: any) => {
  89. let key = e.key
  90. if (key === 'Enter') {
  91. let value = e.target.value
  92. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, adgroupId: value })
  93. }
  94. }}
  95. onChange={(e) => {
  96. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, adgroupId: e.target.value })
  97. }}
  98. />
  99. </Col>
  100. <Col>
  101. <Input
  102. placeholder='定向名称'
  103. allowClear
  104. style={{ width: 150 }}
  105. value={queryparams.adgroupName}
  106. onBlur={(e) => {
  107. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, adgroupName: e.target.value })
  108. }}
  109. onKeyDownCapture={(e: any) => {
  110. let key = e.key
  111. if (key === 'Enter') {
  112. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, adgroupName: e.target.value })
  113. }
  114. }}
  115. onChange={(e) => {
  116. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, adgroupName: e.target.value })
  117. }}
  118. />
  119. </Col>
  120. </Row>
  121. </>}
  122. onChange={(props: any) => {
  123. let { sortData, pagination } = props
  124. let { current, pageSize } = pagination
  125. setQueryparams({ ...queryparams, pageNum: current, pageSize })
  126. }}
  127. />
  128. </div>
  129. }
  130. export default React.memo(Log)