<?php

namespace App\Admin\Controllers;

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

/**
 * 代理商服务项目
 *
 * @property AgentProjectService $service
 */
class AgentProjectController extends AdminController
{
	protected string $serviceName = AgentProjectService::class;

	public function list()
	{
		$crud = $this->baseCRUD()
			->filterTogglable(false)
			->headerToolbar([
				$this->createButton('dialog'),
				...$this->baseHeaderToolBar()
			])
			->columns([
				amis()->TableColumn('id', 'ID')->sortable(),
				amis()->TableColumn('cate_id', '代理商项目分类ID'),
				amis()->TableColumn('project_id', '项目ID'),
				amis()->TableColumn('price', '项目金额'),
				amis()->TableColumn('duration', '服务时长(分钟)')->sortable(),
				amis()->TableColumn('distance', '接单距离(米)')->sortable(),
				amis()->TableColumn('state', '状态(enable:启用 disable:禁用)'),
				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('cate_id', '代理商项目分类ID'),
			amis()->TextControl('project_id', '项目ID'),
			amis()->TextControl('price', '项目金额'),
			amis()->TextControl('duration', '服务时长(分钟)'),
			amis()->TextControl('distance', '接单距离(米)'),
			amis()->TextControl('state', '状态(enable:启用 disable:禁用)'),
		]);
	}

	public function detail()
	{
		return $this->baseDetail()->body([
			amis()->TextControl('id', 'ID')->static(),
			amis()->TextControl('cate_id', '代理商项目分类ID')->static(),
			amis()->TextControl('project_id', '项目ID')->static(),
			amis()->TextControl('price', '项目金额')->static(),
			amis()->TextControl('duration', '服务时长(分钟)')->static(),
			amis()->TextControl('distance', '接单距离(米)')->static(),
			amis()->TextControl('state', '状态(enable:启用 disable:禁用)')->static(),
			amis()->TextControl('created_at', admin_trans('admin.created_at'))->static(),
			amis()->TextControl('updated_at', admin_trans('admin.updated_at'))->static(),
		]);
	}
}