diff --git a/resources/views/admin/platform_leads/index.blade.php b/resources/views/admin/platform_leads/index.blade.php index 898528f..9206ad0 100644 --- a/resources/views/admin/platform_leads/index.blade.php +++ b/resources/views/admin/platform_leads/index.blade.php @@ -91,21 +91,42 @@
{{ $statusLabels[$l->status] ?? $l->status }} -
- @csrf - - -
-
- @csrf - - -
-
- @csrf - - -
+ + @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) +
+ @csrf + + +
+ @endforeach
{{ $l->name }} diff --git a/tests/Feature/AdminPlatformLeadIndexStatusActionButtonsTest.php b/tests/Feature/AdminPlatformLeadIndexStatusActionButtonsTest.php new file mode 100644 index 0000000..9ac1bf2 --- /dev/null +++ b/tests/Feature/AdminPlatformLeadIndexStatusActionButtonsTest.php @@ -0,0 +1,68 @@ +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); + } +}