From db7395fe36663bd2c6013c0c36d9e4964a4ab1dd Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Fri, 3 May 2024 21:47:47 +0800 Subject: [PATCH] admin delete --- app/Admin/Controllers/AdminController.php | 5 ++++- app/Admin/Services/EmployeeSignRepairService.php | 9 --------- app/Admin/Services/HolidayApplyService.php | 3 --- app/Admin/Services/OfficalBusinessService.php | 3 --- app/Admin/Services/OvertimeApplyService.php | 3 --- 5 files changed, 4 insertions(+), 19 deletions(-) diff --git a/app/Admin/Controllers/AdminController.php b/app/Admin/Controllers/AdminController.php index 6a2daaf..b85eeab 100644 --- a/app/Admin/Controllers/AdminController.php +++ b/app/Admin/Controllers/AdminController.php @@ -84,7 +84,10 @@ abstract class AdminController extends Controller try { DB::beginTransaction(); - $this->service->delete($ids); + $result = $this->service->delete($ids); + if ($result === false) { + admin_abort($this->service->getError()); + } DB::commit(); } catch (Throwable $th) { diff --git a/app/Admin/Services/EmployeeSignRepairService.php b/app/Admin/Services/EmployeeSignRepairService.php index 00f6235..b1505dd 100644 --- a/app/Admin/Services/EmployeeSignRepairService.php +++ b/app/Admin/Services/EmployeeSignRepairService.php @@ -118,15 +118,6 @@ class EmployeeSignRepairService extends BaseService { $list = $this->query()->with(['workflow'])->whereIn('id', explode(',', $ids))->get(); foreach ($list as $item) { - $workflow = $item->workflow; - if ($workflow) { - if ($workflow->check_status == CheckStatus::Processing) { - throw new RuntimeException(CheckStatus::Processing->text() . ', 无法删除'); - } - if ($workflow->check_status == CheckStatus::Success) { - throw new RuntimeException(CheckStatus::Success->text() . ', 无法删除'); - } - } $item->delete(); } return true; diff --git a/app/Admin/Services/HolidayApplyService.php b/app/Admin/Services/HolidayApplyService.php index c902284..421811d 100644 --- a/app/Admin/Services/HolidayApplyService.php +++ b/app/Admin/Services/HolidayApplyService.php @@ -116,9 +116,6 @@ class HolidayApplyService extends BaseService { $list = $this->query()->with(['workflow'])->whereIn('id', explode(',', $ids))->get(); foreach ($list as $item) { - if (!$item->canUpdate()) { - return $this->setError('审核中, 无法删除'); - } $item->delete(); } return true; diff --git a/app/Admin/Services/OfficalBusinessService.php b/app/Admin/Services/OfficalBusinessService.php index 625a3b0..3eb61b9 100644 --- a/app/Admin/Services/OfficalBusinessService.php +++ b/app/Admin/Services/OfficalBusinessService.php @@ -116,9 +116,6 @@ class OfficalBusinessService extends BaseService { $list = $this->query()->with(['workflow'])->whereIn('id', explode(',', $ids))->get(); foreach ($list as $item) { - if (!$item->canUpdate()) { - return $this->setError('审核中, 无法删除'); - } $item->delete(); } return true; diff --git a/app/Admin/Services/OvertimeApplyService.php b/app/Admin/Services/OvertimeApplyService.php index 4dc7958..2ef71ac 100644 --- a/app/Admin/Services/OvertimeApplyService.php +++ b/app/Admin/Services/OvertimeApplyService.php @@ -126,9 +126,6 @@ class OvertimeApplyService extends BaseService { $list = $this->query()->with(['workflow'])->whereIn('id', explode(',', $ids))->get(); foreach ($list as $item) { - if (!$item->canUpdate()) { - return $this->setError('审核中, 无法删除'); - } $item->delete(); } return true;