操作栏添加浮动操作,对接授权账户列表

This commit is contained in:
Lrd
2026-06-30 09:15:29 +08:00
parent b21f35582e
commit 67c2484b8d
9 changed files with 811 additions and 41 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -28,7 +28,7 @@
}
})();
</script>
<script type="module" crossorigin src="/assets/index-BHOoZIhk.js"></script>
<script type="module" crossorigin src="/assets/index-D_mDWfOt.js"></script>
<link rel="stylesheet" crossorigin href="/assets/index-xCZbcxht.css">
</head>
<body>
+2
View File
@@ -19,6 +19,7 @@ import RemoveLens from './pages/RemoveLens';
import GeneratedRecord from './pages/GeneratedRecord';
import PreTest from './pages/PreTest';
import AuthorizationPage from './pages/AuthorizationPage';
import AuthAccountPage from './pages/AuthAccountPage';
import MaterialListPage from './pages/MaterialListPage';
import RemoveInfo from './pages/RemoveInfo';
import RemoveRw from './pages/RemoveRw';
@@ -118,6 +119,7 @@ const App = () => {
<Route path="materials" element={<MaterialListPage />} />
<Route path="consume" element={<ConsumePage />} />
<Route path="popular" element={<PopularPage />} />
<Route path="authacc" element={<AuthAccountPage />} />
<Route path="creativeplaza" element={<CreativePlazaPage />} />
</Route>
<Route path="*" element={<Navigate to="/projects" replace />} />
+1 -1
View File
@@ -743,4 +743,4 @@ export async function deleteOAuthAccount(params: DeleteOAuthAccountParams): Prom
// 获取用户全部授权账户列表
export async function getAllOAuthAccountList(): Promise<any> {
return api.post(`/upload-material/oauth_account_list`);
}
}
+302
View File
@@ -0,0 +1,302 @@
import React, { useEffect, useState } from 'react';
import { Button, Table, Modal, App, Input, Pagination, Typography, Space } from 'antd';
import { LockOutlined } from '@ant-design/icons';
import { getOAuthAccountList, deleteOAuthAccount, getOpenTypeAll } from '../api';
const formatDateTime = (dateStr: string) => {
if (!dateStr) return '';
const date = new Date(dateStr);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
};
interface AuthorizationData {
id: string;
status: string;
description: string;
account_userid?: string;
open_type?: number;
account_id?: string;
}
const AuthAccountPage: React.FC = () => {
const { message } = App.useApp();
const [authorizations, setAuthorizations] = useState<AuthorizationData[]>([]);
const [listLoading, setListLoading] = useState(false);
const [currentPage, setCurrentPage] = useState(1);
const [pageSize, setPageSize] = useState(10);
const [total, setTotal] = useState(0);
const [searchParams, setSearchParams] = useState({
advertiser_id: '',
oauth_id: '',
advertiser_name: '',
});
const [openTypeMap, setOpenTypeMap] = useState<Record<number, string>>({});
useEffect(() => {
loadOAuthList();
loadOpenTypeList();
}, []);
const loadOpenTypeList = async () => {
try {
const res = await getOpenTypeAll();
const data = res.data || [];
const map: Record<number, string> = {};
const options: { value: number; label: string }[] = [];
data.forEach(item => {
map[item.openType] = item.typeName;
options.push({ value: item.openType, label: item.typeName });
});
setOpenTypeMap(map);
} catch (error) {
console.error('加载开户方式列表失败:', error);
}
};
const loadOAuthList = async (page = 1, pageSize = 10, params = searchParams) => {
setListLoading(true);
try {
const response = await getOAuthAccountList({
advertiser_id: params.advertiser_id || '',
oauth_id: params.oauth_id || '',
advertiser_name: params.advertiser_name || '',
page,
page_size: pageSize,
});
if (response) {
if (response.data) {
setAuthorizations(response.data.data || response.data);
}
if (response.pagination) {
setTotal(response.pagination.total || 0);
setCurrentPage(response.pagination.page || 1);
setPageSize(response.pagination.pageSize || 10);
}
} else {
setAuthorizations(response || []);
}
} catch (error) {
message.error('获取授权列表失败');
} finally {
setListLoading(false);
}
};
const columns = [
{
title: 'ID',
dataIndex: 'id',
key: 'id',
},
{
title: '广告主账户ID',
dataIndex: 'advertiserId',
key: 'advertiserId',
width: 160,
},
{
title: '广告主账户名称',
dataIndex: 'advertiserName',
key: 'advertiserName',
},
{
title: '广告主账户角色',
dataIndex: 'advertiserRole',
key: 'advertiserRole',
},
{
title: '授权账户ID',
dataIndex: 'accountId',
key: 'accountId',
width: 160,
},
{
title: '授权账户名称',
dataIndex: 'accountName',
key: 'accountName',
},
{
title: '授权账户角色',
dataIndex: 'accountRole',
key: 'accountRole',
render: (role: string) => {
const roleMap: Record<string, string> = {
ADVERTISER: '客户',
CUSTOMER_ADMIN: '普通版工作台-管理员',
CUSTOMER_OPERATOR: '普通版工作台-协作者',
AGENT: '代理商',
CHILD_AGENT: '二级代理商',
PLATFORM_ROLE_STAR: '星图账户',
PLATFORM_ROLE_SHOP_ACCOUNT: '抖音店铺账户',
PLATFORM_ROLE_QIANCHUAN_AGENT: '千川代理商',
PLATFORM_ROLE_STAR_AGENT: '星图代理商',
PLATFORM_ROLE_AWEME: '抖音号',
PLATFORM_ROLE_STAR_MCN: '星图MCN机构',
PLATFORM_ROLE_STAR_ISV: '星图服务商',
AGENT_SYSTEM_ACCOUNT: '代理商系统账户',
PLATFORM_ROLE_LOCAL_AGENT: '本地推代理商',
PLATFORM_ROLE_YUNTU_BRAND_ISV_ADMIN: '云图品牌服务商管理员',
PLATFORM_ROLE_LIFE: '抖音来客账户',
PLATFORM_ROLE_ENTERPRISE_BP_ADMIN: '升级版工作台管理员',
PLATFORM_ROLE_ENTERPRISE_BP_OPERATOR: '升级版工作台协作者',
};
return roleMap[role] || role;
},
},
{
title: '授权账户登录账号ID',
dataIndex: 'accountUserid',
key: 'accountUserid',
},
{
title: '授权账户登录账号名称',
dataIndex: 'accountUsername',
key: 'accountUsername',
},
{
title: '授权ID',
dataIndex: 'oauthId',
key: 'oauthId',
},
{
title: '开户方式',
dataIndex: 'openType',
key: 'openType',
render: (text: number) => <span style={{ color: '#1e293b' }}>{openTypeMap[text] || text}</span>,
},
{
title: '创建时间',
dataIndex: 'createdAt',
key: 'createdAt',
width: 160,
render: (text: string) => <span style={{ color: '#64748b' }}>{formatDateTime(text)}</span>,
},
{
title: '操作',
fixed: 'right' as const,
dataIndex: 'action',
key: 'action',
render: (_: string, record: AuthorizationData) => (
<Space>
<Button
size="small"
danger
onClick={() => {
Modal.confirm({
title: '确认删除',
content: '确定要删除该授权账户吗?',
okText: '确定',
cancelText: '取消',
onOk: async () => {
try {
await deleteOAuthAccount({ id: record.id });
message.success('删除成功');
loadOAuthList(currentPage, pageSize);
} catch (error) {
message.error('删除失败');
}
},
});
}}
>
</Button>
</Space>
),
},
];
const tableData = authorizations.map((item, index) => ({
...item,
index: index + 1,
key: item.id,
}));
return (
<div style={{ minHeight: '94vh' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8, marginBottom: 12 }}>
<LockOutlined style={{ color: '#6366f1', fontSize: 16 }} />
<Typography.Text strong style={{ fontSize: 16 }}></Typography.Text>
</div>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', gap: 12, marginBottom: 16 }}>
<div style={{ display: 'flex', gap: 12 }}>
<Input
placeholder="广告主账户ID"
value={searchParams.advertiser_id}
onChange={(e) => setSearchParams(prev => ({ ...prev, advertiser_id: e.target.value }))}
style={{ width: 180 }}
onPressEnter={() => { setCurrentPage(1); loadOAuthList(1, pageSize); }}
/>
<Input
placeholder="授权ID"
value={searchParams.oauth_id}
onChange={(e) => setSearchParams(prev => ({ ...prev, oauth_id: e.target.value }))}
style={{ width: 180 }}
onPressEnter={() => { setCurrentPage(1); loadOAuthList(1, pageSize); }}
/>
<Input
placeholder="广告主账户名称"
value={searchParams.advertiser_name}
onChange={(e) => setSearchParams(prev => ({ ...prev, advertiser_name: e.target.value }))}
style={{ width: 180 }}
onPressEnter={() => { setCurrentPage(1); loadOAuthList(1, pageSize); }}
/>
<Button
type="primary"
size="medium"
onClick={() => { setCurrentPage(1); loadOAuthList(1, pageSize); }}
>
</Button>
<Button
size="medium"
onClick={() => {
setSearchParams({ advertiser_id: '', oauth_id: '', advertiser_name: '' });
setCurrentPage(1);
loadOAuthList(1, pageSize);
}}
>
</Button>
</div>
</div>
<div style={{ background: '#fff', borderRadius: 12, boxShadow: '0 1px 3px rgba(0,0,0,0.05)' }}>
<Table
dataSource={tableData}
columns={columns}
loading={listLoading}
pagination={false}
rowKey="id"
bordered={false}
scroll={{ x: 'max-content' }}
/>
<div style={{ padding: '16px', textAlign: 'right' }}>
<Pagination
current={currentPage}
pageSize={pageSize}
total={total}
showSizeChanger
showTotal={(total) => `${total} 条记录`}
onChange={(page, size) => {
setCurrentPage(page);
setPageSize(size);
loadOAuthList(page, size);
}}
size="small"
/>
</div>
</div>
</div>
);
};
export default AuthAccountPage;
+23 -9
View File
@@ -1,5 +1,6 @@
import React, { useEffect, useState } from 'react';
import { Button, Table, Tag, Modal, Select, App, Input, Pagination, Typography, Space } from 'antd';
import { useNavigate } from 'react-router-dom';
import { PlusOutlined, LockOutlined } from '@ant-design/icons';
import { getOAuthList, requestOAuth, getOpenTypeAll } from '../api';
@@ -41,13 +42,23 @@ interface AuthorizationData {
id: string;
status: string;
description: string;
account_userid?: string;
open_type?: number;
account_id?: string;
advertiserId?: string;
advertiserName?: string;
accountRole?: string;
accountUserid?: string;
accountUsername?: string;
appid?: string;
materialAuthStatus?: boolean;
openType?: number;
portType?: number;
userId?: string;
createdAt?: string;
updatedAt?: string;
}
const AuthorizationPage: React.FC = () => {
const { message } = App.useApp();
const navigate = useNavigate();
const [authorizations, setAuthorizations] = useState<AuthorizationData[]>([]);
const [loading, setLoading] = useState(false);
const [listLoading, setListLoading] = useState(false);
@@ -250,14 +261,17 @@ const AuthorizationPage: React.FC = () => {
{
title: '操作',
dataIndex: 'action',
fixed: 'right' as const,
key: 'action',
width: 140,
render: (text: string) => (
<Space>
<Button type="primary" size="small" >
</Button>
</Space>
render: (_: unknown, record) => (
<Button
type="link"
onClick={() => navigate(`/consume?advertiserId=${record.advertiserId}`)}
style={{ color: '#6366f1', padding: 0 }}
>
</Button>
),
},
];
+7 -2
View File
@@ -31,7 +31,7 @@ const ConsumePage: React.FC = () => {
const [searchText, setSearchText] = useState('');
const [currentPage, setCurrentPage] = useState(1);
const [pageSize, setPageSize] = useState(10);
const [advertiserId, setAdvertiserId] = useState(searchParams.get('accountId') || '');
const [advertiserId, setAdvertiserId] = useState(searchParams.get('advertiserId') || '');
const [consumeDateRange, setConsumeDateRange] = useState<[string, string] | undefined>();
const [syncDate, setSyncDate] = useState<string>(dayjs().subtract(1, 'day').format('YYYY-MM-DD'));
const [syncAdvertiserId, setSyncAdvertiserId] = useState<string>('');
@@ -88,7 +88,12 @@ const ConsumePage: React.FC = () => {
}));
const handleBack = () => {
navigate('/authorization');
const referrer = document.referrer;
if (referrer.includes(window.location.origin)) {
navigate(-1);
} else {
navigate('/authorization');
}
};
const handleSearch = () => {
+24 -24
View File
@@ -37,7 +37,7 @@ const GeneratedRecord: React.FC = () => {
const [uploading, setUploading] = useState(false);
// 上传配置弹窗相关状态
// 推送配置弹窗相关状态
const [uploadConfigModalVisible, setUploadConfigModalVisible] = useState(false);
const [accountIdLists, setAccountIdLists] = useState<{
accountId: string;
@@ -68,7 +68,7 @@ const GeneratedRecord: React.FC = () => {
const [selectedHistoryAccounts, setSelectedHistoryAccounts] = useState<any[]>([]);
const [openTypeMap, setOpenTypeMap] = useState<Record<number, string>>({});
// 上传任务历史弹窗相关状态
// 推送任务历史弹窗相关状态
const [uploadHistoryModalVisible, setUploadHistoryModalVisible] = useState(false);
const [uploadHistoryList, setUploadHistoryList] = useState<any[]>([]);
const [uploadHistoryTotal, setUploadHistoryTotal] = useState(0);
@@ -671,7 +671,7 @@ const GeneratedRecord: React.FC = () => {
};
const handleBatchUploadSelected = () => {
if (selectedItems.size === 0) {
message.warning('请先选择要上传的媒体');
message.warning('请先选择要推送的媒体');
return;
}
setAccountIdLists([[]]);
@@ -741,7 +741,7 @@ const GeneratedRecord: React.FC = () => {
setUploadHistoryList(data || []);
setUploadHistoryTotal(res.pagination?.total || res.total || 0);
} catch (error) {
console.error('加载上传历史失败:', error);
console.error('加载推送历史失败:', error);
setUploadHistoryList([]);
setUploadHistoryTotal(0);
} finally {
@@ -763,10 +763,10 @@ const GeneratedRecord: React.FC = () => {
setUploadHistoryPageSize(pageSize);
loadUploadHistory();
};
// 批量上传素材
// 批量推送素材
const handleStartBatchUpload = async () => {
if (selectedItems.size === 0) {
message.warning('请先选择要上传的媒体');
message.warning('请先选择要推送的媒体');
return;
}
const itemMap = new Map<string, any>();
@@ -869,8 +869,8 @@ const GeneratedRecord: React.FC = () => {
setMaterialFileNames(new Map());
setUnifiedFileName('');
} catch (error: any) {
console.error('批量上传失败:', error);
message.error(error.message || '批量上传失败');
console.error('批量推送失败:', error);
message.error(error.message || '批量推送失败');
} finally {
setUploading(false);
}
@@ -1056,7 +1056,7 @@ const GeneratedRecord: React.FC = () => {
}, [filterType, filterMedia]);
return (
<div style={{ minHeight: 'calc(100vh - 90px)', background: '#ffffffff', overflowY: 'auto' }} >
{/* 操作栏:筛选 + 上传按钮 */}
{/* 操作栏:筛选 + 推送按钮 */}
<div style={{
display: 'flex',
alignItems: 'center',
@@ -1167,7 +1167,7 @@ const GeneratedRecord: React.FC = () => {
fontWeight: 600,
}}
>
{uploading ? '上传中...' : `推送至账户 (${selectedItems.size})`}
{uploading ? '推送中...' : `推送至账户 (${selectedItems.size})`}
</Button>
</Space>
) : (
@@ -1284,7 +1284,7 @@ const GeneratedRecord: React.FC = () => {
e.currentTarget.style.boxShadow = '0 4px 15px rgba(102, 126, 234, 0.4)';
}}
>
</Button>
</div>
{/* Content area */}
@@ -1369,9 +1369,9 @@ const GeneratedRecord: React.FC = () => {
)}
</div>
)}
{/* 上传配置弹窗 */}
{/* 推送配置弹窗 */}
<Modal
title={selectedItems.size === 1 ? '上传配置' : '批量上传配置'}
title={selectedItems.size === 1 ? '推送配置' : '批量推送配置'}
open={uploadConfigModalVisible}
onCancel={() => {
setUploadConfigModalVisible(false);
@@ -1845,15 +1845,15 @@ const GeneratedRecord: React.FC = () => {
disabled={uploading || (accountTab === 'new' ? accountIdLists.every(list => list.length === 0) : selectedHistoryAccounts.length === 0)}
style={{ borderRadius: 8 }}
>
{uploading ? '上传中...' : '开始上传'}
{uploading ? '推送中...' : '开始推送'}
</Button>
</div>
</div>
</Modal>
{/* 上传任务历史弹窗 */}
{/* 推送任务历史弹窗 */}
<Modal
title="上传任务历史"
title="推送任务历史"
open={uploadHistoryModalVisible}
onCancel={() => setUploadHistoryModalVisible(false)}
footer={null}
@@ -1868,10 +1868,10 @@ const GeneratedRecord: React.FC = () => {
placeholder="选择状态"
style={{ width: 200, marginRight: 12 }}
options={[
{ value: '1', label: '待上传' },
{ value: '2', label: '上传中' },
{ value: '3', label: '上传成功' },
{ value: '4', label: '上传失败' },
{ value: '1', label: '待推送' },
{ value: '2', label: '推送中' },
{ value: '3', label: '推送成功' },
{ value: '4', label: '推送失败' },
]}
allowClear
/>
@@ -1905,10 +1905,10 @@ const GeneratedRecord: React.FC = () => {
width: 100,
render: (status: string) => {
const statusMap: Record<string, string> = {
'1': '待上传',
'2': '上传中',
'3': '上传成功',
'4': '上传失败',
'1': '待推送',
'2': '推送中',
'3': '推送成功',
'4': '推送失败',
};
const statusColorMap: Record<string, string> = {
'1': '#f59e0b',
+9 -4
View File
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import { Button, Table, Tag, Input, Pagination, Typography, Select, App } from 'antd';
import { Link } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import { FolderOpenOutlined, EyeOutlined } from '@ant-design/icons';
import { getResourcesMaterialList } from '../api';
import PreResultDisplay from '../components/PreResultDisplay';
@@ -81,6 +81,7 @@ interface MaterialData {
const MaterialListPage: React.FC = () => {
const { message } = App.useApp();
const navigate = useNavigate();
const [materials, setMaterials] = useState<MaterialData[]>([]);
const [listLoading, setListLoading] = useState(false);
const [currentPage, setCurrentPage] = useState(1);
@@ -269,12 +270,16 @@ const MaterialListPage: React.FC = () => {
},
{
title: '操作',
fixed: 'right' as const,
key: 'action',
width: 120,
render: (_: unknown, record) => (
<Link to={`/consume?accountId=${record.advertiserId}`} style={{ color: '#6366f1' }}>
<Button
type="link"
onClick={() => navigate(`/consume?advertiserId=${record.advertiserId}`)}
style={{ color: '#6366f1', padding: 0 }}
>
</Link>
</Button>
),
},
// {