fix: restore carrier reporting status summaries
This commit is contained in:
@@ -17,7 +17,7 @@ const signature = {
|
||||
carrierReportSummary: {
|
||||
mobile: { status: 'approved', approved: 3, total: 3 },
|
||||
unicom: { status: 'reporting', approved: 2, total: 3 },
|
||||
telecom: { status: 'waiting_material', approved: 1, total: 3 },
|
||||
telecom: { status: 'abandoned', approved: 0, total: 3 },
|
||||
},
|
||||
drainageInfo: { links: [{ id: 'drainage-1', siteName: 'www.lisglo.com', url: 'www.lisglo.com', auditStatus: 'approved' }] },
|
||||
drainageCarrierReportSummary: {
|
||||
@@ -42,15 +42,17 @@ function renderTable(overrides: Partial<Parameters<typeof EnterpriseSignaturesTa
|
||||
}
|
||||
|
||||
describe('EnterpriseSignaturesTable dense presentation', () => {
|
||||
it('uses compact headers, bracketed signatures, channel counts and only the requested row actions', () => {
|
||||
it('uses compact headers, bracketed signatures, carrier statuses with counts and only the requested row actions', () => {
|
||||
renderTable();
|
||||
expect(screen.getByText('【聆界科技】')).toBeVisible();
|
||||
expect(screen.getAllByText('审核状态')).toHaveLength(2);
|
||||
expect(screen.queryByText('签名名称')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('签名审核')).not.toBeInTheDocument();
|
||||
expect(screen.queryByText('报备详情')).not.toBeInTheDocument();
|
||||
expect(screen.getAllByLabelText('已报备通过3个,总通道数3个')).toHaveLength(2);
|
||||
expect(screen.getByLabelText('已报备通过2个,总通道数3个')).toHaveTextContent('2/3');
|
||||
expect(screen.getAllByLabelText('全部通过,已报备通过3个,总通道数3个')).toHaveLength(2);
|
||||
expect(screen.getByLabelText('部分通过,已报备通过2个,总通道数3个')).toHaveTextContent('部分通过2/3');
|
||||
expect(screen.getByLabelText('放弃报备,已报备通过0个,总通道数3个')).toHaveTextContent('放弃报备0/3');
|
||||
expect(screen.getByLabelText('资料待补充,已报备通过0个,总通道数3个')).toHaveTextContent('资料待补充0/3');
|
||||
expect(screen.getAllByRole('button', { name: '报备状态' })).toHaveLength(2);
|
||||
expect(screen.getAllByRole('button', { name: '编辑' })).toHaveLength(2);
|
||||
expect(screen.getAllByRole('button', { name: '删除' })).toHaveLength(2);
|
||||
@@ -61,5 +63,8 @@ describe('EnterpriseSignaturesTable dense presentation', () => {
|
||||
renderTable({ expandedSignatureId: '', setSignatureSort });
|
||||
await userEvent.click(screen.getByRole('button', { name: '签名降序' }));
|
||||
expect(setSignatureSort).toHaveBeenCalledWith('desc');
|
||||
expect(screen.getByRole('button', { name: '签名升序' }).querySelector('.lucide-triangle')).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: '签名降序' }).querySelector('.enterprise-signature-table__sort-triangle--down')).toBeInTheDocument();
|
||||
expect(document.querySelector('.lucide-arrow-up, .lucide-arrow-down')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { Dispatch, SetStateAction } from 'react';
|
||||
import { ArrowDown, ArrowUp, ChevronDown, ChevronRight, Edit3, Plus } from 'lucide-react';
|
||||
import { ChevronDown, ChevronRight, Edit3, Plus, Triangle } from 'lucide-react';
|
||||
import type { ClientSmsSignature } from '@/api/adminApi';
|
||||
import { Button, DeleteRiskAction, Pagination } from '@/components/ui';
|
||||
import { AuditStatusTag, CarrierReportCount, formatSignatureName, readDrainagePayload, signatureCardVisual } from './signature.helpers';
|
||||
@@ -51,8 +51,8 @@ export function EnterpriseSignaturesTable({
|
||||
<span className="enterprise-signature-table__sortable">
|
||||
签名
|
||||
<span className="enterprise-signature-table__sort-actions">
|
||||
<Button aria-pressed={signatureSort === 'asc'} icon={<ArrowUp size={13} />} iconOnly onClick={() => setSignatureSort('asc')} size="sm" variant={signatureSort === 'asc' ? 'secondary' : 'ghost'}>签名升序</Button>
|
||||
<Button aria-pressed={signatureSort === 'desc'} icon={<ArrowDown size={13} />} iconOnly onClick={() => setSignatureSort('desc')} size="sm" variant={signatureSort === 'desc' ? 'secondary' : 'ghost'}>签名降序</Button>
|
||||
<Button aria-pressed={signatureSort === 'asc'} icon={<Triangle aria-hidden="true" fill="currentColor" size={11} />} iconOnly onClick={() => setSignatureSort('asc')} size="sm" variant={signatureSort === 'asc' ? 'secondary' : 'ghost'}>签名升序</Button>
|
||||
<Button aria-pressed={signatureSort === 'desc'} icon={<Triangle aria-hidden="true" className="enterprise-signature-table__sort-triangle--down" fill="currentColor" size={11} />} iconOnly onClick={() => setSignatureSort('desc')} size="sm" variant={signatureSort === 'desc' ? 'secondary' : 'ghost'}>签名降序</Button>
|
||||
</span>
|
||||
</span>
|
||||
<span>企业</span>
|
||||
|
||||
@@ -16,19 +16,13 @@ export function carrierLabel(carrier?: string | null) {
|
||||
}
|
||||
|
||||
export function formatSignatureName(name: string) {
|
||||
const value = name.trim().replace(/^[【\[]+|[】\]]+$/g, '').trim();
|
||||
const value = name.trim().replace(/^(?:【|\[)+|(?:】|\])+$/g, '').trim();
|
||||
return value ? `【${value}】` : '—';
|
||||
}
|
||||
|
||||
export function CarrierReportTag({ summary }: { summary?: CarrierReportSummary }) {
|
||||
if (!summary || summary.status === 'not_applicable' || summary.total === 0) return <Tag tone="neutral">不适用</Tag>;
|
||||
let label = '未报备';
|
||||
let tone: 'success' | 'danger' | 'warning' | 'info' | 'neutral' = 'neutral';
|
||||
if (summary.status === 'approved') { label = '全部通过'; tone = 'success'; }
|
||||
else if (summary.status === 'failed' || summary.status === 'rejected') { label = '报备失败'; tone = 'danger'; }
|
||||
else if (summary.status === 'waiting_material') { label = '资料待补充'; tone = 'warning'; }
|
||||
else if (summary.approved > 0) { label = '部分通过'; tone = 'info'; }
|
||||
else if (summary.status === 'reporting' || summary.status === 'exporting') { label = '报备中'; tone = 'warning'; }
|
||||
const { label, tone } = carrierReportMeta(summary);
|
||||
return <span className="carrier-report-summary"><Tag tone={tone}>{label}</Tag><small>({summary.approved}/{summary.total})</small></span>;
|
||||
}
|
||||
|
||||
@@ -36,20 +30,31 @@ export function CarrierReportCount({ summary }: { summary?: CarrierReportSummary
|
||||
if (!summary || summary.status === 'not_applicable' || summary.total === 0) {
|
||||
return <span className="carrier-report-count carrier-report-count--neutral" title="没有适用的目标通道">—</span>;
|
||||
}
|
||||
const tone = summary.approved === summary.total
|
||||
? 'success'
|
||||
: ['failed', 'rejected'].includes(summary.status) ? 'danger' : 'warning';
|
||||
const { label, tone } = carrierReportMeta(summary);
|
||||
return (
|
||||
<span
|
||||
aria-label={`已报备通过${summary.approved}个,总通道数${summary.total}个`}
|
||||
aria-label={`${label},已报备通过${summary.approved}个,总通道数${summary.total}个`}
|
||||
className={`carrier-report-count carrier-report-count--${tone}`}
|
||||
title={`已报备通过 ${summary.approved} 个 / 总通道数 ${summary.total} 个`}
|
||||
title={`${label};已报备通过 ${summary.approved} 个 / 总通道数 ${summary.total} 个`}
|
||||
>
|
||||
{summary.approved}/{summary.total}
|
||||
<span>{label}</span>
|
||||
<small>{summary.approved}/{summary.total}</small>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
function carrierReportMeta(summary: CarrierReportSummary) {
|
||||
let label = '未报备';
|
||||
let tone: 'success' | 'danger' | 'warning' | 'info' | 'neutral' = 'neutral';
|
||||
if (summary.status === 'approved') { label = '全部通过'; tone = 'success'; }
|
||||
else if (summary.status === 'abandoned') { label = '放弃报备'; tone = 'neutral'; }
|
||||
else if (summary.status === 'failed' || summary.status === 'rejected') { label = '报备失败'; tone = 'danger'; }
|
||||
else if (summary.status === 'waiting_material') { label = '资料待补充'; tone = 'warning'; }
|
||||
else if (summary.approved > 0) { label = '部分通过'; tone = 'info'; }
|
||||
else if (summary.status === 'reporting' || summary.status === 'exporting') { label = '报备中'; tone = 'warning'; }
|
||||
return { label, tone };
|
||||
}
|
||||
|
||||
export function signatureCardVisual(auditStatus: string, summaries?: Record<string, CarrierReportSummary>) {
|
||||
if (auditStatus === 'rejected') return { label: '签名审核已驳回', tone: 'red' as SignatureCardTone };
|
||||
if (auditStatus === 'pending') return { label: '签名待审核', tone: 'amber' as SignatureCardTone };
|
||||
|
||||
Reference in New Issue
Block a user