From fe3ea9d90b67765111c1cd72d3928629e1c921ac Mon Sep 17 00:00:00 2001 From: Jing Li Date: Thu, 4 Apr 2024 11:18:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A1=E6=89=B9=E7=8A=B6=E6=80=81-=E5=BE=85?= =?UTF-8?q?=E6=8F=90=E5=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/Hr/HolidayController.php | 6 +++--- .../Controllers/Hr/OfficalBusinessController.php | 6 +++--- app/Admin/Controllers/Hr/OvertimeController.php | 6 +++--- app/Admin/Controllers/Hr/SignRepairController.php | 4 ++-- app/Admin/Services/WorkFlowService.php | 14 +++++++------- app/Enums/CheckStatus.php | 9 +++++++-- app/Models/WorkflowCheck.php | 6 +++++- app/Traits/HasCheckActions.php | 2 +- .../2024_03_27_113404_create_workflows_table.php | 4 ++-- 9 files changed, 33 insertions(+), 24 deletions(-) diff --git a/app/Admin/Controllers/Hr/HolidayController.php b/app/Admin/Controllers/Hr/HolidayController.php index 67e1b5e..28d59b6 100644 --- a/app/Admin/Controllers/Hr/HolidayController.php +++ b/app/Admin/Controllers/Hr/HolidayController.php @@ -67,10 +67,10 @@ class HolidayController extends AdminController $this->rowShowButton()->visible(Admin::user()->can('admin.hr.holiday.view')), $this->rowEditTypeButton('drawer', 'xl') ->visible(Admin::user()->can('admin.hr.holiday.update')) - ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), $this->rowDeleteButton() ->visible(Admin::user()->can('admin.hr.holiday.delete')) - ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), $this->applyAction(), $this->cancelAction(), ]), @@ -144,4 +144,4 @@ class HolidayController extends AdminController ] ])->body([$detail, amisMake()->Divider(), $table]); } -} \ No newline at end of file +} diff --git a/app/Admin/Controllers/Hr/OfficalBusinessController.php b/app/Admin/Controllers/Hr/OfficalBusinessController.php index a980164..abdbf7c 100644 --- a/app/Admin/Controllers/Hr/OfficalBusinessController.php +++ b/app/Admin/Controllers/Hr/OfficalBusinessController.php @@ -61,10 +61,10 @@ class OfficalBusinessController extends AdminController $this->rowShowButton()->visible(Admin::user()->can('admin.hr.business.view')), $this->rowEditTypeButton('drawer', 'xl') ->visible(Admin::user()->can('admin.hr.business.update')) - ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), $this->rowDeleteButton() ->visible(Admin::user()->can('admin.hr.business.delete')) - ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), $this->applyAction(), $this->cancelAction(), ]), @@ -131,4 +131,4 @@ class OfficalBusinessController extends AdminController ] ])->body([$detail, amisMake()->Divider(), $table]); } -} \ No newline at end of file +} diff --git a/app/Admin/Controllers/Hr/OvertimeController.php b/app/Admin/Controllers/Hr/OvertimeController.php index 57e4d47..0eb2f43 100644 --- a/app/Admin/Controllers/Hr/OvertimeController.php +++ b/app/Admin/Controllers/Hr/OvertimeController.php @@ -62,10 +62,10 @@ class OvertimeController extends AdminController $this->rowShowButton()->visible(Admin::user()->can('admin.hr.overtime.view')), $this->rowEditTypeButton('drawer', 'xl') ->visible(Admin::user()->can('admin.hr.overtime.update')) - ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), $this->rowDeleteButton() ->visible(Admin::user()->can('admin.hr.overtime.delete')) - ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), $this->applyAction(), $this->cancelAction(), ]), @@ -133,4 +133,4 @@ class OvertimeController extends AdminController ] ])->body([$detail, amisMake()->Divider(), $table]); } -} \ No newline at end of file +} diff --git a/app/Admin/Controllers/Hr/SignRepairController.php b/app/Admin/Controllers/Hr/SignRepairController.php index 45cdb7e..446150d 100644 --- a/app/Admin/Controllers/Hr/SignRepairController.php +++ b/app/Admin/Controllers/Hr/SignRepairController.php @@ -66,10 +66,10 @@ class SignRepairController extends AdminController $this->rowShowButton()->visible(Admin::user()->can('admin.hr.repairs.view')), $this->rowEditTypeButton('drawer', 'xl') ->visible(Admin::user()->can('admin.hr.repairs.update')) - ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), $this->rowDeleteButton() ->visible(Admin::user()->can('admin.hr.repairs.delete')) - ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), $this->applyAction(), $this->cancelAction(), ]) diff --git a/app/Admin/Services/WorkFlowService.php b/app/Admin/Services/WorkFlowService.php index 995e620..58070d8 100644 --- a/app/Admin/Services/WorkFlowService.php +++ b/app/Admin/Services/WorkFlowService.php @@ -20,10 +20,10 @@ class WorkFlowService extends BaseService * 发起审核申请 * 1. 待审核 Model 实现 Checkable * 2. 生成全部的审核流程 - * + * * @param WorkflowCheck $check 待审核记录 * @param Employee $user 申请人 - * + * * @return boolean true: 成功, false: 失败, $this->getError(): 错误消息 */ public function apply(WorkflowCheck $check, Employee $user) @@ -110,11 +110,11 @@ class WorkFlowService extends BaseService * 取消审核 * 1. 删除未审核的流程 * 2. 更新申请记录的状态 - * + * */ public function cancel(WorkflowCheck $check) { - $check->logs()->whereIn('check_status', [CheckStatus::None, CheckStatus::Processing])->delete(); + $check->logs()->whereIn('check_status', [CheckStatus::Pending, CheckStatus::Processing])->delete(); $check->update([ 'check_status' => CheckStatus::Cancel, ]); @@ -124,7 +124,7 @@ class WorkFlowService extends BaseService /** * 审核单个流程 - * + * * @param Employee $user 审核人 * @param WorkflowLog $log 审核流水记录 * @param boolean $status 通过/不通过 @@ -155,13 +155,13 @@ class WorkFlowService extends BaseService /** * 开启下一个审核流程 - * + * * @param WorkflowCheck $check * @return boolean */ public function next(WorkflowCheck $check) { - $log = $check->logs()->where('check_status', CheckStatus::None)->orderBy('sort')->first(); + $log = $check->logs()->where('check_status', CheckStatus::Pending)->orderBy('sort')->first(); if ($log) { $log->update(['check_status' => CheckStatus::Processing]); // 申请人自动审核通过 diff --git a/app/Enums/CheckStatus.php b/app/Enums/CheckStatus.php index b8de3fc..43cb410 100644 --- a/app/Enums/CheckStatus.php +++ b/app/Enums/CheckStatus.php @@ -7,10 +7,14 @@ namespace App\Enums; */ enum CheckStatus: int { + /** + * 待提审 + */ + case None = 0; /** * 待审核 */ - case None = 1; + case Pending = 1; /** * 审核中 */ @@ -31,7 +35,8 @@ enum CheckStatus: int public static function options(): array { return [ - self::None->value => '待审核', + self::None->value => '待提审', + self::Pending->value => '待审核', self::Processing->value => '审核中', self::Success->value => '审核通过', self::Fail->value => '审核不通过', diff --git a/app/Models/WorkflowCheck.php b/app/Models/WorkflowCheck.php index 6323621..70b0a02 100644 --- a/app/Models/WorkflowCheck.php +++ b/app/Models/WorkflowCheck.php @@ -15,7 +15,11 @@ use EloquentFilter\Filterable; class WorkflowCheck extends Model { use HasDateTimeFormatter, Filterable; - + + protected $attributes = [ + 'check_status' => CheckStatus::Pending, + ]; + protected $fillable = ['subject_type', 'subject_id', 'subject_data', 'key', 'employee_id', 'check_status', 'checked_at', 'check_remarks']; protected $casts = [ diff --git a/app/Traits/HasCheckActions.php b/app/Traits/HasCheckActions.php index b13a412..b7412d1 100644 --- a/app/Traits/HasCheckActions.php +++ b/app/Traits/HasCheckActions.php @@ -17,7 +17,7 @@ trait HasCheckActions 'user' => '${employee_id}', ])) ->confirmText(__('admin.confirm')) - ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'); + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'); } diff --git a/database/migrations/2024_03_27_113404_create_workflows_table.php b/database/migrations/2024_03_27_113404_create_workflows_table.php index 4119438..52ea413 100644 --- a/database/migrations/2024_03_27_113404_create_workflows_table.php +++ b/database/migrations/2024_03_27_113404_create_workflows_table.php @@ -28,7 +28,7 @@ return new class extends Migration $table->morphs('subject'); $table->json('subject_data')->nullable('审核内容'); $table->foreignId('employee_id')->nullable()->comment('申请人, employees.id'); - $table->unsignedInteger('check_status')->default(CheckStatus::None->value)->comment('审核状态'); + $table->unsignedInteger('check_status')->default(CheckStatus::Pending->value)->comment('审核状态'); $table->timestamp('checked_at')->nullable()->comment('审核通过时间'); $table->string('check_remarks')->nullable()->comment('审核未通过原因'); @@ -46,7 +46,7 @@ return new class extends Migration $table->unsignedBigInteger('check_user_id')->nullable()->comment('实际审核人(admin_users.id)'); $table->timestamp('checked_at')->nullable()->comment('审核时间'); $table->string('remarks')->nullable()->comment('审核备注'); - $table->unsignedTinyInteger('check_status')->default(CheckStatus::None->value)->comment('审核状态'); + $table->unsignedTinyInteger('check_status')->default(CheckStatus::Pending->value)->comment('审核状态'); $table->unsignedInteger('sort')->default(0)->comment('顺序(asc)'); $table->timestamps();