index.tsx 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. import { useAjax } from "@/Hook/useAjax"
  2. import { getLogListApi } from "@/services/launchAdq/adq"
  3. import { Button, Col, Input, Row } from "antd"
  4. import React, { useCallback, 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. getList(queryparams)
  37. }, [])
  38. const getList=useCallback((params:any)=>{
  39. getLogList.run({...params,userId})
  40. },[userId])
  41. return <div>
  42. <TableData
  43. isCard={false}
  44. columns={() => tableConfig(tableIdClick)}
  45. ajax={getLogList}
  46. dataSource={getLogList?.data?.data?.records}
  47. loading={getLogList?.data?.loading}
  48. scroll={{ y: 550 }}
  49. total={getLogList?.data?.data?.total}
  50. page={getLogList?.data?.data?.current}
  51. pageSize={getLogList?.data?.data?.size}
  52. leftChild={<>
  53. <Row gutter={[10, 10]}>
  54. <Col>
  55. <Input
  56. placeholder='广告账号'
  57. allowClear
  58. style={{ width: 150 }}
  59. value={queryparams.accountId}
  60. onBlur={(e) => {
  61. let value = e.target.value
  62. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, accountId: value })
  63. }}
  64. onKeyDownCapture={(e: any) => {
  65. let key = e.key
  66. if (key === 'Enter') {
  67. let value = e.target.value
  68. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, accountId: value })
  69. }
  70. }}
  71. onChange={(e) => {
  72. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, accountId: e.target.value })
  73. }}
  74. />
  75. </Col>
  76. <Col>
  77. <Input
  78. placeholder='广告组id'
  79. allowClear
  80. style={{ width: 150 }}
  81. value={queryparams.adgroupId}
  82. onBlur={(e) => {
  83. let value = e.target.value
  84. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, adgroupId: value })
  85. }}
  86. onKeyDownCapture={(e: any) => {
  87. let key = e.key
  88. if (key === 'Enter') {
  89. let value = e.target.value
  90. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, adgroupId: value })
  91. }
  92. }}
  93. onChange={(e) => {
  94. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, adgroupId: e.target.value })
  95. }}
  96. />
  97. </Col>
  98. <Col>
  99. <Input
  100. placeholder='广告名称'
  101. allowClear
  102. style={{ width: 150 }}
  103. value={queryparams.adgroupName}
  104. onBlur={(e) => {
  105. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, adgroupName: e.target.value })
  106. }}
  107. onKeyDownCapture={(e: any) => {
  108. let key = e.key
  109. if (key === 'Enter') {
  110. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, adgroupName: e.target.value })
  111. }
  112. }}
  113. onChange={(e) => {
  114. setQueryparams({...queryparams, pageNum: 1, pageSize: 20, adgroupName: e.target.value })
  115. }}
  116. />
  117. </Col>
  118. <Col>
  119. <Button type='primary' onClick={()=>{getList({...queryparams,pageNum:1})}}>搜索</Button>
  120. </Col>
  121. </Row>
  122. </>}
  123. onChange={(props: any) => {
  124. let { sortData, pagination } = props
  125. let { current, pageSize } = pagination
  126. setQueryparams({ ...queryparams, pageNum: current, pageSize })
  127. getList({...queryparams, pageNum: current, pageSize})
  128. }}
  129. />
  130. </div>
  131. }
  132. export default React.memo(Log)