baseCRUD() ->filterTogglable(false) ->columnsTogglable(false) ->headerToolbar([ $this->createButton(true), ]) ->filter($this->baseFilter()->actions([])->body([ amisMake()->SelectControl()->name('type_id')->label(__('user_score.type_id'))->options($this->getTypeOptions())->clearable()->size('md'), amisMake()->SelectControl()->name('cate_id')->label(__('user_score.cate_id'))->options($this->getCateOptions())->clearable()->searchable()->size('md'), amisMake()->SelectControl()->name('user_id')->label(__('user_score.user_id'))->options($this->getUserOptions())->clearable()->searchable()->size('md'), amisMake()->TextControl()->name('title')->label(__('user_score.title'))->clearable()->size('md'), amisMake()->SelectControl()->name('check_status')->label(__('user_score.check_status'))->options(CheckStatus::options())->clearable()->size('md'), amisMake()->DateRangeControl()->name('created_range')->label(__('user_score.created_at'))->clearable()->size('md'), amisMake()->Component()->setType('submit')->label(__('admin.search'))->level('primary'), ])) ->columns([ amisMake()->TableColumn()->name('id')->label(__('user_score.id')), amisMake()->TableColumn()->name('type.name')->label(__('user_score.type_id')), amisMake()->TableColumn()->name('cate.name')->label(__('user_score.cate_id')), amisMake()->TableColumn()->name('user.name')->label(__('user_score.user_id')), amisMake()->TableColumn()->name('title')->label(__('user_score.title')), amisMake()->TableColumn()->name('check_status_text')->label(__('user_score.check_status')), amisMake()->TableColumn()->name('score')->label(__('user_score.score')), amisMake()->TableColumn()->name('created_at')->label(__('user_score.created_at')), $this->rowActions([ $this->rowShowButton(), $this->rowEditButton(true), $this->rowDeleteButton(), ]), ]); return $this->baseList($crud); } public function form($edit): Form { return $this->baseForm()->title('')->body([ amisMake()->SelectControl()->name('type_id')->label(__('user_score.type_id'))->options($this->getTypeOptions())->required(), amisMake()->SelectControl()->name('user_id')->label(__('user_score.user_id'))->options($this->getUserOptions())->required(), amisMake()->TextControl()->name('title')->label(__('user_score.title'))->required(), amisMake()->TextareaControl()->name('content')->label(__('user_score.content')), amisMake()->ImageControl()->name('images')->label(__('user_score.images'))->multiple()->receiver(admin_url('upload_image') . '?full-url=1')->autoUpload(), amisMake()->FileControl()->name('file')->label(__('user_score.file'))->autoUpload() ]); } public function show($id) { if ($this->actionOfGetData()) { return $this->response()->success($this->service->getDetail($id)); } $info = UserScore::findOrFail($id); $detail = amisMake() ->Card() ->className('base-form') ->header(['title' => __('admin.detail')]) ->body($this->detail()) ->toolbar([ amisMake()->Button() ->visible($info->check_status != CheckStatus::Success) ->label('审核') ->level('danger') ->className('mr-1') ->actionType('dialog') ->dialog(amisMake()->Dialog()->title('审核')->body(amisMake()->Form()->api("/user-score/$id/check")->body([ amisMake()->RadiosControl()->name('check_status')->label(__('user_score.check_status'))->options([ CheckStatus::Success->value => CheckStatus::Success->text(), CheckStatus::Fail->value => CheckStatus::Fail->text(), ])->value(CheckStatus::Success->value)->required(), amisMake()->NumberControl()->name('score')->label(__('user_score.score')), amisMake()->TextControl()->name('check_remarks')->label(__('user_score.check_remarks')), ])->onEvent([ 'submitSucc' => [ 'actions' => [ ['actionType' => 'custom', 'script' => 'window.$owl.refreshAmisPage()',] ] ] ]))), $this->backButton(), ]); $page = $this->basePage()->body($detail); return $this->response()->success($page); } public function detail(): Form { return $this->baseDetail()->title('')->body([ amisMake()->TextControl()->name('id')->label(__('user_score.id'))->static(), amisMake()->TextControl()->name('type.name')->label(__('user_score.type_id'))->static(), amisMake()->TextControl()->name('cate.name')->label(__('user_score.cate_id'))->static(), amisMake()->TextControl()->name('user.name')->label(__('user_score.user_id'))->static(), amisMake()->TextControl()->name('title')->label(__('user_score.title'))->static(), amisMake()->TextareaControl()->name('content')->label(__('user_score.content'))->static(), amisMake()->TextControl()->name('images')->label(__('user_score.images'))->static()->staticSchema(amisMake()->Images()), amisMake()->TextControl()->name('file')->label(__('user_score.file'))->static()->staticSchema(amisMake()->Link()->body('${file}')->href('${file}')->blank()), amisMake()->TextControl()->name('check_status_text')->label(__('user_score.check_status'))->static(), amisMake()->TextControl()->name('check_user.name')->label(__('user_score.check_user_id'))->static(), amisMake()->TextControl()->name('check_remarks')->label(__('user_score.check_remarks'))->static(), amisMake()->TextControl()->name('check_at')->label(__('user_score.check_at'))->static(), amisMake()->TextControl()->name('score')->label(__('user_score.score'))->static(), amisMake()->TextControl()->name('created_at')->label(__('user_score.created_at'))->static(), ]); } public function check($id, Request $request) { $info = UserScore::findOrFail($id); try { $this->service->check($info, $request->all()); return $this->response()->success(); } catch (BaseException $e) { return $this->response()->fail($e->getMessage()); } } public function getTypeOptions() { if (!$this->typeOptions) { $this->typeOptions = UserScore::getTypeList()->map(fn($item) => ['value' => $item->id, 'label' => $item->name]); } return $this->typeOptions; } public function getUserOptions() { if (!$this->userOptions) { $this->userOptions = PartyUser::select(['id as value', 'name as label'])->get(); } return $this->userOptions; } public function getCateOptions() { if (!$this->cateOptions) { $this->cateOptions = PartyCate::select(['id as value', 'name as label'])->get(); } return $this->cateOptions; } }