reviewDetails.tsx 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import { useAjax } from "@/Hook/useAjax"
  2. import { getCreativeReviewDetailApi } from "@/services/adqV3/global"
  3. import { Card, Drawer, Table } from "antd"
  4. import React, { useEffect, useState } from "react"
  5. import { tableConfigDetail } from "./tableConfig"
  6. import '../../tencentAdPutIn/index.less'
  7. interface Props {
  8. dynamic: any
  9. visible?: boolean,
  10. onClose?: () => void
  11. }
  12. /**
  13. * 审核详情
  14. * @returns
  15. */
  16. const ReviewDetails: React.FC<Props> = ({ dynamic, visible, onClose }) => {
  17. /****************************/
  18. const [tableData, setTableData] = useState<any[]>([])
  19. const getCreativeReviewDetail = useAjax((params) => getCreativeReviewDetailApi(params))
  20. /****************************/
  21. useEffect(() => {
  22. if (dynamic && Object.keys(dynamic).length) {
  23. const { accountId, dynamicCreativeId } = dynamic
  24. getCreativeReviewDetail.run({ accountId, dynamicCreativeIds: [dynamicCreativeId] }).then(res => {
  25. if (res) {
  26. let { elementResultList } = res[0]
  27. let count = 0
  28. elementResultList.forEach((item: any) => {
  29. if (item?.componentInfo) {
  30. count += 1
  31. }
  32. })
  33. setTableData(elementResultList?.map((item: any, index: number, array: any[]) => {
  34. let params = { ...item, id: index, rowSpan: 1, accountId, dynamicCreativeId }
  35. if (item?.componentInfo?.componentType === 'VIDEO') {
  36. if (array?.[index + 1]?.componentInfo?.componentId === item?.componentInfo?.componentId) {
  37. params.rowSpan = 2
  38. } else {
  39. params.rowSpan = 0
  40. }
  41. }
  42. if (index === count) {
  43. params.rowSpan = elementResultList.length - count
  44. } else if (index > count) {
  45. params.rowSpan = 0
  46. }
  47. return params
  48. }))
  49. }
  50. })
  51. }
  52. }, [dynamic])
  53. return <Drawer
  54. title={<strong>创意审核详情</strong>}
  55. open={visible}
  56. width={'70%'}
  57. onClose={onClose}
  58. bodyStyle={{ backgroundColor: '#f1f4fc', padding: 10 }}
  59. >
  60. <Card
  61. title={<strong>{dynamic?.dynamicCreativeName}</strong>}
  62. bodyStyle={{ padding: 0 }}
  63. className="cardResetCss"
  64. >
  65. <Table
  66. columns={tableConfigDetail()}
  67. dataSource={tableData}
  68. size="small"
  69. loading={getCreativeReviewDetail?.loading}
  70. scroll={{ x: 1100 }}
  71. bordered
  72. rowKey={'id'}
  73. />
  74. </Card>
  75. </Drawer>
  76. }
  77. export default React.memo(ReviewDetails)