index.tsx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import Ad from "@/pages/launchSystemNew/adq/ad"
  2. import { Card, Select, Tabs } from "antd"
  3. import React, { useEffect, useState } from "react"
  4. import { useModel } from "umi"
  5. import Monitor from "./monitor"
  6. import PlanList from "./planList"
  7. const AdMonitorList: React.FC = () => {
  8. // 变量开始
  9. const [tab, setTab] = useState<string>('monitor') // tab切换
  10. const { getPlanList, getPlanDetailList, getAllPlanList } = useModel('useAdMonitor.useMonitor')
  11. const [userId, setUserId] = useState(localStorage.getItem("userId") as string)
  12. const { getPicherList } = useModel('useOperating.useWxGroupList')
  13. // 变量结束
  14. // 获取投手
  15. useEffect(() => {
  16. !getPicherList.data && getPicherList.run()
  17. }, [])
  18. return <div className="adMonitorList">
  19. <Tabs activeKey={tab} className="adMonitorListTab" size="small" type="card" onChange={(activeKey: string) => {
  20. if (activeKey === 'monitor') {
  21. getAllPlanList.data && getAllPlanList.mutate([])
  22. } else {
  23. getPlanList.data && getPlanList.mutate([])
  24. getPlanDetailList.data && getPlanDetailList.mutate([])
  25. }
  26. setTab(activeKey)
  27. }}>
  28. <Tabs.TabPane tab="今日起量广告监控" key="monitor" />
  29. <Tabs.TabPane tab="广告列表" key="list" />
  30. <Tabs.TabPane tab="广告列表2" key="list2" />
  31. </Tabs>
  32. {tab === 'monitor' ? <Monitor onChange={() => { setTab('list') }} /> : tab === 'list' ? <PlanList /> : <Card><Ad userId={userId} Ts={()=>{
  33. return <Select
  34. showSearch
  35. value={userId ? Number(userId) : undefined}
  36. style={{ minWidth: 180, maxWidth: 250 }}
  37. maxTagCount={1}
  38. allowClear
  39. placeholder="请选择投手"
  40. // disabled={queryForm?.adgroup || queryForm?.accountId?.length > 0}
  41. onChange={(value) => {
  42. setUserId(value?.toString() || '')
  43. }}
  44. filterOption={(input, option) =>
  45. (option?.children as any).toLowerCase().indexOf(input.toLowerCase()) >= 0
  46. }
  47. >
  48. {getPicherList?.data?.map((item: { nickname: string, userId: number }, index: number) =>
  49. <Select.Option
  50. value={item.userId}
  51. key={item.userId + '' + index}
  52. >
  53. {item.nickname}
  54. </Select.Option>
  55. )}
  56. </Select>
  57. }}/></Card>}
  58. </div>
  59. }
  60. export default AdMonitorList