Files
Leantime/app/Domain/Bom/Controllers/Show.php
wangruiguo d647428529
Some checks failed
Security Audit / Composer Security Audit (push) Has been cancelled
Security Audit / NPM Security Audit (push) Has been cancelled
Security Audit / CodeQL Analysis (push) Has been cancelled
OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
2026-09-03 18:49:20 +08:00

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|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');
}
}