diff --git a/app/Admin/Controllers/Hr/HolidayController.php b/app/Admin/Controllers/Hr/HolidayController.php index 28d59b6..428052a 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::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->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::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), $this->applyAction(), $this->cancelAction(), ]), diff --git a/app/Admin/Controllers/Hr/OfficalBusinessController.php b/app/Admin/Controllers/Hr/OfficalBusinessController.php index abdbf7c..15256cd 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::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->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::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), $this->applyAction(), $this->cancelAction(), ]), diff --git a/app/Admin/Controllers/Hr/OvertimeController.php b/app/Admin/Controllers/Hr/OvertimeController.php index 0eb2f43..85eb353 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::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->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::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), $this->applyAction(), $this->cancelAction(), ]), diff --git a/app/Admin/Controllers/Hr/SignRepairController.php b/app/Admin/Controllers/Hr/SignRepairController.php index 446150d..45cdb7e 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::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->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::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'), + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->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 58070d8..594aff0 100644 --- a/app/Admin/Services/WorkFlowService.php +++ b/app/Admin/Services/WorkFlowService.php @@ -114,7 +114,7 @@ class WorkFlowService extends BaseService */ public function cancel(WorkflowCheck $check) { - $check->logs()->whereIn('check_status', [CheckStatus::Pending, CheckStatus::Processing])->delete(); + $check->logs()->whereIn('check_status', [CheckStatus::None, CheckStatus::Processing])->delete(); $check->update([ 'check_status' => CheckStatus::Cancel, ]); @@ -161,7 +161,7 @@ class WorkFlowService extends BaseService */ public function next(WorkflowCheck $check) { - $log = $check->logs()->where('check_status', CheckStatus::Pending)->orderBy('sort')->first(); + $log = $check->logs()->where('check_status', CheckStatus::None)->orderBy('sort')->first(); if ($log) { $log->update(['check_status' => CheckStatus::Processing]); // 申请人自动审核通过 diff --git a/app/Enums/CheckStatus.php b/app/Enums/CheckStatus.php index 43cb410..8757882 100644 --- a/app/Enums/CheckStatus.php +++ b/app/Enums/CheckStatus.php @@ -10,11 +10,7 @@ enum CheckStatus: int /** * 待提审 */ - case None = 0; - /** - * 待审核 - */ - case Pending = 1; + case None = 1; /** * 审核中 */ @@ -36,7 +32,6 @@ enum CheckStatus: int { return [ 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 70b0a02..67bfd1d 100644 --- a/app/Models/WorkflowCheck.php +++ b/app/Models/WorkflowCheck.php @@ -17,7 +17,7 @@ class WorkflowCheck extends Model use HasDateTimeFormatter, Filterable; protected $attributes = [ - 'check_status' => CheckStatus::Pending, + 'check_status' => CheckStatus::None, ]; protected $fillable = ['subject_type', 'subject_id', 'subject_data', 'key', 'employee_id', 'check_status', 'checked_at', 'check_remarks']; diff --git a/app/Traits/HasCheckActions.php b/app/Traits/HasCheckActions.php index b7412d1..b13a412 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::Pending->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'); + ->visibleOn('${OR(workflow.check_status == '.CheckStatus::None->value.', workflow.check_status == '.CheckStatus::Cancel->value.', workflow.check_status == '.CheckStatus::Fail->value.')}'); } diff --git a/app/Traits/HasCheckable.php b/app/Traits/HasCheckable.php index 9213334..d41161d 100644 --- a/app/Traits/HasCheckable.php +++ b/app/Traits/HasCheckable.php @@ -9,7 +9,6 @@ use Illuminate\Support\Str; trait HasCheckable { - protected $check_key = ''; protected static function booted(): void { static::created(function ($model) { @@ -20,9 +19,13 @@ trait HasCheckable }); } - public function getCheckKey() + public function getCheckKey(): string { - return $this->check_key ?: Str::snake(class_basename(__CLASS__)); + if (property_exists($this, 'checkKey')) { + return $this->checkKey; + } + + return Str::snake(class_basename(__CLASS__)); } /** 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 52ea413..4119438 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::Pending->value)->comment('审核状态'); + $table->unsignedInteger('check_status')->default(CheckStatus::None->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::Pending->value)->comment('审核状态'); + $table->unsignedTinyInteger('check_status')->default(CheckStatus::None->value)->comment('审核状态'); $table->unsignedInteger('sort')->default(0)->comment('顺序(asc)'); $table->timestamps();