index.tsx 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import { useAjax } from "@/Hook/useAjax"
  2. import { getSysAdcreativeInfo } from "@/services/launchAdq/creative"
  3. import { EyeOutlined } from "@ant-design/icons"
  4. import { Popover, Spin } from "antd"
  5. import React, { useState } from "react"
  6. import AdcreativeCol from "../../launchManage/createAd/adcreativeCol"
  7. import style from '../targetingPopover/index.less'
  8. interface Props {
  9. id: number,
  10. name: string
  11. }
  12. /**
  13. * 表格查看创意基本信息
  14. * @returns
  15. */
  16. const AdcreativePopover: React.FC<Props> = (props) => {
  17. /*************************/
  18. const { id, name } = props
  19. const [visible, setVisible] = useState<boolean>(false)
  20. const getSysAdcreative = useAjax((params) => getSysAdcreativeInfo(params))
  21. /*************************/
  22. const handleVisibleChange = (newVisible: boolean) => {
  23. setVisible(newVisible)
  24. if (id && newVisible) {
  25. getSysAdcreative.run(id)
  26. }
  27. }
  28. return <Popover
  29. content={<Spin spinning={getSysAdcreative.loading}>
  30. <div className={`${style.popover} ${style.aStyle}`}>
  31. {getSysAdcreative?.data && <AdcreativeCol data={getSysAdcreative?.data} />}
  32. </div>
  33. </Spin>}
  34. trigger="click"
  35. placement="left"
  36. visible={visible}
  37. onVisibleChange={handleVisibleChange}
  38. >
  39. {/* 查看创意 */}
  40. <a style={{ color: '#1890ff', fontSize: 12 }}>{name || id}</a>
  41. </Popover>
  42. }
  43. export default React.memo(AdcreativePopover)