<?php

namespace App\Admin\Controllers;

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

/**
 * 订单分销记录
 *
 * @property OrderDistRecordService $service
 */
class OrderDistRecordController extends AdminController
{
	protected string $serviceName = OrderDistRecordService::class;

	public function list()
	{
		$crud = $this->baseCRUD()
			->filterTogglable(false)
			->headerToolbar([
				$this->createButton('dialog'),
				...$this->baseHeaderToolBar()
			])
			->columns([
				amis()->TableColumn('id', 'ID')->sortable(),
				amis()->TableColumn('order_id', '订单编号'),
				amis()->TableColumn('object_id', '对象编号'),
				amis()->TableColumn('object_type', '对象类型'),
				amis()->TableColumn('dist_type', '分销类型'),
				amis()->TableColumn('amount', '分销金额'),
				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('order_id', '订单编号'),
			amis()->TextControl('object_id', '对象编号'),
			amis()->TextControl('object_type', '对象类型'),
			amis()->TextControl('dist_type', '分销类型'),
			amis()->TextControl('amount', '分销金额'),
		]);
	}

	public function detail()
	{
		return $this->baseDetail()->body([
			amis()->TextControl('id', 'ID')->static(),
			amis()->TextControl('order_id', '订单编号')->static(),
			amis()->TextControl('object_id', '对象编号')->static(),
			amis()->TextControl('object_type', '对象类型')->static(),
			amis()->TextControl('dist_type', '分销类型')->static(),
			amis()->TextControl('amount', '分销金额')->static(),
			amis()->TextControl('created_at', admin_trans('admin.created_at'))->static(),
			amis()->TextControl('updated_at', admin_trans('admin.updated_at'))->static(),
		]);
	}
}