|
@@ -1,13 +1,13 @@
|
|
|
|
|
|
-import Tables from "@/components/Tables"
|
|
|
import { useAjax } from "@/Hook/useAjax"
|
|
|
-import { CheckOutlined, QuestionCircleOutlined, SyncOutlined } from "@ant-design/icons"
|
|
|
-import { Button, Input, message, Modal, Space, Tooltip } from "antd"
|
|
|
+import { CheckOutlined, CloseOutlined, SyncOutlined } from "@ant-design/icons"
|
|
|
+import { Button, Checkbox, Input, message, Modal, Select, Space, Table, Typography } from "antd"
|
|
|
import React, { useEffect, useState } from "react"
|
|
|
import style from '../GoodsModal/index.less'
|
|
|
import columns from "./tableConfig"
|
|
|
-import { getAdqLandingPageListApi, putAdqLandingPageApi } from "@/services/adqV3/global"
|
|
|
-
|
|
|
+import { getAdqLandingPageListApi, getWXDownPageAuthInfoListApi } from "@/services/adqV3/global"
|
|
|
+import { OPTION_ENUM } from "../../tencentAdPutIn/const"
|
|
|
+const { Title, Text } = Typography;
|
|
|
|
|
|
/**
|
|
|
* 获取adq落地页
|
|
@@ -18,17 +18,30 @@ interface Props {
|
|
|
onClose?: () => void,
|
|
|
onChange?: (data: PULLIN.AccountCreateLogsProps[]) => void,
|
|
|
adgroups: any
|
|
|
+ dynamic: any
|
|
|
data: PULLIN.AccountCreateLogsProps[]
|
|
|
}
|
|
|
const PageModal: React.FC<Props> = (props) => {
|
|
|
|
|
|
/*************************/
|
|
|
- const { visible, onClose, data: data1, adgroups, onChange } = props
|
|
|
+ const { visible, onClose, data: data1, adgroups, onChange, dynamic } = props
|
|
|
const { marketingGoal, marketingAssetOuterSpec: { marketingTargetType }, marketingCarrierType, siteSet } = adgroups
|
|
|
+ const { creativeTemplateId, creativeComponents: { mainJumpInfo } } = dynamic
|
|
|
+ let overrideCanvasHeadOption = ''
|
|
|
+ if (mainJumpInfo && mainJumpInfo?.length > 0) {
|
|
|
+ mainJumpInfo.forEach((item: any) => {
|
|
|
+ let { pageSpec } = item.value
|
|
|
+ let key = Object.keys(pageSpec)[0]
|
|
|
+ let pageSpecValue = pageSpec[key]
|
|
|
+ overrideCanvasHeadOption = pageSpecValue.overrideCanvasHeadOption
|
|
|
+ })
|
|
|
+ }
|
|
|
const [selectAdz, setSelectAdz] = useState<number>(1) // 选择广告主
|
|
|
const [data, setData] = useState<PULLIN.AccountCreateLogsProps[]>(data1 || [])
|
|
|
- const [queryForm, setQueryForm] = useState<{ accountId?: number, pageName?: string, pageSize: number, pageNum: number }>({ pageNum: 1, pageSize: 20 })
|
|
|
+ const [queryForm, setQueryForm] = useState<{ accountId?: number, pageName?: string, ownerUid?: number, pageSize: number, pageNum: number, isSqDownPage: boolean, isCanvasType?: boolean }>({ pageNum: 1, pageSize: 20, isSqDownPage: false })
|
|
|
const [loading, setLoading] = useState<boolean>(false)
|
|
|
+ const [wXDownPageAuthInfo, setWXDownPageAuthInfo] = useState<any>({})
|
|
|
+ const [tableData, setTableData] = useState<any>({})
|
|
|
|
|
|
const listAjax = useAjax((params) => getAdqLandingPageListApi(params))
|
|
|
/*************************/
|
|
@@ -37,17 +50,49 @@ const PageModal: React.FC<Props> = (props) => {
|
|
|
if (data?.length > 0) {
|
|
|
setQueryForm({ ...queryForm, pageNum: 1, accountId: data[selectAdz - 1].accountId })
|
|
|
}
|
|
|
- }, [selectAdz])
|
|
|
+ }, [])
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ if (data?.length > 0) {
|
|
|
+ setLoading(true)
|
|
|
+ let accountDataList = data.map(item => item.accountId)
|
|
|
+ let infoAjax = accountDataList.map(accountId => getWXDownPageAuthInfoListApi(accountId))
|
|
|
+ let newData: any = {}
|
|
|
+ Promise.all(infoAjax).then(res => {
|
|
|
+ res?.forEach((item, index) => {
|
|
|
+ newData[accountDataList[index]] = item?.data || []
|
|
|
+ })
|
|
|
+ setWXDownPageAuthInfo(newData)
|
|
|
+ setLoading(false)
|
|
|
+ }).catch(() => setLoading(false))
|
|
|
+ }
|
|
|
+ }, [])
|
|
|
|
|
|
useEffect(() => {
|
|
|
if (queryForm?.accountId) {
|
|
|
getList()
|
|
|
}
|
|
|
- }, [queryForm, marketingGoal, marketingTargetType, marketingCarrierType, siteSet])
|
|
|
+ }, [queryForm, marketingGoal, marketingTargetType, marketingCarrierType, siteSet, mainJumpInfo])
|
|
|
|
|
|
// 获取落地页列表
|
|
|
const getList = () => {
|
|
|
- listAjax.run({ ...queryForm, pageStatus: 'NORMAL', marketingGoal, marketingTargetType, marketingCarrierType, siteSet })
|
|
|
+ let params: any = { ...queryForm, pageStatus: 'NORMAL', marketingGoal, marketingTargetType, marketingCarrierType, siteSet }
|
|
|
+ if (params.isSqDownPage) {
|
|
|
+ if (!params?.ownerUid) {
|
|
|
+ setTableData({ total: 0, records: [] })
|
|
|
+ return
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ delete params?.ownerUid
|
|
|
+ }
|
|
|
+ if (params?.isCanvasType) {
|
|
|
+ params.canvasType = 'CANVAS_TYPE_COMMON_PAGE'
|
|
|
+ }
|
|
|
+ delete params?.isCanvasType
|
|
|
+ delete params.isSqDownPage
|
|
|
+ listAjax.run(params).then(res => {
|
|
|
+ setTableData(res || {})
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
const handleOk = () => {
|
|
@@ -63,61 +108,53 @@ const PageModal: React.FC<Props> = (props) => {
|
|
|
if (value === selectAdz) {
|
|
|
return
|
|
|
}
|
|
|
+ let accountId = data[value - 1].accountId
|
|
|
+ setQueryForm({ ...queryForm, pageNum: 1, accountId, ownerUid: wXDownPageAuthInfo[accountId]?.[0]?.accountId })
|
|
|
setSelectAdz(value)
|
|
|
}
|
|
|
|
|
|
/** 表格选折 */
|
|
|
- const onChangeTable = (selectedRowKeys: React.Key[], selectedRows: any) => {
|
|
|
+ const onChangeTable = (_: React.Key[], selectedRows: any) => {
|
|
|
let newData = JSON.parse(JSON.stringify(data))
|
|
|
newData[selectAdz - 1]['pageList'] = selectedRows
|
|
|
setData([...newData])
|
|
|
}
|
|
|
|
|
|
- /** 同步落地页 */
|
|
|
- const synPageList = () => {
|
|
|
- setLoading(true)
|
|
|
- putAdqLandingPageApi({ accountIdList: data?.map(item => item.accountId), isUsePool: false }).then(res => {
|
|
|
- message.success('同步成功,结果可能需要几分钟返回,请手动点击下面刷新按钮')
|
|
|
- setLoading(false)
|
|
|
- listAjax.refresh()
|
|
|
- }).catch(() => setLoading(false))
|
|
|
- }
|
|
|
-
|
|
|
/** 一键设置 */
|
|
|
- const setOnekey = () => {
|
|
|
- let pageName: string = data[selectAdz - 1]['pageList']?.[0]?.pageName
|
|
|
- let newData: PULLIN.AccountCreateLogsProps[] = JSON.parse(JSON.stringify(data))
|
|
|
- const hide = message.loading(`正在设置...`, 0, () => {
|
|
|
- message.success('设置成功');
|
|
|
- });
|
|
|
- let ajax = newData?.filter(item => item.accountId !== data[selectAdz - 1].accountId)?.map(item => {
|
|
|
- return getAdqLandingPageListApi({ pageName, accountId: item.accountId, pageNum: 1, pageSize: 20, pageStatus: 'NORMAL' })
|
|
|
- })
|
|
|
- Promise.all(ajax).then(res => {
|
|
|
- if (res && Array.isArray(res)) {
|
|
|
- res.forEach((item: any) => {
|
|
|
- let records = item?.data?.records
|
|
|
- if (Array.isArray(records) && records?.length > 0) {
|
|
|
- let record = records[0]
|
|
|
- newData = newData.map(item => {
|
|
|
- if (item.accountId.toString() === record.accountId.toString()) {
|
|
|
- return { ...item, pageList: [{ ...record, id: record.pageId }] }
|
|
|
- }
|
|
|
- return item
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- setData(newData)
|
|
|
- }
|
|
|
- message.success('设置完成');
|
|
|
- hide()
|
|
|
- })
|
|
|
- }
|
|
|
+ // const setOnekey = () => {
|
|
|
+ // let pageName: string = data[selectAdz - 1]['pageList']?.[0]?.pageName
|
|
|
+ // let newData: PULLIN.AccountCreateLogsProps[] = JSON.parse(JSON.stringify(data))
|
|
|
+ // const hide = message.loading(`正在设置...`, 0, () => {
|
|
|
+ // message.success('设置成功');
|
|
|
+ // });
|
|
|
+ // let ajax = newData?.filter(item => item.accountId !== data[selectAdz - 1].accountId)?.map(item => {
|
|
|
+ // return getAdqLandingPageListApi({ pageName, accountId: item.accountId, pageNum: 1, pageSize: 20, pageStatus: 'NORMAL' })
|
|
|
+ // })
|
|
|
+ // Promise.all(ajax).then(res => {
|
|
|
+ // if (res && Array.isArray(res)) {
|
|
|
+ // res.forEach((item: any) => {
|
|
|
+ // let records = item?.data?.records
|
|
|
+ // if (Array.isArray(records) && records?.length > 0) {
|
|
|
+ // let record = records[0]
|
|
|
+ // newData = newData.map(item => {
|
|
|
+ // if (item.accountId.toString() === record.accountId.toString()) {
|
|
|
+ // return { ...item, pageList: [{ ...record, id: record.pageId }] }
|
|
|
+ // }
|
|
|
+ // return item
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // setData(newData)
|
|
|
+ // }
|
|
|
+ // message.success('设置完成');
|
|
|
+ // hide()
|
|
|
+ // })
|
|
|
+ // }
|
|
|
|
|
|
return <Modal
|
|
|
title={<Space>
|
|
|
<span>ADQ落地页</span>
|
|
|
- <Button size="small" onClick={() => { synPageList() }} type="link" loading={loading}>同步落地页</Button>
|
|
|
+ <Text type="warning">{OPTION_ENUM[overrideCanvasHeadOption]}</Text>
|
|
|
</Space>}
|
|
|
visible={visible}
|
|
|
onCancel={() => { onClose && onClose() }}
|
|
@@ -131,46 +168,153 @@ const PageModal: React.FC<Props> = (props) => {
|
|
|
<div className={style.left}>
|
|
|
<h4 className={style.title}>媒体账户</h4>
|
|
|
{data?.map((item, index) => (
|
|
|
- <div key={index} onClick={() => { handleSelectAdz(index + 1, item) }} className={`${style.accItem} ${selectAdz === index + 1 && style.select} `}>
|
|
|
+ <div key={index} onClick={() => { if (!loading) handleSelectAdz(index + 1, item) }} className={`${style.accItem} ${selectAdz === index + 1 && style.select} `}>
|
|
|
{item?.accountId}
|
|
|
{data[index].pageList?.length > 0 && <CheckOutlined style={{ color: '#1890ff' }} />}
|
|
|
</div>
|
|
|
))}
|
|
|
</div>
|
|
|
<div className={style.right}>
|
|
|
- <Space style={{ marginBottom: 10 }} align="end" size={0}>
|
|
|
- <Input value={queryForm?.pageName} allowClear placeholder='请输入落地页名称' onChange={(e) => setQueryForm({ ...queryForm, pageNum: 1, pageName: e.target.value })} />
|
|
|
- <Button icon={<SyncOutlined />} type='link' loading={listAjax?.loading} onClick={() => { listAjax?.refresh() }}>刷新</Button>
|
|
|
- {data?.length > 1 && <Button disabled={!data[selectAdz - 1]['pageList']?.length} onClick={setOnekey} type="link" loading={listAjax.loading}>
|
|
|
+ <Space style={{ marginBottom: 10 }}>
|
|
|
+ <Checkbox
|
|
|
+ onChange={(e) => {
|
|
|
+ setQueryForm({ ...queryForm, pageNum: 1, isCanvasType: e.target.checked })
|
|
|
+ }}
|
|
|
+ checked={queryForm.isCanvasType}
|
|
|
+ ><span style={{ fontSize: 12 }}>展示外换内组件原生页</span></Checkbox>
|
|
|
+ <Checkbox
|
|
|
+ onChange={(e) => {
|
|
|
+ if (e.target.checked && wXDownPageAuthInfo && Object.keys(wXDownPageAuthInfo).length) {
|
|
|
+ setQueryForm({ ...queryForm, pageNum: 1, ownerUid: wXDownPageAuthInfo[data[selectAdz - 1].accountId]?.[0]?.accountId, isSqDownPage: true })
|
|
|
+ } else {
|
|
|
+ setQueryForm({ ...queryForm, pageNum: 1, ownerUid: undefined, isSqDownPage: false })
|
|
|
+ }
|
|
|
+ }}
|
|
|
+ checked={queryForm.isSqDownPage}
|
|
|
+ ><span style={{ fontSize: 12 }}>被授权落地页</span></Checkbox>
|
|
|
+ {queryForm.isSqDownPage && <Select
|
|
|
+ placeholder='选择原生页授权方信息'
|
|
|
+ style={{ width: 200 }}
|
|
|
+ showSearch
|
|
|
+ filterOption={(input: any, option: any) =>
|
|
|
+ (option!.children as unknown as string).toLowerCase().includes(input.toLowerCase())
|
|
|
+ }
|
|
|
+ allowClear
|
|
|
+ onChange={(value) => {
|
|
|
+ setQueryForm({ ...queryForm, pageNum: 1, ownerUid: value })
|
|
|
+ }}
|
|
|
+ value={queryForm?.ownerUid}
|
|
|
+ dropdownMatchSelectWidth={false}
|
|
|
+ >
|
|
|
+ {wXDownPageAuthInfo?.[data[selectAdz - 1].accountId]?.map((item: { accountId: number; accountName: string }) => {
|
|
|
+ return <Select.Option value={item.accountId} key={item.accountId}>{item.accountName}</Select.Option>
|
|
|
+ })}
|
|
|
+ </Select>}
|
|
|
+ <Input value={queryForm?.pageName} style={{ width: 150 }} allowClear placeholder='请输入落地页名称' onChange={(e) => setQueryForm({ ...queryForm, pageNum: 1, pageName: e.target.value })} />
|
|
|
+ <Button style={{ padding: 0, margin: 0 }} icon={<SyncOutlined />} type='link' loading={listAjax?.loading} onClick={() => { listAjax?.refresh() }}>刷新</Button>
|
|
|
+ {/* {data?.length > 1 && <Button style={{ padding: 0, margin: 0 }} disabled={!data[selectAdz - 1]['pageList']?.length} onClick={setOnekey} type="link" loading={listAjax.loading}>
|
|
|
<Space>
|
|
|
<span>一键设置</span>
|
|
|
<Tooltip color="#FFF" overlayInnerStyle={{ color: '#000' }} title="设置其它账号有相同名称的落地页为那个账号的落地页(注意需要落地页名称相同,否则不设置)">
|
|
|
<QuestionCircleOutlined />
|
|
|
</Tooltip>
|
|
|
</Space>
|
|
|
- </Button>}
|
|
|
+ </Button>} */}
|
|
|
</Space>
|
|
|
- <Tables
|
|
|
+ <Table
|
|
|
columns={columns()}
|
|
|
- dataSource={listAjax?.data?.records?.map((item: any) => ({ ...item, id: item.pageId }))}
|
|
|
+ dataSource={tableData?.records}
|
|
|
size="small"
|
|
|
- loading={listAjax?.loading}
|
|
|
+ loading={listAjax?.loading || loading}
|
|
|
scroll={{ y: 300 }}
|
|
|
bordered
|
|
|
- total={listAjax?.data?.total}
|
|
|
- defaultPageSize={20}
|
|
|
- current={listAjax?.data?.current}
|
|
|
- pageSize={listAjax?.data?.size}
|
|
|
- pageChange={(page: number, pageSize?: number) => {
|
|
|
- setQueryForm({ ...queryForm, pageNum: page, pageSize: pageSize as number || 20 })
|
|
|
+ rowKey={'pageId'}
|
|
|
+ pagination={{
|
|
|
+ total: tableData?.total,
|
|
|
+ defaultPageSize: 20,
|
|
|
+ current: tableData?.current,
|
|
|
+ pageSize: tableData?.size
|
|
|
+ }}
|
|
|
+ onChange={(pagination) => {
|
|
|
+ const { current, pageSize } = pagination
|
|
|
+ setQueryForm({ ...queryForm, pageNum: current as number, pageSize: pageSize as number || 20 })
|
|
|
}}
|
|
|
+ /**
|
|
|
+ * canvasType
|
|
|
+ * VIDEO
|
|
|
+ * VIDEO_1280_960 横板1280*960
|
|
|
+ * VIDEO_1280_720 横板1280*720
|
|
|
+ * VERTICAL_VIDEO_NEW_916 9:16 视频
|
|
|
+ * COMMON_PAGE 引用外层素材原生页
|
|
|
+ * IMAGE
|
|
|
+ */
|
|
|
rowSelection={{
|
|
|
- type: 'radio',
|
|
|
- selectedRowKeys: data[selectAdz - 1]?.pageList?.map((item: any) => item?.id?.toString()),
|
|
|
+ type: [910].includes(creativeTemplateId) ? 'checkbox' : 'radio',
|
|
|
+ getCheckboxProps: (record) => {
|
|
|
+ let { canvasType, pageElementsSpecList } = record
|
|
|
+ let topData = pageElementsSpecList[0]
|
|
|
+ /**
|
|
|
+ * 641 三图 642 4图 643 6图 311 一图
|
|
|
+ * 721 素板视频 9:16 -> VERTICAL_VIDEO_NEW_916 720 722 横板视频 -> VIDEO_1280_960
|
|
|
+ * 618 常规视频 ---> VIDEO
|
|
|
+ * 1708 1707 ---> false
|
|
|
+ */
|
|
|
+ if (overrideCanvasHeadOption === 'OPTION_CREATIVE_OVERRIDE_CANVAS' || [1708, 1707].includes(creativeTemplateId)) {
|
|
|
+ return {
|
|
|
+ disabled: false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ([721].includes(creativeTemplateId) && canvasType === 'VERTICAL_VIDEO_NEW_916') {
|
|
|
+ return {
|
|
|
+ disabled: false
|
|
|
+ }
|
|
|
+ } else if ([720, 722].includes(creativeTemplateId) && canvasType === 'VIDEO_1280_960') {
|
|
|
+ return {
|
|
|
+ disabled: false
|
|
|
+ }
|
|
|
+ } else if ([618].includes(creativeTemplateId) && canvasType === 'VIDEO') {
|
|
|
+ return {
|
|
|
+ disabled: false
|
|
|
+ }
|
|
|
+ } else if ([311].includes(creativeTemplateId) && canvasType === "IMAGE" && topData.imageSpec.length === 1) {
|
|
|
+ return {
|
|
|
+ disabled: false
|
|
|
+ }
|
|
|
+ } else if ([641].includes(creativeTemplateId) && canvasType === "IMAGE" && topData.imageSpec.length === 3) {
|
|
|
+ return {
|
|
|
+ disabled: false
|
|
|
+ }
|
|
|
+ } else if ([642].includes(creativeTemplateId) && canvasType === "IMAGE" && topData.imageSpec.length === 4) {
|
|
|
+ return {
|
|
|
+ disabled: false
|
|
|
+ }
|
|
|
+ } else if ([643].includes(creativeTemplateId) && canvasType === "IMAGE" && topData.imageSpec.length === 6) {
|
|
|
+ return {
|
|
|
+ disabled: false
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ disabled: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ selectedRowKeys: data[selectAdz - 1]?.pageList?.map((item: any) => item?.pageId),
|
|
|
onChange: onChangeTable
|
|
|
}}
|
|
|
/>
|
|
|
</div>
|
|
|
+ <div className={style.center}>
|
|
|
+ <Title level={5}>已选:{data[selectAdz - 1]?.pageList?.length || 0}</Title>
|
|
|
+ <div className={style.select_content}>
|
|
|
+ {data[selectAdz - 1]?.pageList?.map((item: any) => <div key={item.pageId}>
|
|
|
+ <Text ellipsis={{ tooltip: true }} className={style.marketingAssetName}>{item.pageName}</Text>
|
|
|
+ <CloseOutlined className={style.close} onClick={() => {
|
|
|
+ let newData: PULLIN.AccountCreateLogsProps[] = JSON.parse(JSON.stringify(data))
|
|
|
+ newData[selectAdz - 1].pageList = newData[selectAdz - 1]?.pageList?.filter((i: any) => i?.pageId !== item.pageId)
|
|
|
+ setData(newData)
|
|
|
+ }} />
|
|
|
+ </div>)}
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
|
|
|
</Modal>
|