From cf2eb4e6cd22e05a9f0915f2c357f68008a0a3a8 Mon Sep 17 00:00:00 2001 From: cody <648753004@qq.com> Date: Thu, 23 Oct 2025 11:25:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/OrderAgreementController.php | 25 ++++++++--- app/Models/OrderAgreement.php | 10 +++++ .../admin/order-agreement/index.blade.php | 42 ++++++++++++------- 3 files changed, 56 insertions(+), 21 deletions(-) diff --git a/app/Http/Controllers/Admin/OrderAgreementController.php b/app/Http/Controllers/Admin/OrderAgreementController.php index 407400b..376440d 100644 --- a/app/Http/Controllers/Admin/OrderAgreementController.php +++ b/app/Http/Controllers/Admin/OrderAgreementController.php @@ -22,19 +22,32 @@ class OrderAgreementController extends CommonController public function index(Request $request) { - $query = $this->model->with(['order', 'paramedicSign', 'customerSign', 'companySign', 'file']); + $query = $this->model->with(['order', 'paramedic', 'customer', 'paramedicSign', 'customerSign', 'companySign', 'file']); - // 搜索功能 + // 搜索功能 - 按订单编号搜索 + if ($request->order_serial) { + $query->whereHas('order', function ($q) use ($request) { + $q->where('serial', 'like', '%' . $request->order_serial . '%'); + }); + } + + // 按订单ID搜索(保留用于从订单列表跳转) if ($request->order_id) { $query->where('order_id', $request->order_id); } - if ($request->customer_id) { - $query->where('customer_id', $request->customer_id); + // 按客户名字搜索 + if ($request->customer_name) { + $query->whereHas('customer', function ($q) use ($request) { + $q->where('name', 'like', '%' . $request->customer_name . '%'); + }); } - if ($request->paramedic_id) { - $query->where('paramedic_id', $request->paramedic_id); + // 按护工名字搜索 + if ($request->paramedic_name) { + $query->whereHas('paramedic', function ($q) use ($request) { + $q->where('name', 'like', '%' . $request->paramedic_name . '%'); + }); } $data = $query->orderBy('id', 'desc')->paginate(10); diff --git a/app/Models/OrderAgreement.php b/app/Models/OrderAgreement.php index 2e64944..8bdfd40 100755 --- a/app/Models/OrderAgreement.php +++ b/app/Models/OrderAgreement.php @@ -31,4 +31,14 @@ class OrderAgreement extends SoftDeletesModel return $this->hasOne(Orders::class, 'id', 'order_id'); } + public function paramedic() + { + return $this->hasOne(Paramedic::class, 'id', 'paramedic_id'); + } + + public function customer() + { + return $this->hasOne(\App\Customer::class, 'id', 'customer_id'); + } + } diff --git a/resources/views/admin/order-agreement/index.blade.php b/resources/views/admin/order-agreement/index.blade.php index c543694..f228f02 100644 --- a/resources/views/admin/order-agreement/index.blade.php +++ b/resources/views/admin/order-agreement/index.blade.php @@ -15,16 +15,16 @@