admin agreement

main
panliang 2024-05-03 21:36:33 +08:00
parent f99dede28c
commit 55379ca25a
4 changed files with 5 additions and 6 deletions

View File

@ -50,7 +50,7 @@ class AgreementService extends BaseService
if ($user->can('admin.agreement.update') && $model->canUpdate()) { if ($user->can('admin.agreement.update') && $model->canUpdate()) {
array_push($actions, 'edit'); array_push($actions, 'edit');
} }
if ($user->can('admin.agreement.delete') && $model->canUpdate()) { if ($user->can('admin.agreement.delete')) {
array_push($actions, 'delete'); array_push($actions, 'delete');
} }
if ($user->can('admin.agreement.download') && in_array($model->workflow->check_status, [CheckStatus::Success])) { if ($user->can('admin.agreement.download') && in_array($model->workflow->check_status, [CheckStatus::Success])) {
@ -126,9 +126,6 @@ class AgreementService extends BaseService
{ {
$list = $this->query()->with(['workflow'])->whereIn('id', explode(',', $ids))->get(); $list = $this->query()->with(['workflow'])->whereIn('id', explode(',', $ids))->get();
foreach ($list as $item) { foreach ($list as $item) {
if (!$model->canUpdate()) {
throw new RuntimeException('无法删除');
}
$item->delete(); $item->delete();
} }
return true; return true;

View File

@ -22,6 +22,9 @@ class AgreementResource extends JsonResource
'employee_id' => $this->employee_id, 'employee_id' => $this->employee_id,
'employee' => EmployeeResource::make($this->whenLoaded('employee')), 'employee' => EmployeeResource::make($this->whenLoaded('employee')),
'store_id' => $this->store_id,
'store' => StoreResource::make($this->whenLoaded('store')),
'workflow_check' => WorkflowCheckResource::make($this->whenLoaded('workflow')), 'workflow_check' => WorkflowCheckResource::make($this->whenLoaded('workflow')),
'created_at' => $this->created_at->timestamp, 'created_at' => $this->created_at->timestamp,

View File

@ -35,7 +35,6 @@ class WorkflowCheckResource extends JsonResource
{ {
$model = Relation::getMorphedModel($type); $model = Relation::getMorphedModel($type);
$class = match ($model) { $class = match ($model) {
'agreements' => AgreementResource::class,
default => 'App\\Http\\Resources\\'.class_basename($model).'Resource', default => 'App\\Http\\Resources\\'.class_basename($model).'Resource',
}; };

View File

@ -33,6 +33,6 @@ class Agreement extends Model
public function store() public function store()
{ {
return $this->belongsTo(Store::class, 'employee_id'); return $this->belongsTo(Store::class, 'store_id');
} }
} }