chore(admin-ui): migrate merchants index to filters/list card and admin pagination
This commit is contained in:
@@ -29,59 +29,77 @@
|
|||||||
};
|
};
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
<div class="card mb-20">
|
<details class="card mb-20 collapsible filters-card" data-role="collapsible" data-storage-key="admin.merchants.filters" open>
|
||||||
<p class="muted muted-tight">这里是总台视角的站点管理入口,用于开通、查看和维护 SaaS 站点主体。</p>
|
<summary class="collapsible-summary filters-summary">
|
||||||
<p class="muted">当前站点列表已接入缓存:{{ $cacheMeta['store'] }} / TTL {{ $cacheMeta['ttl'] }}。</p>
|
<div class="flex-between items-center">
|
||||||
|
<div>
|
||||||
@if($safeBackForLinks !== '')
|
<h3 class="mb-0">站点管理</h3>
|
||||||
<div class="mt-10">
|
<div class="muted muted-xs">总台视角的站点管理入口:开通、查看和维护 SaaS 站点主体。</div>
|
||||||
<a href="{!! $safeBackForLinks !!}" class="muted">← 返回上一页(保留上下文)</a>
|
</div>
|
||||||
|
<span class="muted muted-xs">点击收起/展开</span>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
<div class="muted muted-xs mt-6">当前站点列表已接入缓存:{{ $cacheMeta['store'] }} / TTL {{ $cacheMeta['ttl'] }}。</div>
|
||||||
|
|
||||||
<h3>新增站点</h3>
|
@if($safeBackForLinks !== '')
|
||||||
<form method="post" action="/admin/merchants">
|
<div class="mt-10">
|
||||||
@csrf
|
<a href="{!! $safeBackForLinks !!}" class="muted">← 返回上一页(保留上下文)</a>
|
||||||
<div class="grid-3">
|
</div>
|
||||||
<input name="name" placeholder="站点名称" value="{{ old('name') }}">
|
@endif
|
||||||
<input name="slug" placeholder="站点标识 slug" value="{{ old('slug') }}">
|
</summary>
|
||||||
<input name="plan" placeholder="套餐,如 pro/basic" value="{{ old('plan', 'basic') }}">
|
|
||||||
<input name="status" placeholder="状态" value="{{ old('status', 'active') }}">
|
<div class="collapsible-body filters-body">
|
||||||
<input name="contact_name" placeholder="联系人" value="{{ old('contact_name') }}">
|
<h3 class="mt-0">新增站点</h3>
|
||||||
<input name="contact_phone" placeholder="联系电话" value="{{ old('contact_phone') }}">
|
<form method="post" action="/admin/merchants" class="filters-grid">
|
||||||
|
@csrf
|
||||||
|
<div class="grid-3">
|
||||||
|
<input name="name" placeholder="站点名称" value="{{ old('name') }}">
|
||||||
|
<input name="slug" placeholder="站点标识 slug" value="{{ old('slug') }}">
|
||||||
|
<input name="plan" placeholder="套餐,如 pro/basic" value="{{ old('plan', 'basic') }}">
|
||||||
|
<input name="status" placeholder="状态" value="{{ old('status', 'active') }}">
|
||||||
|
<input name="contact_name" placeholder="联系人" value="{{ old('contact_name') }}">
|
||||||
|
<input name="contact_phone" placeholder="联系电话" value="{{ old('contact_phone') }}">
|
||||||
|
</div>
|
||||||
|
<div class="mt-12"><input name="contact_email" placeholder="联系邮箱" class="w-full" value="{{ old('contact_email') }}"></div>
|
||||||
|
<div class="mt-12"><button type="submit" class="btn btn-sm">创建站点</button></div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<div class="card list-card">
|
||||||
|
<div class="list-card-header">
|
||||||
|
<div>
|
||||||
|
<h3 class="list-card-title">站点列表</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-12"><input name="contact_email" placeholder="联系邮箱" class="w-full" value="{{ old('contact_email') }}"></div>
|
</div>
|
||||||
<div class="mt-12"><button type="submit">创建站点</button></div>
|
<div class="list-card-body">
|
||||||
</form>
|
<table class="list-card-table">
|
||||||
</div>
|
<thead><tr><th>ID</th><th>站点名称</th><th>Slug</th><th>套餐</th><th>状态</th><th>联系人</th><th>操作</th></tr></thead>
|
||||||
|
<tbody>
|
||||||
|
@forelse($merchants as $merchant)
|
||||||
|
<tr>
|
||||||
|
<td>{{ $merchant->id }}</td>
|
||||||
|
<td>{{ $merchant->name }}</td>
|
||||||
|
<td>{{ $merchant->slug }}</td>
|
||||||
|
<td>{{ $merchant->plan }}</td>
|
||||||
|
<td>{{ $merchant->status }}</td>
|
||||||
|
<td>{{ $merchant->contact_name }} / {{ $merchant->contact_phone }}</td>
|
||||||
|
<td>
|
||||||
|
<div class="actions gap-10">
|
||||||
|
<a href="/site-admin/login" target="_blank" rel="noopener">进入站点后台</a>
|
||||||
|
<a class="muted" href="{!! $makeSubscriptionsUrl((int) $merchant->id) !!}">订阅</a>
|
||||||
|
<a class="muted" href="{!! $makePlatformOrdersUrl((int) $merchant->id) !!}">平台订单</a>
|
||||||
|
<a class="muted" href="{!! $makePlatformOrdersUrl((int) $merchant->id, ['renewal_missing_subscription' => '1']) !!}">续费缺订阅</a>
|
||||||
|
</div>
|
||||||
|
<div class="muted muted-xs">当前阶段请使用该站点管理员账号登录</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr><td colspan="7" class="muted table-empty">暂无站点</td></tr>
|
||||||
|
@endforelse
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
<div class="card">
|
{{ $merchants->links('pagination.admin') }}
|
||||||
<h3>站点列表</h3>
|
</div>
|
||||||
<table>
|
|
||||||
<thead><tr><th>ID</th><th>站点名称</th><th>Slug</th><th>套餐</th><th>状态</th><th>联系人</th><th>操作</th></tr></thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach($merchants as $merchant)
|
|
||||||
<tr>
|
|
||||||
<td>{{ $merchant->id }}</td>
|
|
||||||
<td>{{ $merchant->name }}</td>
|
|
||||||
<td>{{ $merchant->slug }}</td>
|
|
||||||
<td>{{ $merchant->plan }}</td>
|
|
||||||
<td>{{ $merchant->status }}</td>
|
|
||||||
<td>{{ $merchant->contact_name }} / {{ $merchant->contact_phone }}</td>
|
|
||||||
<td>
|
|
||||||
<div class="actions gap-10">
|
|
||||||
<a href="/site-admin/login" target="_blank" rel="noopener">进入站点后台</a>
|
|
||||||
<a class="muted" href="{!! $makeSubscriptionsUrl((int) $merchant->id) !!}">订阅</a>
|
|
||||||
<a class="muted" href="{!! $makePlatformOrdersUrl((int) $merchant->id) !!}">平台订单</a>
|
|
||||||
<a class="muted" href="{!! $makePlatformOrdersUrl((int) $merchant->id, ['renewal_missing_subscription' => '1']) !!}">续费缺订阅</a>
|
|
||||||
</div>
|
|
||||||
<div class="muted muted-xs">当前阶段请使用该站点管理员账号登录</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
@endforeach
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="pagination-wrap">{{ $merchants->links() }}</div>
|
|
||||||
@endsection
|
@endsection
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
class AdminMerchantsIndexShouldUseFiltersAndListCardStructureTest 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_merchants_index_should_use_filters_and_list_card_structure(): void
|
||||||
|
{
|
||||||
|
$this->loginAsPlatformAdmin();
|
||||||
|
|
||||||
|
$response = $this->get('/admin/merchants');
|
||||||
|
$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/merchants/index.blade.php'));
|
||||||
|
$this->assertIsString($blade);
|
||||||
|
$this->assertStringContainsString("links('pagination.admin')", $blade);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user