feat: add BOM template import and simplify task navigation
This commit is contained in:
1 parent
6c817de359
commit
ae7e0e6a1b
9 files changed
+287
-12
No files matched your search
@@ -15,10 +15,12 @@ V1.1.0 沿用原有任务视图和料号规则编辑,增加按工程拆分的
|
||||
|
||||
## 可选 Excel 操作
|
||||
|
||||
无需导出也能完成全部编辑。需要在 Excel 中操作时,可导出采集后的 `.xlsx`,修改替换开关、新料号、自定义 Value 开关及文本、同步 NC,再导入。
|
||||
无需导出也能完成全部编辑。需要在 Excel 中操作时,可导出完整位号计划,或点击“BOM 模板”生成更适合物料工程师编辑的 BOM 表。BOM 一行可以填写多个位号(逗号、分号、空格或顿号分隔),并填写旧料号、新料号、替换开关、Value 和同步 NC。
|
||||
|
||||
导入先显示到表格中预览,点击“保存位号计划”后才生效。工程、图页、UID、位号、旧料号及原 Value 是身份校验字段,应保持原样。无法添加未采集器件、重复器件或跨工程目标;不接受公式。布尔选项可使用 TRUE/FALSE 或 是/否。
|
||||
|
||||
BOM 导入会把未列出的采集位号保留为“不替换”,并要求每个填写的位号在当前工程清单中唯一匹配;同名位号跨图页时应填写图页或 UID。导入失败不会改变已保存计划。
|
||||
|
||||
“同步 NC”默认勾选,可以按行关闭;仅按原规则识别独立 `/NC` 标记。Value 复制选项和每行自定义 Value 延续原工具的处理方式。替换计划不允许旧、新料号相同,也不允许同批链式或循环替换。
|
||||
|
||||
## 保存、恢复及旧任务
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
"""Safe BOM-template import for one-to-many RefDes replacement plans."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from openpyxl import Workbook, load_workbook
|
||||
from openpyxl.styles import Font, PatternFill
|
||||
from openpyxl.worksheet.datavalidation import DataValidation
|
||||
|
||||
from .errors import TaskCenterError
|
||||
from .target_plan import TargetPlanRow, compile_target_rules
|
||||
|
||||
|
||||
BOM_HEADERS = ('old_part_number', 'new_part_number', 'refdes', 'schematic_name',
|
||||
'sheet_number', 'uid', 'enabled', 'custom_value', 'sync_nc')
|
||||
_REFDES_SPLIT = re.compile(r'[,,;;、\s]+')
|
||||
_ALIASES = {
|
||||
'旧料号': 'old_part_number', '旧物料编码': 'old_part_number', 'old_part': 'old_part_number',
|
||||
'新料号': 'new_part_number', '新物料编码': 'new_part_number', 'new_part': 'new_part_number',
|
||||
'位号': 'refdes', '参考标号': 'refdes', 'refdes': 'refdes', 'reference_designator': 'refdes',
|
||||
'原理图': 'schematic_name', 'schematic': 'schematic_name', '图页': 'sheet_number', 'sheet': 'sheet_number',
|
||||
'uid': 'uid', '替换': 'enabled', '是否替换': 'enabled', 'enabled': 'enabled',
|
||||
'新value': 'custom_value', '自定义value': 'custom_value', 'custom_value': 'custom_value',
|
||||
'同步nc': 'sync_nc', '同步_nc': 'sync_nc', 'sync_nc': 'sync_nc',
|
||||
}
|
||||
|
||||
|
||||
def write_bom_template(path: Path, records=()) -> Path:
|
||||
workbook = Workbook()
|
||||
sheet = workbook.active
|
||||
sheet.title = 'BOM Replacement'
|
||||
sheet.append(BOM_HEADERS)
|
||||
for record in records:
|
||||
sheet.append(tuple(record.get(header, '') for header in BOM_HEADERS))
|
||||
for cell in sheet[1]:
|
||||
cell.font = Font(bold=True, color='FFFFFF')
|
||||
cell.fill = PatternFill('solid', fgColor='1D3557')
|
||||
sheet.freeze_panes = 'A2'
|
||||
sheet.auto_filter.ref = sheet.dimensions
|
||||
for column in ('G', 'I'):
|
||||
validation = DataValidation(type='list', formula1='"TRUE,FALSE"', allow_blank=False)
|
||||
sheet.add_data_validation(validation)
|
||||
validation.add(f'{column}2:{column}{max(2, sheet.max_row + 500)}')
|
||||
for column, width in {'A': 22, 'B': 22, 'C': 28, 'D': 18, 'E': 14,
|
||||
'F': 28, 'G': 12, 'H': 24, 'I': 12}.items():
|
||||
sheet.column_dimensions[column].width = width
|
||||
path = Path(path)
|
||||
workbook.save(path)
|
||||
return path
|
||||
|
||||
|
||||
def read_bom_plan(store, task_id: str, path: Path) -> tuple[TargetPlanRow, ...]:
|
||||
baseline = store.list_target_plan(task_id)
|
||||
if not baseline:
|
||||
raise TaskCenterError('target_inventory', 'collect component inventory before importing a BOM')
|
||||
by_key = {row.target.key: row for row in baseline}
|
||||
by_identity: dict[tuple[str, str], list[TargetPlanRow]] = {}
|
||||
for row in baseline:
|
||||
by_identity.setdefault((row.target.old_part_number.casefold(), row.target.refdes.casefold()), []).append(row)
|
||||
matched: dict[tuple[str, str, str, str], TargetPlanRow] = {}
|
||||
workbook = None
|
||||
try:
|
||||
workbook = load_workbook(Path(path), read_only=True, data_only=False)
|
||||
if len(workbook.worksheets) != 1:
|
||||
raise ValueError('BOM 工作簿只能包含一个工作表')
|
||||
sheet = workbook.active
|
||||
records = list(sheet.iter_rows(values_only=False))
|
||||
if not records:
|
||||
raise ValueError('BOM 工作表为空')
|
||||
headers = _normal_headers(tuple(cell.value for cell in records[0]))
|
||||
required = {'old_part_number', 'new_part_number', 'refdes'}
|
||||
if not required <= set(headers):
|
||||
raise ValueError('BOM 必须包含旧料号、新料号和位号列')
|
||||
positions = {name: index for index, name in enumerate(headers) if name}
|
||||
for cells in records[1:]:
|
||||
values = tuple(cell.value for cell in cells)
|
||||
if not any(value not in (None, '') for value in values):
|
||||
continue
|
||||
if any(cell.data_type == 'f' for cell in cells):
|
||||
raise ValueError('BOM 不接受公式,请填写实际值')
|
||||
old = _text(values, positions, 'old_part_number')
|
||||
new = _text(values, positions, 'new_part_number')
|
||||
refs = _split_refdes(_text(values, positions, 'refdes'))
|
||||
if not old or not new or not refs:
|
||||
raise ValueError('BOM 行的旧料号、新料号和位号不能为空')
|
||||
enabled = _bool(_value(values, positions, 'enabled', True))
|
||||
sync_nc = _bool(_value(values, positions, 'sync_nc', True))
|
||||
custom = _text(values, positions, 'custom_value')
|
||||
schematic = _text(values, positions, 'schematic_name')
|
||||
sheet_number = _text(values, positions, 'sheet_number')
|
||||
uid = _text(values, positions, 'uid')
|
||||
for refdes in refs:
|
||||
candidates = [row for row in by_identity.get((old.casefold(), refdes.casefold()), ())
|
||||
if (not schematic or row.target.schematic_name.casefold() == schematic.casefold())
|
||||
and (not sheet_number or row.target.sheet_number.casefold() == sheet_number.casefold())
|
||||
and (not uid or row.target.uid == uid)]
|
||||
if len(candidates) != 1:
|
||||
raise ValueError(f'位号 {refdes} 无法唯一匹配当前采集清单')
|
||||
target = candidates[0].target
|
||||
if target.key in matched:
|
||||
raise ValueError(f'位号 {refdes} 在 BOM 中重复')
|
||||
matched[target.key] = TargetPlanRow(target, enabled, new, bool(custom), custom, sync_nc)
|
||||
result = tuple(matched.get(key, TargetPlanRow(row.target)) for key, row in by_key.items())
|
||||
compile_target_rules(result)
|
||||
return result
|
||||
except (OSError, ValueError, TypeError, KeyError) as error:
|
||||
if isinstance(error, TaskCenterError):
|
||||
raise
|
||||
raise TaskCenterError('bom_import', str(error)) from error
|
||||
finally:
|
||||
if workbook is not None:
|
||||
workbook.close()
|
||||
|
||||
|
||||
def _normal_headers(values):
|
||||
result = []
|
||||
for value in values:
|
||||
raw = str(value or '').strip().casefold().replace(' ', '').replace('-', '_')
|
||||
result.append(raw if raw in BOM_HEADERS else _ALIASES.get(raw, ''))
|
||||
return tuple(result)
|
||||
|
||||
|
||||
def _value(values, positions, name, default=''):
|
||||
index = positions.get(name)
|
||||
if index is None or index >= len(values) or values[index] in (None, ''):
|
||||
return default
|
||||
return values[index]
|
||||
|
||||
|
||||
def _text(values, positions, name):
|
||||
value = _value(values, positions, name, '')
|
||||
return '' if value is None else str(value).strip()
|
||||
|
||||
|
||||
def _split_refdes(value):
|
||||
return tuple(item for item in _REFDES_SPLIT.split(value.strip()) if item)
|
||||
|
||||
|
||||
def _bool(value):
|
||||
if type(value) is bool:
|
||||
return value
|
||||
if isinstance(value, (int, float)) and value in (0, 1):
|
||||
return bool(value)
|
||||
if isinstance(value, str) and value.strip().casefold() in {'true', '是', '1', 'yes', 'y'}:
|
||||
return True
|
||||
if isinstance(value, str) and value.strip().casefold() in {'false', '否', '0', 'no', 'n', ''}:
|
||||
return False
|
||||
raise ValueError('BOM 布尔字段只能填写 TRUE/FALSE 或 是/否')
|
||||
@@ -21,6 +21,7 @@ from .target_plan import compile_target_rules
|
||||
from .project_tasks import create_project_tasks as _create_project_tasks
|
||||
from .inventory import collect_target_inventory
|
||||
from .spreadsheet_plan import export_target_plan as _export_target_plan, import_target_plan as _import_target_plan
|
||||
from .bom_plan import read_bom_plan as _read_bom_plan, write_bom_template as _write_bom_template
|
||||
from .project_context import ProjectTaskContext
|
||||
|
||||
|
||||
@@ -127,6 +128,27 @@ class TaskCenterService:
|
||||
return self._operation("export_target_plan", task_id,
|
||||
lambda: _export_target_plan(self._store, task_id, path))
|
||||
|
||||
def preview_bom_plan(self, task_id: str, path: Path) -> tuple:
|
||||
return self._operation("preview_bom_plan", task_id,
|
||||
lambda: _read_bom_plan(self._store, task_id, path))
|
||||
|
||||
def export_bom_template(self, task_id: str, path: Path) -> Path:
|
||||
def export():
|
||||
rows = self._store.list_target_plan(task_id)
|
||||
records = ({
|
||||
'old_part_number': row.target.old_part_number,
|
||||
'new_part_number': row.new_part_number,
|
||||
'refdes': row.target.refdes,
|
||||
'schematic_name': row.target.schematic_name,
|
||||
'sheet_number': row.target.sheet_number,
|
||||
'uid': row.target.uid,
|
||||
'enabled': row.enabled,
|
||||
'custom_value': row.custom_value if row.custom_value_enabled else '',
|
||||
'sync_nc': row.sync_nc,
|
||||
} for row in rows)
|
||||
return _write_bom_template(path, records)
|
||||
return self._operation("export_bom_template", task_id, export)
|
||||
|
||||
def for_project_task(self, task_id: str) -> "TaskCenterService":
|
||||
"""Return a facade whose evidence root is isolated to this task."""
|
||||
self._store.get_task(task_id)
|
||||
|
||||
@@ -146,10 +146,9 @@ class TrialTaskCenterWindow(QMainWindow):
|
||||
def _refresh_task_list(self):
|
||||
try:
|
||||
self._tasks = self.service.tasks()
|
||||
choice = self.task_list.filter.currentText()
|
||||
wanted = {'已完成': TaskStatus.COMPLETED, '已删除': TaskStatus.DELETED}.get(choice)
|
||||
tasks = tuple(t for t in self._tasks if t.status is wanted) if wanted else tuple(
|
||||
t for t in self._tasks if t.status not in {TaskStatus.COMPLETED, TaskStatus.DELETED})
|
||||
order = {TaskStatus.DELETED: 3, TaskStatus.COMPLETED: 2}
|
||||
tasks = tuple(sorted(self._tasks, key=lambda task: (order.get(task.status, 1),
|
||||
-task.updated_utc.timestamp(), task.name.casefold())))
|
||||
self.task_list.populate(tasks)
|
||||
except Exception as error:
|
||||
self._show_error(error)
|
||||
|
||||
@@ -127,8 +127,10 @@ class ProjectPlanPanel(QWidget):
|
||||
self.table = TargetTable(self)
|
||||
self.collect_button = QPushButton('采集所有匹配位号', objectName='collectTargetInventory')
|
||||
self.save_button = QPushButton('保存位号计划', objectName='saveTargetPlan')
|
||||
self.import_button = QPushButton('导入 Excel', objectName='importTargetPlan')
|
||||
self.export_button = QPushButton('导出 Excel', objectName='exportTargetPlan')
|
||||
self.import_button = QPushButton('导入位号计划', objectName='importTargetPlan')
|
||||
self.export_button = QPushButton('导出位号计划', objectName='exportTargetPlan')
|
||||
self.import_bom_button = QPushButton('导入 BOM', objectName='importBomPlan')
|
||||
self.export_bom_button = QPushButton('BOM 模板', objectName='exportBomTemplate')
|
||||
self.select_all = QPushButton('全部替换')
|
||||
self.select_none = QPushButton('全部保留')
|
||||
self.bulk_part = QLineEdit(objectName='bulkTargetPart')
|
||||
@@ -143,7 +145,8 @@ class ProjectPlanPanel(QWidget):
|
||||
self.summary = QLabel('先添加旧、新料号规则,再采集位号;可直接在这里编辑,也可选用 Excel。')
|
||||
self.summary.setWordWrap(True)
|
||||
actions = QHBoxLayout()
|
||||
for button in (self.collect_button, self.save_button, self.import_button, self.export_button):
|
||||
for button in (self.collect_button, self.save_button, self.import_button, self.export_button,
|
||||
self.import_bom_button, self.export_bom_button):
|
||||
actions.addWidget(button)
|
||||
actions.addStretch()
|
||||
selection = QHBoxLayout()
|
||||
@@ -166,6 +169,8 @@ class ProjectPlanPanel(QWidget):
|
||||
self.save_button.clicked.connect(self.save)
|
||||
self.import_button.clicked.connect(self.import_excel)
|
||||
self.export_button.clicked.connect(self.export_excel)
|
||||
self.import_bom_button.clicked.connect(self.import_bom)
|
||||
self.export_bom_button.clicked.connect(self.export_bom)
|
||||
self.select_all.clicked.connect(lambda: self.table.select_all_targets(True))
|
||||
self.select_none.clicked.connect(lambda: self.table.select_all_targets(False))
|
||||
self.bulk_apply.clicked.connect(lambda: self.table.apply_to_selected(self.bulk_part.text()))
|
||||
@@ -226,11 +231,13 @@ class ProjectPlanPanel(QWidget):
|
||||
def set_plan_editable(self, editable):
|
||||
self._editable = bool(editable)
|
||||
self.table.set_plan_editable(self._editable)
|
||||
for widget in (self.collect_button, self.save_button, self.import_button,
|
||||
for widget in (self.collect_button, self.save_button, self.import_button, self.import_bom_button,
|
||||
self.select_all, self.select_none, self.bulk_part, self.bulk_apply):
|
||||
widget.setEnabled(self._editable and bool(self.task_id))
|
||||
self.export_button.setEnabled(self._editable and bool(self.task_id)
|
||||
and bool(self.table.rows()) and not self.table.dirty)
|
||||
self.export_bom_button.setEnabled(self._editable and bool(self.task_id)
|
||||
and bool(self.table.rows()) and not self.table.dirty)
|
||||
|
||||
def _dispatch(self, operation, callback, button):
|
||||
self.window._run_async(operation, callback, button, expected_task_id=self.task_id)
|
||||
@@ -284,3 +291,27 @@ class ProjectPlanPanel(QWidget):
|
||||
task_id = self.task_id
|
||||
self._dispatch(lambda: self.window.service.export_target_plan(task_id, Path(path)),
|
||||
lambda result: self.summary.setText(f'已导出:{result}'), self.export_button)
|
||||
|
||||
def import_bom(self):
|
||||
if not self.task_id:
|
||||
return
|
||||
path, _ = QFileDialog.getOpenFileName(self, '导入 BOM 模板', '', 'BOM Excel (*.xlsx)')
|
||||
if path:
|
||||
task_id = self.task_id
|
||||
self._dispatch(lambda: self.window.service.preview_bom_plan(task_id, Path(path)),
|
||||
self._preview_bom, self.import_bom_button)
|
||||
|
||||
def _preview_bom(self, rows):
|
||||
self.table.populate(rows)
|
||||
self.table.dirty = True
|
||||
self.summary.setText(f'BOM 已匹配 {sum(row.enabled for row in rows)} 个位号;请检查预览后点击保存位号计划。')
|
||||
self._changed()
|
||||
|
||||
def export_bom(self):
|
||||
if not self.task_id or self.table.dirty:
|
||||
return
|
||||
path, _ = QFileDialog.getSaveFileName(self, '导出 BOM 模板', '替换BOM模板.xlsx', 'Excel (*.xlsx)')
|
||||
if path:
|
||||
task_id = self.task_id
|
||||
self._dispatch(lambda: self.window.service.export_bom_template(task_id, Path(path)),
|
||||
lambda result: self.summary.setText(f'已导出 BOM 模板:{result}'), self.export_bom_button)
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
APP_STYLESHEET = """
|
||||
QWidget { background: #f4f6f8; color: #17212b; font-size: 13px; }
|
||||
QLabel#taskSectionTitle { color: #5d6873; font-size: 12px; font-weight: 600; padding: 2px 4px; }
|
||||
QWidget#taskNavigation, QWidget#workspace, QTextEdit { background: #ffffff; border: 1px solid #cbd5df; }
|
||||
QPushButton, QComboBox, QLineEdit, QTableWidget { border: 1px solid #aebdca; border-radius: 4px; background: #ffffff; }
|
||||
QPushButton { min-height: 30px; padding: 2px 9px; }
|
||||
@@ -17,7 +18,7 @@ QLineEdit, QComboBox { min-height: 28px; padding: 0 6px; }
|
||||
QTableWidget { gridline-color: #d8e0e7; selection-background-color: #dbeeff; selection-color: #17212b; }
|
||||
QHeaderView::section { background: #e8edf1; border: 0; border-bottom: 1px solid #cbd5df; padding: 5px; font-weight: 600; }
|
||||
QListWidget { background: #ffffff; border: 1px solid #cbd5df; }
|
||||
QListWidget::item { padding: 6px; }
|
||||
QListWidget::item { padding: 8px 10px; border-radius: 6px; margin: 2px 0; }
|
||||
QListWidget::item:selected { background: #dbeeff; color: #17212b; }
|
||||
QLabel#operatorBand { background: #fff8d9; border: 1px solid #dfbf4b; padding: 7px; color: #5a4600; }
|
||||
QLabel#operatorBand[state="success"] { background: #edf8f1; border-color: #71a982; color: #245b35; }
|
||||
|
||||
@@ -6,7 +6,7 @@ from collections.abc import Callable
|
||||
from typing import Iterable
|
||||
|
||||
from PySide6.QtCore import Qt, QSignalBlocker
|
||||
from PySide6.QtWidgets import QComboBox, QGridLayout, QListWidget, QListWidgetItem, QPushButton, QVBoxLayout, QWidget
|
||||
from PySide6.QtWidgets import QComboBox, QGridLayout, QLabel, QListWidget, QListWidgetItem, QPushButton, QVBoxLayout, QWidget
|
||||
|
||||
|
||||
class TaskList(QWidget):
|
||||
@@ -15,6 +15,8 @@ class TaskList(QWidget):
|
||||
self.setObjectName("taskNavigation")
|
||||
self.filter = QComboBox(objectName="taskFilter")
|
||||
self.filter.addItems(("进行中", "已完成", "已删除"))
|
||||
self.filter.setVisible(False)
|
||||
self.filter.setMaximumHeight(0)
|
||||
self.list = QListWidget(objectName="taskList")
|
||||
self.new_button = QPushButton("新建", objectName="newTaskButton")
|
||||
self.edit_button = QPushButton("编辑", objectName="editTaskButton")
|
||||
@@ -33,7 +35,7 @@ class TaskList(QWidget):
|
||||
actions.addWidget(self.queue_button, 3, 0, 1, 2)
|
||||
layout = QVBoxLayout(self)
|
||||
layout.setContentsMargins(8, 8, 8, 8)
|
||||
layout.addWidget(self.filter)
|
||||
layout.addWidget(QLabel('任务', objectName='taskSectionTitle'))
|
||||
layout.addWidget(self.list, 1)
|
||||
layout.addLayout(actions)
|
||||
self.list.itemSelectionChanged.connect(lambda: on_open(self.current_task_id() or ""))
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
from openpyxl import Workbook
|
||||
|
||||
from dx_productivity.trial_task_center.bom_plan import BOM_HEADERS, read_bom_plan, write_bom_template
|
||||
from dx_productivity.trial_task_center.errors import TaskCenterError
|
||||
from dx_productivity.trial_task_center.store import TaskStore
|
||||
from dx_productivity.trial_task_center.target_plan import ComponentTarget
|
||||
|
||||
|
||||
def setup_store(tmp_path):
|
||||
store = TaskStore(tmp_path / 'tasks.db')
|
||||
task = store.create_task('board')
|
||||
path = tmp_path / 'board.prj'
|
||||
store.sync_projects(task.task_id, tmp_path, (path,))
|
||||
targets = tuple(ComponentTarget(path, 'MAIN', '1', uid, ref, 'OLD', value)
|
||||
for uid, ref, value in (('u1', 'R1', '10nF'), ('u2', 'R2', '22nF'), ('u3', 'C1', '1uF')))
|
||||
store.record_target_inventory(task.task_id, targets)
|
||||
return store, task, targets
|
||||
|
||||
|
||||
def test_bom_template_expands_one_to_many_refdes_and_preserves_unlisted_targets(tmp_path):
|
||||
store, task, targets = setup_store(tmp_path)
|
||||
path = tmp_path / 'bom.xlsx'
|
||||
write_bom_template(path, (
|
||||
{'old_part_number': 'OLD', 'new_part_number': 'NEW-A', 'refdes': 'R1, R2',
|
||||
'enabled': '是', 'sync_nc': '否', 'custom_value': '10nF'},
|
||||
))
|
||||
rows = read_bom_plan(store, task.task_id, path)
|
||||
by_ref = {row.target.refdes: row for row in rows}
|
||||
assert by_ref['R1'].enabled and by_ref['R2'].enabled
|
||||
assert not by_ref['R1'].sync_nc
|
||||
assert not by_ref['C1'].enabled
|
||||
store.close()
|
||||
|
||||
|
||||
def test_bom_rejects_unknown_or_ambiguous_refdes_and_formulas(tmp_path):
|
||||
store, task, _ = setup_store(tmp_path)
|
||||
path = tmp_path / 'bom.xlsx'
|
||||
write_bom_template(path, ({'old_part_number': 'OLD', 'new_part_number': 'NEW', 'refdes': 'R9'},))
|
||||
with pytest.raises(TaskCenterError, match='R9'):
|
||||
read_bom_plan(store, task.task_id, path)
|
||||
workbook = Workbook(); sheet = workbook.active; sheet.append(BOM_HEADERS)
|
||||
sheet.append(['OLD', '=A2', 'R1', '', '', '', True, '', True])
|
||||
workbook.save(path)
|
||||
with pytest.raises(TaskCenterError, match='公式'):
|
||||
read_bom_plan(store, task.task_id, path)
|
||||
store.close()
|
||||
@@ -102,3 +102,22 @@ def test_single_project_summary_and_local_gates_do_not_query_service_again(qtbot
|
||||
assert window.run_panel.quick_run_button.isEnabled()
|
||||
window.close()
|
||||
store.close()
|
||||
|
||||
|
||||
def test_project_plan_exposes_bom_import_and_template_actions(qtbot, tmp_path):
|
||||
from dx_productivity.trial_task_center.service import TaskCenterService
|
||||
from dx_productivity.trial_task_center.store import TaskStore
|
||||
from dx_productivity.trial_task_center.logging_setup import configure_logging
|
||||
from dx_productivity.trial_task_center.ui.main_window import TrialTaskCenterWindow
|
||||
from PySide6.QtWidgets import QPushButton
|
||||
|
||||
root = tmp_path / 'projects'; root.mkdir()
|
||||
path = root / 'board.prj'; path.write_text('KEY FrontEndSnapshot "DxD"\nKEY iCDBDir "database"\n')
|
||||
store = TaskStore(tmp_path / 'tasks.db')
|
||||
service = TaskCenterService(store, configure_logging(tmp_path / 'data'))
|
||||
task = service.create_project_tasks(root)[0]
|
||||
window = TrialTaskCenterWindow(service); qtbot.addWidget(window); window.open_task(task.task_id)
|
||||
assert window.findChild(QPushButton, 'importBomPlan').text() == '导入 BOM'
|
||||
assert window.findChild(QPushButton, 'exportBomTemplate').text() == 'BOM 模板'
|
||||
assert not window.task_list.filter.isVisible()
|
||||
window.close(); store.close()
|
||||
Reference in new issue
Block a user