import { useAjax } from "@/Hook/useAjax"; import { DeleteOutlined, DownOutlined, PauseCircleOutlined, PlayCircleOutlined, PlusOutlined, QuestionCircleOutlined } from "@ant-design/icons"; import { Button, Checkbox, Col, DatePicker, Dropdown, Input, Menu, Modal, Row, Select, Space, Tooltip, Typography, message } from "antd" import React, { useCallback, useEffect, useState } from "react" import { ADGROUP_STATUS } from "../const"; import { getAdqV3AdListApi, modifyStatusBatchApi, syncBatchApi } from "@/services/launchAdq/adqv3"; import tableConfig from "./tableConfig"; import { txAdConfig } from "../config"; import UpdateAd from "./updateAd"; import TableData from "@/pages/launchSystemNew/components/TableData"; import AddDynamic from "../../tencentAdPutIn/create/addDynamic"; import { arraysHaveSameValues } from "@/utils/utils"; import { MARKETING_CARRIER_TYPE_ENUM, MARKETING_GOAL_ENUM, MARKETING_SUB_GOAL_ENUM, MARKETING_TARGET_TYPE_ENUM, MARKETING_TARGET_TYPE_GAME_ENUM, SITE_SET_ENUM } from "../../tencentAdPutIn/const"; import Log from "../components/log"; import '../../tencentAdPutIn/index.less' import UserTactics from "../../tencentAdPutIn/create/TacticsS/userTactics"; import UpdateAd3 from "./updateAd3"; import { useLocalStorageState } from "ahooks"; import AutoAcquisitionSet from "./autoAcquisitionSet"; const { Text } = Typography; const Ad: React.FC = ({ userId, creativeHandle }) => { /*****************************************/ const [useType, setUseType] = useLocalStorageState('AD_UNIT_TYPE', 'NOVEL'); const [pageSize, setPageSize] = useLocalStorageState('AD_PAGESIZE', 20); const [queryFrom, set_queryFrom] = useState({ pageNum: 1, pageSize: pageSize || 20, adUnitType: 'NOVEL' }) const [isClearSelect, setIsClearSelect] = useState(true) const [selectedRows, setSelectedRows] = useState([]) const [tactics, setTactics] = useState() const [update, setUpdate] = useState<{ visible: boolean }>({ visible: false }) const [addDynamicVisible, setAddDynamicVisible] = useState(false) const [handleType, setHandleType] = useState(1) const [czjlShow, setCzjlShow] = useState(false) const [updateData, setUpdateDate] = useState<{ visible: boolean, type: '修改出价' | '修改名称' | '修改日限额' | '修改投放时间' | '删除' | '深度优化ROI' | '修改投放首日开始时间' }>({ visible: false, type: '修改出价' }) const [autoAcqVisible, setAutoAcqVisible] = useState(false) const syncBatch = useAjax((params) => syncBatchApi(params)) const modifyStatusBatch = useAjax((params) => modifyStatusBatchApi(params)) const getAdqV3AdList = useAjax((params) => getAdqV3AdListApi(params), { formatResult: true }) /*****************************************/ useEffect(() => { getList({ pageNum: 1, pageSize: pageSize || 20, adUnitType: 'NOVEL' }) }, [userId]) // 获取列表 const getList = useCallback((params: ADQV3.GetAdListProps) => { getAdqV3AdList.run({ ...params, userId }) }, [userId, getAdqV3AdList]) // 同步 const sync = useCallback(() => { if (selectedRows?.length > 0) { let accountAdgroupMaps = [...new Set(selectedRows?.map(item => item.accountId + ',' + item.adgroupId))] syncBatch.run({ accountAdgroupMaps }).then(res => { res && getAdqV3AdList.refresh() res ? message.success('同步成功!') : message.error('同步失败!') }) } else { message.error('请勾选需要同步的广告') } }, [getAdqV3AdList, selectedRows]) // 批量启停 const adStatus = (type: boolean) => { let newSelectedRows = [] if (type) { newSelectedRows = selectedRows.filter((item: { configuredStatus: string, adgroupId: number }) => item.configuredStatus === 'AD_STATUS_SUSPEND') } else { newSelectedRows = selectedRows.filter((item: { configuredStatus: string, adgroupId: number }) => item.configuredStatus === 'AD_STATUS_NORMAL') } if (newSelectedRows.length === 0) { message.warn(`所有广告都是${type ? '启动' : '暂停'}状态,无需${type ? '启动' : '暂停'}操作`) return } let accountAdgroupMaps = [...new Set(newSelectedRows?.map(item => item.accountId + ',' + item.adgroupId))] modifyStatusBatch.run({ accountAdgroupMaps, suspend: !type }).then(res => { message.success(`${type ? '启动' : '暂停'}成功`) getAdqV3AdList.refresh() setSelectedRows([]) }) } // 添加创意 const addDynamic = () => { setAddDynamicVisible(true) } return
{ let value = e.target.value let arr: any = [] if (value) { value = value.replace(/[,,\s]/g, ',') arr = value.split(',').filter((a: any) => a) } set_queryFrom({ ...queryFrom, accountIdList: arr }) }} /> { let value = e.target.value let arr: any = [] if (value) { value = value.replace(/[,,\s]/g, ',') arr = value.split(',').filter((a: any) => a) } set_queryFrom({ ...queryFrom, adgroupIdList: arr }) }} /> { let value = e.target.value set_queryFrom({ ...queryFrom, adgroupName: value }) }} /> { let value = e.target.value let arr: any = [] if (value) { value = value.replace(/[,,\s]/g, ',') arr = value.split(',').filter((a: any) => a) } set_queryFrom({ ...queryFrom, accountMemo: arr }) }} /> { let value = e.target.value let arr: any = [] if (value) { value = value.replace(/[,,\s]/g, ',') arr = value.split(',').filter((a: any) => a) } set_queryFrom({ ...queryFrom, accountRemark: arr }) }} /> { set_queryFrom({ ...queryFrom, beginDate: options[0], endDate: options[1] }) }} /> {selectedRows?.length > 0 && } tableConfig(() => getAdqV3AdList.refresh(), useType, creativeHandle)} ajax={getAdqV3AdList} syncAjax={sync} fixed={{ left: 2, right: 5 }} dataSource={getAdqV3AdList?.data?.data?.records} loading={getAdqV3AdList?.loading || syncBatch?.loading} scroll={{ y: 560 }} total={getAdqV3AdList?.data?.data?.total} page={getAdqV3AdList?.data?.data?.current} pageSize={getAdqV3AdList?.data?.data?.size} myKey={'adgroupId'} gutter={[0, 10]} config={txAdConfig} configName="腾讯广告3.0" leftChild={