chore(admin-ui): migrate platform leads index to filters/list card and admin pagination
This commit is contained in:
@@ -73,140 +73,154 @@
|
||||
};
|
||||
@endphp
|
||||
|
||||
<div class="card mb-20">
|
||||
<p class="muted muted-tight">对外平台(/platform)收集的开通意向线索,用于前期 A(站点开通型)人工运营承接。</p>
|
||||
|
||||
@if($safeBackForLinks !== '')
|
||||
<div class="mt-10">
|
||||
<a href="{!! $safeBackForLinks !!}" class="muted">← 返回上一页(保留上下文)</a>
|
||||
<details class="card mb-20 collapsible filters-card" data-role="collapsible" data-storage-key="admin.platform_leads.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">对外平台(/platform)收集的开通意向线索,用于前期人工运营承接。</div>
|
||||
</div>
|
||||
<span class="muted muted-xs">点击收起/展开</span>
|
||||
</div>
|
||||
@endif
|
||||
<p class="muted">后续会在此处逐步接入:一键生成站点/订阅/平台订单、跟进记录、转化漏斗与治理提示。</p>
|
||||
</div>
|
||||
|
||||
<div class="card mb-20">
|
||||
<h3>筛选</h3>
|
||||
<form method="get" action="/admin/platform-leads" class="grid-3">
|
||||
@if($safeBackForLinks !== '')
|
||||
<input type="hidden" name="back" value="{!! $safeBackForLinks !!}">
|
||||
<div class="mt-10">
|
||||
<a href="{!! $safeBackForLinks !!}" class="muted">← 返回上一页(保留上下文)</a>
|
||||
</div>
|
||||
@endif
|
||||
<select name="status">
|
||||
<option value="">全部状态</option>
|
||||
@foreach(($statusLabels ?? []) as $v => $label)
|
||||
<option value="{{ $v }}" @selected(($filters['status'] ?? '') === $v)>{{ $label }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<input name="keyword" placeholder="关键词:姓名/手机号/邮箱/公司" value="{{ $filters['keyword'] ?? '' }}">
|
||||
<input type="number" name="lead_id" placeholder="线索ID(可选)" value="{{ $filters['lead_id'] ?? '' }}">
|
||||
|
||||
<div class="muted muted-xs mt-6">后续会在此处逐步接入:一键生成站点/订阅/平台订单、跟进记录、转化漏斗与治理提示。</div>
|
||||
</summary>
|
||||
|
||||
<div class="collapsible-body filters-body">
|
||||
<h3 class="mt-0">筛选</h3>
|
||||
<form method="get" action="/admin/platform-leads" class="grid-3 filters-grid">
|
||||
@if($safeBackForLinks !== '')
|
||||
<input type="hidden" name="back" value="{!! $safeBackForLinks !!}">
|
||||
@endif
|
||||
<select name="status">
|
||||
<option value="">全部状态</option>
|
||||
@foreach(($statusLabels ?? []) as $v => $label)
|
||||
<option value="{{ $v }}" @selected(($filters['status'] ?? '') === $v)>{{ $label }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<input name="keyword" placeholder="关键词:姓名/手机号/邮箱/公司" value="{{ $filters['keyword'] ?? '' }}">
|
||||
<input type="number" name="lead_id" placeholder="线索ID(可选)" value="{{ $filters['lead_id'] ?? '' }}">
|
||||
<div>
|
||||
<button type="submit" class="btn btn-sm">应用筛选</button>
|
||||
<a class="btn btn-secondary btn-sm" href="/admin/platform-leads">重置</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<div class="card list-card">
|
||||
<div class="list-card-header">
|
||||
<div>
|
||||
<button type="submit">应用筛选</button>
|
||||
<h3 class="list-card-title">线索列表</h3>
|
||||
<div class="muted muted-xs mt-6">当前阶段仅提供查询与筛选;已补“从线索创建订单”入口,先把收费闭环跑起来。</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<h3>线索列表</h3>
|
||||
<div class="muted mb-10">当前阶段仅提供查询与筛选;已补“从线索创建订单”入口,先把收费闭环跑起来。</div>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>状态</th>
|
||||
<th>姓名</th>
|
||||
<th>手机号</th>
|
||||
<th>邮箱</th>
|
||||
<th>公司</th>
|
||||
<th>套餐ID</th>
|
||||
<th>来源</th>
|
||||
<th>创建时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($leads as $l)
|
||||
<div class="list-card-body">
|
||||
<table class="list-card-table table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>{{ $l->id }}</td>
|
||||
<td>
|
||||
<div class="actions">
|
||||
<span>{{ $statusLabels[$l->status] ?? $l->status }}</span>
|
||||
|
||||
@php
|
||||
// 轻量运营流转:仅展示“下一步可能动作”,减少噪音/误点。
|
||||
$nextActions = [];
|
||||
switch ((string) $l->status) {
|
||||
case 'new':
|
||||
$nextActions = ['contacted', 'converted', 'closed'];
|
||||
break;
|
||||
case 'contacted':
|
||||
$nextActions = ['qualified', 'converted', 'closed'];
|
||||
break;
|
||||
case 'qualified':
|
||||
$nextActions = ['converted', 'closed'];
|
||||
break;
|
||||
case 'converted':
|
||||
$nextActions = ['closed'];
|
||||
break;
|
||||
default:
|
||||
$nextActions = [];
|
||||
}
|
||||
|
||||
$actionLabels = [
|
||||
'contacted' => ['text' => '标记已联系', 'class' => 'btn-secondary btn-sm'],
|
||||
'qualified' => ['text' => '标记已确认需求', 'class' => 'btn-secondary btn-sm'],
|
||||
'converted' => ['text' => '标记已转化', 'class' => 'btn btn-sm'],
|
||||
'closed' => ['text' => '关闭', 'class' => 'btn-danger btn-sm'],
|
||||
];
|
||||
@endphp
|
||||
|
||||
@foreach($nextActions as $status)
|
||||
<form method="post" action="/admin/platform-leads/{{ $l->id }}/set-status" class="inline-form">
|
||||
@csrf
|
||||
<input type="hidden" name="status" value="{{ $status }}">
|
||||
<button type="submit" class="{{ $actionLabels[$status]['class'] ?? 'btn-secondary btn-sm' }}">{{ $actionLabels[$status]['text'] ?? $status }}</button>
|
||||
</form>
|
||||
@endforeach
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ $l->name }}</td>
|
||||
<td>{{ $l->mobile }}</td>
|
||||
<td>{{ $l->email }}</td>
|
||||
<td>{{ $l->company }}</td>
|
||||
<td>{{ $l->plan_id ?: '-' }}</td>
|
||||
<td>{{ $l->source }}</td>
|
||||
<td>{{ optional($l->created_at)->format('Y-m-d H:i:s') }}</td>
|
||||
<td>
|
||||
<div class="actions">
|
||||
<a class="btn btn-sm" href="{!! $buildCreatePlatformOrderUrl($l) !!}">创建订单</a>
|
||||
<a class="btn btn-secondary btn-sm" href="{!! $buildCreateRenewalOrderUrl($l) !!}">创建续费订单</a>
|
||||
|
||||
@php
|
||||
$viewOrdersUrl = '/admin/platform-orders?' . \Illuminate\Support\Arr::query([
|
||||
'lead_id' => $l->id,
|
||||
'back' => $selfWithoutBack,
|
||||
]);
|
||||
|
||||
$viewRenewalMissingSubOrdersUrl = '/admin/platform-orders?' . \Illuminate\Support\Arr::query([
|
||||
'lead_id' => $l->id,
|
||||
'renewal_missing_subscription' => '1',
|
||||
'back' => $selfWithoutBack,
|
||||
]);
|
||||
@endphp
|
||||
<a class="btn-secondary btn-sm" href="{!! $viewOrdersUrl !!}">查看订单</a>
|
||||
<a class="btn-secondary btn-sm" href="{!! $viewRenewalMissingSubOrdersUrl !!}">续费缺订阅</a>
|
||||
</div>
|
||||
</td>
|
||||
<th>ID</th>
|
||||
<th>状态</th>
|
||||
<th>姓名</th>
|
||||
<th>手机号</th>
|
||||
<th>邮箱</th>
|
||||
<th>公司</th>
|
||||
<th>套餐ID</th>
|
||||
<th>来源</th>
|
||||
<th>创建时间</th>
|
||||
<th>操作</th>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="10" class="muted">暂无线索</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</thead>
|
||||
<tbody>
|
||||
@forelse($leads as $l)
|
||||
<tr>
|
||||
<td>{{ $l->id }}</td>
|
||||
<td>
|
||||
<div class="actions">
|
||||
<span>{{ $statusLabels[$l->status] ?? $l->status }}</span>
|
||||
|
||||
<div class="pagination-wrap">
|
||||
{{ $leads->links() }}
|
||||
@php
|
||||
// 轻量运营流转:仅展示“下一步可能动作”,减少噪音/误点。
|
||||
$nextActions = [];
|
||||
switch ((string) $l->status) {
|
||||
case 'new':
|
||||
$nextActions = ['contacted', 'converted', 'closed'];
|
||||
break;
|
||||
case 'contacted':
|
||||
$nextActions = ['qualified', 'converted', 'closed'];
|
||||
break;
|
||||
case 'qualified':
|
||||
$nextActions = ['converted', 'closed'];
|
||||
break;
|
||||
case 'converted':
|
||||
$nextActions = ['closed'];
|
||||
break;
|
||||
default:
|
||||
$nextActions = [];
|
||||
}
|
||||
|
||||
$actionLabels = [
|
||||
'contacted' => ['text' => '标记已联系', 'class' => 'btn-secondary btn-sm'],
|
||||
'qualified' => ['text' => '标记已确认需求', 'class' => 'btn-secondary btn-sm'],
|
||||
'converted' => ['text' => '标记已转化', 'class' => 'btn btn-sm'],
|
||||
'closed' => ['text' => '关闭', 'class' => 'btn-danger btn-sm'],
|
||||
];
|
||||
@endphp
|
||||
|
||||
@foreach($nextActions as $status)
|
||||
<form method="post" action="/admin/platform-leads/{{ $l->id }}/set-status" class="inline-form">
|
||||
@csrf
|
||||
<input type="hidden" name="status" value="{{ $status }}">
|
||||
<button type="submit" class="{{ $actionLabels[$status]['class'] ?? 'btn-secondary btn-sm' }}">{{ $actionLabels[$status]['text'] ?? $status }}</button>
|
||||
</form>
|
||||
@endforeach
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ $l->name }}</td>
|
||||
<td>{{ $l->mobile }}</td>
|
||||
<td>{{ $l->email }}</td>
|
||||
<td>{{ $l->company }}</td>
|
||||
<td>{{ $l->plan_id ?: '-' }}</td>
|
||||
<td>{{ $l->source }}</td>
|
||||
<td>{{ optional($l->created_at)->format('Y-m-d H:i:s') }}</td>
|
||||
<td>
|
||||
<div class="actions">
|
||||
<a class="btn btn-sm" href="{!! $buildCreatePlatformOrderUrl($l) !!}">创建订单</a>
|
||||
<a class="btn btn-secondary btn-sm" href="{!! $buildCreateRenewalOrderUrl($l) !!}">创建续费订单</a>
|
||||
|
||||
@php
|
||||
$viewOrdersUrl = '/admin/platform-orders?' . \Illuminate\Support\Arr::query([
|
||||
'lead_id' => $l->id,
|
||||
'back' => $selfWithoutBack,
|
||||
]);
|
||||
|
||||
$viewRenewalMissingSubOrdersUrl = '/admin/platform-orders?' . \Illuminate\Support\Arr::query([
|
||||
'lead_id' => $l->id,
|
||||
'renewal_missing_subscription' => '1',
|
||||
'back' => $selfWithoutBack,
|
||||
]);
|
||||
@endphp
|
||||
<a class="btn-secondary btn-sm" href="{!! $viewOrdersUrl !!}">查看订单</a>
|
||||
<a class="btn-secondary btn-sm" href="{!! $viewRenewalMissingSubOrdersUrl !!}">续费缺订阅</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="10" class="muted table-empty">暂无线索</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
{{ $leads->links('pagination.admin') }}
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminPlatformLeadsIndexShouldUseFiltersAndListCardStructureTest 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_platform_leads_index_should_use_filters_and_list_card_structure(): void
|
||||
{
|
||||
$this->loginAsPlatformAdmin();
|
||||
|
||||
$response = $this->get('/admin/platform-leads');
|
||||
$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/platform_leads/index.blade.php'));
|
||||
$this->assertIsString($blade);
|
||||
$this->assertStringContainsString("links('pagination.admin')", $blade);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user