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