|
...
|
...
|
@@ -28,13 +28,13 @@ class WorkOrderController extends BaseController |
|
|
|
'workOrder.project:id,company',
|
|
|
|
])
|
|
|
|
->where('manage_id', $this->manage['id'])
|
|
|
|
->when($request->input('project_id'), function ($query) use ($request) {
|
|
|
|
->when($request->input('project_id') !== null, function ($query) use ($request) {
|
|
|
|
// project_id 查 workOrder
|
|
|
|
return $query->whereHas('workOrder', function ($q) use ($request) {
|
|
|
|
$q->where('project_id', $request->input('project_id'));
|
|
|
|
});
|
|
|
|
})
|
|
|
|
->when($request->input('status'), function ($query) use ($request) {
|
|
|
|
->when($request->input('status') !== null, function ($query) use ($request) {
|
|
|
|
// status 查 WorkOrderLog
|
|
|
|
return $query->where('status', $request->input('status'));
|
|
|
|
})
|
|
...
|
...
|
@@ -67,10 +67,10 @@ class WorkOrderController extends BaseController |
|
|
|
'logs.manager:id,name',
|
|
|
|
'project:id,company',
|
|
|
|
])
|
|
|
|
->when($request->input('project_id'), function ($query) use ($request) {
|
|
|
|
->when($request->input('project_id') !== null, function ($query) use ($request) {
|
|
|
|
return $query->where('project_id', $request->input('project_id'));
|
|
|
|
})
|
|
|
|
->when($request->input('status'), function ($query) use ($request) {
|
|
|
|
->when($request->input('status') !== null, function ($query) use ($request) {
|
|
|
|
return $query->where('status', $request->input('status'));
|
|
|
|
})
|
|
|
|
->when($request->input('search'), function ($query) use ($request) {
|
|
...
|
...
|
@@ -150,19 +150,23 @@ class WorkOrderController extends BaseController |
|
|
|
$log->status = WorkOrderLog::STATUS_COMPLETED;
|
|
|
|
$log->end_at = now();
|
|
|
|
$log->save();
|
|
|
|
// 如果所有的子任务都已完成, 则更新工单主表状态
|
|
|
|
$pending = $workOrder->logs()
|
|
|
|
->where('status', '<', WorkOrderLog::STATUS_COMPLETED)
|
|
|
|
->count();
|
|
|
|
if ($pending == 0)
|
|
|
|
{
|
|
|
|
$workOrder->status = WorkOrderLog::STATUS_COMPLETED;
|
|
|
|
$workOrder->save();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($request->input('status') !== null)
|
|
|
|
{
|
|
|
|
$log->status = $request->input('status');
|
|
|
|
$log->save();
|
|
|
|
}
|
|
|
|
// 如果所有的子任务都已完成, 则更新工单主表状态
|
|
|
|
$pending = $workOrder->logs()
|
|
|
|
->where('status', '<', WorkOrderLog::STATUS_COMPLETED)
|
|
|
|
->count();
|
|
|
|
if ($pending == 0)
|
|
|
|
{
|
|
|
|
$workOrder->status = WorkOrderLog::STATUS_COMPLETED;
|
|
|
|
$workOrder->save();
|
|
|
|
}
|
|
|
|
return $log;
|
|
|
|
});
|
|
|
|
|
|
|
|
$this->response('success', Code::SUCCESS, $result->toArray());
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|