Files
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

75 lines
2.7 KiB
PHP
Raw Permalink 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 Leantime\Domain\Bom\Services\MasterRef as MasterRefService;
use Symfony\Component\HttpFoundation\Response;
/**
* 项目引用视图:项目里查看已引用的全局主数据(BOM/工艺文件/工具清单),
* 并叠加项目级追加列(日期/库存/采购数量等),追加列只存引用层,不回写全局。
*
* 路由约定(Frontcontroller 默认 /module/action):
* GET /bom/refs 项目已引用的主数据列表
* GET /bom/refs/{id} 单个引用视图(主数据 + 项目级追加列)
*/
class Refs extends Controller
{
private BomService $bomService;
private MasterRefService $masterRefService;
public function init(BomService $bomService, MasterRefService $masterRefService): void
{
$this->bomService = $bomService;
$this->masterRefService = $masterRefService;
}
#[RequiresPermission(BomPermissions::VIEW)]
public function get(array $params): Response
{
$projectId = (int) session('currentProject');
$refId = isset($params['id']) ? (int) $params['id'] : 0;
// 单个引用视图
if ($refId > 0) {
$refDetail = $this->masterRefService->getRefDetail($refId);
if ($refDetail === false) {
$this->tpl->setNotification($this->language->__('notification.bom_not_found', '引用不存在'), 'error');
return $this->tpl->display('bom.refs', 'app', 404);
}
$master = $this->bomService->getBomDetail((int) $refDetail['ref']['masterId']);
$this->tpl->assign('ref', $refDetail['ref']);
$this->tpl->assign('refColumns', $refDetail['columns']);
$this->tpl->assign('refValues', $refDetail['values']);
$this->tpl->assign('master', $master);
$this->tpl->assign('fixedColumns', BomService::FIXED_COLUMNS);
$this->tpl->assign('projectId', $projectId);
return $this->tpl->display('bom.refDetail');
}
// 项目已引用列表
$refs = $this->masterRefService->getRefs($projectId);
$list = [];
foreach ($refs as $ref) {
$master = $this->bomService->getBom((int) $ref['masterId']);
if ($master !== false) {
$ref['master'] = $master;
$list[] = $ref;
}
}
$this->tpl->assign('refs', $list);
$this->tpl->assign('projectId', $projectId);
return $this->tpl->display('bom.refs');
}
}