Files
Leantime/app/Domain/Bom/Controllers/Show.php

61 lines
2.1 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace Leantime\Domain\Bom\Controllers;
use Leantime\Core\Auth\Permissions\RequiresPermission;
use Leantime\Core\Controller\Controller;
use Leantime\Domain\Bom\Permissions\BomPermissions;
use Leantime\Domain\Bom\Services\Bom as BomService;
use Symfony\Component\HttpFoundation\Response;
/**
* BOM 页面(项目清单"目标及里程碑"下方入口)。
* 约定路由GET /bom/show 列表
* GET /bom/show/{id} 详情(可编辑表格)
*/
class Show extends Controller
{
private BomService $bomService;
public function init(BomService $bomService): void
{
$this->bomService = $bomService;
}
#[RequiresPermission(BomPermissions::VIEW)]
public function get(array $params): Response
{
$projectId = (int) session('currentProject');
$bomId = isset($params['id']) ? (int) $params['id'] : 0;
// ?type=bom|process|toolingquery string经 incomingRequest 读取)
$type = (string) $this->incomingRequest->query('type', 'bom');
if (! in_array($type, ['bom', 'process', 'tooling'], true)) {
$type = 'bom';
}
if ($bomId > 0) {
$detail = $this->bomService->getBomDetail($bomId);
if ($detail === false) {
$this->tpl->setNotification($this->language->__('notification.bom_not_found', 'BOM 不存在'), 'error');
return $this->tpl->display('bom.show', 'app', 404);
}
$this->tpl->assign('detail', $detail);
$this->tpl->assign('fixedColumns', BomService::FIXED_COLUMNS);
$this->tpl->assign('projectId', $projectId);
return $this->tpl->display('bom.detail');
}
// 三类主数据bom/process/tooling共用列表type 参数切换
$masters = $this->bomService->getMasters($type, $projectId);
$this->tpl->assign('boms', $masters);
$this->tpl->assign('type', $type);
$this->tpl->assign('projectId', $projectId);
$this->tpl->assign('fixedColumns', BomService::FIXED_COLUMNS);
return $this->tpl->display('bom.show');
}
}