commit
9e01acb511
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use App\Models\Paramedic;
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
|
||||
class OrdersExport implements FromCollection
|
||||
{
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Illuminate\Support\Collection
|
||||
*/
|
||||
public function collection()
|
||||
{
|
||||
$res = [];
|
||||
foreach ($this->data as $row) {
|
||||
$res[] = [
|
||||
"订单编号" => " ".$row->serial,
|
||||
"所属项目/医院" => $row->project->name,
|
||||
"客户姓名" => $row->customer->name ?: $row->patient->name,
|
||||
"联系电话" => " ".$row->customer->mobile,
|
||||
"被护理人" => $row->patient->name,
|
||||
"开始服务日期" => $row->from_date,
|
||||
"结束服务日期" => $row->to_date,
|
||||
"总计" => $row->total,
|
||||
"状态" => $row->getStatusLabelAttribute(),
|
||||
];
|
||||
}
|
||||
if (count($res)) {
|
||||
array_unshift($res, array_keys($res[0]));
|
||||
}
|
||||
return collect($res);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Worker;
|
||||
|
||||
use App\Models\Paramedic;
|
||||
use App\Worker;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class AuthController extends Controller
|
||||
{
|
||||
|
||||
public $guardName = "worker";
|
||||
public $authModel;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->authModel = new Worker();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new AuthController instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
||||
public function guard()
|
||||
{
|
||||
return auth()->guard($this->guardName);
|
||||
}
|
||||
|
||||
public function guardName()
|
||||
{
|
||||
return $this->guardName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/worker/login-by-username",
|
||||
* tags={"护工端用户相关"},
|
||||
* summary="V2-通过用户名密码登录",
|
||||
* description="",
|
||||
* @OA\Parameter(name="username", in="query", @OA\Schema(type="string"), required=true, description="用户名(身份证号)"),
|
||||
* @OA\Parameter(name="password", in="query", @OA\Schema(type="string"), required=true, description="密码"),
|
||||
* @OA\Response(
|
||||
* response="200",
|
||||
* description="护工通过用户名(身份证号)密码登录"
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function loginByUsername()
|
||||
{
|
||||
$credentials = [
|
||||
"id_card_number" => request()->username,
|
||||
"password" => request()->password
|
||||
];
|
||||
if (!$token = $this->guard()->attempt($credentials)) {
|
||||
return response()->json([
|
||||
'errorcode' => '401',
|
||||
'errormsg' => '登录失败'
|
||||
], 401);
|
||||
}
|
||||
|
||||
return $this->respondWithToken($token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Get(
|
||||
* path="/worker/me",
|
||||
* tags={"护工端用户相关"},
|
||||
* summary="V2-获取登录者信息",
|
||||
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
||||
* description="",
|
||||
* @OA\Response(
|
||||
* response="200",
|
||||
* description="获取登录者信息"
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function me()
|
||||
{
|
||||
$id = $this->guard()->id();
|
||||
$paramedic = (new Paramedic())->find($id);
|
||||
return response()->json($paramedic->toArray());
|
||||
}
|
||||
|
||||
/**
|
||||
* @OA\Post(
|
||||
* path="/worker/logout",
|
||||
* tags={"护工端用户相关"},
|
||||
* summary="V2 退出登录",
|
||||
* @OA\Parameter(name="token", in="query", @OA\Schema(type="string"), required=true, description="token"),
|
||||
* description="",
|
||||
* @OA\Response(
|
||||
* response="200",
|
||||
* description="退出登录"
|
||||
* )
|
||||
* )
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$this->guard()->logout();
|
||||
DB::commit();
|
||||
return response()->json([
|
||||
'errormsg' => "退出登录成功!"
|
||||
]);
|
||||
} catch (\Exception $exception) {
|
||||
DB::rollBack();
|
||||
return response()->json([
|
||||
'errorcode' => '402',
|
||||
'errormsg' => $exception->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the token array structure.
|
||||
*
|
||||
* @param string $token
|
||||
*
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
*/
|
||||
protected function respondWithToken($token)
|
||||
{
|
||||
$user = $this->guard()->user();
|
||||
$user = $user->toArray();
|
||||
|
||||
return response()->json([
|
||||
'access_token' => $token,
|
||||
'token_type' => 'bearer',
|
||||
'expires_in' => $this->guard()->factory()->getTTL() * 60,
|
||||
'user_info' => $user
|
||||
]);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Worker;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class CommonController extends Controller
|
||||
{
|
||||
public $guardName = "worker";
|
||||
public $worker;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$worker = $this->guard()->user();
|
||||
$this->worker = $worker;
|
||||
}
|
||||
|
||||
public function guard()
|
||||
{
|
||||
return auth()->guard($this->guardName);
|
||||
}
|
||||
|
||||
public function guardName()
|
||||
{
|
||||
return $this->guardName;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Notifications;
|
||||
|
||||
use App\Models\Orders;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Notifications\Messages\MailMessage;
|
||||
use Illuminate\Notifications\Notification;
|
||||
|
||||
class CustomerOrderCreated extends Notification
|
||||
{
|
||||
use Queueable;
|
||||
|
||||
public $order;
|
||||
|
||||
/**
|
||||
* Create a new notification instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Orders $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the notification's delivery channels.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function via($notifiable)
|
||||
{
|
||||
return ['database'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mail representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return \Illuminate\Notifications\Messages\MailMessage
|
||||
*/
|
||||
public function toMail($notifiable)
|
||||
{
|
||||
return (new MailMessage)
|
||||
->line('The introduction to the notification.')
|
||||
->action('Notification Action', url('/'))
|
||||
->line('Thank you for using our application!');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the array representation of the notification.
|
||||
*
|
||||
* @param mixed $notifiable
|
||||
* @return array
|
||||
*/
|
||||
public function toArray($notifiable)
|
||||
{
|
||||
return [
|
||||
"order_id" => $this->order->id,
|
||||
"order_serial" => $this->order->serial
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Illuminate\Notifications\Notifiable;
|
||||
use Tymon\JWTAuth\Contracts\JWTSubject;
|
||||
|
||||
/**
|
||||
* App\Manager
|
||||
*
|
||||
*/
|
||||
class Worker extends Authenticatable implements JWTSubject
|
||||
{
|
||||
use Notifiable;
|
||||
|
||||
protected $table = "paramedic";
|
||||
|
||||
const GUARD_NAME = "worker";
|
||||
|
||||
public function getAvatarUrlAttribute()
|
||||
{
|
||||
$protocol = request()->secure() ? "https" : "http";
|
||||
if (!$this->avatar) {
|
||||
switch ($this->sex) {
|
||||
case "男":
|
||||
$this->avatar = "/images/male.png";
|
||||
break;
|
||||
case "女":
|
||||
$this->avatar = "/images/female.png";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $this->avatar ? $protocol . "://" . request()->getHost() . $this->avatar : $this->avatar;
|
||||
}
|
||||
|
||||
public function guardName()
|
||||
{
|
||||
return self::GUARD_NAME;
|
||||
}
|
||||
|
||||
// Rest omitted for brevity
|
||||
|
||||
/**
|
||||
* Get the identifier that will be stored in the subject claim of the JWT.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getJWTIdentifier()
|
||||
{
|
||||
return $this->getKey();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a key value array, containing any custom claims to be added to the JWT.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getJWTCustomClaims()
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = [];
|
||||
|
||||
/**
|
||||
* The attributes that should be hidden for arrays.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = [
|
||||
'password', 'remember_token',
|
||||
];
|
||||
|
||||
/**
|
||||
* The attributes that should be cast to native types.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $casts = [
|
||||
'verified_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UpdateOrdersAddScore extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table("orders", function (Blueprint $table) {
|
||||
$table->decimal("score")->nullable();
|
||||
$table->timestamp("scored_at")->nullable();
|
||||
$table->string("comment")->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UpdateParamedicAddAuthFields extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table("paramedic", function (Blueprint $table) {
|
||||
$table->string("remember_token")->nullable();
|
||||
$table->string("password")->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UpdateProjectAddPercentFirstParty extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table("project", function (Blueprint $table) {
|
||||
$table->decimal("percent_first_party", 5, 2)->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class UpdateManagersAddNoLockAbility extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table("managers", function (Blueprint $table) {
|
||||
$table->tinyInteger("no_lock_ability")->default(0)->nullable();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 13 KiB |
@ -0,0 +1,110 @@
|
||||
@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>
|
||||
<input class="form-control" type="text" name="keyword" value="{{ request()->keyword }}"
|
||||
placeholder="订单编号/联系人/联系电话">
|
||||
</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>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($data as $row)
|
||||
<tr data-id="{{$row->id}}">
|
||||
<td>
|
||||
{{ $row->serial }}
|
||||
</td>
|
||||
<td>{{ $row->project->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>
|
||||
<td>
|
||||
<a class="btn btn-sm btn-primary"
|
||||
href="javascript:;" onclick="toggleItems(this)"><i
|
||||
class="mdi mdi-arrow-down"></i> 查看</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="display: none">
|
||||
<td colspan="11" class="p-0">
|
||||
<table class="table table-striped mb-0 border-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>所在床位</th>
|
||||
<th>护理日期</th>
|
||||
<th>护工</th>
|
||||
<th>单价</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($row->orderItems as $item)
|
||||
<tr data-id="{{ $item->id }}" data-item-id="{{ $item->id }}">
|
||||
<td>{{ $item->building->name }}-{{ $item->room->name }}
|
||||
-{{ $item->bed->name }}床
|
||||
</td>
|
||||
<td>{{ $item->service_date }}</td>
|
||||
<td>{{ $item->paramedic ? $item->paramedic->name : "" }}</td>
|
||||
<td data-field="total">{{ $item->total }}</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@include("public._pages")
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
|
||||
@push("footer")
|
||||
<script>
|
||||
$(function () {
|
||||
$("#pages a.page-link").each(function () {
|
||||
if (!$(this).attr("href")) {
|
||||
return;
|
||||
}
|
||||
var filters = $("#search-form").serialize();
|
||||
$(this).attr("href", $(this).attr("href") + "&" + filters);
|
||||
});
|
||||
});
|
||||
|
||||
function toggleItems(element) {
|
||||
$(element).closest("tr").next("tr").toggle();
|
||||
$(element).closest("tr").toggleClass("bg-warning");
|
||||
$(element).find("i").toggleClass("mdi-arrow-up")
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
Loading…
Reference in new issue