|
@@ -2,7 +2,7 @@
|
|
|
import { FnAjax, useAjax } from '@/Hook/useAjax'
|
|
|
import { ListData, } from '@/services/launchAdq'
|
|
|
import { PromotedObjectType } from '@/services/launchAdq/enum'
|
|
|
-import { createSysAdcreative, getSysAdcreativeList } from '@/services/launchAdq/creative'
|
|
|
+import { createSysAdcreative, getSysAdcreativeInfo, getSysAdcreativeList } from '@/services/launchAdq/creative'
|
|
|
import { Col, Row, Input, Select, Button } from 'antd'
|
|
|
import React, { useEffect, useState, useCallback } from 'react'
|
|
|
import TableData from '../../../components/TableData'
|
|
@@ -11,19 +11,21 @@ import tableConfig from './tableConfig'
|
|
|
|
|
|
export interface ModalConfig {
|
|
|
visible: boolean;
|
|
|
- title?: string;
|
|
|
+ type?:'add'|'look'|'edit',
|
|
|
+ dataInfo?:null
|
|
|
}
|
|
|
|
|
|
function Creative() {
|
|
|
// 变量
|
|
|
const [modalConfig, setModalConfig] = useState<ModalConfig>({
|
|
|
visible: false,
|
|
|
- title: '新建'
|
|
|
+ type:'add'
|
|
|
})
|
|
|
const [oldsearchData, setOldsearchData] = useState<any>(null)
|
|
|
// api方法
|
|
|
- const sysAdcreativeList: FnAjax<ListData<any>|any> = useAjax((params) => getSysAdcreativeList(params),{formatResult:true})
|
|
|
+ const sysAdcreativeList: FnAjax<ListData<any> | any> = useAjax((params) => getSysAdcreativeList(params), { formatResult: true })
|
|
|
const createSysAdgroup = useAjax((params) => createSysAdcreative(params))
|
|
|
+ const targetingInfo = useAjax((params) => getSysAdcreativeInfo(params),{formatResult:true})
|
|
|
// 初始获取列表
|
|
|
useEffect(() => {
|
|
|
getList({ pageSize: 20, pageNum: 1 })
|
|
@@ -49,14 +51,24 @@ function Creative() {
|
|
|
createSysAdgroup.run(arg).then(res => {
|
|
|
if (res) {
|
|
|
sysAdcreativeList.refresh()
|
|
|
- handleModalConfig({ visible: false })
|
|
|
+ handleModalConfig({ visible: false,dataInfo:null,type:'add' })
|
|
|
}
|
|
|
})
|
|
|
}, [sysAdcreativeList])
|
|
|
- console.log(sysAdcreativeList)
|
|
|
+ // 获取详情
|
|
|
+ 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={sysAdcreativeList}
|
|
|
dataSource={sysAdcreativeList?.data?.data?.records}
|
|
|
loading={sysAdcreativeList?.loading}
|
|
@@ -114,7 +126,7 @@ function Creative() {
|
|
|
getList({ pageNum: current, pageSize })
|
|
|
}}
|
|
|
/>
|
|
|
- {modalConfig.visible && <AdModal visible={modalConfig.visible} title={modalConfig.title} PupFn={handleModalConfig} callback={submit} confirmLoading={createSysAdgroup.loading} />}
|
|
|
+ {modalConfig.visible && <AdModal visible={modalConfig.visible} type={modalConfig.type} PupFn={handleModalConfig} callback={submit} confirmLoading={createSysAdgroup.loading} dataInfo={modalConfig.dataInfo}/>}
|
|
|
</div>
|
|
|
}
|
|
|
export default Creative
|