import { useAjax } from "@/Hook/useAjax" import { PromotionDataDay, getPromotionDataDatListApi, getPromotionDataDatTotalApi, newEditTTAdgroupsDataApi } from "@/services/gameData/adlist" import React, { useEffect, useState } from "react" import columns12 from "./tableConfig" import QueryForm from "@/components/QueryForm" import TableData from "../../components/TableData" import moment from "moment" import { getPresets } from "@/components/QueryForm/const" import DayAd from "./dayAd" import { Button, message, Modal, notification, Space, Table } from "antd" import { PauseCircleOutlined, PlayCircleOutlined } from "@ant-design/icons" const Monitor = () => { /***************************************/ const [queryForm, setQueryForm] = useState({ pageNum: 1, pageSize: 50, sourceSystem: 'ZX_ONE', costBeginDate: moment().format('YYYY-MM-DD'), costEndDate: moment().format('YYYY-MM-DD') }) const [totalData, setTotalData] = useState([]) const [visible, setVisible] = useState(false) const [promotionId, setPromotionId] = useState() const [adName, setAdName] = useState('') const [selectedRows, setSelectedRows] = useState([]) const [failIdList, setFailIdList] = useState<{ adgroupId: number, code: number, message: string, messageCn: string }[]>([]) const [failVisible, setFailVisible] = useState(false) const getPromotionDataDatList = useAjax((params) => getPromotionDataDatListApi(params)) const getPromotionDataDatTotal = useAjax((params) => getPromotionDataDatTotalApi(params)) const newEditTTAdgroupsData = useAjax((params) => newEditTTAdgroupsDataApi(params)) /***************************************/ useEffect(() => { getPromotionDataDatList.run(queryForm) getPromotionDataDatTotal.run(queryForm).then((res: { id: number; accountName: string }) => { res.id = 1 res.accountName = '总计' setTotalData([res]) }) }, [queryForm]) const dayHandle = (data: any) => { setVisible(true) setAdName(data.promotionName) setPromotionId(data.promotionId) } // 批量启停 const adStatus = (type: 'play' | 'suspend') => { let params: any = {} params.suspend = type === 'play' ? false : true params.adgroupIds = selectedRows.map(item => item.accountId + ',' + item.promotionId) if (params.adgroupIds.length === 0) { message.warn(`所以账号都是${type === 'play' ? '启动' : '暂停'}状态,无需${type === 'play' ? '启动' : '暂停'}操作`) return } let hide = message.loading(`正在设置...`, 0, () => { message.success('设置成功'); }); newEditTTAdgroupsData.run(params).then((res: any) => { if (res?.failIdList?.length === 0) { message.success(`操作完成!`) getPromotionDataDatList.refresh() setSelectedRows([]) } else { setFailIdList(res?.list || []) setFailVisible(true) } hide() }) } return
{/* { setIsZj(!e); }} /> */} {selectedRows.length > 0 && } 操作完数据结果延时5分钟之内,即时结果去腾讯后台查看 } leftChild={ { const { type, gameClassify, costBeginDay, costEndDay, sysUserName, regPayIntervalTime, ...params } = data let newQueryForm = JSON.parse(JSON.stringify(queryForm)) newQueryForm.pageNum = 1 newQueryForm.pitcherName = sysUserName newQueryForm.accountType = type newQueryForm.classify = gameClassify if (costBeginDay && costEndDay) { newQueryForm.costBeginDate = costBeginDay newQueryForm.costEndDate = costEndDay } else { delete newQueryForm.costBeginDate delete newQueryForm.costEndDate } if (regPayIntervalTime?.length > 0 && (regPayIntervalTime[0] || regPayIntervalTime[1])) { newQueryForm.firstRechargeAmountMin = regPayIntervalTime[0] newQueryForm.firstRechargeAmountMax = regPayIntervalTime[1] } setQueryForm({ ...newQueryForm, ...params }) }} isSource isAccountId isAccount isType isAgentId isBGGameClassify isConsumeDay={{ ranges: getPresets() }} isCpName isGameId isSysUserId isProjectId isProjectName isPromotionId isPromotionName isAdTTStatus isPayIntervalTime={{ tips: '首日充值金额区间(元)' }} />} isZj totalData={totalData} scroll={{ x: 1000, y: 600 }} ajax={getPromotionDataDatList} fixed={{ left: 3, right: 1 }} dataSource={getPromotionDataDatList?.data?.records?.map((item: any, index: number) => ({ ...item, id: Number(queryForm.pageNum.toString() + index.toString()) }))} total={getPromotionDataDatList?.data?.total} page={queryForm.pageNum} pageSize={queryForm.pageSize} sortData={{ field: queryForm?.sortFiled, order: queryForm?.sortType === 'asc' ? 'ascend' : 'descend' }} title='头条广告监控' onChange={(props: any) => { let { pagination, sortData } = props let { current, pageSize } = pagination let newQueryForm = JSON.parse(JSON.stringify(queryForm)) if (sortData && sortData?.order) { newQueryForm['sortType'] = sortData?.order === 'ascend' ? 'asc' : 'desc' newQueryForm['sortFiled'] = sortData?.field } else { delete newQueryForm['sortType'] delete newQueryForm['sortFiled'] } newQueryForm.pageNum = current newQueryForm.pageSize = pageSize setQueryForm({ ...newQueryForm }) }} config={columns12(dayHandle)} configName={'头条广告监控'} rowSelection={{ selectedRowKeys: selectedRows.map(item => item.id + ''), getCheckboxProps: (record: any) => ({ disabled: record.status === 'STATUS_DELETED' || record?.accountName === '总计' }), onSelect: (record: { promotionId: number }, selected: boolean) => { if (selected) { selectedRows.push({ ...record }) setSelectedRows([...selectedRows]) } else { let newSelectAccData = selectedRows.filter((item: { promotionId: number }) => item.promotionId !== record.promotionId) setSelectedRows([...newSelectAccData]) } }, onSelectAll: (selected: boolean, selectedRowss: { promotionId: number }[], changeRows: { promotionId: number }[]) => { if (selected) { let newSelectAccData = [...selectedRows] changeRows.forEach((item: { promotionId: number }) => { let index = newSelectAccData.findIndex((ite: { promotionId: number }) => ite.promotionId === item.promotionId) if (index === -1) { newSelectAccData.push({ ...item }) } }) setSelectedRows([...newSelectAccData]) } else { let newSelectAccData = selectedRows.filter((item: { promotionId: number }) => { let index = changeRows.findIndex((ite: { promotionId: number }) => ite.promotionId === item.promotionId) if (index !== -1) { return false } else { return true } }) setSelectedRows([...newSelectAccData]) } } }} /> {failVisible && 报错信息} visible={failVisible} className='modalResetCss' width={650} onCancel={() => { setFailVisible(false); setFailIdList([]) }} footer={null} > {value}, }, { title: 'code', dataIndex: 'code', key: 'code', width: 70, align: 'center', render: (value) => {value}, }, { title: '错误信息', dataIndex: 'messageCn', key: 'messageCn', render: (value) => {value}, }]} dataSource={failIdList} /> } {visible && { setVisible(false); setPromotionId(undefined) }} queryForm={queryForm} promotionId={promotionId} />} } export default Monitor