|
@@ -5,7 +5,7 @@ import { Col, Row, Input, Select, message, Space, Button, Popconfirm, Switch, no
|
|
|
import React, { useEffect, useCallback, useState } from 'react'
|
|
|
import TableData from '../../components/TableData'
|
|
|
import tableConfig from './tableConfig'
|
|
|
-import { putAdqAdgroupsSync, getAdqAdgroupsList, delListAdqAdgroupsApi, newEditAdqAdgroupsDataApi, editAdqAdgroupsDataApi, putAdqAdgroupsSyncBatch } from '@/services/launchAdq/adq'
|
|
|
+import { putAdqAdgroupsSync, getAdqAdgroupsList, delListAdqAdgroupsApi, newEditAdqAdgroupsDataApi, editAdqAdgroupsDataApi, putAdqAdgroupsSyncBatch, putModifyCustomAudienceApi } from '@/services/launchAdq/adq'
|
|
|
import { CopyOutlined, DeleteOutlined, FieldTimeOutlined, PauseCircleOutlined, PlayCircleOutlined, SyncOutlined, TransactionOutlined } from '@ant-design/icons'
|
|
|
import UpdateAd from './updateAd'
|
|
|
import Copy from './copy'
|
|
@@ -14,6 +14,7 @@ import { txAdConfig } from '../config'
|
|
|
import Log from '../log'
|
|
|
import EarlyWarning from '@/components/EarlyWarning'
|
|
|
import SetEarlyWarning from '@/components/EarlyWarning/setEarlyWarning'
|
|
|
+import CrowdPackModal from '../../components/crowdPackModal'
|
|
|
|
|
|
type Props = {
|
|
|
accountId?: string,
|
|
@@ -51,6 +52,8 @@ const Ad: React.FC<Props> = (props) => {
|
|
|
const [detailShow, setDetailShow] = useState<boolean>(false)
|
|
|
const [detailData, setDetailData] = useState<any>({})
|
|
|
const [czjlShow, setCzjlShow] = useState(false)
|
|
|
+ const [cpVisible, setCpVisible] = useState(false)
|
|
|
+ const [accountCreateLogs, setAccountCreateLogs] = useState<{ adAccountId: number, id: number, customAudienceList?: any[], excludedCustomAudienceList?: any[] }[]>([])
|
|
|
const [queryFrom, set_queryFrom] = useState<{
|
|
|
pageNum: number;
|
|
|
pageSize: number;
|
|
@@ -69,6 +72,7 @@ const Ad: React.FC<Props> = (props) => {
|
|
|
const delListAdqAdgroups = useAjax((params) => delListAdqAdgroupsApi(params))
|
|
|
const editAdqAdgroupsData = useAjax((params) => newEditAdqAdgroupsDataApi(params))
|
|
|
const editAdqAdgroups = useAjax((params) => editAdqAdgroupsDataApi(params))
|
|
|
+ const putModifyCustomAudience = useAjax((params) => putModifyCustomAudienceApi(params))
|
|
|
const putAdqAdgroupsSyncBatchApi = useAjax((params) => putAdqAdgroupsSyncBatch(params))
|
|
|
/************************/
|
|
|
|
|
@@ -192,6 +196,46 @@ const Ad: React.FC<Props> = (props) => {
|
|
|
setDetailData(data)
|
|
|
setDetailShow(true)
|
|
|
}
|
|
|
+
|
|
|
+ // 设置人群包
|
|
|
+ const setRqb = () => {
|
|
|
+ const { accountId } = selectedRows[0]
|
|
|
+ setAccountCreateLogs([{ id: accountId, adAccountId: accountId }])
|
|
|
+ setCpVisible(true)
|
|
|
+ }
|
|
|
+
|
|
|
+ // 确认提交人群包
|
|
|
+ const handleRqb = (value: any[]) => {
|
|
|
+
|
|
|
+ if ((value[0]?.customAudienceList && value[0]?.customAudienceList?.length > 0) || (value[0]?.excludedCustomAudienceList && value[0]?.excludedCustomAudienceList?.length > 0)) {
|
|
|
+ let { adAccountId, customAudienceList = [], excludedCustomAudienceList = [] } = value[0]
|
|
|
+ let adgroupIds = selectedRows.map((item: { adgroupId: number }) => item.adgroupId)
|
|
|
+ let customAudienceIds = customAudienceList.map((item: { id: number }) => item.id)
|
|
|
+ let excludedCustomAudienceIds = excludedCustomAudienceList.map((item: { id: number }) => item.id)
|
|
|
+
|
|
|
+ const hide = message.loading('正在修改。。。', 0)
|
|
|
+
|
|
|
+ setAccountCreateLogs([])
|
|
|
+ setCpVisible(false)
|
|
|
+ let params: any = { adAccountId, adgroupIds };
|
|
|
+ if (excludedCustomAudienceIds.length > 0) {
|
|
|
+ params['excludedCustomAudienceIds'] = excludedCustomAudienceIds
|
|
|
+ }
|
|
|
+ if (customAudienceIds?.length > 0) {
|
|
|
+ params['customAudienceIds'] = customAudienceIds
|
|
|
+ }
|
|
|
+ putModifyCustomAudience.run(params).then(res => {
|
|
|
+ hide()
|
|
|
+ setSelectedRows([])
|
|
|
+ message.success('修改成功,请到腾讯广告平台查看')
|
|
|
+ }).catch(err => hide())
|
|
|
+ } else {
|
|
|
+ message.error('请选择用户群')
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log('selectedRows--->', selectedRows)
|
|
|
+
|
|
|
return <div>
|
|
|
{/* 修改广告 */}
|
|
|
{update.visible && <UpdateAd
|
|
@@ -380,15 +424,16 @@ const Ad: React.FC<Props> = (props) => {
|
|
|
leftChild={<Space direction='vertical'>
|
|
|
<Row gutter={[10, 10]} align='middle'>
|
|
|
<Col>
|
|
|
- <Switch checkedChildren="普通模式" unCheckedChildren="深度优化" checked={model} onChange={(checked) => { setModel(checked); setSelectedRows([]) }} style={model ? {} : { background: '#67c23a' }} />
|
|
|
+ <Switch checkedChildren="普通" unCheckedChildren="ROI" checked={model} onChange={(checked) => { setModel(checked); setSelectedRows([]) }} style={model ? {} : { background: '#67c23a' }} />
|
|
|
</Col>
|
|
|
{model ? <>
|
|
|
<Col><Button type='primary' style={{ background: '#1890ff' }} icon={<FieldTimeOutlined />} disabled={selectedRows.length === 0} onClick={editScheduling}>修改排期出价名称</Button></Col>
|
|
|
<Col><Button type='primary' style={{ background: '#1890ff' }} icon={<CopyOutlined />} disabled={selectedRows.length === 0} onClick={copyHandle}>复制</Button></Col>
|
|
|
<Col><Button type='primary' style={{ background: '#67c23a', borderColor: '#67c23a' }} loading={editAdqAdgroupsData.loading} icon={<PlayCircleOutlined />} disabled={selectedRows.length === 0} onClick={() => adStatus('play')}>启动</Button></Col>
|
|
|
<Col><Button type='primary' style={{ background: '#e6a23c', borderColor: '#e6a23c' }} loading={editAdqAdgroupsData.loading} icon={<PauseCircleOutlined />} disabled={selectedRows.length === 0} onClick={() => adStatus('suspend')}>暂停</Button></Col>
|
|
|
+ <Col><Button type='primary' loading={putModifyCustomAudience.loading} disabled={selectedRows.length > 0 ? !selectedRows.every((item: { accountId: number }) => item.accountId === selectedRows[0].accountId) : true} onClick={() => setRqb()}>修改人群包</Button></Col>
|
|
|
<Col><Button type='primary' style={{ background: '#00bcd4', borderColor: '#00bcd4' }} loading={putAdqAdgroupsSyncBatchApi.loading} icon={<SyncOutlined />} disabled={selectedRows.length === 0} onClick={syncAd}>同步广告</Button></Col>
|
|
|
- <Col><SetEarlyWarning selectedRows={selectedRows} onChange={() => listAjax.refresh()}/></Col>
|
|
|
+ <Col><SetEarlyWarning selectedRows={selectedRows} onChange={() => listAjax.refresh()} /></Col>
|
|
|
<Col>
|
|
|
<Popconfirm
|
|
|
title="确定删除?"
|
|
@@ -426,7 +471,7 @@ const Ad: React.FC<Props> = (props) => {
|
|
|
selectedRows.push({ ...record })
|
|
|
setSelectedRows([...selectedRows])
|
|
|
} else {
|
|
|
- let newSelectAccData = selectedRows.filter((item: { adgroupId: number }) => item.adgroupId!== record.adgroupId)
|
|
|
+ let newSelectAccData = selectedRows.filter((item: { adgroupId: number }) => item.adgroupId !== record.adgroupId)
|
|
|
setSelectedRows([...newSelectAccData])
|
|
|
}
|
|
|
},
|
|
@@ -473,6 +518,7 @@ const Ad: React.FC<Props> = (props) => {
|
|
|
>
|
|
|
<Log {...props} />
|
|
|
</Modal>}
|
|
|
+ {cpVisible && <CrowdPackModal visible={cpVisible} data={accountCreateLogs} onClose={() => setCpVisible(false)} onChange={(e) => { handleRqb(e) }} />}
|
|
|
</div>
|
|
|
}
|
|
|
export default Ad
|