Sfoglia il codice sorgente

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

wjx 2 anni fa
parent
commit
5d5ce1a5d4

+ 12 - 8
src/pages/launchSystemNew/account/appointPut.tsx

@@ -40,16 +40,20 @@ const AppointPut: React.FC<Props> = (props) => {
             let res = allOfMember?.data || await allOfMember.run()
             if (res?.data) {
                 let useAll: any = []
-                res?.data?.forEach((item: { key: { userId: any; nickName: any; }; value: any[]; }) => {
+                res?.data?.forEach((item: any) => {
                     let obj = {
-                        key: item.key.userId,
-                        label: item.key.nickName
-                    }
-                    if (item?.value) {
-                        obj['childrenarr'] = item?.value?.map(item => {
-                            return { key: item.accountId + '_' + item.id, label: item?.remark ? item.accountId + '_' + item?.remark : item.accountId }
-                        })
+                        key: item.userId,
+                        label: item.nickname
                     }
+                    // let obj = {
+                    //     key: item.key.userId,
+                    //     label: item.key.nickName
+                    // }
+                    // if (item?.value) {
+                    //     obj['childrenarr'] = item?.value?.map(item => {
+                    //         return { key: item.accountId + '_' + item.id, label: item?.remark ? item.accountId + '_' + item?.remark : item.accountId }
+                    //     })
+                    // }
                     useAll.push(obj)
                 })
                 setUserAll(useAll)

+ 8 - 6
src/pages/launchSystemNew/account/index.tsx

@@ -10,7 +10,7 @@ import TableData from '../components/TableData'
 import GroupLeft from './groupLeft'
 import { MenuFoldOutlined, MenuUnfoldOutlined, SwapOutlined } from '@ant-design/icons'
 import TeamMembers from '../components/teamMembers'
-import { getAdAccountAllOfMember } from '@/services/launchAdq/adq'
+import { getAdAccountAllOfMember, getErpUserAll } from '@/services/launchAdq/adq'
 import AddAccountToGroup from './addAccountToGroup'
 import { delAccountToGroupApi } from '@/services/launchAdq/subgroup'
 import { useModel } from 'umi'
@@ -58,15 +58,17 @@ const AdAuthorize: React.FC = () => {
     const delAccountToGroup = useAjax((params) => delAccountToGroupApi(params))
     const getAdAccountList = useAjax((params) => getAdAccountListApi(params), { formatResult: true })
     const allOfMember = useAjax(() => getAdAccountAllOfMember(), { formatResult: true })
+    const erpUserALL = useAjax(() => getErpUserAll(), { formatResult: true })
     /*************************/
 
     useEffect(() => {
         groupListInit()
+        !erpUserALL.data  && erpUserALL.run()
     }, [])
 
     useEffect(() => {
         getList()
-    }, [queryForm])
+    }, [])
 
     /** 获取账号列表 */
     const getList = () => {
@@ -164,13 +166,13 @@ const AdAuthorize: React.FC = () => {
                             <Radio.Button value="putUser">批量指派投放助理</Radio.Button>
                         </Radio.Group>
                         <Input.TextArea
-                            placeholder="广告账号, 多个以,隔开(id1,id2)"
+                            placeholder="多个广告账号以,隔开(id1,id2)"
                             allowClear
                             style={{ minWidth: 200 }}
-                            rows={1}
                             value={queryForm?.accountIds}
+                            rows={1}
                             onChange={(e) => {
-                                setQueryForm({ ...queryForm, accountIds: e.target.value })
+                                setQueryForm({ ...queryForm, accountIds: e.target.value.replaceAll(/\s/ig,'') })
                             }}
                         />
                         <Button onClick={getList} type='primary' loading={getAdAccountList.loading}>搜索</Button>
@@ -230,7 +232,7 @@ const AdAuthorize: React.FC = () => {
         {/* 切号 */}
         {checkAccShow && <CheckAccount value={data} visible={checkAccShow} onChange={() => { getList(); setCheckAccShow(false); setSelectAccData([]) }} onClose={() => { setCheckAccShow(false) }} />}
         {/* 指派 */}
-        {puShow && <AppointPut value={puData} visible={puShow} onClose={() => { setPuShow(false) }} allOfMember={allOfMember} onChange={() => { setPuShow(false); getAdAccountList.refresh(); setSelectAccData([]) }} />}
+        {puShow && <AppointPut value={puData} visible={puShow} onClose={() => { setPuShow(false) }} allOfMember={erpUserALL} onChange={() => { setPuShow(false); getAdAccountList.refresh(); setSelectAccData([]) }} />}
 
         {remarkData.visible && <Modal
             visible={remarkData.visible}

+ 41 - 14
src/pages/launchSystemNew/adq/ad/index.tsx

@@ -104,13 +104,13 @@ const Ad: React.FC<Props> = (props) => {
             message.error('请先勾选要同步的广点通账号!')
             return
         }
-        let arr = [...new Set(selectedRows?.map(item=>item.accountId))]
-        syncAjax.run({ accountIdList:arr }).then(res => {
+        let arr = [...new Set(selectedRows?.map(item => item.accountId))]
+        syncAjax.run({ accountIdList: arr }).then(res => {
             res && listAjax.refresh()
             res ? message.success('同步成功!') : message.error('同步失败!')
 
         })
-    }, [listAjax,selectedRows])
+    }, [listAjax, selectedRows])
 
     /** 删除 */
     const deleteHandle = (type: 0 | 1, adgroupId?: number) => {
@@ -190,7 +190,6 @@ const Ad: React.FC<Props> = (props) => {
         setDetailData(data)
         setDetailShow(true)
     }
-
     return <div>
         {/* 修改广告 */}
         {update.visible && <UpdateAd
@@ -417,8 +416,36 @@ const Ad: React.FC<Props> = (props) => {
                             record?.deepConversionSpec?.deepConversionWorthSpec?.goal === 'GOAL_1DAY_PURCHASE_ROAS'
                         )
                 }),
-                onChange: (selectedRowKeys: any, selectedRows: any) => {
-                    setSelectedRows(selectedRows)
+                onSelect: (record: { adgroupId: number, mpName: string }, selected: boolean) => {
+                    if (selected) {
+                        selectedRows.push({ ...record })
+                        setSelectedRows([...selectedRows])
+                    } else {
+                        let newSelectAccData = selectedRows.filter((item: { adgroupId: number }) => item.adgroupId!== record.adgroupId)
+                        setSelectedRows([...newSelectAccData])
+                    }
+                },
+                onSelectAll: (selected: boolean, selectedRowss: { adgroupId: number }[], changeRows: { adgroupId: number }[]) => {
+                    if (selected) {
+                        let newSelectAccData = [...selectedRows]
+                        changeRows.forEach((item: { adgroupId: number }) => {
+                            let index = newSelectAccData.findIndex((ite: { adgroupId: number }) => ite.adgroupId === item.adgroupId)
+                            if (index === -1) {
+                                newSelectAccData.push({ ...item })
+                            }
+                        })
+                        setSelectedRows([...newSelectAccData])
+                    } else {
+                        let newSelectAccData = selectedRows.filter((item: { adgroupId: number }) => {
+                            let index = changeRows.findIndex((ite: { adgroupId: number }) => ite.adgroupId === item.adgroupId)
+                            if (index !== -1) {
+                                return false
+                            } else {
+                                return true
+                            }
+                        })
+                        setSelectedRows([...newSelectAccData])
+                    }
                 }
             }}
             onChange={(props: any) => {
@@ -430,14 +457,14 @@ const Ad: React.FC<Props> = (props) => {
         />
         {detailShow && <PlanDetail visible={detailShow} onClose={() => { setDetailShow(false) }} data={detailData} />}
         {czjlShow && <Modal
-                visible={czjlShow}
-                onCancel={()=>{setCzjlShow(false)}}
-                onOk={()=>{setCzjlShow(false)}}
-                width={1200}
-                footer={null}
-                title={"广告操作记录"}
-            >
-                <Log {...props} />
+            visible={czjlShow}
+            onCancel={() => { setCzjlShow(false) }}
+            onOk={() => { setCzjlShow(false) }}
+            width={1200}
+            footer={null}
+            title={"广告操作记录"}
+        >
+            <Log {...props} />
         </Modal>}
     </div>
 }

+ 44 - 43
src/pages/launchSystemNew/launchManage/createAd/index.tsx

@@ -89,18 +89,18 @@ const CreateAd: React.FC = () => {
     useEffect(() => {
         getGroupList.run()
     }, [])
-
+  
 
     /** 判断出价方式,优化目标 “二方包”人群包仅能在出价方式为CPC(包含oCPM点击优化目标)、CPM场景下使用 */
-    useEffect(() => {
-        if (queryForm?.sysAdgroup && Object.keys(queryForm?.sysAdgroup).length > 0 && (!['BID_MODE_CPC', 'BID_MODE_CPM'].includes(queryForm?.sysAdgroup?.bidMode) || !(queryForm?.sysAdgroup?.bidMode === 'BID_MODE_OCPM' && queryForm?.sysAdgroup?.optimizationGoal === 'OPTIMIZATIONGOAL_CLICK'))) {
-            setAccountCreateLogs(() => accountCreateLogs.map(item => {
-                delete item?.customAudienceList
-                delete item?.excludedCustomAudienceList
-                return item
-            }))
-        }
-    }, [queryForm?.sysAdgroup])
+    // useEffect(() => {
+    //     if (queryForm?.sysAdgroup && Object.keys(queryForm?.sysAdgroup).length > 0 && (!['BID_MODE_CPC', 'BID_MODE_CPM'].includes(queryForm?.sysAdgroup?.bidMode) || !(queryForm?.sysAdgroup?.bidMode === 'BID_MODE_OCPM' && queryForm?.sysAdgroup?.optimizationGoal === 'OPTIMIZATIONGOAL_CLICK'))) {
+    //         setAccountCreateLogs(() => accountCreateLogs.map(item => {
+    //             delete item?.customAudienceList
+    //             delete item?.excludedCustomAudienceList
+    //             return item
+    //         }))
+    //     }
+    // }, [queryForm?.sysAdgroup])
 
     /**数据回填 */
     useEffect(() => {
@@ -111,6 +111,26 @@ const CreateAd: React.FC = () => {
                 let adcreativeTemplateId = adCreateLogs[0]?.sysAdcreative?.adcreativeTemplateId
                 let sysPageId = adCreateLogs[0]?.sysPageId
                 let pageId = adCreateLogs[0]?.pageId
+
+                // 账号信息相关
+                let adCreateLogsData = adCreateLogs?.map((item: any) => {
+                    return {
+                        adAccountId: item?.accountId,
+                        id: item?.adAccountId,
+                        // 数据源
+                        userActionSetsList: item?.userActionSetList?.map((item: any) => ({ ...item, id: item?.userActionSetId })),
+                        // 商品
+                        productList: item?.product ? [{ ...item?.product, productCatalog: item?.productCatalog, id: Number(item?.product?.productOuterId?.replace(/\D/ig, '')) }] : undefined,
+                        coldStartAudienceList: item?.coldStartAudienceList?.map((item: any) => ({ ...item, id: item.audienceId })),
+                        // pageList: [item.page]
+                        // 定向用户群
+                        customAudienceList: item?.customAudienceList?.map((item: any) => ({ ...item, id: item.audienceId })),
+                        // 排除用户群
+                        excludedCustomAudienceList: item?.excludedCustomAudienceList?.map((item: any) => ({ ...item, id: item.audienceId }))
+                    }
+                }).filter((item: any, index: number, self: any) => self.findIndex((i: any) => i.id == item.id) === index)
+                setAccountCreateLogs(adCreateLogsData)
+
                 let type: 1 | 2 = 1
                 if (sysPageId && pageId) {
                     type = 1
@@ -134,29 +154,28 @@ const CreateAd: React.FC = () => {
                 /** 云端落地页 */
                 let adqPageList: any[] = []
                 let taskMediaMaps: any[] = []
-                const sorted = groupBy(adCreateLogs, (item) => [item.accountId])
                 let type2Data = {}
-
                 if (type === 1) {
-                    pageList = sorted[0]?.map((item: any) => {
-                        if (item?.sysPageId) {
-                            return item.sysPage
+                    const sorted = groupBy(adCreateLogs, (item) => [item.sysAdcreativeId])
+                    pageList = sorted?.map((item: any[]) => {
+                        if (item.some((item1: { sysPageId: number }) => item1.sysPageId)) {
+                            return item[0].sysPage
                         } else {
                             return null
                         }
                     })
-                    adqPageList = sorted[0]?.map((item: any) => {
-                        if (item?.pageId) {
-                            return {
-                                pageList: [{ ...item.page, id: item.page.pageId }],
-                                adAccountId: item?.accountId,
-                                id: item?.adAccountId,
-                            }
+                    adqPageList = sorted?.map((item: any[]) => {
+                        if (item.some((item1: { pageId: number }) => item1.pageId)) {
+                            return item.map((item1: any) => ({
+                                pageList: [{ ...item1.page, id: item1.page.pageId }],
+                                adAccountId: item1?.accountId,
+                                id: item1?.adAccountId,
+                            }))
                         } else {
                             return null
                         }
                     })
-                    taskMediaMaps = sorted[0]?.map((item: any, index: number) => {
+                    taskMediaMaps = groupBy(adCreateLogs, (item) => [item.accountId])?.[0]?.map((item: any, index: number) => {
                         let pageElementsSpecList = item?.sysPage?.pageSpecsList[0]?.pageElementsSpecList // 内容区
                         let globalSpec = item?.sysPage?.globalSpec  // 悬浮组件
                         /** 处理客服 */
@@ -171,7 +190,7 @@ const CreateAd: React.FC = () => {
                             if ((globalSpec?.globalElementsSpecList?.length > 0 && globalSpec?.globalElementsSpecList)) {
                                 groupList.push({ type: 2, name: '悬浮组件', cropList: [] })
                             }
-                            cropUserGroupMap = groupBy(adCreateLogs, (item) => [item.sysAdcreativeId])[0]?.map((item: any) => {
+                            cropUserGroupMap = sorted[0]?.map((item: any) => {
                                 let corpUserGroup1s = item?.corpUserGroup1s
                                 let corpUserGroup2s = item?.corpUserGroup2s
                                 return {
@@ -192,6 +211,7 @@ const CreateAd: React.FC = () => {
                         return { sysAdcreative: item?.sysAdcreative, sysPageId: item?.sysPageId, cropUserGroupMap, accountPageIdMap }
                     })
                 } else {
+                    const sorted = groupBy(adCreateLogs, (item) => [item.accountId])
                     let adCreateLog = adCreateLogs[0]
                     if (adCreateLog?.sysPageId) {
                         pageList = [adCreateLog?.sysPage]
@@ -351,25 +371,6 @@ const CreateAd: React.FC = () => {
                     pageList,
                     adqPageList
                 })
-
-                // 账号信息相关
-                let adCreateLogsData = adCreateLogs?.map((item: any) => {
-                    return {
-                        adAccountId: item?.accountId,
-                        id: item?.adAccountId,
-                        // 数据源
-                        userActionSetsList: item?.userActionSetList?.map((item: any) => ({ ...item, id: item?.userActionSetId })),
-                        // 商品
-                        productList: item?.product ? [{ ...item?.product, productCatalog: item?.productCatalog, id: Number(item?.product?.productOuterId?.replace(/\D/ig, '')) }] : undefined,
-                        coldStartAudienceList: item?.coldStartAudienceList?.map((item: any) => ({ ...item, id: item.audienceId })),
-                        // pageList: [item.page]
-                        // 定向用户群
-                        customAudienceList: item?.customAudienceList?.map((item: any) => ({ ...item, id: item.audienceId })),
-                        // 排除用户群
-                        excludedCustomAudienceList: item?.excludedCustomAudienceList?.map((item: any) => ({ ...item, id: item.audienceId }))
-                    }
-                }).filter((item: any, index: number, self: any) => self.findIndex((i: any) => i.id == item.id) === index)
-                setAccountCreateLogs(adCreateLogsData)
             })
             sessionStorage.removeItem('TASKID')
         } else {

+ 2 - 8
src/pages/launchSystemNew/launchManage/createAd/targeting/index.tsx

@@ -64,14 +64,8 @@ function TargetIng(props: Props) {
                     {
                         key: '1',
                         label: <>
-                            {queryForm?.sysAdgroup && Object.keys(queryForm?.sysAdgroup).length > 0 ? (['BID_MODE_CPC', 'BID_MODE_CPM'].includes(queryForm?.sysAdgroup?.bidMode) || (queryForm?.sysAdgroup?.bidMode === 'BID_MODE_OCPM' && queryForm?.sysAdgroup?.optimizationGoal === 'OPTIMIZATIONGOAL_CLICK')) ? <>
-                                {accountCreateLogs?.length > 0 && queryForm?.sysTargeting ? <Button type="link" style={{ fontSize: 12, padding: 0 }} onClick={() => setCpVisible(true)}>选择定向包</Button> : <Tooltip title={accountCreateLogs?.length > 0 ? `请先添加定向` : `请先选择媒体账户`}>
-                                    <Button type="link" disabled style={{ fontSize: 12, padding: 0 }}>选择定向包</Button>
-                                </Tooltip>}
-                            </> : <Tooltip title='“二方包”人群包仅能在出价方式为CPC(包含oCPM点击优化目标)、CPM场景下使用'>
-                                <Button type="link" disabled style={{ fontSize: 12, padding: 0 }}>选择定向包</Button>
-                            </Tooltip> : <Tooltip title='请先设置广告基本信息'>
-                                <Button type="link" disabled style={{ fontSize: 12, padding: 0 }}>选择定向包</Button>
+                            {accountCreateLogs?.length > 0 && queryForm?.sysTargeting ? <Button type="link" style={{ fontSize: 12, padding: 0 }} onClick={() => setCpVisible(true)}>选择定向包</Button> : <Tooltip title={accountCreateLogs?.length > 0 ? `请先添加定向` : `请先选择媒体账户`}>
+                                <Button type="link" style={{ fontSize: 12, padding: 0 }}>选择定向包</Button>
                             </Tooltip>}
                         </>
                     },

+ 8 - 0
src/services/launchAdq/adq.ts

@@ -7,6 +7,14 @@ import { api } from '../api';
 export async function getAdAccountAllOfMember() {
   return request(api + '/adq/adAccount/allOfMember');
 }
+/***
+ * 无权限限制获取全部用户列表
+ * 
+ */ 
+export async function getErpUserAll(){
+  return request(api+`/erp/user/all`)
+}
+
 
 /**
  * 获取ADQ账号列表

+ 1 - 1
src/services/launchAdq/createAd.ts

@@ -173,7 +173,7 @@ export async function getCropWechatApi(data: number[]) {
  * @returns 
  */
 export async function sysCropWechatApi({ accountId, corpId }: { accountId: number, corpId: number }) {
-  return request(api + `/adq/cropWechatCsgroup/syncByAccount/${accountId}/${corpId}`, {
+  return request(api + `/adq/corpWechatCsgroup/syncByAccount/${accountId}/${corpId}`, {
     method: 'POST'
   })
 }