wjx 9 месяцев назад
Родитель
Сommit
22556c4453

+ 18 - 2
src/pages/launchSystemV3/tencentAdPutIn/taskList/log.tsx

@@ -1,9 +1,10 @@
 import { useAjax } from "@/Hook/useAjax"
 import { getTaskV3LogListApi } from "@/services/adqV3"
-import { Button, Drawer, Space, Table, Tag } from "antd"
+import { Button, Drawer, Space, Table, Tag, message } from "antd"
 import React, { useEffect, useState } from "react"
 import { columnsLog } from "./tableConfig"
 import DynamicLog from "./dynamicLog"
+import { syncAdInfoApi } from "@/services/adqV3/global"
 
 interface Props {
     data: any
@@ -22,6 +23,7 @@ const Log: React.FC<Props> = (props) => {
     const [queryForm, setQueryForm] = useState<PULLIN.GetTaskV3LogProps>({ pageNum: 1, pageSize: 20 })
 
     const getTaskV3LogList = useAjax((params) => getTaskV3LogListApi(params), { formatResult: true })
+    const syncAdInfo = useAjax((params) => syncAdInfoApi(params))
     /*****************************/
 
     useEffect(() => {
@@ -35,6 +37,20 @@ const Log: React.FC<Props> = (props) => {
         }
     }
 
+    // 同步
+    const sync = (value: any) => {
+        const hide = message.loading(`正在同步...`, 0, () => {
+            message.success('同步成功,结果可能几分钟之后返回');
+        });
+        syncAdInfo.run({ accountAdgroupMaps: [value.accountId + ',' + value.adgroupId], adgroupCreateLogId: value.id }).then(res => {
+            if(res) {
+                getTaskV3LogList.refresh()
+                message.success('同步成功,结果可能几分钟之后返回')
+                hide()
+            }
+        })
+    }
+
     return <Drawer
         bodyStyle={{ padding: 0 }}
         title={<Space>
@@ -47,7 +63,7 @@ const Log: React.FC<Props> = (props) => {
         visible={visible}
     >
         <Table
-            columns={columnsLog()}
+            columns={columnsLog(sync)}
             dataSource={getTaskV3LogList?.data?.data?.records}
             size="small"
             loading={getTaskV3LogList?.loading}

+ 12 - 2
src/pages/launchSystemV3/tencentAdPutIn/taskList/tableConfig.tsx

@@ -169,7 +169,7 @@ const columns = (geoLocationList: any, modelList: any, callback: (data: any, typ
 
 export default columns
 
-export const columnsLog = (): TableProps<any>['columns'] => {
+export const columnsLog = (sync: (value: any) => void): TableProps<any>['columns'] => {
     return [
         {
             title: '广告账号',
@@ -230,7 +230,7 @@ export const columnsLog = (): TableProps<any>['columns'] => {
             width: 90,
             align: 'center',
             render(value) {
-                return { 0: <Badge status="processing" text={<span style={{ fontSize: 12 }}>执行中</span>} />, 1: <Badge status="error" style={{ fontSize: 12 }} text={<span>失败</span>} />, 100: <Badge style={{ fontSize: 12 }} status="success" text={<span>成功</span>} /> }[value]
+                return { 0: <Badge status="processing" text={<span style={{ fontSize: 12 }}>执行中</span>} />, 1: <Badge status="error" style={{ fontSize: 12 }} text={<span>失败</span>} />, 101: <Badge status="warning" style={{ fontSize: 12 }} text={<span>同步异常</span>} />, 100: <Badge style={{ fontSize: 12 }} status="success" text={<span>成功</span>} /> }[value]
             },
         },
         {
@@ -255,6 +255,16 @@ export const columnsLog = (): TableProps<any>['columns'] => {
                 return <span style={{ fontSize: 12 }}>{value}</span>
             }
         },
+        {
+            title: '操作',
+            dataIndex: 'cz',
+            key: 'cz',
+            width: 70,
+            align: 'center',
+            render(_, records) {
+                return records?.adgroupStatus === 101 ? <a style={{ fontSize: 12 }} onClick={() => sync(records)}>同步</a> : '--'
+            }
+        }
     ]
 }
 

+ 12 - 0
src/services/adqV3/global.ts

@@ -312,4 +312,16 @@ export async function getCreativeReviewDetailApi({ accountId, dynamicCreativeIds
         data: dynamicCreativeIds,
         params: { accountId }
     })
+}
+
+/**
+ * 同步广告
+ * @param data 
+ * @returns 
+ */
+export async function syncAdInfoApi(data: { accountAdgroupMaps: string[], adgroupCreateLogId: number }) {
+    return request(api + `/adq/syncAdInfo/syncByAdgroupIds`, {
+        method: 'POST',
+        data
+    })
 }