<?php

namespace App\Admin\Controllers;

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

/**
 * 代理商项目设置
 *
 * @property AgentProjectConfigService $service
 */
class AgentProjectConfigController extends AdminController
{
	protected string $serviceName = AgentProjectConfigService::class;

	public function list()
	{
		$crud = $this->baseCRUD()
			->filterTogglable(false)
			->headerToolbar([
				$this->createButton('dialog'),
				...$this->baseHeaderToolBar()
			])
			->columns([
				amis()->TableColumn('id', 'ID')->sortable(),
				amis()->TableColumn('agent_id', '代理商编号'),
				amis()->TableColumn('base_price', '服务的起步价'),
				amis()->TableColumn('per_kilometer_fee', '每公里的费用'),
				amis()->TableColumn('state', '状态'),
				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('agent_id', '代理商编号'),
			amis()->TextControl('base_price', '服务的起步价'),
			amis()->TextControl('per_kilometer_fee', '每公里的费用'),
			amis()->TextControl('state', '状态'),
		]);
	}

	public function detail()
	{
		return $this->baseDetail()->body([
			amis()->TextControl('id', 'ID')->static(),
			amis()->TextControl('agent_id', '代理商编号')->static(),
			amis()->TextControl('base_price', '服务的起步价')->static(),
			amis()->TextControl('per_kilometer_fee', '每公里的费用')->static(),
			amis()->TextControl('state', '状态')->static(),
			amis()->TextControl('created_at', admin_trans('admin.created_at'))->static(),
			amis()->TextControl('updated_at', admin_trans('admin.updated_at'))->static(),
		]);
	}
}