fix: align report workbench page actions
This commit is contained in:
@@ -293,27 +293,30 @@ export function AdminReportMaterialsPage() {
|
||||
<h1>报备资料池</h1>
|
||||
<p>这里按企业应用 × 签名或引流对象 × 资料版本展示待生成资料;生成批次后再拆成通道与运营商明细。</p>
|
||||
</div>
|
||||
<Button
|
||||
disabled={busy || selected.size === 0}
|
||||
icon={<Layers3 size={16} />}
|
||||
onClick={() => void beginCreateBatch()}
|
||||
>
|
||||
{busy ? '生成中...' : `预检并生成(${selected.size})`}
|
||||
</Button>
|
||||
<div className="page-heading__actions">
|
||||
<Button
|
||||
disabled={!eligibleItems.length}
|
||||
onClick={() =>
|
||||
setSelected(allSelected ? new Set() : new Set(eligibleItems.map((item) => item.id)))
|
||||
}
|
||||
variant="ghost"
|
||||
>
|
||||
{allSelected ? '取消全选' : '全选当页'}
|
||||
</Button>
|
||||
<Button
|
||||
disabled={busy || selected.size === 0}
|
||||
icon={<Layers3 size={16} />}
|
||||
onClick={() => void beginCreateBatch()}
|
||||
>
|
||||
{busy ? '生成中...' : `预检并生成(${selected.size})`}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
{error ? <p className="form-error">{error}</p> : null}
|
||||
{message ? <p className="form-success">{message}</p> : null}
|
||||
<div className="page-stack">
|
||||
{filter}
|
||||
<div className="surface">
|
||||
<label className="table-actions">
|
||||
<input
|
||||
checked={allSelected}
|
||||
onChange={() => setSelected(allSelected ? new Set() : new Set(eligibleItems.map((item) => item.id)))}
|
||||
type="checkbox"
|
||||
/>
|
||||
选择本页全部可生成资料
|
||||
</label>
|
||||
<Table
|
||||
columns={pendingColumns}
|
||||
data={pendingData.items}
|
||||
|
||||
@@ -359,7 +359,7 @@ export function AdminReportTasksPage() {
|
||||
<h1>通道报备明细</h1>
|
||||
<p>按企业应用 × 签名/引流对象 × 通道 × 运营商展示,未生成任务的“未报备”明细也会显示。</p>
|
||||
</div>
|
||||
<div className="page-heading-actions">
|
||||
<div className="page-heading__actions">
|
||||
<Button
|
||||
disabled={!tasks.length}
|
||||
onClick={() =>
|
||||
@@ -367,7 +367,7 @@ export function AdminReportTasksPage() {
|
||||
}
|
||||
variant="ghost"
|
||||
>
|
||||
{allCurrentPageSelected ? '取消全选' : '全选当前页'}
|
||||
{allCurrentPageSelected ? '取消全选' : '全选当页'}
|
||||
</Button>
|
||||
<Button
|
||||
disabled={!selected.size}
|
||||
|
||||
@@ -3,6 +3,7 @@ import userEvent from '@testing-library/user-event';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { MemoryRouter } from 'react-router-dom';
|
||||
import { AdminReportBatchesPage } from './AdminReportBatchesPage';
|
||||
import { AdminReportMaterialsPage } from './AdminReportMaterialsPage';
|
||||
import { AdminReportTasksPage } from './AdminReportTasksPage';
|
||||
|
||||
const { adminApi, clipboardWriteText } = vi.hoisted(() => ({
|
||||
@@ -11,9 +12,11 @@ const { adminApi, clipboardWriteText } = vi.hoisted(() => ({
|
||||
exportSingleReportMaterial: vi.fn(),
|
||||
getReportMaterialBatch: vi.fn(),
|
||||
getSingleReportMaterialDetail: vi.fn(),
|
||||
listPendingReportMaterials: vi.fn(),
|
||||
listReportDetailsPage: vi.fn(),
|
||||
listReportMaterialBatches: vi.fn(),
|
||||
listReportMaterialBatchTasks: vi.fn(),
|
||||
preflightReportMaterialBatch: vi.fn(),
|
||||
},
|
||||
clipboardWriteText: vi.fn(),
|
||||
}));
|
||||
@@ -54,7 +57,7 @@ describe('report workbench pages', () => {
|
||||
);
|
||||
|
||||
const user = userEvent.setup();
|
||||
const selectPage = await screen.findByRole('button', { name: '全选当前页' });
|
||||
const selectPage = await screen.findByRole('button', { name: '全选当页' });
|
||||
await user.click(selectPage);
|
||||
expect(screen.getByRole('button', { name: '取消全选' })).toBeVisible();
|
||||
expect(screen.getByRole('button', { name: '批量修改状态(2)' })).toBeEnabled();
|
||||
@@ -65,6 +68,49 @@ describe('report workbench pages', () => {
|
||||
screen.getAllByRole('checkbox').forEach((checkbox) => expect(checkbox).not.toBeChecked());
|
||||
});
|
||||
|
||||
it('uses the shared current-page selection button in the material pool heading', async () => {
|
||||
const material = {
|
||||
id: 'signature:signature-1',
|
||||
tenantId: 'tenant-1',
|
||||
signatureId: 'signature-1',
|
||||
applicationId: 'app-1',
|
||||
reportType: 'signature',
|
||||
name: '测试签名',
|
||||
detail: '测试用途',
|
||||
materialVersion: 1,
|
||||
changedAt: '2026-09-03T01:00:00.000Z',
|
||||
tenant: { id: 'tenant-1', name: '测试企业' },
|
||||
application: { id: 'app-1', name: '测试应用' },
|
||||
};
|
||||
adminApi.listPendingReportMaterials.mockResolvedValue({ items: [material], total: 1, page: 1, pageSize: 20 });
|
||||
adminApi.preflightReportMaterialBatch.mockResolvedValue({
|
||||
eligible: true,
|
||||
eligibleTargetCount: 1,
|
||||
skippedTargetCount: 0,
|
||||
items: [
|
||||
{
|
||||
id: material.id,
|
||||
eligible: true,
|
||||
blockedReasons: [],
|
||||
targets: [{ eligible: true }],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<AdminReportMaterialsPage />
|
||||
</MemoryRouter>,
|
||||
);
|
||||
|
||||
const user = userEvent.setup();
|
||||
await user.click(await screen.findByRole('button', { name: '全选当页' }));
|
||||
expect(screen.getByRole('button', { name: '取消全选' })).toBeVisible();
|
||||
expect(screen.getByRole('button', { name: '预检并生成(1)' })).toBeEnabled();
|
||||
expect(screen.getByRole('checkbox', { name: '选择测试签名' })).toBeChecked();
|
||||
expect(screen.queryByText('选择本页全部可生成资料')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('shows and copies the channel brief returned by the batch detail API', async () => {
|
||||
const batch = {
|
||||
id: 'batch-1',
|
||||
|
||||
Reference in New Issue
Block a user