diff --git a/resources/views/admin/platform_orders/index.blade.php b/resources/views/admin/platform_orders/index.blade.php index c38ec02..a8c5e73 100644 --- a/resources/views/admin/platform_orders/index.blade.php +++ b/resources/views/admin/platform_orders/index.blade.php @@ -44,9 +44,20 @@ @endphp @if($incomingLeadId > 0) -
+ @php + // 清除 lead_id 筛选:保留其它筛选条件,但移除 lead_id/page。 + $clearLeadQuery = $currentQuery; + unset($clearLeadQuery['lead_id'], $clearLeadQuery['page']); + + $clearLeadUrl = '/admin/platform-orders'; + if (count($clearLeadQuery) > 0) { + $clearLeadUrl .= '?' . \Illuminate\Support\Arr::query($clearLeadQuery); + } + @endphp +
当前线索:#{{ $incomingLeadId }} (已按 lead_id 过滤订单集合) + 清除线索筛选
@endif diff --git a/tests/Feature/AdminPlatformOrderIndexClearLeadFilterLinkTest.php b/tests/Feature/AdminPlatformOrderIndexClearLeadFilterLinkTest.php new file mode 100644 index 0000000..4233e0b --- /dev/null +++ b/tests/Feature/AdminPlatformOrderIndexClearLeadFilterLinkTest.php @@ -0,0 +1,64 @@ +seed(); + + $this->post('/admin/login', [ + 'email' => 'platform.admin@demo.local', + 'password' => 'Platform@123456', + ])->assertRedirect('/admin'); + } + + public function test_index_should_render_clear_lead_filter_link_when_lead_id_present(): void + { + $this->loginAsPlatformAdmin(); + + $url = '/admin/platform-orders?' . Arr::query([ + 'lead_id' => 12, + 'payment_status' => 'paid', + 'page' => 3, + ]); + + $res = $this->get($url); + $res->assertOk(); + + $html = $res->getContent(); + + $res->assertSee('清除线索筛选', false); + + preg_match_all('/href="([^"]+)"/', $html, $matches); + $hrefs = $matches[1] ?? []; + + $clearUrls = array_values(array_filter($hrefs, fn ($u) => str_contains($u, '清除') === false && str_contains($u, '/admin/platform-orders'))); + + // 在所有 href 中找一个不带 lead_id、不带 page,但仍保留 payment_status 的链接 + $found = false; + foreach ($hrefs as $u) { + if (!str_contains($u, '/admin/platform-orders')) { + continue; + } + $parts = parse_url($u); + parse_str($parts['query'] ?? '', $q); + + if (!isset($q['lead_id']) + && !isset($q['page']) + && ($q['payment_status'] ?? '') === 'paid') { + $found = true; + break; + } + } + + $this->assertTrue($found, '未找到正确的“清除线索筛选”链接(应移除 lead_id/page 并保留其它筛选)'); + } +}