|
@@ -1,7 +1,7 @@
|
|
import React, { useEffect, useRef, useState } from "react"
|
|
import React, { useEffect, useRef, useState } from "react"
|
|
import '../../tencentAdPutIn/index.less'
|
|
import '../../tencentAdPutIn/index.less'
|
|
-import { Button, Card, DatePicker, Input, message, Pagination, Popconfirm, Select, Space, Switch, Table, Tabs } from "antd"
|
|
|
|
-import { delComponentApi, getCreativeComponentListApi, GetCreativeComponentProps, getDefaultSharingApi, updateDefaultSharingApi } from "@/services/adqV3/global"
|
|
|
|
|
|
+import { Button, Card, DatePicker, Input, message, Pagination, Popconfirm, Select, Space, Switch, Tabs } from "antd"
|
|
|
|
+import { delComponentApi, getCreativeComponentDataListApi, GetCreativeComponentProps, getDefaultSharingApi, updateDefaultSharingApi } from "@/services/adqV3/global"
|
|
import './index.less'
|
|
import './index.less'
|
|
import { DeleteOutlined, PlusOutlined, SyncOutlined } from "@ant-design/icons"
|
|
import { DeleteOutlined, PlusOutlined, SyncOutlined } from "@ant-design/icons"
|
|
import { useAjax } from "@/Hook/useAjax"
|
|
import { useAjax } from "@/Hook/useAjax"
|
|
@@ -9,9 +9,10 @@ import SelectAdAccount from "@/components/SelectAdAccount"
|
|
import { COMMON_POTENTIAL_STATUS_ENUM, COMPONENT_GENERATION_TYPE_ENUM, DEFAULT_COMPONENT_SUB_IMAGE_TYPE, DEFAULT_COMPONENT_SUB_SHOW_IMAGE, DEFAULT_COMPONENT_SUB_SHOW_VIDEO, DEFAULT_COMPONENT_SUB_VIDEO_TYPE } from "./const"
|
|
import { COMMON_POTENTIAL_STATUS_ENUM, COMPONENT_GENERATION_TYPE_ENUM, DEFAULT_COMPONENT_SUB_IMAGE_TYPE, DEFAULT_COMPONENT_SUB_SHOW_IMAGE, DEFAULT_COMPONENT_SUB_SHOW_VIDEO, DEFAULT_COMPONENT_SUB_VIDEO_TYPE } from "./const"
|
|
import moment from "moment"
|
|
import moment from "moment"
|
|
import { useDebounce, useSize } from "ahooks"
|
|
import { useDebounce, useSize } from "ahooks"
|
|
-import TableConfig from "./tableConfig"
|
|
|
|
import AddComponents from "./addComponents"
|
|
import AddComponents from "./addComponents"
|
|
import { DefaultOptionType } from "antd/lib/select"
|
|
import { DefaultOptionType } from "antd/lib/select"
|
|
|
|
+import TablePro from "@/components/TablePro"
|
|
|
|
+import columns12 from "./tableConfig"
|
|
|
|
|
|
/**
|
|
/**
|
|
* 创意组件
|
|
* 创意组件
|
|
@@ -27,6 +28,9 @@ const ManageComponent: React.FC = () => {
|
|
const debouncedComponentIdStingSting = useDebounce(componentIdSting, { wait: 500 });
|
|
const debouncedComponentIdStingSting = useDebounce(componentIdSting, { wait: 500 });
|
|
const ref = useRef<HTMLDivElement>(null);
|
|
const ref = useRef<HTMLDivElement>(null);
|
|
const size = useSize(ref);
|
|
const size = useSize(ref);
|
|
|
|
+ const ref1 = useRef<HTMLDivElement>(null);
|
|
|
|
+ const size1 = useSize(ref1);
|
|
|
|
+ const [tableHeaderHeight, setTableHeaderHeight] = useState<number>(0)
|
|
const [addVisible, setAddVisible] = useState<boolean>(false)
|
|
const [addVisible, setAddVisible] = useState<boolean>(false)
|
|
const [loading, setLoading] = useState<boolean>(true)
|
|
const [loading, setLoading] = useState<boolean>(true)
|
|
const [adUnitAccount, setAdUnitAccount] = useState<number>()
|
|
const [adUnitAccount, setAdUnitAccount] = useState<number>()
|
|
@@ -34,7 +38,7 @@ const ManageComponent: React.FC = () => {
|
|
const [putInType, setPutInType] = useState<'NOVEL' | 'GAME'>('NOVEL')
|
|
const [putInType, setPutInType] = useState<'NOVEL' | 'GAME'>('NOVEL')
|
|
const [selectedRows, setSelectedRows] = useState<any[]>([])
|
|
const [selectedRows, setSelectedRows] = useState<any[]>([])
|
|
|
|
|
|
- const getCreativeComponentList = useAjax((params) => getCreativeComponentListApi(params))
|
|
|
|
|
|
+ const getCreativeComponentList = useAjax((params) => getCreativeComponentDataListApi(params))
|
|
const getDefaultSharing = useAjax((params) => getDefaultSharingApi(params))
|
|
const getDefaultSharing = useAjax((params) => getDefaultSharingApi(params))
|
|
const updateDefaultSharing = useAjax((params) => updateDefaultSharingApi(params))
|
|
const updateDefaultSharing = useAjax((params) => updateDefaultSharingApi(params))
|
|
const delComponent = useAjax((params) => delComponentApi(params))
|
|
const delComponent = useAjax((params) => delComponentApi(params))
|
|
@@ -57,6 +61,29 @@ const ManageComponent: React.FC = () => {
|
|
}
|
|
}
|
|
}, [queryParams, debouncedIdSting, debouncedComponentIdStingSting])
|
|
}, [queryParams, debouncedIdSting, debouncedComponentIdStingSting])
|
|
|
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
+ // 1. 通过选择器获取目标元素
|
|
|
|
+ const element = document.querySelector('.ant-table-header');
|
|
|
|
+ if (!element) return;
|
|
|
|
+
|
|
|
|
+ // 2. 创建 ResizeObserver
|
|
|
|
+ const observer = new ResizeObserver((entries) => {
|
|
|
|
+ for (const entry of entries) { // 遍历 entries 数组
|
|
|
|
+ const observedHeight = entry.contentRect.height; // 提取 contentRect
|
|
|
|
+ setTableHeaderHeight(observedHeight)
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 3. 开始观察
|
|
|
|
+ observer.observe(element);
|
|
|
|
+
|
|
|
|
+ // 4. 清理函数
|
|
|
|
+ return () => {
|
|
|
|
+ observer.unobserve(element);
|
|
|
|
+ observer.disconnect();
|
|
|
|
+ };
|
|
|
|
+ }, [])
|
|
|
|
+
|
|
const handleGet = (adAccountId: number) => {
|
|
const handleGet = (adAccountId: number) => {
|
|
getDefaultSharing.run({ adAccountId }).then(res => {
|
|
getDefaultSharing.run({ adAccountId }).then(res => {
|
|
if (res) {
|
|
if (res) {
|
|
@@ -75,9 +102,9 @@ const ManageComponent: React.FC = () => {
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
|
|
- const handleDel = (id: number[]) => {
|
|
|
|
|
|
+ const handleDel = (id: number[], accountId: number) => {
|
|
const hide = message.loading('正在删除...', 0)
|
|
const hide = message.loading('正在删除...', 0)
|
|
- delComponent.run({ componentId: id, adAccountId: queryParams?.adAccountId }).then(res => {
|
|
|
|
|
|
+ delComponent.run({ componentId: id, adAccountId: accountId }).then(res => {
|
|
hide()
|
|
hide()
|
|
if (res?.length === 0) {
|
|
if (res?.length === 0) {
|
|
message.success('删除成功')
|
|
message.success('删除成功')
|
|
@@ -133,7 +160,7 @@ const ManageComponent: React.FC = () => {
|
|
<Button icon={<SyncOutlined />} type="link" onClick={() => { getCreativeComponentList.refresh() }} loading={getCreativeComponentList.loading}></Button>
|
|
<Button icon={<SyncOutlined />} type="link" onClick={() => { getCreativeComponentList.refresh() }} loading={getCreativeComponentList.loading}></Button>
|
|
<Popconfirm
|
|
<Popconfirm
|
|
title="确定删除?"
|
|
title="确定删除?"
|
|
- onConfirm={() => { handleDel(selectedRows.map(item => item.componentId)) }}
|
|
|
|
|
|
+ onConfirm={() => { handleDel(selectedRows.map(item => item.componentId), queryParams?.adAccountId as number) }}
|
|
disabled={selectedRows.length === 0}
|
|
disabled={selectedRows.length === 0}
|
|
>
|
|
>
|
|
<Button icon={<DeleteOutlined />} type="primary" danger size="small" disabled={selectedRows.length === 0} loading={delComponent.loading}>删除</Button>
|
|
<Button icon={<DeleteOutlined />} type="primary" danger size="small" disabled={selectedRows.length === 0} loading={delComponent.loading}>删除</Button>
|
|
@@ -160,103 +187,131 @@ const ManageComponent: React.FC = () => {
|
|
padding: 0
|
|
padding: 0
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
- <div className="manageComponent-header">
|
|
|
|
- <Button icon={<PlusOutlined />} type="primary" onClick={() => { setAddVisible(true) }}>新建组件</Button>
|
|
|
|
- <Input.TextArea
|
|
|
|
- style={{ width: 160 }}
|
|
|
|
- value={idSting}
|
|
|
|
- rows={1}
|
|
|
|
- placeholder="素材ID(多个,,空格换行)"
|
|
|
|
- allowClear
|
|
|
|
- onChange={(e) => setIdSting(e.target.value)}
|
|
|
|
- />
|
|
|
|
- <Input.TextArea
|
|
|
|
- style={{ width: 160 }}
|
|
|
|
- value={componentIdSting}
|
|
|
|
- rows={1}
|
|
|
|
- placeholder="组件ID(多个,,空格换行)"
|
|
|
|
- allowClear
|
|
|
|
- onChange={(e) => setComponentIdSting(e.target.value)}
|
|
|
|
- />
|
|
|
|
- <Select
|
|
|
|
- showSearch
|
|
|
|
- placeholder="二级组件类型"
|
|
|
|
- filterOption={(input, option) =>
|
|
|
|
- ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
|
|
|
|
- }
|
|
|
|
- style={{ minWidth: 120 }}
|
|
|
|
- maxTagCount={1}
|
|
|
|
- mode="multiple"
|
|
|
|
- allowClear
|
|
|
|
- value={queryParams?.componentSubType}
|
|
|
|
- onChange={(e) => {
|
|
|
|
- setQueryParams({ ...queryParams, componentSubType: e, pageNum: 1 })
|
|
|
|
- }}
|
|
|
|
- options={(queryParams?.activeKey === 'IMAGE' ? DEFAULT_COMPONENT_SUB_IMAGE_TYPE : DEFAULT_COMPONENT_SUB_VIDEO_TYPE) as DefaultOptionType[]}
|
|
|
|
- />
|
|
|
|
- <Select
|
|
|
|
- showSearch
|
|
|
|
- placeholder="已删除?"
|
|
|
|
- filterOption={(input, option) =>
|
|
|
|
- ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
|
|
|
|
- }
|
|
|
|
- style={{ width: 100 }}
|
|
|
|
- value={queryParams?.isDeleted}
|
|
|
|
- allowClear
|
|
|
|
- onChange={(e) => {
|
|
|
|
- setQueryParams({ ...queryParams, isDeleted: e, pageNum: 1 })
|
|
|
|
- }}
|
|
|
|
- options={[
|
|
|
|
- { label: '已删除', value: true },
|
|
|
|
- { label: '未删除', value: false }
|
|
|
|
- ]}
|
|
|
|
- />
|
|
|
|
- <Select
|
|
|
|
- showSearch
|
|
|
|
- placeholder="组件潜力"
|
|
|
|
- filterOption={(input, option) =>
|
|
|
|
- ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
|
|
|
|
- }
|
|
|
|
- style={{ minWidth: 100 }}
|
|
|
|
- maxTagCount={1}
|
|
|
|
- mode="multiple"
|
|
|
|
- value={queryParams?.potentialStatus}
|
|
|
|
- onChange={(e) => {
|
|
|
|
- setQueryParams({ ...queryParams, potentialStatus: e, pageNum: 1 })
|
|
|
|
- }}
|
|
|
|
- options={Object.keys(COMMON_POTENTIAL_STATUS_ENUM).map(key => ({ label: COMMON_POTENTIAL_STATUS_ENUM[key as keyof typeof COMMON_POTENTIAL_STATUS_ENUM], value: key }))}
|
|
|
|
- />
|
|
|
|
- <Select
|
|
|
|
- showSearch
|
|
|
|
- placeholder="来源"
|
|
|
|
- filterOption={(input, option) =>
|
|
|
|
- ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
|
|
|
|
- }
|
|
|
|
- style={{ minWidth: 100 }}
|
|
|
|
- maxTagCount={1}
|
|
|
|
- mode="multiple"
|
|
|
|
- value={queryParams?.generationType}
|
|
|
|
- onChange={(e) => {
|
|
|
|
- setQueryParams({ ...queryParams, generationType: e, pageNum: 1 })
|
|
|
|
- }}
|
|
|
|
- options={Object.keys(COMPONENT_GENERATION_TYPE_ENUM).map(key => ({ label: COMPONENT_GENERATION_TYPE_ENUM[key as keyof typeof COMPONENT_GENERATION_TYPE_ENUM], value: key }))}
|
|
|
|
- />
|
|
|
|
- <DatePicker.RangePicker
|
|
|
|
- placeholder={['创建时间开始', '创建时间结束']}
|
|
|
|
- value={queryParams?.createTimeMin && queryParams?.createTimeMax ? [moment(queryParams?.createTimeMin), moment(queryParams?.createTimeMax)] as any : undefined}
|
|
|
|
- onChange={(_, option) => setQueryParams({ ...queryParams, createTimeMin: option[0], createTimeMax: option[1], pageNum: 1 })}
|
|
|
|
- />
|
|
|
|
- </div>
|
|
|
|
|
|
+
|
|
<div className="manageComponent-content" ref={ref}>
|
|
<div className="manageComponent-content" ref={ref}>
|
|
- <Table
|
|
|
|
- columns={TableConfig(queryParams?.activeKey as any, handleDel)}
|
|
|
|
- dataSource={getCreativeComponentList.data?.records || []}
|
|
|
|
|
|
+ <TablePro
|
|
|
|
+ leftChild={<div className="manageComponent-header" ref={ref1}>
|
|
|
|
+ <Button icon={<PlusOutlined />} type="primary" onClick={() => { setAddVisible(true) }}>新建组件</Button>
|
|
|
|
+ <Input
|
|
|
|
+ style={{ width: 100 }}
|
|
|
|
+ value={queryParams?.componentCustomName}
|
|
|
|
+ placeholder="组件名称"
|
|
|
|
+ allowClear
|
|
|
|
+ onChange={(e) => setQueryParams({ ...queryParams, componentCustomName: e.target.value, pageNum: 1 })}
|
|
|
|
+ />
|
|
|
|
+ <Input.TextArea
|
|
|
|
+ style={{ width: 160 }}
|
|
|
|
+ value={idSting}
|
|
|
|
+ rows={1}
|
|
|
|
+ placeholder="素材ID(多个,,空格换行)"
|
|
|
|
+ allowClear
|
|
|
|
+ onChange={(e) => setIdSting(e.target.value)}
|
|
|
|
+ />
|
|
|
|
+ <Input.TextArea
|
|
|
|
+ style={{ width: 160 }}
|
|
|
|
+ value={componentIdSting}
|
|
|
|
+ rows={1}
|
|
|
|
+ placeholder="组件ID(多个,,空格换行)"
|
|
|
|
+ allowClear
|
|
|
|
+ onChange={(e) => setComponentIdSting(e.target.value)}
|
|
|
|
+ />
|
|
|
|
+ <Select
|
|
|
|
+ showSearch
|
|
|
|
+ placeholder="二级组件类型"
|
|
|
|
+ filterOption={(input, option) =>
|
|
|
|
+ ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
|
|
|
|
+ }
|
|
|
|
+ style={{ minWidth: 120 }}
|
|
|
|
+ maxTagCount={1}
|
|
|
|
+ mode="multiple"
|
|
|
|
+ allowClear
|
|
|
|
+ value={queryParams?.componentSubType}
|
|
|
|
+ onChange={(e) => {
|
|
|
|
+ setQueryParams({ ...queryParams, componentSubType: e, pageNum: 1 })
|
|
|
|
+ }}
|
|
|
|
+ options={(queryParams?.activeKey === 'IMAGE' ? DEFAULT_COMPONENT_SUB_IMAGE_TYPE : DEFAULT_COMPONENT_SUB_VIDEO_TYPE) as DefaultOptionType[]}
|
|
|
|
+ />
|
|
|
|
+ <Select
|
|
|
|
+ showSearch
|
|
|
|
+ placeholder="已删除?"
|
|
|
|
+ filterOption={(input, option) =>
|
|
|
|
+ ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
|
|
|
|
+ }
|
|
|
|
+ style={{ width: 100 }}
|
|
|
|
+ value={queryParams?.isDeleted}
|
|
|
|
+ allowClear
|
|
|
|
+ onChange={(e) => {
|
|
|
|
+ setQueryParams({ ...queryParams, isDeleted: e, pageNum: 1 })
|
|
|
|
+ }}
|
|
|
|
+ options={[
|
|
|
|
+ { label: '已删除', value: true },
|
|
|
|
+ { label: '未删除', value: false }
|
|
|
|
+ ]}
|
|
|
|
+ />
|
|
|
|
+ <Select
|
|
|
|
+ showSearch
|
|
|
|
+ placeholder="组件潜力"
|
|
|
|
+ filterOption={(input, option) =>
|
|
|
|
+ ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
|
|
|
|
+ }
|
|
|
|
+ style={{ minWidth: 100 }}
|
|
|
|
+ maxTagCount={1}
|
|
|
|
+ mode="multiple"
|
|
|
|
+ value={queryParams?.potentialStatus}
|
|
|
|
+ onChange={(e) => {
|
|
|
|
+ setQueryParams({ ...queryParams, potentialStatus: e, pageNum: 1 })
|
|
|
|
+ }}
|
|
|
|
+ options={Object.keys(COMMON_POTENTIAL_STATUS_ENUM).map(key => ({ label: COMMON_POTENTIAL_STATUS_ENUM[key as keyof typeof COMMON_POTENTIAL_STATUS_ENUM], value: key }))}
|
|
|
|
+ />
|
|
|
|
+ <Select
|
|
|
|
+ showSearch
|
|
|
|
+ placeholder="来源"
|
|
|
|
+ filterOption={(input, option) =>
|
|
|
|
+ ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
|
|
|
|
+ }
|
|
|
|
+ style={{ minWidth: 75 }}
|
|
|
|
+ maxTagCount={1}
|
|
|
|
+ mode="multiple"
|
|
|
|
+ value={queryParams?.generationType}
|
|
|
|
+ onChange={(e) => {
|
|
|
|
+ setQueryParams({ ...queryParams, generationType: e, pageNum: 1 })
|
|
|
|
+ }}
|
|
|
|
+ options={Object.keys(COMPONENT_GENERATION_TYPE_ENUM).map(key => ({ label: COMPONENT_GENERATION_TYPE_ENUM[key as keyof typeof COMPONENT_GENERATION_TYPE_ENUM], value: key }))}
|
|
|
|
+ />
|
|
|
|
+ <DatePicker.RangePicker
|
|
|
|
+ placeholder={['创建时间开始', '创建时间结束']}
|
|
|
|
+ style={{ width: 250 }}
|
|
|
|
+ value={queryParams?.createTimeMin && queryParams?.createTimeMax ? [moment(queryParams?.createTimeMin), moment(queryParams?.createTimeMax)] as any : undefined}
|
|
|
|
+ onChange={(_, option) => setQueryParams({ ...queryParams, createTimeMin: option[0], createTimeMax: option[1], pageNum: 1 })}
|
|
|
|
+ />
|
|
|
|
+ </div>}
|
|
|
|
+ refreshAjax={() => getCreativeComponentList.refresh()}
|
|
|
|
+ rowKey="componentId"
|
|
|
|
+ config={columns12(handleDel)}
|
|
|
|
+ fixed={{ left: 1, right: 0 }}
|
|
|
|
+ scroll={{ x: 1000, y: (size?.height || 0) - ((size1?.height || 33) + (tableHeaderHeight || 45) + 20) }}
|
|
|
|
+ configName='创意组件'
|
|
loading={getCreativeComponentList.loading || loading}
|
|
loading={getCreativeComponentList.loading || loading}
|
|
- scroll={{ x: 1000, y: (size?.height || 0) - 36 }}
|
|
|
|
|
|
+ ajax={getCreativeComponentList}
|
|
|
|
+ page={getCreativeComponentList?.data?.current || 1}
|
|
|
|
+ pageSize={getCreativeComponentList?.data?.size || 20}
|
|
|
|
+ total={getCreativeComponentList?.data?.total || 0}
|
|
|
|
+ dataSource={getCreativeComponentList.data?.records || []}
|
|
pagination={false}
|
|
pagination={false}
|
|
- size="small"
|
|
|
|
- bordered
|
|
|
|
- rowKey="componentId"
|
|
|
|
|
|
+ onChange={(pagination: any, _: any, sortData: any) => {
|
|
|
|
+ let { current, pageSize } = pagination
|
|
|
|
+ let newQueryForm = JSON.parse(JSON.stringify(queryParams))
|
|
|
|
+ if (sortData && sortData?.order) {
|
|
|
|
+ newQueryForm['sortAsc'] = sortData?.order === 'ascend' ? true : false
|
|
|
|
+ newQueryForm['sortColumn'] = sortData?.field
|
|
|
|
+ } else {
|
|
|
|
+ delete newQueryForm['sortAsc']
|
|
|
|
+ delete newQueryForm['sortColumn']
|
|
|
|
+ }
|
|
|
|
+ newQueryForm.pageNum = current || newQueryForm.pageNum
|
|
|
|
+ newQueryForm.pageSize = pageSize || newQueryForm.pageSize
|
|
|
|
+ setQueryParams({ ...newQueryForm })
|
|
|
|
+ }}
|
|
rowSelection={{
|
|
rowSelection={{
|
|
selectedRowKeys: selectedRows.map(item => item.componentId),
|
|
selectedRowKeys: selectedRows.map(item => item.componentId),
|
|
getCheckboxProps: (record: any) => ({
|
|
getCheckboxProps: (record: any) => ({
|
|
@@ -300,11 +355,11 @@ const ManageComponent: React.FC = () => {
|
|
<div className="manageComponent-footer">
|
|
<div className="manageComponent-footer">
|
|
<Pagination
|
|
<Pagination
|
|
size="small"
|
|
size="small"
|
|
- total={getCreativeComponentList?.data?.total || 0}
|
|
|
|
|
|
+ total={getCreativeComponentList?.data?.totalRow || 0}
|
|
showSizeChanger
|
|
showSizeChanger
|
|
showQuickJumper
|
|
showQuickJumper
|
|
- pageSize={getCreativeComponentList?.data?.size || 30}
|
|
|
|
- current={getCreativeComponentList?.data?.current || 1}
|
|
|
|
|
|
+ pageSize={getCreativeComponentList?.data?.pageSize || 30}
|
|
|
|
+ current={getCreativeComponentList?.data?.pageNumber || 1}
|
|
onChange={(page: number, pageSize: number) => {
|
|
onChange={(page: number, pageSize: number) => {
|
|
ref.current?.querySelector('.ant-table-body')?.scrollTo({ top: 0 })
|
|
ref.current?.querySelector('.ant-table-body')?.scrollTo({ top: 0 })
|
|
setTimeout(() => setQueryParams({ ...queryParams, pageNum: page, pageSize }), 50)
|
|
setTimeout(() => setQueryParams({ ...queryParams, pageNum: page, pageSize }), 50)
|