fix(promo): HQ 渠道负责人与关联合伙人展示为公司-人名
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
/** HQ 推广码:渠道负责人 / 关联合伙人展示。有公司则「公司-人名」,无公司则人名。 */
|
||||
export function formatPromoPartnerLabel(p?: {
|
||||
companyName?: string | null;
|
||||
name?: string | null;
|
||||
id?: string;
|
||||
} | null): string {
|
||||
if (!p) return '—';
|
||||
const company = (p.companyName ?? '').trim();
|
||||
const person = (p.name ?? '').trim();
|
||||
if (company && person) return `${company}-${person}`;
|
||||
if (company) return company;
|
||||
if (person) return person;
|
||||
return p.id || '—';
|
||||
}
|
||||
|
||||
export function formatPromoPartnerNames(
|
||||
partners?: Array<{ companyName?: string | null; name?: string | null; id?: string }> | null,
|
||||
): string {
|
||||
if (!partners?.length) return '—';
|
||||
return partners.map((p) => formatPromoPartnerLabel(p)).join('、');
|
||||
}
|
||||
@@ -9,11 +9,11 @@ import {
|
||||
PROMO_CODE_STATUS_LABELS,
|
||||
promoConversion,
|
||||
type PromoCodeItem,
|
||||
type PromoCodePartnerBrief,
|
||||
type PromoCodeScene,
|
||||
} from '@dukang/shared-types';
|
||||
import { request, type Paginated } from '../lib/api';
|
||||
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../lib/constants';
|
||||
import { formatPromoPartnerLabel, formatPromoPartnerNames } from '../lib/promo-partner-label';
|
||||
import { useAdminList } from '../lib/useAdminList';
|
||||
import { useAdminListColumns } from '../lib/useAdminListColumns';
|
||||
import { AdminListHeader } from '../components/AdminListHeader';
|
||||
@@ -23,17 +23,6 @@ type Row = PromoCodeItem;
|
||||
type PartnerOption = { id: string; companyName?: string | null; name?: string; phone?: string };
|
||||
type SceneOption = { value: PromoCodeScene; label: string };
|
||||
|
||||
function formatPartnerLabel(p?: PromoCodePartnerBrief | PartnerOption | null) {
|
||||
if (!p) return '—';
|
||||
const title = p.companyName || p.name || p.id;
|
||||
return p.phone ? `${title} · ${p.phone}` : title;
|
||||
}
|
||||
|
||||
function formatPartnerNames(partners?: PromoCodePartnerBrief[] | null) {
|
||||
if (!partners?.length) return '—';
|
||||
return partners.map((p) => p.companyName || p.name || p.id).join('、');
|
||||
}
|
||||
|
||||
export default function PromoCodesPage() {
|
||||
const navigate = useNavigate();
|
||||
const [filterForm] = Form.useForm();
|
||||
@@ -50,7 +39,7 @@ export default function PromoCodesPage() {
|
||||
const [creating, setCreating] = useState(false);
|
||||
|
||||
const partnerSelectOptions = useMemo(
|
||||
() => partners.map((p) => ({ value: p.id, label: formatPartnerLabel(p) })),
|
||||
() => partners.map((p) => ({ value: p.id, label: formatPromoPartnerLabel(p) })),
|
||||
[partners],
|
||||
);
|
||||
|
||||
@@ -142,12 +131,12 @@ export default function PromoCodesPage() {
|
||||
{
|
||||
title: '渠道负责人',
|
||||
width: 160,
|
||||
render: (_, row) => formatPartnerNames(row.channelOwners),
|
||||
render: (_, row) => formatPromoPartnerNames(row.channelOwners),
|
||||
},
|
||||
{
|
||||
title: '关联合伙人',
|
||||
width: 140,
|
||||
render: (_, row) => row.assocPartner?.companyName || row.assocPartner?.name || '—',
|
||||
render: (_, row) => formatPromoPartnerLabel(row.assocPartner),
|
||||
},
|
||||
{ title: '创建', dataIndex: 'createdAt', width: 160, render: fmtTime },
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
} from '@dukang/shared-types';
|
||||
import { request, type Paginated } from '../../lib/api';
|
||||
import { ADMIN_OPTIONS_PAGE_SIZE, fmtTime } from '../../lib/constants';
|
||||
import { formatPromoPartnerLabel, formatPromoPartnerNames } from '../../lib/promo-partner-label';
|
||||
import type { PromoCodeDetailContext } from './PromoCodeDetailLayout';
|
||||
import PromoCodeMetricsPanel from './PromoCodeMetricsPanel';
|
||||
|
||||
@@ -53,17 +54,6 @@ const CONVERSION_HINT =
|
||||
|
||||
type PartnerOption = { id: string; companyName?: string | null; name?: string | null; phone?: string | null };
|
||||
|
||||
function formatPartnerLabel(p?: { companyName?: string | null; name?: string | null; phone?: string | null; id: string } | null) {
|
||||
if (!p) return '—';
|
||||
const title = p.companyName || p.name || p.id;
|
||||
return p.phone ? `${title} · ${p.phone}` : title;
|
||||
}
|
||||
|
||||
function formatPartnerNames(partners?: Array<{ companyName?: string | null; name?: string | null; id: string }> | null) {
|
||||
if (!partners?.length) return '—';
|
||||
return partners.map((p) => p.companyName || p.name || p.id).join('、');
|
||||
}
|
||||
|
||||
function StatHint({ label, hint }: { label: string; hint: string }) {
|
||||
return (
|
||||
<span>
|
||||
@@ -107,7 +97,7 @@ export default function PromoCodeDetailPage() {
|
||||
const map = new Map(partners.map((p) => [p.id, p]));
|
||||
for (const p of detail.channelOwners ?? []) map.set(p.id, p);
|
||||
if (detail.assocPartner) map.set(detail.assocPartner.id, detail.assocPartner);
|
||||
return [...map.values()].map((p) => ({ value: p.id, label: formatPartnerLabel(p) }));
|
||||
return [...map.values()].map((p) => ({ value: p.id, label: formatPromoPartnerLabel(p) }));
|
||||
}, [partners, detail.channelOwners, detail.assocPartner]);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -229,12 +219,12 @@ export default function PromoCodeDetailPage() {
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="渠道负责人">
|
||||
<span style={{ whiteSpace: 'nowrap' }}>
|
||||
{formatPartnerNames(detail.channelOwners)}
|
||||
{formatPromoPartnerNames(detail.channelOwners)}
|
||||
</span>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="关联合伙人">
|
||||
<span style={{ whiteSpace: 'nowrap' }}>
|
||||
{formatPartnerLabel(detail.assocPartner)}
|
||||
{formatPromoPartnerLabel(detail.assocPartner)}
|
||||
</span>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="备注">{detail.remark || '—'}</Descriptions.Item>
|
||||
|
||||
Reference in New Issue
Block a user