审批状态-待提审

main
Jing Li 2024-04-04 11:18:21 +08:00
parent d591be918b
commit fe3ea9d90b
9 changed files with 33 additions and 24 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::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() $this->rowDeleteButton()
->visible(Admin::user()->can('admin.hr.holiday.delete')) ->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->applyAction(),
$this->cancelAction(), $this->cancelAction(),
]), ]),
@ -144,4 +144,4 @@ class HolidayController extends AdminController
] ]
])->body([$detail, amisMake()->Divider(), $table]); ])->body([$detail, amisMake()->Divider(), $table]);
} }
} }

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::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() $this->rowDeleteButton()
->visible(Admin::user()->can('admin.hr.business.delete')) ->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->applyAction(),
$this->cancelAction(), $this->cancelAction(),
]), ]),
@ -131,4 +131,4 @@ class OfficalBusinessController extends AdminController
] ]
])->body([$detail, amisMake()->Divider(), $table]); ])->body([$detail, amisMake()->Divider(), $table]);
} }
} }

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::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() $this->rowDeleteButton()
->visible(Admin::user()->can('admin.hr.overtime.delete')) ->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->applyAction(),
$this->cancelAction(), $this->cancelAction(),
]), ]),
@ -133,4 +133,4 @@ class OvertimeController extends AdminController
] ]
])->body([$detail, amisMake()->Divider(), $table]); ])->body([$detail, amisMake()->Divider(), $table]);
} }
} }

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::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() $this->rowDeleteButton()
->visible(Admin::user()->can('admin.hr.repairs.delete')) ->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->applyAction(),
$this->cancelAction(), $this->cancelAction(),
]) ])

View File

@ -20,10 +20,10 @@ class WorkFlowService extends BaseService
* 发起审核申请 * 发起审核申请
* 1. 待审核 Model 实现 Checkable * 1. 待审核 Model 实现 Checkable
* 2. 生成全部的审核流程 * 2. 生成全部的审核流程
* *
* @param WorkflowCheck $check 待审核记录 * @param WorkflowCheck $check 待审核记录
* @param Employee $user 申请人 * @param Employee $user 申请人
* *
* @return boolean true: 成功, false: 失败, $this->getError(): 错误消息 * @return boolean true: 成功, false: 失败, $this->getError(): 错误消息
*/ */
public function apply(WorkflowCheck $check, Employee $user) public function apply(WorkflowCheck $check, Employee $user)
@ -110,11 +110,11 @@ class WorkFlowService extends BaseService
* 取消审核 * 取消审核
* 1. 删除未审核的流程 * 1. 删除未审核的流程
* 2. 更新申请记录的状态 * 2. 更新申请记录的状态
* *
*/ */
public function cancel(WorkflowCheck $check) 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->update([
'check_status' => CheckStatus::Cancel, 'check_status' => CheckStatus::Cancel,
]); ]);
@ -124,7 +124,7 @@ class WorkFlowService extends BaseService
/** /**
* 审核单个流程 * 审核单个流程
* *
* @param Employee $user 审核人 * @param Employee $user 审核人
* @param WorkflowLog $log 审核流水记录 * @param WorkflowLog $log 审核流水记录
* @param boolean $status 通过/不通过 * @param boolean $status 通过/不通过
@ -155,13 +155,13 @@ class WorkFlowService extends BaseService
/** /**
* 开启下一个审核流程 * 开启下一个审核流程
* *
* @param WorkflowCheck $check * @param WorkflowCheck $check
* @return boolean * @return boolean
*/ */
public function next(WorkflowCheck $check) 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) { if ($log) {
$log->update(['check_status' => CheckStatus::Processing]); $log->update(['check_status' => CheckStatus::Processing]);
// 申请人自动审核通过 // 申请人自动审核通过

View File

@ -7,10 +7,14 @@ namespace App\Enums;
*/ */
enum CheckStatus: int enum CheckStatus: int
{ {
/**
* 待提审
*/
case None = 0;
/** /**
* 待审核 * 待审核
*/ */
case None = 1; case Pending = 1;
/** /**
* 审核中 * 审核中
*/ */
@ -31,7 +35,8 @@ enum CheckStatus: int
public static function options(): array public static function options(): array
{ {
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

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

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::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.')}');
} }

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::None->value)->comment('审核状态'); $table->unsignedInteger('check_status')->default(CheckStatus::Pending->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::None->value)->comment('审核状态'); $table->unsignedTinyInteger('check_status')->default(CheckStatus::Pending->value)->comment('审核状态');
$table->unsignedInteger('sort')->default(0)->comment('顺序(asc)'); $table->unsignedInteger('sort')->default(0)->comment('顺序(asc)');
$table->timestamps(); $table->timestamps();