liyinglin 2 years ago
parent 21a0415216
commit d424a290a3

@ -10,6 +10,7 @@ namespace App\Http\Controllers\Admin;
use App\Exports\OrdersExport;
use App\Models\AdminAreaLink;
use App\Models\Area;
use App\Models\Bed;
use App\Models\OrderItems;
use App\Models\Orders;
@ -198,4 +199,62 @@ class OrdersController extends CommonController
->paginate(10);
return view($this->bladePath . ".score", compact("data", "project_id"));
}
/**
* 陪护一览
*/
public function artboard(Request $request)
{
$userId = auth()->id();
// 判断是否护士长
$roleId = Role::where('name', 'like', '%护士长%')->where('guard_name', 'admin')->value('id');
$hushizhang = DB::table('model_has_roles')->where('role_id', $roleId)
->where('model_type', 'App\Admin')
->where('model_id', $userId)->count();
$areaId = [];
if ($hushizhang) {
$user = auth()->user();
$areaId = AdminAreaLink::where(function ($qeury) use ($request) {
if ($request->project_id) {
$qeury->where('project_id', $request->project_id);
}
})->where('admin_id', $user->id)->pluck('area_id');
}
$data = Area::where(function ($query) use ($areaId) {
if ($areaId) {
$query->whereIn('id', $areaId);
}
})->with([
"beds" => function ($query) use ($request) {
if ($request->has_ongoing_order) {
$query->has("onGoingOrder");
}
$query->with(["onGoingOrder" => function ($query) {
$query->leftJoin("paramedic", "orders.paramedic_id", "=", "paramedic.id")
->select("orders.id", "orders.bed_id", "orders.paramedic_id", "orders.status", "paramedic.name as paramedic_name");
}])->select("bed.id", "bed.name", "bed.room_id", "bed.area_id", "bed.myindex")
->leftJoin("room", "bed.room_id", "=", "room.id")
->addSelect("room.name as room_name")
->orderBy("room.name")
->orderBy("bed.name");
}])->whereRaw("`area`.`project_id` = '{$request->project_id}'")
->orderBy("building.myindex")
->orderBy("area.myindex")
->select("area.id", "area.name", "area.building_id", "area.project_id")
->leftJoin("building", "area.building_id", "=", "building.id")
->addSelect("building.name as building_name")
->withCount("beds")
->get();
if ($request->has_ongoing_order) {
$data = $data->filter(function ($item) {
return $item->beds->count();
});
}
dd($data->toArray());
return view($this->bladePath . ".artboard", compact("data"));
}
}

@ -0,0 +1,62 @@
@extends("admin.layouts.layout")
@section("content")
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="mb-3">
<form class="form-inline" id="search-form" autocomplete="off">
<select class="form-control mr-1" name="project_id"
onchange="$(this).closest('form').submit()">
@foreach($projects as $pp)
<option
value="{{$pp->id}}" @if($pp->id == $project_id) {{ "selected" }}@endif>{{$pp->name}}</option>
@endforeach
</select>
</form>
</div>
<table class="table table-bordered" id="data-table">
<thead>
<tr>
<th>订单编号</th>
<th>所属项目/医院</th>
<th>所在楼栋</th>
<th>所在病区</th>
<th>客户姓名</th>
<th>联系电话</th>
<th>被护理人</th>
<th>开始服务日期</th>
<th>评分</th>
<th>评价</th>
<th>操作</th>
</tr>
</thead>
<tbody>
@foreach ($data as $row)
<tr data-id="{{$row->id}}">
<td>
{{ $row->serial }}
</td>
<td>{{ $row->project->name }}</td>
<td>{{ $row->bed->building->name }}</td>
<td>{{ $row->bed->area->name }}</td>
<td>{{ $row->customer->name ?: $row->patient->name }}</td>
<td>{{ $row->customer->mobile }}</td>
<td>{{ $row->patient->name }}</td>
<td>{{ $row->from_date }}</td>
<td>{{ $row->score }}</td>
<td>{{ $row->comment }}</td>
</tr>
@endforeach
</tbody>
</table>
@include("public._pages")
</div>
</div>
</div>
</div>
@endsection

@ -92,6 +92,9 @@ Route::group(["namespace" => "Admin", "prefix" => "admin"], function () {
Route::get("orders/get-item/{item_id}", 'OrdersController@getItem');
Route::get("orders/score", 'OrdersController@score');
Route::get("orders/artboard", 'OrdersController@artboard');
Route::get("statistics/overview", 'StatisticsController@overview');
Route::get("statistics/salary", 'StatisticsController@salary');
Route::get("statistics/finance", 'StatisticsController@finance');

Loading…
Cancel
Save