baseCRUD() ->tableLayout('fixed') ->headerToolbar([ $this->createTypeButton('drawer', 'xl')->visible($user->can('admin.store.stores.create')), ...$this->baseHeaderToolBar(), ]) ->bulkActions([]) ->filter($this->baseFilter()->body([ amis()->GroupControl()->mode('horizontal')->body([ amisMake()->TextControl()->name('title')->label(__('store.title'))->columnRatio(3)->clearable(), amisMake()->TreeSelectControl()->name('category_id')->label(__('store.category_id'))->columnRatio(3) ->source(admin_url('api/keywords/tree-list?parent_key=store_category')) ->labelField('name') ->valueField('key') ->onlyLeaf(true) ->clearable(), amisMake()->SelectControl()->name('business_id')->label(__('store.business_id'))->columnRatio(3) ->source(admin_url('api/keywords/tree-list?parent_key=store_business')) ->labelField('name') ->valueField('key') ->clearable(), ]), amisMake()->GroupControl()->mode('horizontal')->body([ amisMake()->SelectControl()->name('level_id')->label(__('store.level_id'))->columnRatio(3) ->source(admin_url('api/keywords/tree-list?parent_key=store_level')) ->labelField('name') ->valueField('key') ->clearable(), // amisMake()->InputCityControl()->name('region')->label(__('store.region'))->columnRatio(3) // ->allowDistrict(false) // ->extractValue(false) // ->clearable(), amisMake()->SelectControl()->name('business_status')->label(__('store.business_status'))->options(BusinessStatus::options())->columnRatio(3)->clearable(), ]), ])) ->columns([ amisMake()->TableColumn()->name('id')->label(__('store.id')), amisMake()->TableColumn()->name('title')->label(__('store.title')), amisMake()->TableColumn()->name('master.name')->label(__('store.master_id')), amisMake()->TableColumn()->name('category.name')->label(__('store.category_id')), amisMake()->TableColumn()->name('business.name')->label(__('store.business_id')), amisMake()->TableColumn()->name('level.name')->label(__('store.level_id')), amisMake()->TableColumn()->name('region')->label(__('store.region'))->set('type', 'tpl')->set('tpl', '${region.province}-${region.city}'), amisMake()->TableColumn()->name('business_status')->label(__('store.business_status'))->type('switch')->trueValue(BusinessStatus::Open)->falseValue(BusinessStatus::Close), amisMake()->TableColumn()->name('created_at')->label(__('store.created_at')), $this->rowActions([ $this->rowShowButton()->visible($user->can('admin.store.stores.view')), $this->rowEditTypeButton('drawer', 'xl')->visible($user->can('admin.store.stores.update')), $this->rowDeleteButton()->visible($user->can('admin.store.stores.delete')), ]), ]); return $this->baseList($crud); } public function form($edit): Form { return $this->baseForm()->title('')->body([ amisMake()->TextControl()->name('title')->label(__('store.title'))->required(), amisMake()->SelectControl()->name('master_id')->label(__('store.master_id')) ->source($edit ? admin_url('api/employees?_all=1&employee_status='.EmployeeStatus::Online->value) : admin_url('api/employees?_all=1&store_id=0&employee_status='.EmployeeStatus::Online->value)) ->labelField('name') ->valueField('id') ->searchable() ->required(), amisMake()->TreeSelectControl()->name('category_id')->label(__('store.category_id')) ->source(admin_url('api/keywords/tree-list?parent_key=store_category')) ->labelField('name') ->valueField('key') ->onlyLeaf(true) ->required(), amisMake()->SelectControl()->name('business_id')->label(__('store.business_id')) ->source(admin_url('api/keywords/tree-list?parent_key=store_business')) ->labelField('name') ->valueField('key') ->required(), amisMake()->SelectControl()->name('level_id')->label(__('store.level_id')) ->source(admin_url('api/keywords/tree-list?parent_key=store_level')) ->labelField('name') ->valueField('key') ->required(), amisMake()->InputCityControl()->name('region')->label(__('store.region'))->allowDistrict(false)->extractValue(false)->required(), amisMake()->LocationControl()->name('location')->label(__('store.location'))->ak('xDTLJ15QG6zt3f6VQcaNBfN8q3MsWBsE')->autoSelectCurrentLoc(), ]); } public function detail(): Form { $detail = amisMake()->Property()->items([ ['label' => __('store.title'), 'content' => '${title}'], ['label' => __('store.master_id'), 'content' => '${master.name}'], ['label' => __('store.business_status'), 'content' => amisMake()->Tag()->label('${business_status_text}')->color('${business_status_color}')], ['label' => __('store.category_id'), 'content' => '${category.name}'], ['label' => __('store.business_id'), 'content' => '${business.name}'], ['label' => __('store.level_id'), 'content' => '${level.name}'], ['label' => __('store.region'), 'content' => '${region.province}-${region.city}'], ['label' => __('store.address'), 'content' => '${address}', 'span' => 2], ['label' => __('store.profit_ratio'), 'content' => '${profit_ratio}%', 'span' => 3], ]); return $this->baseDetail()->title('')->body([$detail]); } public function shareList() { return $this->service->listQuery()->get(['id', 'title']); } }