<?php

namespace App\Admin\Controllers;

use App\Services\CoachLocationService;
use Slowlyo\OwlAdmin\Controllers\AdminController;

/**
 * 技师定位
 *
 * @property CoachLocationService $service
 */
class CoachLocationController extends AdminController
{
	protected string $serviceName = CoachLocationService::class;

	public function list()
	{
		$crud = $this->baseCRUD()
			->filterTogglable(false)
			->headerToolbar([
				$this->createButton('dialog'),
				...$this->baseHeaderToolBar()
			])
			->columns([
				amis()->TableColumn('id', 'ID')->sortable(),
				amis()->TableColumn('coach_id', '技师编号'),
				amis()->TableColumn('type', '地址类型'),
				amis()->TableColumn('latitude', '纬度'),
				amis()->TableColumn('longitude', '经度'),
				amis()->TableColumn('province', '省'),
				amis()->TableColumn('city', '市'),
				amis()->TableColumn('district', '区'),
				amis()->TableColumn('location', '定位地址'),
				amis()->TableColumn('area_code', '行政区划代码'),
				amis()->TableColumn('created_at', admin_trans('admin.created_at'))->type('datetime')->sortable(),
				amis()->TableColumn('updated_at', admin_trans('admin.updated_at'))->type('datetime')->sortable(),
				$this->rowActions('dialog')
			]);

		return $this->baseList($crud);
	}

	public function form($isEdit = false)
	{
		return $this->baseForm()->body([
			amis()->TextControl('coach_id', '技师编号'),
			amis()->TextControl('type', '地址类型'),
			amis()->TextControl('latitude', '纬度'),
			amis()->TextControl('longitude', '经度'),
			amis()->TextControl('province', '省'),
			amis()->TextControl('city', '市'),
			amis()->TextControl('district', '区'),
			amis()->TextControl('location', '定位地址'),
			amis()->TextControl('area_code', '行政区划代码'),
		]);
	}

	public function detail()
	{
		return $this->baseDetail()->body([
			amis()->TextControl('id', 'ID')->static(),
			amis()->TextControl('coach_id', '技师编号')->static(),
			amis()->TextControl('type', '地址类型')->static(),
			amis()->TextControl('latitude', '纬度')->static(),
			amis()->TextControl('longitude', '经度')->static(),
			amis()->TextControl('province', '省')->static(),
			amis()->TextControl('city', '市')->static(),
			amis()->TextControl('district', '区')->static(),
			amis()->TextControl('location', '定位地址')->static(),
			amis()->TextControl('area_code', '行政区划代码')->static(),
			amis()->TextControl('created_at', admin_trans('admin.created_at'))->static(),
			amis()->TextControl('updated_at', admin_trans('admin.updated_at'))->static(),
		]);
	}
}