main
Jing Li 2024-04-04 11:42:36 +08:00
parent fe3ea9d90b
commit 0ec4e24c84
10 changed files with 21 additions and 23 deletions

View File

@ -67,10 +67,10 @@ class HolidayController extends AdminController
$this->rowShowButton()->visible(Admin::user()->can('admin.hr.holiday.view')), $this->rowShowButton()->visible(Admin::user()->can('admin.hr.holiday.view')),
$this->rowEditTypeButton('drawer', 'xl') $this->rowEditTypeButton('drawer', 'xl')
->visible(Admin::user()->can('admin.hr.holiday.update')) ->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() $this->rowDeleteButton()
->visible(Admin::user()->can('admin.hr.holiday.delete')) ->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->applyAction(),
$this->cancelAction(), $this->cancelAction(),
]), ]),

View File

@ -61,10 +61,10 @@ class OfficalBusinessController extends AdminController
$this->rowShowButton()->visible(Admin::user()->can('admin.hr.business.view')), $this->rowShowButton()->visible(Admin::user()->can('admin.hr.business.view')),
$this->rowEditTypeButton('drawer', 'xl') $this->rowEditTypeButton('drawer', 'xl')
->visible(Admin::user()->can('admin.hr.business.update')) ->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() $this->rowDeleteButton()
->visible(Admin::user()->can('admin.hr.business.delete')) ->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->applyAction(),
$this->cancelAction(), $this->cancelAction(),
]), ]),

View File

@ -62,10 +62,10 @@ class OvertimeController extends AdminController
$this->rowShowButton()->visible(Admin::user()->can('admin.hr.overtime.view')), $this->rowShowButton()->visible(Admin::user()->can('admin.hr.overtime.view')),
$this->rowEditTypeButton('drawer', 'xl') $this->rowEditTypeButton('drawer', 'xl')
->visible(Admin::user()->can('admin.hr.overtime.update')) ->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() $this->rowDeleteButton()
->visible(Admin::user()->can('admin.hr.overtime.delete')) ->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->applyAction(),
$this->cancelAction(), $this->cancelAction(),
]), ]),

View File

@ -66,10 +66,10 @@ class SignRepairController extends AdminController
$this->rowShowButton()->visible(Admin::user()->can('admin.hr.repairs.view')), $this->rowShowButton()->visible(Admin::user()->can('admin.hr.repairs.view')),
$this->rowEditTypeButton('drawer', 'xl') $this->rowEditTypeButton('drawer', 'xl')
->visible(Admin::user()->can('admin.hr.repairs.update')) ->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() $this->rowDeleteButton()
->visible(Admin::user()->can('admin.hr.repairs.delete')) ->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->applyAction(),
$this->cancelAction(), $this->cancelAction(),
]) ])

View File

@ -114,7 +114,7 @@ class WorkFlowService extends BaseService
*/ */
public function cancel(WorkflowCheck $check) 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->update([
'check_status' => CheckStatus::Cancel, 'check_status' => CheckStatus::Cancel,
]); ]);
@ -161,7 +161,7 @@ class WorkFlowService extends BaseService
*/ */
public function next(WorkflowCheck $check) 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) { if ($log) {
$log->update(['check_status' => CheckStatus::Processing]); $log->update(['check_status' => CheckStatus::Processing]);
// 申请人自动审核通过 // 申请人自动审核通过

View File

@ -10,11 +10,7 @@ enum CheckStatus: int
/** /**
* 待提审 * 待提审
*/ */
case None = 0; case None = 1;
/**
* 待审核
*/
case Pending = 1;
/** /**
* 审核中 * 审核中
*/ */
@ -36,7 +32,6 @@ enum CheckStatus: int
{ {
return [ return [
self::None->value => '待提审', self::None->value => '待提审',
self::Pending->value => '待审核',
self::Processing->value => '审核中', self::Processing->value => '审核中',
self::Success->value => '审核通过', self::Success->value => '审核通过',
self::Fail->value => '审核不通过', self::Fail->value => '审核不通过',

View File

@ -17,7 +17,7 @@ class WorkflowCheck extends Model
use HasDateTimeFormatter, Filterable; use HasDateTimeFormatter, Filterable;
protected $attributes = [ 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']; protected $fillable = ['subject_type', 'subject_id', 'subject_data', 'key', 'employee_id', 'check_status', 'checked_at', 'check_remarks'];

View File

@ -17,7 +17,7 @@ trait HasCheckActions
'user' => '${employee_id}', 'user' => '${employee_id}',
])) ]))
->confirmText(__('admin.confirm')) ->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.')}');
} }

View File

@ -9,7 +9,6 @@ use Illuminate\Support\Str;
trait HasCheckable trait HasCheckable
{ {
protected $check_key = '';
protected static function booted(): void protected static function booted(): void
{ {
static::created(function ($model) { 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__));
} }
/** /**

View File

@ -28,7 +28,7 @@ return new class extends Migration
$table->morphs('subject'); $table->morphs('subject');
$table->json('subject_data')->nullable('审核内容'); $table->json('subject_data')->nullable('审核内容');
$table->foreignId('employee_id')->nullable()->comment('申请人, employees.id'); $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->timestamp('checked_at')->nullable()->comment('审核通过时间');
$table->string('check_remarks')->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->unsignedBigInteger('check_user_id')->nullable()->comment('实际审核人(admin_users.id)');
$table->timestamp('checked_at')->nullable()->comment('审核时间'); $table->timestamp('checked_at')->nullable()->comment('审核时间');
$table->string('remarks')->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->unsignedInteger('sort')->default(0)->comment('顺序(asc)');
$table->timestamps(); $table->timestamps();