Преглед изворни кода

Merge branch 'shenwu' of http://git.zanxiangnet.com/wjx/ad-manage into wangjianxin

wjx пре 2 година
родитељ
комит
3b839fd47e

+ 1 - 1
src/pages/launchSystemNew/launchManage/localAd/ad/index.tsx

@@ -51,7 +51,7 @@ function Ad() {
         createSysAdgroup.run(arg).then(res => {
             if (res) {
                 sysAdgroupsList.refresh()
-                handleModalConfig({ visible: false })
+                handleModalConfig({ visible: false,dataInfo:null,type:'add' })
             }
         })
     }, [sysAdgroupsList])

+ 3 - 2
src/pages/launchSystemNew/launchManage/localAd/ad/modal.tsx

@@ -18,6 +18,7 @@ interface Props {
 /**广告模板*/
 function AdModal(props: Props) {
     let { visible, confirmLoading, PupFn, callback, type, dataInfo } = props
+    let arg = type === 'look' ? { footer: null } : {}
     const sceneTagsList = useAjax((params) => getSceneTagsList(params))
     const [form] = Form.useForm();
     let dateType = Form.useWatch('dateType', form)
@@ -91,7 +92,6 @@ function AdModal(props: Props) {
     // 数据回填
     useEffect(() => {
         if (dataInfo) {
-            console.log('dataInfo', dataInfo)
             form.setFieldsValue({
                 adgroupName: dataInfo?.adgroupName,//广告名称
                 promotedObjectType: dataInfo?.promotedObjectType,//推广目标
@@ -118,10 +118,11 @@ function AdModal(props: Props) {
     return <Modal
         visible={visible}
         title={type === 'add' ? '新建广告' : type === 'look' ? '广告详情' : '编辑广告'}
-        onCancel={() => { PupFn({ visible: false }) }}
+        onCancel={() => { PupFn({ visible: false,dataInfo:null,type:'add' }) }}
         onOk={type === 'look' ? () => message.warning('详情无法改动内容') : handleOk}
         width={900}
         confirmLoading={confirmLoading}
+        {...arg}
     >
         <Form
             form={form}

+ 8 - 8
src/pages/launchSystemNew/launchManage/localAd/creative/modal.tsx

@@ -70,23 +70,23 @@ function CreativeModal(props: Props) {
                     case 'image'://图素材
                         newValues.adcreativeElements = {
                             ...newValues.adcreativeElements,
-                            image: materialConfig.list[0].url,
+                            imageUrl: materialConfig.list[0].url,
                         }
                         delete newValues[key]
                         break;
                     case 'video'://视频素材
                         newValues.adcreativeElements = {
                             ...newValues.adcreativeElements,
-                            video: materialConfig.list[0].url,
+                            videoUrl: materialConfig.list[0].url,
                         }
                         delete newValues[key]
                         break;
                     case 'image_list'://图素材
-                        // newValues.adcreativeElements = {
-                        //     video: materialConfig.list[0].url,
-                        //     description: newValues.description,
-                        // }
-                        // delete newValues[key]
+                        newValues.adcreativeElements = {
+                            imageUrlList: materialConfig.list?.map(item=>item.url),
+                            description: newValues.description,
+                        }
+                        delete newValues[key]
                         break;
                     case 'short_video1'://视频素材
                         // newValues.adcreativeElements = {
@@ -109,7 +109,7 @@ function CreativeModal(props: Props) {
             delete newValues.dataShow //删除数据开关
             delete newValues.actionBtn //删除行动开关
             console.log('newValues=>2', newValues)
-            // callback(newValues)
+            callback(newValues)
         })
         // PupFn({ visible: false })
     }, [form, materialConfig])

+ 19 - 6
src/pages/launchSystemNew/launchManage/localAd/targeting/index.tsx

@@ -1,7 +1,7 @@
 
 import { FnAjax, useAjax } from '@/Hook/useAjax'
 import { ListData, } from '@/services/launchAdq'
-import { createsysTargeting, getsysTargetingList } from '@/services/launchAdq/targeting'
+import { createsysTargeting, getsysTargetingInfo, getsysTargetingList } from '@/services/launchAdq/targeting'
 import { Col, Row, Input,  Button } from 'antd'
 import React, { useEffect, useState, useCallback } from 'react'
 import TableData from '../../../components/TableData'
@@ -10,19 +10,21 @@ import tableConfig from './tableConfig'
 
 export interface ModalConfig {
     visible: boolean;
-    title?: string;
+    type?:'add'|'look'|'edit',
+    dataInfo?:null
 }
 
 function Targeting() {
     // 变量
     const [modalConfig, setModalConfig] = useState<ModalConfig>({
         visible: false,
-        title: '新建'
+        type:'add'
     })
     const [oldsearchData, setOldsearchData] = useState<any>(null)
     // api方法
     const list: FnAjax<ListData<any>|any> = useAjax((params) => getsysTargetingList(params),{formatResult:true})
     const create = useAjax((params) => createsysTargeting(params))
+    const targetingInfo = useAjax((params) => getsysTargetingInfo(params),{formatResult:true})
     // 初始获取列表
     useEffect(() => {
         getList({ pageSize: 20, pageNum: 1 })
@@ -48,13 +50,24 @@ function Targeting() {
         create.run(arg).then(res => {
             if (res) {
                 list.refresh()
-                handleModalConfig({ visible: false })
+                handleModalConfig({ visible: false,dataInfo:null,type:'add' })
             }
         })
     }, [list])
+      // 获取详情
+      const getInfo = useCallback((adgroupsId,type)=>{
+        targetingInfo.run(adgroupsId).then((res: any)=>{
+            setModalConfig({...modalConfig,visible:true,type,dataInfo:res.data})
+        })
+    },[modalConfig])
+    // 回调
+    const callback=useCallback((data,type)=>{
+        getInfo(data.id,type)
+
+    },[])
     return <div>
         <TableData
-            columns={tableConfig}
+            columns={()=>tableConfig(callback)}
             ajax={list}
             dataSource={list?.data?.data?.records}
             loading={list?.loading}
@@ -100,7 +113,7 @@ function Targeting() {
         // config={guanggao}
         // configName={'广告模板列表'}
         />
-        {modalConfig.visible && <AdModal visible={modalConfig.visible} title={modalConfig.title} PupFn={handleModalConfig} callback={submit} confirmLoading={create.loading} />}
+        {modalConfig.visible && <AdModal visible={modalConfig.visible}  PupFn={handleModalConfig} callback={submit} confirmLoading={create.loading} type={modalConfig.type} dataInfo={modalConfig.dataInfo}/>}
     </div>
 }
 export default Targeting

+ 46 - 15
src/pages/launchSystemNew/launchManage/localAd/targeting/modal.tsx

@@ -4,18 +4,22 @@ import { GenderEnum, EducationEnum, ExcludedDimensionEnum, MaritalStatusEnum, Op
 import { ModalConfig } from '.'
 import { useAjax } from '@/Hook/useAjax'
 import { getTagsList } from '@/services/launchAdq/global'
+import { filter } from '@umijs/deps/compiled/lodash'
 interface Props {
     title?: string,
     visible: boolean,
     PupFn: (arg: ModalConfig) => void,
     callback: (params: any) => void,
-    confirmLoading: boolean
+    confirmLoading: boolean,
+    type?: 'add' | 'look' | 'edit',//新增,查看,编辑
+    dataInfo?: any
 }
 const ios_os = Object.keys(UserOsEnum).filter(key => key.includes('IOS'))
 const android_os = Object.keys(UserOsEnum).filter(key => key.includes('ANDROID'))
 /**创意模板*/
 function AdModal(props: Props) {
-    let { visible, title, confirmLoading, PupFn, callback } = props
+    let { visible, confirmLoading, PupFn, callback, type, dataInfo } = props
+    let arg = type === 'look' ? { footer: null } : {}
     const tagsList_REGION = useAjax((params) => getTagsList(params))
     const tagsList_MODEL = useAjax((params) => getTagsList(params))
     const [form] = Form.useForm();
@@ -52,7 +56,7 @@ function AdModal(props: Props) {
                         if (newValues[key] === '1') {
                             newValues.targeting.geoLocation = {
                                 locationTypes: ['LIVE_IN'],//对于微信流量(site_set=SITE_SET_WECHAT、SITE_SET_MOMENTS、SITE_SET_MINI_GAME_WECHAT),仅能选择"LIVE_IN"(常住);
-                                regions: newValues.regions && newValues.regions[0] === 1156 ? regionsList[0]?.children?.filter((item:any)=>!item.disabled)?.map((item: { value: any })=>item.value) : newValues.regions
+                                regions: newValues.regions && newValues.regions[0] === 1156 ? regionsList[0]?.children?.filter((item: any) => !item.disabled)?.map((item: { value: any }) => item.value) : newValues.regions
                             }
                         }
                         delete newValues[key]
@@ -170,10 +174,10 @@ function AdModal(props: Props) {
                         break;
                 }
             })
-            console.log(JSON.stringify(newValues))
-            // callback(newValues)
+            // console.log(JSON.stringify(newValues))
+            callback(newValues)
         })
-    }, [form,regionsList])
+    }, [form, regionsList])
 
     // 监听ios系统全选事件
     useEffect(() => {
@@ -256,23 +260,50 @@ function AdModal(props: Props) {
         })
     }, [])
     // 回填数据
-    useEffect(()=>{
-        if(regionsList.length > 0){
-            console.log(111)
-            let arr = [156,540000,630000,510000,450000,320000,220000,370000,340000,150000,140000,420000,130000,360000,310000,330000,650000,350000,120000,110000,640000,530000,210000,610000,520000,230000,460000,440000,500000,410000,620000,430000]
-            let newArr = regionsList[0]?.children?.filter((item:any)=>!item.disabled)?.map((item: { value: any })=>item.value)
+    useEffect(() => {
+        if (regionsList.length > 0 && dataInfo) {
+            let newArr = regionsList[0]?.children?.filter((item: any) => !item.disabled)?.map((item: { value: any }) => item.value)//全选省列表
+            let { description, targetingName, targeting } = dataInfo
+            let { age, deviceBrandModel, devicePrice, education, excludedConvertedAudience, gender, geoLocation, maritalStatus, networkType, userOs, wechatAdBehavior } = targeting
             form.setFieldsValue({
-                regions:JSON.stringify(arr) === JSON.stringify(newArr) ? [1156] : arr//地域回填
+                targetingName,//定向名称
+                description,//定向描述
+                geoLocationType: geoLocation?.regions ? '1' : '0',//地域选项
+                regions: geoLocation?.regions && JSON.stringify(geoLocation?.regions) === JSON.stringify(newArr) ? [1156] : geoLocation?.regions,//地域回填
+                ageType: age ? '1' : '0',//年龄选项
+                age_min: age ? age[0].min : 14,//年龄
+                age_max: age ? age[0].max : 66,//年龄
+                gender: gender ? gender?.join() : '0',//性别
+                educationType: education ? '1' : '0',//学历
+                education,//学历
+                maritalStatusType: maritalStatus ? '1' : '0',//婚恋
+                maritalStatus,//婚恋
+                excludedDimension: excludedConvertedAudience ? excludedConvertedAudience?.excludedDimension : '0',//排除已转化
+                conversionBehaviorList: excludedConvertedAudience ? excludedConvertedAudience?.conversionBehaviorList[0] : undefined,//排除已转化
+                deviceBrandModelType: deviceBrandModel ? '1' : '0',//设备品牌型号
+                deviceBrandModelList: deviceBrandModel?.excludedList || deviceBrandModel?.includedList,//设备品牌型号
+                isexcluded: deviceBrandModel && deviceBrandModel?.excludedList,//设备品牌型号
+                userOsType:userOs?'1':'0',//操作系统
+                userOsIos:userOs?.filter((os:string)=>os.includes('IOS')),//操作系统
+                userOsAndroid:userOs?.filter((os:string)=>os.includes('ANDROID')),//操作系统
+                networkType:networkType?'1':'0',//联网方式
+                network:networkType,//联网方式
+                devicePriceType:devicePrice?'1':'0',//设备价格
+                devicePrice,//设备价格
+                wechatAdBehaviorType:wechatAdBehavior?'1':'0',//微信再营销
+                actions:wechatAdBehavior?.actions,//再营销
+                excludedActions:wechatAdBehavior?.excludedActions,//排除再营销
             })
         }
-    },[regionsList])
+    }, [regionsList, dataInfo])
     return <Modal
         visible={visible}
-        title={title + '定向'}
-        onCancel={() => { PupFn({ visible: false }) }}
+        title={type === 'add' ? '新建定向' : type === 'look' ? '定向详情' : '编辑定向'}
+        onCancel={() => { PupFn({ visible: false ,dataInfo:null,type:'add'}) }}
         onOk={handleOk}
         width={900}
         confirmLoading={confirmLoading}
+        {...arg}
     >
         <Form
             form={form}

+ 8 - 6
src/pages/launchSystemNew/launchManage/localAd/targeting/tableConfig.tsx

@@ -1,6 +1,6 @@
 import React from 'react'
 import { Space } from 'antd'
-function tableConfig():any{
+function tableConfig(callback:(data:any,type:'edit'|'look')=>void):any{
     return [
         {
             title: 'ID',
@@ -32,11 +32,13 @@ function tableConfig():any{
             dataIndex:'cz',
             key: 'cz',
             align: 'center',  
-            render:()=>{
-               return <Space>
-                    <a>详情</a>
-                </Space>
-            }
+            render:(a: any,b: any)=>{
+                return <Space>
+                     <a onClick={()=>{
+                         callback(b,'look')
+                     }}>详情</a>
+                 </Space>
+             }
         }
     ]
 }

+ 4 - 0
src/services/launchAdq/index.d.ts

@@ -790,3 +790,7 @@ export interface AdcreativeTemplate {
     unsupportType: string;
   }[];
 }
+
+
+
+