From adc8cfcb9cdeed6deacc7e35e600e65dc63a7a09 Mon Sep 17 00:00:00 2001 From: panliang <1163816051@qq.com> Date: Sat, 4 May 2024 08:41:28 +0800 Subject: [PATCH] admin check_status map --- app/Admin/Controllers/AgreementController.php | 2 +- app/Admin/Services/AgreementService.php | 4 +-- .../Services/EmployeePromotionService.php | 5 +--- .../Services/EmployeeSignRepairService.php | 2 +- app/Enums/CheckStatus.php | 30 +++++++++++++------ app/Enums/PromotionStatus.php | 4 +-- app/Models/Employee.php | 2 +- app/Traits/HasCheckActions.php | 2 +- lang/zh_CN/agreement.php | 2 +- 9 files changed, 31 insertions(+), 22 deletions(-) diff --git a/app/Admin/Controllers/AgreementController.php b/app/Admin/Controllers/AgreementController.php index 4c66a7b..fa3e10c 100644 --- a/app/Admin/Controllers/AgreementController.php +++ b/app/Admin/Controllers/AgreementController.php @@ -108,7 +108,7 @@ class AgreementController extends AdminController ['label' => __('agreement.employee_id'), 'content' => '${employee.name}'], ['label' => __('agreement.store_id'), 'content' => '${store.title}'], ['label' => __('agreement.created_at'), 'content' => '${created_at}'], - ['label' => __('agreement.remarks'), 'content' => '${remarks}', 'span' => 3], + ['label' => __('agreement.remarks'), 'content' => '${remarks}', 'span' => 2], ['label' => __('agreement.images'), 'content' => amisMake()->Images()->name('images')->enlargeAble(), 'span' => 3], ['label' => __('workflow_log.check_status'), 'content' => amisMake()->Mapping()->name('workflow.check_status')->map(CheckStatus::options())], ['label' => __('workflow_log.checked_at'), 'content' => '${workflow.checked_at}'], diff --git a/app/Admin/Services/AgreementService.php b/app/Admin/Services/AgreementService.php index 6f3c1ee..c4fc62a 100644 --- a/app/Admin/Services/AgreementService.php +++ b/app/Admin/Services/AgreementService.php @@ -47,10 +47,10 @@ class AgreementService extends BaseService if ($user->can('admin.agreement.view')) { array_push($actions, 'view'); } - if ($user->can('admin.agreement.update') && $model->canUpdate()) { + if ($user->can('admin.agreement.update') && !in_array($model->workflow->check_status, [CheckStatus::Processing])) { array_push($actions, 'edit'); } - if ($user->can('admin.agreement.delete')) { + if ($user->can('admin.agreement.delete') && !in_array($model->workflow->check_status, [CheckStatus::Processing])) { array_push($actions, 'delete'); } if ($user->can('admin.agreement.download') && in_array($model->workflow->check_status, [CheckStatus::Success])) { diff --git a/app/Admin/Services/EmployeePromotionService.php b/app/Admin/Services/EmployeePromotionService.php index f475a03..ded82fa 100644 --- a/app/Admin/Services/EmployeePromotionService.php +++ b/app/Admin/Services/EmployeePromotionService.php @@ -54,7 +54,7 @@ class EmployeePromotionService extends BaseService if ($user->can('admin.hr.promotion.update') && !in_array($model->promotion_status, [PromotionStatus::Processing])) { array_push($actions, 'edit'); } - if ($user->can('admin.hr.promotion.delete') && !in_array($model->promotion_status, [PromotionStatus::Processing, PromotionStatus::Fail])) { + if ($user->can('admin.hr.promotion.delete') && !in_array($model->promotion_status, [PromotionStatus::Processing])) { array_push($actions, 'delete'); } if (in_array($model->promotion_status, [PromotionStatus::Processing])) { @@ -174,9 +174,6 @@ class EmployeePromotionService extends BaseService { $list = $this->query()->with(['workflow'])->whereIn('id', explode(',', $ids))->get(); foreach ($list as $item) { - if (!$item->canUpdate()) { - throw new RuntimeException($item->promotion_status->text() . ', 无法删除'); - } $item->delete(); } return true; diff --git a/app/Admin/Services/EmployeeSignRepairService.php b/app/Admin/Services/EmployeeSignRepairService.php index b1505dd..d96db13 100644 --- a/app/Admin/Services/EmployeeSignRepairService.php +++ b/app/Admin/Services/EmployeeSignRepairService.php @@ -8,7 +8,7 @@ use Illuminate\Support\Facades\Validator; use Illuminate\Validation\Rule; use Slowlyo\OwlAdmin\Admin; use App\Enums\CheckStatus; -use Slowlyo\OwlAdmin\Models\AdminUser; +use App\Models\AdminUser; use App\Exceptions\RuntimeException; class EmployeeSignRepairService extends BaseService diff --git a/app/Enums/CheckStatus.php b/app/Enums/CheckStatus.php index 5bc9102..888dc49 100644 --- a/app/Enums/CheckStatus.php +++ b/app/Enums/CheckStatus.php @@ -28,15 +28,27 @@ enum CheckStatus: int */ case Cancel = 5; - public static function options(): array + public static function options($index = 1): array { - return [ - self::None->value => '待提审', - self::Processing->value => '审核中', - self::Success->value => '已通过', - self::Fail->value => '已拒绝', - // self::Cancel->value => '已取消', + $maps = [ + // 申请人看到的状态 + 1 => [ + self::None->value => '待提审', + self::Processing->value => '审核中', + self::Success->value => '已通过', + self::Fail->value => '未通过', + // self::Cancel->value => '已取消', + ], + // 审核人看到的状态 + 2 => [ + self::None->value => '未开始', + self::Processing->value => '待审核', + self::Success->value => '已通过', + self::Fail->value => '未通过', + // self::Cancel->value => '已取消', + ] ]; + return data_get($maps, $index); } public static function labelMap(): array @@ -50,8 +62,8 @@ enum CheckStatus: int ]; } - public function text() + public function text($index = 1) { - return data_get(self::options(), $this->value); + return data_get(self::options($index), $this->value); } } diff --git a/app/Enums/PromotionStatus.php b/app/Enums/PromotionStatus.php index 7e3a37e..f176bc5 100644 --- a/app/Enums/PromotionStatus.php +++ b/app/Enums/PromotionStatus.php @@ -34,8 +34,8 @@ enum PromotionStatus: int self::Employee->value => '待补充', self::Invitor->value => '待推荐', self::Processing->value => '审核中', - self::Success->value => '审核通过', - self::Fail->value => '审核不通过', + self::Success->value => '已通过', + self::Fail->value => '未通过', ]; } diff --git a/app/Models/Employee.php b/app/Models/Employee.php index f0936c6..5ccadf9 100644 --- a/app/Models/Employee.php +++ b/app/Models/Employee.php @@ -11,7 +11,7 @@ use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract; use Illuminate\Database\Eloquent\Casts\Attribute; use Illuminate\Database\Eloquent\Model; use Laravel\Sanctum\HasApiTokens; -use Slowlyo\OwlAdmin\Models\AdminUser; +use App\Models\AdminUser; use App\Enums\UserRole; use Illuminate\Database\Eloquent\Builder; diff --git a/app/Traits/HasCheckActions.php b/app/Traits/HasCheckActions.php index c12794c..aba8716 100644 --- a/app/Traits/HasCheckActions.php +++ b/app/Traits/HasCheckActions.php @@ -77,7 +77,7 @@ trait HasCheckActions amis()->TableColumn()->name('batch_id')->label(__('workflow_log.batch_id')), amis()->TableColumn()->name('check_name')->label(__('workflow_log.check_name')), amis()->TableColumn()->name('check_user.name')->label(__('workflow_log.check_user_id')), - amis()->TableColumn()->name('check_status')->label(__('workflow_log.check_status'))->set('type', 'mapping')->map(CheckStatus::options()), + amis()->TableColumn()->name('check_status')->label(__('workflow_log.check_status'))->set('type', 'mapping')->map(CheckStatus::options(2)), amis()->TableColumn()->name('checked_at')->label(__('workflow_log.checked_at')), amis()->TableColumn()->name('remarks')->label(__('workflow_log.remarks')), ])->itemActions([ diff --git a/lang/zh_CN/agreement.php b/lang/zh_CN/agreement.php index 3703e2a..2b1c28c 100644 --- a/lang/zh_CN/agreement.php +++ b/lang/zh_CN/agreement.php @@ -9,5 +9,5 @@ return [ 'employee_id' => '上传人', 'images' => '合同图片', 'remarks' => '备注', - 'store_id' => '合同', + 'store_id' => '门店', ];