index.tsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import FlieBox from '@/components/FileBoxAD'
  2. import HocError from '@/Hoc/HocError'
  3. import { QuestionCircleFilled } from '@ant-design/icons'
  4. import { Button, Space, Tabs, Tooltip } from 'antd'
  5. import React, { useEffect, useState } from 'react'
  6. import { useModel } from 'umi'
  7. import AddLandingPage from '../../components/addLandingPage'
  8. import BathLauCopy from '../../components/bathLauCopy'
  9. import LookLanding from '../../components/lookLanding'
  10. import style from './index.less'
  11. const { TabPane } = Tabs;
  12. function Cloud() {
  13. /**********************/
  14. const { state, set, getList, init, typeEnum, list } = useModel('useLaunchAdq.useBdMedia')
  15. const { mediaType, belongUser, parentId } = state
  16. const [visible, setVisible] = useState<boolean>(false)
  17. const [lookVisible, setLookVisible] = useState<boolean>(false)
  18. const [copyVisible, setCopyVisible] = useState<boolean>(false)
  19. const [id, setId] = useState<number>(0)
  20. /**********************/
  21. /**加载组件或数据更新执行请求列表 */
  22. useEffect(() => {
  23. if (belongUser === '1' || belongUser === '0') {
  24. getList()
  25. }
  26. }, [mediaType, belongUser, parentId])
  27. return <div className={style.colud}>
  28. <Tabs
  29. type="card"
  30. onChange={(activeKey: any) => {
  31. init({ mediaType: activeKey })//切换类型时先初始化数据,并设置类型
  32. }}
  33. className={style.card}
  34. activeKey={mediaType}
  35. >
  36. {
  37. ['IMG', 'VIDEO', 'PAGE'].map((key: any) => {
  38. return <TabPane tab={typeEnum[key]} key={key} style={{ backgroundColor: '#fff', padding: '0 15px' }} >
  39. <Tabs onChange={(activeKey: any) => { set({ belongUser: activeKey }) }} activeKey={belongUser} tabBarExtraContent={<Space>
  40. {
  41. mediaType === 'PAGE' ? <Button type="primary" size='small' onClick={() => { setVisible(true) }}>新建素材</Button> : <Button size='small' type="primary" onClick={() => { set({ imgVisrible: true }) }}>新建素材</Button>
  42. }
  43. <Tooltip title="功能都在下方内容区右键" placement="left">
  44. <QuestionCircleFilled />
  45. </Tooltip>
  46. </Space>}>
  47. <TabPane tab={'个人本地'} key={1} />
  48. <TabPane tab={'公共本地'} key={0} />
  49. </Tabs>
  50. <FlieBox setPage={(type, data) => {
  51. setId(data || 0)
  52. if (type === 0 || type === 2) {
  53. setVisible(true)
  54. } else if (type === 1) {
  55. setLookVisible(true)
  56. } else if (type) {
  57. setCopyVisible(true)
  58. }
  59. }} />
  60. </TabPane>
  61. })
  62. }
  63. </Tabs>
  64. {/* 落地页新增 复制 */}
  65. {visible && <AddLandingPage visible={visible} hideModal={() => setVisible(false)} ajax={list} id={id} />}
  66. {/* 查看落地页 */}
  67. {lookVisible && <LookLanding visible={lookVisible} onClose={() => setLookVisible(false)} id={id} />}
  68. {/* 批量复制 */}
  69. {copyVisible && <BathLauCopy visible={copyVisible} onClose={() => setCopyVisible(false)} id={id} ajaxHome={list} />}
  70. </div>
  71. }
  72. export default HocError(Cloud)