master
cody 6 months ago
parent 9cd8c85df7
commit cf2eb4e6cd

@ -22,19 +22,32 @@ class OrderAgreementController extends CommonController
public function index(Request $request) 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) { if ($request->order_id) {
$query->where('order_id', $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); $data = $query->orderBy('id', 'desc')->paginate(10);

@ -31,4 +31,14 @@ class OrderAgreement extends SoftDeletesModel
return $this->hasOne(Orders::class, 'id', 'order_id'); 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');
}
} }

@ -15,16 +15,16 @@
<div class="mb-3"> <div class="mb-3">
<form method="GET" action="{{url($urlPrefix)}}" class="form-inline"> <form method="GET" action="{{url($urlPrefix)}}" class="form-inline">
<div class="form-group mr-2"> <div class="form-group mr-2">
<input type="number" name="order_id" class="form-control" placeholder="订单ID" <input type="text" name="order_serial" class="form-control" placeholder="订单编号"
value="{{request('order_id')}}"> value="{{request('order_serial')}}">
</div> </div>
<div class="form-group mr-2"> <div class="form-group mr-2">
<input type="number" name="customer_id" class="form-control" placeholder="客户ID" <input type="text" name="customer_name" class="form-control" placeholder="客户姓名"
value="{{request('customer_id')}}"> value="{{request('customer_name')}}">
</div> </div>
<div class="form-group mr-2"> <div class="form-group mr-2">
<input type="number" name="paramedic_id" class="form-control" placeholder="护工ID" <input type="text" name="paramedic_name" class="form-control" placeholder="护工姓名"
value="{{request('paramedic_id')}}"> value="{{request('paramedic_name')}}">
</div> </div>
<button type="submit" class="btn btn-info mr-2">搜索</button> <button type="submit" class="btn btn-info mr-2">搜索</button>
<a href="{{url($urlPrefix)}}" class="btn btn-secondary">重置</a> <a href="{{url($urlPrefix)}}" class="btn btn-secondary">重置</a>
@ -35,13 +35,13 @@
<thead> <thead>
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>订单ID</th> <th>订单编号</th>
<th>护工ID</th> <th>护工姓名</th>
<th>客户ID</th> <th>客户姓名</th>
<th>护工签名</th> <th>护工签名</th>
<th>客户签名</th> <th>客户签名</th>
<th>公司签名</th> <th>公司签名</th>
<th>文件</th> <th>协议文件</th>
<th>创建时间</th> <th>创建时间</th>
<th>操作</th> <th>操作</th>
</tr> </tr>
@ -52,13 +52,25 @@
<td>{{ $row->id }}</td> <td>{{ $row->id }}</td>
<td> <td>
@if($row->order) @if($row->order)
{{ $row->order_id }} {{ $row->order->serial }}
@else @else
{{ $row->order_id ?: '-' }} -
@endif
</td>
<td>
@if($row->paramedic)
{{ $row->paramedic->name }}
@else
-
@endif
</td>
<td>
@if($row->customer)
{{ $row->customer->name }}
@else
-
@endif @endif
</td> </td>
<td>{{ $row->paramedic_id ?: '-' }}</td>
<td>{{ $row->customer_id ?: '-' }}</td>
<td> <td>
@if($row->paramedicSign) @if($row->paramedicSign)
<a href="{{Storage::url($row->paramedicSign->folder . '/' . $row->paramedicSign->name)}}" <a href="{{Storage::url($row->paramedicSign->folder . '/' . $row->paramedicSign->name)}}"
@ -86,7 +98,7 @@
<td> <td>
@if($row->file) @if($row->file)
<a href="{{Storage::url($row->file->folder . '/' . $row->file->name)}}" <a href="{{Storage::url($row->file->folder . '/' . $row->file->name)}}"
target="_blank">下载</a> target="_blank">查看</a>
@else @else
- -
@endif @endif

Loading…
Cancel
Save