|
@@ -0,0 +1,67 @@
|
|
|
+
|
|
|
+import { useAjax } from '@/Hook/useAjax'
|
|
|
+import { PromotedObjectType } from '@/services/launchAdq/enum'
|
|
|
+import { Col, Row, Input, Select, Button, message } from 'antd'
|
|
|
+import React, { useEffect, useState, useCallback } from 'react'
|
|
|
+import TableData from '../../components/TableData'
|
|
|
+import tableConfig from './tableConfig'
|
|
|
+import { putAdqAdgroupsSync, getAdqAdAccountList } from '@/services/launchAdq/adq'
|
|
|
+
|
|
|
+function AdAccount(props: { accountId: string, adAccountId: string ,userId:string}) {
|
|
|
+ let { accountId, adAccountId,userId } = props
|
|
|
+ // api方法
|
|
|
+ const listAjax = useAjax((params) => getAdqAdAccountList(params), { formatResult: true })
|
|
|
+ const syncAjax = useAjax((adAccountId) => putAdqAdgroupsSync(adAccountId))
|
|
|
+ console.log('创意=====》')
|
|
|
+ useEffect(() => {
|
|
|
+ getList({ pageNum: 1, pageSize: 20 })
|
|
|
+ }, [accountId,userId])
|
|
|
+ // 获取列表
|
|
|
+ const getList = useCallback((params: {
|
|
|
+ pageNum: number;
|
|
|
+ pageSize: number;
|
|
|
+ accountId?: string;
|
|
|
+ adcreativeName?: string;
|
|
|
+ }) => {
|
|
|
+ if (!params.adcreativeName || params.adcreativeName !== listAjax?.params[0]?.adcreativeName) {
|
|
|
+ !params.adcreativeName && delete params.adcreativeName
|
|
|
+ listAjax.run({ ...params,userId, accountId })
|
|
|
+ }
|
|
|
+ }, [accountId,userId,listAjax])
|
|
|
+ // 同步
|
|
|
+ const sync = useCallback(() => {
|
|
|
+ if(!adAccountId){
|
|
|
+ message.error('请先选择要同步的广点通账号!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ syncAjax.run({adAccountId}).then(res => {
|
|
|
+ res && listAjax.refresh()
|
|
|
+ res ? message.success('同步成功!') : message.error('同步失败!')
|
|
|
+
|
|
|
+ })
|
|
|
+ }, [adAccountId, listAjax])
|
|
|
+ return <div>
|
|
|
+ <TableData
|
|
|
+ columns={tableConfig}
|
|
|
+ ajax={listAjax}
|
|
|
+ syncAjax={sync}
|
|
|
+ dataSource={listAjax?.data?.data?.records}
|
|
|
+ loading={listAjax?.loading || syncAjax?.loading}
|
|
|
+ scroll={{ x: 2500 }}
|
|
|
+ total={listAjax?.data?.data?.total}
|
|
|
+ page={listAjax?.data?.data?.current}
|
|
|
+ pageSize={listAjax?.data?.data?.size}
|
|
|
+ myKey={'adgroupId'}
|
|
|
+ leftChild={<>
|
|
|
+ <Row gutter={[10, 10]}>
|
|
|
+ </Row>
|
|
|
+ </>}
|
|
|
+ onChange={(props: any) => {
|
|
|
+ // let { sortData, pagination } = props
|
|
|
+ // let { current, pageSize } = pagination
|
|
|
+ // getList({ pageNum: current, pageSize })
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+}
|
|
|
+export default AdAccount
|