From b2b457907e9b9458012eca452b298f027031343a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=90=9D=E5=8D=9C?= Date: Mon, 16 Mar 2026 03:59:46 +0800 Subject: [PATCH] chore(admin-ui): migrate product import histories to filters/list card and admin pagination --- .../admin/products/import_histories.blade.php | 202 ++++++++++-------- ...ouldUseFiltersAndListCardStructureTest.php | 45 ++++ 2 files changed, 157 insertions(+), 90 deletions(-) create mode 100644 tests/Feature/AdminProductImportHistoriesIndexShouldUseFiltersAndListCardStructureTest.php diff --git a/resources/views/admin/products/import_histories.blade.php b/resources/views/admin/products/import_histories.blade.php index dd61a4b..9c11fff 100644 --- a/resources/views/admin/products/import_histories.blade.php +++ b/resources/views/admin/products/import_histories.blade.php @@ -4,106 +4,128 @@ @section('page_title', '平台商品导入历史') @section('content') -
-

这里集中查看平台视角的商品导入历史,适合运营侧复盘批量导入结果、失败明细与清理后文件状态。

+@php + $exportHistoryQuery = http_build_query(array_filter([ + 'merchant_id' => $importHistoryFilters['merchant_id'] ?? '', + 'import_result_status' => $importHistoryFilters['result_status'] ?? 'all', + 'import_time_range' => $importHistoryFilters['time_range'] ?? 'all', + 'start_date' => $importHistoryFilters['start_date'] ?? '', + 'end_date' => $importHistoryFilters['end_date'] ?? '', + 'import_sort' => $importHistoryFilters['sort'] ?? 'latest', + ], fn ($value, $key) => match ($key) { + 'start_date', 'end_date' => $value !== null && $value !== '', + default => $value !== null && $value !== '' && $value !== 'all' && $value !== 'latest', + }, ARRAY_FILTER_USE_BOTH)); +@endphp - @php - $exportHistoryQuery = http_build_query(array_filter([ - 'merchant_id' => $importHistoryFilters['merchant_id'] ?? '', - 'import_result_status' => $importHistoryFilters['result_status'] ?? 'all', - 'import_time_range' => $importHistoryFilters['time_range'] ?? 'all', - 'start_date' => $importHistoryFilters['start_date'] ?? '', - 'end_date' => $importHistoryFilters['end_date'] ?? '', - 'import_sort' => $importHistoryFilters['sort'] ?? 'latest', - ], fn ($value, $key) => match ($key) { - 'start_date', 'end_date' => $value !== null && $value !== '', - default => $value !== null && $value !== '' && $value !== 'all' && $value !== 'latest', - }, ARRAY_FILTER_USE_BOTH)); - @endphp -
-
- - - - - - - - - 导出当前筛选 CSV - 清空筛选 - 返回商品页 +
+ +
+
+

平台商品导入历史

+
集中复盘平台视角的商品导入结果、失败明细与文件状态(面向运营)。
+
+ 点击收起/展开
- +
- @if(!empty($importHistoryFilters['date_errors'])) -
- @foreach($importHistoryFilters['date_errors'] as $dateError) -
{{ $dateError }}
- @endforeach -
- @endif +
+
+
+ + + + + + + + + 导出当前筛选 CSV + 清空筛选 + 返回商品页 +
+
-
+ @if(!empty($importHistoryFilters['date_errors'])) +
+ @foreach($importHistoryFilters['date_errors'] as $dateError) +
{{ $dateError }}
+ @endforeach +
+ @endif +
+
+ +
+
累计导入批次
{{ $importHistoryStats['total_imports'] ?? 0 }}
累计成功商品
{{ $importHistoryStats['total_success'] ?? 0 }}
累计失败商品
{{ $importHistoryStats['total_failed'] ?? 0 }}
含失败批次
{{ $importHistoryStats['warning_imports'] ?? 0 }}
+
- - - - @forelse($importHistories as $history) - - - - - - - - - - - - @empty - - @endforelse - -
ID导入时间商家上传文件结果成功失败操作者失败明细
{{ $history->id }}{{ $history->imported_at?->format('Y-m-d H:i:s') }}{{ $history->merchant?->name ?? '平台批量导入' }}{{ $history->file_name }} - @if(($history->failed_count ?? 0) > 0) - 部分失败 - @else - 成功 - @endif - {{ $history->success_count }}{{ $history->failed_count }}{{ $history->admin?->name ?? '-' }} - @if($history->failure_file && ($history->failure_file_available ?? false)) - 下载 failure CSV - @elseif($history->failure_file) - 文件已过保留期 - @else - - @endif -
暂无导入记录
+
+
+
+

导入记录

+
+
+
+ + + + @forelse($importHistories as $history) + + + + + + + + + + + + @empty + + @endforelse + +
ID导入时间商家上传文件结果成功失败操作者失败明细
{{ $history->id }}{{ $history->imported_at?->format('Y-m-d H:i:s') }}{{ $history->merchant?->name ?? '平台批量导入' }}{{ $history->file_name }} + @if(($history->failed_count ?? 0) > 0) + 部分失败 + @else + 成功 + @endif + {{ $history->success_count }}{{ $history->failed_count }}{{ $history->admin?->name ?? '-' }} + @if($history->failure_file && ($history->failure_file_available ?? false)) + 下载 failure CSV + @elseif($history->failure_file) + 文件已过保留期 + @else + + @endif +
暂无导入记录
-
{{ $importHistories->links() }}
+ {{ $importHistories->links('pagination.admin') }} +
@endsection diff --git a/tests/Feature/AdminProductImportHistoriesIndexShouldUseFiltersAndListCardStructureTest.php b/tests/Feature/AdminProductImportHistoriesIndexShouldUseFiltersAndListCardStructureTest.php new file mode 100644 index 0000000..75d01c2 --- /dev/null +++ b/tests/Feature/AdminProductImportHistoriesIndexShouldUseFiltersAndListCardStructureTest.php @@ -0,0 +1,45 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_admin_product_import_histories_index_should_use_filters_and_list_card_structure(): void + { + $this->loginAsPlatformAdmin(); + + $res = $this->get('/admin/products/import-histories'); + $res->assertOk(); + + // 护栏:导入历史页应使用统一 Filters Card + List Card 结构。 + $res->assertSee('filters-card', false); + $res->assertSee('filters-summary', false); + $res->assertSee('filters-body', false); + $res->assertSee('filters-grid', false); + + $res->assertSee('list-card', false); + $res->assertSee('list-card-header', false); + $res->assertSee('list-card-body', false); + $res->assertSee('list-card-table', false); + + // 分页统一:用扫描型护栏断言。 + $blade = file_get_contents(resource_path('views/admin/products/import_histories.blade.php')); + $this->assertIsString($blade); + $this->assertStringContainsString("links('pagination.admin')", $blade); + } +}