|
@@ -1,7 +1,8 @@
|
|
|
-import React, { useState, useEffect } from 'react'
|
|
|
-import { Card, Col, Menu, Row, Select, Tabs } from 'antd';
|
|
|
+import React, { useState, useEffect, useCallback } from 'react'
|
|
|
+import { Badge, Card, Col, Menu, Row, Select, Tabs, Tag } from 'antd';
|
|
|
// import './index.less'
|
|
|
import Campaign from './campaign';
|
|
|
+import AdAccount from './adAccount';
|
|
|
import Ad from './ad';
|
|
|
import Creative from './creative';
|
|
|
import LandingPage from './landingPage';
|
|
@@ -13,8 +14,8 @@ import { useModel } from 'umi';
|
|
|
const { TabPane } = Tabs;
|
|
|
let Menus: any = Menu
|
|
|
const tabsConfig = [
|
|
|
- { key: '1', tab: '账户信息', jsx: () => null },
|
|
|
- { key: '2', tab: '计划', jsx:(props: any) => <Campaign {...props} />},
|
|
|
+ { key: '1', tab: '账户信息', jsx: (props: any) => <AdAccount {...props} /> },
|
|
|
+ { key: '2', tab: '计划', jsx: (props: any) => <Campaign {...props} /> },
|
|
|
{ key: '3', tab: '广告', jsx: (props: any) => <Ad {...props} /> },
|
|
|
{ key: '4', tab: '创意', jsx: (props: any) => <Creative {...props} /> },
|
|
|
{ key: '5', tab: '落地页', jsx: (props: any) => <LandingPage {...props} /> },
|
|
@@ -24,13 +25,39 @@ function Adq() {
|
|
|
const userInfo = useModel('@@initialState', model => model.initialState?.currentUser)
|
|
|
const allOfMember = useAjax(() => getAdAccountAllOfMember(), { formatResult: true })
|
|
|
const [userAll, setUserAll] = useState([])
|
|
|
- const [activeKey, setActiveKey] = useState('2')
|
|
|
- const [userId, setUserId] = useState<any>('1'||userInfo?.userId?.toString())
|
|
|
+ const [activeKey, setActiveKey] = useState('1')
|
|
|
+ const [userId, setUserId] = useState<any>(userInfo?.userId?.toString())
|
|
|
const [selectedArr, setSelectedArr] = useState([])
|
|
|
+ const [queryParmas, setQueryParmas] = useState({
|
|
|
+ accountId: '',//账户ID
|
|
|
+ campaignId: '',//计划ID
|
|
|
+ adgroupId: '',//广告ID
|
|
|
+ adcreativeId: '',//创意ID
|
|
|
+ pageId: '',//落地页ID
|
|
|
+ targetingId: '',//定向ID
|
|
|
+ })
|
|
|
const [idS, setIds] = useState({//需要用到的accountId,adAccountId
|
|
|
accountId: '',
|
|
|
adAccountId: ''
|
|
|
})
|
|
|
+ // 点击table中的ID添加对应条件
|
|
|
+ const tableIdClick = useCallback((props: {
|
|
|
+ activeKey: string, parma: {
|
|
|
+ accountId?: string,//账户ID
|
|
|
+ campaignId?: string,//计划ID
|
|
|
+ adgroupId?: string,//广告ID
|
|
|
+ adcreativeId?: string,//创意ID
|
|
|
+ pageId?: string,//落地页ID
|
|
|
+ targetingId?: string,//定向ID
|
|
|
+ }
|
|
|
+ }) => {
|
|
|
+ // 暂时注释不开放
|
|
|
+ // let { activeKey, parma } = props
|
|
|
+ // setQueryParmas({ ...queryParmas, ...parma })
|
|
|
+ // setActiveKey(activeKey)
|
|
|
+
|
|
|
+ }, [queryParmas, activeKey])
|
|
|
+ // 获取组员
|
|
|
useEffect(() => {
|
|
|
allOfMember.run().then(res => {
|
|
|
if (res?.data) {
|
|
@@ -52,15 +79,35 @@ function Adq() {
|
|
|
}
|
|
|
})
|
|
|
}, [])
|
|
|
+ //选中的组员的子账号
|
|
|
useEffect(() => {
|
|
|
if (userAll.length > 0 && userId) {
|
|
|
let newArr: any = userAll?.filter((item: any) => item.key == userId)
|
|
|
setSelectedArr(newArr[0]?.childrenarr || [])
|
|
|
}
|
|
|
}, [userAll, userId])
|
|
|
- console.log('selectedArr===>', selectedArr)
|
|
|
+ // 用户点击table中的账号ID处理
|
|
|
+ useEffect(() => {
|
|
|
+ if (selectedArr.length > 0 && queryParmas.accountId) {
|
|
|
+ let obj: any = selectedArr?.filter((item: any) => item.key.includes(queryParmas.accountId))[0]
|
|
|
+ if (obj) {
|
|
|
+ let arr = obj.key.split('_')
|
|
|
+ setIds({ accountId: arr[0], adAccountId: arr[1] })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, [queryParmas, selectedArr])
|
|
|
+ // 初始跳转到自己的名称
|
|
|
+ useEffect(() => {
|
|
|
+ if (userAll?.length > 0 && userInfo?.userId) {
|
|
|
+ let topEq = userAll?.findIndex((item: any) => item.key == userInfo?.userId)
|
|
|
+ let em:any = document.getElementById('myMenus')
|
|
|
+ if (em) {
|
|
|
+ em.scrollTop=52 * topEq - 36
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, [userInfo?.userId, userAll])
|
|
|
return <Row style={{ position: 'relative' }}>
|
|
|
- <Col style={{ height: '100%', overflowY: 'auto', position: 'absolute', left: 0, top: 0, bottom: 0, width: 150, background: '#fff' }}>
|
|
|
+ <Col id='myMenus' style={{ height: '100%', overflowY: 'auto', position: 'absolute', left: 0, top: 0, bottom: 0, width: 150, background: '#fff' }}>
|
|
|
<Menus
|
|
|
theme='light'
|
|
|
onClick={(e: any) => {//点击菜单
|
|
@@ -75,18 +122,24 @@ function Adq() {
|
|
|
<Col span={21} style={{ marginLeft: 150 }}>
|
|
|
<Card>
|
|
|
<Tabs activeKey={activeKey} type="card" onChange={(activeKey) => { setActiveKey(activeKey) }} tabBarExtraContent={
|
|
|
- <Select placeholder='广点通账号' style={{ minWidth: 200 }} showSearch filterOption={(input: any, option: any) =>
|
|
|
- (option!.children as unknown as string).toLowerCase().includes(input.toLowerCase())
|
|
|
- } allowClear onChange={(value: any) => {
|
|
|
- let accountId = ''
|
|
|
- let adAccountId = ''
|
|
|
- if (value) {
|
|
|
- let arr = value.split('_')
|
|
|
- accountId = arr[0]
|
|
|
- adAccountId = arr[1]
|
|
|
- }
|
|
|
- setIds({ accountId, adAccountId })
|
|
|
- }} >
|
|
|
+ <Select
|
|
|
+ placeholder='广点通账号'
|
|
|
+ style={{ minWidth: 200 }}
|
|
|
+ showSearch
|
|
|
+ filterOption={(input: any, option: any) =>
|
|
|
+ (option!.children as unknown as string).toLowerCase().includes(input.toLowerCase())
|
|
|
+ } allowClear onChange={(value: any) => {
|
|
|
+ let accountId = ''
|
|
|
+ let adAccountId = ''
|
|
|
+ if (value) {
|
|
|
+ let arr = value.split('_')
|
|
|
+ accountId = arr[0]
|
|
|
+ adAccountId = arr[1]
|
|
|
+ }
|
|
|
+ setIds({ accountId, adAccountId })
|
|
|
+ }}
|
|
|
+ value={idS.accountId ? idS.accountId + '_' + idS.adAccountId : null}
|
|
|
+ >
|
|
|
{
|
|
|
selectedArr?.map((item: any) => {
|
|
|
return <Select.Option value={item.key} key={item.key}>{item.label}</Select.Option>
|
|
@@ -97,7 +150,45 @@ function Adq() {
|
|
|
{
|
|
|
tabsConfig?.map(item => {
|
|
|
return <TabPane tab={item.tab} key={item.key} >
|
|
|
- {activeKey=== item.key && item.jsx({...idS, userId })}
|
|
|
+ <>
|
|
|
+ {/* 点击了列表中的ID默认展示并搜索对应ID条件 */}
|
|
|
+ <Row >
|
|
|
+ <Col>
|
|
|
+ {
|
|
|
+ Object.keys(queryParmas)?.filter(key => queryParmas[key])?.map(key => {
|
|
|
+ enum nameEnum {
|
|
|
+ accountId = '账户ID',
|
|
|
+ campaignId = '计划ID',
|
|
|
+ adgroupId = '广告ID',
|
|
|
+ adcreativeId = '创意ID',
|
|
|
+ pageId = '落地页ID',
|
|
|
+ targetingId = '定向ID',
|
|
|
+ }
|
|
|
+ return <Badge
|
|
|
+ key={key}
|
|
|
+ count={
|
|
|
+ <span
|
|
|
+ style={{ width: 14, height: 14, borderRadius: '50%', background: '#ff4d4f', boxShadow: '0 0 0 1px #fff', color: '#fff', textAlign: 'center' }}
|
|
|
+ onClick={() => {
|
|
|
+ setQueryParmas({ ...queryParmas, [key]: '' })
|
|
|
+ setIds({
|
|
|
+ accountId: '',
|
|
|
+ adAccountId: ''
|
|
|
+ })
|
|
|
+ }}
|
|
|
+ >x</span>}
|
|
|
+ size='small'
|
|
|
+ offset={[-20, 2]}
|
|
|
+ style={{ cursor: 'pointer' }}
|
|
|
+ >
|
|
|
+ <Tag style={{ marginRight: 20, marginBottom: 20 }}>{nameEnum[key]}:{queryParmas[key]}</Tag>
|
|
|
+ </Badge>
|
|
|
+ })
|
|
|
+ }
|
|
|
+ </Col>
|
|
|
+ </Row>
|
|
|
+ {activeKey === item.key && item.jsx({ ...idS, userId, queryParmas, tableIdClick })}
|
|
|
+ </>
|
|
|
</TabPane>
|
|
|
})
|
|
|
}
|