reviewDetails.tsx 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. console.log('------------->', res)
  26. if (res) {
  27. let { elementResultList } = res[0]
  28. let cover: any, count = 0
  29. elementResultList.forEach((item: any) => {
  30. if (item?.elementName === '图片' && item?.componentInfo?.componentType === "VIDEO") {
  31. cover = item
  32. }
  33. if (item?.componentInfo) {
  34. count += 1
  35. }
  36. })
  37. setTableData(elementResultList?.map((item: any, index: number) => {
  38. let params = { ...item, id: index, rowSpan: 1 }
  39. if (item?.componentInfo?.componentType === 'VIDEO' && cover) {
  40. if (item?.elementType === "VIDEO") {
  41. params.rowSpan = 2
  42. } else {
  43. params.rowSpan = 0
  44. }
  45. }
  46. if (index === count) {
  47. params.rowSpan = elementResultList.length - count
  48. } else if (index > count) {
  49. params.rowSpan = 0
  50. }
  51. return params
  52. }))
  53. }
  54. })
  55. }
  56. }, [dynamic])
  57. return <Drawer
  58. title={<strong>创意审核详情</strong>}
  59. visible={visible}
  60. width={'70%'}
  61. onClose={onClose}
  62. bodyStyle={{ backgroundColor: '#f1f4fc', padding: 10 }}
  63. >
  64. <Card
  65. title={<strong>{dynamic?.dynamicCreativeName}</strong>}
  66. bodyStyle={{ padding: 0 }}
  67. className="cardResetCss"
  68. >
  69. <Table
  70. columns={tableConfigDetail()}
  71. dataSource={tableData}
  72. size="small"
  73. loading={getCreativeReviewDetail?.loading}
  74. scroll={{ x: 1100 }}
  75. bordered
  76. rowKey={'id'}
  77. />
  78. </Card>
  79. </Drawer>
  80. }
  81. export default React.memo(ReviewDetails)