import React, { useEffect, useState } from "react" import { useAjax } from "@/Hook/useAjax" import { getNovelGDTListApi, GetNovelGDTListProps, getNovelGDTTotalApi } from "@/services/iaaData" import TablePro from "@/components/TablePro" import columns12 from "./tableConfig" import moment from "moment" import { useModel } from "umi" import { Button, Dropdown, message, Select, Space, Switch } from "antd" import { modifyStatusBatchApi } from "@/services/gameData" import { DeleteOutlined, DownOutlined, PauseCircleOutlined, PlayCircleOutlined } from "@ant-design/icons" import DayAd from "./dayAd" import QueryFormNovel from "@/components/QueryForm/queryFormNovel" import UpdateAd3 from "@/pages/iaaData/components/UpdateAd3" import AutoAcquisitionSet from "./autoAcquisitionSet" /** * 腾讯广告列表 * @returns */ const TencentNovelAd: React.FC<{ configName?: string, dayConfigName?: string }> = ({ configName, dayConfigName }) => { /****************************************/ const { initialState } = useModel('@@initialState'); const [selectedRows, setSelectedRows] = useState([]) const [queryForm, setQueryForm] = useState({ pageNum: 1, pageSize: 30, dataTimeMin: moment().format('YYYY-MM-DD'), dataTimeMax: moment().format('YYYY-MM-DD'), }) const [totalData, setTotalData] = useState([]) const [visible, setVisible] = useState(false) const [promotionId, setPromotionId] = useState() const [adName, setAdName] = useState('') const [updateData, setUpdateDate] = useState<{ visible: boolean, type: '修改出价' | '修改名称' | '修改日限额' | '修改投放时间' | '删除' | '深度优化ROI' | '修改投放首日开始时间' }>({ visible: false, type: '修改出价' }) const [autoAcqVisible, setAutoAcqVisible] = useState(false) const [handleType, setHandleType] = useState(1) const [isZj, setIsZj] = useState(true) const modifyStatusBatch = useAjax((params) => modifyStatusBatchApi(params)) const getGDTList = useAjax((params) => getNovelGDTListApi(params)) const getGDTTotal = useAjax((params) => getNovelGDTTotalApi(params)) /****************************************/ useEffect(() => { getList() }, [queryForm, initialState?.iaaApp, initialState?.productType]) const getList = () => { if (initialState?.iaaApp?.length && initialState?.productType) { getGDTList.run({ ...queryForm, appId: initialState.iaaApp, productType: initialState.productType }) getGDTTotal.run({ ...queryForm, appId: initialState.iaaApp, productType: initialState.productType }).then((res: { data: { id: number; accountId: string } }) => { if (res?.data) { let data = res?.data data.id = 1 data.accountId = '总计' setTotalData([data]) } else { setTotalData([{ id: 1, accountId: '总计' }]) } }) } else { setTotalData([{ id: 1, accountId: '总计' }]) getGDTList.mutate({ data: undefined }) } } const dayHandle = (data: any) => { setVisible(true) setAdName(data.adgroupName) setPromotionId(data.adgroupId) } // 批量启停 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 => { if (res?.data?.failIdList?.length === 0) { message.success(`${type ? '启动' : '暂停'}成功`) getGDTList.refresh() setSelectedRows([]) } else { message.success(`${type ? '启动' : '暂停'}失败,${JSON.stringify(res?.data?.list)}`) } }) } return
{ setIsZj(!e); }} />