chore(admin-ui): migrate product categories index to filters/list card and admin pagination
This commit is contained in:
@@ -4,11 +4,21 @@
|
||||
@section('page_title', '商品分类')
|
||||
|
||||
@section('content')
|
||||
<div class="card mb-20">
|
||||
<p class="muted muted-tight">这里是总台视角的商品分类巡检与维护入口,可跨站点查看分类结构。</p>
|
||||
<p class="muted">当前分类列表已接入缓存:{{ $cacheMeta['store'] }} / TTL {{ $cacheMeta['ttl'] }}。</p>
|
||||
<h3>新增分类</h3>
|
||||
<form method="post" action="/admin/product-categories">
|
||||
<details class="card mb-20 collapsible filters-card" data-role="collapsible" data-storage-key="admin.product_categories.filters" open>
|
||||
<summary class="collapsible-summary filters-summary">
|
||||
<div class="flex-between items-center">
|
||||
<div>
|
||||
<h3 class="mb-0">商品分类</h3>
|
||||
<div class="muted muted-xs">总台视角的商品分类巡检与维护入口,可跨站点查看分类结构。</div>
|
||||
</div>
|
||||
<span class="muted muted-xs">点击收起/展开</span>
|
||||
</div>
|
||||
<div class="muted muted-xs mt-6">当前分类列表已接入缓存:{{ $cacheMeta['store'] }} / TTL {{ $cacheMeta['ttl'] }}。</div>
|
||||
</summary>
|
||||
|
||||
<div class="collapsible-body filters-body">
|
||||
<h3 class="mt-0">新增分类</h3>
|
||||
<form method="post" action="/admin/product-categories" class="filters-grid">
|
||||
@csrf
|
||||
<div class="grid-3">
|
||||
<select name="merchant_id">
|
||||
@@ -25,16 +35,23 @@
|
||||
<input name="sort" placeholder="排序" value="{{ old('sort', 0) }}">
|
||||
<input name="description" placeholder="分类说明" class="span-2" value="{{ old('description') }}">
|
||||
</div>
|
||||
<div class="mt-12"><button type="submit">创建分类</button></div>
|
||||
<div class="mt-12"><button type="submit" class="btn btn-sm">创建分类</button></div>
|
||||
</form>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<div class="card">
|
||||
<h3>分类列表</h3>
|
||||
<table>
|
||||
<div class="card list-card">
|
||||
<div class="list-card-header">
|
||||
<div>
|
||||
<h3 class="list-card-title">分类列表</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-card-body">
|
||||
<table class="list-card-table">
|
||||
<thead><tr><th>ID</th><th>商家</th><th>名称</th><th>Slug</th><th>状态</th><th>排序</th><th>说明</th><th>操作</th></tr></thead>
|
||||
<tbody>
|
||||
@foreach($categories as $category)
|
||||
@forelse($categories as $category)
|
||||
<tr>
|
||||
<td>{{ $category->id }}</td>
|
||||
<td>{{ $category->merchant?->name ?? ('商家#'.$category->merchant_id) }}</td>
|
||||
@@ -53,18 +70,21 @@
|
||||
<td><input name="sort" value="{{ $category->sort }}" class="w-90"></td>
|
||||
<td><input name="description" value="{{ $category->description }}"></td>
|
||||
<td>
|
||||
<button type="submit">更新</button>
|
||||
<button type="submit" class="btn btn-secondary btn-sm">更新</button>
|
||||
</form>
|
||||
<form method="post" action="/admin/product-categories/{{ $category->id }}/delete" class="inline" onsubmit="return confirm('确定删除这个分类?');">
|
||||
@csrf
|
||||
<button type="submit" class="button-danger">删除</button>
|
||||
<button type="submit" class="btn btn-danger btn-sm">删除</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
@empty
|
||||
<tr><td colspan="8" class="muted table-empty">暂无分类</td></tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="pagination-wrap">{{ $categories->links() }}</div>
|
||||
{{ $categories->links('pagination.admin') }}
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminProductCategoriesIndexShouldUseFiltersAndListCardStructureTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function loginAsPlatformAdmin(): void
|
||||
{
|
||||
$this->seed();
|
||||
|
||||
$this->post('/admin/login', [
|
||||
'email' => 'platform.admin@demo.local',
|
||||
'password' => 'Platform@123456',
|
||||
])->assertRedirect('/admin');
|
||||
}
|
||||
|
||||
public function test_admin_product_categories_index_should_use_filters_and_list_card_structure(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$response = $this->get('/admin/product-categories');
|
||||
$response->assertOk();
|
||||
|
||||
// 护栏:商品分类页应使用统一 Filters Card + List Card 结构,便于全站后台观感一致。
|
||||
$response->assertSee('filters-card', false);
|
||||
$response->assertSee('filters-summary', false);
|
||||
$response->assertSee('filters-body', false);
|
||||
$response->assertSee('filters-grid', false);
|
||||
|
||||
$response->assertSee('list-card', false);
|
||||
$response->assertSee('list-card-header', false);
|
||||
$response->assertSee('list-card-body', false);
|
||||
$response->assertSee('list-card-table', false);
|
||||
|
||||
// 分页统一:此页数据量可能不足导致 hasPages=false,因此用扫描型护栏断言。
|
||||
$blade = file_get_contents(resource_path('views/admin/product_categories/index.blade.php'));
|
||||
$this->assertIsString($blade);
|
||||
$this->assertStringContainsString("links('pagination.admin')", $blade);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user