feat(ops): v4.0.7 HQ 活动图快链与勾选导出

HQ 指定一张活动图为勾选主合伙人合成 PNG/zip;城市合伙人页增加快链与单下/导出。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-01 15:12:10 +08:00
parent eeee55e215
commit cdc4b82931
21 changed files with 1041 additions and 28 deletions
@@ -1,6 +1,7 @@
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { Link, useSearchParams } from 'react-router-dom';
import {
Button, Form, Image, Input, InputNumber, Modal, Popconfirm, Select, Space, Table, Tag, message,
Alert, Button, Form, Image, Input, InputNumber, Modal, Popconfirm, Select, Space, Table, Tag, message,
} from 'antd';
import type { ColumnsType } from 'antd/es/table';
import {
@@ -10,7 +11,7 @@ import {
type ActivityPosterQrSlot,
type ActivityPosterStatus,
} from '@dukang/shared-types';
import { request } from '../lib/api';
import { request, requestDownload } from '../lib/api';
import { fmtTime } from '../lib/constants';
import { useAdminList } from '../lib/useAdminList';
import { useAdminListColumns } from '../lib/useAdminListColumns';
@@ -30,7 +31,16 @@ type FormValues = {
status?: ActivityPosterStatus;
};
type PartnerHint = {
id: string;
companyName?: string | null;
name?: string;
phone?: string;
};
export default function ActivityPostersPage() {
const [searchParams] = useSearchParams();
const partnerId = searchParams.get('partnerId')?.trim() || '';
const [form] = Form.useForm();
const [editForm] = Form.useForm<FormValues>();
const [filters, setFilters] = useState<Record<string, string>>({});
@@ -45,6 +55,8 @@ export default function ActivityPostersPage() {
);
const [modalOpen, setModalOpen] = useState(false);
const [editing, setEditing] = useState<ActivityPosterItem | null>(null);
const [partnerHint, setPartnerHint] = useState<PartnerHint | null>(null);
const [downloadingId, setDownloadingId] = useState<string | null>(null);
const imageUrl = Form.useWatch('imageUrl', editForm);
const qrXPct = Form.useWatch('qrXPct', editForm);
@@ -56,6 +68,20 @@ export default function ActivityPostersPage() {
qrSizePct: qrSizePct ?? DEFAULT_ACTIVITY_POSTER_QR_SLOT.qrSizePct,
};
useEffect(() => {
if (!partnerId) {
setPartnerHint(null);
return;
}
void request<PartnerHint>(`/admin/partners/${partnerId}`)
.then(setPartnerHint)
.catch(() => setPartnerHint({ id: partnerId }));
}, [partnerId]);
const partnerLabel = partnerHint
? (partnerHint.companyName || partnerHint.name || partnerHint.phone || partnerHint.id)
: partnerId;
function openCreate() {
setEditing(null);
editForm.setFieldsValue({
@@ -98,6 +124,23 @@ export default function ActivityPostersPage() {
void reload();
}
async function downloadForPartner(posterId: string) {
if (!partnerId) return;
setDownloadingId(posterId);
try {
await requestDownload(
`/admin/activity-posters/${posterId}/image?partnerId=${encodeURIComponent(partnerId)}`,
{},
'activity-poster.png',
);
message.success('已开始下载');
} catch (e) {
message.error(e instanceof Error ? e.message : '下载失败');
} finally {
setDownloadingId(null);
}
}
const baseColumns: ColumnsType<ActivityPosterItem> = [
{
title: '标题',
@@ -129,10 +172,20 @@ export default function ActivityPostersPage() {
{ title: '更新', dataIndex: 'updatedAt', width: 160, render: fmtTime },
{
title: '操作',
width: 200,
width: partnerId ? 280 : 200,
render: (_, row) => (
<Space>
<Button type="link" size="small" onClick={() => openEdit(row)}></Button>
{partnerId && row.status === 'ACTIVE' ? (
<Button
type="link"
size="small"
loading={downloadingId === row.id}
onClick={() => void downloadForPartner(row.id)}
>
</Button>
) : null}
<Button
type="link"
size="small"
@@ -176,6 +229,19 @@ export default function ActivityPostersPage() {
settings={settingsButton}
actions={<Button type="primary" onClick={openCreate}></Button>}
/>
{partnerId ? (
<Alert
type="info"
showIcon
style={{ marginBottom: 16 }}
message={
<>
{partnerLabel}{' '}
<Link to="/city-partners"></Link>
</>
}
/>
) : null}
<Form form={form} layout="inline" style={{ marginBottom: 16 }} onFinish={(v) => { setFilters(v); setPage(1); }}>
<Form.Item name="status" label="状态">
<Select
+67 -2
View File
@@ -30,7 +30,6 @@ import {
PARTNER_STAFF_ROLE_LABELS,
type PartnerPermissionKey,
} from '@dukang/shared-types';
import { request, type Paginated } from '../lib/api';
import { omitNullFields } from '../lib/omit-null-fields';
import { districtCodeLabel, formatDistrictLabels } from '../lib/china-region';
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
@@ -38,9 +37,11 @@ import { useAdminList } from '../lib/useAdminList';
import CityDistrictMultiSelect from '../components/CityDistrictMultiSelect';
import PartnerSubAccountList, { type PartnerSubAccountRow } from '../components/PartnerSubAccountList';
import PartnerAssocPanel from '../components/PartnerAssocPanel';
import ActivityPosterDownloadModal from '../components/ActivityPosterDownloadModal';
import { useAdminListColumns } from '../lib/useAdminListColumns';
import { AdminListHeader } from '../components/AdminListHeader';
import { AdminPrimaryLink } from '../components/AdminPrimaryLink';
import { request, type HqProfile, type Paginated } from '../lib/api';
type SubRow = PartnerSubAccountRow;
@@ -159,6 +160,9 @@ export default function CityPartnersPage() {
const [maxCommissionRate, setMaxCommissionRate] = useState(0.05);
const [createMaxRate, setCreateMaxRate] = useState(0.05);
const [createCityCode, setCreateCityCode] = useState<string | undefined>();
const [selectedRowKeys, setSelectedRowKeys] = useState<string[]>([]);
const [posterDownloadIds, setPosterDownloadIds] = useState<string[] | null>(null);
const [canDownloadPosters, setCanDownloadPosters] = useState(false);
const loadCities = useCallback(async () => {
const res = await request<Paginated<CityOption>>(`/admin/cities?pageSize=${ADMIN_OPTIONS_PAGE_SIZE}`);
@@ -169,6 +173,12 @@ export default function CityPartnersPage() {
void loadCities();
}, [loadCities]);
useEffect(() => {
void request<HqProfile>('/admin/auth/me')
.then((p) => setCanDownloadPosters((p.permissionKeys ?? []).includes('activity_posters')))
.catch(() => setCanDownloadPosters(false));
}, []);
const editCityCode = detail?.cityId
? cities.find((c) => c.id === detail.cityId)?.code
: undefined;
@@ -373,17 +383,34 @@ export default function CityPartnersPage() {
</Link>
),
},
{
title: '活动图',
width: 70,
render: (_, row) => (
<Link
to={`/activity-posters?partnerId=${encodeURIComponent(row.id)}`}
title={`为「${row.companyName || row.phone}」下载活动图`}
>
</Link>
),
},
{ title: '子账号', dataIndex: 'accountCount', width: 70, render: (n) => Math.max(0, n - 1) },
{ title: '创建', dataIndex: 'createdAt', width: 150, render: fmtTime },
{
title: '操作',
width: 140,
width: 220,
fixed: 'right',
render: (_, row) => (
<Space size={0}>
<Button type="link" size="small" onClick={() => void openPartner(row.id)}>
</Button>
{canDownloadPosters ? (
<Button type="link" size="small" onClick={() => setPosterDownloadIds([row.id])}>
</Button>
) : null}
<Popconfirm
title="确认删除该城市合伙人?"
description="若有门店需先删除门店;账号下有订单或核销单将禁止删除。"
@@ -410,7 +437,16 @@ export default function CityPartnersPage() {
settings={settingsButton}
actions={
<>
<Link to="/activity-posters"></Link>
<Link to="/users?assocPartnerAccountId=any"></Link>
{canDownloadPosters ? (
<Button
disabled={!selectedRowKeys.length}
onClick={() => setPosterDownloadIds(selectedRowKeys)}
>
{selectedRowKeys.length ? `${selectedRowKeys.length}` : ''}
</Button>
) : null}
<Button
type="primary"
onClick={() => {
@@ -498,6 +534,14 @@ export default function CityPartnersPage() {
dataSource={toTableRows(data?.items ?? [])}
scroll={{ x: 'max-content' }}
childrenColumnName="__noTreeChildren__"
rowSelection={
canDownloadPosters
? {
selectedRowKeys,
onChange: (keys) => setSelectedRowKeys(keys.map(String)),
}
: undefined
}
expandable={{
expandedRowRender: (record) => (
<PartnerSubAccountList
@@ -564,6 +608,21 @@ export default function CityPartnersPage() {
{detail.assocUserCount ?? 0}
</Link>
</Descriptions.Item>
<Descriptions.Item label="活动图">
<Space>
<Link
to={`/activity-posters?partnerId=${encodeURIComponent(detail.id)}`}
title="查看活动图并下载该合伙人合成图"
>
</Link>
{canDownloadPosters ? (
<Button type="link" size="small" onClick={() => setPosterDownloadIds([detail.id])}>
</Button>
) : null}
</Space>
</Descriptions.Item>
<Descriptions.Item label="管仓仓库" span={2}>
{detail.managedWarehouseName ?? (
<Typography.Text type="secondary">
@@ -812,6 +871,12 @@ export default function CityPartnersPage() {
</Form.Item>
</Form>
</Modal>
<ActivityPosterDownloadModal
open={posterDownloadIds != null && posterDownloadIds.length > 0}
partnerIds={posterDownloadIds ?? []}
onClose={() => setPosterDownloadIds(null)}
/>
</div>
);
}