61 lines
2.1 KiB
PHP
61 lines
2.1 KiB
PHP
<?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|tooling(query 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');
|
||
}
|
||
}
|