| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 | 
							- import React, { useEffect, useCallback } from 'react'
 
- import { Col, Input, message, Row } from 'antd'
 
- import { useAjax } from '@/Hook/useAjax'
 
- import { getAdqTargetingList, putAdqTargetingSyncAll } from '@/services/launchAdq/adq'
 
- import TableData from '../../components/TableData'
 
- import tableConfig from './tableConfig'
 
- function Targeting(props: { adAccountId: any, userId: string, accountId: any, tableIdClick: any }) {
 
-     let { accountId, adAccountId, userId, tableIdClick } = props
 
-     const listAjax = useAjax((params) => getAdqTargetingList(params), { formatResult: true })
 
-     const syncAjax = useAjax((adAccountId) => putAdqTargetingSyncAll(adAccountId))
 
-     console.log('定向=====》')
 
-     useEffect(() => {
 
-         getList({ pageNum: 1, pageSize: 20, accountId })
 
-     }, [userId, accountId])
 
-     // 获取列表
 
-     const getList = useCallback((params: {
 
-         pageNum: number;
 
-         pageSize: number;
 
-         accountId?: string;
 
-         targetingName?: string;
 
-     }) => {
 
-         console.log(accountId)
 
-         if (!params.targetingName || params.targetingName !== listAjax?.params[0]?.targetingName) {
 
-             !params.targetingName && delete params.targetingName
 
-             listAjax.run({ ...params, userId })
 
-         }
 
-     }, [listAjax, userId])
 
-     // 同步 
 
-     const sync = useCallback(() => {
 
-         if (!adAccountId) {
 
-             message.error('请先选择要同步的广点通账号!')
 
-             return
 
-         }
 
-         syncAjax.run(adAccountId).then(res => {
 
-             console.log(res)
 
-             res && listAjax.refresh()
 
-             res ? message.success('同步成功!') : message.error('同步失败!')
 
-         })
 
-     }, [adAccountId, listAjax])
 
-     return <div>
 
-         <TableData
 
-             isCard={false}
 
-             columns={() => tableConfig(tableIdClick)}
 
-             ajax={listAjax}
 
-             syncAjax={sync}
 
-             dataSource={listAjax?.data?.data?.records}
 
-             loading={listAjax?.loading || syncAjax?.loading}
 
-             scroll={{ x: 2000, y: 550 }}
 
-             total={listAjax?.data?.data?.total}
 
-             page={listAjax?.data?.data?.current}
 
-             pageSize={listAjax?.data?.data?.size}
 
-             myKey={'targetingId'}
 
-             leftChild={<>
 
-                 <Row gutter={[10, 10]}>
 
-                     <Col>
 
-                         <Input
 
-                             placeholder='广告账号'
 
-                             allowClear
 
-                             style={{ width: 150 }}
 
-                             onBlur={(e) => {
 
-                                 let value = e.target.value
 
-                                 getList({ pageNum: 1, pageSize: 20, accountId: value })
 
-                             }}
 
-                             onKeyDownCapture={(e: any) => {
 
-                                 let key = e.key
 
-                                 if (key === 'Enter') {
 
-                                     let value = e.target.value
 
-                                     getList({ pageNum: 1, pageSize: 20, accountId: value })
 
-                                 }
 
-                             }}
 
-                             onChange={(e) => {
 
-                                 let value = e.target.value
 
-                                 if (!value) {
 
-                                     getList({ pageNum: 1, pageSize: 20, accountId: value })
 
-                                 }
 
-                             }}
 
-                         />
 
-                     </Col>
 
-                     <Col>
 
-                         <Input
 
-                             placeholder='定向名称'
 
-                             allowClear
 
-                             style={{ width: 150 }}
 
-                             onBlur={(e) => {
 
-                                 let value = e.target.value
 
-                                 getList({ pageNum: 1, pageSize: 20, targetingName: value })
 
-                             }}
 
-                             onKeyDownCapture={(e: any) => {
 
-                                 let key = e.key
 
-                                 if (key === 'Enter') {
 
-                                     let value = e.target.value
 
-                                     getList({ pageNum: 1, pageSize: 20, targetingName: value })
 
-                                 }
 
-                             }}
 
-                             onChange={(e) => {
 
-                                 let value = e.target.value
 
-                                 if (!value) {
 
-                                     getList({ pageNum: 1, pageSize: 20, targetingName: value })
 
-                                 }
 
-                             }}
 
-                         />
 
-                     </Col>
 
-                 </Row>
 
-             </>}
 
-             onChange={(props: any) => {
 
-                 let { sortData, pagination } = props
 
-                 let { current, pageSize } = pagination
 
-                 getList({ pageNum: current, pageSize })
 
-             }}
 
-         />
 
-     </div>
 
- }
 
- export default Targeting
 
 
  |