chore(admin): 开通线索状态操作按当前状态智能显示
This commit is contained in:
@@ -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>
|
||||||
<form method="post" action="/admin/platform-leads/{{ $l->id }}/set-status" class="inline-form">
|
|
||||||
@csrf
|
@php
|
||||||
<input type="hidden" name="status" value="contacted">
|
// 轻量运营流转:仅展示“下一步可能动作”,减少噪音/误点。
|
||||||
<button type="submit" class="btn-secondary btn-sm">标记已联系</button>
|
$nextActions = [];
|
||||||
</form>
|
switch ((string) $l->status) {
|
||||||
<form method="post" action="/admin/platform-leads/{{ $l->id }}/set-status" class="inline-form">
|
case 'new':
|
||||||
@csrf
|
$nextActions = ['contacted', 'converted', 'closed'];
|
||||||
<input type="hidden" name="status" value="converted">
|
break;
|
||||||
<button type="submit" class="btn btn-sm">标记已转化</button>
|
case 'contacted':
|
||||||
</form>
|
$nextActions = ['qualified', 'converted', 'closed'];
|
||||||
<form method="post" action="/admin/platform-leads/{{ $l->id }}/set-status" class="inline-form">
|
break;
|
||||||
@csrf
|
case 'qualified':
|
||||||
<input type="hidden" name="status" value="closed">
|
$nextActions = ['converted', 'closed'];
|
||||||
<button type="submit" class="btn-danger btn-sm">关闭</button>
|
break;
|
||||||
</form>
|
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>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ $l->name }}</td>
|
<td>{{ $l->name }}</td>
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user