<?php

namespace App\Admin\Controllers;

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

/**
 * 项目服务
 *
 * @property ProjectService $service
 */
class ProjectController extends AdminController
{
	protected string $serviceName = ProjectService::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', '项目分类编号'),
				amis()->TableColumn('cover', '项目封面'),
				amis()->TableColumn('title', '项目标题'),
				amis()->TableColumn('subtitle', '项目副标题'),
				amis()->TableColumn('price', '项目金额'),
				amis()->TableColumn('original_price', '项目原价'),
				amis()->TableColumn('sales', '虚拟销量')->sortable(),
				amis()->TableColumn('duration', '服务时长')->sortable(),
				amis()->TableColumn('project_desc', '项目介绍'),
				amis()->TableColumn('service_desc', '服务说明'),
				amis()->TableColumn('type', '服务类型'),
				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('cate_id', '项目分类编号'),
			amis()->TextControl('cover', '项目封面'),
			amis()->TextControl('title', '项目标题'),
			amis()->TextControl('subtitle', '项目副标题'),
			amis()->TextControl('price', '项目金额'),
			amis()->TextControl('original_price', '项目原价'),
			amis()->TextControl('sales', '虚拟销量'),
			amis()->TextControl('duration', '服务时长'),
			amis()->TextControl('project_desc', '项目介绍'),
			amis()->TextControl('service_desc', '服务说明'),
			amis()->TextControl('type', '服务类型'),
			amis()->TextControl('state', '状态'),
		]);
	}

	public function detail()
	{
		return $this->baseDetail()->body([
			amis()->TextControl('id', 'ID')->static(),
			amis()->TextControl('cate_id', '项目分类编号')->static(),
			amis()->TextControl('cover', '项目封面')->static(),
			amis()->TextControl('title', '项目标题')->static(),
			amis()->TextControl('subtitle', '项目副标题')->static(),
			amis()->TextControl('price', '项目金额')->static(),
			amis()->TextControl('original_price', '项目原价')->static(),
			amis()->TextControl('sales', '虚拟销量')->static(),
			amis()->TextControl('duration', '服务时长')->static(),
			amis()->TextControl('project_desc', '项目介绍')->static(),
			amis()->TextControl('service_desc', '服务说明')->static(),
			amis()->TextControl('type', '服务类型')->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(),
		]);
	}
}