index.tsx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. import { useAjax } from "@/Hook/useAjax"
  2. import { IdcardFilled, MenuFoldOutlined, MenuUnfoldOutlined } from "@ant-design/icons"
  3. import { Select, Menu, Spin, Button, Card, Tabs } from "antd"
  4. import React, { useEffect, useState } from "react"
  5. import { useModel } from "umi"
  6. import style from '../../launchSystemNew/adq/index.less'
  7. import { getPicherListApi } from "@/services/operating/account"
  8. import Ad from "./ad"
  9. import Creative from "./creative"
  10. const AdqV3: React.FC = () => {
  11. /****************************/
  12. const userInfo = useModel('@@initialState', model => model.initialState?.currentUser)
  13. const allOfMember = useAjax(() => getPicherListApi(), { formatResult: true })
  14. const [userAll, setUserAll] = useState([])
  15. const [activeKey, setActiveKey] = useState('1')
  16. const [userId, setUserId] = useState<any>(userInfo?.userId?.toString())
  17. const [hide, setHide] = useState<boolean>(false)
  18. const [queryForm, setQueryForm] = useState<ADQV3.GetDynamicCreativeProps>({ pageNum: 1, pageSize: 20, userId })
  19. /****************************/
  20. // 获取组员
  21. useEffect(() => {
  22. allOfMember.run().then(res => {
  23. if (res?.data) {
  24. let useAll: any = []
  25. res?.data?.forEach((item: { userId: number; nickname: any; }) => {
  26. let obj = {
  27. key: item.userId,
  28. label: item.nickname,
  29. icon: <IdcardFilled />,
  30. }
  31. useAll.push(obj)
  32. })
  33. setUserAll(useAll)
  34. }
  35. })
  36. }, [])
  37. // // 初始跳转到自己的名称
  38. useEffect(() => {
  39. if (userAll?.length > 0 && userId) {
  40. let topEq = userAll?.findIndex((item: any) => item.key == userId)
  41. let em: any = document.getElementById('myMenus1')
  42. console.log(topEq)
  43. if (em) {
  44. em.scrollTop = (52 - 4) * topEq
  45. }
  46. }
  47. }, [userId, userAll])
  48. const creativeHandle = (id: number) => {
  49. setQueryForm({ ...queryForm, adgroupId: id })
  50. setActiveKey('2')
  51. }
  52. return <div className={style.adq}>
  53. {!hide && <div className={style.left}>
  54. <Spin spinning={allOfMember.loading}>
  55. <div>
  56. <Select
  57. placeholder='名称搜索'
  58. style={{ width: '100%' }}
  59. showSearch
  60. filterOption={(input: any, option: any) => {
  61. return (option!?.children as unknown as string)?.toLowerCase()?.includes(input?.toLowerCase())
  62. }}
  63. allowClear
  64. onChange={(value: any) => {
  65. if (value) {
  66. setUserId(value.toString())
  67. }
  68. }}
  69. loading={allOfMember.loading}
  70. >
  71. {userAll.map((item: any) => {
  72. return <Select.Option value={item.key} key={item.key}>{item.label}</Select.Option>
  73. })}
  74. </Select>
  75. <Menu
  76. id='myMenus1'
  77. theme='light'
  78. onClick={(e: any) => {//点击菜单
  79. setUserId(e.key)
  80. }}
  81. selectedKeys={userId}
  82. mode="inline"
  83. multiple={false}
  84. items={userAll}
  85. style={{
  86. overflowY: 'auto',
  87. height: 'calc(100vh - 150px)',
  88. overflowX: 'hidden'
  89. }}
  90. />
  91. </div>
  92. </Spin>
  93. </div>}
  94. <div className={style.right} style={!hide ? { width: 'calc(100% - 150px)' } : { width: '100%' }}>
  95. <div className={style.hiddenBtn}><Button size='small' type="primary" onClick={() => setHide(!hide)} icon={!hide ? <MenuFoldOutlined /> : <MenuUnfoldOutlined />} /></div>
  96. <Card bodyStyle={{ padding: '12px 16px' }}>
  97. <Tabs activeKey={activeKey} size="small" type="card" onChange={(activeKey) => { setActiveKey(activeKey) }}>
  98. <Tabs.TabPane tab={'广告'} key='1' >
  99. <Ad userId={userId} creativeHandle={creativeHandle} />
  100. </Tabs.TabPane>
  101. <Tabs.TabPane tab={'创意'} key='2' >
  102. <Creative queryForm={queryForm} setQueryForm={setQueryForm} userId={userId}/>
  103. </Tabs.TabPane>
  104. </Tabs>
  105. </Card>
  106. </div>
  107. </div>
  108. }
  109. export default AdqV3