From 854d3894dbf0c33d7740f5ca395594018119db67 Mon Sep 17 00:00:00 2001 From: limeng <1131177064@qq.com> Date: Fri, 30 Oct 2026 14:26:07 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8A=A5=E4=BB=B7=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E6=8A=A5=E4=BB=B7=E5=8F=98=E6=9B=B4=E8=AE=B0=E5=BD=95=E9=A1=B5?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BF=AB=E9=80=92=E5=85=AC=E5=8F=B8/?= =?UTF-8?q?=E7=8A=B6=E6=80=81/=E5=8F=98=E6=9B=B4=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 快递公司支持输入模糊匹配或从下拉建议中选择;状态、变更类型下拉筛选,可组合,提供「清空」。 - 分页保留筛选条件;批量审核后回到同一筛选结果页。 - 无匹配记录时给出空状态提示;补分页样式(原分页按竖排列表显示)。 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_014nvGZkg27YMEdhRy6EiUwf --- .../Business/CourierQuoteChanges.php | 34 +++++++- .../quote-change-history.blade.php | 17 +++- .../Business/QuoteChangeHistoryFilterTest.php | 82 +++++++++++++++++++ 3 files changed, 128 insertions(+), 5 deletions(-) create mode 100644 tests/Feature/Business/QuoteChangeHistoryFilterTest.php diff --git a/app/Http/Controllers/Business/CourierQuoteChanges.php b/app/Http/Controllers/Business/CourierQuoteChanges.php index e1e617fc..4c6adf34 100644 --- a/app/Http/Controllers/Business/CourierQuoteChanges.php +++ b/app/Http/Controllers/Business/CourierQuoteChanges.php @@ -26,19 +26,46 @@ class CourierQuoteChanges extends Controller ) { } - public function index(): View + public function index(Request $request): View { + $filters = $this->historyFilters($request); $changes = CourierQuoteChange::query() ->with(['items', 'version']) + ->when($filters['carrier'] !== '', fn ($q) => $q->where('carrier_name', 'like', '%' . addcslashes($filters['carrier'], '%_\\') . '%')) + ->when($filters['status'] !== '', fn ($q) => $q->where('status', $filters['status'])) + ->when($filters['change_type'] !== '', fn ($q) => $q->where('change_type', $filters['change_type'])) ->latest('updated_at') - ->paginate(20); + ->paginate(20) + ->withQueryString(); return view('business.pages.courier-payables.quote-change-history', [ 'changes' => $changes, 'canReview' => $this->canReview(), + 'filters' => $filters, + 'carrierOptions' => CourierQuoteChange::query()->whereNotNull('carrier_name')->distinct()->orderBy('carrier_name')->pluck('carrier_name')->all(), + 'changeTypeOptions' => CourierQuoteChange::query()->whereNotNull('change_type')->distinct()->orderBy('change_type')->pluck('change_type')->all(), + 'statusOptions' => [ + CourierQuoteChange::STATUS_DRAFT => '草稿', + CourierQuoteChange::STATUS_PENDING_REVIEW => '待审核', + CourierQuoteChange::STATUS_RETURNED => '已退回', + CourierQuoteChange::STATUS_APPROVED => '已审核', + ], ]); } + /** @return array{carrier:string,status:string,change_type:string} */ + private function historyFilters(Request $request): array + { + $status = (string) $request->input('status', ''); + $allowed = [CourierQuoteChange::STATUS_DRAFT, CourierQuoteChange::STATUS_PENDING_REVIEW, CourierQuoteChange::STATUS_RETURNED, CourierQuoteChange::STATUS_APPROVED]; + + return [ + 'carrier' => mb_substr(trim((string) $request->input('carrier', '')), 0, 100), + 'status' => in_array($status, $allowed, true) ? $status : '', + 'change_type' => mb_substr(trim((string) $request->input('change_type', '')), 0, 50), + ]; + } + public function create(Request $request): View|RedirectResponse { $quotes = $this->snapshot->load()['quotes'] ?? []; @@ -195,7 +222,8 @@ class CourierQuoteChanges extends Controller } } $passed = count(array_filter($results, static fn ($result) => $result['success'])); - return redirect()->route('business.courier-quote-changes.index', ['page' => max(1, (int) $request->input('page', 1))]) + $back = array_filter($this->historyFilters($request), static fn ($v) => $v !== ''); + return redirect()->route('business.courier-quote-changes.index', ['page' => max(1, (int) $request->input('page', 1))] + $back) ->with('success', '批量审核完成:成功 ' . $passed . ' 条,未通过 ' . (count($results) - $passed) . ' 条。') ->with('batch_review_results', $results); } diff --git a/resources/views/business/pages/courier-payables/quote-change-history.blade.php b/resources/views/business/pages/courier-payables/quote-change-history.blade.php index 95c00b74..5db96cd2 100644 --- a/resources/views/business/pages/courier-payables/quote-change-history.blade.php +++ b/resources/views/business/pages/courier-payables/quote-change-history.blade.php @@ -44,13 +44,26 @@ @endif
报价变更记录
草稿、审核和新版本按当前公司隔离保存,历史记录不可覆盖原报价。
- @if($changes->isEmpty()) + @php($filters = $filters ?? ['carrier' => '', 'status' => '', 'change_type' => '']) + @php($filtering = ($filters['carrier'] ?? '') !== '' || ($filters['status'] ?? '') !== '' || ($filters['change_type'] ?? '') !== '') + + @if($changes->isEmpty() && $filtering) +
没有符合条件的变更记录
换个快递公司、状态或变更类型试试,或点「清空」查看全部。
+ @elseif($changes->isEmpty())
还没有报价变更记录
发起第一张变更单后,草稿和审核进度会显示在这里。
@else @if($canReview)
@csrf + @foreach(['carrier', 'status', 'change_type'] as $keep)@if(($filters[$keep] ?? '') !== '')@endif @endforeach
已选 0 条可全选本页待审核项;逐条校验,失败项保留待处理。
@endif
@if($canReview)@endif @@ -75,7 +88,7 @@
变更单号原报价快递公司变更类型明细生效日期生效方式追溯核算状态新版本更新时间操作