generated from liutk/owl-admin-base
admin agreement
parent
78065128c5
commit
c80be8475e
|
|
@ -57,6 +57,7 @@ class AgreementController extends AdminController
|
|||
amisMake()->TableColumn()->name('id')->label(__('agreement.id')),
|
||||
amisMake()->TableColumn()->name('name')->label(__('agreement.name')),
|
||||
amisMake()->TableColumn()->name('employee.name')->label(__('agreement.employee_id')),
|
||||
amisMake()->TableColumn()->name('store.title')->label(__('agreement.store_id')),
|
||||
amisMake()->TableColumn()->name('workflow.check_status')->label(__('workflow_log.check_status'))->set('type', 'mapping')->map(CheckStatus::options()),
|
||||
amisMake()->TableColumn()->name('workflow.check_name')->label(__('workflow.value')),
|
||||
amisMake()->TableColumn()->name('created_at')->label(__('agreement.created_at')),
|
||||
|
|
@ -105,6 +106,7 @@ class AgreementController extends AdminController
|
|||
$detail = amisMake()->Property()->items([
|
||||
['label' => __('agreement.name'), 'content' => '${name}'],
|
||||
['label' => __('agreement.employee_id'), 'content' => '${employee.name}'],
|
||||
['label' => __('agreement.store_id'), 'content' => '${store.title}'],
|
||||
['label' => __('agreement.created_at'), 'content' => '${created_at}'],
|
||||
['label' => __('agreement.remarks'), 'content' => '${remarks}', 'span' => 3],
|
||||
['label' => __('agreement.images'), 'content' => amisMake()->Images()->name('images')->enlargeAble(), 'span' => 3],
|
||||
|
|
|
|||
|
|
@ -3,16 +3,17 @@
|
|||
namespace App\Admin\Services;
|
||||
|
||||
use App\Admin\Filters\AgreementFilter;
|
||||
use App\Models\{Agreement, WorkflowCheck};
|
||||
use App\Models\{Agreement, WorkflowCheck, Employee};
|
||||
use Illuminate\Support\Facades\{Validator, Storage};
|
||||
use Illuminate\Support\Str;
|
||||
use Slowlyo\OwlAdmin\Admin;
|
||||
use App\Enums\CheckStatus;
|
||||
use Slowlyo\OwlAdmin\Models\AdminUser;
|
||||
use App\Exceptions\RuntimeException;
|
||||
|
||||
class AgreementService extends BaseService
|
||||
{
|
||||
protected array $withRelationships = ['employee', 'workflow'];
|
||||
protected array $withRelationships = ['employee', 'workflow', 'store'];
|
||||
|
||||
protected string $modelName = Agreement::class;
|
||||
|
||||
|
|
@ -49,7 +50,7 @@ class AgreementService extends BaseService
|
|||
if ($user->can('admin.agreement.update') && $model->canUpdate()) {
|
||||
array_push($actions, 'edit');
|
||||
}
|
||||
if ($user->can('admin.agreement.delete')) {
|
||||
if ($user->can('admin.agreement.delete') && $model->canUpdate()) {
|
||||
array_push($actions, 'delete');
|
||||
}
|
||||
if ($user->can('admin.agreement.download') && in_array($model->workflow->check_status, [CheckStatus::Success])) {
|
||||
|
|
@ -69,6 +70,10 @@ class AgreementService extends BaseService
|
|||
|
||||
public function resloveData($data, $model = null)
|
||||
{
|
||||
// 获取员工所在的门店
|
||||
if (! isset($data['store_id']) && isset($data['employee_id'])) {
|
||||
$data['store_id'] = Employee::where('id', $data['employee_id'])->value('store_id');
|
||||
}
|
||||
if (isset($data['images']) && $data['images']) {
|
||||
$images = [];
|
||||
foreach ($data['images'] as $value) {
|
||||
|
|
@ -121,8 +126,8 @@ class AgreementService extends BaseService
|
|||
{
|
||||
$list = $this->query()->with(['workflow'])->whereIn('id', explode(',', $ids))->get();
|
||||
foreach ($list as $item) {
|
||||
if (!$item->canUpdate()) {
|
||||
return $this->setError('审核中, 无法删除');
|
||||
if (!$model->canUpdate()) {
|
||||
throw new RuntimeException('无法删除');
|
||||
}
|
||||
$item->delete();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class AgreementController extends Controller
|
|||
|
||||
public function show($id)
|
||||
{
|
||||
$info = Agreement::with(['employee', 'workflow'])->findOrFail($id);
|
||||
$info = Agreement::with(['employee', 'workflow', 'store'])->findOrFail($id);
|
||||
|
||||
return AgreementResource::make($info);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class Agreement extends Model
|
|||
{
|
||||
use HasDateTimeFormatter, Filterable, HasCheckable;
|
||||
|
||||
protected $fillable = ['name', 'employee_id', 'images', 'remarks'];
|
||||
protected $fillable = ['name', 'employee_id', 'store_id', 'images', 'remarks'];
|
||||
|
||||
protected $casts = [
|
||||
'images' => 'json',
|
||||
|
|
@ -30,4 +30,9 @@ class Agreement extends Model
|
|||
{
|
||||
return $this->belongsTo(Employee::class, 'employee_id');
|
||||
}
|
||||
|
||||
public function store()
|
||||
{
|
||||
return $this->belongsTo(Store::class, 'employee_id');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ return new class extends Migration
|
|||
$table->id();
|
||||
$table->string('name')->comment('名称');
|
||||
$table->foreignId('employee_id')->comment('上传人');
|
||||
$table->foreignId('store_id')->comment('门店');
|
||||
$table->json('images')->nullable()->comment('图片列表');
|
||||
$table->string('remarks')->nullable()->comment('备注');
|
||||
$table->timestamps();
|
||||
|
|
|
|||
|
|
@ -9,4 +9,5 @@ return [
|
|||
'employee_id' => '上传人',
|
||||
'images' => '合同图片',
|
||||
'remarks' => '备注',
|
||||
'store_id' => '合同',
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue