chore(admin): 开通线索状态操作按当前状态智能显示

This commit is contained in:
萝卜
2026-03-14 03:49:02 +00:00
parent e8b3c55efd
commit 25e8bd7cc2
2 changed files with 104 additions and 15 deletions

View File

@@ -91,21 +91,42 @@
<td> <td>
<div class="actions"> <div class="actions">
<span>{{ $statusLabels[$l->status] ?? $l->status }}</span> <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"> <form method="post" action="/admin/platform-leads/{{ $l->id }}/set-status" class="inline-form">
@csrf @csrf
<input type="hidden" name="status" value="contacted"> <input type="hidden" name="status" value="{{ $status }}">
<button type="submit" class="btn-secondary btn-sm">标记已联系</button> <button type="submit" class="{{ $actionLabels[$status]['class'] ?? 'btn-secondary btn-sm' }}">{{ $actionLabels[$status]['text'] ?? $status }}</button>
</form>
<form method="post" action="/admin/platform-leads/{{ $l->id }}/set-status" class="inline-form">
@csrf
<input type="hidden" name="status" value="converted">
<button type="submit" class="btn btn-sm">标记已转化</button>
</form>
<form method="post" action="/admin/platform-leads/{{ $l->id }}/set-status" class="inline-form">
@csrf
<input type="hidden" name="status" value="closed">
<button type="submit" class="btn-danger btn-sm">关闭</button>
</form> </form>
@endforeach
</div> </div>
</td> </td>
<td>{{ $l->name }}</td> <td>{{ $l->name }}</td>

View File

@@ -0,0 +1,68 @@
<?php
namespace Tests\Feature;
use App\Models\PlatformLead;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class AdminPlatformLeadIndexStatusActionButtonsTest 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_index_should_hide_actions_for_closed_leads(): void
{
$this->loginAsPlatformAdmin();
PlatformLead::query()->create([
'name' => '已关闭线索',
'mobile' => '',
'email' => '',
'company' => '',
'source' => 'test',
'status' => 'closed',
'plan_id' => null,
'meta' => ['from' => 'test'],
]);
$res = $this->get('/admin/platform-leads');
$res->assertOk();
// closed 不应再展示“关闭/标记”按钮
$res->assertDontSee('标记已联系', false);
$res->assertDontSee('标记已转化', false);
$res->assertDontSee('标记已确认需求', false);
$res->assertDontSee('>关闭<', false);
}
public function test_index_should_show_qualified_action_for_contacted_leads(): void
{
$this->loginAsPlatformAdmin();
PlatformLead::query()->create([
'name' => '已联系线索',
'mobile' => '',
'email' => '',
'company' => '',
'source' => 'test',
'status' => 'contacted',
'plan_id' => null,
'meta' => ['from' => 'test'],
]);
$res = $this->get('/admin/platform-leads');
$res->assertOk();
$res->assertSee('标记已确认需求', false);
}
}