import { useAjax } from "@/Hook/useAjax" import { delBatchCreativeApi, getDynamicCreativeV3ListApi, syncBatchCreativeApi, updateBatchDynamicCreativesInfoApi } from "@/services/launchAdq/adqv3" import { Badge, Button, Col, DatePicker, Form, Input, Modal, Popconfirm, Row, Select, Space, Table, message } from "antd" import React, { useEffect, useState } from "react" import { txDynamicConfig } from "../config" import tableConfig from "./tableConfig" import TableData from "@/pages/launchSystemNew/components/TableData" import ReviewDetails from "./reviewDetails" import { DeleteOutlined, PauseCircleOutlined, PlayCircleOutlined } from "@ant-design/icons" import '../../tencentAdPutIn/index.less' import HandleLog from "./handleLog" import moment from "moment" import RetriaModal from "./retriaModal" import ReplacePage from "./replacePage" import ReplaceGfPage from "./replaceGfPage" /** 审核结果 */ export const AD_STATUS = { NORMAL: , PENDING: , DENIED: , PARTIALLY_NORMAL: , } const Creative: React.FC = ({ queryForm, setQueryForm, userId }) => { /*********************************/ const [form] = Form.useForm(); const [dynimicData, setDynamicData] = useState({}) const [dynimicVisible, setDynamicVisible] = useState(false) const [selectedRows, setSelectedRows] = useState([]) const [failIdList, setFailIdList] = useState<{ adgroupId: number, code: number, message: string, messageCn: string }[]>([]) const [failVisible, setFailVisible] = useState(false) const [logVisible, setLogVisible] = useState(false) const [handleType, setHandleType] = useState(1) const [replaceVisible, setReplaceVisible] = useState(false) const [replaceGfVisible, setReplaceGfVisible] = useState(false) const getDynamicCreativeV3List = useAjax((params) => getDynamicCreativeV3ListApi(params), { formatResult: true }) const delBatchCreative = useAjax((params) => delBatchCreativeApi(params)) const updateBatchDynamicCreativesInfo = useAjax((params) => updateBatchDynamicCreativesInfoApi(params)) const syncBatchCreative = useAjax((params) => syncBatchCreativeApi(params)) /*********************************/ useEffect(() => { form.setFieldsValue({ adgroupId: queryForm.adgroupId }) }, [queryForm.adgroupId]) useEffect(() => { let params: any = { ...queryForm, userId } if (params?.accountId) { params.accountId = params.accountId?.split(/[,,\s\n]+/) } getDynamicCreativeV3List.run(params) }, [userId, queryForm]) const onFinish = (values: any) => { console.log(values) const { date, ...value } = values let newQueryForm = { ...queryForm, ...value } if (date?.length) { newQueryForm.beginDate = moment(date[0]).format('YYYY-MM-DD') newQueryForm.endDate = moment(date[1]).format('YYYY-MM-DD') } else { delete newQueryForm?.beginDate delete newQueryForm?.endDate } setQueryForm(newQueryForm) } const reviewStatusDetails = (value: any) => { setDynamicData(value) setDynamicVisible(true) } const dynamicHandle = (type: '删除' | '启动' | '暂停', data?: any) => { let accountAdgroupMaps = data ? [data.accountId + ',' + data.dynamicCreativeId] : [...new Set(selectedRows?.map(item => item.accountId + ',' + item.dynamicCreativeId))] let hide: any if (data) { hide = message.loading(`正在设置...`, 0, () => { message.success('设置成功'); }); } switch (type) { case '删除': delBatchCreative.run({ accountAdgroupMaps }).then(res => { if (res?.failIdList?.length === 0) { message.success(`修改操作完成!`) getDynamicCreativeV3List.refresh() setSelectedRows([]) } else { setFailIdList(res?.list || []) setFailVisible(true) } }) break case '启动': case '暂停': updateBatchDynamicCreativesInfo.run({ accountAdgroupMaps, suspend: type === '暂停' }).then(res => { if (res?.failIdList?.length === 0) { message.success(`修改操作完成!`) getDynamicCreativeV3List.refresh() setSelectedRows([]) } else { setFailIdList(res?.list || []) setFailVisible(true) } if (hide) { hide() } }) break } } const sync = () => { if (selectedRows?.length > 0) { const hide = message.loading(`正在同步...`, 0, () => { message.success('设置成功'); }); let accountAdgroupMaps = [...new Set(selectedRows?.map(item => item.accountId + ',' + item.dynamicCreativeId))] syncBatchCreative.run({ accountAdgroupMaps }).then(res => { res && getDynamicCreativeV3List.refresh() res ? message.success('同步成功!') : message.error('同步失败!') hide() }).catch(() => hide()) } else { message.error('请勾选需要同步的创意') } } return <>
tableConfig(reviewStatusDetails, (data, type) => dynamicHandle(type, data))} ajax={getDynamicCreativeV3List} fixed={{ left: 2, right: 4 }} dataSource={getDynamicCreativeV3List?.data?.data?.records} loading={getDynamicCreativeV3List?.loading || syncBatchCreative.loading || updateBatchDynamicCreativesInfo.loading} scroll={{ y: 560 }} syncAjax={sync} total={getDynamicCreativeV3List?.data?.data?.total} page={getDynamicCreativeV3List?.data?.data?.current} pageSize={getDynamicCreativeV3List?.data?.data?.size} myKey={'dynamicCreativeId'} gutter={[0, 10]} config={txDynamicConfig} configName="创意3.0" leftChild={