import Tables from "@/components/Tables"; import useEcharts from "@/Hook/useEcharts"; import { CloudDownloadOutlined, RedoOutlined } from "@ant-design/icons"; import { Button, Card, DatePicker, Modal, Radio, Space, Spin, Statistic, Tag } from "antd"; import moment, { Moment } from "moment"; import React, { useCallback, useEffect, useState } from "react"; import { useModel } from "umi"; import columns from './tableConfig' import { compare } from '@/utils/utils' import { formatDate, downloadFile1 } from '@/utils/downloadFile' import { downLoadSpeedApi } from "@/services/adMonitor/adMonitor"; import '../index.less' type Props = { visible?: boolean, onClose?: () => void, data?: any, dataStartTime?: string dataEndTime?: string } function PlanDetail(props: Props) { const { adgroupId, putUserId, accountId } = props.data const { getCostSpeed } = useModel('useAdMonitor.useMonitor') /** 变量start */ const { visible, onClose, dataStartTime, dataEndTime } = props const { LineMonitor } = useEcharts() const [lineDis, setLineDis] = useState([]) const [queryForm, setQueryForm] = useState({ adgroupId, accountId, sysUserId: putUserId, timeUnit: dataStartTime || dataEndTime ? 'day' : 'hour', dataStartTime: dataStartTime || moment().format('YYYY-MM-DD'), dataEndTime: dataEndTime || moment().format('YYYY-MM-DD') }) const [speedData, setSpeedData] = useState<{ totalCost: string, viewCount: string, clickCount: string, clickRate: string, orderRate: string, costSpeed: string, adCostSpeedVOList: any[] }>() const [adCostSpeedDtoListOri, setAdCostSpeedDtoListOri] = useState([]) const [downLoadLoading, setDownLoadLoading] = useState(false) /** 变量end */ useEffect(() => { getList() }, [queryForm]) const getList = useCallback(() => { getCostSpeed.run(queryForm).then((res: any) => { if (res?.data) { setSpeedData(() => res?.data) setAdCostSpeedDtoListOri(() => [...res?.data?.adCostSpeedVOList]) let spendData: any = { legendName: '花费' } let exposureData: any = { legendName: '曝光次数' } res?.data?.adCostSpeedVOList?.forEach((item: { day: string, time: string, cost: string, viewCount: string }) => { if (queryForm.timeUnit === 'hour') { spendData[item?.time] = item?.cost exposureData[item?.time] = item?.viewCount } else { spendData[item?.day] = item?.cost exposureData[item?.day] = item?.viewCount } }); setLineDis(() => [spendData, exposureData]) } }) }, [queryForm, adCostSpeedDtoListOri, speedData]) // 设置获取图标数据区间 设置时间 const setTime = useCallback((str: string[]) => { setQueryForm({ ...queryForm, dataStartTime: str[0], dataEndTime: str[1] }) }, [queryForm]) const disabledDate = (date: Moment) => { if (queryForm?.timeUnit === 'hour') { return date && (date < moment().startOf('day').subtract(9, 'day') || date > moment().endOf('day')) } else { return false } } const downLoadExcel = useCallback(() => { setDownLoadLoading(true) downLoadSpeedApi(queryForm).then(res => { setDownLoadLoading(false) downloadFile1(res, 'octet-stream', formatDate(new Date()) + ".xlsx") }).catch(() => setDownLoadLoading(false)) }, [queryForm, downLoadLoading]) return 计划名称:{props?.data?.campaignName || '--'}         广告名称:{props?.data?.adgroupName} } visible={visible} width={900} bodyStyle={{ padding: '0 5px', backgroundColor: '#f2f2f2' }} footer={null} onCancel={() => { onClose && onClose() }} >
{ setTime(str) }} value={(queryForm?.dataStartTime && queryForm?.dataEndTime ? [moment(queryForm?.dataStartTime), moment(queryForm?.dataEndTime)] : null) as any} /> { if (e.target.value === 'hour') { setQueryForm({ ...queryForm, timeUnit: e.target.value, dataStartTime: moment().format('YYYY-MM-DD'), dataEndTime: moment().format('YYYY-MM-DD') }) } else { setQueryForm({ ...queryForm, timeUnit: e.target.value }) } }}> {/* 5min */} 分天 小时 刷新时间:{getCostSpeed?.data?.reqTime} { getList() }}> 刷新
总消耗
曝光次数
点击次数
点击率
所选时间内平均消耗速度
{getCostSpeed?.loading ? : }
明细表
} > { if (JSON.stringify(sorter) !== '{}') { let { field, order } = sorter // descend 降序 大到小 ascend 升序 小到大 if (JSON.stringify(speedData) !== '{}') { setSpeedData({ ...speedData as any, adCostSpeedVOList: order ? speedData?.adCostSpeedVOList?.sort(compare(field, order)) : [...adCostSpeedDtoListOri] }) } } }} />
} export default React.memo(PlanDetail)