refactor(shipping-notice): 移除废弃的履约策略模型与相关逻辑
- 删除 `ShippingFulfillmentPolicy` 模型及其依赖,简化字段治理逻辑 - 更新相关服务与 API,确保自动建单策略通过 Schema 草稿管理 - 调整文档与代码注释,反映新的固定履约契约逻辑 - 增强事件审计功能,记录任务状态变化与操作人信息
This commit is contained in:
1 parent
aa8fb2616c
commit
c85997884b
81 files changed
+2625
-1965
No files matched your search
@@ -2,7 +2,7 @@
|
||||
backend/app/api/admin/shipping_order_schema.py
|
||||
|
||||
用途:提供唯一发货订单 Schema、字段目录和版本发布的管理 API。
|
||||
依赖:admin blueprint、require_admin、order_schema.service、fulfillment_policy_registry。
|
||||
依赖:admin blueprint、require_admin、order_schema.service、field_asset_service。
|
||||
逻辑:路由读取管理员身份;字段校验、不可变性与事务由领域服务完成。
|
||||
固定操作默认 Schema STANDARD_SHIPPING_NOTICE;不接受 family_code,不下线表结构。
|
||||
"""
|
||||
@@ -16,7 +16,6 @@ from app.core.decorators import require_admin
|
||||
from app.core.response import ok
|
||||
from app.models.shipping_order_schema import ShippingOrderField
|
||||
from app.services.shipping_notice.order_schema import service
|
||||
from app.services.shipping_notice import fulfillment_policy_registry
|
||||
from app.services.shipping_notice import field_asset_service
|
||||
from app.services.shipping_notice.standard_field_registry import DEFAULT_V1_ADOPTION_CODES
|
||||
|
||||
@@ -38,39 +37,16 @@ def get_shipping_order_schema():
|
||||
return _ok(service.get_state())
|
||||
|
||||
|
||||
@admin_bp.route('/shipping-order-schema/auto-creation-policy', methods=['GET', 'PUT'])
|
||||
@admin_bp.route('/shipping-order-schema/auto-creation-policy', methods=['GET'])
|
||||
@require_admin
|
||||
def shipping_order_auto_creation_policy():
|
||||
"""
|
||||
GET:读取已发布生效的自动建单策略。
|
||||
PUT:已废弃;须写入 Schema 草稿并随版本发布生效。
|
||||
读取已发布生效的自动建单策略。
|
||||
|
||||
说明:写操作已移除。修改须通过 Schema 草稿保存并发布
|
||||
(PUT /shipping-order-schema/versions/:id 携带 auto_creation_policy)。
|
||||
"""
|
||||
if request.method == 'GET':
|
||||
return _ok(service.get_auto_creation_policy())
|
||||
return _ok(service.save_auto_creation_policy(
|
||||
request.get_json(silent=True) or {}, actor_id=_actor_id(),
|
||||
))
|
||||
|
||||
|
||||
@admin_bp.route('/shipping-fulfillment-policies', methods=['GET', 'POST'])
|
||||
@require_admin
|
||||
def shipping_fulfillment_policies():
|
||||
"""读取履约策略能力目录或创建新的货代履约策略草稿。"""
|
||||
if request.method == 'GET':
|
||||
return _ok(fulfillment_policy_registry.get_state())
|
||||
return _ok(fulfillment_policy_registry.create_draft(
|
||||
request.get_json(silent=True) or {}, actor_id=_actor_id(),
|
||||
), status=201)
|
||||
|
||||
|
||||
@admin_bp.route('/shipping-fulfillment-policies/<int:policy_id>/publish', methods=['POST'])
|
||||
@require_admin
|
||||
def publish_shipping_fulfillment_policy(policy_id: int):
|
||||
"""发布指定货代履约策略版本并退役当前版本。"""
|
||||
payload = request.get_json(silent=True) or {}
|
||||
return _ok(fulfillment_policy_registry.publish(
|
||||
policy_id, actor_id=_actor_id(), expected_lock_version=payload.get('expected_lock_version'),
|
||||
))
|
||||
return _ok(service.get_auto_creation_policy())
|
||||
|
||||
|
||||
@admin_bp.route('/shipping-order-schema', methods=['POST'])
|
||||
|
||||
@@ -38,7 +38,6 @@ from app.models.shipping_fulfillment import (
|
||||
ShippingReservation,
|
||||
ShippingUploadAttempt,
|
||||
)
|
||||
from app.models.shipping_fulfillment_policy import ShippingFulfillmentPolicy
|
||||
from app.models.shipping_order_schema import (
|
||||
ShippingFieldAsset,
|
||||
ShippingOrderExtraction,
|
||||
@@ -250,7 +249,6 @@ __all__ = [
|
||||
'ShippingInventoryVerificationLine',
|
||||
'ShippingExportArtifactLine',
|
||||
'ShippingUploadAttempt',
|
||||
'ShippingFulfillmentPolicy',
|
||||
'ShippingNoticeIntake',
|
||||
'ShippingNoticeDocument',
|
||||
'ShippingNoticeCandidate',
|
||||
|
||||
@@ -271,6 +271,9 @@ class ShippingTaskEvent(Base):
|
||||
task_id: Mapped[int] = mapped_column(ForeignKey('shipping_tasks.id'), index=True)
|
||||
event_type: Mapped[str] = mapped_column(String(64), index=True)
|
||||
detail_json: Mapped[Optional[dict]] = mapped_column(JSON, nullable=True)
|
||||
before_json: Mapped[Optional[dict]] = mapped_column(JSON, nullable=True)
|
||||
after_json: Mapped[Optional[dict]] = mapped_column(JSON, nullable=True)
|
||||
source: Mapped[Optional[str]] = mapped_column(String(32), nullable=True, index=True)
|
||||
actor_id: Mapped[Optional[int]] = mapped_column(ForeignKey('users.id'), nullable=True, index=True)
|
||||
request_id: Mapped[Optional[str]] = mapped_column(String(64), nullable=True, index=True)
|
||||
created_at: Mapped[datetime] = mapped_column(default=datetime.utcnow, index=True)
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
"""
|
||||
models/shipping_fulfillment_policy.py
|
||||
|
||||
用途:保存货代字段能力绑定和不可变履约策略版本。
|
||||
依赖:订单 Schema、users 与 SQLAlchemy Base。
|
||||
逻辑:Schema 负责字段目录;本模型以稳定 field_id 将字段绑定到货代履约能力,并只允许一个 published 策略。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Optional
|
||||
|
||||
from sqlalchemy import CheckConstraint, DateTime, ForeignKey, Index, Integer, JSON, String, Text, UniqueConstraint, text
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.models.base import Base
|
||||
|
||||
|
||||
class ShippingFulfillmentPolicy(Base):
|
||||
"""货代履约策略版本;published 版本不可修改且由冻结 Snapshot 引用。"""
|
||||
|
||||
__tablename__ = 'shipping_fulfillment_policies'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('schema_id', 'policy_code', 'version', name='uq_shipping_fulfillment_policies_version'),
|
||||
CheckConstraint("status IN ('draft', 'published', 'retired')", name='ck_shipping_fulfillment_policies_status'),
|
||||
Index(
|
||||
'uq_shipping_fulfillment_policy_one_published', 'schema_id', unique=True,
|
||||
postgresql_where=text("status = 'published'"), sqlite_where=text("status = 'published'"),
|
||||
),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
schema_id: Mapped[int] = mapped_column(ForeignKey('shipping_order_schemas.id'), nullable=False)
|
||||
policy_code: Mapped[str] = mapped_column(String(64), nullable=False)
|
||||
version: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
status: Mapped[str] = mapped_column(String(16), nullable=False, default='draft', server_default='draft')
|
||||
definition_json: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False, default=dict)
|
||||
checksum: Mapped[Optional[str]] = mapped_column(String(64), nullable=True)
|
||||
lock_version: Mapped[int] = mapped_column(Integer, nullable=False, default=1, server_default='1')
|
||||
change_note: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
|
||||
source_policy_id: Mapped[Optional[int]] = mapped_column(ForeignKey('shipping_fulfillment_policies.id'), nullable=True)
|
||||
created_by_id: Mapped[Optional[int]] = mapped_column(ForeignKey('users.id'), nullable=True)
|
||||
published_by_id: Mapped[Optional[int]] = mapped_column(ForeignKey('users.id'), nullable=True)
|
||||
published_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
retired_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
|
||||
+18
-12
@@ -156,6 +156,7 @@ class CoordinateProfileLogicalRow(CoordinateReconstructionModel):
|
||||
|
||||
fields: dict[str, str] = Field(default_factory=dict)
|
||||
source_row_indices: list[int] = Field(min_length=1)
|
||||
role: Literal['data', 'deleted'] = 'data'
|
||||
issues: list[str] = Field(default_factory=list)
|
||||
|
||||
|
||||
@@ -228,13 +229,15 @@ def reconstruct_coordinate_profile_rows(
|
||||
exclusion_regions: list[dict[str, Any]] | None = None,
|
||||
initial_fields: dict[str, str] | None = None,
|
||||
initial_next_offset: int = 0,
|
||||
include_deleted: bool = False,
|
||||
) -> list[CoordinateProfileLogicalRow]:
|
||||
"""
|
||||
按 v2 物理行和字段区域合并逻辑明细,不使用 MinerU 的行列结果。
|
||||
|
||||
主行必须在其已绑定 ``line_no`` 区域中出现有效行号才启动明细;未满足此条件的
|
||||
视觉行不会被猜测为新行。随后只按连续 ``row_offset`` 消费 continuation,避免描述
|
||||
换行、合计或相邻无关表区静默混入当前订单行。
|
||||
换行、合计或相邻无关表区静默混入当前订单行。``include_deleted`` 仅供标注预览
|
||||
返回删除行证据;正式解析保持默认值,删除行不会进入业务结果。
|
||||
"""
|
||||
bbox = table_bbox if isinstance(table_bbox, LayoutBBox) else LayoutBBox.model_validate(table_bbox)
|
||||
ordered_layouts = sorted((item for item in line_layouts if isinstance(item, dict)), key=lambda item: item.get('row_offset', -1))
|
||||
@@ -287,6 +290,7 @@ def reconstruct_coordinate_profile_rows(
|
||||
ordered_layouts=ordered_layouts,
|
||||
termination_rules=termination_rules or [],
|
||||
initial_fields=initial_fields,
|
||||
include_deleted=include_deleted,
|
||||
)
|
||||
if relative_y_rows is not None:
|
||||
return relative_y_rows
|
||||
@@ -323,10 +327,12 @@ def reconstruct_coordinate_profile_rows(
|
||||
next_offset = initial_next_offset if current is not None else 0
|
||||
current_issues: list[str] = []
|
||||
|
||||
def flush() -> None:
|
||||
def flush(*, role: Literal['data', 'deleted'] = 'data') -> None:
|
||||
nonlocal current, sources, next_offset, current_issues
|
||||
if current is not None and (sources or initial_fields):
|
||||
results.append(CoordinateProfileLogicalRow(fields=current, source_row_indices=sources, issues=current_issues))
|
||||
results.append(CoordinateProfileLogicalRow(
|
||||
fields=current, source_row_indices=sources, role=role, issues=current_issues,
|
||||
))
|
||||
current, sources, next_offset, current_issues = None, [], 0, []
|
||||
|
||||
for row_index, band in enumerate(_group_visual_rows(glyphs)):
|
||||
@@ -335,10 +341,9 @@ def reconstruct_coordinate_profile_rows(
|
||||
flush()
|
||||
break
|
||||
if _DELETED_PATTERN.fullmatch(re.sub(r'\s+', '', text)):
|
||||
# Deletion markers apply only to the immediately preceding started record.
|
||||
# Do not emit it as a partial row and do not guess an association when no
|
||||
# main row is active.
|
||||
current, sources, next_offset, current_issues = None, [], 0, []
|
||||
# Preserve deleted evidence for the annotator; downstream consumers use
|
||||
# the role to exclude it rather than silently losing the document row.
|
||||
flush(role='deleted')
|
||||
continue
|
||||
main_values, main_issues = values_for(band, ordered_layouts[0])
|
||||
line_no = re.sub(r'\s+', '', main_values.get('line_no', ''))
|
||||
@@ -370,7 +375,7 @@ def reconstruct_coordinate_profile_rows(
|
||||
current_issues.extend(continuation_issues)
|
||||
next_offset += 1
|
||||
flush()
|
||||
return results
|
||||
return results if include_deleted else [row for row in results if row.role != 'deleted']
|
||||
|
||||
|
||||
def _reconstruct_relative_y_profile_rows(
|
||||
@@ -380,6 +385,7 @@ def _reconstruct_relative_y_profile_rows(
|
||||
ordered_layouts: list[dict[str, Any]],
|
||||
termination_rules: list[dict[str, Any]],
|
||||
initial_fields: dict[str, str] | None,
|
||||
include_deleted: bool,
|
||||
) -> list[CoordinateProfileLogicalRow] | None:
|
||||
"""
|
||||
将单个多视觉行物理框按父行内相对 Y 投影到每条重复明细。
|
||||
@@ -429,10 +435,9 @@ def _reconstruct_relative_y_profile_rows(
|
||||
for anchor_index, start in enumerate(anchors):
|
||||
end = anchors[anchor_index + 1] if anchor_index + 1 < len(anchors) else len(usable_bands)
|
||||
record = usable_bands[start:end]
|
||||
if any(_DELETED_PATTERN.fullmatch(re.sub(
|
||||
deleted = any(_DELETED_PATTERN.fullmatch(re.sub(
|
||||
r'\s+', '', ''.join(glyph.text for _, glyph in sorted(band, key=lambda item: item[1].bbox.x0)),
|
||||
)) for _, band in record):
|
||||
continue
|
||||
)) for _, band in record)
|
||||
values: dict[str, str] = {}
|
||||
issues: list[str] = []
|
||||
matched_bands, alignment_issues = _match_field_band_groups(
|
||||
@@ -467,9 +472,10 @@ def _reconstruct_relative_y_profile_rows(
|
||||
results.append(CoordinateProfileLogicalRow(
|
||||
fields=values,
|
||||
source_row_indices=[row_index for row_index, _ in record],
|
||||
role='deleted' if deleted else 'data',
|
||||
issues=issues,
|
||||
))
|
||||
return results
|
||||
return results if include_deleted else [row for row in results if row.role != 'deleted']
|
||||
|
||||
|
||||
def _matches_termination_rule(
|
||||
|
||||
@@ -126,7 +126,7 @@ def _extract_layout(
|
||||
# intent, but it must remain review-only until the label is fixed.
|
||||
results.append(_read_value_region(
|
||||
layout=layout, config=config, glyphs=glyphs, page_no=page_no, source=source,
|
||||
region=_absolute_anchor_region(layout.value_region, reference_anchor),
|
||||
region=_absolute_value_region(layout=layout, anchor=reference_anchor, width=width, height=height),
|
||||
anchor_bbox=reference_anchor, fallback=False,
|
||||
review_issue='order_field_anchor_text_mismatch',
|
||||
))
|
||||
@@ -142,7 +142,7 @@ def _extract_layout(
|
||||
anchor_bbox, _indices = matches[0]
|
||||
results.append(_read_value_region(
|
||||
layout=layout, config=config, glyphs=glyphs, page_no=page_no, source=source,
|
||||
region=_absolute_anchor_region(layout.value_region, anchor_bbox), anchor_bbox=anchor_bbox, fallback=False,
|
||||
region=_absolute_value_region(layout=layout, anchor=anchor_bbox, width=width, height=height), anchor_bbox=anchor_bbox, fallback=False,
|
||||
))
|
||||
usable = [item for item in results if item.status != 'unavailable']
|
||||
if len(usable) == 1:
|
||||
@@ -165,16 +165,12 @@ def _read_value_region(
|
||||
source: str, region: LayoutBBox, anchor_bbox: LayoutBBox | None, fallback: bool,
|
||||
review_issue: str | None = None,
|
||||
) -> OrderFieldExtraction:
|
||||
"""按视觉行合并值区文字,多行模式先以停止标签截断,再执行 Schema 规范化与校验。
|
||||
"""按管理员值框读取文字,多行模式先以停止标签截断,再执行 Schema 规范化与校验。
|
||||
|
||||
``right_of_anchor`` 使用锚点右侧的同一连续文本段,而不是严格依赖值框的
|
||||
左边界;这能避免标签后的冒号进入值,也能容忍框选末尾少量字符。
|
||||
值框是字段边界的主证据。即使 ``right_of_anchor`` 也不跨出该边界补字,
|
||||
以免相邻字段的临界字符混入当前字段并与画布标注不一致。
|
||||
"""
|
||||
selected = (
|
||||
_inline_right_of_anchor_glyphs(glyphs=glyphs, anchor_bbox=anchor_bbox, region=region)
|
||||
if layout.value_mode == 'right_of_anchor' and anchor_bbox is not None
|
||||
else [(index, item) for index, item in enumerate(glyphs) if _glyph_center_inside(item, region)]
|
||||
)
|
||||
selected = [(index, item) for index, item in enumerate(glyphs) if _glyph_center_inside(item, region)]
|
||||
if layout.value_mode == 'multi_line':
|
||||
selected = _stop_before_anchor(
|
||||
selected, glyphs=glyphs, stop_anchors=layout.stop_anchors, anchor_bbox=anchor_bbox,
|
||||
@@ -449,6 +445,13 @@ def _absolute_anchor_region(region: AnchorRelativeRegion | None, anchor: LayoutB
|
||||
)
|
||||
|
||||
|
||||
def _absolute_value_region(*, layout: OrderFieldLayout, anchor: LayoutBBox, width: float, height: float) -> LayoutBBox:
|
||||
"""优先使用管理员画布绝对值框;旧模板才按锚点偏移投影。"""
|
||||
if layout.absolute_value_region is not None:
|
||||
return _absolute_relative_region(layout.absolute_value_region, width=width, height=height)
|
||||
return _absolute_anchor_region(layout.value_region, anchor)
|
||||
|
||||
|
||||
def _glyph_bbox(glyph: dict[str, Any]) -> LayoutBBox:
|
||||
"""严格解析一枚冻结 glyph 的 bbox;坏坐标不会被修正后参与提取。"""
|
||||
return LayoutBBox.model_validate(glyph.get('bbox'))
|
||||
|
||||
@@ -110,9 +110,11 @@ class OrderFieldLayout(OrderProfileModel):
|
||||
page_scope: Literal['first_page', 'all_pages', 'exact_page'] = 'first_page'
|
||||
page_no: int | None = Field(default=None, ge=1)
|
||||
anchor: AnchorRule | None = None
|
||||
# Anchored values use offsets relative to the anchor bbox; fixed-position
|
||||
# fallback values are stored separately so they cannot be mistaken for anchors.
|
||||
# ``absolute_value_region`` is the authoritative administrator-drawn page box.
|
||||
# ``value_region`` remains only for legacy profiles whose values were stored as
|
||||
# offsets relative to the anchor bbox.
|
||||
value_region: AnchorRelativeRegion | None = None
|
||||
absolute_value_region: RelativeRegion | None = None
|
||||
fallback_value_region: RelativeRegion | None = None
|
||||
value_mode: Literal['single_line', 'multi_line', 'right_of_anchor', 'below_anchor'] = 'single_line'
|
||||
stop_anchors: list[AnchorRule] = Field(default_factory=list)
|
||||
@@ -132,8 +134,11 @@ class OrderFieldLayout(OrderProfileModel):
|
||||
raise ValueError('value-only order field must have a bounded page scope')
|
||||
if self.value_region is not None or self.fallback_value_region is None:
|
||||
raise ValueError('value-only order field requires one fallback value region')
|
||||
elif self.value_region is None or self.fallback_value_region is not None:
|
||||
raise ValueError('anchored order field requires one anchor-relative value region')
|
||||
elif (
|
||||
(self.value_region is None) == (self.absolute_value_region is None)
|
||||
or self.fallback_value_region is not None
|
||||
):
|
||||
raise ValueError('anchored order field requires one value region')
|
||||
if self.value_mode == 'multi_line' and not self.stop_anchors:
|
||||
raise ValueError('multi-line order field requires stop anchors')
|
||||
return self
|
||||
@@ -226,6 +231,7 @@ class DraftUnboundOrderFieldLayout(OrderProfileModel):
|
||||
page_no: int | None = Field(default=None, ge=1)
|
||||
anchor: AnchorRule | None = None
|
||||
value_region: AnchorRelativeRegion | None = None
|
||||
absolute_value_region: RelativeRegion | None = None
|
||||
fallback_value_region: RelativeRegion | None = None
|
||||
value_mode: Literal['single_line', 'multi_line', 'right_of_anchor', 'below_anchor'] = 'single_line'
|
||||
stop_anchors: list[AnchorRule] = Field(default_factory=list)
|
||||
@@ -237,7 +243,8 @@ class DraftUnboundOrderFieldLayout(OrderProfileModel):
|
||||
OrderFieldLayout(
|
||||
layout_id=self.layout_id, field_id='draft_unbound', field_code='draft_unbound',
|
||||
page_scope=self.page_scope, page_no=self.page_no, anchor=self.anchor,
|
||||
value_region=self.value_region, fallback_value_region=self.fallback_value_region,
|
||||
value_region=self.value_region, absolute_value_region=self.absolute_value_region,
|
||||
fallback_value_region=self.fallback_value_region,
|
||||
value_mode=self.value_mode, stop_anchors=self.stop_anchors,
|
||||
minimum_evidence_level=self.minimum_evidence_level,
|
||||
)
|
||||
|
||||
@@ -274,17 +274,15 @@ def _json_value(value: Any) -> Any:
|
||||
|
||||
|
||||
def list_independent_samples(*, suite_id: int, actor_id: int) -> dict[str, Any]:
|
||||
"""列出可用于当前盲测的同类专用订单,严格排除建模和已加入盲测的文档。"""
|
||||
"""列出可用于当前盲测的同类专用订单,严格排除建模和已加入盲测的文档。
|
||||
|
||||
列表阶段只读取已存布局摘要,不能为每个候选触发 OCR/坐标证据补齐;用户选中
|
||||
某份样本后,再由候选预览执行完整的坐标和订单字段校验。
|
||||
"""
|
||||
suite = db.session.get(ShippingDocumentProfileTestSuite, int(suite_id))
|
||||
if suite is None:
|
||||
raise NotFoundError('Order document profile test suite not found', code='SHIPPING.ORDER_DOCUMENT_PROFILE_TEST_NOT_FOUND')
|
||||
profile = _profile(suite.profile_id)
|
||||
parser = _definition_contract(profile)
|
||||
schema_fields = {
|
||||
str(item.get('field_id') or ''): item
|
||||
for item in (profile.schema_version.definition_json or {}).get('fields') or []
|
||||
if isinstance(item, dict) and item.get('enabled', True)
|
||||
}
|
||||
excluded = {
|
||||
item.document_id for item in ShippingOrderDocumentProfileSample.query.filter_by(profile_id=profile.id).all()
|
||||
} | {item.document_id for item in suite.samples}
|
||||
@@ -298,18 +296,12 @@ def list_independent_samples(*, suite_id: int, actor_id: int) -> dict[str, Any]:
|
||||
if document.id in excluded:
|
||||
continue
|
||||
layout = current_layout_snapshot(document) or {}
|
||||
if isinstance(parser, OrderCoordinateProfileV2):
|
||||
layout = _ensure_order_field_evidence(document=document, layout=layout, parser=parser)
|
||||
if not _has_matching_key_order_field(parser=parser, schema_fields=schema_fields, layout=layout):
|
||||
continue
|
||||
tables = layout.get('tables') if isinstance(layout.get('tables'), list) else []
|
||||
if layout.get('status') != 'ready' or not tables:
|
||||
continue
|
||||
for table in tables:
|
||||
if not isinstance(table, dict) or not str(table.get('table_id') or ''):
|
||||
continue
|
||||
if isinstance(parser, OrderCoordinateProfileV2) and not _coordinate_table_available(document.id, str(table['table_id'])):
|
||||
continue
|
||||
result.append({
|
||||
'document_id': document.id, 'table_id': str(table['table_id']),
|
||||
'page_no': int(table.get('page_no') or 1), 'filename': document.filename or '',
|
||||
|
||||
@@ -15,7 +15,6 @@ from typing import Any
|
||||
from app.extensions import db
|
||||
from app.models import (
|
||||
ShippingExcelTemplate,
|
||||
ShippingFulfillmentPolicy,
|
||||
ShippingInventoryParsingProfile,
|
||||
ShippingInventoryRoutingRule,
|
||||
ShippingInventoryRoutingRuleCondition,
|
||||
@@ -176,28 +175,7 @@ def list_field_runtime_references(field_id: str) -> list[dict[str, Any]]:
|
||||
extra={'template_code': template.template_code},
|
||||
))
|
||||
|
||||
# [STEP 5] 履约策略 field_bindings
|
||||
for policy in ShippingFulfillmentPolicy.query.filter(
|
||||
ShippingFulfillmentPolicy.status.in_(['draft', 'published']),
|
||||
).all():
|
||||
hit_paths: list[str] = []
|
||||
for index, item in enumerate((policy.definition_json or {}).get('field_bindings', []) or []):
|
||||
if isinstance(item, dict) and str(item.get('field_id') or '') == field_id:
|
||||
role = item.get('role') or item.get('purpose') or index
|
||||
hit_paths.append(f'definition.field_bindings[{index}]({role})')
|
||||
if not hit_paths:
|
||||
continue
|
||||
references.append(_ref(
|
||||
kind='fulfillment_policy',
|
||||
object_id=policy.id,
|
||||
display_name=getattr(policy, 'display_name', None) or f'Policy #{policy.id}',
|
||||
status=policy.status,
|
||||
version=getattr(policy, 'version', None),
|
||||
reference_path='; '.join(hit_paths),
|
||||
admin_path='/admin/shipping-inventory?section=fulfillment',
|
||||
))
|
||||
|
||||
# [STEP 6] 客户识别定义 / 规则集
|
||||
# [STEP 5] 客户识别定义 / 规则集
|
||||
for definition in ShippingIdentityDefinition.query.filter_by(
|
||||
context_field_id=field_id, status='active',
|
||||
).all():
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
冻结前履约就绪门禁。
|
||||
|
||||
用途:集中检查订单解析、字段裁决、客户、冲突与库存源状态,阻止不完整订单进入不可编辑快照。
|
||||
依赖:订单 Extraction、字段裁决、冲突门禁、库存源门禁及已发布履约策略。
|
||||
依赖:订单 Extraction、字段裁决、冲突门禁、库存源门禁及固定履约契约。
|
||||
逻辑:order_freeze_service 在创建 Snapshot 前调用;失败统一返回结构化 blocking issues。
|
||||
阶段 5 自动冻结入口接入后,同一服务继续负责把 Run 级自动冻结门禁摘要折叠为冻结阻断原因。
|
||||
"""
|
||||
@@ -22,7 +22,6 @@ def assert_freeze_readiness(
|
||||
*,
|
||||
task: ShippingTask,
|
||||
extraction: ShippingOrderExtraction,
|
||||
policy: Any,
|
||||
configs: dict[str, dict[str, Any]],
|
||||
freeze_mode: str = 'manual',
|
||||
auto_freeze_policy: dict[str, Any] | None = None,
|
||||
@@ -34,7 +33,7 @@ def assert_freeze_readiness(
|
||||
issues.extend(open_field_conflict_issues(task))
|
||||
issues.extend(_auto_freeze_blocking_issues(freeze_mode=freeze_mode, auto_freeze_policy=auto_freeze_policy))
|
||||
|
||||
required = required_field_configs(extraction.schema_version.definition_json or {}, policy)
|
||||
required = required_field_configs(extraction.schema_version.definition_json or {})
|
||||
required_codes = {'reservation_id', 'part_number', 'qty'}
|
||||
values = ShippingOrderFieldValue.query.filter_by(extraction_id=extraction.id).all()
|
||||
decisions = ShippingOrderFieldDecision.query.filter_by(extraction_id=extraction.id).all()
|
||||
|
||||
@@ -1,268 +1,64 @@
|
||||
"""
|
||||
services/shipping_notice/fulfillment_policy_registry.py
|
||||
|
||||
用途:管理货代字段能力绑定与版本化滚动履约策略。
|
||||
依赖:唯一发货订单 Schema、字段资产、履约策略模型与统一 AppError。
|
||||
逻辑:策略使用稳定 field_id 绑定货代能力;核心能力仅允许系统标准行字段;
|
||||
发布策略前必须存在已发布 Schema,且绑定字段已被采用;
|
||||
冻结只消费当前 published 策略,历史 Snapshot 保存完整策略事实。
|
||||
用途:声明唯一且不可配置的货代滚动履约契约。
|
||||
依赖:订单 Schema 版本定义与统一 ValidationError。
|
||||
逻辑:冻结服务取得核心字段配置并把规则快照写入订单;库存、制单和上传只读取该冻结事实。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
from datetime import datetime
|
||||
from typing import Any
|
||||
|
||||
from app.core.errors import ConflictError, NotFoundError, ValidationError
|
||||
from app.extensions import db
|
||||
from app.models import ShippingFulfillmentPolicy, ShippingOrderField, ShippingOrderSchema, ShippingOrderSchemaVersion
|
||||
from app.services.shipping_notice.standard_field_registry import (
|
||||
DEFAULT_SCHEMA_FAMILY_CODE,
|
||||
FULFILLMENT_CORE_FIELD_CODES,
|
||||
)
|
||||
|
||||
|
||||
SHIP_AVAILABLE_ROLLING_V1 = 'SHIP_AVAILABLE_ROLLING_V1'
|
||||
_CORE_CAPABILITIES = frozenset({
|
||||
'fulfillment.reservation_identity', 'fulfillment.part_number', 'fulfillment.quantity',
|
||||
})
|
||||
_CAPABILITIES = {
|
||||
'fulfillment.reservation_identity': {'scope': 'line', 'value_type': 'string', 'required': True},
|
||||
'fulfillment.part_number': {'scope': 'line', 'value_type': 'string', 'required': True},
|
||||
'fulfillment.quantity': {'scope': 'line', 'value_type': 'decimal', 'required': True},
|
||||
'routing.inventory_source_hint': {'scope': 'line', 'value_type': 'string', 'required': False},
|
||||
}
|
||||
_REQUIRED_CAPABILITIES = frozenset({
|
||||
'fulfillment.reservation_identity', 'fulfillment.part_number', 'fulfillment.quantity',
|
||||
})
|
||||
_CANONICAL_FIELD_CODES = {
|
||||
'fulfillment.reservation_identity': 'reservation_id',
|
||||
'fulfillment.part_number': 'part_number',
|
||||
'fulfillment.quantity': 'qty',
|
||||
'routing.inventory_source_hint': 'inventory_source_hint',
|
||||
from app.core.errors import ValidationError
|
||||
FIXED_FULFILLMENT_RULE_CODE = 'SHIP_AVAILABLE_ROLLING_V1'
|
||||
_REQUIRED_FIELDS = {
|
||||
'reservation_id': {'scope': 'line', 'value_type': 'string'},
|
||||
'part_number': {'scope': 'line', 'value_type': 'string'},
|
||||
'qty': {'scope': 'line', 'value_type': 'decimal'},
|
||||
}
|
||||
|
||||
|
||||
def capability_catalog() -> list[dict[str, Any]]:
|
||||
"""返回货代专用能力目录;管理员不能配置自由代码、SQL 或脚本。"""
|
||||
return [{'capability_code': code, **spec} for code, spec in sorted(_CAPABILITIES.items())]
|
||||
|
||||
|
||||
def _schema() -> ShippingOrderSchema:
|
||||
"""
|
||||
读取唯一发货订单 Schema(STANDARD_SHIPPING_NOTICE),兼容历史 SHIPPING_ORDER。
|
||||
|
||||
Raises:
|
||||
NotFoundError: Schema 尚未初始化。
|
||||
"""
|
||||
schema = ShippingOrderSchema.query.filter_by(schema_code=DEFAULT_SCHEMA_FAMILY_CODE).one_or_none()
|
||||
if schema is None:
|
||||
schema = ShippingOrderSchema.query.filter_by(schema_code='SHIPPING_ORDER').one_or_none()
|
||||
if schema is None:
|
||||
raise NotFoundError('Shipping order schema is not initialized', code='SHIPPING.ORDER_SCHEMA_NOT_FOUND')
|
||||
return schema
|
||||
|
||||
|
||||
def _checksum(definition: dict[str, Any]) -> str:
|
||||
"""为策略定义计算稳定摘要,供冻结与审计比对。"""
|
||||
return hashlib.sha256(json.dumps(definition, ensure_ascii=True, sort_keys=True, separators=(',', ':')).encode()).hexdigest()
|
||||
|
||||
|
||||
def _field_bindings(raw: Any, **_ignored: Any) -> list[dict[str, Any]]:
|
||||
"""校验能力与稳定 field_id 的一对一绑定;核心能力仅允许系统标准行字段。"""
|
||||
if not isinstance(raw, list):
|
||||
raise ValidationError('field_bindings must be a list', code='SHIPPING.FULFILLMENT_POLICY_INVALID')
|
||||
seen_capabilities: set[str] = set()
|
||||
seen_fields: set[str] = set()
|
||||
bindings: list[dict[str, Any]] = []
|
||||
for item in raw:
|
||||
if not isinstance(item, dict):
|
||||
raise ValidationError('field binding is invalid', code='SHIPPING.FULFILLMENT_POLICY_INVALID')
|
||||
capability = str(item.get('capability_code') or '').strip()
|
||||
field_id = str(item.get('field_id') or '').strip()
|
||||
spec = _CAPABILITIES.get(capability)
|
||||
field = db.session.get(ShippingOrderField, field_id) if field_id else None
|
||||
if (
|
||||
spec is None or field is None or field.status != 'active'
|
||||
or field.scope != spec['scope'] or field.value_type != spec['value_type']
|
||||
or capability in seen_capabilities or field_id in seen_fields
|
||||
):
|
||||
raise ValidationError('field capability binding is invalid', code='SHIPPING.FULFILLMENT_POLICY_INVALID')
|
||||
expected_code = _CANONICAL_FIELD_CODES.get(capability)
|
||||
if capability in _CORE_CAPABILITIES:
|
||||
if field.asset_kind != 'system_standard' or field.field_code not in FULFILLMENT_CORE_FIELD_CODES:
|
||||
raise ValidationError(
|
||||
'Core fulfillment capabilities require system standard line fields',
|
||||
code='SHIPPING.FULFILLMENT_FIELD_INVALID',
|
||||
details={'capability_code': capability, 'field_code': field.field_code},
|
||||
)
|
||||
if expected_code and field.field_code != expected_code:
|
||||
raise ValidationError(
|
||||
'Core fulfillment capability must bind the canonical standard field',
|
||||
code='SHIPPING.FULFILLMENT_FIELD_INVALID',
|
||||
details={'capability_code': capability, 'expected': expected_code},
|
||||
)
|
||||
seen_capabilities.add(capability)
|
||||
seen_fields.add(field_id)
|
||||
bindings.append({
|
||||
'capability_code': capability,
|
||||
'field_id': field.id,
|
||||
'field_code': field.field_code,
|
||||
'scope': field.scope,
|
||||
'value_type': field.value_type,
|
||||
})
|
||||
if _REQUIRED_CAPABILITIES - seen_capabilities:
|
||||
raise ValidationError(
|
||||
'required fulfillment capability bindings are missing',
|
||||
code='SHIPPING.FULFILLMENT_POLICY_INVALID',
|
||||
details={'capabilities': sorted(_REQUIRED_CAPABILITIES - seen_capabilities)},
|
||||
)
|
||||
return sorted(bindings, key=lambda item: item['capability_code'])
|
||||
|
||||
|
||||
def _definition(raw: dict[str, Any], **_ignored: Any) -> dict[str, Any]:
|
||||
"""生成可发布的受控策略定义,策略仅支持滚动发货语义。"""
|
||||
policy_code = str(raw.get('policy_code') or SHIP_AVAILABLE_ROLLING_V1).strip()
|
||||
if policy_code != SHIP_AVAILABLE_ROLLING_V1:
|
||||
raise ValidationError('unsupported fulfillment policy', code='SHIPPING.FULFILLMENT_POLICY_INVALID')
|
||||
def fixed_rule_definition() -> dict[str, Any]:
|
||||
"""返回代码内置履约规则;管理员和 API 均不能修改此定义。"""
|
||||
return {
|
||||
'policy_code': policy_code,
|
||||
'rule_code': FIXED_FULFILLMENT_RULE_CODE,
|
||||
'fulfillment_mode': 'ship_available_rolling',
|
||||
'requires_confirmed_customer': True,
|
||||
'allows_partial_reservation': False,
|
||||
'field_bindings': _field_bindings(raw.get('field_bindings')),
|
||||
'requires_full_reservation_availability': True,
|
||||
'includes_all_available_reservations': True,
|
||||
}
|
||||
|
||||
|
||||
def list_field_references(field_id: str) -> list[dict[str, Any]]:
|
||||
"""列出仍绑定该字段的履约策略版本,供影响分析使用。"""
|
||||
items: list[dict[str, Any]] = []
|
||||
for policy in ShippingFulfillmentPolicy.query.filter(
|
||||
ShippingFulfillmentPolicy.status.in_(['draft', 'published']),
|
||||
).all():
|
||||
bindings = (policy.definition_json or {}).get('field_bindings') or []
|
||||
if any(str(item.get('field_id') or '') == field_id for item in bindings if isinstance(item, dict)):
|
||||
items.append({
|
||||
'kind': 'fulfillment_policy',
|
||||
'policy_id': policy.id,
|
||||
'version': policy.version,
|
||||
'status': policy.status,
|
||||
})
|
||||
return items
|
||||
def fixed_rule_checksum() -> str:
|
||||
"""计算固定规则摘要,便于冻结快照与审计记录稳定比对。"""
|
||||
encoded = json.dumps(fixed_rule_definition(), ensure_ascii=True, sort_keys=True, separators=(',', ':')).encode()
|
||||
return hashlib.sha256(encoded).hexdigest()
|
||||
|
||||
|
||||
def _payload(policy: ShippingFulfillmentPolicy) -> dict[str, Any]:
|
||||
"""序列化策略版本,前端只能拿到已验证定义与版本状态。"""
|
||||
return {
|
||||
'id': policy.id, 'policy_code': policy.policy_code, 'version': policy.version, 'status': policy.status,
|
||||
'definition': dict(policy.definition_json or {}), 'checksum': policy.checksum,
|
||||
'lock_version': policy.lock_version, 'change_note': policy.change_note,
|
||||
'published_at': policy.published_at.isoformat() if policy.published_at else None,
|
||||
def required_field_configs(definition: dict[str, Any]) -> dict[str, dict[str, Any]]:
|
||||
"""从当前 Schema 定义定位固定履约所需的三个标准表身字段并校验类型。"""
|
||||
by_code = {
|
||||
str(item.get('field_code') or ''): item
|
||||
for item in definition.get('fields') or []
|
||||
if item.get('enabled', True)
|
||||
}
|
||||
|
||||
|
||||
def get_state() -> dict[str, Any]:
|
||||
"""读取唯一发货订单 Schema 的货代履约策略管理状态及当前发布版本。"""
|
||||
schema = _schema()
|
||||
policies = ShippingFulfillmentPolicy.query.filter_by(schema_id=schema.id).order_by(ShippingFulfillmentPolicy.version.desc()).all()
|
||||
return {
|
||||
'schema_code': schema.schema_code,
|
||||
'capabilities': capability_catalog(),
|
||||
'policies': [_payload(item) for item in policies],
|
||||
}
|
||||
|
||||
|
||||
def create_draft(
|
||||
raw: dict[str, Any], *, actor_id: int | None,
|
||||
) -> dict[str, Any]:
|
||||
"""创建下一策略草稿;未发布策略不得参与冻结。"""
|
||||
schema = _schema()
|
||||
latest = db.session.query(ShippingFulfillmentPolicy.version).filter_by(schema_id=schema.id).order_by(ShippingFulfillmentPolicy.version.desc()).first()
|
||||
definition = _definition(raw, schema_id=schema.id)
|
||||
policy = ShippingFulfillmentPolicy(
|
||||
schema_id=schema.id, policy_code=definition['policy_code'], version=(int(latest[0]) + 1 if latest else 1),
|
||||
definition_json=definition, change_note=str(raw.get('change_note') or '').strip() or None, created_by_id=actor_id,
|
||||
)
|
||||
db.session.add(policy)
|
||||
db.session.commit()
|
||||
return _payload(policy)
|
||||
|
||||
|
||||
def publish(
|
||||
policy_id: int, *, actor_id: int | None, expected_lock_version: int | None,
|
||||
) -> dict[str, Any]:
|
||||
"""发布策略并退役旧版本;策略字段必须存在于当前已发布 Schema。"""
|
||||
policy = db.session.get(ShippingFulfillmentPolicy, policy_id)
|
||||
if policy is None:
|
||||
raise NotFoundError('Fulfillment policy not found', code='SHIPPING.FULFILLMENT_POLICY_NOT_FOUND')
|
||||
schema = _schema()
|
||||
if policy.schema_id != schema.id:
|
||||
raise NotFoundError('Fulfillment policy not found', code='SHIPPING.FULFILLMENT_POLICY_NOT_FOUND')
|
||||
if policy.status != 'draft' or expected_lock_version != policy.lock_version:
|
||||
raise ConflictError('Fulfillment policy has changed', code='SHIPPING.FULFILLMENT_POLICY_CONFLICT')
|
||||
definition = _definition(dict(policy.definition_json or {}), schema_id=policy.schema_id)
|
||||
published_schema = ShippingOrderSchemaVersion.query.filter_by(
|
||||
schema_id=policy.schema_id, status='published',
|
||||
).one_or_none()
|
||||
if published_schema is None:
|
||||
raise ConflictError(
|
||||
'Fulfillment policy requires a published schema version',
|
||||
code='SHIPPING.FULFILLMENT_POLICY_SCHEMA_REQUIRED',
|
||||
details={'schema_id': policy.schema_id},
|
||||
)
|
||||
enabled_field_ids = {
|
||||
str(config.get('field_id'))
|
||||
for config in (published_schema.definition_json or {}).get('fields') or []
|
||||
if config.get('enabled', True)
|
||||
}
|
||||
missing_field_ids = sorted(
|
||||
str(binding['field_id'])
|
||||
for binding in definition['field_bindings']
|
||||
if str(binding['field_id']) not in enabled_field_ids
|
||||
)
|
||||
if missing_field_ids:
|
||||
raise ValidationError(
|
||||
'Fulfillment policy fields must be included in the published schema',
|
||||
code='SHIPPING.FULFILLMENT_POLICY_INVALID',
|
||||
details={'field_ids': missing_field_ids},
|
||||
)
|
||||
current = ShippingFulfillmentPolicy.query.filter_by(schema_id=policy.schema_id, status='published').one_or_none()
|
||||
now = datetime.utcnow()
|
||||
if current is not None:
|
||||
current.status, current.retired_at = 'retired', now
|
||||
policy.definition_json = definition
|
||||
policy.checksum = _checksum(definition)
|
||||
policy.status, policy.published_by_id, policy.published_at = 'published', actor_id, now
|
||||
db.session.commit()
|
||||
return _payload(policy)
|
||||
|
||||
|
||||
def published_policy() -> ShippingFulfillmentPolicy:
|
||||
"""取得唯一 Schema 当前可执行策略;没有发布版本时 fail closed。"""
|
||||
schema = _schema()
|
||||
policy = ShippingFulfillmentPolicy.query.filter_by(schema_id=schema.id, status='published').one_or_none()
|
||||
if policy is None:
|
||||
raise ConflictError('No published fulfillment policy', code='SHIPPING.FULFILLMENT_POLICY_NOT_PUBLISHED')
|
||||
return policy
|
||||
|
||||
|
||||
def required_field_configs(definition: dict[str, Any], policy: ShippingFulfillmentPolicy) -> dict[str, dict[str, Any]]:
|
||||
"""把已发布策略的能力绑定解析为冻结字段配置,并拒绝 Schema 版本漂移。"""
|
||||
by_id = {str(item.get('field_id')): item for item in definition.get('fields') or [] if item.get('enabled', True)}
|
||||
selected: dict[str, dict[str, Any]] = {}
|
||||
bound_capabilities: set[str] = set()
|
||||
for binding in (policy.definition_json or {}).get('field_bindings') or []:
|
||||
capability = str(binding.get('capability_code') or '')
|
||||
config = by_id.get(str(binding.get('field_id') or ''))
|
||||
spec = _CAPABILITIES.get(capability)
|
||||
if config is None and spec is not None and not spec['required']:
|
||||
continue
|
||||
if config is None or spec is None or config.get('scope') != spec['scope'] or config.get('value_type') != spec['value_type']:
|
||||
raise ValidationError('Frozen order schema does not satisfy the fulfillment policy', code='SHIPPING.ORDER_CONTRACT_INVALID')
|
||||
selected[_CANONICAL_FIELD_CODES[capability]] = config
|
||||
bound_capabilities.add(capability)
|
||||
if _REQUIRED_CAPABILITIES - bound_capabilities:
|
||||
raise ValidationError('Fulfillment policy bindings are incomplete', code='SHIPPING.ORDER_CONTRACT_INVALID')
|
||||
for field_code, expected in _REQUIRED_FIELDS.items():
|
||||
config = by_code.get(field_code)
|
||||
if (
|
||||
config is None
|
||||
or config.get('scope') != expected['scope']
|
||||
or config.get('value_type') != expected['value_type']
|
||||
or config.get('asset_kind') not in (None, 'system_standard')
|
||||
):
|
||||
raise ValidationError(
|
||||
'Frozen order schema does not satisfy the fixed fulfillment rule',
|
||||
code='SHIPPING.ORDER_CONTRACT_INVALID',
|
||||
details={'field_code': field_code},
|
||||
)
|
||||
selected[field_code] = config
|
||||
return selected
|
||||
@@ -20,7 +20,7 @@ from flask import current_app
|
||||
|
||||
from app import db
|
||||
from app.core.errors import ConflictError, ValidationError
|
||||
from app.models import ShippingTask, ShippingTaskEvent
|
||||
from app.models import ShippingTask
|
||||
from app.services.shipping_notice.constants import CP_UPLOADED, PH_UPLOAD_RPA_PENDING, PH_UPLOAD_RESULT_UNKNOWN
|
||||
from app.services.shipping_notice.export import generate_shipment_excel, order_field_id_values
|
||||
from app.services.shipping_notice.inventory_file_store import active_inventory_lines_for_task
|
||||
@@ -53,7 +53,7 @@ from app.services.shipping_notice.rpa_attempts import (
|
||||
from app.services.shipping_notice.inventory_source_gate import assert_inventory_source_gate, is_inventory_source_stable
|
||||
from app.services.shipping_notice.customer_identity_gate import customer_gate_tool_response
|
||||
from app.services.shipping_notice.state_machine import TaskTransition, apply_task_transition
|
||||
from app.services.shipping_notice.tool_common import prepend_tool_message, set_task_step_progress
|
||||
from app.services.shipping_notice.tool_common import log_task_event, prepend_tool_message, set_task_step_progress
|
||||
from app.services.shipping_notice.tool_response import tool_response
|
||||
from app.services.shipping_notice.task_disposition_service import task_execution_block_reason
|
||||
|
||||
@@ -164,18 +164,13 @@ def _rpa_upload_timeout_seconds() -> int:
|
||||
return _cfg_int("SHIPPING_NOTICE_RPA_UPLOAD_TIMEOUT_SECONDS", 30, min_value=5)
|
||||
|
||||
|
||||
def log_task_event(task: ShippingTask, event_type: str, detail: dict[str, Any] | None = None) -> None:
|
||||
"""写入 ShippingTaskEvent 审计记录。"""
|
||||
if task.id is None:
|
||||
db.session.flush()
|
||||
db.session.add(
|
||||
ShippingTaskEvent(
|
||||
task_id=task.id,
|
||||
event_type=event_type,
|
||||
detail_json=detail or {},
|
||||
)
|
||||
)
|
||||
|
||||
def _event_actor_id(payload: dict[str, Any]) -> int | None:
|
||||
"""解析工作台传入的操作人;缺失时明确按系统自动动作记录。"""
|
||||
try:
|
||||
value = payload.get('operator_id') or payload.get('actor_id')
|
||||
return int(value) if value is not None else None
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
|
||||
|
||||
def match_completed(task: ShippingTask) -> bool:
|
||||
@@ -314,6 +309,7 @@ def match_inventory(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
dict[str, Any]: Tool 标准响应;status 可为 ok / needs_human / failed。
|
||||
"""
|
||||
lang = resolve_lang(payload)
|
||||
actor_id = _event_actor_id(payload)
|
||||
task = resolve_task_from_payload(payload)
|
||||
if not task:
|
||||
return tool_response(status="failed", message=t("workflow.fulfillment.task_not_found", lang=lang))
|
||||
@@ -464,7 +460,7 @@ def match_inventory(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
|
||||
if match_status in {"fulfillable", "partial"} and match_completed(task):
|
||||
apply_task_transition(task, TaskTransition.MATCHED_FULFILLABLE)
|
||||
log_task_event(task, "matched_rolling_available", {"match_status": match_status, "verification_id": verification.id})
|
||||
log_task_event(task, "matched_rolling_available", {"match_status": match_status, "verification_id": verification.id}, actor_id=actor_id, source='workspace_api' if actor_id else 'system')
|
||||
db.session.commit()
|
||||
match_result = tool_response(
|
||||
status="ok",
|
||||
@@ -475,7 +471,7 @@ def match_inventory(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
return try_auto_chain_after_match(task, match_result, payload=payload)
|
||||
|
||||
apply_task_transition(task, TaskTransition.MATCH_SHORTAGE)
|
||||
log_task_event(task, "match_needs_review", {"match_status": match_status, "shortage": shortage})
|
||||
log_task_event(task, "match_needs_review", {"match_status": match_status, "shortage": shortage}, actor_id=actor_id, source='workspace_api' if actor_id else 'system')
|
||||
db.session.commit()
|
||||
return tool_response(
|
||||
status="needs_human",
|
||||
@@ -513,6 +509,7 @@ def generate_excel(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
dict[str, Any]: 含 download_hint 的 Tool 响应;门禁失败时 forbidden_next_tools 含 upload_to_freight。
|
||||
"""
|
||||
lang = resolve_lang(payload)
|
||||
actor_id = _event_actor_id(payload)
|
||||
task = resolve_task_from_payload(payload)
|
||||
if not task:
|
||||
return tool_response(status="failed", message=t("workflow.fulfillment.task_not_found", lang=lang))
|
||||
@@ -617,7 +614,7 @@ def generate_excel(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
progress_percent=100,
|
||||
detail=filename,
|
||||
)
|
||||
log_task_event(task, "export_generated", {"file_name": filename, "artifact_no": artifact.artifact_no})
|
||||
log_task_event(task, "export_generated", {"file_name": filename, "artifact_no": artifact.artifact_no}, actor_id=actor_id, source='workspace_api' if actor_id else 'system')
|
||||
_commit_generated_export(path)
|
||||
return tool_response(
|
||||
status="ok",
|
||||
@@ -708,7 +705,7 @@ def upload_to_freight(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
)
|
||||
except (ConflictError, ValidationError) as exc:
|
||||
return tool_response(status='failed', task=task, message=str(exc), data=serialize_task_for_tool(task))
|
||||
log_task_event(task, 'upload_manual_confirmed', {'artifact_id': attempt.artifact_id, 'attempt_id': attempt.id})
|
||||
log_task_event(task, 'upload_manual_confirmed', {'artifact_id': attempt.artifact_id, 'attempt_id': attempt.id}, actor_id=attempt.operator_id, source='workspace_api')
|
||||
db.session.commit()
|
||||
return tool_response(
|
||||
status="ok",
|
||||
|
||||
@@ -3,7 +3,7 @@ backend/app/services/shipping_notice/order_document_profile_creation_service.py
|
||||
|
||||
用途:完成订单模板三步创建向导的最终原子提交。
|
||||
依赖:Profile 保存、样本布局、Revision、EditLease 与 Profile 审计模型。
|
||||
逻辑:前两步只在浏览器保存临时状态;本服务在最后一步一次创建草稿、样本绑定、Revision 审计和编辑租约,任一失败整体回滚。
|
||||
逻辑:前两步只在浏览器保存临时状态;本服务在最后一步一次创建草稿、首份建模/训练样本绑定、Revision 审计和编辑租约,任一失败整体回滚。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -112,15 +112,22 @@ def complete_wizard(data: dict[str, Any], *, actor_id: int | None) -> dict[str,
|
||||
change_source='wizard_created', commit=False,
|
||||
)
|
||||
profile_id = int(saved['id'])
|
||||
db.session.add(ShippingOrderDocumentProfileSample(
|
||||
profile_id=profile_id, document_id=document.id, table_id=table_id,
|
||||
sample_role='annotation', created_by_id=actor_id,
|
||||
))
|
||||
# 首份样本既承载画布标注,也作为训练证据;盲测仍必须另选独立文档。
|
||||
for sample_role in ('annotation', 'training'):
|
||||
db.session.add(ShippingOrderDocumentProfileSample(
|
||||
profile_id=profile_id, document_id=document.id, table_id=table_id,
|
||||
sample_role=sample_role, created_by_id=actor_id,
|
||||
))
|
||||
db.session.flush()
|
||||
profile_service._refresh_training_sample_count(db.session.get(ShippingOrderDocumentProfile, profile_id))
|
||||
revision_no = int(saved['draft_revision']['revision_no'])
|
||||
profile_service._audit(
|
||||
profile_id=profile_id, document_id=document.id, event_type='wizard_created', actor_id=actor_id,
|
||||
operation_id=operation_id, browser_session_id=session_id, revision_no=revision_no,
|
||||
detail={'main_table_id': table_id, 'schema_version_id': schema_version_id, 'profile_code': profile_code},
|
||||
detail={
|
||||
'main_table_id': table_id, 'schema_version_id': schema_version_id, 'profile_code': profile_code,
|
||||
'sample_roles': ['annotation', 'training'],
|
||||
},
|
||||
)
|
||||
now = datetime.utcnow()
|
||||
token = secrets.token_urlsafe(32)
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ def create_report(profile_id: int, *, data: dict[str, Any], actor_id: int | None
|
||||
run_id = data.get('validation_run_id')
|
||||
validation = db.session.get(ShippingOrderDocumentProfileValidationRun, int(run_id)) if str(run_id or '').isdigit() else None
|
||||
blocking: list[dict[str, Any]] = []
|
||||
if validation is None or validation.profile_id != profile.id or validation.status != 'passed' or validation.definition_checksum != revision.definition_checksum:
|
||||
if validation is None or validation.profile_id != profile.id or validation.run_type != 'current_sample' or validation.status != 'passed' or validation.definition_checksum != revision.definition_checksum:
|
||||
blocking.append({'key': 'current_validation_required', 'message': 'A passing validation run for the current draft is required.'})
|
||||
try:
|
||||
from app.services.shipping_notice.document_profile_quality_service import assert_profile_publishable
|
||||
|
||||
@@ -386,8 +386,14 @@ def _normalize_definition(raw: Any, *, schema_version: ShippingOrderSchemaVersio
|
||||
draft_unbound_order_field_layouts=normalized['draft_unbound_order_field_layouts'],
|
||||
)
|
||||
except (TypeError, ValueError) as exc:
|
||||
# Pydantic locations only describe the submitted contract, so exposing the
|
||||
# first one lets the workbench identify a bad region without leaking data.
|
||||
validation_errors = getattr(exc, 'errors', lambda: [])()
|
||||
location = validation_errors[0].get('loc', ()) if validation_errors else ()
|
||||
raise ValidationError(
|
||||
'Order profile definition is invalid', code='SHIPPING.ORDER_DOCUMENT_PROFILE_INVALID',
|
||||
'Order profile definition is invalid',
|
||||
code='SHIPPING.ORDER_DOCUMENT_PROFILE_INVALID',
|
||||
details={'field_path': '.'.join(str(item) for item in location) or '$'},
|
||||
) from exc
|
||||
return {
|
||||
'contract_version': contract.contract_version,
|
||||
@@ -662,6 +668,8 @@ def preview_profile_region(
|
||||
table_region=table_region.region.model_dump(),
|
||||
termination_rules=[item.model_dump() for item in table_region.termination_rules],
|
||||
exclusion_regions=[item.model_dump() for item in table_region.exclusion_regions],
|
||||
# 预览保留删除证据,供管理员核对;正式订单运行仍使用默认排除规则。
|
||||
include_deleted=True,
|
||||
))
|
||||
# 复合解析器可能生成未显式列在 target_fields 的附加字段,仍需纳入本次候选。
|
||||
for row in rows:
|
||||
@@ -676,7 +684,7 @@ def preview_profile_region(
|
||||
result = {
|
||||
'table_id': table_id, 'row_count': len(rows) + (1 if field_codes else 0),
|
||||
'column_count': len(field_codes), 'rows': ([field_codes] if field_codes else []) + [[row.fields.get(code, '') for code in field_codes] for row in rows],
|
||||
'row_roles': (['header'] if field_codes else []) + ['data'] * len(rows),
|
||||
'row_roles': (['header'] if field_codes else []) + [row.role for row in rows],
|
||||
'source_row_indices': ([[]] if field_codes else []) + [row.source_row_indices for row in rows],
|
||||
'status': 'needs_review',
|
||||
}
|
||||
|
||||
@@ -122,6 +122,20 @@ def _instant_summary(profile: ShippingOrderDocumentProfile) -> dict[str, Any]:
|
||||
}
|
||||
|
||||
|
||||
def _current_sample_summary(*, line_field_count: int, line_value_count: int, header_field_count: int, header_value_count: int, sample_role: str) -> tuple[str, dict[str, Any], dict[str, Any]]:
|
||||
"""将样本试读的字段和值完整性转为发布可消费的明确结果。"""
|
||||
field_count = line_field_count + header_field_count
|
||||
value_count = line_value_count + header_value_count
|
||||
summary = {
|
||||
'sample_role': sample_role, 'field_count': field_count, 'value_count': value_count,
|
||||
'line_field_count': line_field_count, 'header_field_count': header_field_count,
|
||||
}
|
||||
if field_count <= 0 or value_count <= 0:
|
||||
summary['failure_code'] = 'order_profile_current_sample_no_readable_values'
|
||||
return 'failed', summary, {}
|
||||
return 'passed', summary, {'field_count': field_count, 'value_count': value_count}
|
||||
|
||||
|
||||
def run_instant_check(profile_id: int, *, data: dict[str, Any], actor_id: int | None, browser_session_id: str | None, lease_token: str | None, operation_id: str) -> dict[str, Any]:
|
||||
"""创建即时结构检查运行;必须持有草稿租约且失败结果同样持久化可查询。"""
|
||||
profile = _profile(profile_id)
|
||||
@@ -152,9 +166,18 @@ def run_current_sample(profile_id: int, *, data: dict[str, Any], actor_id: int |
|
||||
}, actor_id=actor_id)
|
||||
rows = preview.get('rows') if isinstance(preview, dict) else []
|
||||
fields = preview.get('field_codes') if isinstance(preview, dict) else []
|
||||
row.status, row.summary_json, row.result_snapshot_json = 'passed', {
|
||||
'sample_role': sample.sample_role, 'row_count': len(rows or []), 'field_count': len(fields or []),
|
||||
}, {'row_count': len(rows or []), 'field_count': len(fields or [])}
|
||||
definition = dict(profile.definition_json or {})
|
||||
header_fields = profile_service.preview_order_field_values({
|
||||
'document_id': sample.document_id, 'schema_version_id': profile.schema_version_id,
|
||||
'page_no': 1, 'definition': definition,
|
||||
}, actor_id=actor_id).get('fields') or []
|
||||
line_value_count = sum(1 for source_row in rows[1:] if isinstance(source_row, list) for value in source_row if str(value or '').strip())
|
||||
header_value_count = sum(1 for field in header_fields if isinstance(field, dict) and str(field.get('value') or '').strip())
|
||||
row.status, row.summary_json, row.result_snapshot_json = _current_sample_summary(
|
||||
line_field_count=len(fields or []), line_value_count=line_value_count,
|
||||
header_field_count=len(header_fields), header_value_count=header_value_count,
|
||||
sample_role=sample.sample_role,
|
||||
)
|
||||
except Exception as exc:
|
||||
row.status, row.summary_json, row.result_snapshot_json = 'failed', {
|
||||
'sample_role': sample.sample_role, 'failure_code': getattr(exc, 'code', 'SHIPPING.ORDER_DOCUMENT_PROFILE_RECONSTRUCTION_UNAVAILABLE'),
|
||||
|
||||
@@ -3,7 +3,7 @@ services/shipping_notice/order_field_purposes.py
|
||||
|
||||
用途:将冻结订单 Snapshot 按冻结货代策略能力投影给履约链。
|
||||
依赖:冻结履约策略、export.order_field_id_values、ShippingTask。
|
||||
逻辑:路由、门禁、匹配和展示只通过策略冻结的 stable field_id 定位字段,禁止读取 Schema business_purpose 或任务行固定列。
|
||||
逻辑:路由、门禁、匹配和展示只通过固定规则冻结的 stable field_id 定位字段,禁止读取 Schema business_purpose 或任务行固定列。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -28,17 +28,14 @@ def task_line_purpose_field_ids(task: ShippingTask, *, required: set[str] | None
|
||||
snapshot = db.session.get(ShippingOrderSnapshot, task.order_snapshot_id) if task.order_snapshot_id else None
|
||||
if snapshot is None:
|
||||
raise ValueError('任务没有可用于履约的冻结订单快照')
|
||||
policy = (snapshot.rule_versions_json or {}).get('fulfillment_policy')
|
||||
definition = policy.get('definition') if isinstance(policy, dict) else None
|
||||
bindings = definition.get('field_bindings') if isinstance(definition, dict) else None
|
||||
rule = (snapshot.rule_versions_json or {}).get('fulfillment_rule')
|
||||
required_ids = rule.get('required_field_ids') if isinstance(rule, dict) else None
|
||||
purposes = {
|
||||
purpose: str(binding.get('field_id'))
|
||||
for binding in bindings or []
|
||||
if isinstance(binding, dict)
|
||||
and binding.get('scope') == 'line'
|
||||
and (purpose := _PURPOSE_BY_CAPABILITY.get(str(binding.get('capability_code') or '')))
|
||||
and binding.get('field_id')
|
||||
}
|
||||
'reservation_id': str(required_ids.get('reservation_id') or ''),
|
||||
'part_number': str(required_ids.get('part_number') or ''),
|
||||
'quantity': str(required_ids.get('qty') or ''),
|
||||
} if isinstance(required_ids, dict) else {}
|
||||
purposes = {purpose: field_id for purpose, field_id in purposes.items() if field_id}
|
||||
missing = sorted((required or set()) - set(purposes))
|
||||
if missing:
|
||||
raise ValueError(f'冻结履约策略缺少字段能力:{", ".join(missing)}')
|
||||
|
||||
@@ -31,7 +31,7 @@ from app.models import (
|
||||
)
|
||||
|
||||
# 强类型列只是既有查询/导出投影;56 项标准字段的完整事实始终写在 field_id JSON。
|
||||
# 注意:本常量须保持在 fulfillment_policy / standard_field_registry 导入之前定义,
|
||||
# 注意:本常量须保持在固定履约契约 / standard_field_registry 导入之前定义,
|
||||
# 供 standard_field_registry 引用,避免三方循环导入。
|
||||
HEADER_FIELD_PROJECTIONS = {
|
||||
'customer_po_number': 'customer_po_number', 'customer_code': 'customer_code', 'customer_name': 'customer_name',
|
||||
@@ -107,7 +107,6 @@ def freeze_order_snapshot(
|
||||
assert_freeze_readiness(
|
||||
task=task,
|
||||
extraction=extraction,
|
||||
policy=policy,
|
||||
configs=configs,
|
||||
freeze_mode=freeze_mode,
|
||||
auto_freeze_policy=auto_freeze_policy,
|
||||
@@ -125,12 +124,10 @@ def freeze_order_snapshot(
|
||||
order_data_version=actual_version,
|
||||
rule_versions_json={
|
||||
**dict(rule_versions or {}),
|
||||
'fulfillment_policy': {
|
||||
'id': policy.id,
|
||||
'code': policy.policy_code,
|
||||
'version': policy.version,
|
||||
'checksum': policy.checksum,
|
||||
'definition': dict(policy.definition_json or {}),
|
||||
'fulfillment_rule': {
|
||||
'code': policy['rule_code'],
|
||||
'checksum': _fixed_rule_checksum(),
|
||||
'definition': dict(policy),
|
||||
'required_field_ids': {code: config['field_id'] for code, config in configs.items()},
|
||||
},
|
||||
'ordering_customer': {
|
||||
@@ -215,7 +212,7 @@ def _source_manifest(*, extraction: ShippingOrderExtraction, policy: Any) -> dic
|
||||
for item in (extraction.schema_version.definition_json or {}).get('fields') or []
|
||||
if isinstance(item, dict) and item.get('enabled', True)
|
||||
],
|
||||
'fulfillment_policy': {'id': policy.id, 'version': policy.version, 'checksum': policy.checksum},
|
||||
'fulfillment_rule': {'code': policy['rule_code'], 'checksum': _fixed_rule_checksum()},
|
||||
'fields': fields,
|
||||
'manual_reviews': reviews,
|
||||
}
|
||||
@@ -249,23 +246,27 @@ def _confirmed_ordering_customer(extraction: ShippingOrderExtraction) -> Shippin
|
||||
return row
|
||||
|
||||
|
||||
def _policy_configs(extraction: ShippingOrderExtraction) -> tuple[Any, dict[str, dict[str, Any]]]:
|
||||
"""按已发布货代策略验证冻结契约,Schema 只继续承担字段目录职责。"""
|
||||
# 懒加载:避免 standard_field_registry ↔ order_freeze ↔ fulfillment_policy 循环导入。
|
||||
def _policy_configs(extraction: ShippingOrderExtraction) -> tuple[dict[str, Any], dict[str, dict[str, Any]]]:
|
||||
"""按固定履约契约验证冻结字段,Schema 仅承担字段目录职责。"""
|
||||
from app.services.shipping_notice.fulfillment_policy_registry import (
|
||||
published_policy,
|
||||
fixed_rule_definition,
|
||||
required_field_configs,
|
||||
)
|
||||
|
||||
definition = extraction.schema_version.definition_json or {}
|
||||
policy = published_policy()
|
||||
required = required_field_configs(definition, policy)
|
||||
required = required_field_configs(definition)
|
||||
all_configs = {
|
||||
str(item.get('field_code') or ''): item
|
||||
for item in definition.get('fields') or []
|
||||
if item.get('enabled', True)
|
||||
}
|
||||
return policy, all_configs | required
|
||||
return fixed_rule_definition(), all_configs | required
|
||||
|
||||
|
||||
def _fixed_rule_checksum() -> str:
|
||||
"""延迟读取固定规则摘要,避免标准字段目录初始化时形成循环导入。"""
|
||||
from app.services.shipping_notice.fulfillment_policy_registry import fixed_rule_checksum
|
||||
return fixed_rule_checksum()
|
||||
|
||||
def _assert_llm_review_gate(extraction: ShippingOrderExtraction, configs: dict[str, dict[str, Any]]) -> None:
|
||||
"""关键字段若由未经证据确认的 LLM fallback 参与裁决,则强制人工复核。"""
|
||||
|
||||
@@ -246,21 +246,19 @@ def get_auto_creation_policy() -> dict[str, Any]:
|
||||
|
||||
def save_auto_creation_policy(raw: Any, *, actor_id: int | None) -> dict[str, Any]:
|
||||
"""
|
||||
拒绝立即改写自动建单策略;须写入 Schema 草稿并随发布生效。
|
||||
兼容旧调用的拒绝入口;自动建单策略不得经独立写接口立即生效。
|
||||
|
||||
Args:
|
||||
raw: 忽略;保留签名兼容旧 PUT。
|
||||
raw: 忽略。
|
||||
actor_id: 忽略。
|
||||
|
||||
Returns:
|
||||
永不返回。
|
||||
|
||||
Raises:
|
||||
ConflictError: 引导客户端走草稿保存/发布路径。
|
||||
ConflictError: 引导改走草稿保存并发布(``SHIPPING.ORDER_SCHEMA_AUTO_CREATION_VIA_DRAFT``)。
|
||||
"""
|
||||
del raw, actor_id
|
||||
raise ConflictError(
|
||||
'Auto-creation policy must be saved on the Schema draft and takes effect on publish',
|
||||
'Auto-creation policy must be saved on the Schema draft and takes effect on publish; '
|
||||
'PUT /shipping-order-schema/auto-creation-policy has been removed',
|
||||
code='SHIPPING.ORDER_SCHEMA_AUTO_CREATION_VIA_DRAFT',
|
||||
)
|
||||
|
||||
@@ -871,19 +869,6 @@ def initialize_schema(data: dict[str, Any], *, actor_id: int | None) -> dict[str
|
||||
after={'schema_code': SCHEMA_CODE, 'display_name': display_name},
|
||||
change_summary={'action': 'family_created'},
|
||||
)
|
||||
# 初始化仅预置策略草稿;须有 published Schema 后才能有效绑定字段。
|
||||
from app.services.shipping_notice.fulfillment_policy_registry import create_draft
|
||||
|
||||
fields_by_code = {item.field_code: item for item in ShippingOrderField.query.filter_by(status='active').all()}
|
||||
create_draft({
|
||||
'field_bindings': [
|
||||
{'capability_code': 'fulfillment.reservation_identity', 'field_id': fields_by_code['reservation_id'].id},
|
||||
{'capability_code': 'fulfillment.part_number', 'field_id': fields_by_code['part_number'].id},
|
||||
{'capability_code': 'fulfillment.quantity', 'field_id': fields_by_code['qty'].id},
|
||||
{'capability_code': 'routing.inventory_source_hint', 'field_id': fields_by_code['inventory_source_hint'].id},
|
||||
],
|
||||
'change_note': '初始化货代滚动履约策略',
|
||||
}, actor_id=actor_id)
|
||||
db.session.commit()
|
||||
return get_state()
|
||||
|
||||
|
||||
@@ -139,9 +139,15 @@ def _fulfillment_timeline(task: ShippingTask) -> dict[str, list[dict[str, Any]]]
|
||||
artifact_lines = ShippingExportArtifactLine.query.filter(
|
||||
ShippingExportArtifactLine.artifact_id.in_(artifact_ids),
|
||||
).all() if artifact_ids else []
|
||||
reservations_by_artifact: dict[int, list[int]] = {}
|
||||
reservation_ids = {
|
||||
item.id: item.reservation_id
|
||||
for item in ShippingReservation.query.filter(ShippingReservation.task_id == task.id).all()
|
||||
}
|
||||
reservations_by_artifact: dict[int, list[str]] = {}
|
||||
for line in artifact_lines:
|
||||
reservations_by_artifact.setdefault(int(line.artifact_id), []).append(int(line.reservation_id))
|
||||
reservations_by_artifact.setdefault(int(line.artifact_id), []).append(
|
||||
reservation_ids.get(int(line.reservation_id), str(line.reservation_id))
|
||||
)
|
||||
attempts = ShippingUploadAttempt.query.filter(
|
||||
ShippingUploadAttempt.artifact_id.in_(artifact_ids),
|
||||
).order_by(ShippingUploadAttempt.created_at, ShippingUploadAttempt.id).all() if artifact_ids else []
|
||||
@@ -150,7 +156,7 @@ def _fulfillment_timeline(task: ShippingTask) -> dict[str, list[dict[str, Any]]]
|
||||
'id': item.id, 'status': item.status, 'inventory_snapshot_id': item.inventory_snapshot_id,
|
||||
'source_config_version': item.source_config_version, 'created_at': item.created_at.isoformat() if item.created_at else None,
|
||||
'lines': [{
|
||||
'reservation_id': line.reservation_id, 'required_qty': str(line.required_qty),
|
||||
'reservation_id': reservation_ids.get(int(line.reservation_id), str(line.reservation_id)), 'required_qty': str(line.required_qty),
|
||||
'available_qty': str(line.available_qty), 'status': line.status,
|
||||
} for line in item.lines],
|
||||
} for item in verifications],
|
||||
@@ -732,6 +738,11 @@ def serialize_task(task: ShippingTask, projection: TaskProjection) -> dict[str,
|
||||
{
|
||||
"event_type": e.event_type,
|
||||
"detail_json": e.detail_json,
|
||||
"actor_id": e.actor_id,
|
||||
"request_id": e.request_id,
|
||||
"source": e.source,
|
||||
"before_json": e.before_json,
|
||||
"after_json": e.after_json,
|
||||
"created_at": e.created_at.isoformat() if e.created_at else None,
|
||||
}
|
||||
for e in sorted(task.events or [], key=lambda x: x.created_at or "")
|
||||
@@ -1788,4 +1799,4 @@ def count_my_todos(user_id: int, *, is_admin: bool = False) -> dict[str, int]:
|
||||
"processing": processing,
|
||||
"done": done,
|
||||
"total_pending_badge": pending,
|
||||
}
|
||||
}
|
||||
@@ -259,6 +259,10 @@ def log_task_event(
|
||||
detail: dict[str, Any] | None = None,
|
||||
*,
|
||||
actor_id: int | None = None,
|
||||
request_id: str | None = None,
|
||||
source: str | None = None,
|
||||
before: dict[str, Any] | None = None,
|
||||
after: dict[str, Any] | None = None,
|
||||
) -> None:
|
||||
"""
|
||||
写入 ShippingTaskEvent 审计记录(task 尚未 flush 时自动 flush)。
|
||||
@@ -269,8 +273,12 @@ def log_task_event(
|
||||
Args:
|
||||
task: 目标任务。
|
||||
event_type: 事件类型码。
|
||||
detail: 结构化明细;可含 source。
|
||||
detail: 结构化明细;包含动作对象与原因。
|
||||
actor_id: 操作者用户 ID;系统事件传 None。
|
||||
request_id: 请求追踪标识。
|
||||
source: 操作来源,如 workspace_api 或 system。
|
||||
before: 操作前业务快照。
|
||||
after: 操作后业务快照。
|
||||
"""
|
||||
if task.id is None:
|
||||
db.session.flush()
|
||||
@@ -279,6 +287,10 @@ def log_task_event(
|
||||
event_type=event_type,
|
||||
detail_json=detail or {},
|
||||
actor_id=actor_id,
|
||||
request_id=request_id,
|
||||
source=source,
|
||||
before_json=before,
|
||||
after_json=after,
|
||||
))
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
"""replace configurable fulfillment policy with fixed rule and enrich task audit
|
||||
|
||||
Revision ID: 1a3b5c7d9e0f
|
||||
Revises: 1a2b3c4d5e60
|
||||
Create Date: 2026-07-29 00:00:00.000000
|
||||
"""
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision = '1a3b5c7d9e0f'
|
||||
down_revision = '1a2b3c4d5e60'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""删除无需配置的策略表,并为任务审计补齐前后快照和来源。"""
|
||||
op.add_column('shipping_task_events', sa.Column('before_json', sa.JSON(), nullable=True))
|
||||
op.add_column('shipping_task_events', sa.Column('after_json', sa.JSON(), nullable=True))
|
||||
op.add_column('shipping_task_events', sa.Column('source', sa.String(length=32), nullable=True))
|
||||
op.create_index('ix_shipping_task_events_source', 'shipping_task_events', ['source'])
|
||||
op.drop_index('uq_shipping_fulfillment_policy_one_published', table_name='shipping_fulfillment_policies')
|
||||
op.drop_table('shipping_fulfillment_policies')
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""恢复策略表结构;不恢复已被明确废弃的历史策略数据。"""
|
||||
op.create_table(
|
||||
'shipping_fulfillment_policies',
|
||||
sa.Column('id', sa.Integer(), primary_key=True),
|
||||
sa.Column('schema_id', sa.Integer(), sa.ForeignKey('shipping_order_schemas.id'), nullable=False),
|
||||
sa.Column('policy_code', sa.String(length=64), nullable=False),
|
||||
sa.Column('version', sa.Integer(), nullable=False),
|
||||
sa.Column('status', sa.String(length=16), nullable=False, server_default='draft'),
|
||||
sa.Column('definition_json', sa.JSON(), nullable=False),
|
||||
sa.Column('checksum', sa.String(length=64)), sa.Column('lock_version', sa.Integer(), nullable=False, server_default='1'),
|
||||
sa.Column('change_note', sa.Text()), sa.Column('source_policy_id', sa.Integer()),
|
||||
sa.Column('created_by_id', sa.Integer()), sa.Column('published_by_id', sa.Integer()),
|
||||
sa.Column('published_at', sa.DateTime()), sa.Column('retired_at', sa.DateTime()),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=False), sa.Column('updated_at', sa.DateTime(), nullable=False),
|
||||
)
|
||||
op.create_index('uq_shipping_fulfillment_policy_one_published', 'shipping_fulfillment_policies', ['schema_id'], unique=True)
|
||||
op.drop_index('ix_shipping_task_events_source', table_name='shipping_task_events')
|
||||
op.drop_column('shipping_task_events', 'source')
|
||||
op.drop_column('shipping_task_events', 'after_json')
|
||||
op.drop_column('shipping_task_events', 'before_json')
|
||||
@@ -22,7 +22,6 @@ from app.models import (
|
||||
ShippingOrderFieldObservation,
|
||||
ShippingOrderFieldValue,
|
||||
ShippingTaskFieldConflict,
|
||||
ShippingFulfillmentPolicy,
|
||||
ShippingOrderLine,
|
||||
ShippingOrderSchema,
|
||||
ShippingOrderSchemaVersion,
|
||||
@@ -32,7 +31,7 @@ from app.models import (
|
||||
User,
|
||||
)
|
||||
from app.services.shipping_notice.freeze_readiness_service import assert_freeze_readiness
|
||||
from app.services.shipping_notice.fulfillment_policy_registry import published_policy, required_field_configs
|
||||
from app.services.shipping_notice.fulfillment_policy_registry import required_field_configs
|
||||
from app.services.shipping_notice.order_freeze_service import (
|
||||
HEADER_FIELD_PROJECTIONS,
|
||||
LINE_FIELD_PROJECTIONS,
|
||||
@@ -75,27 +74,6 @@ def _build_accepted_order(*, with_unverified_llm: bool = False, with_extension:
|
||||
version = ShippingOrderSchemaVersion(schema_id=schema.id, version=1, status='published', definition_json={'fields': definitions}, checksum='snapshot-test')
|
||||
db.session.add(version)
|
||||
db.session.flush()
|
||||
bindings = [
|
||||
('fulfillment.reservation_identity', 'reservation_id'),
|
||||
('fulfillment.part_number', 'part_number'),
|
||||
('fulfillment.quantity', 'qty'),
|
||||
('routing.inventory_source_hint', 'inventory_source_hint'),
|
||||
]
|
||||
db.session.add(ShippingFulfillmentPolicy(
|
||||
schema_id=schema.id, policy_code='SHIP_AVAILABLE_ROLLING_V1', version=1, status='published',
|
||||
checksum='policy-test', definition_json={
|
||||
'policy_code': 'SHIP_AVAILABLE_ROLLING_V1', 'fulfillment_mode': 'ship_available_rolling',
|
||||
'requires_confirmed_customer': True, 'allows_partial_reservation': False,
|
||||
'field_bindings': [
|
||||
{
|
||||
'capability_code': capability, 'field_id': fields[field_code].id,
|
||||
'field_code': field_code, 'scope': 'line',
|
||||
'value_type': 'decimal' if field_code == 'qty' else 'string',
|
||||
}
|
||||
for capability, field_code in bindings
|
||||
],
|
||||
},
|
||||
))
|
||||
extraction = ShippingOrderExtraction(
|
||||
task_id=task.id, schema_version_id=version.id, input_snapshot_hash='a' * 64, status='accepted',
|
||||
)
|
||||
@@ -237,21 +215,7 @@ def test_freeze_allows_schema_without_optional_standard_fields(app):
|
||||
|
||||
assert snapshot.lines[0].reservation_id == '0012345678'
|
||||
assert snapshot.currency is None
|
||||
assert snapshot.rule_versions_json['fulfillment_policy']['code'] == 'SHIP_AVAILABLE_ROLLING_V1'
|
||||
|
||||
|
||||
def test_freeze_rejects_when_no_fulfillment_policy_is_published(app):
|
||||
"""关键断言:Schema 已发布不等于可履约,未发布策略时必须在冻结入口阻断。"""
|
||||
with app.app_context():
|
||||
task, user = _build_accepted_order()
|
||||
ShippingFulfillmentPolicy.query.delete()
|
||||
db.session.commit()
|
||||
|
||||
with pytest.raises(ConflictError) as error:
|
||||
freeze_order_snapshot(task, actor_id=user.id, expected_order_data_version=7)
|
||||
|
||||
assert error.value.code == 'SHIPPING.FULFILLMENT_POLICY_NOT_PUBLISHED'
|
||||
assert task.order_snapshot_id is None
|
||||
assert snapshot.rule_versions_json['fulfillment_rule']['code'] == 'SHIP_AVAILABLE_ROLLING_V1'
|
||||
|
||||
|
||||
def test_freeze_rejects_unconfirmed_or_caller_supplied_customer(app):
|
||||
@@ -295,20 +259,18 @@ def test_auto_freeze_readiness_fails_closed_with_run_policy_blockers(app):
|
||||
task, _user = _build_accepted_order(suffix='auto-freeze-readiness')
|
||||
extraction = db.session.get(ShippingOrderExtraction, task.current_order_extraction_id)
|
||||
assert extraction is not None
|
||||
policy = published_policy()
|
||||
definition = extraction.schema_version.definition_json or {}
|
||||
configs = {
|
||||
str(item.get('field_code') or ''): item
|
||||
for item in definition.get('fields') or []
|
||||
if isinstance(item, dict) and item.get('enabled', True)
|
||||
}
|
||||
configs.update(required_field_configs(definition, policy))
|
||||
configs.update(required_field_configs(definition))
|
||||
|
||||
with pytest.raises(ValidationError) as blocked_error:
|
||||
assert_freeze_readiness(
|
||||
task=task,
|
||||
extraction=extraction,
|
||||
policy=policy,
|
||||
configs=configs,
|
||||
freeze_mode='auto',
|
||||
auto_freeze_policy={
|
||||
|
||||
@@ -1,51 +0,0 @@
|
||||
"""
|
||||
backend/tests/test_fulfillment_core_rejects_extension.py
|
||||
|
||||
用途:验证履约核心能力拒绝绑定扩展字段资产(阶段 5 收口)。
|
||||
依赖:fulfillment_policy_registry、field_asset_service、Flask 测试 app。
|
||||
逻辑:初始化 Schema 族后,用扩展字段绑 fulfillment.part_number 须抛 FULFILLMENT_FIELD_INVALID。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from app.core.errors import ValidationError
|
||||
from app.models.shipping_order_schema import ShippingOrderField
|
||||
from app.services.shipping_notice import field_asset_service
|
||||
from app.services.shipping_notice import fulfillment_policy_registry
|
||||
from app.services.shipping_notice.order_schema import service as order_schema_service
|
||||
|
||||
|
||||
def test_core_fulfillment_binding_rejects_extension_field(app):
|
||||
"""关键断言:扩展资产不可绑定履约核心 capability。"""
|
||||
with app.app_context():
|
||||
field_asset_service.ensure_standard_assets_seeded()
|
||||
order_schema_service.initialize_schema({'display_name': 'Fulfillment Gate'}, actor_id=None)
|
||||
extension = field_asset_service.create_extension({
|
||||
'field_code': 'custom_part_alias',
|
||||
'scope': 'line',
|
||||
'value_type': 'string',
|
||||
'display_name': '自定义料号',
|
||||
}, actor_id=None)
|
||||
reservation = ShippingOrderField.query.filter_by(field_code='reservation_id').one()
|
||||
qty = ShippingOrderField.query.filter_by(field_code='qty').one()
|
||||
with pytest.raises(ValidationError) as exc:
|
||||
fulfillment_policy_registry.create_draft({
|
||||
'field_bindings': [
|
||||
{
|
||||
'capability_code': 'fulfillment.reservation_identity',
|
||||
'field_id': reservation.id,
|
||||
},
|
||||
{
|
||||
'capability_code': 'fulfillment.part_number',
|
||||
'field_id': extension['id'],
|
||||
},
|
||||
{
|
||||
'capability_code': 'fulfillment.quantity',
|
||||
'field_id': qty.id,
|
||||
},
|
||||
],
|
||||
'change_note': 'must fail',
|
||||
}, actor_id=None)
|
||||
assert exc.value.code == 'SHIPPING.FULFILLMENT_FIELD_INVALID'
|
||||
@@ -34,7 +34,7 @@ def _wizard_payload(schema_id: int, document_id: int, *, table_id: str = 'sample
|
||||
|
||||
|
||||
def test_wizard_completion_creates_profile_sample_revision_audit_and_lease_atomically(app):
|
||||
"""关键断言:最后一步一次提交全部治理对象,并绑定用户已确认的主表格。"""
|
||||
"""关键断言:最后一步一次提交全部治理对象,并将主表格作为标注和训练证据。"""
|
||||
with app.app_context():
|
||||
schema = _schema_version()
|
||||
# 只借用已解析文档夹具;其 Profile 绑定与向导目标无关。
|
||||
@@ -55,12 +55,15 @@ def test_wizard_completion_creates_profile_sample_revision_audit_and_lease_atomi
|
||||
assert created['draft_revision']['revision_no'] == 1
|
||||
assert created['edit_lease']['browser_session_id'] == 'wizard-tab-a'
|
||||
assert ShippingOrderDocumentProfileSample.query.filter_by(profile_id=profile_id, document_id=sample.document_id, table_id='sample-table', sample_role='annotation').count() == 1
|
||||
assert ShippingOrderDocumentProfileSample.query.filter_by(profile_id=profile_id, document_id=sample.document_id, table_id='sample-table', sample_role='training').count() == 1
|
||||
assert db.session.get(ShippingOrderDocumentProfile, profile_id).training_sample_count == 1
|
||||
assert ShippingOrderDocumentProfileDraftRevision.query.filter_by(profile_id=profile_id, revision_no=1).count() == 1
|
||||
assert ShippingOrderDocumentProfileEditLease.query.filter_by(profile_id=profile_id).count() == 1
|
||||
audit = ShippingOrderDocumentProfileAudit.query.filter_by(
|
||||
profile_id=profile_id, event_type='wizard_created', operation_id='wizard-create-op',
|
||||
).one()
|
||||
assert audit.detail_json['profile_code'] == created['profile_code']
|
||||
assert audit.detail_json['sample_roles'] == ['annotation', 'training']
|
||||
|
||||
|
||||
def test_wizard_completion_invalid_main_table_rolls_back_without_profile(app):
|
||||
|
||||
@@ -27,7 +27,7 @@ def _passing_run(profile: dict) -> ShippingOrderDocumentProfileValidationRun:
|
||||
row = ShippingOrderDocumentProfileValidationRun(
|
||||
profile_id=profile['id'], revision_no=profile['draft_revision']['revision_no'],
|
||||
definition_checksum=profile['draft_revision']['definition_checksum'], schema_version_id=profile['schema_version_id'],
|
||||
run_type='instant_check', status='passed', summary_json={}, result_snapshot_json={}, operation_id='passing-validation',
|
||||
run_type='current_sample', status='passed', summary_json={}, result_snapshot_json={}, operation_id='passing-validation',
|
||||
)
|
||||
db.session.add(row); db.session.commit()
|
||||
return row
|
||||
|
||||
@@ -82,3 +82,16 @@ def test_failed_current_sample_run_remains_queryable(app):
|
||||
)
|
||||
assert result['status'] == 'failed'
|
||||
assert validation_service.list_runs(draft['id'])[0]['id'] == result['id']
|
||||
|
||||
|
||||
def test_current_sample_summary_rejects_empty_fields_or_values():
|
||||
"""关键断言:没有字段或读取值的样本不能伪装成可发布的通过运行。"""
|
||||
assert validation_service._current_sample_summary(
|
||||
line_field_count=0, line_value_count=2, header_field_count=0, header_value_count=0, sample_role='annotation',
|
||||
)[0] == 'failed'
|
||||
assert validation_service._current_sample_summary(
|
||||
line_field_count=2, line_value_count=0, header_field_count=1, header_value_count=0, sample_role='annotation',
|
||||
)[0] == 'failed'
|
||||
assert validation_service._current_sample_summary(
|
||||
line_field_count=2, line_value_count=1, header_field_count=1, header_value_count=0, sample_role='annotation',
|
||||
)[0] == 'passed'
|
||||
@@ -12,6 +12,7 @@ from app.extensions import db
|
||||
from app.models import (
|
||||
FileAsset,
|
||||
ShippingDocumentProfileTestRun,
|
||||
ShippingDocumentProfileTestSample,
|
||||
ShippingDocumentProfileTestSuite,
|
||||
ShippingNoticeDocument,
|
||||
ShippingNoticeIntake,
|
||||
@@ -271,6 +272,51 @@ def test_profile_detail_returns_safe_summaries_without_blind_truth(app):
|
||||
assert 'blind-secret.pdf' not in encoded
|
||||
|
||||
|
||||
def test_profile_detail_separates_bound_and_suite_blind_test_counts(app):
|
||||
"""盲测套件样本不等同于模板直接绑定的 blind_test 样本,详情 DTO 必须分别统计。"""
|
||||
with app.app_context():
|
||||
schema = _schema_version()
|
||||
user = User(username='suite-only-admin', email='suite-only@example.com', role='admin', status='active')
|
||||
db.session.add(user)
|
||||
db.session.flush()
|
||||
profile = _profile(schema.id, profile_code='TSUITE', version=1, status='published')
|
||||
suite = ShippingDocumentProfileTestSuite(
|
||||
profile_id=profile.id,
|
||||
profile_checksum=profile.checksum or '1' * 64,
|
||||
status='approved',
|
||||
approved_by_id=user.id,
|
||||
approved_at=datetime.utcnow(),
|
||||
created_by_id=user.id,
|
||||
)
|
||||
db.session.add(suite)
|
||||
db.session.flush()
|
||||
document = _document(user, filename='suite-only.pdf', content_hash='f' * 64)
|
||||
db.session.add(ShippingDocumentProfileTestSample(
|
||||
suite_id=suite.id,
|
||||
document_id=document.id,
|
||||
table_id='suite-only-table',
|
||||
expected_rows_json=[],
|
||||
expected_order_fields_json={},
|
||||
created_by_id=user.id,
|
||||
))
|
||||
db.session.add(ShippingDocumentProfileTestRun(
|
||||
suite_id=suite.id,
|
||||
profile_checksum=profile.checksum or '1' * 64,
|
||||
status='passed',
|
||||
sample_count=1,
|
||||
passed_sample_count=1,
|
||||
failure_codes_json=[],
|
||||
executed_by_id=user.id,
|
||||
))
|
||||
db.session.commit()
|
||||
|
||||
detail = version_service.get_profile_detail(profile.id)
|
||||
# 绑定样本为零不否定独立盲测套件已完成。
|
||||
assert detail['sample_summary']['blind_test_count'] == 0
|
||||
assert detail['test_summary']['sample_count'] == 1
|
||||
assert detail['test_summary']['status'] == 'approved'
|
||||
|
||||
|
||||
def test_version_center_routes_return_family_summary_and_explicit_404(app, admin_jwt_headers):
|
||||
"""新版本中心路由必须能按族返回摘要,并在版本不存在时返回明确 404。"""
|
||||
with app.app_context():
|
||||
|
||||
@@ -313,8 +313,8 @@ def test_coordinate_profile_rows_restore_pdf_visual_spaces():
|
||||
assert rows[0].fields['shipway'] == 'By Truck'
|
||||
|
||||
|
||||
def test_coordinate_profile_rows_discard_the_prior_record_for_explicit_deleted_marker():
|
||||
"""`** Item deleted **` 只能废弃前一条已启动明细,不能作为下一条或独立明细。"""
|
||||
def test_coordinate_profile_rows_hide_deleted_records_by_default_and_expose_them_for_preview():
|
||||
"""正式解析排除删除行,标注预览可显式返回同一行的删除证据。"""
|
||||
rows = reconstruct_coordinate_profile_rows(
|
||||
characters=_glyphs(
|
||||
[('00010', 10), ('PART-DELETED', 65)],
|
||||
@@ -329,6 +329,20 @@ def test_coordinate_profile_rows_discard_the_prior_record_for_explicit_deleted_m
|
||||
)
|
||||
assert [row.fields for row in rows] == [{'line_no': '00020', 'part_number': 'PART-KEEP'}]
|
||||
|
||||
preview_rows = reconstruct_coordinate_profile_rows(
|
||||
characters=_glyphs(
|
||||
[('00010', 10), ('PART-DELETED', 65)],
|
||||
[('** Item deleted **', 65)],
|
||||
[('00020', 10), ('PART-KEEP', 65)],
|
||||
), table_bbox={'x0': 0, 'y0': 0, 'x1': 200, 'y1': 100},
|
||||
line_layouts=[{'layout_id': 'main', 'row_offset': 0, 'field_regions': [
|
||||
{'field_code': 'line_no', 'region': {'x0': 0, 'y0': 0, 'x1': .25, 'y1': 1}},
|
||||
{'field_code': 'part_number', 'region': {'x0': .25, 'y0': 0, 'x1': 1, 'y1': 1}},
|
||||
]}], include_deleted=True,
|
||||
)
|
||||
# 关键断言:预览保留被删除的原始明细,但角色明确标识为不可纳入结果。
|
||||
assert [(row.fields['line_no'], row.role) for row in preview_rows] == [('00010', 'deleted'), ('00020', 'data')]
|
||||
|
||||
|
||||
def test_coordinate_profile_rows_replay_f9a1_four_physical_rows_with_bound_schema_fields():
|
||||
"""脱敏回放 F9A1:四条物理行只合并为一条,并只读取已绑定的标准字段。"""
|
||||
@@ -434,6 +448,7 @@ def test_coordinate_profile_rows_apply_field_y_relative_to_a_repeated_physical_l
|
||||
assert deleted == []
|
||||
|
||||
|
||||
|
||||
def test_coordinate_profile_rows_replay_sample_visual_band_offsets_despite_parent_whitespace():
|
||||
"""父物理行含底部留白时应复用样例视觉子行偏移,不能按高度缩放把字段投到行间。"""
|
||||
rows = reconstruct_coordinate_profile_rows(
|
||||
|
||||
@@ -249,6 +249,32 @@ def test_coordinate_v2_blind_suite_uses_frozen_coordinate_evidence_not_html_grid
|
||||
assert executed['latest_run']['status'] == 'passed', executed['latest_run']['failure_codes']
|
||||
|
||||
|
||||
def test_coordinate_blind_candidate_list_does_not_prepare_missing_evidence(app, monkeypatch):
|
||||
"""关键断言:打开盲测候选列表只能读取现有摘要,不能为历史文档触发 OCR 证据补齐。"""
|
||||
with app.app_context():
|
||||
profile, user, documents = _published_profile_with_samples()
|
||||
profile.definition_json = {
|
||||
'contract_version': 'order_coordinate_profile.v2', 'document_match': {'required_anchors': []},
|
||||
'table_regions': [], 'order_field_layouts': [],
|
||||
}
|
||||
for document in documents:
|
||||
db.session.get(ShippingNoticeIntake, document.intake_id).purpose = 'order_document_profile_sample'
|
||||
db.session.add(ShippingOrderDocumentProfileSample(
|
||||
profile_id=profile.id, document_id=documents[0].id, table_id='table-1',
|
||||
sample_role='training', created_by_id=user.id,
|
||||
))
|
||||
db.session.commit()
|
||||
suite = quality.create_suite(profile_id=profile.id, actor_id=user.id)
|
||||
monkeypatch.setattr(
|
||||
quality, '_ensure_order_field_evidence',
|
||||
lambda **_kwargs: pytest.fail('candidate listing must not prepare coordinate evidence'),
|
||||
)
|
||||
|
||||
available = quality.list_independent_samples(suite_id=suite['id'], actor_id=user.id)['samples']
|
||||
|
||||
assert {item['document_id'] for item in available} == {documents[1].id, documents[2].id}
|
||||
|
||||
|
||||
def test_coordinate_blind_preview_skips_header_only_regions(app):
|
||||
"""关键断言:仅含订单字段的页不重建物理行,候选预览不会因空布局报 500。"""
|
||||
with app.app_context():
|
||||
|
||||
@@ -1,175 +0,0 @@
|
||||
"""
|
||||
tests/test_shipping_fulfillment_policy.py
|
||||
|
||||
用途:验证货代字段能力绑定与版本化履约策略。
|
||||
依赖:订单 Schema 服务、履约策略注册表与测试数据库。
|
||||
逻辑:策略只允许受控能力绑定稳定 field_id;发布后冻结保存版本快照,错误类型或范围必须阻断;
|
||||
无已发布 Schema 时不得发布策略。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from app import db
|
||||
from app.core.errors import ConflictError, ValidationError
|
||||
from app.models import ShippingFulfillmentPolicy, ShippingOrderField
|
||||
from app.services.shipping_notice.fulfillment_policy_registry import create_draft, get_state, publish
|
||||
from app.services.shipping_notice.order_schema import service as schema_service
|
||||
|
||||
|
||||
def _bindings() -> list[dict[str, str]]:
|
||||
"""以当前标准字段的稳定 ID 构造首个滚动履约策略绑定。"""
|
||||
fields = {item.field_code: item for item in ShippingOrderField.query.filter_by(status='active').all()}
|
||||
return [
|
||||
{'capability_code': 'fulfillment.reservation_identity', 'field_id': fields['reservation_id'].id},
|
||||
{'capability_code': 'fulfillment.part_number', 'field_id': fields['part_number'].id},
|
||||
{'capability_code': 'fulfillment.quantity', 'field_id': fields['qty'].id},
|
||||
{'capability_code': 'routing.inventory_source_hint', 'field_id': fields['inventory_source_hint'].id},
|
||||
]
|
||||
|
||||
|
||||
def _field_config(field_id: str, *, display_name: str, value_type: str = 'string') -> dict:
|
||||
"""构造可发布的最小字段配置,验证策略只能绑定当前已发布字段。"""
|
||||
return {
|
||||
'field_id': field_id, 'display_name': display_name, 'business_purpose': 'general',
|
||||
'required': False, 'aliases': [], 'normalizer_key': 'decimal' if value_type == 'decimal' else 'uppercase_trim',
|
||||
'validator_keys': [], 'enum_options': [],
|
||||
'evidence_policy': {
|
||||
'required': True, 'source_precedence': ['attachment_table'],
|
||||
'conflict_policy': 'block', 'allow_single_source': True,
|
||||
},
|
||||
'relation_role': None, 'comparator_key': 'decimal' if value_type == 'decimal' else 'normalized_text',
|
||||
}
|
||||
|
||||
|
||||
def _publish_minimal_schema() -> None:
|
||||
"""发布含履约绑定字段的最小 Schema,供策略发布门禁使用。"""
|
||||
fields = {item.field_code: item for item in ShippingOrderField.query.filter_by(status='active').all()}
|
||||
draft = schema_service.create_draft({}, actor_id=None)
|
||||
configs = [
|
||||
_field_config(fields['reservation_id'].id, display_name='预定单号'),
|
||||
_field_config(fields['part_number'].id, display_name='料号'),
|
||||
_field_config(fields['qty'].id, display_name='数量', value_type='decimal'),
|
||||
_field_config(fields['inventory_source_hint'].id, display_name='库存源线索'),
|
||||
]
|
||||
saved = schema_service.save_draft(draft['id'], {
|
||||
'fields': configs, 'expected_lock_version': draft['lock_version'],
|
||||
}, actor_id=None)
|
||||
schema_service.publish(draft['id'], actor_id=None, expected_lock_version=saved['lock_version'])
|
||||
|
||||
|
||||
def test_policy_initialization_and_publish_versions_are_isolated(app):
|
||||
"""初始化只创建待确认草稿;有已发布 Schema 后,发布策略会退役旧版且保留稳定字段绑定。"""
|
||||
with app.app_context():
|
||||
schema_service.initialize_schema({'display_name': '货代字段'}, actor_id=None)
|
||||
initial = ShippingFulfillmentPolicy.query.filter_by(status='draft').one()
|
||||
assert initial.policy_code == 'SHIP_AVAILABLE_ROLLING_V1'
|
||||
assert {item['capability_code'] for item in initial.definition_json['field_bindings']} >= {
|
||||
'fulfillment.reservation_identity', 'fulfillment.part_number', 'fulfillment.quantity',
|
||||
}
|
||||
|
||||
_publish_minimal_schema()
|
||||
initial = publish(initial.id, actor_id=None, expected_lock_version=initial.lock_version)
|
||||
assert initial['status'] == 'published'
|
||||
|
||||
draft = create_draft({'field_bindings': _bindings(), 'change_note': '复核策略'}, actor_id=None)
|
||||
released = publish(draft['id'], actor_id=None, expected_lock_version=draft['lock_version'])
|
||||
|
||||
assert released['status'] == 'published'
|
||||
assert ShippingFulfillmentPolicy.query.filter_by(status='retired').one().id == initial['id']
|
||||
assert len(get_state()['capabilities']) == 4
|
||||
|
||||
|
||||
def test_policy_publish_requires_published_schema(app):
|
||||
"""断言:同族尚无已发布 Schema 时,不得发布履约策略。"""
|
||||
with app.app_context():
|
||||
schema_service.initialize_schema({'display_name': '货代字段'}, actor_id=None)
|
||||
initial = ShippingFulfillmentPolicy.query.filter_by(status='draft').one()
|
||||
with pytest.raises(ConflictError) as exc_info:
|
||||
publish(initial.id, actor_id=None, expected_lock_version=initial.lock_version)
|
||||
assert exc_info.value.code == 'SHIPPING.FULFILLMENT_POLICY_SCHEMA_REQUIRED'
|
||||
|
||||
|
||||
def test_policy_rejects_scope_or_type_drift(app):
|
||||
"""能力绑定只能选择匹配 scope/value_type 的字段,不能借字段目录绕过履约契约。"""
|
||||
with app.app_context():
|
||||
schema_service.initialize_schema({'display_name': '货代字段'}, actor_id=None)
|
||||
bindings = _bindings()
|
||||
wrong = next(item for item in ShippingOrderField.query.filter_by(field_code='customer_po_number').all())
|
||||
bindings[0]['field_id'] = wrong.id
|
||||
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
create_draft({'field_bindings': bindings}, actor_id=None)
|
||||
assert exc_info.value.code == 'SHIPPING.FULFILLMENT_POLICY_INVALID'
|
||||
|
||||
|
||||
def test_policy_rejects_extension_on_core_capability(app):
|
||||
"""核心履约能力不得绑定扩展字段;须使用系统标准表身字段。"""
|
||||
with app.app_context():
|
||||
schema_service.initialize_schema({'display_name': '货代字段'}, actor_id=None)
|
||||
custom = schema_service.save_field({
|
||||
'field_code': 'customer_reservation_reference', 'scope': 'line', 'value_type': 'string',
|
||||
'display_name': '客户预约单号',
|
||||
}, actor_id=None)
|
||||
bindings = _bindings()
|
||||
bindings[0]['field_id'] = custom['id']
|
||||
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
create_draft({'field_bindings': bindings, 'change_note': '客户预约单字段'}, actor_id=None)
|
||||
assert exc_info.value.code == 'SHIPPING.FULFILLMENT_FIELD_INVALID'
|
||||
|
||||
|
||||
def test_policy_publish_rejects_an_active_field_omitted_from_published_schema(app):
|
||||
"""已有正式 Schema 后,API 不得发布绑定了目录中但未纳入版本的字段的策略。"""
|
||||
with app.app_context():
|
||||
schema_service.initialize_schema({'display_name': '货代字段'}, actor_id=None)
|
||||
fields = {item.field_code: item for item in ShippingOrderField.query.filter_by(status='active').all()}
|
||||
draft = schema_service.create_draft({}, actor_id=None)
|
||||
# 故意不纳入 inventory_source_hint,策略绑定仍包含该字段时应被拒绝。
|
||||
configs = [
|
||||
_field_config(fields['reservation_id'].id, display_name='预定单号'),
|
||||
_field_config(fields['part_number'].id, display_name='料号'),
|
||||
_field_config(fields['qty'].id, display_name='数量', value_type='decimal'),
|
||||
]
|
||||
saved = schema_service.save_draft(draft['id'], {
|
||||
'fields': configs, 'expected_lock_version': draft['lock_version'],
|
||||
}, actor_id=None)
|
||||
schema_service.publish(draft['id'], actor_id=None, expected_lock_version=saved['lock_version'])
|
||||
policy_draft = create_draft({'field_bindings': _bindings()}, actor_id=None)
|
||||
|
||||
with pytest.raises(ValidationError) as exc_info:
|
||||
publish(policy_draft['id'], actor_id=None, expected_lock_version=policy_draft['lock_version'])
|
||||
assert exc_info.value.code == 'SHIPPING.FULFILLMENT_POLICY_INVALID'
|
||||
|
||||
|
||||
def test_schema_publish_cannot_omit_a_field_bound_by_published_policy(app):
|
||||
"""发布 Schema 时须反查当前策略,避免移除绑定字段后冻结阶段才失败。"""
|
||||
with app.app_context():
|
||||
schema_service.initialize_schema({'display_name': '货代字段'}, actor_id=None)
|
||||
fields = {item.field_code: item for item in ShippingOrderField.query.filter_by(status='active').all()}
|
||||
first = schema_service.create_draft({}, actor_id=None)
|
||||
first_fields = [
|
||||
_field_config(fields['reservation_id'].id, display_name='预定单号'),
|
||||
_field_config(fields['part_number'].id, display_name='料号'),
|
||||
_field_config(fields['qty'].id, display_name='数量', value_type='decimal'),
|
||||
_field_config(fields['inventory_source_hint'].id, display_name='库存源线索'),
|
||||
]
|
||||
saved = schema_service.save_draft(first['id'], {
|
||||
'fields': first_fields, 'expected_lock_version': first['lock_version'],
|
||||
}, actor_id=None)
|
||||
schema_service.publish(first['id'], actor_id=None, expected_lock_version=saved['lock_version'])
|
||||
initial_policy = ShippingFulfillmentPolicy.query.filter_by(status='draft').one()
|
||||
publish(initial_policy.id, actor_id=None, expected_lock_version=initial_policy.lock_version)
|
||||
second = schema_service.create_draft({}, actor_id=None)
|
||||
only_required = first_fields[:3]
|
||||
saved = schema_service.save_draft(second['id'], {
|
||||
'fields': only_required, 'expected_lock_version': second['lock_version'],
|
||||
}, actor_id=None)
|
||||
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
schema_service.publish(second['id'], actor_id=None, expected_lock_version=saved['lock_version'])
|
||||
assert getattr(exc_info.value, 'code', None) in {
|
||||
'SHIPPING.ORDER_SCHEMA_PUBLISH_DEPENDENCY_BLOCKED',
|
||||
'SHIPPING.FIELD_IMPACT_BLOCKED',
|
||||
}
|
||||
@@ -522,11 +522,16 @@ def test_profile_samples_are_governed_and_audited(app, monkeypatch):
|
||||
})
|
||||
db.session.commit()
|
||||
|
||||
annotation_samples = service.add_profile_sample(
|
||||
draft['id'], document_id=document.id, table_id='sample-table', sample_role='annotation', actor_id=None,
|
||||
)
|
||||
samples = service.add_profile_sample(
|
||||
draft['id'], document_id=document.id, table_id='sample-table', sample_role='training', actor_id=None,
|
||||
)
|
||||
profile = db.session.get(ShippingOrderDocumentProfile, draft['id'])
|
||||
assert len(samples) == 1
|
||||
# 标注与训练是不同的证据角色,同一文档页可同时承担两者。
|
||||
assert len(annotation_samples) == 1
|
||||
assert {item['sample_role'] for item in samples} == {'annotation', 'training'}
|
||||
assert profile.training_sample_count == 1
|
||||
audit = ShippingOrderDocumentProfileAudit.query.filter_by(profile_id=profile.id).order_by(
|
||||
ShippingOrderDocumentProfileAudit.id.desc(),
|
||||
@@ -534,9 +539,10 @@ def test_profile_samples_are_governed_and_audited(app, monkeypatch):
|
||||
assert audit.event_type == 'profile_sample_added'
|
||||
assert audit.detail_json == {'sample_role': 'training', 'has_table_binding': True}
|
||||
|
||||
service.remove_profile_sample(profile.id, samples[0]['id'], actor_id=None)
|
||||
training_sample = next(item for item in samples if item['sample_role'] == 'training')
|
||||
service.remove_profile_sample(profile.id, training_sample['id'], actor_id=None)
|
||||
assert db.session.get(ShippingOrderDocumentProfile, profile.id).training_sample_count == 0
|
||||
assert ShippingOrderDocumentProfileSample.query.filter_by(profile_id=profile.id).count() == 0
|
||||
assert ShippingOrderDocumentProfileSample.query.filter_by(profile_id=profile.id).count() == 1
|
||||
|
||||
with pytest.raises(Exception) as caught:
|
||||
service.publish(profile.id, actor_id=None, expected_lock_version=profile.lock_version)
|
||||
@@ -929,6 +935,20 @@ def test_profile_rejects_unknown_field_and_stale_lock(app):
|
||||
assert getattr(caught.value, 'code', None) == 'SHIPPING.ORDER_DOCUMENT_PROFILE_INVALID'
|
||||
|
||||
|
||||
def test_profile_definition_validation_exposes_first_invalid_field_path(app):
|
||||
"""关键断言:无效坐标必须给出安全字段路径,供工作台定位而不回传样本文本。"""
|
||||
with app.app_context():
|
||||
schema = _schema_version()
|
||||
invalid = _data(schema.id)
|
||||
invalid['definition']['table_regions'][0]['line_layouts'][0]['region']['x1'] = 0
|
||||
|
||||
with pytest.raises(Exception) as caught:
|
||||
service.save_draft(invalid, actor_id=None)
|
||||
|
||||
assert getattr(caught.value, 'code', None) == 'SHIPPING.ORDER_DOCUMENT_PROFILE_INVALID'
|
||||
assert getattr(caught.value, 'details', {}).get('field_path') == 'table_regions.0.line_layouts.0.region'
|
||||
|
||||
|
||||
def test_profile_admin_api_requires_admin_and_uses_standard_errors(app):
|
||||
"""普通用户不能维护 Profile;管理员错误使用统一业务 envelope。"""
|
||||
app.config['AUTH_JWT_REQUIRED'] = False
|
||||
@@ -966,6 +986,24 @@ def test_profile_admin_api_requires_admin_and_uses_standard_errors(app):
|
||||
assert lease.status_code == 201
|
||||
lease_payload = parse_api_data(lease.get_json())
|
||||
|
||||
invalid_definition = _data(schema_id)
|
||||
invalid_definition['definition']['table_regions'][0]['line_layouts'][0]['region']['x1'] = 0
|
||||
invalid = client.put(
|
||||
f"/api/admin/shipping-notice/order-document-profiles/{payload['id']}",
|
||||
json={
|
||||
**invalid_definition,
|
||||
'expected_lock_version': payload['lock_version'],
|
||||
'browser_session_id': 'profile-admin-tab',
|
||||
'lease_token': lease_payload['lease_token'],
|
||||
'operation_id': 'profile-admin-invalid-definition',
|
||||
},
|
||||
headers={'X-Username': 'profile-admin', 'X-Role': 'admin'},
|
||||
)
|
||||
assert invalid.status_code == 400
|
||||
invalid_error = parse_api_error(invalid.get_json())
|
||||
assert invalid_error['code'] == 'SHIPPING.ORDER_DOCUMENT_PROFILE_INVALID'
|
||||
assert invalid_error['details']['field_path'] == 'table_regions.0.line_layouts.0.region'
|
||||
|
||||
conflict = client.put(
|
||||
f"/api/admin/shipping-notice/order-document-profiles/{payload['id']}",
|
||||
json={
|
||||
|
||||
@@ -805,7 +805,6 @@ def test_run_submission_auto_freezes_qualified_tasks(app):
|
||||
"""Run 命中已授权模板后,应自动消费 accepted Candidate 并冻结为履约 Snapshot。"""
|
||||
with app.app_context():
|
||||
from app.models import ShippingCustomer, ShippingDocumentProfileAutoFreezeQualification, ShippingOrderCustomerMatch
|
||||
from app.services.shipping_notice.fulfillment_policy_registry import create_draft, publish
|
||||
from tests.test_shipping_order_auto_freeze_policy import _published_profile
|
||||
|
||||
fields = _ensure_order_schema()
|
||||
@@ -838,15 +837,6 @@ def test_run_submission_auto_freezes_qualified_tasks(app):
|
||||
unit = run.extraction_plan.units[0]
|
||||
job = db.session.get(Job, run.current_job_id)
|
||||
profile = _published_profile(schema_version_id=run.schema_version_id, checksum='e' * 64)
|
||||
policy_draft = create_draft({
|
||||
'field_bindings': [
|
||||
{'capability_code': 'fulfillment.reservation_identity', 'field_id': fields['reservation_id']},
|
||||
{'capability_code': 'fulfillment.part_number', 'field_id': fields['part_number']},
|
||||
{'capability_code': 'fulfillment.quantity', 'field_id': fields['qty']},
|
||||
{'capability_code': 'routing.inventory_source_hint', 'field_id': fields['inventory_source_hint']},
|
||||
],
|
||||
}, actor_id=None)
|
||||
publish(policy_draft['id'], actor_id=None, expected_lock_version=policy_draft['lock_version'])
|
||||
customer = ShippingCustomer(standard_name='Freeze Customer', short_code='FRZ')
|
||||
db.session.add(customer)
|
||||
db.session.flush()
|
||||
|
||||
@@ -8,6 +8,8 @@ tests/test_shipping_order_field_extraction.py
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pydantic import ValidationError as PydanticValidationError
|
||||
|
||||
from app.services.shipping_notice.document_layout.order_field_extraction import extract_order_fields
|
||||
from app.services.shipping_notice.document_layout.order_profile import OrderCoordinateProfileV2
|
||||
from app.services.shipping_notice.document_layout.runtime import _ocr_page_characters
|
||||
@@ -248,24 +250,24 @@ def test_common_purchase_order_slash_date_is_normalized():
|
||||
assert result.value.isoformat() == '2026-06-20'
|
||||
|
||||
|
||||
def test_date_recovers_one_glyph_just_outside_value_frame():
|
||||
"""关键断言:日期值框少一个字符宽时仅补紧邻末尾数字,避免候选无故消失。"""
|
||||
def test_date_does_not_extend_beyond_value_frame():
|
||||
"""值框边界是标注预览的唯一证据,日期也不得跨框补全。"""
|
||||
profile = _profile(layout={
|
||||
'anchor': {'anchor_id': 'date', 'text': 'DATE'},
|
||||
# The right edge falls just before the final ``6`` of 06/20/2026.
|
||||
'value_region': {'x0': 1.2, 'y0': 0, 'x1': 3.73, 'y1': 1},
|
||||
'value_region': {'x0': 1.2, 'y0': 0, 'x1': 3.55, 'y1': 1},
|
||||
})
|
||||
result = extract_order_fields(profile=profile, schema_fields=_schema(
|
||||
field_code='order_date', value_type='date', validator_keys=['iso_date'],
|
||||
), coordinate_evidence=_evidence(pages={'1': _glyphs(('DATE 06/20/2026', 20, 20))}))[0]
|
||||
|
||||
# 断言仅相邻一个字宽的末尾数字可恢复为完整的受控日期。
|
||||
assert result.status == 'confirmed'
|
||||
assert result.value.isoformat() == '2026-06-20'
|
||||
# 关键断言:框外末尾字符不能被静默吞入,管理员需扩大值框后再读取。
|
||||
assert result.status == 'needs_review'
|
||||
assert result.value is None
|
||||
|
||||
|
||||
def test_right_of_anchor_recovers_a_customer_name_cut_off_by_value_frame():
|
||||
"""客户值框截在单词中间时,应跳过冒号并补全同一连续公司名称。"""
|
||||
def test_right_of_anchor_does_not_extend_customer_name_beyond_value_frame():
|
||||
"""右侧锚点模式同样严格服从值框,避免相邻字段字符污染。"""
|
||||
profile = _profile(layout={
|
||||
'anchor': {'anchor_id': 'bill_to', 'text': 'BILL TO'},
|
||||
# Right edge cuts ``Corporation`` before its last three characters.
|
||||
@@ -277,9 +279,9 @@ def test_right_of_anchor_recovers_a_customer_name_cut_off_by_value_frame():
|
||||
'BILL TO: Inventec Corporation BILL ADDRESS: 66 Street', 20, 20,
|
||||
))}))[0]
|
||||
|
||||
# 关键断言:不能回传 ``: Inventec Corporati``,也不能吞入右侧地址字段。
|
||||
# 关键断言:不跨框补足公司名称,也不吞入右侧地址字段。
|
||||
assert result.status == 'confirmed'
|
||||
assert result.value == 'Inventec Corporation'
|
||||
assert result.value == 'Inventec Corpor'
|
||||
|
||||
|
||||
def test_right_of_anchor_never_extends_from_customer_value_box_into_address():
|
||||
@@ -300,6 +302,57 @@ def test_right_of_anchor_never_extends_from_customer_value_box_into_address():
|
||||
assert result.value == 'Inventec Corporation'
|
||||
|
||||
|
||||
def test_absolute_value_region_uses_canvas_boundary_instead_of_anchor_projection():
|
||||
"""锚点只定位字段,画布绝对值框必须排除其左侧的相邻字符。"""
|
||||
profile = _profile(layout={
|
||||
'anchor': {'anchor_id': 'bill_to', 'text': 'BILL TO'},
|
||||
'absolute_value_region': {'x0': .30, 'y0': .20, 'x1': .95, 'y1': .30},
|
||||
'value_mode': 'right_of_anchor',
|
||||
})
|
||||
result = extract_order_fields(profile=profile, schema_fields=_schema(
|
||||
field_code='bill_to_address',
|
||||
), coordinate_evidence=_evidence(pages={'1': _glyphs(
|
||||
('BILL TO', 20, 20), ('n 66 Hou-Kang Street', 56, 44),
|
||||
)}))[0]
|
||||
|
||||
# 关键断言:框左侧的 n 不属于值框,实际标签 bbox 的尺寸不得改变该判断。
|
||||
assert result.value == '66 Hou-Kang Street'
|
||||
|
||||
|
||||
def test_anchored_order_field_rejects_ambiguous_legacy_and_absolute_value_regions():
|
||||
"""新旧值框不能并存,避免后续编辑绕过唯一画布读取边界。"""
|
||||
try:
|
||||
_profile(layout={
|
||||
'anchor': {'anchor_id': 'bill_to', 'text': 'BILL TO'},
|
||||
'value_region': {'x0': 1.2, 'y0': 0, 'x1': 5, 'y1': 1},
|
||||
'absolute_value_region': {'x0': .30, 'y0': .20, 'x1': .95, 'y1': .30},
|
||||
})
|
||||
except PydanticValidationError as error:
|
||||
# 新旧坐标体系只能二选一,确保绝对画布框始终是新定义的唯一读取边界。
|
||||
assert 'anchored order field requires one value region' in str(error)
|
||||
else:
|
||||
raise AssertionError('anchored order field accepted two value regions')
|
||||
|
||||
|
||||
def test_absolute_multiline_value_region_keeps_all_rows_before_stop_anchor():
|
||||
"""多行字段严格按画布高度读取,不能因锚点投影高度而丢失末行。"""
|
||||
profile = _profile(layout={
|
||||
'anchor': {'anchor_id': 'destination', 'text': 'DESTINATION'},
|
||||
'absolute_value_region': {'x0': .30, 'y0': .20, 'x1': 1, 'y1': .46},
|
||||
'value_mode': 'multi_line',
|
||||
'stop_anchors': [{'anchor_id': 'tel', 'text': 'TEL'}],
|
||||
})
|
||||
result = extract_order_fields(profile=profile, schema_fields=_schema(
|
||||
field_code='destination',
|
||||
), coordinate_evidence=_evidence(pages={'1': _glyphs(
|
||||
('DESTINATION', 20, 20), ('Blvd Madrid 8560', 64, 44),
|
||||
('32695', 64, 56), ('Juarez, Chihuahua, Mexico', 64, 68), ('TEL 52-656', 20, 84),
|
||||
)}))[0]
|
||||
|
||||
# 关键断言:三个值行全部保留,停止标签之后的电话号码不进入结果。
|
||||
assert result.value == 'Blvd Madrid 8560\n32695\nJuarez, Chihuahua, Mexico'
|
||||
|
||||
|
||||
def test_multiline_stop_anchor_ignores_same_label_above_current_anchor():
|
||||
"""页眉或其他区块中位于当前锚点上方的停止标签,不能截断账款地址。"""
|
||||
address = _profile(layout={
|
||||
|
||||
@@ -16,7 +16,6 @@ from sqlalchemy.exc import IntegrityError
|
||||
from app import db
|
||||
from app.models import (
|
||||
ShippingExcelTemplate,
|
||||
ShippingFulfillmentPolicy,
|
||||
ShippingInventoryParsingProfile,
|
||||
ShippingOrderExtraction,
|
||||
ShippingOrderField,
|
||||
@@ -285,48 +284,6 @@ def test_order_schema_admin_api_permissions_and_validation(app, client):
|
||||
assert parse_api_error(invalid.get_json())['code'] == 'SHIPPING.ORDER_FIELD_INVALID'
|
||||
|
||||
|
||||
def test_fulfillment_policy_admin_api_requires_published_schema_and_admin(app, client):
|
||||
"""关键断言:策略仅由管理员发布,且绑定字段必须存在于当前 published Schema。"""
|
||||
app.config['AUTH_JWT_REQUIRED'] = False
|
||||
with app.app_context():
|
||||
_seed_users()
|
||||
service.initialize_schema({'display_name': '发货订单字段'}, actor_id=None)
|
||||
fields = {item.field_code: item for item in ShippingOrderField.query.filter_by(status='active').all()}
|
||||
draft = service.create_draft({}, actor_id=None)
|
||||
configs = []
|
||||
for code, name, value_type in (
|
||||
('reservation_id', '预约单号', 'string'),
|
||||
('part_number', '料号', 'string'),
|
||||
('qty', '数量', 'decimal'),
|
||||
('inventory_source_hint', '库存源线索', 'string'),
|
||||
):
|
||||
config = _field_config(fields[code].id, name=name)
|
||||
config.update({
|
||||
'aliases': [],
|
||||
'normalizer_key': 'decimal' if value_type == 'decimal' else 'uppercase_trim',
|
||||
'validator_keys': ['positive_decimal'] if value_type == 'decimal' else ['reservation_id'] if code == 'reservation_id' else [],
|
||||
'comparator_key': 'decimal' if value_type == 'decimal' else 'normalized_text',
|
||||
})
|
||||
configs.append(config)
|
||||
_save_draft(draft['id'], configs)
|
||||
_publish_draft(draft['id'])
|
||||
policy = ShippingFulfillmentPolicy.query.filter_by(status='draft').one()
|
||||
|
||||
forbidden = client.post(
|
||||
f'/api/admin/shipping-fulfillment-policies/{policy.id}/publish',
|
||||
headers=_headers('schema-user', 'user'), json={'expected_lock_version': policy.lock_version},
|
||||
)
|
||||
assert forbidden.status_code == 403
|
||||
assert parse_api_error(forbidden.get_json())['code'] == 'AUTH.FORBIDDEN'
|
||||
|
||||
published = client.post(
|
||||
f'/api/admin/shipping-fulfillment-policies/{policy.id}/publish',
|
||||
headers=_headers('schema-admin', 'admin'), json={'expected_lock_version': policy.lock_version},
|
||||
)
|
||||
assert published.status_code == 200
|
||||
assert parse_api_data(published.get_json())['status'] == 'published'
|
||||
|
||||
|
||||
def test_dynamic_header_field_value_is_unique(app):
|
||||
"""Header 动态字段值必须按 extraction+field 唯一,避免 NULL 绕过唯一约束。"""
|
||||
with app.app_context():
|
||||
|
||||
+3
-3
@@ -184,7 +184,7 @@
|
||||
|
||||
> 实施计划与 UI 框线见 [field-governance-plan.md](features/shipping-notice/field-governance-plan.md)。本轮不重做库存履约治理 UI、Excel/RPA、客户识别 UI。
|
||||
|
||||
- 所有 EML、PDF、Word 发货订单共享默认 Schema 族「标准发货通知」(`STANDARD_SHIPPING_NOTICE`)的当前已发布版本;文件类型只决定文本/OCR 技术解析器,不决定字段集合。模型支持多 Schema 族,本轮 UI/运行只启用该默认族。
|
||||
- 所有 EML、PDF、Word 发货订单共享唯一发货订单 Schema「标准发货通知」(`STANDARD_SHIPPING_NOTICE`)的当前已发布版本;文件类型只决定文本/OCR 技术解析器,不决定字段集合。系统不开放多 Schema 族治理;演进仅通过该 Schema 的多版本草稿/发布完成。
|
||||
- **字段资产与 Schema 解耦**:字段资产是全局长期对象;Schema 版本仅「采用」资产并配置版本级识别规则。取消采用不得删除资产。管理端拆为「字段资产库」与「订单 Schema」两个独立入口,不得再把字段 CRUD、Schema 规则与履约策略混在同一页。
|
||||
- **系统标准字段(已锁定 57 项)**:由代码注册表种子,与 `STANDARD_ORDER_FIELD_SPECS` 一致(23 Header + 34 Line)。管理员不可手输标准 `field_code`、不可改 scope/类型/履约语义、不可弃用或物理删除。停用某标准字段语义只能在 Schema 版本取消采用。
|
||||
- **存储分层**:全部已发布字段按稳定 `field_id` 冻结进 Snapshot 的 `header_values_json` / `field_values_json`;其中核心子集额外投影到 Snapshot/Line 强类型列(与现有冻结投影表一致)。强类型列是查询/履约兼容投影,不是标准字段全集边界。
|
||||
@@ -193,9 +193,9 @@
|
||||
- Schema 版本级仅允许编辑:是否采用、显示名、必填、别名、识别说明、标准化、校验、证据策略。版本级禁止改 scope、类型、存储与履约语义。
|
||||
- 草稿保存和发布必须采用乐观锁(`lock_version`);冲突返回 409。发布前必须做影响分析:若目标版本取消采用的字段仍被已发布文档模板、履约策略、库存配置或 Excel 模板引用,必须阻断。已终结历史 Run 只读展示,不阻断发布。
|
||||
- 版本创建/保存/发布/阻断、字段采用/取消采用、扩展创建/弃用/恢复均须追加式审计:操作者、时间、原因(适用时)、请求 ID、前后摘要、影响范围;禁止写入订单正文或证据原文。
|
||||
- 默认族上线后由管理员手动创建草稿;UI 可一键勾选建议采用集(客户 PO、账款客户/地址、送货客户/地址、币种、项次、内部料号、客户料号、要求送货日期、数量、单位、含税金额、预约单号、库存源线索共 15 项),仍须人工填写修改说明并发布;迁移不得自动发布。
|
||||
- 默认 Schema 上线后由管理员手动创建草稿;UI 可一键勾选建议采用集(客户 PO、账款客户/地址、送货客户/地址、币种、项次、内部料号、客户料号、要求送货日期、数量、单位、含税金额、预约单号、库存源线索共 15 项),仍须人工填写修改说明并发布;迁移不得自动发布。
|
||||
- 下游配置一律引用稳定 `field_id`,不引用显示名称。履约核心 `part_number` / `reservation_id` / `qty` 必须绑定系统标准表身字段,禁止绑定扩展字段。
|
||||
- 已接受订单的解析真相为 `ShippingOrderExtraction` 及其 `Decision/FieldValue`;冻结后 `ShippingOrderSnapshot/Line` 是库存、导出、上传的唯一业务真相。Run/Extraction 须冻结 Schema 族、版本、checksum 与完整字段定义;后续资产或契约变更不得污染历史展示与结果。
|
||||
- 已接受订单的解析真相为 `ShippingOrderExtraction` 及其 `Decision/FieldValue`;冻结后 `ShippingOrderSnapshot/Line` 是库存、导出、上传的唯一业务真相。Run/Extraction 须冻结 Schema 编码(`schema_code`)、版本、checksum 与完整字段定义;后续资产或契约变更不得污染历史展示与结果。
|
||||
- 管理端必须使用后端受控选择器;不要求业务管理员直接编辑 Profile/模板 JSON。切换策略:不迁移旧字段规则/Schema/模板与策略绑定;保留历史运行只读;重建配置后再打开新运行入口。
|
||||
- 发货 Excel 模板必须独立版本化管理并由库存源绑定 published 版本;多个同结构库存源共享同一模板,不得在库存源中复制映射。模板发布后文件和映射不可变。
|
||||
- 库存站点允许先以禁用状态保存基础信息,逐步通过测试导出确认库存文件解析方案并绑定 published 发货模板;首次保存不要求手工选择解析方案。正式启用是独立门禁动作,必须完成连接、测试导出与解析验证、解析方案、发货模板和仓库映射;一旦启用,各项绑定必须齐全且有效。固定仓须维护该货代仓的精确映射或库存源默认映射;动态仓还须从测试文件识别仓库栏位并覆盖测试样例中的每个仓库。系统绝不根据名称相似度自动创建外部仓库映射。
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
> **状态**:阶段 0–5 已授权落地(2026-07-29);上线仍按 §5 切换清单执行
|
||||
> **读者**:产品、研发、测试、货代配置管理员
|
||||
> **范围**:字段规则目标态(资产库 + Schema 采用 + 影响门禁 + 运行冻结审计 + 管理端 UI)
|
||||
> **不在本轮**:库存履约治理 UI/决策、Excel/RPA 体验重构、客户识别 UI 深改(G2/G3)、多 Schema 族管理 UI
|
||||
> **不在本轮**:库存履约治理 UI/决策、Excel/RPA 体验重构、客户识别 UI 深改(G2/G3);不开放多 Schema 族管理(系统仅唯一 `STANDARD_SHIPPING_NOTICE`)
|
||||
|
||||
本文是本轮**单一实施计划与验收矩阵**。权威需求/技术口径须与本文件及 [demand.md](../../demand.md)、[tec.md](../../tec.md)、[technical.md](technical.md)、[business.md](business.md) 保持一致。
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
三支柱**同等必要、不可互相替代**:
|
||||
|
||||
1. **领域与数据**:系统标准 57 项 + 扩展资产;Schema 族/版本采用;迁移清空旧配置;历史 Run 只读保留
|
||||
1. **领域与数据**:系统标准 57 项 + 扩展资产;唯一 Schema 多版本采用;迁移清空旧配置;历史 Run 只读保留
|
||||
2. **门禁与审计**:影响分析、发布事务、配置与运行审计不可漂移
|
||||
3. **管理端 UI**:导航拆分、字段资产库、Schema 采用式工作台、影响/审计抽屉(用户可感知主交付;框线必须按线验收)
|
||||
|
||||
@@ -76,7 +76,7 @@ Schema 采用 → Run 冻结 可引用已发布 Header field_id 本
|
||||
| 字段资产 | 全局长期对象;标准或扩展;稳定 `field_id` |
|
||||
| 系统标准字段 | 代码注册的 57 项;不可新建/改形/弃用/删除 |
|
||||
| 扩展字段 | 业务新增;仅 JSON;可弃用/恢复 |
|
||||
| Schema 族 | 逻辑契约族;首期仅 `STANDARD_SHIPPING_NOTICE` |
|
||||
| 发货订单 Schema | 唯一逻辑契约 `STANDARD_SHIPPING_NOTICE`;仅多版本演进,不开放多族 |
|
||||
| Schema 版本 | `draft` / `published` / `retired`;每族最多一个 published |
|
||||
| 采用 | 版本引用某字段资产并附版本级规则;取消采用不删资产 |
|
||||
| 核心投影 | 标准字段子集双写 Snapshot 强类型列 |
|
||||
@@ -262,7 +262,7 @@ Schema 采用 → Run 冻结 可引用已发布 Header field_id 本
|
||||
|
||||
**验收**:标准=57;无 mail 资产;扩展弃用必审;无物理删除;历史 Run 可读。
|
||||
|
||||
### 阶段 2 — Schema 族、版本规则与发布快照
|
||||
### 阶段 2 — 唯一 Schema、版本规则与发布快照
|
||||
|
||||
**目标**:采用式契约后端。
|
||||
|
||||
@@ -300,7 +300,7 @@ Schema 采用 → Run 冻结 可引用已发布 Header field_id 本
|
||||
|
||||
```text
|
||||
停配置写 + 停新冻结
|
||||
→ 迁移(清配置域 / 种子 57 标准资产 / 空 Schema 族 / 保留运行域 / 软化历史 field FK)
|
||||
→ 迁移(清配置域 / 种子 57 标准资产 / 空唯一 Schema / 保留运行域 / 软化历史 field FK)
|
||||
→ 开配置
|
||||
→(UI)可选建扩展 → 创建草稿 → 勾选建议 15 项 → 填写修改说明 → 手动发布 V1
|
||||
→ 重绑模板 / 策略 / 库存映射 / Excel
|
||||
@@ -343,7 +343,7 @@ Schema 采用 → Run 冻结 可引用已发布 Header field_id 本
|
||||
- 库存履约治理 UI / 决策重构
|
||||
- Excel / RPA 配置体验
|
||||
- 客户识别 UI 与证据源 registry 深改(G2/G3)
|
||||
- 多 Schema 族管理 UI
|
||||
- 多 Schema 族管理(已明确不做;固定唯一 Schema)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -899,7 +899,7 @@ SHIPPING_NOTICE_RPA_SHARED_UPLOAD_TRIGGER_DIR=data/shipping_notice/freight_rpa/u
|
||||
**管理端入口(目标 IA)**:后台「货代管理 → 订单识别」拆为独立入口:
|
||||
|
||||
1. **字段资产库** — 系统标准 57 项(只读)+ 扩展字段(新建/弃用/恢复);影响分析与配置审计
|
||||
2. **订单 Schema** — 族/版本采用与版本级识别规则;发布前影响门禁;**无**字段增删、**无**履约策略编辑卡
|
||||
2. **订单 Schema** — 唯一 Schema 的多版本采用与版本级识别规则;发布前影响门禁;**无**字段增删、**无**履约策略编辑卡
|
||||
3. 订单文档模板、客户识别规则、识别任务(客户识别 UI 本轮不改,仅切断「上下文 = 订单字段资产」边界)
|
||||
|
||||
「库存管理」综合工作台**不再嵌入** Schema 页。各页复用 `shipping_inventory` 管理权限。
|
||||
@@ -914,7 +914,7 @@ SHIPPING_NOTICE_RPA_SHARED_UPLOAD_TRIGGER_DIR=data/shipping_notice/freight_rpa/u
|
||||
|
||||
**运行**:`published_version()` / `get_published_contract()` / `published_policy()` 读取唯一 Schema 的 published 版本;Extraction/Run 冻结 schema_code、version、checksum 与完整字段定义;审计详情不回读当前资产。履约策略发布前必须存在已发布 Schema。切换不迁移旧配置;保留历史 Run 只读。
|
||||
|
||||
版本治理、差异、使用追溯、Dify contract 编译等既有能力在目标态下继续以稳定 `field_id` 与冻结定义为准;接口将拆分为字段资产 API 与 Schema 族/版本 API(阶段 1–2 落地)。过渡期兼容路由以实施 PR 为准。
|
||||
版本治理、差异、使用追溯、Dify contract 编译等既有能力在目标态下继续以稳定 `field_id` 与冻结定义为准;接口拆分为字段资产 API 与唯一 Schema 版本 API。过渡期兼容路由以实施 PR 为准。
|
||||
|
||||
字段规则运行语义如下:
|
||||
|
||||
@@ -2098,7 +2098,7 @@ API 层
|
||||
|
||||
### 6.7 字段分层、冻结策略与 Reservation 注册(目标态修订 2026-07-29)
|
||||
|
||||
货代发货订单字段结构为「平台系统事实 → **全局字段资产**(系统标准 57 项锁定 + 扩展)→ Schema 族版本采用 → 字段能力绑定 → 版本化履约策略」。标准目录不是全量固定必填;当前唯一允许的履约策略是 `SHIP_AVAILABLE_ROLLING_V1`。冻结时只检查已采用的 Line `reservation_id:string`、`part_number:string`、`qty:decimal`(严格大于 0)和已人工确认的 Bill-to 客户。核心履约能力只能绑定标准表身字段,禁止扩展字段。管理端「字段资产库 / 订单 Schema」与履约策略编辑解耦;履约治理 UI 重构见后续,详见 [field-governance-plan.md](field-governance-plan.md)。
|
||||
货代发货订单字段结构为「平台系统事实 → **全局字段资产**(系统标准 57 项锁定 + 扩展)→ 唯一 Schema 多版本采用 → 字段能力绑定 → 版本化履约策略」。标准目录不是全量固定必填;当前唯一允许的履约策略是 `SHIP_AVAILABLE_ROLLING_V1`。冻结时只检查已采用的 Line `reservation_id:string`、`part_number:string`、`qty:decimal`(严格大于 0)和已人工确认的 Bill-to 客户。核心履约能力只能绑定标准表身字段,禁止扩展字段。管理端「字段资产库 / 订单 Schema」与履约策略编辑解耦;履约治理 UI 重构见后续,详见 [field-governance-plan.md](field-governance-plan.md)。
|
||||
|
||||
`inventory_source_hint` 保持可选 Line 字段,仅供库存路由从冻结 Snapshot 读取。库存路由禁止回读可变 `FieldValue`。
|
||||
|
||||
@@ -2299,6 +2299,7 @@ Case 状态:`unreviewed`、`draft`、`ready`、`confirming`、`confirmed`、`n
|
||||
- PDF 工具栏采用左侧编辑操作、中间上一页/页码/下一页、右侧缩放操作的固定布局;页码输入支持大页数文档直接跳转,页面标记只按精确页码渲染。
|
||||
- 历史 `all_pages` 草稿缺少原始页码时按第 1 页恢复,重新保存后统一写入 `exact_page + page_no`,避免第 1 页标记泄漏到第 2 页。
|
||||
- 自动标记优先从 PDF 原生文字层补齐字符坐标与页面尺寸,仅在原生文字层为空时调用 OCR;补证结果仍属于待人工复核证据。
|
||||
- 订单级字段的 `anchor` 只用于定位字段、唯一性校验和停止标签上下文;管理员在画布确认的 `absolute_value_region`(归一化页面坐标)是唯一值读取边界,后端不得再按实际匹配到的标签 bbox 投影、缩放或偏移该值框。新草稿必须写入 `absolute_value_region`,不再写入锚点相对的 `value_region`;历史 Profile 的 `value_region` 仅在缺少绝对值框时兼容读取。删除后重新标注也必须直接持久化新的绝对值框,禁止从锚点 bbox 反算,避免零高度、非法偏移及画布与读取结果不一致。多行值仅在绝对值框内按视觉行读取,并在当前锚点后的首个停止标签前截断。
|
||||
- 字段规则新增 `auto_annotation_enabled`:已启用且授权 PDF/OCR 坐标的 Header 字段才生成订单级标签/值框,Line 字段才按 `display_name + aliases` 的唯一精确表头命中生成表头字段框和对应明细字段框。默认仅业务必填、自动建单关键或具名业务用途字段参与;其余可选字段默认关闭,管理员可按需启用。关闭后保留字段的抽取语义和既有模板绑定,但不再参与新的自动标记。多个字段共享同一别名、同一重建列承载多个标签或无精确命中时一律保留未绑定候选并进入人工复核。
|
||||
- 物理行和字段框描述可重复应用的行版式:横向边界用于字段取值;一个物理行包含多条视觉子行时,系统使用首条 `line_no` 锚定明细的真实字符坐标,将字段框校准到实际视觉 band(未标注的描述/备注行仍计入序号),再把同一纵向字段组按严格单调顺序对齐到后续明细。记录出现额外换行时,以 X 命中、注册解析器和有限字段形态辅助选择;最佳候选不唯一时字段留空并记录 `coordinate_profile_field_band_ambiguous`,禁止静默猜测。该机制避免父框留白、行距变化和可变换行造成错位,也防止料号尾数污染数量、单位或日期;覆盖父行全高的旧字段框和多 `row_offset` 模板继续按原兼容链路解析。
|
||||
- 翻页时只选择当前页表格;当前页没有表格时清空表格与局部候选上下文,禁止复用上一页坐标证据。
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@
|
||||
| EML 正文补充表合并(阶段 2) | 已实现 | 正文 HTML 表解析为带 DOM 单元格证据的 PO 级补充事实,不创建独立订单或执行 Unit;按 `PO + MPN`、受限 PO 降级补 Reservation/Allocation/库存来源提示,PDF 数量保持权威,歧义统一进入人工复核 |
|
||||
| PDF 模板 PO 拆分与严格拒识(阶段 3) | 已实现 | 已批准模板中每条明细均有唯一 PO 证据时,单 PDF 自动拆为多个独立订单;表级多 PO 未能归属明细、模板歧义、漂移和证据不足统一转人工复核,Route Decision 分别审计四类表计数 |
|
||||
| 订单模板版本中心(阶段 0-7) | 已实现 | 订单文档模板按 `profile_code` 聚合版本族;已落地独立版本详情、历史只读样本画布、服务端语义差异、审计记录页签、实际使用页签,以及阶段 7 的 blind test 隔离与发布治理 |
|
||||
| 订单模板录入 UX 重构(阶段 0-7) | 已完成 | 已完成 Draft Revision、Lease、向导、独立草稿编辑器自动保存、不可变验证运行与两步发布报告;阶段 7 已删除旧兼容工作台/创建路径和直接发布入口,并完成前后端构建、定向回归、迁移链及四语言校验。Dify 无需配置变更,仅由管理员核对本地确定性解析主链未接入模板治理接口。 |
|
||||
| 订单模板录入 UX 重构(阶段 0-7) | 已完成 | 已完成 Draft Revision、Lease、向导、独立草稿编辑器自动保存、不可变验证运行与两步发布报告;盲测工作台支持独立样本复核、执行与批准,编辑器在可见状态自动续租。阶段 7 已删除旧兼容工作台/创建路径和直接发布入口,并完成前后端构建、定向回归、迁移链及四语言校验。Dify 无需配置变更,仅由管理员核对本地确定性解析主链未接入模板治理接口。 |
|
||||
| 订单人工复核工作台(阶段 0-7) | 已实现 | 每个 PDF Unit 一个 Review Case,机器 Candidate/Extraction 不可变、人工 Draft 独立版本化;按 PDF 独立处置、证据复核与原子确认建单,不支持多订单 PDF 或跨 PDF 合并/拆分。确认后复用同一 `auto_progress` 链 |
|
||||
| **STP 直通 + 例外工作台** | 进行中 | 可信 PDF 自动建 Task 并推进至「待人工上传」;例外进入人工复核/任务处理;Chat 仅上传与通知;`checkpoint_kind` + 可解释 `summary`;我的待办跨会话入口。首期不触发货代 RPA 上传、不改 Dify |
|
||||
| 模板发布与自动冻结资格分离(阶段 4) | 已实现 | Profile 的发布仅允许确定性解析;每个发布版本独立冻结人工确认资格,首版强制 `manual_confirmation` 且自动冻结关闭,盲测批准、旧版本资格或 checksum 变化均不能越过该门禁 |
|
||||
|
||||
+1
-1
@@ -157,7 +157,7 @@
|
||||
- **Schema 与版本**:唯一发货订单 Schema 编码 `STANDARD_SHIPPING_NOTICE`(表结构保留 `schema_code`,暂不开放多族)。版本生命周期 `draft -> published -> retired`;最多一个 published。草稿与发布均以完整 `definition_json` + SHA-256 checksum 为配置真相;发布时冻结完整快照。`lock_version` 乐观锁;冲突 HTTP 409。履约策略发布必须存在 published Schema。
|
||||
- **版本级规则边界**:版本可配置采用开关、显示名、必填、别名、识别/校验/证据;不可覆盖资产的 scope、value_type、storage、履约语义。
|
||||
- **审计**:追加式事件覆盖扩展创建/更新/弃用/恢复、草稿保存、字段采用/取消采用、发布阻断/成功等;仅安全摘要,不传输订单正文。版本 diff 按稳定 `field_id` 比较,显示名变化不得误判为字段删除。
|
||||
- **运行冻结**:`ShippingOrderExtraction` / ExtractionRun 锁定 `family_code`、`schema_version_id`、checksum 与完整字段定义;管理员审计不回读当前资产属性。历史 Run 在配置重建后仍只读可查(依赖冻结 JSON;旧 `field_id` 不要求映射到新资产 UUID)。
|
||||
- **运行冻结**:`ShippingOrderExtraction` / ExtractionRun 锁定 `schema_code`(快照中可兼容保留历史 `family_code` 别名)、`schema_version_id`、checksum 与完整字段定义;管理员审计不回读当前资产属性。历史 Run 在配置重建后仍只读可查(依赖冻结 JSON;旧 `field_id` 不要求映射到新资产 UUID)。
|
||||
- **发布门禁**:发布同事务执行影响分析;已发布文档模板、履约策略、库存 Profile/路由、Excel 模板仍引用将被取消采用的字段时一律阻断(`SHIPPING.FIELD_IMPACT_BLOCKED` 等结构化错误)。已终结历史 Run 不阻断。
|
||||
- **切换**:不迁移旧配置语义;清空配置域并种子标准资产;保留运行域只读。不建设长期双读旧「唯一 Schema 字段目录」模型。
|
||||
- 订单文档 Profile 仍以稳定 `field_id` 为身份;兼容判定与历史冻结语义保持,破坏性字段移除由发布门禁与模板迁移处理。
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
| :--- | :--- | :--- | :--- | :--- | :--- |
|
||||
| **发货通知** | **STP 直通 + 例外工作台契约** | checkpoint_kind / 可解释 summary / 待办分类同源;auto_progress 止于待人工上传且不触发货代 RPA 上传;创建者可处理、管理员只读。 | `test_shipping_notice_state_machine.py`、`test_shipping_notice_ui_state.py`、`test_shipping_notice_query_service.py`(my-todos)、`test_shipping_notice_stp_acceptance.py`、technical.md §1.6 / §3.4 | 可信直通、多 PDF 隔离、人工复核确认后 auto_progress、无证据拒绝人工上传、跨会话待办、禁 RPA 上传 | 任意入口相同 checkpoint/kind/summary/actions;待办深链进入复核或任务处理;四语言与构建通过。 |
|
||||
| **发货通知** | **字段资产库与标准目录** | 全局系统标准 57 项只读;扩展可创建/弃用/恢复;禁止物理删除与 mail/context 入资产;标准不可弃用。 | `test_shipping_field_asset_service.py`、迁移 `1b2c3d4e5f6a`、前端 `shipping-field-assets` 导航单测 | 种子标准、扩展撞标准码、sender_email、无原因弃用、DELETE | 标准=57;扩展 active⇄retired 有审计;409 `FIELD_ASSET_DELETE_FORBIDDEN` / `STANDARD_NO_RETIRE` / `CONTEXT_FORBIDDEN`。 |
|
||||
| **发货通知** | **Schema 采用式契约与建议集** | Schema 族仅采用资产;草稿取消采用不删资产;retired 扩展不可采用;C4 建议 15 项可一键勾选但须手动发布。 | `order_schema/service` 相关测试、`shippingConfigNavigation.spec.ts`、Schema 页采用 UI | 空族初始化、采用建议 15、取消采用、发布 V1 | published 只读;definition 仅含采用字段;建议集不等于自动发布。 |
|
||||
| **发货通知** | **Schema 采用式契约与建议集** | 唯一 Schema 仅采用资产;草稿取消采用不删资产;retired 扩展不可采用;C4 建议 15 项可一键勾选但须手动发布。 | `order_schema/service` 相关测试、`shippingConfigNavigation.spec.ts`、Schema 页采用 UI | 空 Schema 初始化、采用建议 15、取消采用、发布 V1 | published 只读;definition 仅含采用字段;建议集不等于自动发布。 |
|
||||
| **发货通知** | **字段影响分析与发布门禁** | 取消采用或弃用前汇总下游引用;配置引用阻断,历史 Run 只读不阻断;发布同事务写 checksum。 | `test_field_impact_analysis.py`、Schema publish API | Excel/模板仍引用 field_id、历史 Observation 仅提示、lock 冲突 | 409 `FIELD_IMPACT_BLOCKED`/`publish_blocked` 审计;无阻断时可发布。 |
|
||||
| **发货通知** | **履约核心字段拒扩展** | 履约核心能力仅允许系统标准行字段(part_number/reservation_id/qty 等)。 | `fulfillment_policy_registry` 校验、相关服务测试 | 扩展字段绑 `fulfillment.part_number` | 拒绝 `SHIPPING.FULFILLMENT_FIELD_INVALID`。 |
|
||||
| **发货通知** | **Run 冻结族/版本可追溯** | Run input snapshot 固化 schema_code/family_code/version/checksum/definition;新旧 Run 隔离、历史可回查。 | `test_shipping_order_extraction_runs.py`、`order_extraction_run_service` | 发布后改草稿再发新 Run、读旧 Run | 旧 Run checksum/definition 不变;快照含 family_code。 |
|
||||
| **发货通知** | **Run 冻结版本可追溯** | Run input snapshot 固化 schema_code/version/checksum/definition(兼容字段可含历史 family_code);新旧 Run 隔离、历史可回查。 | `test_shipping_order_extraction_runs.py`、`order_extraction_run_service` | 发布后改草稿再发新 Run、读旧 Run | 旧 Run checksum/definition 不变;快照含 schema_code。 |
|
||||
| **发货通知** | **订单坐标 Profile v2 工作台与表头建议** | 画布按页受控加载,物理行与字段区域可编辑;表头建议只使用唯一 Schema 别名。 | `test_shipping_coordinate_table_reconstruction.py`、`test_shipping_order_document_profile.py`、前端 `vue-tsc`/build。 | 多页 PDF、10 条物理行、50 个字段区域、重复 `Part No.`、缺失表头、拖动/缩放/撤销。 | 单页令牌不复用;保存为连续 main/continuation 布局;歧义表头不自动绑定;建议固定 `needs_review` 且不泄露 bbox/HTML。 |
|
||||
|
||||
| 功能分类 | 功能子项 | 功能描述 | 测试代码撰写要求 | 测试输入数据 (示例) | 预期测试输出 (示例) |
|
||||
|
||||
@@ -67,6 +67,8 @@ const OrderProfileEditorRoutePage = () =>
|
||||
import("@/features/admin/modules/shipping-order-document-profiles/OrderProfileEditorRoutePage.vue");
|
||||
const OrderProfileValidationPage = () =>
|
||||
import("@/features/admin/modules/shipping-order-document-profiles/OrderProfileValidationPage.vue");
|
||||
const OrderProfileBlindTestPage = () =>
|
||||
import("@/features/admin/modules/shipping-order-document-profiles/OrderProfileBlindTestPage.vue");
|
||||
const OrderProfilePublishCheckPage = () =>
|
||||
import("@/features/admin/modules/shipping-order-document-profiles/OrderProfilePublishCheckPage.vue");
|
||||
|
||||
@@ -222,6 +224,12 @@ export const adminRoutes: RouteRecordRaw[] = [
|
||||
component: OrderProfileValidationPage,
|
||||
meta: { requiresAdmin: true, adminModule: "shipping_inventory", adminSubModule: 'order_document_profiles', title: "验证订单文档模板" },
|
||||
},
|
||||
{
|
||||
path: "shipping-order-document-profiles/:profileCode/drafts/:profileId/blind-test",
|
||||
name: "AdminShippingOrderDocumentProfileBlindTest",
|
||||
component: OrderProfileBlindTestPage,
|
||||
meta: { requiresAdmin: true, adminModule: "shipping_inventory", adminSubModule: 'order_document_profiles', title: "订单文档模板盲测" },
|
||||
},
|
||||
{
|
||||
path: "shipping-order-document-profiles/:profileCode/drafts/:profileId/publish-check",
|
||||
name: "AdminShippingOrderDocumentProfilePublishCheck",
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
* 用途:单一发货订单 Schema 管理 JSON API。
|
||||
* 依赖:shared/api/client、shared/utils/auth、订单 Schema DTO。
|
||||
* 逻辑:页面加载状态、维护草稿与发布版本;无多族参数。
|
||||
* 自动建单写操作经草稿 PUT;GET /auto-creation-policy 仅读已发布生效值。
|
||||
*/
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
@@ -17,8 +18,6 @@ import type {
|
||||
ShippingOrderSchemaVersionPage,
|
||||
ShippingOrderSchemaVersionUsage,
|
||||
ShippingOrderSchemaProfileImpact,
|
||||
ShippingFulfillmentPolicy,
|
||||
ShippingFulfillmentPolicyState,
|
||||
} from '../types/shipping-order-schema.types';
|
||||
|
||||
const auth = () => ({ headers: getAuthHeaders() });
|
||||
@@ -196,41 +195,3 @@ export const publishShippingOrderSchemaDraft = (
|
||||
...jsonAuth(),
|
||||
},
|
||||
);
|
||||
|
||||
/** 读取受控履约能力目录及策略版本,页面不提供任意表达式配置。 */
|
||||
export const getShippingFulfillmentPolicyState = () =>
|
||||
requestJson<ShippingFulfillmentPolicyState>(
|
||||
'/api/admin/shipping-fulfillment-policies',
|
||||
auth(),
|
||||
);
|
||||
|
||||
/** 创建按稳定字段 ID 绑定的下一履约策略草稿。 */
|
||||
export const createShippingFulfillmentPolicyDraft = (
|
||||
payload: {
|
||||
field_bindings: Array<{ capability_code: string; field_id: string }>;
|
||||
change_note?: string;
|
||||
},
|
||||
) => requestJson<ShippingFulfillmentPolicy>(
|
||||
'/api/admin/shipping-fulfillment-policies',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
...jsonAuth(),
|
||||
},
|
||||
);
|
||||
|
||||
/** 显式发布策略草稿;服务端原子退役上一发布版本。 */
|
||||
export const publishShippingFulfillmentPolicy = (
|
||||
policyId: number,
|
||||
expectedLockVersion: number,
|
||||
) =>
|
||||
requestJson<ShippingFulfillmentPolicy>(
|
||||
`/api/admin/shipping-fulfillment-policies/${policyId}/publish`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify({
|
||||
expected_lock_version: expectedLockVersion,
|
||||
}),
|
||||
...jsonAuth(),
|
||||
},
|
||||
);
|
||||
+147
-69
@@ -276,32 +276,127 @@ function auditEventLabel(eventType: string): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算审计前后快照的顶层属性差异,优先给管理员看变更摘要。
|
||||
* 计算审计前后快照的属性级差异行,对象/数组展开为可读业务摘要。
|
||||
* @param before - 变更前快照
|
||||
* @param after - 变更后快照
|
||||
* @returns 发生变更的属性列表
|
||||
* @returns 差异行(路径 + 格式化前后值)
|
||||
*/
|
||||
function snapshotPropertyDiffs(
|
||||
before: Record<string, unknown> | null | undefined,
|
||||
after: Record<string, unknown> | null | undefined,
|
||||
): Array<{ key: string; before: unknown; after: unknown }> {
|
||||
const left = before && typeof before === 'object' ? before : {};
|
||||
const right = after && typeof after === 'object' ? after : {};
|
||||
const keys = new Set([...Object.keys(left), ...Object.keys(right)]);
|
||||
return [...keys]
|
||||
.sort()
|
||||
.filter((key) => JSON.stringify(left[key]) !== JSON.stringify(right[key]))
|
||||
.map((key) => ({ key, before: left[key], after: right[key] }));
|
||||
): Array<{ key: string; label: string; before: string; after: string }> {
|
||||
const left = before && typeof before === 'object' && !Array.isArray(before) ? before : {};
|
||||
const right = after && typeof after === 'object' && !Array.isArray(after) ? after : {};
|
||||
return flattenObjectDiffs(left, right);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将快照属性值格式化为短文本;复杂对象缩略为 JSON。
|
||||
* 将属性路径映射为业务标签;未知路径回退为路径本身。
|
||||
* @param path - 点分属性路径
|
||||
*/
|
||||
function formatSnapshotValue(value: unknown): string {
|
||||
function auditPropertyLabel(path: string): string {
|
||||
const leaf = path.replace(/\[\d+\]/g, '').split('.').filter(Boolean).pop() || path;
|
||||
const key = `admin.shippingFieldAssets.auditProperty.${leaf}`;
|
||||
const translated = t(key);
|
||||
return translated !== key ? translated : path;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归展开两个对象的差异;数组与标量在叶节点格式化。
|
||||
* @param before - 变更前对象
|
||||
* @param after - 变更后对象
|
||||
* @param prefix - 当前路径前缀
|
||||
*/
|
||||
function flattenObjectDiffs(
|
||||
before: Record<string, unknown>,
|
||||
after: Record<string, unknown>,
|
||||
prefix = '',
|
||||
): Array<{ key: string; label: string; before: string; after: string }> {
|
||||
const keys = new Set([...Object.keys(before), ...Object.keys(after)]);
|
||||
const rows: Array<{ key: string; label: string; before: string; after: string }> = [];
|
||||
for (const key of [...keys].sort()) {
|
||||
const path = prefix ? `${prefix}.${key}` : key;
|
||||
const left = before[key];
|
||||
const right = after[key];
|
||||
if (JSON.stringify(left) === JSON.stringify(right)) continue;
|
||||
|
||||
const bothPlainObjects = isPlainObject(left) && isPlainObject(right);
|
||||
if (bothPlainObjects) {
|
||||
rows.push(...flattenObjectDiffs(left as Record<string, unknown>, right as Record<string, unknown>, path));
|
||||
continue;
|
||||
}
|
||||
|
||||
// 同构对象数组:按索引展开子属性,便于识别批量排序/条目变更。
|
||||
if (Array.isArray(left) && Array.isArray(right) && left.every(isPlainObject) && right.every(isPlainObject)) {
|
||||
const max = Math.max(left.length, right.length);
|
||||
if (left.length !== right.length) {
|
||||
rows.push({
|
||||
key: `${path}.length`,
|
||||
label: t('admin.shippingFieldAssets.auditArrayLength', { path: auditPropertyLabel(path) }),
|
||||
before: String(left.length),
|
||||
after: String(right.length),
|
||||
});
|
||||
}
|
||||
for (let index = 0; index < max; index += 1) {
|
||||
const itemBefore = (left[index] as Record<string, unknown> | undefined) || {};
|
||||
const itemAfter = (right[index] as Record<string, unknown> | undefined) || {};
|
||||
if (JSON.stringify(itemBefore) === JSON.stringify(itemAfter)) continue;
|
||||
rows.push(...flattenObjectDiffs(itemBefore, itemAfter, `${path}[${index}]`));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
rows.push({
|
||||
key: path,
|
||||
label: auditPropertyLabel(path),
|
||||
before: formatBusinessValue(left),
|
||||
after: formatBusinessValue(right),
|
||||
});
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为可展开的普通对象(排除数组与 null)。
|
||||
*/
|
||||
function isPlainObject(value: unknown): value is Record<string, unknown> {
|
||||
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将审计属性值格式化为业务可读短文案。
|
||||
* @param value - 任意快照值
|
||||
*/
|
||||
function formatBusinessValue(value: unknown): string {
|
||||
if (value === undefined) return '—';
|
||||
if (value === null) return 'null';
|
||||
if (typeof value === 'string') return value || '""';
|
||||
if (typeof value === 'number' || typeof value === 'boolean') return String(value);
|
||||
if (value === null) return t('admin.shippingFieldAssets.auditValueNull');
|
||||
if (typeof value === 'boolean') {
|
||||
return value
|
||||
? t('admin.shippingFieldAssets.auditValueYes')
|
||||
: t('admin.shippingFieldAssets.auditValueNo');
|
||||
}
|
||||
if (typeof value === 'string') return value.trim() ? value : t('admin.shippingFieldAssets.auditValueEmpty');
|
||||
if (typeof value === 'number') return String(value);
|
||||
if (Array.isArray(value)) {
|
||||
if (!value.length) return t('admin.shippingFieldAssets.auditValueEmptyList');
|
||||
if (value.every((item) => typeof item === 'string' || typeof item === 'number' || typeof item === 'boolean')) {
|
||||
return value.map((item) => formatBusinessValue(item)).join('、');
|
||||
}
|
||||
return t('admin.shippingFieldAssets.auditValueObjectList', { count: value.length });
|
||||
}
|
||||
if (isPlainObject(value)) {
|
||||
const entries = Object.entries(value);
|
||||
if (!entries.length) return t('admin.shippingFieldAssets.auditValueEmpty');
|
||||
// 浅对象:列出关键键值,避免整段压缩 JSON。
|
||||
const preferred = ['field_code', 'display_name', 'display_name_default', 'status', 'scope', 'value_type', 'action', 'reason'];
|
||||
const ordered = [
|
||||
...preferred.filter((key) => key in value),
|
||||
...entries.map(([key]) => key).filter((key) => !preferred.includes(key)),
|
||||
].slice(0, 6);
|
||||
return ordered
|
||||
.map((key) => `${auditPropertyLabel(key)}=${formatBusinessValue(value[key])}`)
|
||||
.join(' · ');
|
||||
}
|
||||
try {
|
||||
return JSON.stringify(value);
|
||||
} catch {
|
||||
@@ -380,13 +475,10 @@ onMounted(() => {
|
||||
<section class="mx-auto max-w-7xl space-y-6 p-6">
|
||||
<header class="page-header">
|
||||
<div>
|
||||
<p class="text-xs font-bold uppercase tracking-widest text-brand-600">
|
||||
{{ t('admin.shippingFieldAssets.eyebrow') }}
|
||||
</p>
|
||||
<h1 class="mt-2 text-2xl font-bold text-primary">{{ t('admin.shippingFieldAssets.title') }}</h1>
|
||||
<p class="mt-2 text-sm text-muted">{{ t('admin.shippingFieldAssets.subtitle') }}</p>
|
||||
<h1 class="section-title">{{ t('admin.shippingFieldAssets.title') }}</h1>
|
||||
<p class="section-desc mt-1">{{ t('admin.shippingFieldAssets.subtitle') }}</p>
|
||||
</div>
|
||||
<button type="button" class="primary-button" @click="showCreate = true">
|
||||
<button type="button" class="btn-primary" @click="showCreate = true">
|
||||
{{ t('admin.shippingFieldAssets.createExtension') }}
|
||||
</button>
|
||||
</header>
|
||||
@@ -395,21 +487,21 @@ onMounted(() => {
|
||||
<input
|
||||
v-model="q"
|
||||
type="search"
|
||||
class="toolbar-input"
|
||||
class="input-field toolbar-input"
|
||||
:placeholder="t('admin.shippingFieldAssets.search')"
|
||||
@keyup.enter="loadList"
|
||||
>
|
||||
<select v-model="kindFilter" class="toolbar-select" @change="loadList">
|
||||
<select v-model="kindFilter" class="select-field toolbar-select" @change="loadList">
|
||||
<option value="">{{ t('admin.shippingFieldAssets.kindAll') }}</option>
|
||||
<option value="system_standard">{{ t('admin.shippingFieldAssets.kindStandard') }}</option>
|
||||
<option value="extension">{{ t('admin.shippingFieldAssets.kindExtension') }}</option>
|
||||
</select>
|
||||
<select v-model="statusFilter" class="toolbar-select" @change="loadList">
|
||||
<select v-model="statusFilter" class="select-field toolbar-select" @change="loadList">
|
||||
<option value="">{{ t('admin.shippingFieldAssets.statusAll') }}</option>
|
||||
<option value="active">{{ t('admin.shippingFieldAssets.statusActive') }}</option>
|
||||
<option value="retired">{{ t('admin.shippingFieldAssets.statusRetired') }}</option>
|
||||
</select>
|
||||
<button type="button" class="secondary-button" :disabled="loading" @click="loadList">
|
||||
<button type="button" class="btn-secondary btn-sm" :disabled="loading" @click="loadList">
|
||||
{{ t('admin.shippingFieldAssets.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
@@ -532,20 +624,20 @@ onMounted(() => {
|
||||
<div class="section-card edit-card">
|
||||
<label>
|
||||
<span>{{ t('admin.shippingFieldAssets.displayName') }}</span>
|
||||
<input v-model="editName" type="text">
|
||||
<input v-model="editName" class="input-field" type="text">
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t('admin.shippingFieldAssets.semantic') }}</span>
|
||||
<textarea v-model="editSemantic" rows="3" />
|
||||
<textarea v-model="editSemantic" class="input-field" rows="3" />
|
||||
</label>
|
||||
<div class="actions">
|
||||
<button type="button" class="secondary-button" :disabled="saving" @click="saveExtensionMeta">
|
||||
<button type="button" class="btn-secondary btn-sm" :disabled="saving" @click="saveExtensionMeta">
|
||||
{{ t('admin.shippingFieldAssets.saveMeta') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="selected.status === 'active'"
|
||||
type="button"
|
||||
class="danger-button"
|
||||
class="btn-danger btn-sm"
|
||||
:disabled="saving"
|
||||
@click="openReasonDialog('retire')"
|
||||
>
|
||||
@@ -554,7 +646,7 @@ onMounted(() => {
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="secondary-button"
|
||||
class="btn-secondary btn-sm"
|
||||
:disabled="saving"
|
||||
@click="openReasonDialog('restore')"
|
||||
>
|
||||
@@ -611,10 +703,10 @@ onMounted(() => {
|
||||
v-for="diff in snapshotPropertyDiffs(event.before, event.after)"
|
||||
:key="`${event.id}-${diff.key}`"
|
||||
>
|
||||
<code>{{ diff.key }}</code>
|
||||
<span>{{ formatSnapshotValue(diff.before) }}</span>
|
||||
<strong>{{ diff.label }}</strong>
|
||||
<span>{{ diff.before }}</span>
|
||||
<span aria-hidden="true">→</span>
|
||||
<span>{{ formatSnapshotValue(diff.after) }}</span>
|
||||
<span>{{ diff.after }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
<details v-if="event.before || event.after" class="audit-snap">
|
||||
@@ -637,26 +729,26 @@ onMounted(() => {
|
||||
<div class="impact-dialog">
|
||||
<header>
|
||||
<h2>{{ t('admin.shippingFieldAssets.createExtension') }}</h2>
|
||||
<button type="button" class="text-button" @click="showCreate = false">{{ t('admin.shippingFieldAssets.cancel') }}</button>
|
||||
<button type="button" class="btn-ghost btn-sm" @click="showCreate = false">{{ t('admin.shippingFieldAssets.cancel') }}</button>
|
||||
</header>
|
||||
<label>
|
||||
<span>{{ t('admin.shippingFieldAssets.fieldCode') }}</span>
|
||||
<input v-model="createForm.field_code">
|
||||
<input v-model="createForm.field_code" class="input-field">
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t('admin.shippingFieldAssets.displayName') }}</span>
|
||||
<input v-model="createForm.display_name">
|
||||
<input v-model="createForm.display_name" class="input-field">
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t('admin.shippingFieldAssets.scope') }}</span>
|
||||
<select v-model="createForm.scope">
|
||||
<select v-model="createForm.scope" class="select-field">
|
||||
<option value="header">header</option>
|
||||
<option value="line">line</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t('admin.shippingFieldAssets.valueType') }}</span>
|
||||
<select v-model="createForm.value_type">
|
||||
<select v-model="createForm.value_type" class="select-field">
|
||||
<option value="string">string</option>
|
||||
<option value="decimal">decimal</option>
|
||||
<option value="integer">integer</option>
|
||||
@@ -667,11 +759,11 @@ onMounted(() => {
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t('admin.shippingFieldAssets.semantic') }}</span>
|
||||
<textarea v-model="createForm.semantic_description" rows="3" />
|
||||
<textarea v-model="createForm.semantic_description" class="input-field" rows="3" />
|
||||
</label>
|
||||
<footer>
|
||||
<button type="button" class="secondary-button" @click="showCreate = false">{{ t('admin.shippingFieldAssets.cancel') }}</button>
|
||||
<button type="button" class="primary-button" :disabled="saving" @click="submitCreate">{{ t('admin.shippingFieldAssets.confirm') }}</button>
|
||||
<button type="button" class="btn-secondary" @click="showCreate = false">{{ t('admin.shippingFieldAssets.cancel') }}</button>
|
||||
<button type="button" class="btn-primary" :disabled="saving" @click="submitCreate">{{ t('admin.shippingFieldAssets.confirm') }}</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
@@ -680,7 +772,7 @@ onMounted(() => {
|
||||
<div class="impact-dialog">
|
||||
<header>
|
||||
<h2>{{ reasonAction === 'retire' ? t('admin.shippingFieldAssets.retire') : t('admin.shippingFieldAssets.restore') }}</h2>
|
||||
<button type="button" class="text-button" @click="showReasonDialog = false">{{ t('admin.shippingFieldAssets.cancel') }}</button>
|
||||
<button type="button" class="btn-ghost btn-sm" @click="showReasonDialog = false">{{ t('admin.shippingFieldAssets.cancel') }}</button>
|
||||
</header>
|
||||
<p class="muted">{{ t('admin.shippingFieldAssets.reasonHint') }}</p>
|
||||
<template v-if="reasonAction === 'retire'">
|
||||
@@ -697,10 +789,10 @@ onMounted(() => {
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
<textarea v-model="reasonText" rows="4" />
|
||||
<textarea v-model="reasonText" class="input-field" rows="4" />
|
||||
<footer>
|
||||
<button type="button" class="secondary-button" @click="showReasonDialog = false">{{ t('admin.shippingFieldAssets.cancel') }}</button>
|
||||
<button type="button" class="primary-button" :disabled="saving" @click="submitReasonAction">{{ t('admin.shippingFieldAssets.confirm') }}</button>
|
||||
<button type="button" class="btn-secondary" @click="showReasonDialog = false">{{ t('admin.shippingFieldAssets.cancel') }}</button>
|
||||
<button type="button" class="btn-primary" :disabled="saving" @click="submitReasonAction">{{ t('admin.shippingFieldAssets.confirm') }}</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
@@ -709,22 +801,9 @@ onMounted(() => {
|
||||
|
||||
<style scoped>
|
||||
.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
|
||||
.primary-button, .secondary-button, .danger-button, .text-button {
|
||||
border: 0; border-radius: 6px; padding: 8px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
|
||||
}
|
||||
.primary-button { background: #0ea5e9; color: #fff; }
|
||||
.secondary-button { border: 1px solid #d7e0ea; background: #fff; color: #475569; }
|
||||
.danger-button { border: 1px solid #fca5a5; background: #fff; color: #b91c1c; }
|
||||
.text-button { background: transparent; color: #64748b; }
|
||||
.primary-button:disabled, .secondary-button:disabled, .danger-button:disabled { cursor: not-allowed; opacity: .55; }
|
||||
|
||||
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
||||
.toolbar-input, .toolbar-select {
|
||||
min-width: 160px; border: 1px solid #d9e2ec; border-radius: 6px; background: #fff;
|
||||
padding: 7px 9px; color: #334155; font: inherit; font-size: 12px; outline: none;
|
||||
}
|
||||
.toolbar-input, .toolbar-select { min-width: 160px; padding: 7px 9px; font: inherit; font-size: 12px; }
|
||||
.toolbar-input { min-width: 220px; flex: 1 1 220px; }
|
||||
.toolbar-input:focus, .toolbar-select:focus { border-color: #38bdf8; box-shadow: 0 0 0 2px rgb(56 189 248 / 12%); }
|
||||
|
||||
.assets-workbench {
|
||||
display: grid; height: min(700px, calc(100vh - 280px)); min-height: 540px;
|
||||
@@ -796,14 +875,7 @@ onMounted(() => {
|
||||
.edit-card label, .impact-dialog label {
|
||||
display: grid; gap: 5px; color: #64748b; font-size: 12px;
|
||||
}
|
||||
.edit-card input, .edit-card textarea, .impact-dialog input, .impact-dialog select, .impact-dialog textarea {
|
||||
min-width: 0; border: 1px solid #d9e2ec; border-radius: 6px; background: #fff;
|
||||
padding: 8px 9px; color: #334155; font: inherit; font-size: 13px; outline: none;
|
||||
}
|
||||
.edit-card input:focus, .edit-card textarea:focus, .impact-dialog input:focus,
|
||||
.impact-dialog select:focus, .impact-dialog textarea:focus {
|
||||
border-color: #38bdf8; box-shadow: 0 0 0 2px rgb(56 189 248 / 12%);
|
||||
}
|
||||
.edit-card .input-field, .impact-dialog .input-field, .impact-dialog .select-field { min-width: 0; padding: 8px 9px; font: inherit; font-size: 13px; }
|
||||
.actions, .impact-dialog footer { display: flex; flex-wrap: wrap; gap: 8px; }
|
||||
.impact-dialog footer { justify-content: flex-end; }
|
||||
.link-list, .plain-list { margin: 0; padding-left: 1.1rem; color: #475569; font-size: 13px; }
|
||||
@@ -827,10 +899,16 @@ onMounted(() => {
|
||||
}
|
||||
.audit-diff-list li {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(88px, auto) 1fr auto 1fr;
|
||||
grid-template-columns: minmax(96px, 1.1fr) 1fr auto 1fr;
|
||||
gap: 6px;
|
||||
align-items: start;
|
||||
}
|
||||
.audit-diff-list strong {
|
||||
color: #0f766e;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
word-break: break-word;
|
||||
}
|
||||
.audit-diff-list code { color: #0f766e; font-size: 11px; word-break: break-all; }
|
||||
.audit-item { border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; padding: 10px 12px; }
|
||||
.audit-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
|
||||
@@ -843,7 +921,7 @@ onMounted(() => {
|
||||
|
||||
.impact-overlay {
|
||||
position: fixed; z-index: 60; inset: 0; display: grid; place-items: center;
|
||||
background: rgb(15 23 42 / .42); padding: 24px;
|
||||
background: var(--overlay-soft); padding: 24px;
|
||||
}
|
||||
.impact-dialog {
|
||||
display: grid; width: min(520px, 96vw); max-height: 82vh; gap: 14px; overflow: auto;
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@ function openAdminPath(item: ShippingFieldImpactItem): void {
|
||||
<aside class="impact-drawer" role="dialog" aria-modal="true">
|
||||
<header>
|
||||
<h2>{{ t('admin.shippingFieldAssets.impactTitle') }}</h2>
|
||||
<button type="button" class="text-button" @click="$emit('update:modelValue', false)">{{ t('common.close') }}</button>
|
||||
<button type="button" class="btn-ghost btn-sm" @click="$emit('update:modelValue', false)">{{ t('common.close') }}</button>
|
||||
</header>
|
||||
<div v-if="loading" class="impact-loading">{{ t('common.loading') }}</div>
|
||||
<template v-else-if="impact">
|
||||
@@ -102,7 +102,7 @@ function openAdminPath(item: ShippingFieldImpactItem): void {
|
||||
.impact-drawer header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
||||
.impact-drawer h2, .impact-drawer h3 { margin: 0; color: #1e293b; font-size: 15px; }
|
||||
.impact-drawer h3 { font-size: 13px; }
|
||||
.text-button, .link-button { border: 0; background: transparent; color: #64748b; font: inherit; font-size: 13px; cursor: pointer; }
|
||||
.link-button { border: 0; background: transparent; color: #64748b; font: inherit; font-size: 13px; cursor: pointer; }
|
||||
.link-button { color: #1d4ed8; padding: 0; text-align: left; }
|
||||
.impact-loading, .muted { color: #64748b; font-size: 13px; }
|
||||
.impact-section { border: 1px solid #e2e8f0; border-radius: 8px; padding: 12px; overflow-y: auto; }
|
||||
|
||||
+6
-7
@@ -8,7 +8,7 @@
|
||||
import { computed, onMounted, reactive, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ArrowUpRight, Check, CircleDotDashed, CircleHelp, FileCheck2, Layers3, Plus, Send, Tags, Workflow } from 'lucide-vue-next';
|
||||
import { ArrowUpRight, Check, CircleDotDashed, CircleHelp, FileCheck2, Layers3, Plus, Send, Tags } from 'lucide-vue-next';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
@@ -211,9 +211,8 @@ onMounted(() => { void load(); });
|
||||
<section class="identity-rules-page">
|
||||
<header class="identity-hero">
|
||||
<div>
|
||||
<p class="identity-kicker"><Workflow class="h-4 w-4" />{{ t('admin.shippingIdentityRules.eyebrow') }}</p>
|
||||
<h2>{{ t('admin.shippingIdentityRules.title') }}</h2>
|
||||
<p>{{ t('admin.shippingIdentityRules.subtitle') }}</p>
|
||||
<h1 class="section-title">{{ t('admin.shippingIdentityRules.title') }}</h1>
|
||||
<p class="section-desc mt-1">{{ t('admin.shippingIdentityRules.subtitle') }}</p>
|
||||
</div>
|
||||
<div class="identity-hero__meta">
|
||||
<div class="identity-hero__status">
|
||||
@@ -313,9 +312,9 @@ onMounted(() => { void load(); });
|
||||
<style scoped>
|
||||
.identity-rules-page { max-width: 1380px; margin: 0 auto; display: grid; gap: 1.25rem; color: #183253; }
|
||||
.identity-hero { display: flex; align-items: end; justify-content: space-between; gap: 2rem; padding: .5rem .25rem .75rem; }
|
||||
.identity-kicker, .identity-panel__eyebrow { display: flex; align-items: center; gap: .45rem; color: #0d8ac6; font-size: .76rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
|
||||
.identity-hero h2 { margin: .35rem 0; color: #102a43; font-size: clamp(1.65rem, 2.5vw, 2.2rem); font-weight: 800; letter-spacing: -.045em; }
|
||||
.identity-hero p:not(.identity-kicker) { max-width: 760px; color: #6d829c; font-size: .93rem; line-height: 1.65; }
|
||||
.identity-panel__eyebrow { display: flex; align-items: center; gap: .45rem; color: #475569; font-size: .76rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
|
||||
.identity-hero h1 { margin: 0; }
|
||||
.identity-hero p { max-width: 760px; }
|
||||
.identity-hero__meta { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; justify-content: flex-end; }
|
||||
.identity-hero__status { display: inline-flex; align-items: center; gap: .48rem; padding: .5rem .75rem; border: 1px solid #bfe7f8; border-radius: 999px; background: #effaff; color: #087aaa; font-size: .78rem; font-weight: 700; white-space: nowrap; }
|
||||
.identity-pulse { width: .5rem; height: .5rem; border-radius: 50%; background: #18b17c; box-shadow: 0 0 0 4px #dff8ed; }.identity-pulse--draft { background: #e09b22; box-shadow: 0 0 0 4px #fff2d5; }
|
||||
|
||||
+109
-136
@@ -6,20 +6,6 @@
|
||||
-->
|
||||
<template>
|
||||
<section class="inventory-console">
|
||||
<header class="console-header">
|
||||
<div>
|
||||
<p class="eyebrow">{{ t('admin.shippingInventory.eyebrow') }}</p>
|
||||
<h1>{{ t('admin.shippingInventory.title') }}</h1>
|
||||
<p>{{ t('admin.shippingInventory.subtitle') }}</p>
|
||||
</div>
|
||||
<div class="flow-strip" aria-label="Shipping configuration flow">
|
||||
<span>{{ t('admin.shippingInventory.flowOrder') }}</span><i>→</i>
|
||||
<span>{{ t('admin.shippingInventory.flowInventory') }}</span><i>→</i>
|
||||
<span>{{ t('admin.shippingInventory.flowTemplate') }}</span><i>→</i>
|
||||
<span>{{ t('admin.shippingInventory.flowRoute') }}</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="console-layout">
|
||||
<main class="workbench">
|
||||
<div class="workbench-heading">
|
||||
@@ -28,9 +14,9 @@
|
||||
<p>{{ t(currentSection.helpKey) }}</p>
|
||||
</div>
|
||||
<div class="workbench-actions">
|
||||
<button v-if="activeTab === 'sources'" type="button" class="secondary-action" @click="openBulkParsingBinding">{{ t('admin.shippingInventory.bulkBindParsingProfile') }}</button>
|
||||
<button v-if="activeTab === 'sources'" type="button" class="secondary-action" @click="openBatchValidation">{{ t('admin.shippingInventory.batchValidation') }}</button>
|
||||
<button v-if="isEditableTab" type="button" class="primary-action" @click="createNew">
|
||||
<button v-if="activeTab === 'sources'" type="button" class="btn-secondary btn-sm" @click="openBulkParsingBinding">{{ t('admin.shippingInventory.bulkBindParsingProfile') }}</button>
|
||||
<button v-if="activeTab === 'sources'" type="button" class="btn-secondary btn-sm" @click="openBatchValidation">{{ t('admin.shippingInventory.batchValidation') }}</button>
|
||||
<button v-if="isEditableTab" type="button" class="btn-primary" @click="createNew">
|
||||
{{ t('admin.shippingInventory.createNew') }}
|
||||
</button>
|
||||
</div>
|
||||
@@ -105,26 +91,26 @@
|
||||
|
||||
<form class="editor-form" autocomplete="off" @submit.prevent="saveCurrent">
|
||||
<template v-if="activeTab === 'profiles'">
|
||||
<label><span>{{ t('admin.shippingInventory.connectionCode') }}</span><input v-model="profile.profile_code" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.connectionName') }}</span><input v-model="profile.display_name" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.connectorType') }}</span><select v-model="profile.connector_type"><option value="dbs">{{ t('admin.shippingInventory.platform.dbs') }}</option><option value="crane">{{ t('admin.shippingInventory.platform.crane') }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.loginUrl') }}</span><input v-model="profile.login_url" type="url" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.username') }}</span><input v-model="profile.username" name="shipping-rpa-credential-user" autocomplete="one-time-code" readonly :placeholder="t('admin.shippingInventory.writeOnlyHint')" @focus="unlockCredentialField"></label>
|
||||
<label><span>{{ t('admin.shippingInventory.password') }}</span><input v-model="profile.password" name="shipping-rpa-credential-password" type="password" autocomplete="new-password" readonly :placeholder="t('admin.shippingInventory.writeOnlyHint')" @focus="unlockCredentialField"></label>
|
||||
<label><span>{{ t('admin.shippingInventory.connectionCode') }}</span><input v-model="profile.profile_code" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.connectionName') }}</span><input v-model="profile.display_name" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.connectorType') }}</span><select v-model="profile.connector_type" class="select-field"><option value="dbs">{{ t('admin.shippingInventory.platform.dbs') }}</option><option value="crane">{{ t('admin.shippingInventory.platform.crane') }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.loginUrl') }}</span><input v-model="profile.login_url" class="input-field" type="url" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.username') }}</span><input v-model="profile.username" class="input-field" name="shipping-rpa-credential-user" autocomplete="one-time-code" readonly :placeholder="t('admin.shippingInventory.writeOnlyHint')" @focus="unlockCredentialField"></label>
|
||||
<label><span>{{ t('admin.shippingInventory.password') }}</span><input v-model="profile.password" class="input-field" name="shipping-rpa-credential-password" type="password" autocomplete="new-password" readonly :placeholder="t('admin.shippingInventory.writeOnlyHint')" @focus="unlockCredentialField"></label>
|
||||
<div class="switch-field"><span>{{ t('admin.shippingInventory.enabled') }}</span><button type="button" class="status-switch" :class="{ on: profile.enabled }" role="switch" :aria-checked="profile.enabled" @click="profile.enabled = !profile.enabled"><i></i><b>{{ profile.enabled ? t('admin.shippingInventory.enabledState') : t('admin.shippingInventory.disabledState') }}</b></button></div>
|
||||
<div class="form-tip full">{{ t('admin.shippingInventory.connectionBoundary') }}</div>
|
||||
</template>
|
||||
|
||||
<template v-else-if="activeTab === 'sources'">
|
||||
<label><span>{{ t('admin.shippingInventory.sourceCode') }}</span><input v-model="source.source_code" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.inventorySiteName') }}</span><input v-model="source.display_name" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.connectorType') }}</span><select v-model="source.connector_type"><option value="dbs">{{ t('admin.shippingInventory.platform.dbs') }}</option><option value="crane">{{ t('admin.shippingInventory.platform.crane') }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.connection') }}</span><select v-model.number="source.rpa_profile_id" required><option :value="0">{{ t('admin.shippingInventory.chooseConnection') }}</option><option v-for="item in compatibleProfiles" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.profile_code }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.parsingProfiles') }}</span><select v-model.number="source.parsing_profile_id" :disabled="source.enabled"><option :value="0">{{ t('admin.shippingInventory.notConfigured') }}</option><option v-for="item in parsingProfiles.filter((row) => row.status === 'published')" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.profile_code }} V{{ item.version }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.excelTemplates') }}</span><select v-model.number="source.excel_template_id"><option :value="0">{{ t('admin.shippingInventory.notConfigured') }}</option><option v-for="item in excelTemplates.filter((row) => row.status === 'published')" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.template_code }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.warehouseResolution') }}</span><select v-model="source.warehouse_resolution_mode"><option value="fixed">{{ t('admin.shippingInventory.fixedWarehouse') }}</option><option value="inventory_match">{{ t('admin.shippingInventory.inventoryMatch') }}</option></select></label>
|
||||
<label v-if="source.warehouse_resolution_mode === 'fixed'"><span>{{ t('admin.shippingInventory.warehouse') }}</span><input v-model="source.fixed_warehouse_id" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.snapshotTtl') }}</span><input v-model.number="source.snapshot_ttl_seconds" min="1" type="number" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.sourceCode') }}</span><input v-model="source.source_code" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.inventorySiteName') }}</span><input v-model="source.display_name" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.connectorType') }}</span><select v-model="source.connector_type" class="select-field"><option value="dbs">{{ t('admin.shippingInventory.platform.dbs') }}</option><option value="crane">{{ t('admin.shippingInventory.platform.crane') }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.connection') }}</span><select v-model.number="source.rpa_profile_id" class="select-field" required><option :value="0">{{ t('admin.shippingInventory.chooseConnection') }}</option><option v-for="item in compatibleProfiles" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.profile_code }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.parsingProfiles') }}</span><select v-model.number="source.parsing_profile_id" class="select-field" :disabled="source.enabled"><option :value="0">{{ t('admin.shippingInventory.notConfigured') }}</option><option v-for="item in parsingProfiles.filter((row) => row.status === 'published')" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.profile_code }} V{{ item.version }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.excelTemplates') }}</span><select v-model.number="source.excel_template_id" class="select-field"><option :value="0">{{ t('admin.shippingInventory.notConfigured') }}</option><option v-for="item in excelTemplates.filter((row) => row.status === 'published')" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.template_code }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.warehouseResolution') }}</span><select v-model="source.warehouse_resolution_mode" class="select-field"><option value="fixed">{{ t('admin.shippingInventory.fixedWarehouse') }}</option><option value="inventory_match">{{ t('admin.shippingInventory.inventoryMatch') }}</option></select></label>
|
||||
<label v-if="source.warehouse_resolution_mode === 'fixed'"><span>{{ t('admin.shippingInventory.warehouse') }}</span><input v-model="source.fixed_warehouse_id" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.snapshotTtl') }}</span><input v-model.number="source.snapshot_ttl_seconds" class="input-field" min="1" type="number" required></label>
|
||||
<section v-if="selectedId" class="readiness-card full" :class="{ ready: source.enabled }">
|
||||
<header class="readiness-heading">
|
||||
<div>
|
||||
@@ -168,26 +154,26 @@
|
||||
</section>
|
||||
</template>
|
||||
<footer v-if="source.enabled" class="readiness-footer">
|
||||
<button type="button" class="text-action danger" @click="requestSourceDeactivation">{{ t('admin.shippingInventory.deactivateSource') }}</button>
|
||||
<button type="button" class="btn-danger btn-sm" @click="requestSourceDeactivation">{{ t('admin.shippingInventory.deactivateSource') }}</button>
|
||||
</footer>
|
||||
</section>
|
||||
<div v-if="!selectedId" class="form-tip full">{{ t('admin.shippingInventory.sourceSavedDisabledHint') }}</div>
|
||||
<template v-if="source.connector_type === 'dbs'">
|
||||
<div class="subsection full">{{ t('admin.shippingInventory.reportPath') }}</div>
|
||||
<label><span>{{ t('admin.shippingInventory.programGroup') }}</span><input v-model="source.report_path_json.program_group" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.programLabel') }}</span><input v-model="source.report_path_json.program_label" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.reportGroup') }}</span><input v-model="source.report_path_json.report_group" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.reportName') }}</span><input v-model="source.report_path_json.report_name" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.programGroup') }}</span><input v-model="source.report_path_json.program_group" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.programLabel') }}</span><input v-model="source.report_path_json.program_label" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.reportGroup') }}</span><input v-model="source.report_path_json.report_group" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.reportName') }}</span><input v-model="source.report_path_json.report_name" class="input-field" required></label>
|
||||
<div class="subsection full">{{ t('admin.shippingInventory.queryParameters') }}</div>
|
||||
<div v-for="(parameter, index) in source.query_parameters_json" :key="`${index}-${parameter.name}`" class="parameter-row full">
|
||||
<input v-model="parameter.name" :placeholder="t('admin.shippingInventory.parameterName')">
|
||||
<select v-model="parameter.mode"><option value="single">{{ t('admin.shippingInventory.single') }}</option><option value="multi_text">{{ t('admin.shippingInventory.multiText') }}</option><option value="multi_select">{{ t('admin.shippingInventory.multiSelect') }}</option></select>
|
||||
<input :value="parameter.values.join(', ')" :placeholder="t('admin.shippingInventory.parameterValues')" @input="parameter.values = splitValues(($event.target as HTMLInputElement).value)">
|
||||
<input v-model="parameter.name" class="input-field" :placeholder="t('admin.shippingInventory.parameterName')">
|
||||
<select v-model="parameter.mode" class="select-field"><option value="single">{{ t('admin.shippingInventory.single') }}</option><option value="multi_text">{{ t('admin.shippingInventory.multiText') }}</option><option value="multi_select">{{ t('admin.shippingInventory.multiSelect') }}</option></select>
|
||||
<input class="input-field" :value="parameter.values.join(', ')" :placeholder="t('admin.shippingInventory.parameterValues')" @input="parameter.values = splitValues(($event.target as HTMLInputElement).value)">
|
||||
<label class="inline-check"><input v-model="parameter.required" type="checkbox">{{ t('admin.shippingInventory.required') }}</label>
|
||||
<label class="inline-check"><input v-model="parameter.select_all" type="checkbox">{{ t('admin.shippingInventory.selectAll') }}</label>
|
||||
<button type="button" class="text-action danger" @click="source.query_parameters_json.splice(index, 1)">{{ t('admin.delete') }}</button>
|
||||
<button type="button" class="btn-danger btn-sm" @click="source.query_parameters_json.splice(index, 1)">{{ t('admin.delete') }}</button>
|
||||
</div>
|
||||
<button type="button" class="secondary-action full" @click="addParameter">{{ t('admin.shippingInventory.addParameter') }}</button>
|
||||
<button type="button" class="btn-secondary btn-sm full" @click="addParameter">{{ t('admin.shippingInventory.addParameter') }}</button>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
@@ -222,10 +208,10 @@
|
||||
</template>
|
||||
|
||||
<template v-else>
|
||||
<label><span>{{ t('admin.shippingInventory.parsingProfileCode') }}</span><input v-model="parsing.profile_code" :disabled="Boolean(selectedId)" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.parsingProfileName') }}</span><input v-model="parsing.display_name" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.fileFormat') }}</span><select v-model="parsing.file_format"><option value="xls">xls</option><option value="xlsx">xlsx</option><option value="csv">csv</option></select></label>
|
||||
<label v-if="!selectedId" class="full"><span>{{ t('admin.shippingInventory.temporaryInventorySession') }}</span><select v-model="selectedTemporaryInventorySession" @change="loadTemporaryInventorySession"><option value="">{{ t('admin.shippingInventory.temporaryInventorySessionNone') }}</option><option v-for="item in temporaryInventorySessions" :key="item.session_no" :value="item.session_no">{{ item.source_file_name }} · {{ item.session_no }}</option></select><small>{{ t('admin.shippingInventory.temporaryInventorySessionHint') }}</small></label>
|
||||
<label><span>{{ t('admin.shippingInventory.parsingProfileCode') }}</span><input v-model="parsing.profile_code" class="input-field" :disabled="Boolean(selectedId)" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.parsingProfileName') }}</span><input v-model="parsing.display_name" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.fileFormat') }}</span><select v-model="parsing.file_format" class="select-field"><option value="xls">xls</option><option value="xlsx">xlsx</option><option value="csv">csv</option></select></label>
|
||||
<label v-if="!selectedId" class="full"><span>{{ t('admin.shippingInventory.temporaryInventorySession') }}</span><select v-model="selectedTemporaryInventorySession" class="select-field" @change="loadTemporaryInventorySession"><option value="">{{ t('admin.shippingInventory.temporaryInventorySessionNone') }}</option><option v-for="item in temporaryInventorySessions" :key="item.session_no" :value="item.session_no">{{ item.source_file_name }} · {{ item.session_no }}</option></select><small>{{ t('admin.shippingInventory.temporaryInventorySessionHint') }}</small></label>
|
||||
<div v-if="temporaryInventorySessionSelected" class="form-tip full">{{ t('admin.shippingInventory.temporaryInventorySessionSelected', { mapping: temporaryInventorySessionSelected.confirmed_usage?.mapping_origin || '-' }) }}</div>
|
||||
<label v-if="!selectedId" class="full"><span>{{ t('admin.shippingInventory.inventorySampleFile') }}</span><input type="file" accept=".xls,.xlsx,.csv" :disabled="analysisLoading || Boolean(temporaryInventorySessionSelected)" @change="analyseInventorySample"><small>{{ t('admin.shippingInventory.inventorySampleFileHint') }}</small></label>
|
||||
<section v-else-if="structureAnalysis" class="sample-evidence-card full">
|
||||
@@ -243,50 +229,50 @@
|
||||
</section>
|
||||
<div v-if="analysisLoading" class="form-tip full">{{ t('admin.shippingInventory.inventorySampleAnalysing') }}</div>
|
||||
<template v-if="structureAnalysis">
|
||||
<label><span>{{ t('admin.shippingInventory.sheetName') }}</span><select v-model="parsing.sheet_name" @change="applyAnalysisCandidate"><option v-for="candidate in analysisCandidates" :key="candidateKey(candidate)" :value="candidate.sheet_name || ''">{{ candidate.sheet_name || t('admin.shippingInventory.csvFile') }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.headerRowIndex') }}</span><select v-model.number="parsing.header_row_index" @change="applyAnalysisCandidate"><option v-for="candidate in analysisCandidatesForSheet" :key="candidateKey(candidate)" :value="candidate.header_row_index">{{ t('admin.shippingInventory.headerRowOption', { row: candidate.header_row_index }) }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.sheetName') }}</span><select v-model="parsing.sheet_name" class="select-field" @change="applyAnalysisCandidate"><option v-for="candidate in analysisCandidates" :key="candidateKey(candidate)" :value="candidate.sheet_name || ''">{{ candidate.sheet_name || t('admin.shippingInventory.csvFile') }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.headerRowIndex') }}</span><select v-model.number="parsing.header_row_index" class="select-field" @change="applyAnalysisCandidate"><option v-for="candidate in analysisCandidatesForSheet" :key="candidateKey(candidate)" :value="candidate.header_row_index">{{ t('admin.shippingInventory.headerRowOption', { row: candidate.header_row_index }) }}</option></select></label>
|
||||
<section class="analysis-preview full"><strong>{{ t('admin.shippingInventory.inventoryAnalysisPreview') }}</strong><p>{{ t('admin.shippingInventory.inventoryAnalysisSummary', structureAnalysis.validation_summary) }}</p><div class="analysis-columns"><span v-for="column in selectedAnalysisColumns" :key="`${column.index}-${column.header}`"><b>{{ column.header || t('admin.shippingInventory.emptyHeader') }}</b><small>{{ column.inferred_type }} · {{ column.sample_values?.join(' / ') || '-' }}</small></span></div></section>
|
||||
<section v-if="structureAnalysis.match_result?.candidates?.length" class="analysis-preview full"><strong>{{ t('admin.shippingInventory.parsingPlanRecommendation') }}</strong><div class="recommendation-list"><article v-for="candidate in structureAnalysis.match_result.candidates" :key="candidate.profile_id"><b>{{ candidate.display_name }} V{{ candidate.version }}</b><small>{{ t(`admin.shippingInventory.recommendationLevel.${candidate.level}`) }} · {{ t('admin.shippingInventory.usedBySites', { count: candidate.source_count }) }}</small><p v-if="candidate.difference?.added_columns?.length">{{ t('admin.shippingInventory.addedColumns', { columns: candidate.difference.added_columns.join('、') }) }}</p><p v-if="candidate.difference?.column_order_changed?.length">{{ t('admin.shippingInventory.columnOrderChanged') }}</p><button type="button" class="secondary-action" @click="adoptRecommendedProfile(candidate.profile_id)">{{ t('admin.shippingInventory.adoptParsingPlan') }}</button></article></div></section>
|
||||
<section v-if="structureAnalysis.match_result?.candidates?.length" class="analysis-preview full"><strong>{{ t('admin.shippingInventory.parsingPlanRecommendation') }}</strong><div class="recommendation-list"><article v-for="candidate in structureAnalysis.match_result.candidates" :key="candidate.profile_id"><b>{{ candidate.display_name }} V{{ candidate.version }}</b><small>{{ t(`admin.shippingInventory.recommendationLevel.${candidate.level}`) }} · {{ t('admin.shippingInventory.usedBySites', { count: candidate.source_count }) }}</small><p v-if="candidate.difference?.added_columns?.length">{{ t('admin.shippingInventory.addedColumns', { columns: candidate.difference.added_columns.join('、') }) }}</p><p v-if="candidate.difference?.column_order_changed?.length">{{ t('admin.shippingInventory.columnOrderChanged') }}</p><button type="button" class="btn-secondary btn-sm" @click="adoptRecommendedProfile(candidate.profile_id)">{{ t('admin.shippingInventory.adoptParsingPlan') }}</button></article></div></section>
|
||||
</template>
|
||||
<div v-else class="form-tip full">{{ t('admin.shippingInventory.inventorySampleRequired') }}</div>
|
||||
<div class="subsection full">{{ t('admin.shippingInventory.fieldMappings') }}</div>
|
||||
<div v-for="(item, index) in parsing.field_mappings" :key="`field-${index}`" class="parsing-mapping-card full">
|
||||
<div class="mapping-title"><strong>{{ t('admin.shippingInventory.mappingItem', { number: index + 1 }) }}</strong><button type="button" class="text-action danger" @click="parsing.field_mappings.splice(index, 1)">{{ t('admin.delete') }}</button></div>
|
||||
<label><span>{{ t('admin.shippingInventory.inventoryField') }}</span><select v-model="item.inventory_field" required><option value="">{{ t('admin.shippingInventory.chooseInventoryField') }}</option><option v-for="field in activeInventoryFields" :key="field.id" :value="String(field.id)">{{ inventoryFieldOptionLabel(field) }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.sourceHeader') }}</span><select v-model="item.source_header" :disabled="!structureAnalysis" required><option value="">{{ t('admin.shippingInventory.chooseSourceHeader') }}</option><option v-for="header in selectedAnalysisHeaders" :key="header" :value="header">{{ header }}</option></select></label>
|
||||
<div class="mapping-title"><strong>{{ t('admin.shippingInventory.mappingItem', { number: index + 1 }) }}</strong><button type="button" class="btn-danger btn-sm" @click="parsing.field_mappings.splice(index, 1)">{{ t('admin.delete') }}</button></div>
|
||||
<label><span>{{ t('admin.shippingInventory.inventoryField') }}</span><select v-model="item.inventory_field" class="select-field" required><option value="">{{ t('admin.shippingInventory.chooseInventoryField') }}</option><option v-for="field in activeInventoryFields" :key="field.id" :value="String(field.id)">{{ inventoryFieldOptionLabel(field) }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.sourceHeader') }}</span><select v-model="item.source_header" class="select-field" :disabled="!structureAnalysis" required><option value="">{{ t('admin.shippingInventory.chooseSourceHeader') }}</option><option v-for="header in selectedAnalysisHeaders" :key="header" :value="header">{{ header }}</option></select></label>
|
||||
<small v-if="item.inventory_field" class="mapping-help">{{ inventoryFieldDescription(item.inventory_field) }}</small>
|
||||
</div>
|
||||
<button type="button" class="secondary-action full" :disabled="!structureAnalysis" @click="addParsingFieldMapping">{{ t('admin.shippingInventory.addFieldMapping') }}</button>
|
||||
<button type="button" class="btn-secondary btn-sm full" :disabled="!structureAnalysis" @click="addParsingFieldMapping">{{ t('admin.shippingInventory.addFieldMapping') }}</button>
|
||||
<div class="subsection full">{{ t('admin.shippingInventory.matchKeys') }}<small>{{ t('admin.shippingInventory.matchKeysHint') }}</small></div>
|
||||
<div v-for="(item, index) in parsing.match_keys" :key="`match-${index}`" class="parsing-mapping-card match-key-card full">
|
||||
<div class="mapping-title"><strong>{{ t('admin.shippingInventory.mappingItem', { number: index + 1 }) }}</strong><button type="button" class="text-action danger" @click="parsing.match_keys.splice(index, 1)">{{ t('admin.delete') }}</button></div>
|
||||
<label><span>{{ t('admin.shippingInventory.orderField') }}</span><select v-model="item.order_field_id" required><option value="">{{ t('admin.shippingInventory.chooseOrderField') }}</option><option v-for="field in matchingOrderFields" :key="field.field_id" :value="field.field_id">{{ orderFieldOptionLabel(field) }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.inventoryField') }}</span><select v-model="item.inventory_field" required><option value="">{{ t('admin.shippingInventory.chooseInventoryField') }}</option><option v-for="field in mappedMatchingInventoryFields" :key="field.id" :value="String(field.id)">{{ inventoryFieldOptionLabel(field) }}</option></select></label>
|
||||
<div class="mapping-title"><strong>{{ t('admin.shippingInventory.mappingItem', { number: index + 1 }) }}</strong><button type="button" class="btn-danger btn-sm" @click="parsing.match_keys.splice(index, 1)">{{ t('admin.delete') }}</button></div>
|
||||
<label><span>{{ t('admin.shippingInventory.orderField') }}</span><select v-model="item.order_field_id" class="select-field" required><option value="">{{ t('admin.shippingInventory.chooseOrderField') }}</option><option v-for="field in matchingOrderFields" :key="field.field_id" :value="field.field_id">{{ orderFieldOptionLabel(field) }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.inventoryField') }}</span><select v-model="item.inventory_field" class="select-field" required><option value="">{{ t('admin.shippingInventory.chooseInventoryField') }}</option><option v-for="field in mappedMatchingInventoryFields" :key="field.id" :value="String(field.id)">{{ inventoryFieldOptionLabel(field) }}</option></select></label>
|
||||
<small v-if="item.inventory_field" class="mapping-help">{{ inventoryFieldDescription(item.inventory_field) }}</small>
|
||||
</div>
|
||||
<button type="button" class="secondary-action full" :disabled="!canAddParsingMatchKey" @click="addParsingMatchKey">{{ t('admin.shippingInventory.addMatchKey') }}</button>
|
||||
<button type="button" class="btn-secondary btn-sm full" :disabled="!canAddParsingMatchKey" @click="addParsingMatchKey">{{ t('admin.shippingInventory.addMatchKey') }}</button>
|
||||
<p v-if="!unusedMatchingInventoryFields.length || !unusedOrderMatchFields.length" class="match-key-tip full">{{ t('admin.shippingInventory.matchKeysComplete') }}</p>
|
||||
<p v-else-if="!structureAnalysis" class="match-key-tip full">{{ t('admin.shippingInventory.matchKeysAnalysisRequired') }}</p>
|
||||
</template>
|
||||
</template>
|
||||
|
||||
<template v-else-if="activeTab === 'inventoryFields'">
|
||||
<label><span>{{ t('admin.shippingInventory.inventoryFieldName') }}</span><input v-model="inventoryField.display_name" :disabled="inventoryFieldReadOnly" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.inventoryFieldFormat') }}</span><select v-model="inventoryField.value_type" :disabled="inventoryFieldReadOnly"><option value="text">{{ t('admin.shippingInventory.inventoryFieldType.text') }}</option><option value="integer">{{ t('admin.shippingInventory.inventoryFieldType.integer') }}</option><option value="decimal">{{ t('admin.shippingInventory.inventoryFieldType.decimal') }}</option><option value="date">{{ t('admin.shippingInventory.inventoryFieldType.date') }}</option></select></label>
|
||||
<label class="full"><span>{{ t('admin.shippingInventory.inventoryFieldDescription') }}</span><input v-model="inventoryField.description" :disabled="inventoryField.status !== 'active'" :placeholder="t('admin.shippingInventory.inventoryFieldDescriptionHint')"></label>
|
||||
<label><span>{{ t('admin.shippingInventory.inventoryFieldPurpose') }}</span><select v-model="inventoryField.usage_type" :disabled="inventoryFieldReadOnly"><option value="match_identity">{{ t('admin.shippingInventory.inventoryFieldPurposeOption.match_identity') }}</option><option value="inventory_quantity">{{ t('admin.shippingInventory.inventoryFieldPurposeOption.inventory_quantity') }}</option><option value="warehouse_identity">{{ t('admin.shippingInventory.inventoryFieldPurposeOption.warehouse_identity') }}</option><option value="general">{{ t('admin.shippingInventory.inventoryFieldPurposeOption.general') }}</option></select><small>{{ t('admin.shippingInventory.inventoryFieldPurposeHint') }}</small></label>
|
||||
<label><span>{{ t('admin.shippingInventory.inventoryFieldOrder') }}</span><input v-model.number="inventoryField.sort_order" :disabled="inventoryField.status !== 'active'" min="0" max="9999" type="number" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.inventoryFieldName') }}</span><input v-model="inventoryField.display_name" class="input-field" :disabled="inventoryFieldReadOnly" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.inventoryFieldFormat') }}</span><select v-model="inventoryField.value_type" class="select-field" :disabled="inventoryFieldReadOnly"><option value="text">{{ t('admin.shippingInventory.inventoryFieldType.text') }}</option><option value="integer">{{ t('admin.shippingInventory.inventoryFieldType.integer') }}</option><option value="decimal">{{ t('admin.shippingInventory.inventoryFieldType.decimal') }}</option><option value="date">{{ t('admin.shippingInventory.inventoryFieldType.date') }}</option></select></label>
|
||||
<label class="full"><span>{{ t('admin.shippingInventory.inventoryFieldDescription') }}</span><input v-model="inventoryField.description" class="input-field" :disabled="inventoryField.status !== 'active'" :placeholder="t('admin.shippingInventory.inventoryFieldDescriptionHint')"></label>
|
||||
<label><span>{{ t('admin.shippingInventory.inventoryFieldPurpose') }}</span><select v-model="inventoryField.usage_type" class="select-field" :disabled="inventoryFieldReadOnly"><option value="match_identity">{{ t('admin.shippingInventory.inventoryFieldPurposeOption.match_identity') }}</option><option value="inventory_quantity">{{ t('admin.shippingInventory.inventoryFieldPurposeOption.inventory_quantity') }}</option><option value="warehouse_identity">{{ t('admin.shippingInventory.inventoryFieldPurposeOption.warehouse_identity') }}</option><option value="general">{{ t('admin.shippingInventory.inventoryFieldPurposeOption.general') }}</option></select><small>{{ t('admin.shippingInventory.inventoryFieldPurposeHint') }}</small></label>
|
||||
<label><span>{{ t('admin.shippingInventory.inventoryFieldOrder') }}</span><input v-model.number="inventoryField.sort_order" class="input-field" :disabled="inventoryField.status !== 'active'" min="0" max="9999" type="number" required></label>
|
||||
<div class="form-tip full">{{ t('admin.shippingInventory.inventoryFieldUserDefinedHint') }}</div>
|
||||
</template>
|
||||
|
||||
<template v-else-if="activeTab === 'templates'">
|
||||
<label><span>{{ t('admin.shippingInventory.templateCode') }}</span><input v-model="excelTemplate.template_code" :disabled="Boolean(selectedId)" required><small>{{ t('admin.shippingInventory.templateCodeHint') }}</small></label>
|
||||
<label><span>{{ t('admin.shippingInventory.excelTemplateName') }}</span><input v-model="excelTemplate.display_name" :disabled="templateReadOnly" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.templateCode') }}</span><input v-model="excelTemplate.template_code" class="input-field" :disabled="Boolean(selectedId)" required><small>{{ t('admin.shippingInventory.templateCodeHint') }}</small></label>
|
||||
<label><span>{{ t('admin.shippingInventory.excelTemplateName') }}</span><input v-model="excelTemplate.display_name" class="input-field" :disabled="templateReadOnly" required></label>
|
||||
<label v-if="!selectedId" class="full"><span>{{ t('admin.shippingInventory.templateFile') }}</span><input type="file" accept=".xlsx" required @change="onTemplateFile"><small>{{ t('admin.shippingInventory.templateFileHint') }}</small></label>
|
||||
<div class="filename-pattern-field full">
|
||||
<span>{{ t('admin.shippingInventory.filenamePattern') }}</span>
|
||||
<div class="filename-input-wrap">
|
||||
<input ref="filenamePatternInput" v-model="excelTemplate.filename_pattern" :disabled="templateReadOnly" @input="updateFilenameVariableMenu" @keydown="handleFilenamePatternKeydown" @blur="closeFilenameVariableMenu">
|
||||
<input ref="filenamePatternInput" v-model="excelTemplate.filename_pattern" class="input-field" :disabled="templateReadOnly" @input="updateFilenameVariableMenu" @keydown="handleFilenamePatternKeydown" @blur="closeFilenameVariableMenu">
|
||||
<div v-if="filenameVariableMenuOpen" class="filename-variable-menu" role="listbox" :aria-label="t('admin.shippingInventory.filenameVariablesTitle')">
|
||||
<button v-for="(variable, index) in filenameVariableCandidates" :key="variable.key" type="button" :class="{ active: index === filenameVariableActiveIndex }" role="option" :aria-selected="index === filenameVariableActiveIndex" @mousedown.prevent @click="insertFilenameVariable(variable)">
|
||||
<code>{{ variable.key }}</code><span>{{ t(variable.labelKey) }}</span>
|
||||
@@ -298,63 +284,63 @@
|
||||
<div class="subsection full">{{ t('admin.shippingInventory.templateMappings') }}<small>{{ t('admin.shippingInventory.templateMappingsHint') }}</small></div>
|
||||
<div v-if="!templateSourceOptions({ row_mode: 'header', source_kind: 'order_field' } as TemplateMapping).length" class="form-tip full">{{ t('admin.shippingInventory.orderFieldOptionsEmpty') }}</div>
|
||||
<div v-for="(item, index) in excelTemplate.mappings" :key="`template-${index}`" class="template-mapping full">
|
||||
<div class="mapping-title"><strong>{{ t('admin.shippingInventory.mappingItem', { number: index + 1 }) }}</strong><button v-if="!templateReadOnly" type="button" class="text-action danger" @click="excelTemplate.mappings.splice(index, 1)">{{ t('admin.delete') }}</button></div>
|
||||
<label><span>{{ t('admin.shippingInventory.templateSheet') }}</span><select v-model="item.sheet" :disabled="templateReadOnly" required><option value="">{{ t('admin.shippingInventory.chooseTemplateSheet') }}</option><option v-for="sheet in templateSheets" :key="sheet" :value="sheet">{{ sheet }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.templateRowMode') }}</span><select v-model="item.row_mode" :disabled="templateReadOnly" @change="item.source_key = ''"><option v-for="mode in templateRowModes" :key="mode" :value="mode">{{ t(`admin.shippingInventory.rowMode.${mode}`) }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.startRow') }}</span><input v-model.number="item.start_row" :disabled="templateReadOnly" min="1" type="number" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.targetColumn') }}</span><select v-model.number="item.target_column" :disabled="templateReadOnly" required><option :value="0">{{ t('admin.shippingInventory.chooseTargetColumn') }}</option><option v-for="column in templateColumns(item.sheet, item.target_column)" :key="column.index" :value="column.index">{{ column.label }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.sourceType') }}</span><select v-model="item.source_kind" :disabled="templateReadOnly" @change="item.source_key = ''"><option v-for="kind in templateSourceKinds" :key="kind" :value="kind">{{ t(`admin.shippingInventory.sourceKind.${kind}`) }}</option></select></label>
|
||||
<div class="mapping-title"><strong>{{ t('admin.shippingInventory.mappingItem', { number: index + 1 }) }}</strong><button v-if="!templateReadOnly" type="button" class="btn-danger btn-sm" @click="excelTemplate.mappings.splice(index, 1)">{{ t('admin.delete') }}</button></div>
|
||||
<label><span>{{ t('admin.shippingInventory.templateSheet') }}</span><select v-model="item.sheet" class="select-field" :disabled="templateReadOnly" required><option value="">{{ t('admin.shippingInventory.chooseTemplateSheet') }}</option><option v-for="sheet in templateSheets" :key="sheet" :value="sheet">{{ sheet }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.templateRowMode') }}</span><select v-model="item.row_mode" class="select-field" :disabled="templateReadOnly" @change="item.source_key = ''"><option v-for="mode in templateRowModes" :key="mode" :value="mode">{{ t(`admin.shippingInventory.rowMode.${mode}`) }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.startRow') }}</span><input v-model.number="item.start_row" class="input-field" :disabled="templateReadOnly" min="1" type="number" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.targetColumn') }}</span><select v-model.number="item.target_column" class="select-field" :disabled="templateReadOnly" required><option :value="0">{{ t('admin.shippingInventory.chooseTargetColumn') }}</option><option v-for="column in templateColumns(item.sheet, item.target_column)" :key="column.index" :value="column.index">{{ column.label }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.sourceType') }}</span><select v-model="item.source_kind" class="select-field" :disabled="templateReadOnly" @change="item.source_key = ''"><option v-for="kind in templateSourceKinds" :key="kind" :value="kind">{{ t(`admin.shippingInventory.sourceKind.${kind}`) }}</option></select></label>
|
||||
<div class="mapping-value-row full">
|
||||
<label class="mapping-source"><span>{{ item.source_kind === 'constant' ? t('admin.shippingInventory.constantValue') : t('admin.shippingInventory.sourceField') }}</span><input v-if="item.source_kind === 'constant'" v-model="item.source_key" :disabled="templateReadOnly" :placeholder="t('admin.shippingInventory.constantValueHint')"><select v-else v-model="item.source_key" :disabled="templateReadOnly" required><option value="">{{ t('admin.shippingInventory.chooseSourceField') }}</option><optgroup v-for="group in templateSourceOptionGroups(item)" :key="group.label" :label="group.label"><option v-for="option in group.options" :key="option.value" :value="option.value">{{ option.label }}</option></optgroup></select><small v-if="item.source_kind !== 'constant'">{{ t(`admin.shippingInventory.sourceKindHint.${item.source_kind}`) }}</small></label>
|
||||
<label><span>{{ t('admin.shippingInventory.valueFormat') }}</span><select v-model="item.formatter" :disabled="templateReadOnly"><option v-for="formatter in templateFormatters" :key="formatter" :value="formatter">{{ t(`admin.shippingInventory.formatter.${formatter}`) }}</option></select></label>
|
||||
<label class="mapping-source"><span>{{ item.source_kind === 'constant' ? t('admin.shippingInventory.constantValue') : t('admin.shippingInventory.sourceField') }}</span><input v-if="item.source_kind === 'constant'" v-model="item.source_key" class="input-field" :disabled="templateReadOnly" :placeholder="t('admin.shippingInventory.constantValueHint')"><select v-else v-model="item.source_key" class="select-field" :disabled="templateReadOnly" required><option value="">{{ t('admin.shippingInventory.chooseSourceField') }}</option><optgroup v-for="group in templateSourceOptionGroups(item)" :key="group.label" :label="group.label"><option v-for="option in group.options" :key="option.value" :value="option.value">{{ option.label }}</option></optgroup></select><small v-if="item.source_kind !== 'constant'">{{ t(`admin.shippingInventory.sourceKindHint.${item.source_kind}`) }}</small></label>
|
||||
<label><span>{{ t('admin.shippingInventory.valueFormat') }}</span><select v-model="item.formatter" class="select-field" :disabled="templateReadOnly"><option v-for="formatter in templateFormatters" :key="formatter" :value="formatter">{{ t(`admin.shippingInventory.formatter.${formatter}`) }}</option></select></label>
|
||||
</div>
|
||||
</div>
|
||||
<button v-if="!templateReadOnly" type="button" class="secondary-action full" @click="addTemplateMapping">{{ t('admin.shippingInventory.addTemplateMapping') }}</button>
|
||||
<button v-if="!templateReadOnly" type="button" class="btn-secondary btn-sm full" @click="addTemplateMapping">{{ t('admin.shippingInventory.addTemplateMapping') }}</button>
|
||||
<div v-if="templateReadOnly" class="form-tip full">{{ t('admin.shippingInventory.publishedTemplateImmutable') }}</div>
|
||||
</template>
|
||||
|
||||
<template v-else-if="activeTab === 'rules'">
|
||||
<label><span>{{ t('admin.shippingInventory.ruleCode') }}</span><input v-model="rule.rule_code" :disabled="ruleReadOnly" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.ruleName') }}</span><input v-model="rule.rule_name" :disabled="ruleReadOnly" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.scope') }}</span><select v-model="rule.scope" :disabled="ruleReadOnly"><option value="task">{{ t('admin.shippingInventory.routeScope.task') }}</option><option value="line">{{ t('admin.shippingInventory.routeScope.line') }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.priority') }}</span><input v-model.number="rule.priority" :disabled="ruleReadOnly" type="number"></label>
|
||||
<label><span>{{ t('admin.shippingInventory.ruleCode') }}</span><input v-model="rule.rule_code" class="input-field" :disabled="ruleReadOnly" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.ruleName') }}</span><input v-model="rule.rule_name" class="input-field" :disabled="ruleReadOnly" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.scope') }}</span><select v-model="rule.scope" class="select-field" :disabled="ruleReadOnly"><option value="task">{{ t('admin.shippingInventory.routeScope.task') }}</option><option value="line">{{ t('admin.shippingInventory.routeScope.line') }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.priority') }}</span><input v-model.number="rule.priority" class="input-field" :disabled="ruleReadOnly" type="number"></label>
|
||||
<div class="subsection full">{{ t('admin.shippingInventory.ruleConditions') }}</div>
|
||||
<div v-for="(condition, index) in rule.conditions" :key="index" class="condition-row full">
|
||||
<select v-model="condition.order_field_id" :disabled="ruleReadOnly" :aria-label="t('admin.shippingInventory.factPath')"><option value="">-</option><option v-for="field in compatibleRoutingFields" :key="field.field_id" :value="field.field_id">{{ field.display_name }}</option></select>
|
||||
<select v-model="condition.operator" :disabled="ruleReadOnly" :aria-label="t('admin.shippingInventory.operator')"><option v-for="item in operators" :key="item.value" :value="item.value">{{ item.label }}</option></select>
|
||||
<input v-if="conditionNeedsExpected(condition)" v-model="condition.expected" :disabled="ruleReadOnly" :placeholder="t('admin.shippingInventory.expectedValue')">
|
||||
<select v-model="condition.order_field_id" class="select-field" :disabled="ruleReadOnly" :aria-label="t('admin.shippingInventory.factPath')"><option value="">-</option><option v-for="field in compatibleRoutingFields" :key="field.field_id" :value="field.field_id">{{ field.display_name }}</option></select>
|
||||
<select v-model="condition.operator" class="select-field" :disabled="ruleReadOnly" :aria-label="t('admin.shippingInventory.operator')"><option v-for="item in operators" :key="item.value" :value="item.value">{{ item.label }}</option></select>
|
||||
<input v-if="conditionNeedsExpected(condition)" v-model="condition.expected" class="input-field" :disabled="ruleReadOnly" :placeholder="t('admin.shippingInventory.expectedValue')">
|
||||
<span v-else class="condition-empty">{{ t('admin.shippingInventory.noExpectedValue') }}</span>
|
||||
<button v-if="!ruleReadOnly" type="button" class="text-action danger" :disabled="rule.conditions.length === 1" @click="removeRuleCondition(index)">{{ t('admin.delete') }}</button>
|
||||
<button v-if="!ruleReadOnly" type="button" class="btn-danger btn-sm" :disabled="rule.conditions.length === 1" @click="removeRuleCondition(index)">{{ t('admin.delete') }}</button>
|
||||
</div>
|
||||
<button v-if="!ruleReadOnly" type="button" class="secondary-action full" @click="addRuleCondition">{{ t('admin.shippingInventory.addCondition') }}</button>
|
||||
<label class="full"><span>{{ t('admin.shippingInventory.sourceCandidates') }}</span><select v-model="rule.source_codes" :disabled="ruleReadOnly" multiple required><option v-for="item in sources" :key="String(item.id)" :value="item.source_code">{{ item.display_name || item.source_code }}</option></select><small>{{ t('admin.shippingInventory.sourceCandidatesHint') }}</small></label>
|
||||
<button v-if="!ruleReadOnly" type="button" class="btn-secondary btn-sm full" @click="addRuleCondition">{{ t('admin.shippingInventory.addCondition') }}</button>
|
||||
<label class="full"><span>{{ t('admin.shippingInventory.sourceCandidates') }}</span><select v-model="rule.source_codes" class="select-field" :disabled="ruleReadOnly" multiple required><option v-for="item in sources" :key="String(item.id)" :value="item.source_code">{{ item.display_name || item.source_code }}</option></select><small>{{ t('admin.shippingInventory.sourceCandidatesHint') }}</small></label>
|
||||
<div v-if="ruleReadOnly" class="form-tip full">{{ t('admin.shippingInventory.publishedImmutable') }}</div>
|
||||
</template>
|
||||
|
||||
<template v-else-if="activeTab === 'mappings'">
|
||||
<label><span>{{ t('admin.shippingInventory.source') }}</span><select v-model.number="mapping.inventory_source_id" required><option :value="0">{{ t('admin.shippingInventory.chooseSource') }}</option><option v-for="item in sources" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.source_code }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.freightWarehouse') }}</span><input v-model="mapping.freight_warehouse_id" :placeholder="t('admin.shippingInventory.defaultMapping')"></label>
|
||||
<label><span>{{ t('admin.shippingInventory.externalSystem') }}</span><input v-model="mapping.external_system_code" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.externalOrganization') }}</span><input v-model="mapping.external_organization_code"></label>
|
||||
<label><span>{{ t('admin.shippingInventory.externalSite') }}</span><input v-model="mapping.external_site_code"></label>
|
||||
<label><span>{{ t('admin.shippingInventory.externalWarehouseCode') }}</span><input v-model="mapping.external_warehouse_code" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.externalWarehouseName') }}</span><input v-model="mapping.external_warehouse_name" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.source') }}</span><select v-model.number="mapping.inventory_source_id" class="select-field" required><option :value="0">{{ t('admin.shippingInventory.chooseSource') }}</option><option v-for="item in sources" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.source_code }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.freightWarehouse') }}</span><input v-model="mapping.freight_warehouse_id" class="input-field" :placeholder="t('admin.shippingInventory.defaultMapping')"></label>
|
||||
<label><span>{{ t('admin.shippingInventory.externalSystem') }}</span><input v-model="mapping.external_system_code" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.externalOrganization') }}</span><input v-model="mapping.external_organization_code" class="input-field"></label>
|
||||
<label><span>{{ t('admin.shippingInventory.externalSite') }}</span><input v-model="mapping.external_site_code" class="input-field"></label>
|
||||
<label><span>{{ t('admin.shippingInventory.externalWarehouseCode') }}</span><input v-model="mapping.external_warehouse_code" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.externalWarehouseName') }}</span><input v-model="mapping.external_warehouse_name" class="input-field" required></label>
|
||||
<div class="switch-field"><span>{{ t('admin.shippingInventory.enabled') }}</span><button type="button" class="status-switch" :class="{ on: mapping.enabled }" role="switch" :aria-checked="mapping.enabled" @click="mapping.enabled = !mapping.enabled"><i></i><b>{{ mapping.enabled ? t('admin.shippingInventory.enabledState') : t('admin.shippingInventory.disabledState') }}</b></button></div>
|
||||
</template>
|
||||
|
||||
<div v-if="isEditableTab" class="form-actions full">
|
||||
<button v-if="!parsingReadOnly" type="submit" class="primary-action" :disabled="saving || ruleReadOnly || templateReadOnly || inventoryFieldReadOnly">{{ saving ? t('admin.shippingInventory.saving') : t('admin.save') }}</button>
|
||||
<button v-if="activeTab === 'rules' && selectedId && selectedRuleStatus === 'draft'" type="button" class="secondary-action" @click="publishCurrentRule">{{ t('admin.shippingInventory.publish') }}</button>
|
||||
<button v-if="activeTab === 'rules' && selectedId && selectedRuleStatus === 'published'" type="button" class="secondary-action" @click="retireCurrentRule">{{ t('admin.shippingInventory.retire') }}</button>
|
||||
<button v-if="activeTab === 'templates' && selectedId && selectedTemplateStatus === 'draft'" type="button" class="secondary-action" @click="publishCurrentTemplate">{{ t('admin.shippingInventory.publishTemplate') }}</button>
|
||||
<button v-if="activeTab === 'templates' && selectedId && selectedTemplateStatus !== 'draft'" type="button" class="secondary-action" @click="createTemplateVersion">{{ t('admin.shippingInventory.createTemplateVersion') }}</button>
|
||||
<button v-if="activeTab === 'templates' && selectedId" type="button" class="secondary-action" @click="openTemplateCloneDialog">{{ t('admin.shippingInventory.cloneTemplate') }}</button>
|
||||
<button v-if="activeTab === 'templates' && selectedId && selectedTemplateStatus === 'published'" type="button" class="text-action danger retire-template-action" @click="retireCurrentTemplate">{{ t('admin.shippingInventory.retireTemplate') }}</button>
|
||||
<button v-if="activeTab === 'parsing' && selectedId && selectedParsingStatus === 'draft'" type="button" class="secondary-action" @click="publishCurrentParsingProfile">{{ t('admin.shippingInventory.publishProfile') }}</button>
|
||||
<button v-if="activeTab === 'parsing' && selectedId && selectedParsingStatus === 'published'" type="button" class="text-action danger retire-template-action" @click="retireCurrentParsingProfile">{{ t('admin.shippingInventory.retireProfile') }}</button>
|
||||
<button v-if="activeTab === 'inventoryFields' && selectedId && inventoryField.status === 'active'" type="button" class="text-action danger retire-template-action" @click="retireCurrentInventoryField">{{ t('admin.shippingInventory.retireInventoryField') }}</button>
|
||||
<button v-if="selectedId && canDeleteCurrent" type="button" class="text-action danger" @click="deleteCurrent">{{ t('admin.delete') }}</button>
|
||||
<button type="button" class="text-action" @click="closeDrawer">{{ t('admin.cancel') }}</button>
|
||||
<button v-if="!parsingReadOnly" type="submit" class="btn-primary" :disabled="saving || ruleReadOnly || templateReadOnly || inventoryFieldReadOnly">{{ saving ? t('admin.shippingInventory.saving') : t('admin.save') }}</button>
|
||||
<button v-if="activeTab === 'rules' && selectedId && selectedRuleStatus === 'draft'" type="button" class="btn-secondary btn-sm" @click="publishCurrentRule">{{ t('admin.shippingInventory.publish') }}</button>
|
||||
<button v-if="activeTab === 'rules' && selectedId && selectedRuleStatus === 'published'" type="button" class="btn-secondary btn-sm" @click="retireCurrentRule">{{ t('admin.shippingInventory.retire') }}</button>
|
||||
<button v-if="activeTab === 'templates' && selectedId && selectedTemplateStatus === 'draft'" type="button" class="btn-secondary btn-sm" @click="publishCurrentTemplate">{{ t('admin.shippingInventory.publishTemplate') }}</button>
|
||||
<button v-if="activeTab === 'templates' && selectedId && selectedTemplateStatus !== 'draft'" type="button" class="btn-secondary btn-sm" @click="createTemplateVersion">{{ t('admin.shippingInventory.createTemplateVersion') }}</button>
|
||||
<button v-if="activeTab === 'templates' && selectedId" type="button" class="btn-secondary btn-sm" @click="openTemplateCloneDialog">{{ t('admin.shippingInventory.cloneTemplate') }}</button>
|
||||
<button v-if="activeTab === 'templates' && selectedId && selectedTemplateStatus === 'published'" type="button" class="btn-danger btn-sm retire-template-action" @click="retireCurrentTemplate">{{ t('admin.shippingInventory.retireTemplate') }}</button>
|
||||
<button v-if="activeTab === 'parsing' && selectedId && selectedParsingStatus === 'draft'" type="button" class="btn-secondary btn-sm" @click="publishCurrentParsingProfile">{{ t('admin.shippingInventory.publishProfile') }}</button>
|
||||
<button v-if="activeTab === 'parsing' && selectedId && selectedParsingStatus === 'published'" type="button" class="btn-danger btn-sm retire-template-action" @click="retireCurrentParsingProfile">{{ t('admin.shippingInventory.retireProfile') }}</button>
|
||||
<button v-if="activeTab === 'inventoryFields' && selectedId && inventoryField.status === 'active'" type="button" class="btn-danger btn-sm retire-template-action" @click="retireCurrentInventoryField">{{ t('admin.shippingInventory.retireInventoryField') }}</button>
|
||||
<button v-if="selectedId && canDeleteCurrent" type="button" class="btn-danger btn-sm" @click="deleteCurrent">{{ t('admin.delete') }}</button>
|
||||
<button type="button" class="btn-ghost btn-sm" @click="closeDrawer">{{ t('admin.cancel') }}</button>
|
||||
</div>
|
||||
</form>
|
||||
</aside>
|
||||
@@ -379,9 +365,9 @@
|
||||
<button type="button" class="drawer-close" :aria-label="t('admin.close')" @click="closeTemplateCloneDialog">×</button>
|
||||
</header>
|
||||
<form class="clone-template-form" @submit.prevent="cloneCurrentTemplate">
|
||||
<label><span>{{ t('admin.shippingInventory.templateCode') }}</span><input v-model="templateClone.template_code" required pattern="[A-Za-z0-9_-]{2,64}" autocomplete="off"><small>{{ t('admin.shippingInventory.cloneTemplateCodeHint') }}</small></label>
|
||||
<label><span>{{ t('admin.shippingInventory.excelTemplateName') }}</span><input v-model="templateClone.display_name" required autocomplete="off"></label>
|
||||
<div class="clone-template-actions"><button type="button" class="text-action" :disabled="templateClone.saving" @click="closeTemplateCloneDialog">{{ t('admin.cancel') }}</button><button type="submit" class="primary-action" :disabled="templateClone.saving">{{ templateClone.saving ? t('admin.shippingInventory.saving') : t('admin.shippingInventory.cloneTemplateConfirm') }}</button></div>
|
||||
<label><span>{{ t('admin.shippingInventory.templateCode') }}</span><input v-model="templateClone.template_code" class="input-field" required pattern="[A-Za-z0-9_-]{2,64}" autocomplete="off"><small>{{ t('admin.shippingInventory.cloneTemplateCodeHint') }}</small></label>
|
||||
<label><span>{{ t('admin.shippingInventory.excelTemplateName') }}</span><input v-model="templateClone.display_name" class="input-field" required autocomplete="off"></label>
|
||||
<div class="clone-template-actions"><button type="button" class="btn-ghost btn-sm" :disabled="templateClone.saving" @click="closeTemplateCloneDialog">{{ t('admin.cancel') }}</button><button type="submit" class="btn-primary" :disabled="templateClone.saving">{{ templateClone.saving ? t('admin.shippingInventory.saving') : t('admin.shippingInventory.cloneTemplateConfirm') }}</button></div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
@@ -389,9 +375,9 @@
|
||||
<section class="clone-template-dialog" role="dialog" aria-modal="true" aria-labelledby="bulk-parsing-binding-title">
|
||||
<header class="clone-template-header"><div><h3 id="bulk-parsing-binding-title">{{ t('admin.shippingInventory.bulkBindParsingProfile') }}</h3><p>{{ t('admin.shippingInventory.bulkBindParsingProfileHint') }}</p></div><button type="button" class="drawer-close" :aria-label="t('admin.close')" @click="closeBulkParsingBinding">×</button></header>
|
||||
<form class="clone-template-form" @submit.prevent="submitBulkParsingBinding">
|
||||
<label><span>{{ t('admin.shippingInventory.inventorySites') }}</span><select v-model="bulkBinding.sourceIds" multiple required><option v-for="item in sources.filter((row) => !row.enabled)" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.source_code }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.parsingProfiles') }}</span><select v-model.number="bulkBinding.profileId" required><option :value="0">{{ t('admin.shippingInventory.notConfigured') }}</option><option v-for="item in parsingProfiles.filter((row) => row.status === 'published')" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.profile_code }} V{{ item.version }}</option></select></label>
|
||||
<div class="clone-template-actions"><button type="button" class="text-action" :disabled="bulkBinding.saving" @click="closeBulkParsingBinding">{{ t('admin.cancel') }}</button><button type="submit" class="primary-action" :disabled="bulkBinding.saving">{{ bulkBinding.saving ? t('admin.shippingInventory.saving') : t('admin.shippingInventory.bulkBindParsingProfile') }}</button></div>
|
||||
<label><span>{{ t('admin.shippingInventory.inventorySites') }}</span><select v-model="bulkBinding.sourceIds" class="select-field" multiple required><option v-for="item in sources.filter((row) => !row.enabled)" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.source_code }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.parsingProfiles') }}</span><select v-model.number="bulkBinding.profileId" class="select-field" required><option :value="0">{{ t('admin.shippingInventory.notConfigured') }}</option><option v-for="item in parsingProfiles.filter((row) => row.status === 'published')" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.profile_code }} V{{ item.version }}</option></select></label>
|
||||
<div class="clone-template-actions"><button type="button" class="btn-ghost btn-sm" :disabled="bulkBinding.saving" @click="closeBulkParsingBinding">{{ t('admin.cancel') }}</button><button type="submit" class="btn-primary" :disabled="bulkBinding.saving">{{ bulkBinding.saving ? t('admin.shippingInventory.saving') : t('admin.shippingInventory.bulkBindParsingProfile') }}</button></div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
@@ -399,16 +385,16 @@
|
||||
<section class="batch-validation-dialog" role="dialog" aria-modal="true" aria-labelledby="batch-validation-title">
|
||||
<header class="clone-template-header"><div><h3 id="batch-validation-title">{{ t('admin.shippingInventory.batchValidation') }}</h3><p>{{ t('admin.shippingInventory.batchValidationHint') }}</p></div><button type="button" class="drawer-close" :aria-label="t('admin.close')" @click="closeBatchValidation">×</button></header>
|
||||
<form v-if="!batchValidation.result" class="batch-selection" @submit.prevent="submitBatchValidation">
|
||||
<div class="batch-selection-toolbar"><label><span>{{ t('admin.shippingInventory.inventorySites') }}</span><input v-model="batchValidation.query" :placeholder="t('admin.shippingInventory.batchValidationSearch')"></label><div class="batch-selection-actions"><button type="button" class="text-action" :disabled="!filteredBatchValidationSources.length" @click="toggleFilteredBatchValidationSources">{{ allFilteredBatchValidationSourcesSelected ? t('admin.shippingInventory.batchValidationClearFiltered') : t('admin.shippingInventory.batchValidationSelectFiltered') }}</button><b>{{ t('admin.shippingInventory.batchValidationSelected', { count: batchValidation.sourceIds.length }) }}</b></div></div>
|
||||
<div class="batch-selection-toolbar"><label><span>{{ t('admin.shippingInventory.inventorySites') }}</span><input v-model="batchValidation.query" class="input-field" :placeholder="t('admin.shippingInventory.batchValidationSearch')"></label><div class="batch-selection-actions"><button type="button" class="btn-ghost btn-sm" :disabled="!filteredBatchValidationSources.length" @click="toggleFilteredBatchValidationSources">{{ allFilteredBatchValidationSourcesSelected ? t('admin.shippingInventory.batchValidationClearFiltered') : t('admin.shippingInventory.batchValidationSelectFiltered') }}</button><b>{{ t('admin.shippingInventory.batchValidationSelected', { count: batchValidation.sourceIds.length }) }}</b></div></div>
|
||||
<div class="batch-source-list"><label v-for="item in filteredBatchValidationSources" :key="String(item.id)" class="batch-source-option"><input v-model="batchValidation.sourceIds" type="checkbox" :value="Number(item.id)"><span><b>{{ item.display_name || item.source_code }}</b><small>{{ item.source_code }} · {{ connectionName(item.source_code) }}</small></span></label><p v-if="!filteredBatchValidationSources.length" class="batch-empty">{{ t('admin.shippingInventory.batchValidationNoSites') }}</p></div>
|
||||
<div class="clone-template-actions"><button type="button" class="text-action" :disabled="batchValidation.saving" @click="closeBatchValidation">{{ t('admin.cancel') }}</button><button type="submit" class="primary-action" :disabled="batchValidation.saving || !batchValidation.sourceIds.length">{{ batchValidation.saving ? t('admin.shippingInventory.configurationTestRunning') : t('admin.shippingInventory.batchValidation') }}</button></div>
|
||||
<div class="clone-template-actions"><button type="button" class="btn-ghost btn-sm" :disabled="batchValidation.saving" @click="closeBatchValidation">{{ t('admin.cancel') }}</button><button type="submit" class="btn-primary" :disabled="batchValidation.saving || !batchValidation.sourceIds.length">{{ batchValidation.saving ? t('admin.shippingInventory.configurationTestRunning') : t('admin.shippingInventory.batchValidation') }}</button></div>
|
||||
</form>
|
||||
<div v-else class="batch-progress">
|
||||
<div class="batch-progress-heading"><div><span>{{ t(`admin.shippingInventory.batchValidationStatus.${batchValidation.result.status}`) }}</span><strong>{{ t('admin.shippingInventory.batchValidationProgress', batchValidation.result) }}</strong></div><b>{{ batchCompletedCount }} / {{ batchValidation.result.total_count }}</b></div>
|
||||
<div class="batch-progress-bar" role="progressbar" :aria-valuenow="batchCompletedCount" :aria-valuemax="batchValidation.result.total_count"><i :style="{ width: `${batchProgressPercent}%` }"></i></div>
|
||||
<div class="batch-stat-grid"><button type="button" :class="{ active: batchValidation.statusFilter === 'all' }" @click="batchValidation.statusFilter = 'all'"><b>{{ batchValidation.result.total_count }}</b><span>{{ t('admin.shippingInventory.batchValidationStat.total') }}</span></button><button type="button" :class="{ active: batchValidation.statusFilter === 'processing' }" @click="batchValidation.statusFilter = 'processing'"><b>{{ batchProcessingCount }}</b><span>{{ t('admin.shippingInventory.batchValidationStat.processing') }}</span></button><button type="button" :class="{ active: batchValidation.statusFilter === 'completed' }" @click="batchValidation.statusFilter = 'completed'"><b>{{ batchValidation.result.success_count }}</b><span>{{ t('admin.shippingInventory.batchValidationStat.success') }}</span></button><button type="button" :class="{ active: batchValidation.statusFilter === 'completed_empty' }" @click="batchValidation.statusFilter = 'completed_empty'"><b>{{ batchValidation.result.empty_count }}</b><span>{{ t('admin.shippingInventory.batchValidationStat.empty') }}</span></button><button type="button" :class="{ active: batchValidation.statusFilter === 'failed' }" @click="batchValidation.statusFilter = 'failed'"><b>{{ batchValidation.result.failed_count }}</b><span>{{ t('admin.shippingInventory.batchValidationStat.failed') }}</span></button></div>
|
||||
<div class="batch-run-list"><article v-for="run in filteredBatchValidationRuns" :key="run.run_no" class="batch-run" :class="`is-${run.status}`"><span class="batch-run-marker"></span><div><b>{{ sourceTitleById(run.inventory_source_id) }}</b><small>{{ t(`admin.shippingInventory.configurationTestStage.${run.stage}`) }}</small></div><small v-if="run.error_message" class="batch-run-error">{{ run.error_message }}</small></article><p v-if="!filteredBatchValidationRuns.length" class="batch-empty">{{ t('admin.shippingInventory.batchValidationNoRuns') }}</p></div>
|
||||
<div class="clone-template-actions"><button v-if="batchValidation.result.failed_count" type="button" class="secondary-action" @click="retryBatchValidation">{{ t('admin.shippingInventory.retryFailedValidation') }}</button><button type="button" class="primary-action" @click="closeBatchValidation">{{ t('admin.close') }}</button></div>
|
||||
<div class="clone-template-actions"><button v-if="batchValidation.result.failed_count" type="button" class="btn-secondary btn-sm" @click="retryBatchValidation">{{ t('admin.shippingInventory.retryFailedValidation') }}</button><button type="button" class="btn-primary" @click="closeBatchValidation">{{ t('admin.close') }}</button></div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
@@ -1482,24 +1468,11 @@ onMounted(load);
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.inventory-console { color: #334155; }
|
||||
.console-header { display: flex; justify-content: space-between; gap: 20px; padding: 0 0 18px; border-bottom: 1px solid #e2e8f0; }
|
||||
.eyebrow { margin: 0 0 4px; color: #0284c7; font-size: 12px; font-weight: 600; }
|
||||
.console-header h1 { margin: 0; color: #1e293b; font-size: 20px; font-weight: 600; letter-spacing: 0; }
|
||||
.console-header p { margin: 6px 0 0; color: #64748b; font-size: 13px; }
|
||||
.flow-strip { align-self: center; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid #e0f2fe; border-radius: 6px; background: #f0f9ff; color: #0369a1; font-size: 12px; font-weight: 500; }
|
||||
.flow-strip i { color: #7dd3fc; font-style: normal; }
|
||||
.inventory-console { color: var(--text-secondary); }
|
||||
.schema-prerequisite { margin: 0 0 14px; border: 1px solid #fde68a; border-radius: 6px; background: #fffbeb; padding: 10px 12px; color: #92400e; font-size: 13px; }
|
||||
.console-layout { padding-top: 20px; }
|
||||
.workbench-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
|
||||
.workbench-heading h2 { margin: 0; color: #1e293b; font-size: 16px; font-weight: 600; letter-spacing: 0; }
|
||||
.workbench-heading p { max-width: 660px; margin: 5px 0 0; color: #64748b; font-size: 13px; }
|
||||
.primary-action, .secondary-action, .text-action { border: 0; border-radius: 6px; padding: 8px 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
|
||||
.primary-action { background: #0ea5e9; color: #fff; }
|
||||
.primary-action:disabled, .secondary-action:disabled, .text-action:disabled { opacity: .5; cursor: not-allowed; }
|
||||
.secondary-action { background: #f1f5f9; color: #475569; }
|
||||
.text-action { background: transparent; padding: 4px; color: #0284c7; }
|
||||
.text-action.danger { color: #b42318; }
|
||||
.workbench-heading h2 { margin: 0; color: #1e293b; font-size: 18px; font-weight: 600; letter-spacing: 0; line-height: 28px; }
|
||||
.workbench-heading p { max-width: 660px; margin: 5px 0 0; color: #64748b; font-size: 14px; line-height: 20px; }
|
||||
.object-list-panel { min-height: 360px; }
|
||||
.object-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
|
||||
.object-row { position: relative; display: flex; width: 100%; min-height: 72px; flex-direction: column; justify-content: center; gap: 4px; border: 1px solid #e2e8f0; border-radius: 8px; background: #fff; padding: 12px 30px 12px 13px; text-align: left; cursor: pointer; }
|
||||
@@ -1510,22 +1483,22 @@ onMounted(load);
|
||||
.status-dot { position: absolute; top: 18px; right: 12px; width: 7px; height: 7px; border-radius: 50%; }
|
||||
.status-dot.on { background: #22c55e; }
|
||||
.status-dot.off { background: #b2bdc9; }
|
||||
.drawer-mask { position: fixed; z-index: 40; inset: 0; display: flex; justify-content: flex-end; background: rgb(15 23 42 / 28%); }
|
||||
.drawer-mask { position: fixed; z-index: 40; inset: 0; display: flex; justify-content: flex-end; background: var(--overlay-soft); }
|
||||
.workbench-actions { display: flex; flex-wrap: wrap; gap: 10px; }
|
||||
.clone-template-mask { z-index: 80; align-items: center; justify-content: center; padding: 20px; }
|
||||
.clone-template-dialog { width: min(480px, 100%); border-radius: 10px; background: #fff; box-shadow: 0 18px 48px rgb(15 23 42 / 25%); }
|
||||
.clone-template-header { display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid #e2e8f0; padding: 18px 20px; }.clone-template-header h3 { margin: 0; color: #1e293b; font-size: 16px; font-weight: 600; }.clone-template-header p { margin: 5px 0 0; color: #64748b; font-size: 12px; line-height: 1.5; }
|
||||
.clone-template-form { display: grid; gap: 14px; padding: 20px; }.clone-template-form label { display: grid; gap: 6px; color: #64748b; font-size: 12px; font-weight: 500; }.clone-template-form input { min-width: 0; border: 1px solid #d9e2ec; border-radius: 6px; padding: 8px 9px; color: #334155; font: inherit; font-size: 13px; }.clone-template-form small { color: #94a3b8; font-size: 11px; line-height: 1.45; }.clone-template-actions { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid #edf2f7; padding-top: 14px; }
|
||||
.batch-validation-dialog { display: grid; width: min(780px, 100%); max-height: min(720px, calc(100vh - 40px)); grid-template-rows: auto minmax(0, 1fr); overflow: hidden; border-radius: 12px; background: #fff; box-shadow: 0 20px 56px rgb(15 23 42 / 28%); }.batch-selection, .batch-progress { display: grid; min-height: 0; gap: 14px; padding: 18px 20px; }.batch-selection { grid-template-rows: auto minmax(0, 1fr) auto; }.batch-selection-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 14px; }.batch-selection-toolbar label { display: grid; flex: 1; gap: 5px; color: #62788a; font-size: 11px; font-weight: 700; }.batch-selection-toolbar input { min-width: 0; border: 1px solid #d8e5ed; border-radius: 6px; padding: 8px 9px; color: #334155; font: inherit; font-size: 13px; }.batch-selection-actions { display: flex; align-items: center; gap: 8px; }.batch-selection-actions > b { flex: 0 0 auto; border-radius: 999px; background: #e9f7fd; padding: 6px 9px; color: #13759d; font-size: 11px; white-space: nowrap; }.batch-selection-actions .text-action { padding: 6px 8px; background: #f1f7fa; color: #17769d; white-space: nowrap; }.batch-source-list, .batch-run-list { min-height: 0; overflow-y: auto; border: 1px solid #dce8ef; border-radius: 8px; background: #fbfdfe; }.batch-source-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 1px; background: #e3edf3; }.batch-source-option { display: flex; min-width: 0; align-items: flex-start; gap: 9px; background: #fff; padding: 10px 11px; cursor: pointer; }.batch-source-option:hover { background: #f4fbfe; }.batch-source-option input { margin: 3px 0 0; accent-color: #168ebc; }.batch-source-option span { display: grid; min-width: 0; gap: 3px; }.batch-source-option b { overflow: hidden; color: #344b60; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }.batch-source-option small { overflow: hidden; color: #8a9aab; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }.batch-empty { grid-column: 1 / -1; margin: 0; padding: 28px 12px; color: #8797a7; font-size: 12px; text-align: center; }.batch-progress { grid-template-rows: auto auto auto minmax(0, 1fr) auto; }.batch-progress-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; }.batch-progress-heading > div { display: grid; gap: 3px; }.batch-progress-heading span { color: #16759f; font-size: 11px; font-weight: 800; }.batch-progress-heading strong { color: #334c60; font-size: 13px; }.batch-progress-heading > b { color: #1c6f96; font-size: 18px; font-variant-numeric: tabular-nums; }.batch-progress-bar { height: 7px; overflow: hidden; border-radius: 999px; background: #e8f0f5; }.batch-progress-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #22a1c7, #4bb8d7); transition: width .25s ease; }.batch-stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }.batch-stat-grid button { display: grid; gap: 2px; border: 1px solid #e0eaf0; border-radius: 7px; background: #fff; padding: 8px; color: #708393; font: inherit; text-align: left; cursor: pointer; }.batch-stat-grid button:hover, .batch-stat-grid button.active { border-color: #8fd0e7; background: #eef9fd; }.batch-stat-grid b { color: #314b60; font-size: 16px; font-variant-numeric: tabular-nums; }.batch-stat-grid span { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }.batch-run-list { display: grid; align-content: start; }.batch-run { display: grid; grid-template-columns: 9px minmax(0, 1fr) minmax(0, .9fr); align-items: center; gap: 9px; border-bottom: 1px solid #e8eff3; padding: 9px 11px; }.batch-run:last-child { border-bottom: 0; }.batch-run-marker { width: 7px; height: 7px; border-radius: 50%; background: #a9b8c5; }.batch-run > div { display: grid; min-width: 0; gap: 2px; }.batch-run b, .batch-run small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.batch-run b { color: #385166; font-size: 12px; }.batch-run > div small { color: #8a9baa; font-size: 10px; }.batch-run-error { color: #ae493b; font-size: 10px; }.batch-run.is-completed .batch-run-marker { background: #32a665; }.batch-run.is-completed_empty .batch-run-marker { background: #e7a628; }.batch-run.is-failed .batch-run-marker { background: #db6552; }
|
||||
.editor-drawer { width: min(760px, 100vw); height: 100%; overflow-y: auto; border-left: 1px solid #dbe5ed; background: #fff; box-shadow: -12px 0 32px rgb(15 23 42 / 18%); }
|
||||
.drawer-header { position: sticky; z-index: 1; top: 0; display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid #e2e8f0; background: #fff; padding: 18px 20px; }
|
||||
.clone-template-form { display: grid; gap: 14px; padding: 20px; }.clone-template-form label { display: grid; gap: 6px; color: #64748b; font-size: 12px; font-weight: 500; }.clone-template-form .input-field { min-width: 0; padding: 8px 9px; font: inherit; font-size: 13px; }.clone-template-form small { color: #94a3b8; font-size: 11px; line-height: 1.45; }.clone-template-actions { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid #edf2f7; padding-top: 14px; }
|
||||
.batch-validation-dialog { display: grid; width: min(780px, 100%); max-height: min(720px, calc(100vh - 40px)); grid-template-rows: auto minmax(0, 1fr); overflow: hidden; border-radius: 12px; background: #fff; box-shadow: 0 20px 56px rgb(15 23 42 / 28%); }.batch-selection, .batch-progress { display: grid; min-height: 0; gap: 14px; padding: 18px 20px; }.batch-selection { grid-template-rows: auto minmax(0, 1fr) auto; }.batch-selection-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 14px; }.batch-selection-toolbar label { display: grid; flex: 1; gap: 5px; color: #62788a; font-size: 11px; font-weight: 700; }.batch-selection-toolbar .input-field { min-width: 0; padding: 8px 9px; font: inherit; font-size: 13px; }.batch-selection-actions { display: flex; align-items: center; gap: 8px; }.batch-selection-actions > b { flex: 0 0 auto; border-radius: 999px; background: #e9f7fd; padding: 6px 9px; color: #13759d; font-size: 11px; white-space: nowrap; }.batch-selection-actions .btn-ghost { padding: 6px 8px; white-space: nowrap; }.batch-source-list, .batch-run-list { min-height: 0; overflow-y: auto; border: 1px solid #dce8ef; border-radius: 8px; background: #fbfdfe; }.batch-source-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; gap: 1px; background: #e3edf3; }.batch-source-option { display: flex; min-width: 0; align-items: flex-start; gap: 9px; background: #fff; padding: 10px 11px; cursor: pointer; }.batch-source-option:hover { background: #f4fbfe; }.batch-source-option input { margin: 3px 0 0; accent-color: #168ebc; }.batch-source-option span { display: grid; min-width: 0; gap: 3px; }.batch-source-option b { overflow: hidden; color: #344b60; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }.batch-source-option small { overflow: hidden; color: #8a9aab; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }.batch-empty { grid-column: 1 / -1; margin: 0; padding: 28px 12px; color: #8797a7; font-size: 12px; text-align: center; }.batch-progress { grid-template-rows: auto auto auto minmax(0, 1fr) auto; }.batch-progress-heading { display: flex; align-items: end; justify-content: space-between; gap: 16px; }.batch-progress-heading > div { display: grid; gap: 3px; }.batch-progress-heading span { color: #16759f; font-size: 11px; font-weight: 800; }.batch-progress-heading strong { color: #334c60; font-size: 13px; }.batch-progress-heading > b { color: #1c6f96; font-size: 18px; font-variant-numeric: tabular-nums; }.batch-progress-bar { height: 7px; overflow: hidden; border-radius: 999px; background: #e8f0f5; }.batch-progress-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #22a1c7, #4bb8d7); transition: width .25s ease; }.batch-stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }.batch-stat-grid button { display: grid; gap: 2px; border: 1px solid #e0eaf0; border-radius: 7px; background: #fff; padding: 8px; color: #708393; font: inherit; text-align: left; cursor: pointer; }.batch-stat-grid button:hover, .batch-stat-grid button.active { border-color: #8fd0e7; background: #eef9fd; }.batch-stat-grid b { color: #314b60; font-size: 16px; font-variant-numeric: tabular-nums; }.batch-stat-grid span { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }.batch-run-list { display: grid; align-content: start; }.batch-run { display: grid; grid-template-columns: 9px minmax(0, 1fr) minmax(0, .9fr); align-items: center; gap: 9px; border-bottom: 1px solid #e8eff3; padding: 9px 11px; }.batch-run:last-child { border-bottom: 0; }.batch-run-marker { width: 7px; height: 7px; border-radius: 50%; background: #a9b8c5; }.batch-run > div { display: grid; min-width: 0; gap: 2px; }.batch-run b, .batch-run small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.batch-run b { color: #385166; font-size: 12px; }.batch-run > div small { color: #8a9baa; font-size: 10px; }.batch-run-error { color: #ae493b; font-size: 10px; }.batch-run.is-completed .batch-run-marker { background: #32a665; }.batch-run.is-completed_empty .batch-run-marker { background: #e7a628; }.batch-run.is-failed .batch-run-marker { background: #db6552; }
|
||||
.editor-drawer { width: min(760px, 100vw); height: 100%; overflow-y: auto; border-left: 1px solid var(--border-default); background: var(--bg-surface); box-shadow: -12px 0 32px rgb(15 23 42 / 18%); }
|
||||
.drawer-header { position: sticky; z-index: 1; top: 0; display: flex; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--border-default); background: var(--bg-surface); padding: 18px 20px; }
|
||||
.drawer-title-row { display: flex; align-items: center; gap: 9px; }.drawer-header h3 { margin: 0; color: #1e293b; font-size: 16px; font-weight: 600; }.source-run-status { flex: 0 0 auto; border: 1px solid #f2d3cd; border-radius: 999px; background: #fff4f1; padding: 3px 7px; color: #a53f30; font-size: 11px; font-weight: 700; }.source-run-status.enabled { border-color: #c7e7d0; background: #eefaf1; color: #247442; }
|
||||
.drawer-header p { margin: 5px 0 0; color: #64748b; font-size: 12px; line-height: 1.5; }
|
||||
.drawer-close { width: 30px; height: 30px; border: 0; border-radius: 6px; background: transparent; color: #64748b; font-size: 24px; line-height: 1; cursor: pointer; }
|
||||
.drawer-close:hover { background: #f1f5f9; color: #334155; }
|
||||
.editor-form { display: grid; align-content: start; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 20px; }
|
||||
.editor-form label { display: flex; flex-direction: column; gap: 6px; color: #64748b; font-size: 12px; font-weight: 500; }
|
||||
.editor-form input, .editor-form select { min-width: 0; border: 1px solid #d9e2ec; border-radius: 6px; background: #fff; padding: 8px 9px; color: #334155; font: inherit; font-size: 13px; font-weight: 400; }
|
||||
.editor-form input, .editor-form select { min-width: 0; border: 1px solid var(--border-default); border-radius: 6px; background: var(--bg-surface); padding: 8px 9px; color: var(--text-secondary); font: inherit; font-size: 13px; font-weight: 400; }
|
||||
.editor-form small { color: #94a3b8; font-size: 11px; font-weight: 400; line-height: 1.45; }
|
||||
.inventory-mapping-tabs { display: flex; gap: 4px; margin: 0 0 14px; border-bottom: 1px solid #e2e8f0; }
|
||||
.inventory-mapping-tabs button { border: 0; border-bottom: 2px solid transparent; background: transparent; padding: 8px 12px; color: #64748b; font: inherit; font-size: 13px; cursor: pointer; }
|
||||
@@ -1589,6 +1562,6 @@ onMounted(load);
|
||||
.audit-detail dl { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 0; margin: 0; padding: 18px 20px; }.audit-detail dt, .audit-detail dd { margin: 0; padding: 11px 0; border-bottom: 1px solid #edf2f7; font-size: 13px; }.audit-detail dt { color: #64748b; }.audit-detail dd { overflow-wrap: anywhere; color: #334155; }
|
||||
.object-list .empty-state { grid-column: 1 / -1; display: grid; min-height: 260px; place-items: center; }
|
||||
.empty-state { border: 1px dashed #c9d7e5; border-radius: 10px; background: #f9fbfd; padding: 38px 18px; color: #7b899a; font-size: 13px; text-align: center; }
|
||||
@media (max-width: 980px) { .console-header { display: block; } .flow-strip { display: inline-flex; margin-top: 18px; } .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card { grid-template-columns: 1fr 1fr; } .mapping-value-row { grid-template-columns: minmax(0, 1.6fr) minmax(180px, 1fr); }.readiness-audit { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
||||
@media (max-width: 640px) { .inventory-console { padding: 18px; } .editor-form, .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card, .mapping-value-row, .parsing-mapping-card, .readonly-mapping-section .parsing-mapping-card, .parsing-summary { grid-template-columns: 1fr; } .mapping-arrow { transform: rotate(90deg); }.workbench-heading { display: block; } .workbench-heading .primary-action { margin-top: 12px; }.batch-source-list { grid-template-columns: 1fr; }.batch-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }.batch-run { grid-template-columns: 9px minmax(0, 1fr); }.batch-run-error { grid-column: 2; }.readiness-heading { display: grid; }.readiness-count { justify-self: start; }.readiness-steps li { grid-template-columns: 24px minmax(0, 1fr); }.readiness-action { grid-column: 2; justify-self: start; }.readiness-footer { justify-content: stretch; }.readiness-footer .primary-action { width: 100%; } }
|
||||
@media (max-width: 980px) { .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card { grid-template-columns: 1fr 1fr; } .mapping-value-row { grid-template-columns: minmax(0, 1.6fr) minmax(180px, 1fr); }.readiness-audit { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
|
||||
@media (max-width: 640px) { .inventory-console { padding: 18px; } .editor-form, .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card, .mapping-value-row, .parsing-mapping-card, .readonly-mapping-section .parsing-mapping-card, .parsing-summary { grid-template-columns: 1fr; } .mapping-arrow { transform: rotate(90deg); }.workbench-heading { display: block; } .workbench-heading .btn-primary { margin-top: 12px; }.batch-source-list { grid-template-columns: 1fr; }.batch-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }.batch-run { grid-template-columns: 9px minmax(0, 1fr); }.batch-run-error { grid-column: 2; }.readiness-heading { display: grid; }.readiness-count { justify-self: start; }.readiness-steps li { grid-template-columns: 24px minmax(0, 1fr); }.readiness-action { grid-column: 2; justify-self: start; }.readiness-footer { justify-content: stretch; }.readiness-footer .btn-primary { width: 100%; } }
|
||||
</style>
|
||||
+305
@@ -0,0 +1,305 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfileBlindTestPage.vue
|
||||
用途:维护订单模板草稿的独立盲测证据,并完成执行和批准。
|
||||
依赖:盲测 API、Vue Router、统一业务错误提示和四语言文案。
|
||||
逻辑:验证页进入本页;管理员选择未参与建模的样本、复核候选后写入真值,再执行并批准,最后回到发布检查。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
approveOrderProfileTestSuite,
|
||||
confirmOrderProfileBlindTestReviews,
|
||||
createOrderProfileTestSuite,
|
||||
executeOrderProfileTestSuite,
|
||||
listOrderProfileBlindTestAvailableSamples,
|
||||
listOrderProfileBoundSamples,
|
||||
previewOrderProfileBlindTestCandidate,
|
||||
removeOrderProfileTestSample,
|
||||
} from '@/features/admin/api/shipping-order-document-profile.api';
|
||||
import type {
|
||||
OrderProfileBlindTestAvailableSample,
|
||||
OrderProfileBlindTestCandidate,
|
||||
OrderProfileTestSuite,
|
||||
} from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const message = useMessage();
|
||||
const { t } = useI18n();
|
||||
const profileId = Number(route.params.profileId);
|
||||
const sessionId = String(route.query.editorSessionId || '').trim() || crypto.randomUUID();
|
||||
const suite = ref<OrderProfileTestSuite | null>(null);
|
||||
const availableSamples = ref<OrderProfileBlindTestAvailableSample[]>([]);
|
||||
const selectedSampleKey = ref('');
|
||||
const candidate = ref<OrderProfileBlindTestCandidate | null>(null);
|
||||
const rowReviews = ref<Array<{ correct: boolean; correction: string }>>([]);
|
||||
const orderFieldReviews = ref<Record<string, { correct: boolean; value: string }>>({});
|
||||
const loading = ref(false);
|
||||
const working = ref(false);
|
||||
const hasTrainingSample = ref(false);
|
||||
const availableSamplesLoaded = ref(false);
|
||||
const availableSamplesLoading = ref(false);
|
||||
|
||||
/** 当前选择仅以 API 列表中的 document/table 组合为准,避免浏览器提交伪造样本。 */
|
||||
const selectedSample = computed(() => availableSamples.value.find((item) => `${item.document_id}:${item.table_id}` === selectedSampleKey.value) || null);
|
||||
/** 盲测执行成功且尚未批准时才允许批准;批准后证据在服务端保持不可变。 */
|
||||
const canApprove = computed(() => hasTrainingSample.value && suite.value?.status === 'draft' && suite.value.latest_run?.status === 'passed');
|
||||
/** 将服务端安全失败码转为管理员可定位的摘要;不回显订单正文或人工真值。 */
|
||||
const failureDetails = computed(() => (suite.value?.latest_run?.failure_codes || []).map((code) => {
|
||||
const parts = code.split(':');
|
||||
const sampleId = parts[0] === 'sample' ? Number(parts[1]) : null;
|
||||
const sample = sampleId == null ? null : suite.value?.samples.find((item) => item.id === sampleId);
|
||||
const sampleName = sample ? `${sample.filename} · P${sample.page_no}` : t('admin.shippingOrderProfiles.blindTest.unknownSample');
|
||||
if (parts[2] === 'order_field') {
|
||||
const fieldCode = parts[3] || '';
|
||||
const reason = parts[4] || '';
|
||||
const reasonKey = reason === 'mismatch' ? 'fieldMismatch' : reason === 'needs_review' ? 'fieldNeedsReview' : 'fieldUnavailable';
|
||||
return { code, message: t(`admin.shippingOrderProfiles.blindTest.failure.${reasonKey}`, { sample: sampleName, field: fieldCode }) };
|
||||
}
|
||||
if (parts[2] === 'coordinate_evidence_missing') {
|
||||
return { code, message: t('admin.shippingOrderProfiles.blindTest.failure.coordinateEvidenceMissing', { sample: sampleName }) };
|
||||
}
|
||||
if (parts[2] === 'mismatch') {
|
||||
return { code, message: t('admin.shippingOrderProfiles.blindTest.failure.rowsMismatch', { sample: sampleName }) };
|
||||
}
|
||||
return { code, message: t('admin.shippingOrderProfiles.blindTest.failure.unknown', { sample: sampleName }) };
|
||||
}));
|
||||
/** 读取订单字段复核状态;候选加载完成时会初始化,默认值仅用于渲染过程中的安全兜底。 */
|
||||
function orderFieldReview(fieldCode: string): { correct: boolean; value: string } {
|
||||
return orderFieldReviews.value[fieldCode] || { correct: true, value: '' };
|
||||
}
|
||||
/** 更新单个订单字段的人工复核状态,保持其他字段复核结果不被输入事件覆盖。 */
|
||||
function updateOrderFieldReview(fieldCode: string, patch: Partial<{ correct: boolean; value: string }>): void {
|
||||
orderFieldReviews.value[fieldCode] = { ...orderFieldReview(fieldCode), ...patch };
|
||||
}
|
||||
|
||||
/** 将统一业务错误转换为安全的界面提示,不暴露盲测真值或内部布局数据。 */
|
||||
function report(error: unknown): void {
|
||||
const code = error instanceof BusinessError ? error.code : '';
|
||||
message.error(code ? t(`errors.${code}`, code) : t('admin.orderProfileValidation.failed'));
|
||||
}
|
||||
|
||||
/** 创建或读取当前草稿 checksum 对应的盲测集;候选样本按需加载,避免进入页面时扫描全部历史样本。 */
|
||||
async function loadSuite(): Promise<void> {
|
||||
loading.value = true;
|
||||
try {
|
||||
const [nextSuite, boundSamples] = await Promise.all([
|
||||
createOrderProfileTestSuite(profileId),
|
||||
listOrderProfileBoundSamples(profileId),
|
||||
]);
|
||||
suite.value = nextSuite;
|
||||
hasTrainingSample.value = boundSamples.some((item) => item.sample_role === 'training');
|
||||
} catch (error) {
|
||||
report(error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 仅在管理员需要挑选盲测样本时加载候选摘要,避免页面首屏等待历史样本逐份证据校验。 */
|
||||
async function loadAvailableSamples(): Promise<void> {
|
||||
if (!suite.value || suite.value.status !== 'draft' || availableSamplesLoaded.value || availableSamplesLoading.value) return;
|
||||
availableSamplesLoading.value = true;
|
||||
try {
|
||||
availableSamples.value = (await listOrderProfileBlindTestAvailableSamples(suite.value.id)).samples;
|
||||
availableSamplesLoaded.value = true;
|
||||
} catch (error) {
|
||||
report(error);
|
||||
} finally {
|
||||
availableSamplesLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 运行选中独立样本并初始化逐行、逐订单字段的人工复核表单。 */
|
||||
async function previewSample(): Promise<void> {
|
||||
if (!suite.value || !selectedSample.value) return;
|
||||
working.value = true;
|
||||
try {
|
||||
candidate.value = await previewOrderProfileBlindTestCandidate(suite.value.id, selectedSample.value);
|
||||
rowReviews.value = candidate.value.rows.map(() => ({ correct: true, correction: '' }));
|
||||
orderFieldReviews.value = Object.fromEntries(candidate.value.order_fields.map((field) => [
|
||||
field.field_code,
|
||||
{ correct: true, value: field.value == null ? '' : String(field.value) },
|
||||
]));
|
||||
} catch (error) {
|
||||
report(error);
|
||||
} finally {
|
||||
working.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 将错误明细的管理员更正解析为字段对象;正确项由服务端以候选值固化。 */
|
||||
function reviewedRows(): Array<Record<string, unknown>> | null {
|
||||
const reviews: Array<Record<string, unknown>> = [];
|
||||
for (const review of rowReviews.value) {
|
||||
if (review.correct) {
|
||||
reviews.push({ correct: true });
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
const values = JSON.parse(review.correction);
|
||||
if (!values || typeof values !== 'object' || Array.isArray(values)) throw new Error('invalid');
|
||||
reviews.push({ correct: false, values });
|
||||
} catch {
|
||||
message.error(t('admin.shippingOrderProfiles.blindTest.correctionInvalid'));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return reviews;
|
||||
}
|
||||
|
||||
/** 提交全量人工复核,将候选结果或管理员更正转换为服务端受保护的盲测真值。 */
|
||||
async function confirmReview(): Promise<void> {
|
||||
if (!suite.value || !candidate.value) return;
|
||||
const reviews = reviewedRows();
|
||||
if (!reviews) return;
|
||||
working.value = true;
|
||||
try {
|
||||
suite.value = await confirmOrderProfileBlindTestReviews(suite.value.id, {
|
||||
document_id: candidate.value.document_id,
|
||||
table_id: candidate.value.table_id,
|
||||
row_reviews: reviews,
|
||||
order_field_reviews: Object.fromEntries(Object.entries(orderFieldReviews.value).map(([fieldCode, review]) => [
|
||||
fieldCode,
|
||||
review.correct ? { correct: true } : { correct: false, value: review.value },
|
||||
])),
|
||||
});
|
||||
candidate.value = null;
|
||||
selectedSampleKey.value = '';
|
||||
availableSamplesLoaded.value = false;
|
||||
availableSamples.value = [];
|
||||
message.success(t('admin.shippingOrderProfiles.blindTest.addedSamples'));
|
||||
} catch (error) {
|
||||
report(error);
|
||||
} finally {
|
||||
working.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 删除草稿阶段误加的盲测样本;批准后的套件会由服务端拒绝变更。 */
|
||||
async function removeSample(sampleId: number): Promise<void> {
|
||||
if (!suite.value) return;
|
||||
working.value = true;
|
||||
try {
|
||||
suite.value = await removeOrderProfileTestSample(suite.value.id, sampleId);
|
||||
availableSamplesLoaded.value = false;
|
||||
availableSamples.value = [];
|
||||
} catch (error) {
|
||||
report(error);
|
||||
} finally {
|
||||
working.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 执行当前完整盲测集;失败原因保留在安全摘要并展示给管理员,不能绕过批准。 */
|
||||
async function executeSuite(): Promise<void> {
|
||||
if (!suite.value) return;
|
||||
working.value = true;
|
||||
try {
|
||||
suite.value = await executeOrderProfileTestSuite(suite.value.id);
|
||||
} catch (error) {
|
||||
report(error);
|
||||
} finally {
|
||||
working.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 批准刚刚通过的当前 checksum 盲测,作为发布门禁所需的质量凭证。 */
|
||||
async function approveSuite(): Promise<void> {
|
||||
if (!suite.value || !canApprove.value) return;
|
||||
working.value = true;
|
||||
try {
|
||||
suite.value = await approveOrderProfileTestSuite(suite.value.id);
|
||||
message.success(t('admin.shippingOrderProfiles.blindTest.approvedHint'));
|
||||
} catch (error) {
|
||||
report(error);
|
||||
} finally {
|
||||
working.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 返回验证页保留同一浏览器标签身份,避免在流程切换中误触发租约冲突。 */
|
||||
function backToValidation(): void {
|
||||
router.push({ name: 'AdminShippingOrderDocumentProfileValidate', params: route.params, query: { editorSessionId: sessionId } });
|
||||
}
|
||||
|
||||
/** 返回编辑器绑定当前标注样本为训练证据,盲测样本保持与建模样本独立。 */
|
||||
function goToEditor(): void {
|
||||
router.push({ name: 'AdminShippingOrderDocumentProfileEdit', params: route.params, query: { editorSessionId: sessionId } });
|
||||
}
|
||||
|
||||
/** 盲测批准后才跳转发布检查;后端仍会再次验证当前草稿 checksum。 */
|
||||
function goToPublishCheck(): void {
|
||||
if (suite.value?.status !== 'approved') return;
|
||||
router.push({ name: 'AdminShippingOrderDocumentProfilePublishCheck', params: route.params, query: { editorSessionId: sessionId } });
|
||||
}
|
||||
|
||||
onMounted(loadSuite);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="blind-test-page">
|
||||
<header>
|
||||
<div><h1 class="section-title">{{ t('admin.shippingOrderProfiles.blindTest.title') }}</h1><p class="section-desc mt-1">{{ t('admin.shippingOrderProfiles.blindTest.reviewHint') }}</p></div>
|
||||
<div class="actions"><button type="button" class="btn-secondary" @click="backToValidation">{{ t('admin.shippingOrderProfiles.blindTest.backToValidation') }}</button><button v-if="suite?.status === 'approved'" type="button" class="btn-primary" @click="goToPublishCheck">{{ t('admin.shippingOrderProfiles.blindTest.goPublishCheck') }}</button></div>
|
||||
</header>
|
||||
|
||||
<p v-if="loading">{{ t('admin.orderProfileValidation.loading') }}</p>
|
||||
<template v-else-if="suite">
|
||||
<section class="card suite-summary"><div><h2>{{ t('admin.shippingOrderProfiles.blindTest.samples', { count: suite.sample_count, status: t(`admin.shippingOrderProfiles.versionCenter.testStatus.${suite.status}`) }) }}</h2><p v-if="suite.latest_run">{{ t('admin.shippingOrderProfiles.blindTest.latestResult', { status: suite.latest_run.status, passed: suite.latest_run.passed_sample_count, count: suite.latest_run.sample_count }) }}</p><p v-else>{{ t('admin.shippingOrderProfiles.blindTest.notRun') }}</p></div><span :class="`status ${suite.status}`">{{ t(`admin.shippingOrderProfiles.versionCenter.testStatus.${suite.status}`) }}</span></section>
|
||||
|
||||
<section v-if="failureDetails.length" class="card failure-details">
|
||||
<div><h2>{{ t('admin.shippingOrderProfiles.blindTest.failure.title') }}</h2><p>{{ t('admin.shippingOrderProfiles.blindTest.failure.hint') }}</p></div>
|
||||
<ul><li v-for="failure in failureDetails" :key="failure.code"><span>{{ failure.message }}</span><code>{{ failure.code }}</code></li></ul>
|
||||
</section>
|
||||
|
||||
<section v-if="suite.status === 'draft'" class="card">
|
||||
<h2>{{ t('admin.shippingOrderProfiles.blindTest.selectIndependentSample') }}</h2>
|
||||
<p v-if="!availableSamplesLoaded">{{ t('admin.shippingOrderProfiles.blindTest.loadIndependentSamplesHint') }}</p>
|
||||
<p v-else-if="!availableSamples.length">{{ t('admin.shippingOrderProfiles.blindTest.noIndependentSamples') }}</p>
|
||||
<div class="sample-picker"><button v-if="!availableSamplesLoaded" type="button" class="btn-secondary" :disabled="availableSamplesLoading" @click="loadAvailableSamples">{{ availableSamplesLoading ? t('admin.shippingOrderProfiles.blindTest.loadingIndependentSamples') : t('admin.shippingOrderProfiles.blindTest.loadIndependentSamples') }}</button><template v-else-if="availableSamples.length"><select v-model="selectedSampleKey" class="select-field"><option value="">{{ t('admin.shippingOrderProfiles.blindTest.selectSamplePlaceholder') }}</option><option v-for="sample in availableSamples" :key="`${sample.document_id}:${sample.table_id}`" :value="`${sample.document_id}:${sample.table_id}`">{{ sample.filename }} · P{{ sample.page_no }}</option></select><button type="button" class="btn-primary" :disabled="!selectedSample || working" @click="previewSample">{{ t('admin.shippingOrderProfiles.blindTest.addCurrentSample') }}</button></template></div>
|
||||
</section>
|
||||
|
||||
<section v-if="candidate" class="card candidate-card">
|
||||
<h2>{{ t('admin.shippingOrderProfiles.blindTest.reviewHint') }}</h2>
|
||||
<p v-if="!candidate.rows.length">{{ t('admin.shippingOrderProfiles.blindTest.candidateRowsEmpty') }}</p>
|
||||
<article v-for="(row, index) in candidate.rows" :key="index" class="review-item">
|
||||
<template v-if="rowReviews[index]">
|
||||
<h3>{{ t('admin.shippingOrderProfiles.blindTest.row', { index: index + 1 }) }}</h3><code>{{ JSON.stringify(row) }}</code>
|
||||
<label><input v-model="rowReviews[index].correct" type="checkbox">{{ t('admin.shippingOrderProfiles.blindTest.correct') }}</label>
|
||||
<textarea v-if="!rowReviews[index].correct" v-model="rowReviews[index].correction" class="input-field" :placeholder="t('admin.shippingOrderProfiles.blindTest.expectedRowsPlaceholder')" />
|
||||
</template>
|
||||
</article>
|
||||
<article v-for="field in candidate.order_fields" :key="field.field_code" class="review-item">
|
||||
<h3>{{ field.field_code }}</h3><code>{{ field.value ?? t('admin.shippingOrderProfiles.emptyCandidateValue') }}</code>
|
||||
<label><input :checked="orderFieldReview(field.field_code).correct" type="checkbox" @change="updateOrderFieldReview(field.field_code, { correct: ($event.target as HTMLInputElement).checked })">{{ t('admin.shippingOrderProfiles.blindTest.correct') }}</label>
|
||||
<input v-if="!orderFieldReview(field.field_code).correct" class="input-field" :value="orderFieldReview(field.field_code).value" :placeholder="t('admin.shippingOrderProfiles.blindTest.correctedValue')" @input="updateOrderFieldReview(field.field_code, { value: ($event.target as HTMLInputElement).value })">
|
||||
</article>
|
||||
<button type="button" class="btn-primary" :disabled="working || !candidate.rows.length" @click="confirmReview">{{ t('admin.shippingOrderProfiles.blindTest.confirmReview') }}</button>
|
||||
</section>
|
||||
|
||||
<section class="card"><h2>{{ t('admin.shippingOrderProfiles.blindTest.addedSamples') }}</h2><p>{{ t('admin.shippingOrderProfiles.blindTest.addedSamplesHint') }}</p><ul v-if="suite.samples.length"><li v-for="sample in suite.samples" :key="sample.id"><span>{{ sample.filename }} · P{{ sample.page_no }}</span><button v-if="suite.status === 'draft'" type="button" class="btn-secondary btn-sm" :disabled="working" @click="removeSample(sample.id)">{{ t('admin.shippingOrderProfiles.blindTest.removeSample') }}</button></li></ul><p v-else>{{ t('admin.shippingOrderProfiles.blindTest.noIndependentSamples') }}</p></section>
|
||||
|
||||
<section class="card execution"><div><h2>{{ t('admin.shippingOrderProfiles.blindTest.execution') }}</h2><p>{{ t('admin.shippingOrderProfiles.blindTest.runHint') }}</p><p v-if="!hasTrainingSample" class="training-required">{{ t('admin.shippingOrderProfiles.blindTest.trainingRequired') }}</p></div><div class="actions"><button v-if="suite.status === 'draft'" type="button" class="btn-secondary" :disabled="working || !suite.sample_count" @click="executeSuite">{{ t('admin.shippingOrderProfiles.blindTest.run') }}</button><button v-if="suite.status === 'draft' && !hasTrainingSample" type="button" class="btn-secondary" :disabled="working" @click="goToEditor">{{ t('admin.shippingOrderProfiles.blindTest.goToEditor') }}</button><button v-if="suite.status === 'draft'" type="button" class="btn-primary" :disabled="working || !canApprove" @click="approveSuite">{{ t('admin.shippingOrderProfiles.blindTest.approve') }}</button></div></section>
|
||||
</template>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.blind-test-page { padding: 24px; color: var(--text-secondary); }
|
||||
header, .suite-summary, .execution, .actions, .sample-picker, li { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
||||
header { align-items: flex-start; margin-bottom: 24px; } h1, h2, h3, p { margin: 0; } h2 { font-size: 16px; } h3 { font-size: 14px; } p:not(.section-desc) { margin-top: 6px; color: var(--text-muted); font-size: 13px; line-height: 1.5; }
|
||||
.card { display: grid; gap: 14px; margin-top: 14px; border: 1px solid var(--border-default); border-radius: 12px; background: var(--bg-surface); padding: 18px; }
|
||||
.status { color: var(--status-warning-fg); font-weight: 700; } .status.approved { color: var(--status-success-fg); } .status.superseded { color: var(--status-error-fg); }
|
||||
.sample-picker .select-field { min-width: 260px; } .candidate-card .input-field { padding: 8px; border-radius: 6px; } textarea.input-field { min-height: 72px; font-family: ui-monospace, monospace; }
|
||||
.candidate-card { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); } .candidate-card > h2, .candidate-card > p, .candidate-card > button { grid-column: 1 / -1; }
|
||||
.review-item { display: grid; gap: 8px; border: 1px solid var(--border-default); border-radius: 8px; padding: 12px; } code { overflow-wrap: anywhere; white-space: pre-wrap; color: var(--text-primary); font-size: 12px; } label { display: flex; gap: 6px; align-items: center; }
|
||||
ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; } li { border-top: 1px solid var(--border-default); padding-top: 8px; }
|
||||
.failure-details { border-color: var(--status-error-border); background: var(--status-error-bg); }.failure-details h2 { color: var(--status-error-fg); }.failure-details li { display: grid; gap: 4px; color: var(--status-error-fg); }.failure-details code { color: var(--status-error-fg); }
|
||||
.training-required { color: var(--status-warning-fg) !important; font-weight: 600; }
|
||||
@media (max-width: 700px) { header, .suite-summary, .execution, .sample-picker { align-items: stretch; flex-direction: column; } .sample-picker .select-field { min-width: 0; width: 100%; } }
|
||||
</style>
|
||||
+13
-11
@@ -26,6 +26,7 @@ const message = useMessage();
|
||||
const step = ref(1);
|
||||
const saving = ref(false);
|
||||
const schemas = ref<ShippingOrderSchemaVersion[]>([]);
|
||||
const schemasResolved = ref(false);
|
||||
const samples = ref<Array<{ document_id: number; intake_no: string; filename?: string | null; table_count: number }>>([]);
|
||||
const tables = ref<Array<{ table_id: string; page_no: number; row_count: number; column_count: number; rows: string[][] }>>([]);
|
||||
const identity = reactive<Identity>({ displayName: '', schemaId: 0 });
|
||||
@@ -53,6 +54,7 @@ async function loadContext(): Promise<void> {
|
||||
const [state, nextSamples] = await Promise.all([getShippingOrderSchemaState(), listOrderProfileSamples()]);
|
||||
schemas.value = state.versions || [];
|
||||
samples.value = nextSamples;
|
||||
schemasResolved.value = true;
|
||||
} catch (error) {
|
||||
message.error(error instanceof BusinessError ? error.message : t('admin.shippingOrderProfiles.wizard.loadFailed'));
|
||||
}
|
||||
@@ -121,9 +123,8 @@ onMounted(loadContext);
|
||||
<section class="wizard-page">
|
||||
<div class="wizard-shell">
|
||||
<header class="wizard-heading">
|
||||
<div class="wizard-eyebrow"><Sparkles :size="16" /> {{ t('admin.shippingOrderProfiles.title') }}</div>
|
||||
<h1>{{ t('admin.shippingOrderProfiles.wizard.title') }}</h1>
|
||||
<p>{{ t('admin.shippingOrderProfiles.wizard.description') }}</p>
|
||||
<h1 class="section-title">{{ t('admin.shippingOrderProfiles.wizard.title') }}</h1>
|
||||
<p class="section-desc mt-1">{{ t('admin.shippingOrderProfiles.wizard.description') }}</p>
|
||||
</header>
|
||||
|
||||
<ol class="stepper" :aria-label="t('admin.shippingOrderProfiles.wizard.steps', { step })">
|
||||
@@ -142,6 +143,7 @@ onMounted(loadContext);
|
||||
v-if="step === 1"
|
||||
:model-value="identity"
|
||||
:schemas="schemas"
|
||||
:schemas-resolved="schemasResolved"
|
||||
@update:model-value="updateIdentity"
|
||||
/>
|
||||
<OrderProfileSampleStep v-else-if="step === 2" v-model="documentId" :samples="samples" @uploaded="refreshSamples" />
|
||||
@@ -149,13 +151,13 @@ onMounted(loadContext);
|
||||
</main>
|
||||
|
||||
<footer class="wizard-actions">
|
||||
<button type="button" class="button button--secondary" @click="router.push({ name: 'AdminShippingOrderDocumentProfiles' })">{{ t('admin.cancel') }}</button>
|
||||
<button type="button" class="btn-secondary" @click="router.push({ name: 'AdminShippingOrderDocumentProfiles' })">{{ t('admin.cancel') }}</button>
|
||||
<span class="wizard-actions__spacer" />
|
||||
<button v-if="step > 1" type="button" class="button button--ghost" @click="step -= 1"><ArrowLeft :size="17" />{{ t('admin.shippingOrderProfiles.wizard.previous') }}</button>
|
||||
<button v-if="step < 3" type="button" class="button button--primary" :disabled="!canNext" @click="next">{{ t('admin.shippingOrderProfiles.wizard.next') }}<ArrowRight :size="17" /></button>
|
||||
<button v-if="step > 1" type="button" class="btn-ghost" @click="step -= 1"><ArrowLeft :size="17" />{{ t('admin.shippingOrderProfiles.wizard.previous') }}</button>
|
||||
<button v-if="step < 3" type="button" class="btn-primary" :disabled="!canNext" @click="next">{{ t('admin.shippingOrderProfiles.wizard.next') }}<ArrowRight :size="17" /></button>
|
||||
<template v-else>
|
||||
<button type="button" class="button button--secondary" :disabled="saving || !canNext" @click="finish(false)">{{ t('admin.shippingOrderProfiles.wizard.createDraft') }}</button>
|
||||
<button type="button" class="button button--primary" :disabled="saving || !canNext" @click="finish(true)">{{ t('admin.shippingOrderProfiles.wizard.createAndEdit') }}<ArrowRight :size="17" /></button>
|
||||
<button type="button" class="btn-secondary" :disabled="saving || !canNext" @click="finish(false)">{{ t('admin.shippingOrderProfiles.wizard.createDraft') }}</button>
|
||||
<button type="button" class="btn-primary" :disabled="saving || !canNext" @click="finish(true)">{{ t('admin.shippingOrderProfiles.wizard.createAndEdit') }}<ArrowRight :size="17" /></button>
|
||||
</template>
|
||||
</footer>
|
||||
</div>
|
||||
@@ -165,9 +167,9 @@ onMounted(loadContext);
|
||||
<style scoped>
|
||||
.wizard-page { min-height: 100%; padding: 24px; background: #f6f8fc; }
|
||||
.wizard-shell { width: 100%; }
|
||||
.wizard-heading { margin-bottom: 28px; }.wizard-eyebrow { display: flex; align-items: center; gap: 7px; color: #1677d2; font-size: .82rem; font-weight: 750; letter-spacing: .04em; }.wizard-heading h1 { margin: 10px 0 7px; color: #15213b; font-size: clamp(1.75rem, 3vw, 2.35rem); letter-spacing: -.035em; }.wizard-heading p { margin: 0; color: #64748b; }
|
||||
.wizard-heading { margin-bottom: 28px; }.wizard-heading h1, .wizard-heading p { margin: 0; }
|
||||
.stepper { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin: 0 0 18px; padding: 0; list-style: none; }.stepper li { display: flex; align-items: center; gap: 10px; color: #94a3b8; font-size: .86rem; font-weight: 650; }.stepper li:not(:last-child)::after { width: 100%; height: 1px; margin-left: 10px; background: #dbe4f0; content: ''; }.stepper li.active { color: #1677d2; }.stepper li.complete { color: #0f8a65; }.stepper-icon { display: inline-grid; flex: 0 0 auto; width: 32px; height: 32px; place-items: center; border: 1px solid currentColor; border-radius: 50%; background: #fff; }.stepper .complete .stepper-icon { color: #fff; border-color: #0f8a65; background: #0f8a65; }.stepper small { display: block; margin-bottom: 1px; color: #94a3b8; font-size: .68rem; font-weight: 700; text-transform: uppercase; }
|
||||
.wizard-card { min-height: 360px; padding: clamp(24px, 4vw, 44px); border: 1px solid #e1e8f2; border-radius: 12px; background: #fff; box-shadow: 0 8px 24px rgb(15 23 42 / .06); }.wizard-card__heading { margin-bottom: 28px; padding-bottom: 18px; border-bottom: 1px solid #edf1f7; }.wizard-card__heading span { color: #1677d2; font-size: .76rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }.wizard-card__heading h2 { margin: 6px 0 0; color: #1e293b; font-size: 1.25rem; }
|
||||
.wizard-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }.wizard-actions__spacer { flex: 1; }.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 42px; padding: 0 15px; border: 1px solid transparent; border-radius: 9px; font-weight: 700; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, background .15s ease; }.button:hover:not(:disabled) { transform: translateY(-1px); }.button:focus-visible { outline: 3px solid rgb(22 119 210 / .25); outline-offset: 2px; }.button:disabled { opacity: .48; cursor: not-allowed; }.button--primary { color: #fff; border-color: #1668dc; background: #1677d2; box-shadow: 0 6px 16px rgb(22 119 210 / .2); }.button--secondary { color: #34445d; border-color: #d6e0ed; background: #fff; }.button--ghost { color: #47617e; background: transparent; }
|
||||
@media (max-width: 640px) { .wizard-page { padding: 24px 16px; }.stepper { grid-template-columns: 1fr; gap: 10px; }.stepper li:not(:last-child)::after { display: none; }.wizard-card { min-height: 300px; border-radius: 14px; }.wizard-actions { flex-wrap: wrap; }.wizard-actions__spacer { display: none; }.button--secondary:first-child { margin-right: auto; } }
|
||||
.wizard-actions { display: flex; align-items: center; gap: 10px; margin-top: 18px; }.wizard-actions__spacer { flex: 1; }
|
||||
@media (max-width: 640px) { .wizard-page { padding: 24px 16px; }.stepper { grid-template-columns: 1fr; gap: 10px; }.stepper li:not(:last-child)::after { display: none; }.wizard-card { min-height: 300px; border-radius: 14px; }.wizard-actions { flex-wrap: wrap; }.wizard-actions__spacer { display: none; }.btn-secondary:first-child { margin-right: auto; } }
|
||||
</style>
|
||||
+345
-464
File diff suppressed because it is too large.
Load diff
+76
-11
@@ -64,20 +64,85 @@ onMounted(loadFamilies);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="profile-library">
|
||||
<header class="profile-library__header">
|
||||
<div><h1>{{ t('admin.shippingOrderProfiles.library.title') }}</h1><p>{{ t('admin.shippingOrderProfiles.library.subtitle') }}</p></div>
|
||||
<button class="primary" type="button" @click="router.push({ name: 'AdminShippingOrderDocumentProfileCreate' })">{{ t('admin.shippingOrderProfiles.library.create') }}</button>
|
||||
<section class="mx-auto max-w-7xl space-y-6 p-6">
|
||||
<header class="page-header">
|
||||
<div>
|
||||
<h1 class="section-title">{{ t('admin.shippingOrderProfiles.library.title') }}</h1>
|
||||
<p class="section-desc mt-1">{{ t('admin.shippingOrderProfiles.library.subtitle') }}</p>
|
||||
</div>
|
||||
<button class="btn-primary" type="button" @click="router.push({ name: 'AdminShippingOrderDocumentProfileCreate' })">
|
||||
{{ t('admin.shippingOrderProfiles.library.create') }}
|
||||
</button>
|
||||
</header>
|
||||
<input v-model="query" class="profile-library__search" :placeholder="t('admin.shippingOrderProfiles.library.search')" type="search">
|
||||
<p v-if="loading">{{ t('admin.shippingOrderProfiles.library.loading') }}</p>
|
||||
<p v-else-if="!filteredFamilies.length">{{ t('admin.shippingOrderProfiles.library.empty') }}</p>
|
||||
<table v-else><thead><tr><th>{{ t('admin.shippingOrderProfiles.name') }}</th><th>{{ t('admin.shippingOrderProfiles.code') }}</th><th>{{ t('admin.shippingOrderProfiles.library.status') }}</th><th>{{ t('admin.shippingOrderProfiles.library.actions') }}</th></tr></thead>
|
||||
<tbody><tr v-for="item in filteredFamilies" :key="item.profile_code"><td>{{ item.display_name }}</td><td><code>{{ item.profile_code }}</code></td><td>{{ item.draft_profile_id ? t('admin.shippingOrderProfiles.library.draft') : item.published_profile_id ? t('admin.shippingOrderProfiles.library.published', { version: item.published_version }) : t('admin.shippingOrderProfiles.library.retired') }}</td><td class="profile-library__actions"><button v-if="item.draft_profile_id" type="button" @click="continueEditing(item)">{{ t('admin.shippingOrderProfiles.versionCenter.continueEditing') }}</button><button v-else-if="item.published_profile_id" type="button" @click="createNewVersion(item)">{{ t('admin.shippingOrderProfiles.newVersion') }}</button><button type="button" @click="viewVersion(item)">{{ t('admin.shippingOrderProfiles.versionCenter.viewVersion') }}</button></td></tr></tbody>
|
||||
</table>
|
||||
|
||||
<div class="toolbar">
|
||||
<input v-model="query" class="toolbar-input" :placeholder="t('admin.shippingOrderProfiles.library.search')" type="search">
|
||||
</div>
|
||||
|
||||
<section class="library-card" :aria-busy="loading">
|
||||
<p v-if="loading" class="library-state">{{ t('admin.shippingOrderProfiles.library.loading') }}</p>
|
||||
<p v-else-if="!filteredFamilies.length" class="library-state">{{ t('admin.shippingOrderProfiles.library.empty') }}</p>
|
||||
<div v-else class="table-scroll">
|
||||
<table class="profile-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ t('admin.shippingOrderProfiles.name') }}</th>
|
||||
<th>{{ t('admin.shippingOrderProfiles.code') }}</th>
|
||||
<th>{{ t('admin.shippingOrderProfiles.library.status') }}</th>
|
||||
<th class="actions-heading">{{ t('admin.shippingOrderProfiles.library.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="item in filteredFamilies" :key="item.profile_code">
|
||||
<td class="profile-name">{{ item.display_name }}</td>
|
||||
<td><code>{{ item.profile_code }}</code></td>
|
||||
<td>
|
||||
<span class="status-badge" :class="{ draft: item.draft_profile_id, published: !item.draft_profile_id && item.published_profile_id }">
|
||||
{{ item.draft_profile_id ? t('admin.shippingOrderProfiles.library.draft') : item.published_profile_id ? t('admin.shippingOrderProfiles.library.published', { version: item.published_version }) : t('admin.shippingOrderProfiles.library.retired') }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="profile-library__actions">
|
||||
<button v-if="item.draft_profile_id" class="btn-ghost btn-sm" type="button" @click="continueEditing(item)">{{ t('admin.shippingOrderProfiles.versionCenter.continueEditing') }}</button>
|
||||
<button v-else-if="item.published_profile_id" class="btn-secondary btn-sm" type="button" @click="createNewVersion(item)">{{ t('admin.shippingOrderProfiles.newVersion') }}</button>
|
||||
<button class="btn-ghost btn-sm" type="button" @click="viewVersion(item)">{{ t('admin.shippingOrderProfiles.versionCenter.viewVersion') }}</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.profile-library { display:grid; gap:1rem; padding:1.5rem; } .profile-library__header { display:flex; justify-content:space-between; gap:1rem; align-items:start; } h1,p { margin:0; } p { color:#64748b; margin-top:.35rem; } .primary { background:#2563eb; color:#fff; border:0; border-radius:.45rem; padding:.6rem .9rem; } .profile-library__search { max-width:28rem; padding:.6rem; border:1px solid #cbd5e1; border-radius:.4rem; } table { border-collapse:collapse; width:100%; background:#fff; } th,td { padding:.75rem; border-bottom:1px solid #e2e8f0; text-align:left; } .profile-library__actions { display:flex; gap:.5rem; flex-wrap:wrap; } button { cursor:pointer; } @media (max-width:700px) { .profile-library__header { flex-direction:column; } table { font-size:.8rem; } }
|
||||
.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
|
||||
.page-header h1 { margin: 0; }
|
||||
.page-header p { margin: 0; }
|
||||
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
|
||||
.toolbar-input {
|
||||
min-width: 220px; flex: 1 1 220px; border: 1px solid #d9e2ec; border-radius: 6px; background: #fff;
|
||||
padding: 7px 9px; color: #334155; font: inherit; font-size: 12px; outline: none;
|
||||
}
|
||||
.toolbar-input:focus { border-color: #38bdf8; box-shadow: 0 0 0 2px rgb(56 189 248 / 12%); }
|
||||
.library-card { overflow: hidden; border: 1px solid #dfe7ef; border-radius: 10px; background: #fff; box-shadow: 0 1px 2px rgb(15 23 42 / 3%); }
|
||||
.library-state { margin: 0; padding: 48px 24px; color: #94a3b8; font-size: 13px; text-align: center; }
|
||||
.table-scroll { overflow-x: auto; }
|
||||
.profile-table { width: 100%; min-width: 720px; border-collapse: collapse; color: #475569; font-size: 13px; }
|
||||
.profile-table th { background: #f8fafc; color: #64748b; font-size: 12px; font-weight: 600; }
|
||||
.profile-table th, .profile-table td { padding: 13px 16px; border-bottom: 1px solid #e5ebf1; text-align: left; vertical-align: middle; }
|
||||
.profile-table tbody tr:last-child td { border-bottom: 0; }
|
||||
.profile-table tbody tr:hover { background: #fbfdff; }
|
||||
.profile-name { color: #334155; font-weight: 600; }
|
||||
.profile-table code { color: #64748b; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; white-space: nowrap; }
|
||||
.status-badge { display: inline-flex; border: 1px solid #cbd5e1; border-radius: 999px; background: #f8fafc; padding: 3px 8px; color: #64748b; font-size: 11px; font-weight: 600; white-space: nowrap; }
|
||||
.status-badge.draft { border-color: #bae6fd; background: #f0f9ff; color: #0369a1; }
|
||||
.status-badge.published { border-color: #bbf7d0; background: #f0fdf4; color: #15803d; }
|
||||
.actions-heading { min-width: 190px; }
|
||||
.profile-library__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.page-header { flex-direction: column; }
|
||||
.btn-primary { width: 100%; }
|
||||
.toolbar-input { min-width: 0; }
|
||||
}
|
||||
</style>
|
||||
+37
-21
@@ -1,39 +1,55 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfilePublishCheckPage.vue
|
||||
用途:生成、审阅和消费订单模板的不可变发布检查报告。
|
||||
用途:以当前已验证草稿生成可读的发布检查,并在门禁通过后发布模板。
|
||||
依赖:发布检查 API、验证运行 API、Vue Router 和统一消息提示。
|
||||
逻辑:用户选择当前通过验证运行生成报告;阻断项不可确认,警告逐项确认后才可原子发布。
|
||||
逻辑:自动选择当前样本试读的通过运行;阻断项不可绕过,语义差异必须逐项确认。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
acquireOrderDocumentProfileEditLease, confirmOrderProfilePublishCheck, createOrderProfilePublishCheck,
|
||||
listOrderProfileValidationRuns,
|
||||
} from '@/features/admin/api/shipping-order-document-profile.api';
|
||||
import { acquireOrderDocumentProfileEditLease, confirmOrderProfilePublishCheck, createOrderProfilePublishCheck, listOrderProfileValidationRuns } from '@/features/admin/api/shipping-order-document-profile.api';
|
||||
import type { OrderProfilePublishCheckReport, OrderProfileValidationRun } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
|
||||
const route = useRoute(); const router = useRouter(); const message = useMessage();
|
||||
const { t } = useI18n();
|
||||
const profileId = Number(route.params.profileId);
|
||||
const runs = ref<OrderProfileValidationRun[]>([]); const report = ref<OrderProfilePublishCheckReport | null>(null);
|
||||
const selectedRunId = ref<number | null>(null); const confirmed = ref<string[]>([]); const busy = ref(false);
|
||||
const route = useRoute(); const router = useRouter(); const message = useMessage(); const { t } = useI18n();
|
||||
const profileId = Number(route.params.profileId); const runs = ref<OrderProfileValidationRun[]>([]); const report = ref<OrderProfilePublishCheckReport | null>(null); const confirmed = ref<string[]>([]); const busy = ref(false);
|
||||
const sessionId = String(route.query.editorSessionId || '').trim() || crypto.randomUUID(); const leaseToken = ref('');
|
||||
const validationRun = computed(() => runs.value.find((item) => item.run_type === 'current_sample' && item.status === 'passed') || null);
|
||||
const publishable = computed(() => report.value?.status === 'valid' && !report.value.blocking_items.length && confirmed.value.length === report.value.warning_items.length);
|
||||
|
||||
/** 显示统一业务错误,避免发布页暴露服务端实现细节。 */
|
||||
function fail(error: unknown): void { message.error(error instanceof BusinessError ? error.code : t('admin.orderProfilePublishCheck.failed')); }
|
||||
function fail(error: unknown): void { message.error(error instanceof BusinessError ? error.message : t('admin.orderProfilePublishCheck.failed')); }
|
||||
/** 获取租约后才允许创建或消费报告,避免发布页绕过草稿写保护。 */
|
||||
async function ensureLease(): Promise<boolean> { if (leaseToken.value) return true; try { leaseToken.value = (await acquireOrderDocumentProfileEditLease(profileId, { browser_session_id: sessionId, operation_id: crypto.randomUUID() })).lease_token; return true; } catch (error) { fail(error); return false; } }
|
||||
/** 加载仅当前草稿仍有效的通过验证运行,历史 stale 运行不可用于发布。 */
|
||||
async function loadRuns(): Promise<void> { try { runs.value = await listOrderProfileValidationRuns(profileId); selectedRunId.value = runs.value.find(item => item.status === 'passed')?.id || null; } catch (error) { fail(error); } }
|
||||
/** 创建并冻结新报告;一次 operation 重试会在服务端返回同一报告。 */
|
||||
async function createReport(): Promise<void> { if (!selectedRunId.value || !(await ensureLease())) return; busy.value = true; try { report.value = await createOrderProfilePublishCheck(profileId, { validation_run_id: selectedRunId.value, browser_session_id: sessionId, lease_token: leaseToken.value, operation_id: crypto.randomUUID() }); confirmed.value = []; } catch (error) { fail(error); } finally { busy.value = false; } }
|
||||
/** 逐项确认所有警告并消费报告,成功后跳转既有只读版本详情页。 */
|
||||
async function publish(): Promise<void> { if (!report.value || !(await ensureLease())) return; busy.value = true; try { const published = await confirmOrderProfilePublishCheck(profileId, report.value.report_no || '', { confirmed_warning_keys: confirmed.value, browser_session_id: sessionId, lease_token: leaseToken.value, operation_id: crypto.randomUUID() }); await router.replace({ name: 'AdminShippingOrderDocumentProfileVersionDetail', params: { profileCode: published.profile_code, version: String(published.version) } }); } catch (error) { fail(error); } finally { busy.value = false; } }
|
||||
/** 读取当前草稿仍有效的样本试读;历史 stale 运行不可用于发布。 */
|
||||
async function loadRuns(): Promise<void> { try { runs.value = await listOrderProfileValidationRuns(profileId); } catch (error) { fail(error); } }
|
||||
/** 创建发布检查报告;后端继续复核当前验证、盲测与 Profile 发布前置条件。 */
|
||||
async function createReport(): Promise<void> { if (!validationRun.value || !(await ensureLease())) return; busy.value = true; try { report.value = await createOrderProfilePublishCheck(profileId, { validation_run_id: validationRun.value.id, browser_session_id: sessionId, lease_token: leaseToken.value, operation_id: crypto.randomUUID() }); confirmed.value = []; } catch (error) { fail(error); } finally { busy.value = false; } }
|
||||
/** 逐项确认警告后消费报告并发布;发布成功后进入只读版本详情。 */
|
||||
async function publish(): Promise<void> { if (!report.value || !publishable.value || !(await ensureLease())) return; busy.value = true; try { const published = await confirmOrderProfilePublishCheck(profileId, report.value.report_no, { confirmed_warning_keys: confirmed.value, browser_session_id: sessionId, lease_token: leaseToken.value, operation_id: crypto.randomUUID() }); await router.replace({ name: 'AdminShippingOrderDocumentProfileVersionDetail', params: { profileCode: published.profile_code, version: String(published.version) } }); } catch (error) { fail(error); } finally { busy.value = false; } }
|
||||
/** 归一化有限的已知门禁码;未知内容仍保留后端安全摘要。 */
|
||||
function itemMessage(item: Record<string, unknown>): string { const key = String(item.key || ''); return key === 'current_validation_required' ? t('admin.orderProfilePublishCheck.currentValidationRequired') : key === 'semantic_diff_review' ? t('admin.orderProfilePublishCheck.semanticDiffReview') : String(item.message || t('admin.orderProfilePublishCheck.unknownIssue')); }
|
||||
function backToValidation(): void { router.push({ name: 'AdminShippingOrderDocumentProfileValidate', params: route.params, query: { editorSessionId: sessionId } }); }
|
||||
onMounted(loadRuns);
|
||||
</script>
|
||||
<template><section class="page"><header><div><p>{{ t('admin.orderProfilePublishCheck.eyebrow') }}</p><h1>{{ t('admin.orderProfilePublishCheck.title') }}</h1><small>{{ t('admin.orderProfilePublishCheck.description') }}</small></div><button type="button" @click="router.back()">{{ t('admin.orderProfilePublishCheck.back') }}</button></header><section v-if="!report" class="card"><h2>{{ t('admin.orderProfilePublishCheck.selectRun') }}</h2><label v-for="run in runs.filter(item => item.status === 'passed')" :key="run.id"><input v-model="selectedRunId" type="radio" :value="run.id">#{{ run.id }} · {{ run.run_type }} · {{ run.created_at }}</label><p v-if="!runs.some(item => item.status === 'passed')">{{ t('admin.orderProfilePublishCheck.noRun') }}</p><button :disabled="busy || !selectedRunId" type="button" @click="createReport">{{ t('admin.orderProfilePublishCheck.create') }}</button></section><section v-else class="card"><h2>{{ t('admin.orderProfilePublishCheck.report', { reportNo: report.report_no }) }}</h2><p>{{ t('admin.orderProfilePublishCheck.status', { status: report.status, revision: report.revision_no }) }}</p><h3>{{ t('admin.orderProfilePublishCheck.blocking') }}</h3><p v-if="!report.blocking_items.length">{{ t('admin.orderProfilePublishCheck.noBlocking') }}</p><ul><li v-for="item in report.blocking_items" :key="String(item.key)">{{ item.message }}</li></ul><h3>{{ t('admin.orderProfilePublishCheck.warnings') }}</h3><label v-for="item in report.warning_items" :key="String(item.key)"><input v-model="confirmed" type="checkbox" :value="String(item.key)">{{ item.message }}</label><button :disabled="busy || report.status !== 'valid' || report.blocking_items.length > 0 || confirmed.length !== report.warning_items.length" type="button" @click="publish">{{ t('admin.orderProfilePublishCheck.confirm') }}</button></section></section></template>
|
||||
<style scoped>.page{max-width:900px;margin:auto;padding:28px}.page header{display:flex;justify-content:space-between;gap:16px}.page header p{color:#2563eb;font-weight:700;margin:0}.page h1{margin:4px 0}.card{margin-top:24px;padding:20px;border:1px solid #cbd5e1;border-radius:8px}.card label{display:block;margin:10px 0}.card button,header button{margin-top:14px;padding:8px 13px;border:0;border-radius:5px;background:#2563eb;color:white}header button{background:#64748b}</style>
|
||||
<template>
|
||||
<section class="page">
|
||||
<header><div><h1 class="section-title">{{ t('admin.orderProfilePublishCheck.title') }}</h1><small class="section-desc mt-1">{{ t('admin.orderProfilePublishCheck.description') }}</small></div><button type="button" class="btn-secondary" @click="backToValidation">{{ t('admin.orderProfilePublishCheck.back') }}</button></header>
|
||||
<section v-if="!report" class="card"><h2>{{ t('admin.orderProfilePublishCheck.readyTitle') }}</h2><p>{{ validationRun ? t('admin.orderProfilePublishCheck.readyHint') : t('admin.orderProfilePublishCheck.noRun') }}</p><button class="btn-primary" :disabled="busy || !validationRun" type="button" @click="createReport">{{ t('admin.orderProfilePublishCheck.create') }}</button></section>
|
||||
<section v-else class="card"><h2>{{ t('admin.orderProfilePublishCheck.reportTitle') }}</h2><p>{{ report.blocking_items.length ? t('admin.orderProfilePublishCheck.blockedHint') : t('admin.orderProfilePublishCheck.reviewHint') }}</p><h3>{{ t('admin.orderProfilePublishCheck.blocking') }}</h3><p v-if="!report.blocking_items.length" class="good">{{ t('admin.orderProfilePublishCheck.noBlocking') }}</p><ul><li v-for="item in report.blocking_items" :key="String(item.key)">{{ itemMessage(item) }}</li></ul><h3>{{ t('admin.orderProfilePublishCheck.warnings') }}</h3><label v-for="item in report.warning_items" :key="String(item.key)"><input v-model="confirmed" type="checkbox" :value="String(item.key)"><span>{{ itemMessage(item) }}</span></label><p v-if="report.warning_items.length" class="hint">{{ t('admin.orderProfilePublishCheck.confirmHint') }}</p><button class="btn-primary" :disabled="busy || !publishable" type="button" @click="publish">{{ t('admin.orderProfilePublishCheck.confirm') }}</button></section>
|
||||
</section>
|
||||
</template>
|
||||
<style scoped>
|
||||
.page { width: 100%; margin: 0; padding: 24px; color: #334155; }
|
||||
.page header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
|
||||
.page h1 { margin: 0; }
|
||||
.page small:not(.section-desc), .card p { color: #64748b; font-size: 13px; line-height: 1.5; }
|
||||
.page small { display: block; margin-top: 5px; }
|
||||
.card { margin-top: 20px; border: 1px solid #dfe7ef; border-radius: 10px; background: #fff; padding: 16px; box-shadow: 0 1px 2px rgb(15 23 42 / 3%); }
|
||||
.card h2 { margin: 0; color: #1e293b; font-size: 15px; font-weight: 600; }.card h3 { margin: 20px 0 8px; color: #1e293b; font-size: 14px; }
|
||||
.card label { display: flex; gap: 8px; margin: 10px 0; color: #475569; font-size: 13px; }.card input { accent-color: #0ea5e9; }
|
||||
.card .btn-primary { margin-top: 14px; }.good { color: #15803d; font-size: 13px; }.hint { font-size: 13px; }ul { margin: 8px 0; padding-left: 20px; color: #b91c1c; font-size: 13px; }
|
||||
@media(max-width:767px) { .page { padding: 16px; }.page header { display: grid; }.page header button { width: 100%; } }
|
||||
</style>
|
||||
+175
-57
@@ -1,22 +1,35 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/OrderProfileValidationPage.vue
|
||||
用途:展示草稿不可变验证运行,并发起即时检查和当前样本试运行。
|
||||
依赖:Profile API、Vue Router、统一消息提示。
|
||||
逻辑:从稳定路由获取草稿身份;所有写操作透传编辑器会话租约,页面仅展示安全摘要与运行编号。
|
||||
用途:验证当前订单模板草稿,并按“基础验证、盲测、发布检查”顺序引导管理员。
|
||||
依赖:Profile 验证 API、编辑租约、Vue Router、统一消息提示。
|
||||
逻辑:一次动作依次执行结构检查和当前样本试读;盲测批准前不解锁发布检查入口。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { getShippingOrderSchemaVersion } from '@/features/admin/api/shipping-order-schema.api';
|
||||
import {
|
||||
acquireOrderDocumentProfileEditLease,
|
||||
getOrderDocumentProfileDetail,
|
||||
listOrderProfileBoundSamples,
|
||||
listOrderProfileValidationRuns,
|
||||
previewOrderProfileOrderFieldValues,
|
||||
previewOrderProfileRegion,
|
||||
runOrderProfileCurrentSample,
|
||||
runOrderProfileInstantCheck,
|
||||
createOrderProfileTestSuite,
|
||||
} from '@/features/admin/api/shipping-order-document-profile.api';
|
||||
import type { OrderProfileValidationRun } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
import type {
|
||||
CoordinateReconstructionPreview,
|
||||
OrderFieldValuePreview,
|
||||
OrderProfileBoundSample,
|
||||
OrderProfileValidationRun,
|
||||
OrderProfileTestSuite,
|
||||
ShippingOrderDocumentProfile,
|
||||
} from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
@@ -27,7 +40,28 @@ const runs = ref<OrderProfileValidationRun[]>([]);
|
||||
const loading = ref(false);
|
||||
const executing = ref(false);
|
||||
const leaseToken = ref('');
|
||||
const profile = ref<ShippingOrderDocumentProfile | null>(null);
|
||||
const sample = ref<OrderProfileBoundSample | null>(null);
|
||||
const headerValues = ref<OrderFieldValuePreview[]>([]);
|
||||
const linePreview = ref<CoordinateReconstructionPreview | null>(null);
|
||||
const resultLoading = ref(false);
|
||||
const resultFailed = ref(false);
|
||||
const fieldNames = ref(new Map<string, string>());
|
||||
const sessionId = String(route.query.editorSessionId || '').trim() || crypto.randomUUID();
|
||||
const blindTestSuite = ref<OrderProfileTestSuite | null>(null);
|
||||
|
||||
const latestRun = (runType: OrderProfileValidationRun['run_type']) =>
|
||||
runs.value.find((item) => item.run_type === runType) || null;
|
||||
const structureRun = computed(() => latestRun('instant_check'));
|
||||
const sampleRun = computed(() => latestRun('current_sample'));
|
||||
const canStartBlindTest = computed(() => structureRun.value?.status === 'passed' && sampleRun.value?.status === 'passed');
|
||||
const canPublish = computed(() => canStartBlindTest.value && blindTestSuite.value?.status === 'approved');
|
||||
const validationState = computed<'ready' | 'stale' | 'failed' | 'pending'>(() => {
|
||||
if (canStartBlindTest.value) return 'ready';
|
||||
if (runs.value.some((item) => item.status === 'stale')) return 'stale';
|
||||
if (runs.value.some((item) => item.status === 'failed')) return 'failed';
|
||||
return 'pending';
|
||||
});
|
||||
|
||||
/** 将后端业务错误转换为统一提示,避免验证页泄露服务端内部细节。 */
|
||||
function report(error: unknown): void {
|
||||
@@ -35,48 +69,96 @@ function report(error: unknown): void {
|
||||
message.error(code ? t(`errors.${code}`, code) : t('admin.orderProfileValidation.failed'));
|
||||
}
|
||||
|
||||
/** 读取运行历史;后端自行计算 stale,因此客户端不根据本地草稿猜测有效性。 */
|
||||
async function loadRuns(): Promise<void> {
|
||||
loading.value = true;
|
||||
/** 读取或建立当前草稿 checksum 的盲测集,使发布入口按已批准状态而非仅样本试读解锁。 */
|
||||
async function loadBlindTestSuite(): Promise<void> {
|
||||
if (!canStartBlindTest.value) {
|
||||
blindTestSuite.value = null;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
runs.value = await listOrderProfileValidationRuns(profileId);
|
||||
blindTestSuite.value = await createOrderProfileTestSuite(profileId);
|
||||
} catch (error) {
|
||||
report(error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 为本页获取单写者租约;冲突时明确提示并保留只读历史查询。 */
|
||||
/** 读取当前草稿对应的不可变验证运行;后端负责将旧 checksum 派生为 stale。 */
|
||||
async function loadRuns(): Promise<void> {
|
||||
loading.value = true;
|
||||
try { runs.value = await listOrderProfileValidationRuns(profileId); } catch (error) { report(error); } finally { loading.value = false; }
|
||||
}
|
||||
|
||||
/** 读取当前草稿和可试读样本;只选建模证据,绝不把盲测样本暴露到页面。 */
|
||||
async function loadContext(): Promise<void> {
|
||||
try {
|
||||
const [detail, samples] = await Promise.all([
|
||||
getOrderDocumentProfileDetail(profileId), listOrderProfileBoundSamples(profileId),
|
||||
]);
|
||||
profile.value = detail;
|
||||
sample.value = samples.find((item) => item.sample_role === 'annotation' || item.sample_role === 'training') || null;
|
||||
const schema = await getShippingOrderSchemaVersion(detail.schema_version_id);
|
||||
fieldNames.value = new Map((schema.definition?.fields || []).map((field) => [field.field_code || '', field.display_name]));
|
||||
} catch (error) { report(error); }
|
||||
}
|
||||
|
||||
/** Schema 显示名称服务于业务核对;稳定编码仅作为辅助追溯信息保留。 */
|
||||
function fieldName(fieldCode: string): string { return fieldNames.value.get(fieldCode) || fieldCode; }
|
||||
|
||||
/** 使用本次草稿定义重读表头和明细;结果只来自实时接口,不回退历史建议文本。 */
|
||||
async function loadReadResults(): Promise<void> {
|
||||
if (!profile.value || !sample.value?.table_id) return;
|
||||
resultLoading.value = true;
|
||||
resultFailed.value = false;
|
||||
try {
|
||||
const pageNo = sample.value.table_identity_snapshot?.page_no || 1;
|
||||
const [headers, lines] = await Promise.all([
|
||||
previewOrderProfileOrderFieldValues(sample.value.document_id, profile.value.schema_version_id, pageNo, profile.value.definition),
|
||||
previewOrderProfileRegion(profileId, sample.value.document_id, sample.value.table_id, profile.value.definition),
|
||||
]);
|
||||
headerValues.value = headers.fields;
|
||||
linePreview.value = lines;
|
||||
} catch {
|
||||
headerValues.value = [];
|
||||
linePreview.value = null;
|
||||
resultFailed.value = true;
|
||||
} finally { resultLoading.value = false; }
|
||||
}
|
||||
|
||||
/** 为本页获取单写者租约,避免验证或发布检查绕过草稿编辑保护。 */
|
||||
async function ensureLease(): Promise<boolean> {
|
||||
if (leaseToken.value) return true;
|
||||
try {
|
||||
const lease = await acquireOrderDocumentProfileEditLease(profileId, {
|
||||
leaseToken.value = (await acquireOrderDocumentProfileEditLease(profileId, {
|
||||
browser_session_id: sessionId, operation_id: crypto.randomUUID(),
|
||||
});
|
||||
leaseToken.value = lease.lease_token;
|
||||
})).lease_token;
|
||||
return true;
|
||||
} catch (error) {
|
||||
report(error);
|
||||
return false;
|
||||
}
|
||||
} catch (error) { report(error); return false; }
|
||||
}
|
||||
|
||||
/** 运行指定验证类型,完成后重新加载服务端冻结的运行摘要。 */
|
||||
async function execute(kind: 'instant' | 'sample'): Promise<void> {
|
||||
/** 依次执行配置结构和当前样本试读;任一步失败均不允许进入发布检查。 */
|
||||
async function validateCurrentDraft(): Promise<void> {
|
||||
if (!(await ensureLease())) return;
|
||||
executing.value = true;
|
||||
try {
|
||||
const payload = { browser_session_id: sessionId, lease_token: leaseToken.value, operation_id: crypto.randomUUID() };
|
||||
if (kind === 'instant') await runOrderProfileInstantCheck(profileId, payload);
|
||||
else await runOrderProfileCurrentSample(profileId, payload);
|
||||
const payload = () => ({ browser_session_id: sessionId, lease_token: leaseToken.value, operation_id: crypto.randomUUID() });
|
||||
await runOrderProfileInstantCheck(profileId, payload());
|
||||
await runOrderProfileCurrentSample(profileId, payload());
|
||||
await loadRuns();
|
||||
await loadBlindTestSuite();
|
||||
await loadReadResults();
|
||||
message.success(t('admin.orderProfileValidation.completed'));
|
||||
} catch (error) {
|
||||
report(error);
|
||||
} finally {
|
||||
executing.value = false;
|
||||
}
|
||||
} catch (error) { report(error); } finally { executing.value = false; }
|
||||
}
|
||||
|
||||
/** 在基本验证通过后进入独立盲测,避免把建模样本试读误当成发布质量凭证。 */
|
||||
function goToBlindTest(): void {
|
||||
if (!canStartBlindTest.value) return;
|
||||
router.push({ name: 'AdminShippingOrderDocumentProfileBlindTest', params: route.params, query: { editorSessionId: sessionId } });
|
||||
}
|
||||
/** 仅在当前草稿的盲测已批准时进入发布检查;后端仍会以 checksum 再次复核门禁。 */
|
||||
function goToPublishCheck(): void {
|
||||
if (!canPublish.value) return;
|
||||
router.push({ name: 'AdminShippingOrderDocumentProfilePublishCheck', params: route.params, query: { editorSessionId: sessionId } });
|
||||
}
|
||||
|
||||
/** 返回同一草稿的编辑路由,保留标签会话身份以复用仍有效的租约。 */
|
||||
@@ -84,44 +166,80 @@ function backToEditor(): void {
|
||||
router.push({ name: 'AdminShippingOrderDocumentProfileEdit', params: route.params, query: { editorSessionId: sessionId } });
|
||||
}
|
||||
|
||||
onMounted(loadRuns);
|
||||
onMounted(async () => {
|
||||
await Promise.all([loadRuns(), loadContext()]);
|
||||
if (canStartBlindTest.value) {
|
||||
await Promise.all([loadBlindTestSuite(), loadReadResults()]);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="validation-page">
|
||||
<header>
|
||||
<div>
|
||||
<p class="eyebrow">{{ t('admin.orderProfileValidation.eyebrow') }}</p>
|
||||
<h1>{{ t('admin.orderProfileValidation.title') }}</h1>
|
||||
<p>{{ t('admin.orderProfileValidation.description') }}</p>
|
||||
<h1 class="section-title">{{ t('admin.orderProfileValidation.title') }}</h1>
|
||||
<p class="section-desc mt-1">{{ t('admin.orderProfileValidation.description') }}</p>
|
||||
</div>
|
||||
<button class="secondary" type="button" @click="backToEditor">{{ t('admin.orderProfileValidation.backToEditor') }}</button>
|
||||
<button class="btn-secondary" type="button" @click="backToEditor">{{ t('admin.orderProfileValidation.backToEditor') }}</button>
|
||||
</header>
|
||||
<div class="actions">
|
||||
<button type="button" :disabled="executing" @click="execute('instant')">{{ t('admin.orderProfileValidation.instantCheck') }}</button>
|
||||
<button type="button" :disabled="executing" @click="execute('sample')">{{ t('admin.orderProfileValidation.currentSample') }}</button>
|
||||
</div>
|
||||
<p v-if="loading">{{ t('admin.orderProfileValidation.loading') }}</p>
|
||||
<table v-else>
|
||||
<thead><tr><th>{{ t('admin.orderProfileValidation.run') }}</th><th>{{ t('admin.orderProfileValidation.type') }}</th><th>{{ t('admin.orderProfileValidation.status') }}</th><th>{{ t('admin.orderProfileValidation.summary') }}</th><th>{{ t('admin.orderProfileValidation.time') }}</th></tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="run in runs" :key="run.id">
|
||||
<td>#{{ run.id }}</td><td>{{ run.run_type }}</td><td><span :class="`status ${run.status}`">{{ run.status }}</span></td>
|
||||
<td>{{ JSON.stringify((run as OrderProfileValidationRun & { summary?: Record<string, unknown> }).summary || {}) }}</td><td>{{ run.created_at }}</td>
|
||||
</tr>
|
||||
<tr v-if="!runs.length"><td colspan="5">{{ t('admin.orderProfileValidation.empty') }}</td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<section class="validation-state" :class="`state-${validationState}`">
|
||||
<div><b>{{ t(`admin.orderProfileValidation.state.${validationState}`) }}</b><p>{{ t(`admin.orderProfileValidation.stateHint.${validationState}`) }}</p></div>
|
||||
<button v-if="canStartBlindTest" type="button" class="btn-primary" :disabled="!canPublish" @click="goToPublishCheck">{{ t('admin.orderProfileValidation.goPublishCheck') }}</button>
|
||||
</section>
|
||||
|
||||
<section class="validation-card current-draft-validation">
|
||||
<header>
|
||||
<div><h2>{{ t('admin.orderProfileValidation.currentDraft') }}</h2><p>{{ t('admin.orderProfileValidation.currentDraftHint') }}</p></div>
|
||||
<button type="button" class="btn-primary" :disabled="executing" @click="validateCurrentDraft">{{ executing ? t('admin.orderProfileValidation.validating') : t('admin.orderProfileValidation.validateCurrent') }}</button>
|
||||
</header>
|
||||
<p v-if="loading">{{ t('admin.orderProfileValidation.loading') }}</p>
|
||||
<div v-else class="checks" :aria-label="t('admin.orderProfileValidation.currentDraft')">
|
||||
<article>
|
||||
<div><h3>{{ t('admin.orderProfileValidation.structureCheck') }}</h3><p>{{ t('admin.orderProfileValidation.structureCheckHint') }}</p></div>
|
||||
<strong :class="`status ${structureRun?.status || 'pending'}`">{{ t(`admin.orderProfileValidation.runStatus.${structureRun?.status || 'pending'}`) }}</strong>
|
||||
</article>
|
||||
<article>
|
||||
<div><h3>{{ t('admin.orderProfileValidation.sampleCheck') }}</h3><p>{{ t('admin.orderProfileValidation.sampleCheckHint') }}</p></div>
|
||||
<strong :class="`status ${sampleRun?.status || 'pending'}`">{{ t(`admin.orderProfileValidation.runStatus.${sampleRun?.status || 'pending'}`) }}</strong>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="canStartBlindTest" class="blind-test-gate">
|
||||
<div><h2>{{ t('admin.shippingOrderProfiles.blindTest.gateTitle') }}</h2><p>{{ blindTestSuite?.status === 'approved' ? t('admin.shippingOrderProfiles.blindTest.gateApprovedHint') : t('admin.shippingOrderProfiles.blindTest.gateRequiredHint') }}</p></div>
|
||||
<div class="gate-actions"><strong :class="`status ${blindTestSuite?.status || 'pending'}`">{{ t(`admin.shippingOrderProfiles.blindTest.status.${blindTestSuite?.status || 'missing'}`) }}</strong><button type="button" class="btn-secondary" @click="goToBlindTest">{{ t('admin.shippingOrderProfiles.blindTest.title') }}</button></div>
|
||||
</section>
|
||||
|
||||
<section v-if="canStartBlindTest" class="results" :aria-label="t('admin.orderProfileValidation.resultsTitle')">
|
||||
<div class="results-heading"><div><h2>{{ t('admin.orderProfileValidation.resultsTitle') }}</h2><p>{{ t('admin.orderProfileValidation.resultsHint') }}</p></div><button type="button" class="btn-secondary btn-sm" :disabled="resultLoading" @click="loadReadResults">{{ t('admin.orderProfileValidation.refreshResults') }}</button></div>
|
||||
<p v-if="resultLoading">{{ t('admin.orderProfileValidation.resultsLoading') }}</p>
|
||||
<p v-else-if="resultFailed" class="result-error">{{ t('admin.orderProfileValidation.resultsFailed') }}</p>
|
||||
<template v-else>
|
||||
<h3>{{ t('admin.orderProfileValidation.headerResults') }}</h3>
|
||||
<dl v-if="headerValues.length" class="header-results"><div v-for="field in headerValues" :key="field.field_id"><dt>{{ fieldName(field.field_code) }}</dt><dd class="field-code">{{ field.field_code }}</dd><dd>{{ field.value || t('admin.orderProfileValidation.noValue') }}</dd></div></dl>
|
||||
<p v-else>{{ t('admin.orderProfileValidation.noHeaderResults') }}</p>
|
||||
<h3>{{ t('admin.orderProfileValidation.lineResults') }}</h3>
|
||||
<div v-if="linePreview?.rows?.length" class="line-results"><table><thead><tr><th v-for="field in linePreview.rows[0]" :key="field"><span>{{ fieldName(field) }}</span><small>{{ field }}</small></th><th>{{ t('admin.orderProfileValidation.rowStatus') }}</th></tr></thead><tbody><tr v-for="(row, index) in linePreview.rows.slice(1)" :key="index" :class="linePreview.row_roles[index + 1] === 'deleted' ? 'deleted-row' : ''"><td v-for="(value, cellIndex) in row" :key="cellIndex">{{ value || t('admin.orderProfileValidation.noValue') }}</td><td>{{ linePreview.row_roles[index + 1] === 'deleted' ? t('admin.orderProfileValidation.deleted') : t('admin.orderProfileValidation.read') }}</td></tr></tbody></table></div>
|
||||
<p v-else>{{ t('admin.orderProfileValidation.noLineResults') }}</p>
|
||||
</template>
|
||||
</section>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.validation-page { max-width: 1180px; margin: 0 auto; padding: 28px; color: #1e293b; }
|
||||
header { display: flex; justify-content: space-between; gap: 24px; align-items: start; }
|
||||
h1 { margin: 4px 0; font-size: 24px; } .eyebrow { margin: 0; color: #2563eb; font-size: 12px; font-weight: 700; }
|
||||
header p:not(.eyebrow) { color: #64748b; margin: 0; }.actions { display: flex; gap: 12px; margin: 24px 0; }
|
||||
button { border: 0; border-radius: 6px; background: #2563eb; color: #fff; padding: 9px 14px; cursor: pointer; } button.secondary { background: #e2e8f0; color: #334155; } button:disabled { opacity: .6; cursor: wait; }
|
||||
table { width: 100%; border-collapse: collapse; background: #fff; } th, td { padding: 12px; border-bottom: 1px solid #e2e8f0; text-align: left; vertical-align: top; } td:nth-child(4) { max-width: 420px; overflow-wrap: anywhere; color: #475569; }
|
||||
.status { text-transform: uppercase; font-size: 12px; font-weight: 700; }.passed { color: #15803d; }.failed, .stale { color: #b91c1c; }
|
||||
@media (max-width: 767px) { .validation-page { padding: 16px; } header { display: block; } header button { margin-top: 16px; } table { font-size: 12px; } }
|
||||
.validation-page { width: 100%; margin: 0; padding: 24px; color: #334155; }
|
||||
header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 16px; }
|
||||
h1 { margin: 0; }
|
||||
header p:not(.section-desc), .validation-card p, .checks p, .validation-state p, .blind-test-gate p { margin: 5px 0 0; color: #64748b; font-size: 13px; line-height: 1.5; }
|
||||
button:disabled { cursor: not-allowed; opacity: .55; }
|
||||
.validation-state, .validation-card, .checks article, .blind-test-gate, .results { border: 1px solid #dfe7ef; border-radius: 10px; background: #fff; box-shadow: 0 1px 2px rgb(15 23 42 / 3%); }
|
||||
.validation-state { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 20px; padding: 16px; }
|
||||
.validation-state { border-color: #bae6fd; background: #f0f9ff; }.validation-state b { color: #0369a1; font-size: 14px; }.state-ready { border-color: #bbf7d0; background: #f0fdf4; }.state-ready b { color: #15803d; }.state-stale, .state-failed { border-color: #fecaca; background: #fef2f2; }.state-stale b, .state-failed b { color: #b91c1c; }
|
||||
.validation-card h2, .checks h3 { margin: 0; color: #1e293b; font-size: 15px; font-weight: 600; }
|
||||
.current-draft-validation { display: grid; gap: 16px; margin-top: 20px; padding: 16px; }.current-draft-validation > header { align-items: center; }.current-draft-validation > header > div { min-width: 0; }.current-draft-validation > header button { flex: 0 0 auto; }.checks { display: grid; gap: 10px; }.checks article { display: flex; align-items: center; justify-content: space-between; gap: 20px; border-radius: 8px; padding: 15px 16px; }.status { min-width: 72px; text-align: right; font-size: 13px; font-weight: 600; }.passed { color: #15803d; }.failed, .stale { color: #b91c1c; }.pending, .running { color: #64748b; }
|
||||
.blind-test-gate { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 20px; padding: 16px; }.blind-test-gate h2 { margin: 0; color: #1e293b; font-size: 15px; font-weight: 600; }.gate-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }.gate-actions .approved { color: #15803d; }.gate-actions .draft, .gate-actions .missing { color: #b45309; }
|
||||
.results { margin-top: 20px; padding: 16px; }.results-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }.results h2, .results h3 { margin: 0; color: #1e293b; }.results h2 { font-size: 15px; }.results h3 { margin-top: 20px; font-size: 14px; }.results-heading p { margin: 5px 0 0; color: #64748b; font-size: 13px; line-height: 1.5; }.header-results { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 12px 0 0; }.header-results div { border: 1px solid #e5ebf1; border-radius: 6px; background: #fbfdff; padding: 10px; }.header-results dt { color: #475569; font-size: 13px; font-weight: 600; }.header-results dd { margin: 4px 0 0; overflow-wrap: anywhere; }.header-results .field-code, .line-results th small { color: #94a3b8; font-size: 11px; font-weight: 400; }.line-results { margin-top: 12px; overflow-x: auto; border: 1px solid #e5ebf1; border-radius: 6px; }.line-results table { width: 100%; min-width: 560px; border-collapse: collapse; }.line-results th, .line-results td { padding: 10px 12px; border-bottom: 1px solid #e5ebf1; text-align: left; vertical-align: top; overflow-wrap: anywhere; }.line-results tbody tr:last-child td { border-bottom: 0; }.line-results th { background: #f8fafc; color: #64748b; font-size: 12px; font-weight: 600; }.line-results th span, .line-results th small { display: block; }.deleted-row { color: #94a3b8; text-decoration: line-through; }.result-error { color: #b91c1c; }
|
||||
@media (max-width: 767px) { .validation-page { padding: 16px; } header, .validation-state, .current-draft-validation > header, .checks article, .blind-test-gate, .results-heading { display: grid; }.validation-state button, .current-draft-validation > header button, .blind-test-gate button, .results-heading button { width: 100%; } }
|
||||
</style>
|
||||
+105
-82
@@ -51,6 +51,9 @@ const pageTitle = computed(() => {
|
||||
)}`;
|
||||
});
|
||||
|
||||
const statusKey = (status: "draft" | "published" | "retired") =>
|
||||
status === "draft" ? "currentDraft" : status === "published" ? "currentPublished" : "retired";
|
||||
|
||||
const openTab = (tab: OrderProfileVersionDetailTab) => {
|
||||
void router.replace({
|
||||
query: {
|
||||
@@ -119,19 +122,20 @@ const createNewVersion = async () => {
|
||||
<template>
|
||||
<section class="version-detail-page">
|
||||
<header class="page-header">
|
||||
<button type="button" class="ghost-button" @click="goBackToWorkbench">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.backToWorkbench") }}
|
||||
</button>
|
||||
<div class="header-main">
|
||||
<div>
|
||||
<p class="eyebrow">{{ t("admin.shippingOrderProfiles.versionCenter.eyebrow") }}</p>
|
||||
<h1>{{ pageTitle }}</h1>
|
||||
<div class="header-copy">
|
||||
<p class="header-kicker">{{ t("admin.shippingOrderProfiles.title") }}</p>
|
||||
<h1 class="section-title">{{ detail?.display_name || profileCode }}</h1>
|
||||
<p class="header-meta">{{ pageTitle }}</p>
|
||||
</div>
|
||||
<div class="header-actions" v-if="detail">
|
||||
<button type="button" class="btn-secondary" @click="goBackToWorkbench">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.backToWorkbench") }}
|
||||
</button>
|
||||
<button
|
||||
v-if="detail.status === 'draft'"
|
||||
type="button"
|
||||
class="primary-button"
|
||||
class="btn-primary"
|
||||
@click="continueEditing"
|
||||
>
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.continueEditing") }}
|
||||
@@ -139,7 +143,7 @@ const createNewVersion = async () => {
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="primary-button"
|
||||
class="btn-primary"
|
||||
:disabled="cloning"
|
||||
@click="createNewVersion"
|
||||
>
|
||||
@@ -174,12 +178,12 @@ const createNewVersion = async () => {
|
||||
</button>
|
||||
</nav>
|
||||
|
||||
<div class="content-layout">
|
||||
<aside class="version-rail">
|
||||
<header>
|
||||
<h2>{{ t("admin.shippingOrderProfiles.versionCenter.familyVersions") }}</h2>
|
||||
<p>{{ detail.profile_code }}</p>
|
||||
</header>
|
||||
<section class="version-switcher" :aria-label="t('admin.shippingOrderProfiles.versionCenter.familyVersions')">
|
||||
<div class="version-switcher__label">
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.familyVersions") }}</span>
|
||||
<small>{{ detail.profile_code }}</small>
|
||||
</div>
|
||||
<div class="version-switcher__list">
|
||||
<button
|
||||
v-for="item in versions"
|
||||
:key="item.id"
|
||||
@@ -189,20 +193,20 @@ const createNewVersion = async () => {
|
||||
@click="openVersion(item.profile_code, item.version)"
|
||||
>
|
||||
<strong>v{{ item.version }}</strong>
|
||||
<span>{{ t(`admin.shippingOrderProfiles.versionCenter.status.${item.status === 'draft' ? 'currentDraft' : item.status === 'published' ? 'currentPublished' : 'retired'}`) }}</span>
|
||||
<span>{{ t(`admin.shippingOrderProfiles.versionCenter.status.${statusKey(item.status)}`) }}</span>
|
||||
</button>
|
||||
</aside>
|
||||
|
||||
<div class="detail-panel">
|
||||
<OrderProfileVersionOverview v-if="activeTab === 'overview'" :detail="detail" />
|
||||
<OrderProfileReadOnlyCanvas v-else-if="activeTab === 'canvas'" :detail="detail" />
|
||||
<OrderProfileVersionDiff v-else-if="activeTab === 'diff'" :detail="detail" :versions="versions" />
|
||||
<OrderProfileAuditTimeline v-else-if="activeTab === 'audit'" :detail="detail" />
|
||||
<OrderProfileUsageTable v-else-if="activeTab === 'usage'" :detail="detail" />
|
||||
<section v-else class="state-card">
|
||||
{{ t("admin.shippingOrderProfiles.loadFailed") }}
|
||||
</section>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="detail-panel">
|
||||
<OrderProfileVersionOverview v-if="activeTab === 'overview'" :detail="detail" />
|
||||
<OrderProfileReadOnlyCanvas v-else-if="activeTab === 'canvas'" :detail="detail" />
|
||||
<OrderProfileVersionDiff v-else-if="activeTab === 'diff'" :detail="detail" :versions="versions" />
|
||||
<OrderProfileAuditTimeline v-else-if="activeTab === 'audit'" :detail="detail" />
|
||||
<OrderProfileUsageTable v-else-if="activeTab === 'usage'" :detail="detail" />
|
||||
<section v-else class="state-card">
|
||||
{{ t("admin.shippingOrderProfiles.loadFailed") }}
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
@@ -211,22 +215,20 @@ const createNewVersion = async () => {
|
||||
<style scoped>
|
||||
.version-detail-page {
|
||||
display: grid;
|
||||
gap: 1rem;
|
||||
gap: 1.25rem;
|
||||
}
|
||||
|
||||
.page-header,
|
||||
.state-card,
|
||||
.version-rail,
|
||||
.version-switcher,
|
||||
.detail-panel {
|
||||
border: 1px solid #e2e8f0;
|
||||
border: 1px solid var(--border-default);
|
||||
border-radius: 1rem;
|
||||
background: #fff;
|
||||
padding: 1rem;
|
||||
background: var(--bg-surface);
|
||||
}
|
||||
|
||||
.page-header {
|
||||
display: grid;
|
||||
gap: 0.9rem;
|
||||
padding: 1.25rem 1.5rem;
|
||||
}
|
||||
|
||||
.header-main {
|
||||
@@ -236,46 +238,41 @@ const createNewVersion = async () => {
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.eyebrow {
|
||||
margin: 0 0 0.35rem;
|
||||
color: #64748b;
|
||||
font-size: 0.75rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
.header-copy {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.page-header h1,
|
||||
.version-rail h2 {
|
||||
.page-header h1 {
|
||||
margin: 0;
|
||||
color: #0f172a;
|
||||
}
|
||||
|
||||
.ghost-button,
|
||||
.primary-button,
|
||||
.header-kicker,
|
||||
.header-meta {
|
||||
margin: 0;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.8125rem;
|
||||
}
|
||||
|
||||
.header-kicker { margin-bottom: 0.25rem; }
|
||||
.header-meta { margin-top: 0.35rem; overflow-wrap: anywhere; }
|
||||
|
||||
.header-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; }
|
||||
|
||||
.tab-button,
|
||||
.version-item {
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 0.7rem;
|
||||
background: #fff;
|
||||
border: 1px solid var(--border-default);
|
||||
border-radius: 0.75rem;
|
||||
background: var(--bg-surface);
|
||||
color: var(--text-secondary);
|
||||
cursor: pointer;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.ghost-button,
|
||||
.primary-button {
|
||||
padding: 0.5rem 0.85rem;
|
||||
}
|
||||
|
||||
.primary-button {
|
||||
background: #0f172a;
|
||||
border-color: #0f172a;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tab-nav {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.6rem;
|
||||
gap: 0.35rem;
|
||||
overflow-x: auto;
|
||||
padding-bottom: 0.15rem;
|
||||
}
|
||||
|
||||
.tab-button {
|
||||
@@ -286,53 +283,79 @@ const createNewVersion = async () => {
|
||||
}
|
||||
|
||||
.tab-button.active {
|
||||
border-color: #2563eb;
|
||||
background: #eff6ff;
|
||||
color: #1d4ed8;
|
||||
border-color: #0ea5e9;
|
||||
background: var(--status-info-bg);
|
||||
color: var(--status-info-fg);
|
||||
}
|
||||
|
||||
.content-layout {
|
||||
display: grid;
|
||||
.version-switcher {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
grid-template-columns: minmax(180px, 220px) minmax(0, 1fr);
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.version-rail {
|
||||
.version-switcher__label {
|
||||
display: grid;
|
||||
align-content: start;
|
||||
gap: 0.75rem;
|
||||
flex: 0 0 auto;
|
||||
gap: 0.1rem;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.version-rail header p {
|
||||
margin: 0.35rem 0 0;
|
||||
color: #64748b;
|
||||
.version-switcher__label small {
|
||||
max-width: 15rem;
|
||||
overflow: hidden;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
font-weight: 400;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.version-switcher__list {
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
gap: 0.5rem;
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.version-item {
|
||||
display: grid;
|
||||
gap: 0.2rem;
|
||||
justify-items: start;
|
||||
padding: 0.75rem;
|
||||
display: inline-flex;
|
||||
flex: 0 0 auto;
|
||||
align-items: baseline;
|
||||
gap: 0.35rem;
|
||||
padding: 0.55rem 0.7rem;
|
||||
}
|
||||
|
||||
.version-item.active {
|
||||
border-color: #2563eb;
|
||||
background: #eff6ff;
|
||||
border-color: #0ea5e9;
|
||||
background: var(--status-info-bg);
|
||||
color: var(--status-info-fg);
|
||||
}
|
||||
|
||||
.version-item span {
|
||||
color: #64748b;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.version-item.active span { color: inherit; }
|
||||
|
||||
.detail-panel { padding: 1.25rem; }
|
||||
|
||||
.error-card {
|
||||
color: #b91c1c;
|
||||
padding: 1rem;
|
||||
color: var(--status-error-fg);
|
||||
}
|
||||
|
||||
@media (max-width: 960px) {
|
||||
.header-main,
|
||||
.content-layout {
|
||||
grid-template-columns: 1fr;
|
||||
.version-switcher {
|
||||
align-items: flex-start;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.header-actions { justify-content: flex-start; }
|
||||
}
|
||||
</style>
|
||||
+33
-34
@@ -42,6 +42,15 @@ const formatJson = (value: unknown) => {
|
||||
const hasPrevious = computed(() => cursorStack.value.length > 0);
|
||||
const hasNext = computed(() => Boolean(page.value?.page.has_more && page.value?.page.next_before_id));
|
||||
|
||||
const loadErrorMessage = (error: unknown) => {
|
||||
if (error instanceof BusinessError && [502, 503, 504].includes(error.status || 0)) {
|
||||
return t("admin.shippingOrderProfiles.versionCenter.serviceUnavailable");
|
||||
}
|
||||
return error instanceof BusinessError
|
||||
? error.message
|
||||
: t("admin.shippingOrderProfiles.versionCenter.audit.loadFailed");
|
||||
};
|
||||
|
||||
const load = async () => {
|
||||
loading.value = true;
|
||||
errorMessage.value = "";
|
||||
@@ -57,9 +66,7 @@ const load = async () => {
|
||||
});
|
||||
} catch (error) {
|
||||
page.value = null;
|
||||
errorMessage.value = error instanceof BusinessError
|
||||
? error.message
|
||||
: t("admin.shippingOrderProfiles.versionCenter.audit.loadFailed");
|
||||
errorMessage.value = loadErrorMessage(error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -112,10 +119,10 @@ watch(
|
||||
<p>{{ t("admin.shippingOrderProfiles.versionCenter.audit.subtitle") }}</p>
|
||||
</div>
|
||||
<div class="toolbar-actions">
|
||||
<button type="button" class="ghost-button" :disabled="loading" @click="resetFilters">
|
||||
<button type="button" class="btn-ghost btn-sm" :disabled="loading" @click="resetFilters">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.audit.reset") }}
|
||||
</button>
|
||||
<button type="button" class="primary-button" :disabled="loading" @click="applyFilters">
|
||||
<button type="button" class="btn-primary btn-sm" :disabled="loading" @click="applyFilters">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.audit.apply") }}
|
||||
</button>
|
||||
</div>
|
||||
@@ -124,23 +131,23 @@ watch(
|
||||
<div class="filters">
|
||||
<label>
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.eventType") }}</span>
|
||||
<input v-model="filters.eventType" type="text" />
|
||||
<input v-model="filters.eventType" class="input-field" type="text" />
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.actor") }}</span>
|
||||
<input v-model="filters.actor" type="text" />
|
||||
<input v-model="filters.actor" class="input-field" type="text" />
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.requestId") }}</span>
|
||||
<input v-model="filters.requestIdFilter" type="text" />
|
||||
<input v-model="filters.requestIdFilter" class="input-field" type="text" />
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.createdFrom") }}</span>
|
||||
<input v-model="filters.createdFrom" type="date" />
|
||||
<input v-model="filters.createdFrom" class="input-field" type="date" />
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.audit.createdTo") }}</span>
|
||||
<input v-model="filters.createdTo" type="date" />
|
||||
<input v-model="filters.createdTo" class="input-field" type="date" />
|
||||
</label>
|
||||
</div>
|
||||
|
||||
@@ -148,7 +155,10 @@ watch(
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.audit.loading") }}
|
||||
</div>
|
||||
<div v-else-if="errorMessage" class="state-card error-card">
|
||||
{{ errorMessage }}
|
||||
<p>{{ errorMessage }}</p>
|
||||
<button type="button" class="btn-secondary btn-sm" @click="load">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.retry") }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-else-if="!page?.items.length" class="state-card">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.audit.empty") }}
|
||||
@@ -174,10 +184,10 @@ watch(
|
||||
</div>
|
||||
|
||||
<div class="pager">
|
||||
<button type="button" class="ghost-button" :disabled="loading || !hasPrevious" @click="loadPrevious">
|
||||
<button type="button" class="btn-ghost btn-sm" :disabled="loading || !hasPrevious" @click="loadPrevious">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.audit.previous") }}
|
||||
</button>
|
||||
<button type="button" class="ghost-button" :disabled="loading || !hasNext" @click="loadNext">
|
||||
<button type="button" class="btn-ghost btn-sm" :disabled="loading || !hasNext" @click="loadNext">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.audit.next") }}
|
||||
</button>
|
||||
</div>
|
||||
@@ -190,9 +200,9 @@ watch(
|
||||
.filters,
|
||||
.timeline-item,
|
||||
.state-card {
|
||||
border: 1px solid #e2e8f0;
|
||||
border: 1px solid var(--border-default);
|
||||
border-radius: 1rem;
|
||||
background: #fff;
|
||||
background: var(--bg-surface);
|
||||
}
|
||||
|
||||
.timeline-panel {
|
||||
@@ -217,13 +227,13 @@ watch(
|
||||
.toolbar h3,
|
||||
.timeline-item h4 {
|
||||
margin: 0;
|
||||
color: #0f172a;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.toolbar p,
|
||||
.timeline-type {
|
||||
margin: 0.25rem 0 0;
|
||||
color: #64748b;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
@@ -242,26 +252,15 @@ watch(
|
||||
.filters label {
|
||||
display: grid;
|
||||
gap: 0.3rem;
|
||||
color: #475569;
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.filters input,
|
||||
.ghost-button,
|
||||
.primary-button {
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 0.75rem;
|
||||
background: #fff;
|
||||
.filters .input-field {
|
||||
padding: 0.5rem 0.75rem;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.primary-button {
|
||||
background: #0f172a;
|
||||
border-color: #0f172a;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.timeline-list {
|
||||
display: grid;
|
||||
gap: 0.8rem;
|
||||
@@ -278,16 +277,16 @@ watch(
|
||||
display: grid;
|
||||
justify-items: end;
|
||||
gap: 0.25rem;
|
||||
color: #64748b;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.timeline-item pre {
|
||||
margin: 0.85rem 0 0;
|
||||
border-radius: 0.75rem;
|
||||
background: #0f172a;
|
||||
background: var(--bg-surface-strong);
|
||||
padding: 0.8rem;
|
||||
color: #e2e8f0;
|
||||
color: var(--text-primary);
|
||||
font-size: 0.72rem;
|
||||
line-height: 1.45;
|
||||
overflow: auto;
|
||||
@@ -295,7 +294,7 @@ watch(
|
||||
}
|
||||
|
||||
.error-card {
|
||||
color: #b91c1c;
|
||||
color: var(--status-error-fg);
|
||||
}
|
||||
|
||||
@media (max-width: 1100px) {
|
||||
|
||||
+30
-4
@@ -30,6 +30,9 @@ const props = defineProps<{
|
||||
pageCount: number;
|
||||
saveDisabled?: boolean;
|
||||
saving?: boolean;
|
||||
pendingSuggestionCount?: number;
|
||||
orderFieldValues?: Record<string, string | null>;
|
||||
orderFieldValueState?: 'idle' | 'loading' | 'ready' | 'failed';
|
||||
}>();
|
||||
const { t } = useI18n();
|
||||
const readonlyMode = computed(() => props.mode === 'readonly');
|
||||
@@ -47,6 +50,8 @@ const emit = defineEmits<{
|
||||
delete: [];
|
||||
save: [];
|
||||
page: [pageNo: number];
|
||||
acceptSuggestion: [];
|
||||
rejectSuggestion: [];
|
||||
}>();
|
||||
|
||||
const imageUrl = ref('');
|
||||
@@ -167,6 +172,18 @@ const endCreation = () => {
|
||||
};
|
||||
|
||||
const selected = computed(() => new Set([props.selectedRegionId]));
|
||||
/** 订单字段标签只使用父级本次坐标读取结果,模板定义仍只保存字段与坐标。 */
|
||||
const displayRegionLabel = (region: OrderProfileCanvasRegion): string => {
|
||||
if (region.kind !== 'order_field') return region.label;
|
||||
const state = props.orderFieldValueState || 'idle';
|
||||
const value = region.fieldCode ? props.orderFieldValues?.[region.fieldCode] : null;
|
||||
const suffix = state === 'loading'
|
||||
? t('admin.shippingOrderProfiles.workbench.orderFieldValueReading')
|
||||
: state === 'failed'
|
||||
? t('admin.shippingOrderProfiles.workbench.orderFieldValueFailed')
|
||||
: value || t('admin.shippingOrderProfiles.workbench.sampleValueUnavailable');
|
||||
return `${region.label} · ${suffix}`;
|
||||
};
|
||||
/** 以固定步进调整页面倍率;区域采用相对坐标,缩放后仍与图像精确对齐。 */
|
||||
const adjustZoom = (delta: number) => { zoom.value = Math.max(.5, Math.min(4, Math.round((zoom.value + delta) * 100) / 100)); };
|
||||
/** 恢复适合工作台宽度的默认倍率,便于快速定位整页。 */
|
||||
@@ -196,13 +213,19 @@ onBeforeUnmount(() => { endMove(); endPan(); endCreation(); URL.revokeObjectURL(
|
||||
<button type="button" :disabled="duplicateDisabled" :title="t('admin.shippingOrderProfiles.workbench.duplicateRegionShortcut')" @click="emit('duplicate')"><Copy /></button>
|
||||
<button type="button" class="delete-action" :disabled="deleteDisabled" :title="t('admin.shippingOrderProfiles.workbench.deleteRegionShortcut')" @click="emit('delete')"><Trash2 /></button>
|
||||
<span class="toolbar-divider" aria-hidden="true" />
|
||||
<button type="button" class="save-action" :disabled="saveDisabled || saving" :title="t('admin.save')" @click="emit('save')"><Save /><span>{{ saving ? t('admin.shippingOrderProfiles.saving') : t('admin.save') }}</span></button>
|
||||
<button type="button" class="save-action" :disabled="saveDisabled || saving" :title="t('admin.save')" @click="emit('save')"><Save /><span>{{ saving ? t('admin.shippingOrderProfiles.saving') : t('admin.save') }}</span></button>
|
||||
<template v-if="pendingSuggestionCount">
|
||||
<span class="toolbar-divider" aria-hidden="true" />
|
||||
<span class="suggestion-count">{{ pendingSuggestionCount }}</span>
|
||||
<button type="button" class="suggestion-action" @click="emit('acceptSuggestion')">{{ t('admin.shippingOrderProfiles.workbench.acceptSuggestion') }}</button>
|
||||
<button type="button" class="suggestion-action suggestion-action--reject" @click="emit('rejectSuggestion')">{{ t('admin.shippingOrderProfiles.workbench.rejectSuggestion') }}</button>
|
||||
</template>
|
||||
</template>
|
||||
<span v-else class="readonly-badge">{{ t('admin.shippingOrderProfiles.versionCenter.readonlyCanvasBadge') }}</span>
|
||||
</div>
|
||||
<div class="page-control">
|
||||
<button type="button" :disabled="pageNo <= 1" :title="t('admin.shippingOrderExtractionRuns.previous')" @click="emit('page', pageNo - 1)"><ArrowLeft /></button>
|
||||
<label><input v-model.number="pageInput" type="number" min="1" :max="pageCount" :aria-label="t('admin.shippingOrderProfiles.workbench.pageNavigation')" @change="goToPage" @keydown.enter.prevent="goToPage" /><span>/ {{ pageCount }}</span></label>
|
||||
<label><input v-model.number="pageInput" class="input-field" type="number" min="1" :max="pageCount" :aria-label="t('admin.shippingOrderProfiles.workbench.pageNavigation')" @change="goToPage" @keydown.enter.prevent="goToPage" /><span>/ {{ pageCount }}</span></label>
|
||||
<button type="button" :disabled="pageNo >= pageCount" :title="t('admin.shippingOrderExtractionRuns.next')" @click="emit('page', pageNo + 1)"><ArrowRight /></button>
|
||||
</div>
|
||||
<div class="zoom-control">
|
||||
@@ -243,7 +266,7 @@ onBeforeUnmount(() => { endMove(); endPan(); endCreation(); URL.revokeObjectURL(
|
||||
@keydown.enter="emit('select', region.id)"
|
||||
@keydown.space.prevent="emit('select', region.id)"
|
||||
>
|
||||
<span class="region-label" @pointerdown.stop="beginDrag($event, region, 'move')">{{ region.label }}</span>
|
||||
<span class="region-label" :title="displayRegionLabel(region)" @pointerdown.stop="beginDrag($event, region, 'move')">{{ displayRegionLabel(region) }}</span>
|
||||
<template v-if="region.kind === 'line' && !readonlyMode">
|
||||
<span v-for="edge in ['n', 'e', 's', 'w']" :key="edge" class="line-hit-edge" :class="`line-hit-${edge}`" @pointerdown.stop="beginDrag($event, region, 'move')" />
|
||||
</template>
|
||||
@@ -263,6 +286,9 @@ onBeforeUnmount(() => { endMove(); endPan(); endCreation(); URL.revokeObjectURL(
|
||||
.canvas-toolbar button { display: inline-flex; min-width: 2rem; height: 2rem; align-items: center; justify-content: center; gap: .35rem; border: 1px solid #475569; border-radius: .35rem; background: #1e293b; padding: .3rem .5rem; color: #e2e8f0; font-size: .72rem; }
|
||||
.canvas-toolbar button:hover { border-color: #60a5fa; background: #26364f; }
|
||||
.canvas-toolbar button:disabled { cursor: not-allowed; opacity: .4; }
|
||||
.suggestion-count { display: inline-grid; min-width: 1.25rem; height: 1.25rem; place-items: center; border-radius: 999px; background: #f59e0b; color: #172033; font-size: .68rem; font-weight: 800; }
|
||||
.canvas-toolbar .suggestion-action { border-color: #22c55e; background: #15803d; }
|
||||
.canvas-toolbar .suggestion-action--reject { border-color: #64748b; background: transparent; }
|
||||
.canvas-toolbar svg, .annotation-tools svg { width: .95rem; height: .95rem; }
|
||||
.toolbar-actions { justify-self: start; }
|
||||
.toolbar-divider { width: 1px; height: 1.25rem; margin: 0 .15rem; background: #475569; }
|
||||
@@ -272,7 +298,7 @@ onBeforeUnmount(() => { endMove(); endPan(); endCreation(); URL.revokeObjectURL(
|
||||
.readonly-badge { display: inline-flex; align-items: center; min-height: 2rem; border: 1px solid #475569; border-radius: .35rem; background: #0f172a; padding: 0 .65rem; color: #cbd5e1; }
|
||||
.page-control { justify-self: center; }
|
||||
.page-control label { display: flex; height: 2rem; align-items: center; gap: .3rem; border: 1px solid #475569; border-radius: .35rem; background: #0f172a; padding: 0 .45rem; color: #94a3b8; }
|
||||
.page-control input { width: 3rem; border: 0; background: transparent; color: #f8fafc; font: 700 .76rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; outline: 0; }
|
||||
.page-control .input-field { width: 3rem; border: 0; background: transparent; color: #f8fafc; font: 700 .76rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-align: right; outline: 0; }
|
||||
.zoom-control { justify-self: end; }
|
||||
.canvas-toolbar output { min-width: 3.4rem; color: #f8fafc; text-align: center; }
|
||||
.zoom-control .fit-action { padding-inline: .65rem; }
|
||||
|
||||
+4
-4
@@ -9,7 +9,7 @@ import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingOrderSchemaVersion } from '@/features/admin/types/shipping-order-schema.types';
|
||||
type Identity = { displayName: string; schemaId: number };
|
||||
const props = defineProps<{ modelValue: Identity; schemas: ShippingOrderSchemaVersion[] }>();
|
||||
const props = defineProps<{ modelValue: Identity; schemas: ShippingOrderSchemaVersion[]; schemasResolved: boolean }>();
|
||||
const emit = defineEmits<{ 'update:modelValue': [value: Identity] }>();
|
||||
const { t } = useI18n();
|
||||
const publishedSchemas = computed(() => props.schemas.filter((item) => item.status === 'published'));
|
||||
@@ -19,12 +19,12 @@ function update(key: keyof Identity, value: string | number): void { emit('updat
|
||||
|
||||
<template>
|
||||
<div class="identity-step">
|
||||
<label class="field"><span>{{ t('admin.shippingOrderProfiles.name') }}<b>*</b></span><input :value="modelValue.displayName" :placeholder="t('admin.shippingOrderProfiles.wizard.namePlaceholder')" @input="update('displayName', ($event.target as HTMLInputElement).value)" /></label>
|
||||
<label class="field"><span>{{ t('admin.shippingOrderProfiles.name') }}<b>*</b></span><input class="input-field" :value="modelValue.displayName" :placeholder="t('admin.shippingOrderProfiles.wizard.namePlaceholder')" @input="update('displayName', ($event.target as HTMLInputElement).value)" /></label>
|
||||
<div class="system-code"><strong>{{ t('admin.shippingOrderProfiles.code') }}</strong><span>{{ t('admin.shippingOrderProfiles.wizard.systemCodeHint') }}</span></div>
|
||||
<label class="field"><span>{{ t('admin.shippingOrderProfiles.schema') }}<b>*</b></span><select :value="modelValue.schemaId" @change="update('schemaId', Number(($event.target as HTMLSelectElement).value))"><option :value="0">{{ t('admin.shippingOrderProfiles.wizard.selectSchema') }}</option><option v-for="schema in publishedSchemas" :key="schema.id" :value="schema.id">v{{ schema.version }}</option></select><small v-if="!publishedSchemas.length" class="field-warning">{{ t('admin.shippingOrderProfiles.wizard.schemaRequired') }}</small></label>
|
||||
<label class="field"><span>{{ t('admin.shippingOrderProfiles.schema') }}<b>*</b></span><select class="select-field" :value="modelValue.schemaId" @change="update('schemaId', Number(($event.target as HTMLSelectElement).value))"><option :value="0">{{ t('admin.shippingOrderProfiles.wizard.selectSchema') }}</option><option v-for="schema in publishedSchemas" :key="schema.id" :value="schema.id">v{{ schema.version }}</option></select><small v-if="schemasResolved && !publishedSchemas.length" class="field-warning">{{ t('admin.shippingOrderProfiles.wizard.schemaRequired') }}</small></label>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.identity-step { display: grid; gap: 22px; max-width: 560px; }.field { display: grid; gap: 8px; color: #263650; font-weight: 700; }.field > span { display: flex; gap: 4px; }.field b { color: #d14343; }.field input,.field select { width: 100%; min-height: 44px; box-sizing: border-box; border: 1px solid #ccd8e6; border-radius: 9px; padding: 0 12px; color: #172033; background: #fff; font: inherit; outline: none; transition: border-color .15s ease, box-shadow .15s ease; }.field input:focus,.field select:focus { border-color: #1677d2; box-shadow: 0 0 0 3px rgb(22 119 210 / .13); }.field small { color: #71829a; font-size: .8rem; font-weight: 500; }.system-code { display: grid; gap: 4px; padding: 13px 14px; border: 1px solid #dbe7f5; border-radius: 9px; color: #52657d; background: #f7fbff; font-size: .86rem; }.system-code strong { color: #263650; }.field-warning { color: #b45309 !important; }
|
||||
.identity-step { display: grid; gap: 22px; max-width: 560px; }.field { display: grid; gap: 8px; color: var(--text-secondary); font-weight: 700; }.field > span { display: flex; gap: 4px; }.field b { color: var(--status-error-fg); }.field .input-field,.field .select-field { min-height: 44px; box-sizing: border-box; font: inherit; }.field small { color: var(--text-muted); font-size: .8rem; font-weight: 500; }.system-code { display: grid; gap: 4px; padding: 13px 14px; border: 1px solid var(--border-default); border-radius: 9px; color: var(--text-secondary); background: var(--bg-surface-soft); font-size: .86rem; }.system-code strong { color: var(--text-primary); }.field-warning { color: var(--status-warning-fg) !important; }
|
||||
</style>
|
||||
+2
-2
@@ -10,5 +10,5 @@ const props = defineProps<{ tables: Array<{ table_id: string; page_no: number; r
|
||||
const emit = defineEmits<{ 'update:modelValue': [value: string] }>();
|
||||
const { t } = useI18n();
|
||||
</script>
|
||||
<template><div class="wizard-step"><div><label>{{ t('admin.shippingOrderProfiles.wizard.orderLineTable') }}<select :value="modelValue" @change="emit('update:modelValue', ($event.target as HTMLSelectElement).value)"><option value="">{{ t('admin.shippingOrderProfiles.selectTable') }}</option><option v-for="table in tables" :key="table.table_id" :value="table.table_id">{{ t('admin.shippingOrderProfiles.wizard.tableOption', { page: table.page_no, rows: table.row_count, columns: table.column_count }) }}</option></select></label><p class="field-hint">{{ t('admin.shippingOrderProfiles.wizard.orderLineTableHint') }}</p></div><p v-if="!tables.length" class="warning">{{ t('admin.shippingOrderProfiles.wizard.noTable') }}</p><div v-else-if="modelValue" class="table-preview"><table><tbody><tr v-for="row in tables.find((item) => item.table_id === modelValue)?.rows.slice(0, 4) || []" :key="row.join('|')"><td v-for="cell in row" :key="cell">{{ cell }}</td></tr></tbody></table></div></div></template>
|
||||
<style scoped>.wizard-step{display:grid;min-width:0;gap:1rem}.wizard-step label{display:grid;gap:.35rem;font-weight:600}.wizard-step select{min-width:0;padding:.6rem;border:1px solid #cbd5e1;border-radius:.4rem}.field-hint{margin:.45rem 0 0;color:#64748b;font-size:.875rem}.warning{color:#b45309}.table-preview{max-width:100%;overflow-x:auto;border:1px solid #e2e8f0;border-radius:.5rem}.table-preview table{width:max-content;min-width:100%;border-collapse:collapse}.table-preview td{max-width:16rem;padding:.55rem;border:1px solid #e2e8f0;overflow-wrap:anywhere;vertical-align:top}</style>
|
||||
<template><div class="wizard-step"><div><label>{{ t('admin.shippingOrderProfiles.wizard.orderLineTable') }}<select class="select-field" :value="modelValue" @change="emit('update:modelValue', ($event.target as HTMLSelectElement).value)"><option value="">{{ t('admin.shippingOrderProfiles.selectTable') }}</option><option v-for="table in tables" :key="table.table_id" :value="table.table_id">{{ t('admin.shippingOrderProfiles.wizard.tableOption', { page: table.page_no, rows: table.row_count, columns: table.column_count }) }}</option></select></label><p class="field-hint">{{ t('admin.shippingOrderProfiles.wizard.orderLineTableHint') }}</p></div><p v-if="!tables.length" class="warning">{{ t('admin.shippingOrderProfiles.wizard.noTable') }}</p><div v-else-if="modelValue" class="table-preview"><table><tbody><tr v-for="row in tables.find((item) => item.table_id === modelValue)?.rows.slice(0, 4) || []" :key="row.join('|')"><td v-for="cell in row" :key="cell">{{ cell }}</td></tr></tbody></table></div></div></template>
|
||||
<style scoped>.wizard-step{display:grid;min-width:0;gap:1rem}.wizard-step label{display:grid;gap:.35rem;font-weight:600}.wizard-step .select-field{min-width:0}.field-hint{margin:.45rem 0 0;color:var(--text-muted);font-size:.875rem}.warning{color:var(--status-warning-fg)}.table-preview{max-width:100%;overflow-x:auto;border:1px solid var(--border-default);border-radius:.5rem}.table-preview table{width:max-content;min-width:100%;border-collapse:collapse}.table-preview td{max-width:16rem;padding:.55rem;border:1px solid var(--border-default);overflow-wrap:anywhere;vertical-align:top}</style>
|
||||
+2
-4
@@ -104,7 +104,7 @@ watch(selectedSampleId, (value) => {
|
||||
<div class="toolbar">
|
||||
<label class="field">
|
||||
<span>{{ t('admin.shippingOrderProfiles.versionCenter.readonlySample') }}</span>
|
||||
<select v-model.number="selectedSampleId">
|
||||
<select v-model.number="selectedSampleId" class="select-field">
|
||||
<option v-for="sample in readonlySamples" :key="sample.id" :value="sample.id">
|
||||
{{ sampleLabel(sample) }}
|
||||
</option>
|
||||
@@ -190,9 +190,7 @@ watch(selectedSampleId, (value) => {
|
||||
font-size: 0.8rem;
|
||||
}
|
||||
|
||||
.field select {
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 0.7rem;
|
||||
.field .select-field {
|
||||
min-height: 2.5rem;
|
||||
padding: 0 0.75rem;
|
||||
}
|
||||
|
||||
+2
-2
@@ -92,11 +92,11 @@ onBeforeUnmount(stopPolling);
|
||||
|
||||
<section class="reuse-panel">
|
||||
<div class="reuse-panel__heading"><h3>{{ t('admin.shippingOrderProfiles.wizard.reuseSample') }}</h3><p>{{ t('admin.shippingOrderProfiles.wizard.reuseSampleHint') }}</p></div>
|
||||
<label class="field"><span>{{ t('admin.shippingOrderProfiles.selectSample') }}</span><select :value="modelValue" @change="emit('update:modelValue', Number(($event.target as HTMLSelectElement).value))"><option :value="0">{{ t('admin.shippingOrderProfiles.selectSample') }}</option><option v-for="sample in samples" :key="sample.document_id" :value="sample.document_id">{{ sample.filename || sample.intake_no }} · {{ sample.table_count }} {{ t('admin.shippingOrderProfiles.tablesUnit') }}</option></select></label>
|
||||
<label class="field"><span>{{ t('admin.shippingOrderProfiles.selectSample') }}</span><select class="select-field" :value="modelValue" @change="emit('update:modelValue', Number(($event.target as HTMLSelectElement).value))"><option :value="0">{{ t('admin.shippingOrderProfiles.selectSample') }}</option><option v-for="sample in samples" :key="sample.document_id" :value="sample.document_id">{{ sample.filename || sample.intake_no }} · {{ sample.table_count }} {{ t('admin.shippingOrderProfiles.tablesUnit') }}</option></select></label>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.sample-step { display: grid; gap: 18px; max-width: 640px; }.upload-panel,.reuse-panel,.parse-status,.selected-sample { border: 1px solid #dce6f2; border-radius: 12px; background: #fff; }.upload-panel { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 18px; background: linear-gradient(110deg, #f6fbff, #fff); }.upload-panel__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 10px; color: #1677d2; background: #e6f4ff; }.upload-panel h3,.reuse-panel h3,.parse-status p,.selected-sample span { margin: 0; }.upload-panel h3,.reuse-panel h3 { color: #263650; font-size: 1rem; }.upload-panel p,.reuse-panel p { margin: 5px 0 0; color: #71829a; font-size: .84rem; }.upload-action { display: inline-flex; min-height: 38px; align-items: center; border-radius: 8px; padding: 0 13px; color: #fff; background: #1677d2; font-weight: 700; cursor: pointer; }.upload-action input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }.parse-status,.selected-sample { display: flex; gap: 10px; align-items: center; padding: 13px 15px; color: #1677d2; background: #f7fbff; }.parse-status strong,.selected-sample strong { display: block; color: #263650; }.parse-status p,.selected-sample span { display: block; margin-top: 3px; color: #64748b; font-size: .83rem; }.parse-status.failed { color: #cf4b4b; border-color: #f0caca; background: #fff8f8; }.parse-status.failed > span { display: grid; width: 19px; height: 19px; place-items: center; border-radius: 50%; color: #fff; background: #cf4b4b; font-weight: 800; }.selected-sample { color: #0f8a65; border-color: #c6eadc; background: #f3fcf8; }.reuse-panel { padding: 18px; }.reuse-panel__heading { margin-bottom: 14px; }.field { display: grid; gap: 7px; color: #475c78; font-size: .88rem; font-weight: 700; }.field select { min-height: 44px; border: 1px solid #ccd8e6; border-radius: 9px; padding: 0 12px; color: #263650; background: #fff; font: inherit; }.field select:focus { outline: 3px solid rgb(22 119 210 / .13); border-color: #1677d2; } @media (max-width: 640px) { .upload-panel { grid-template-columns: auto 1fr; }.upload-action { grid-column: 1 / -1; justify-content: center; } }
|
||||
.sample-step { display: grid; gap: 18px; max-width: 640px; }.upload-panel,.reuse-panel,.parse-status,.selected-sample { border: 1px solid var(--border-default); border-radius: 12px; background: var(--bg-surface); }.upload-panel { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; padding: 18px; background: var(--bg-surface-soft); }.upload-panel__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 10px; color: var(--status-info-fg); background: var(--status-info-bg); }.upload-panel h3,.reuse-panel h3,.parse-status p,.selected-sample span { margin: 0; }.upload-panel h3,.reuse-panel h3 { color: var(--text-primary); font-size: 1rem; }.upload-panel p,.reuse-panel p { margin: 5px 0 0; color: var(--text-muted); font-size: .84rem; }.upload-action { display: inline-flex; min-height: 38px; align-items: center; border-radius: 8px; padding: 0 13px; color: #fff; background: #1677d2; font-weight: 700; cursor: pointer; }.upload-action input { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }.parse-status,.selected-sample { display: flex; gap: 10px; align-items: center; padding: 13px 15px; color: var(--status-info-fg); background: var(--status-info-bg); }.parse-status strong,.selected-sample strong { display: block; color: var(--text-primary); }.parse-status p,.selected-sample span { display: block; margin-top: 3px; color: var(--text-muted); font-size: .83rem; }.parse-status.failed { color: var(--status-error-fg); border-color: var(--status-error-border); background: var(--status-error-bg); }.parse-status.failed > span { display: grid; width: 19px; height: 19px; place-items: center; border-radius: 50%; color: #fff; background: var(--status-error-fg); font-weight: 800; }.selected-sample { color: var(--status-success-fg); border-color: var(--status-success-border); background: var(--status-success-bg); }.reuse-panel { padding: 18px; }.reuse-panel__heading { margin-bottom: 14px; }.field { display: grid; gap: 7px; color: var(--text-secondary); font-size: .88rem; font-weight: 700; }.field .select-field { min-height: 44px; font: inherit; } @media (max-width: 640px) { .upload-panel { grid-template-columns: auto 1fr; }.upload-action { grid-column: 1 / -1; justify-content: center; } }
|
||||
</style>
|
||||
+14
-4
@@ -34,6 +34,15 @@ const formatTime = (value?: string | null) => value ? new Date(value).toLocaleSt
|
||||
const translateUsageValue = (scope: "runStatuses" | "matchStatuses" | "executionStatuses" | "identityModes", value: string) =>
|
||||
t(`admin.shippingOrderProfiles.versionCenter.usage.${scope}.${value}`, value);
|
||||
|
||||
const loadErrorMessage = (error: unknown) => {
|
||||
if (error instanceof BusinessError && [502, 503, 504].includes(error.status || 0)) {
|
||||
return t("admin.shippingOrderProfiles.versionCenter.serviceUnavailable");
|
||||
}
|
||||
return error instanceof BusinessError
|
||||
? error.message
|
||||
: t("admin.shippingOrderProfiles.versionCenter.usage.loadFailed");
|
||||
};
|
||||
|
||||
const load = async () => {
|
||||
loading.value = true;
|
||||
errorMessage.value = "";
|
||||
@@ -44,9 +53,7 @@ const load = async () => {
|
||||
});
|
||||
} catch (error) {
|
||||
page.value = null;
|
||||
errorMessage.value = error instanceof BusinessError
|
||||
? error.message
|
||||
: t("admin.shippingOrderProfiles.versionCenter.usage.loadFailed");
|
||||
errorMessage.value = loadErrorMessage(error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -101,7 +108,10 @@ watch(
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.usage.loading") }}
|
||||
</div>
|
||||
<div v-else-if="errorMessage" class="state-card error-card">
|
||||
{{ errorMessage }}
|
||||
<p>{{ errorMessage }}</p>
|
||||
<button type="button" class="btn-secondary btn-sm" @click="load">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.retry") }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-else-if="!page?.items.length" class="state-card">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.usage.empty") }}
|
||||
|
||||
+17
-11
@@ -65,6 +65,15 @@ const changeTypeLabel = (value: OrderProfileVersionDiffItem["change_type"]) =>
|
||||
|
||||
const changeLabel = (change: OrderProfileVersionDiffChange) => change.key;
|
||||
|
||||
const loadErrorMessage = (error: unknown) => {
|
||||
if (error instanceof BusinessError && [502, 503, 504].includes(error.status || 0)) {
|
||||
return t("admin.shippingOrderProfiles.versionCenter.serviceUnavailable");
|
||||
}
|
||||
return error instanceof BusinessError
|
||||
? error.message
|
||||
: t("admin.shippingOrderProfiles.versionCenter.diff.loadFailed");
|
||||
};
|
||||
|
||||
const valueText = (value: unknown) => {
|
||||
if (value === null || value === undefined || value === "") {
|
||||
return t("admin.shippingOrderProfiles.versionCenter.diff.empty");
|
||||
@@ -101,10 +110,7 @@ const load = async () => {
|
||||
diff.value = await getOrderDocumentProfileDiff(props.detail.id, explicitAgainstProfileId.value);
|
||||
} catch (error) {
|
||||
diff.value = null;
|
||||
errorMessage.value =
|
||||
error instanceof BusinessError
|
||||
? error.message
|
||||
: t("admin.shippingOrderProfiles.versionCenter.diff.loadFailed");
|
||||
errorMessage.value = loadErrorMessage(error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
@@ -129,6 +135,7 @@ watch(
|
||||
<label class="compare-select">
|
||||
<span>{{ t("admin.shippingOrderProfiles.versionCenter.diff.compareTarget") }}</span>
|
||||
<select
|
||||
class="select-field"
|
||||
:value="explicitAgainstProfileId || ''"
|
||||
@change="handleAgainstChange"
|
||||
>
|
||||
@@ -148,7 +155,10 @@ watch(
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.diff.loading") }}
|
||||
</div>
|
||||
<div v-else-if="errorMessage" class="state-card error-card">
|
||||
{{ errorMessage }}
|
||||
<p>{{ errorMessage }}</p>
|
||||
<button type="button" class="btn-secondary btn-sm" @click="load">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.retry") }}
|
||||
</button>
|
||||
</div>
|
||||
<template v-else-if="diff">
|
||||
<div class="summary-bar">
|
||||
@@ -266,13 +276,9 @@ watch(
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.compare-select select {
|
||||
.compare-select .select-field {
|
||||
min-width: 220px;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 0.75rem;
|
||||
background: #fff;
|
||||
padding: 0.5rem 0.75rem;
|
||||
color: #0f172a;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
@@ -429,7 +435,7 @@ ins {
|
||||
display: grid;
|
||||
}
|
||||
|
||||
.compare-select select {
|
||||
.compare-select .select-field {
|
||||
min-width: 0;
|
||||
}
|
||||
}
|
||||
|
||||
+96
-38
@@ -15,6 +15,9 @@ const props = defineProps<{
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const formatDateTime = (value?: string | null) =>
|
||||
value ? new Date(value).toLocaleString() : "-";
|
||||
|
||||
const statusLabel = computed(() => {
|
||||
if (props.detail.status === "draft") {
|
||||
return t("admin.shippingOrderProfiles.versionCenter.status.currentDraft");
|
||||
@@ -25,6 +28,8 @@ const statusLabel = computed(() => {
|
||||
return t("admin.shippingOrderProfiles.versionCenter.status.retired");
|
||||
});
|
||||
|
||||
const statusClass = computed(() => `meta-chip--${props.detail.status}`);
|
||||
|
||||
const frozenEvidenceLabel = computed(() => {
|
||||
const status = props.detail.frozen_evidence?.status || "pending";
|
||||
return t(`admin.shippingOrderProfiles.versionCenter.frozenEvidence.${status}`);
|
||||
@@ -41,10 +46,12 @@ const testStatusLabel = computed(() => {
|
||||
<div class="hero-card">
|
||||
<div class="hero-row">
|
||||
<div>
|
||||
<p class="eyebrow">{{ detail.profile_code }}</p>
|
||||
<p class="eyebrow">{{ t("admin.shippingOrderProfiles.versionCenter.eyebrow") }}</p>
|
||||
<h2>v{{ detail.version }} · {{ statusLabel }}</h2>
|
||||
<p class="profile-identity">{{ detail.profile_code }}</p>
|
||||
</div>
|
||||
<div class="hero-meta">
|
||||
<span class="meta-chip meta-chip--status" :class="statusClass">{{ statusLabel }}</span>
|
||||
<span class="meta-chip">
|
||||
{{ t("admin.shippingOrderProfiles.versionCenter.schemaVersion") }}
|
||||
{{ detail.schema_summary?.version ?? "-" }}
|
||||
@@ -54,26 +61,7 @@ const testStatusLabel = computed(() => {
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<p class="hero-subtitle">{{ detail.display_name }}</p>
|
||||
<p v-if="detail.change_note" class="change-note">{{ detail.change_note }}</p>
|
||||
<dl class="hero-grid">
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.checksum") }}</dt>
|
||||
<dd><code>{{ detail.checksum || "-" }}</code></dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.schemaChecksum") }}</dt>
|
||||
<dd><code>{{ detail.schema_summary?.checksum || "-" }}</code></dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.publishedAt") }}</dt>
|
||||
<dd>{{ detail.published_at || "-" }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.retiredAt") }}</dt>
|
||||
<dd>{{ detail.retired_at || "-" }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div class="summary-grid">
|
||||
@@ -107,7 +95,7 @@ const testStatusLabel = computed(() => {
|
||||
<dd>{{ frozenEvidenceLabel }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.sampleCountPlain") }}</dt>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.blindTestSuiteSampleCount") }}</dt>
|
||||
<dd>{{ detail.frozen_evidence?.sample_count || 0 }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
@@ -133,7 +121,7 @@ const testStatusLabel = computed(() => {
|
||||
<dd>{{ detail.sample_summary?.training_count || 0 }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.blindTestCount") }}</dt>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.boundBlindTestCount") }}</dt>
|
||||
<dd>{{ detail.sample_summary?.blind_test_count || 0 }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
@@ -156,7 +144,7 @@ const testStatusLabel = computed(() => {
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.approvedAt") }}</dt>
|
||||
<dd>{{ detail.test_summary?.approved_at || "-" }}</dd>
|
||||
<dd>{{ formatDateTime(detail.test_summary?.approved_at) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.latestRun") }}</dt>
|
||||
@@ -174,6 +162,28 @@ const testStatusLabel = computed(() => {
|
||||
</p>
|
||||
<p v-else>{{ t("admin.shippingOrderProfiles.versionCenter.noSourceVersion") }}</p>
|
||||
</article>
|
||||
|
||||
<details class="technical-details">
|
||||
<summary>{{ t("admin.shippingOrderProfiles.versionCenter.technicalDetails") }}</summary>
|
||||
<dl class="technical-grid">
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.publishedAt") }}</dt>
|
||||
<dd>{{ formatDateTime(detail.published_at) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.retiredAt") }}</dt>
|
||||
<dd>{{ formatDateTime(detail.retired_at) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.checksum") }}</dt>
|
||||
<dd><code>{{ detail.checksum || "-" }}</code></dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>{{ t("admin.shippingOrderProfiles.versionCenter.schemaChecksum") }}</dt>
|
||||
<dd><code>{{ detail.schema_summary?.checksum || "-" }}</code></dd>
|
||||
</div>
|
||||
</dl>
|
||||
</details>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
@@ -185,9 +195,9 @@ const testStatusLabel = computed(() => {
|
||||
|
||||
.hero-card,
|
||||
.summary-card {
|
||||
border: 1px solid #e2e8f0;
|
||||
border: 1px solid var(--border-default);
|
||||
border-radius: 0.9rem;
|
||||
background: #fff;
|
||||
background: var(--bg-surface);
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
@@ -200,7 +210,7 @@ const testStatusLabel = computed(() => {
|
||||
|
||||
.eyebrow {
|
||||
margin: 0 0 0.35rem;
|
||||
color: #64748b;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.06em;
|
||||
@@ -209,17 +219,19 @@ const testStatusLabel = computed(() => {
|
||||
.hero-card h2,
|
||||
.summary-card h3 {
|
||||
margin: 0;
|
||||
color: #0f172a;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.hero-subtitle,
|
||||
.profile-identity,
|
||||
.change-note {
|
||||
margin: 0.65rem 0 0;
|
||||
color: #475569;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.profile-identity { font-size: 0.875rem; }
|
||||
|
||||
.change-note {
|
||||
border-left: 3px solid #cbd5e1;
|
||||
border-left: 3px solid var(--border-default);
|
||||
padding-left: 0.75rem;
|
||||
}
|
||||
|
||||
@@ -232,13 +244,27 @@ const testStatusLabel = computed(() => {
|
||||
|
||||
.meta-chip {
|
||||
border-radius: 999px;
|
||||
background: #eff6ff;
|
||||
color: #1d4ed8;
|
||||
background: var(--bg-surface-soft);
|
||||
color: var(--text-secondary);
|
||||
padding: 0.35rem 0.65rem;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.hero-grid,
|
||||
.meta-chip--status {
|
||||
background: var(--status-success-bg);
|
||||
color: var(--status-success-fg);
|
||||
}
|
||||
|
||||
.meta-chip--draft {
|
||||
background: var(--status-warning-bg);
|
||||
color: var(--status-warning-fg);
|
||||
}
|
||||
|
||||
.meta-chip--retired {
|
||||
background: var(--status-error-bg);
|
||||
color: var(--status-error-fg);
|
||||
}
|
||||
|
||||
.summary-card dl {
|
||||
display: grid;
|
||||
gap: 0.75rem;
|
||||
@@ -246,16 +272,14 @@ const testStatusLabel = computed(() => {
|
||||
margin: 1rem 0 0;
|
||||
}
|
||||
|
||||
.hero-grid dt,
|
||||
.summary-card dt {
|
||||
color: #64748b;
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.hero-grid dd,
|
||||
.summary-card dd {
|
||||
margin: 0.25rem 0 0;
|
||||
color: #0f172a;
|
||||
color: var(--text-primary);
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
@@ -267,6 +291,40 @@ const testStatusLabel = computed(() => {
|
||||
|
||||
.source-card p {
|
||||
margin: 0.75rem 0 0;
|
||||
color: #334155;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.technical-details {
|
||||
border-top: 1px solid var(--border-subtle);
|
||||
padding-top: 1rem;
|
||||
}
|
||||
|
||||
.technical-details summary {
|
||||
cursor: pointer;
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.875rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.technical-grid {
|
||||
display: grid;
|
||||
gap: 0.75rem;
|
||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
||||
margin: 0.85rem 0 0;
|
||||
}
|
||||
|
||||
.technical-grid dt {
|
||||
color: var(--text-muted);
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
|
||||
.technical-grid dd {
|
||||
margin: 0.25rem 0 0;
|
||||
color: var(--text-secondary);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.technical-grid code {
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
</style>
|
||||
+87
@@ -13,6 +13,9 @@ import {
|
||||
restoreOrderProfileRegionPageNo,
|
||||
suggestFieldCodeFromHeaders,
|
||||
shouldShowStandardOrderProfilePreview,
|
||||
toOrderProfileAnchorId,
|
||||
buildOrderProfileRecognitionResults,
|
||||
normalizeOrderProfileRelativeRegion,
|
||||
} from './orderProfileForm.utils';
|
||||
|
||||
describe('order profile form rules', () => {
|
||||
@@ -111,4 +114,88 @@ describe('order profile form rules', () => {
|
||||
// 断言两个不同字段以相同覆盖率竞争时保持未映射,禁止静默选择。
|
||||
expect(suggestFieldCodeFromHeaders(field, headers)).toBeNull();
|
||||
});
|
||||
|
||||
it('converts a legacy unbound label into a valid anchor id after schema binding', () => {
|
||||
// 断言“未绑定字段 -> 选择 Schema 字段”不会把缺失或大写的画布 ID 送入 AnchorRule。
|
||||
expect(toOrderProfileAnchorId({
|
||||
id: 'unbound-PURCHASEORDERNO', orderFieldId: 'order_field_1_11', label: 'PURCHASE ORDER NO',
|
||||
})).toBe('purchaseorderno');
|
||||
expect(toOrderProfileAnchorId({
|
||||
id: '', orderFieldId: 'order_field_1_11', label: 'PURCHASE ORDER NO',
|
||||
})).toBe('order_field_1_11');
|
||||
expect(toOrderProfileAnchorId({ id: '', orderFieldId: '', label: '' })).toBeNull();
|
||||
});
|
||||
|
||||
it('keeps structured recognition results linked to their annotation regions', () => {
|
||||
const regions = [
|
||||
{ id: 'po-value', kind: 'order_field' as const, label: 'PO', fieldCode: 'po_number', pageNo: 1, region: { x0: .1, y0: .1, x1: .2, y1: .2 } },
|
||||
{ id: 'part-column', kind: 'field' as const, label: 'Part', fieldCode: 'part_number', pageNo: 1, region: { x0: .1, y0: .3, x1: .2, y1: .4 } },
|
||||
];
|
||||
const results = buildOrderProfileRecognitionResults(regions, [{
|
||||
field_id: 'po', field_code: 'po_number', value: 'PO-100', status: 'confirmed', page_no: 1,
|
||||
}], {
|
||||
table_id: 'table-1', row_count: 2, column_count: 1, rows: [['part_number'], ['PN-1']],
|
||||
row_roles: ['header', 'data'], source_row_indices: [[], [1]], status: 'needs_review',
|
||||
});
|
||||
|
||||
// 断言表头和值行都保留可点击的区域 ID,且不恢复原始表格数据结构。
|
||||
expect(results.header).toMatchObject([{ id: 'po-value', fieldCode: 'po_number', value: 'PO-100', status: 'read' }]);
|
||||
expect(results.line).toMatchObject([{ id: 'part-column', fieldCode: 'part_number', value: 'PN-1', status: 'read', rowNo: 1 }]);
|
||||
|
||||
const deleted = buildOrderProfileRecognitionResults(regions, [], {
|
||||
table_id: 'table-1', row_count: 2, column_count: 1, rows: [['part_number'], ['PN-DELETED']],
|
||||
row_roles: ['header', 'deleted'], source_row_indices: [[], [1]], status: 'needs_review',
|
||||
});
|
||||
// 删除行仍可定位,且不会被伪装为待复核或可纳入结果的普通明细。
|
||||
expect(deleted.line).toMatchObject([{ id: 'part-column', value: 'PN-DELETED', status: 'deleted', rowNo: 1 }]);
|
||||
});
|
||||
|
||||
it('does not display a stale auto-suggestion when the current coordinate read has no value', () => {
|
||||
const results = buildOrderProfileRecognitionResults([{
|
||||
id: 'address-value', kind: 'order_field' as const, label: 'Address', fieldCode: 'bill_to_address',
|
||||
suggestedValue: 'n 66 Hou-Kang Street', pageNo: 1, region: { x0: .1, y0: .1, x1: .2, y1: .2 },
|
||||
}], [], null);
|
||||
|
||||
// 坐标框已调整时,旧建议值不能作为当前样本读取结果回显。
|
||||
expect(results.header).toMatchObject([{ id: 'address-value', value: null, status: 'unavailable' }]);
|
||||
});
|
||||
|
||||
it('reports reading and failure without reusing a prior suggested value', () => {
|
||||
const regions = [{
|
||||
id: 'address-value', kind: 'order_field' as const, label: 'Address', fieldCode: 'bill_to_address',
|
||||
suggestedValue: 'n 66 Hou-Kang Street', pageNo: 1, region: { x0: .1, y0: .1, x1: .2, y1: .2 },
|
||||
}];
|
||||
|
||||
expect(buildOrderProfileRecognitionResults(regions, [], null, 'loading').header[0].status).toBe('loading');
|
||||
expect(buildOrderProfileRecognitionResults(regions, [], null, 'failed').header[0]).toMatchObject({
|
||||
value: null, status: 'failed',
|
||||
});
|
||||
});
|
||||
|
||||
it('uses an absolute value box when re-serializing a newly annotated order field', () => {
|
||||
const valueRegion = { x0: .34, y0: .42, x1: .88, y1: .56 };
|
||||
const definition = {
|
||||
anchor: { anchor_id: 'bill_to', text: 'BILL TO' },
|
||||
value_region: null,
|
||||
absolute_value_region: valueRegion,
|
||||
fallback_value_region: null,
|
||||
};
|
||||
|
||||
// 新标注不再依赖标签框尺寸,删除旧标签后重画也不会生成 Infinity/NaN 坐标。
|
||||
expect(definition).toEqual({
|
||||
anchor: { anchor_id: 'bill_to', text: 'BILL TO' },
|
||||
value_region: null,
|
||||
absolute_value_region: valueRegion,
|
||||
fallback_value_region: null,
|
||||
});
|
||||
});
|
||||
|
||||
it('clips a legacy or suggested value box to the page before persistence', () => {
|
||||
// 断言自动建议略超页面边缘时会保留有效可读区域,不能把越界 absolute_value_region 送到后端。
|
||||
expect(normalizeOrderProfileRelativeRegion({ x0: .74, y0: .18, x1: 1.02, y1: .34 })).toEqual({
|
||||
x0: .74, y0: .18, x1: 1, y1: .34,
|
||||
});
|
||||
// 完全落在页面外或零面积的框没有可解释的读取边界,必须由管理员重画。
|
||||
expect(normalizeOrderProfileRelativeRegion({ x0: 1.1, y0: .2, x1: 1.2, y1: .3 })).toBeNull();
|
||||
});
|
||||
});
|
||||
+110
-2
@@ -5,14 +5,37 @@
|
||||
* 逻辑:页面状态只允许 direct 或已注册复合解析器;同一目标字段跨列只能出现一次。
|
||||
*/
|
||||
|
||||
import type { OrderProfileColumnRule } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
import type { OrderProfileCanvasRegion, OrderProfileTableRegion } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
import type {
|
||||
CoordinateReconstructionPreview,
|
||||
OrderFieldValuePreview,
|
||||
OrderProfileCanvasRegion,
|
||||
OrderProfileColumnRule,
|
||||
OrderProfileRelativeRegion,
|
||||
OrderProfileTableRegion,
|
||||
} from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
|
||||
export interface OrderProfileColumnSelection {
|
||||
extractor_key: 'direct' | 'temp_internal_parts';
|
||||
target: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将画布或历史草稿的区域限制为页面归一化坐标。
|
||||
* @param region - 可能来自拖拽、自动建议或历史模板的页面区域。
|
||||
* @returns 可持久化的正面积区域;无法裁剪为有效区域时返回 null。
|
||||
*/
|
||||
export const normalizeOrderProfileRelativeRegion = (
|
||||
region: OrderProfileRelativeRegion,
|
||||
): OrderProfileRelativeRegion | null => {
|
||||
const values = [region.x0, region.y0, region.x1, region.y1];
|
||||
if (values.some((value) => !Number.isFinite(value))) return null;
|
||||
const x0 = Math.max(0, Math.min(1, region.x0));
|
||||
const y0 = Math.max(0, Math.min(1, region.y0));
|
||||
const x1 = Math.max(0, Math.min(1, region.x1));
|
||||
const y1 = Math.max(0, Math.min(1, region.y1));
|
||||
return x0 < x1 && y0 < y1 ? { x0, y0, x1, y1 } : null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 判断是否显示普通表格预览;可直接创建 Profile 的表格不受上一张表多物理行状态影响。
|
||||
* @param profileCreationAllowed - 当前表格是否可直接创建 Profile
|
||||
@@ -85,6 +108,91 @@ export const restoreOrderProfileRegionPageNo = (tableRegion: OrderProfileTableRe
|
||||
return tableRegion.page_scope === 'continuation_pages' ? 2 : 1;
|
||||
};
|
||||
|
||||
/**
|
||||
* 将画布锚点转换为 v2 契约允许的稳定标识。
|
||||
* @param anchor - 当前订单字段关联的标签区域;历史草稿可能没有可用的区域 ID。
|
||||
* @returns 可写入 AnchorRule 的 anchor_id;无法确定锚点时返回 null 并由调用方使用固定坐标回退。
|
||||
*/
|
||||
export const toOrderProfileAnchorId = (
|
||||
anchor: Pick<OrderProfileCanvasRegion, 'id' | 'label' | 'orderFieldId'> | null | undefined,
|
||||
): string | null => {
|
||||
if (!anchor) return null;
|
||||
const source = String(anchor.id || anchor.orderFieldId || anchor.label || '')
|
||||
.trim()
|
||||
.replace(/^unbound-/i, '');
|
||||
if (!source) return null;
|
||||
const normalized = source
|
||||
.toLocaleLowerCase()
|
||||
.replace(/[^a-z0-9]+/g, '_')
|
||||
.replace(/^_+|_+$/g, '');
|
||||
if (!normalized) return null;
|
||||
const prefixed = /^[a-z]/.test(normalized) ? normalized : `anchor_${normalized}`;
|
||||
return prefixed.slice(0, 64);
|
||||
};
|
||||
|
||||
export interface OrderProfileRecognitionResult {
|
||||
id: string | null;
|
||||
key: string;
|
||||
fieldCode: string;
|
||||
value: string | null;
|
||||
status: 'read' | 'review' | 'loading' | 'failed' | 'unavailable' | 'deleted';
|
||||
rowNo?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将已有坐标预览和值读取结果变为可反向定位的结构化复核项。
|
||||
* @param pageRegions - 当前页画布区域;未标注字段不会伪装成可定位项。
|
||||
* @param fieldValues - 订单表头字段值接口的结果。
|
||||
* @param reconstruction - 坐标重建接口的明细行结果。
|
||||
* @returns 表头及明细字段结果,均保留对应画布区域 ID。
|
||||
*/
|
||||
export const buildOrderProfileRecognitionResults = (
|
||||
pageRegions: OrderProfileCanvasRegion[],
|
||||
fieldValues: OrderFieldValuePreview[],
|
||||
reconstruction: CoordinateReconstructionPreview | null,
|
||||
fieldValueState: 'idle' | 'loading' | 'ready' | 'failed' = 'idle',
|
||||
): { header: OrderProfileRecognitionResult[]; line: OrderProfileRecognitionResult[] } => {
|
||||
const valuesByCode = new Map(fieldValues.map((item) => [item.field_code, item]));
|
||||
const header = pageRegions
|
||||
.filter((item) => item.kind === 'order_field' && item.fieldCode)
|
||||
.map((item) => {
|
||||
const value = valuesByCode.get(item.fieldCode!);
|
||||
return {
|
||||
id: item.id,
|
||||
key: item.id,
|
||||
fieldCode: item.fieldCode!,
|
||||
// 实时复核只接受当前坐标读取结果,不能回退显示历史自动建议缓存。
|
||||
value: value?.value || null,
|
||||
status: value?.value ? 'read' as const
|
||||
: fieldValueState === 'loading' ? 'loading' as const
|
||||
: fieldValueState === 'failed' ? 'failed' as const : 'unavailable' as const,
|
||||
};
|
||||
});
|
||||
if (!reconstruction) return { header, line: [] };
|
||||
const regionsByCode = new Map(
|
||||
pageRegions
|
||||
.filter((item) => item.kind === 'field' && item.fieldCode)
|
||||
.map((item) => [item.fieldCode!, item.id]),
|
||||
);
|
||||
const fieldCodes = reconstruction.rows[0] || [];
|
||||
const line = reconstruction.rows.slice(1).flatMap((row, rowIndex) => {
|
||||
const sourceIndex = rowIndex + 1;
|
||||
const role = reconstruction.row_roles[sourceIndex];
|
||||
if (role !== 'data' && role !== 'deleted') return [];
|
||||
return fieldCodes.map((fieldCode, columnIndex) => ({
|
||||
id: regionsByCode.get(fieldCode) || null,
|
||||
key: `${sourceIndex}-${fieldCode}`,
|
||||
fieldCode,
|
||||
value: row[columnIndex] || null,
|
||||
status: role === 'deleted'
|
||||
? 'deleted' as const
|
||||
: row[columnIndex] ? 'read' as const : 'unavailable' as const,
|
||||
rowNo: rowIndex + 1,
|
||||
}));
|
||||
});
|
||||
return { header, line };
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据已确认表头的横向覆盖关系建议明细字段;冲突或覆盖不足时拒绝猜测。
|
||||
* @param fieldRegion - 当前待绑定的明细字段区域
|
||||
|
||||
+7
-8
@@ -101,11 +101,10 @@ watch(
|
||||
<section class="space-y-5 p-5 md:p-7">
|
||||
<header class="flex flex-wrap items-start justify-between gap-4">
|
||||
<div>
|
||||
<p class="text-xs font-semibold uppercase tracking-[0.16em] text-brand-600">{{ t('admin.shippingOrderExtractionRuns.eyebrow') }}</p>
|
||||
<h1 class="mt-1 text-2xl font-bold text-primary">{{ t('admin.shippingOrderExtractionRuns.title') }}</h1>
|
||||
<p class="mt-2 max-w-3xl text-sm text-secondary">{{ t('admin.shippingOrderExtractionRuns.subtitle') }}</p>
|
||||
<h1 class="section-title">{{ t('admin.shippingOrderExtractionRuns.title') }}</h1>
|
||||
<p class="section-desc mt-1 max-w-3xl">{{ t('admin.shippingOrderExtractionRuns.subtitle') }}</p>
|
||||
</div>
|
||||
<button type="button" class="rounded-lg border border-default px-3 py-2 text-sm text-secondary hover:bg-slate-50 dark:hover:bg-slate-800" :disabled="loading" @click="load">
|
||||
<button type="button" class="btn-secondary btn-sm" :disabled="loading" @click="load">
|
||||
{{ t('admin.shippingOrderExtractionRuns.refresh') }}
|
||||
</button>
|
||||
</header>
|
||||
@@ -113,7 +112,7 @@ watch(
|
||||
<div class="flex flex-wrap items-center gap-3 rounded-xl border border-default bg-surface p-3">
|
||||
<label class="flex items-center gap-2 text-sm text-secondary">
|
||||
{{ t('admin.shippingOrderExtractionRuns.status') }}
|
||||
<select v-model="status" class="rounded-md border border-default bg-surface px-2 py-1.5" @change="applyStatus">
|
||||
<select v-model="status" class="select-field py-1.5" @change="applyStatus">
|
||||
<option value="">{{ t('admin.shippingOrderExtractionRuns.allStatuses') }}</option>
|
||||
<option v-for="value in ['queued', 'processing', 'completed', 'partially_completed', 'review_required', 'failed', 'cancelled']" :key="value" :value="value">
|
||||
{{ t(`admin.shippingOrderExtractionRuns.statuses.${value}`) }}
|
||||
@@ -126,7 +125,7 @@ watch(
|
||||
<p v-if="error" class="rounded-lg border border-rose-200 bg-rose-50 p-3 text-sm text-rose-700">{{ error }}</p>
|
||||
<div class="overflow-x-auto rounded-xl border border-default bg-surface">
|
||||
<table class="min-w-[940px] w-full text-left text-sm">
|
||||
<thead class="border-b border-default bg-slate-50 text-xs text-muted dark:bg-slate-900/40"><tr>
|
||||
<thead class="border-b border-default bg-surface-soft text-xs text-muted"><tr>
|
||||
<th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.runNo') }}</th><th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.status') }}</th><th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.stage') }}</th><th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.attempts') }}</th><th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.createdAt') }}</th><th class="px-4 py-3">{{ t('admin.shippingOrderExtractionRuns.totalDuration') }}</th><th class="px-4 py-3"></th>
|
||||
</tr></thead>
|
||||
<tbody><tr v-if="loading"><td colspan="7" class="px-4 py-8 text-center text-muted">{{ t('admin.shippingOrderExtractionRuns.loading') }}</td></tr>
|
||||
@@ -137,7 +136,7 @@ watch(
|
||||
</div>
|
||||
<div class="flex items-center justify-end gap-3 text-sm"><button type="button" class="rounded border border-default px-3 py-1.5 disabled:opacity-50" :disabled="page <= 1 || loading" @click="page -= 1; load()">{{ t('admin.shippingOrderExtractionRuns.previous') }}</button><span>{{ page }}</span><button type="button" class="rounded border border-default px-3 py-1.5 disabled:opacity-50" :disabled="page * pageSize >= total || loading" @click="page += 1; load()">{{ t('admin.shippingOrderExtractionRuns.next') }}</button></div>
|
||||
|
||||
<div v-if="detail || detailLoading" class="fixed inset-0 z-50 flex justify-end bg-black/30" @click.self="closeDetail">
|
||||
<div v-if="detail || detailLoading" class="fixed inset-0 z-50 flex justify-end bg-overlay" @click.self="closeDetail">
|
||||
<aside class="h-full w-full max-w-2xl overflow-y-auto bg-surface p-6 shadow-2xl">
|
||||
<div class="flex items-center justify-between"><h2 class="text-lg font-bold">{{ t('admin.shippingOrderExtractionRuns.detailTitle') }}</h2><button type="button" class="text-secondary" @click="closeDetail">{{ t('admin.close') }}</button></div>
|
||||
<p v-if="detailLoading" class="mt-6 text-muted">{{ t('admin.shippingOrderExtractionRuns.loading') }}</p>
|
||||
@@ -176,7 +175,7 @@ watch(
|
||||
</section>
|
||||
<h3 class="mt-7 font-semibold">{{ t('admin.shippingOrderExtractionRuns.jobAttempts') }}</h3><div class="mt-2 space-y-2"><div v-for="job in detail.job_attempts" :key="job.job_id" class="rounded-lg border border-default p-3 text-sm"><b>#{{ job.job_id }}</b> · {{ job.status }} · {{ t('admin.shippingOrderExtractionRuns.attempts') }} {{ job.attempts }}/{{ job.max_attempts }} · {{ formatDuration(job.duration_ms) }}</div><p v-if="!detail.job_attempts.length" class="text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p></div>
|
||||
<h3 class="mt-7 font-semibold">{{ t('admin.shippingOrderExtractionRuns.units') }}</h3><div class="mt-2 space-y-2"><div v-for="unit in detail.units" :key="unit.unit_id" class="rounded-lg border border-default p-3 text-sm"><b>#{{ unit.position + 1 }} {{ unit.unit_type }}</b> · {{ unit.status }} · {{ t('admin.shippingOrderExtractionRuns.attempts') }} {{ unit.attempt_count }} · {{ formatDuration(unit.duration_ms) }}<span v-if="unit.error_code" class="ml-2 font-mono text-xs text-danger">{{ unit.error_code }}</span>
|
||||
<section v-for="route in unit.route_decisions" :key="`${unit.unit_id}:${route.attempt_no}`" class="mt-3 rounded border border-default bg-slate-50 p-3 text-xs dark:bg-slate-900/40"><h4 class="font-semibold text-primary">{{ t('admin.shippingOrderExtractionRuns.routeDecision') }} #{{ route.attempt_no }}</h4><dl class="mt-2 grid grid-cols-2 gap-x-3 gap-y-1"><dt>{{ t('admin.shippingOrderExtractionRuns.executionMode') }}</dt><dd>{{ t(`admin.shippingOrderExtractionRuns.executionModes.${route.execution_mode}`) }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.matchStatus') }}</dt><dd>{{ t(`admin.shippingOrderExtractionRuns.matchStatuses.${route.match_status}`) }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.selectedProfile') }}</dt><dd>{{ route.selected_profile_code ? `${route.selected_profile_code} V${route.selected_profile_version}` : '-' }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.autoCreateApproved') }}</dt><dd>{{ route.auto_create_approved == null ? '-' : t(route.auto_create_approved ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.fallbackReasons') }}</dt><dd>{{ route.fallback_reason_codes.length ? route.fallback_reason_codes.map(code => t(`admin.shippingOrderExtractionRuns.reasonCodes.${code}`)).join(';') : '-' }}</dd></dl><div v-if="route.candidates.length" class="mt-3"><p class="font-medium">{{ t('admin.shippingOrderExtractionRuns.candidates') }}</p><div v-for="candidate in route.candidates" :key="`${candidate.profile_code}:${candidate.version}`" class="mt-1 flex flex-wrap gap-x-2 text-muted"><span>{{ candidate.profile_code }} V{{ candidate.version }}</span><span>{{ candidate.score.toFixed(2) }}</span><span>{{ candidate.hard_match ? t('admin.shippingOrderExtractionRuns.hardMatch') : t('admin.shippingOrderExtractionRuns.hardMismatch') }}</span><span v-if="candidate.missing_required_anchor_ids?.length">{{ t('admin.shippingOrderExtractionRuns.missingAnchors', { ids: candidate.missing_required_anchor_ids.join(', ') }) }}</span></div></div></section>
|
||||
<section v-for="route in unit.route_decisions" :key="`${unit.unit_id}:${route.attempt_no}`" class="mt-3 rounded border border-default bg-surface-soft p-3 text-xs"><h4 class="font-semibold text-primary">{{ t('admin.shippingOrderExtractionRuns.routeDecision') }} #{{ route.attempt_no }}</h4><dl class="mt-2 grid grid-cols-2 gap-x-3 gap-y-1"><dt>{{ t('admin.shippingOrderExtractionRuns.executionMode') }}</dt><dd>{{ t(`admin.shippingOrderExtractionRuns.executionModes.${route.execution_mode}`) }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.matchStatus') }}</dt><dd>{{ t(`admin.shippingOrderExtractionRuns.matchStatuses.${route.match_status}`) }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.selectedProfile') }}</dt><dd>{{ route.selected_profile_code ? `${route.selected_profile_code} V${route.selected_profile_version}` : '-' }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.autoCreateApproved') }}</dt><dd>{{ route.auto_create_approved == null ? '-' : t(route.auto_create_approved ? 'admin.shippingOrderExtractionRuns.yes' : 'admin.shippingOrderExtractionRuns.no') }}</dd><dt>{{ t('admin.shippingOrderExtractionRuns.fallbackReasons') }}</dt><dd>{{ route.fallback_reason_codes.length ? route.fallback_reason_codes.map(code => t(`admin.shippingOrderExtractionRuns.reasonCodes.${code}`)).join(';') : '-' }}</dd></dl><div v-if="route.candidates.length" class="mt-3"><p class="font-medium">{{ t('admin.shippingOrderExtractionRuns.candidates') }}</p><div v-for="candidate in route.candidates" :key="`${candidate.profile_code}:${candidate.version}`" class="mt-1 flex flex-wrap gap-x-2 text-muted"><span>{{ candidate.profile_code }} V{{ candidate.version }}</span><span>{{ candidate.score.toFixed(2) }}</span><span>{{ candidate.hard_match ? t('admin.shippingOrderExtractionRuns.hardMatch') : t('admin.shippingOrderExtractionRuns.hardMismatch') }}</span><span v-if="candidate.missing_required_anchor_ids?.length">{{ t('admin.shippingOrderExtractionRuns.missingAnchors', { ids: candidate.missing_required_anchor_ids.join(', ') }) }}</span></div></div></section>
|
||||
</div><p v-if="!detail.units.length" class="text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p></div>
|
||||
<h3 class="mt-7 font-semibold">{{ t('admin.shippingOrderExtractionRuns.lifecycle') }}</h3><div class="mt-2 space-y-2"><div v-for="event in detail.progress_events" :key="`${event.sequence_no}:${event.event_code}`" class="rounded-lg border border-default p-3 text-sm"><b>{{ event.event_code }}</b><span class="ml-2 text-secondary">{{ event.status || '-' }}</span><span class="ml-2 font-mono text-xs text-muted">{{ t(`admin.shippingOrderExtractionRuns.visibilities.${event.visibility}`) }}</span><span v-if="event.reason_code" class="ml-2 font-mono text-xs text-muted">{{ event.reason_code }}</span><time class="ml-2 text-xs text-muted">{{ formatTime(event.occurred_at) }}</time></div><p v-if="!detail.progress_events.length" class="text-sm text-muted">{{ t('admin.shippingOrderExtractionRuns.empty') }}</p></div>
|
||||
</template>
|
||||
|
||||
+35
-38
@@ -817,9 +817,8 @@ onMounted(async () => {
|
||||
<template>
|
||||
<section class="mx-auto max-w-7xl space-y-6 p-6">
|
||||
<header>
|
||||
<p class="text-xs font-bold uppercase tracking-widest text-brand-600">{{ t('admin.shippingOrderSchema.eyebrow') }}</p>
|
||||
<h1 class="mt-2 text-2xl font-bold text-primary">{{ t('admin.shippingOrderSchema.title') }}</h1>
|
||||
<p class="mt-2 text-sm text-muted">{{ t('admin.shippingOrderSchema.subtitle') }}</p>
|
||||
<h1 class="section-title">{{ t('admin.shippingOrderSchema.title') }}</h1>
|
||||
<p class="section-desc mt-1">{{ t('admin.shippingOrderSchema.subtitle') }}</p>
|
||||
</header>
|
||||
|
||||
<div v-if="loading" class="rounded-xl border border-default p-8 text-center text-muted">{{ t('common.loading') }}</div>
|
||||
@@ -837,7 +836,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
<div class="schema-setup-form">
|
||||
<p>{{ t('admin.shippingOrderSchema.setupActionHintPhase4') }}</p>
|
||||
<button :disabled="saving" class="primary-button">{{ t('admin.shippingOrderSchema.initialize') }}</button>
|
||||
<button :disabled="saving" class="btn-primary">{{ t('admin.shippingOrderSchema.initialize') }}</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -849,7 +848,7 @@ onMounted(async () => {
|
||||
<p class="field-asset-hint">{{ t('admin.shippingOrderSchema.fieldAssetLibraryHint') }}</p>
|
||||
</div>
|
||||
<div class="no-version-actions">
|
||||
<button type="button" class="primary-button" :disabled="saving" @click="createDraft">
|
||||
<button type="button" class="btn-primary" :disabled="saving" @click="createDraft">
|
||||
{{ t('admin.shippingOrderSchema.createFirstDraft') }}
|
||||
</button>
|
||||
</div>
|
||||
@@ -868,25 +867,25 @@ onMounted(async () => {
|
||||
</span>
|
||||
</div>
|
||||
<div class="toolbar-actions">
|
||||
<button type="button" class="secondary-button" :disabled="saving" @click="openHistory">
|
||||
<button type="button" class="btn-secondary" :disabled="saving" @click="openHistory">
|
||||
{{ t('admin.shippingOrderSchema.historyOpen') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="!draft && published"
|
||||
type="button"
|
||||
class="secondary-button"
|
||||
class="btn-secondary"
|
||||
:disabled="saving"
|
||||
@click="createDraft"
|
||||
>
|
||||
{{ t('admin.shippingOrderSchema.createDraft') }}
|
||||
</button>
|
||||
<template v-if="draft">
|
||||
<button type="button" class="secondary-button" :disabled="saving" @click="saveDraft">
|
||||
<button type="button" class="btn-secondary" :disabled="saving" @click="saveDraft">
|
||||
{{ t('admin.shippingOrderSchema.saveDraft') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="primary-button"
|
||||
class="btn-primary"
|
||||
:disabled="saving || !draftFields.some((item) => item.enabled)"
|
||||
@click="publishDraft"
|
||||
>
|
||||
@@ -933,7 +932,7 @@ onMounted(async () => {
|
||||
<button
|
||||
v-if="draft"
|
||||
type="button"
|
||||
class="adopt-suggested-button"
|
||||
class="btn-secondary btn-sm"
|
||||
:disabled="saving || !suggestedPreviewCount"
|
||||
@click="openSuggestPreview"
|
||||
>
|
||||
@@ -942,7 +941,7 @@ onMounted(async () => {
|
||||
</div>
|
||||
|
||||
<div class="field-search">
|
||||
<input v-model="fieldSearch" type="search" :placeholder="t('admin.shippingOrderSchema.searchFields')">
|
||||
<input v-model="fieldSearch" class="input-field" type="search" :placeholder="t('admin.shippingOrderSchema.searchFields')">
|
||||
<span>{{ t('admin.shippingOrderSchema.adoptedCount', { adopted: adoptedCount, total: catalogFields.length }) }}</span>
|
||||
</div>
|
||||
|
||||
@@ -1037,7 +1036,7 @@ onMounted(async () => {
|
||||
<button
|
||||
v-if="selectedField"
|
||||
type="button"
|
||||
class="secondary-button compact-button"
|
||||
class="btn-secondary btn-sm compact-button"
|
||||
:disabled="fieldImpactLoading"
|
||||
@click="openFieldImpact(selectedField.id)"
|
||||
>
|
||||
@@ -1050,12 +1049,13 @@ onMounted(async () => {
|
||||
<div class="rule-basics">
|
||||
<label>
|
||||
<span class="help-label" :data-help="fieldHelp('displayName')">{{ t('admin.shippingOrderSchema.displayName') }}</span>
|
||||
<input v-model="selectedRuleConfig.display_name" :disabled="isReadOnly">
|
||||
<input v-model="selectedRuleConfig.display_name" class="input-field" :disabled="isReadOnly">
|
||||
</label>
|
||||
<label>
|
||||
<span class="help-label" :data-help="fieldHelp('businessPurpose')">{{ t('admin.shippingOrderSchema.businessPurpose') }}</span>
|
||||
<select
|
||||
v-model="selectedRuleConfig.business_purpose"
|
||||
class="select-field"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled || selectedField.scope !== 'line'"
|
||||
>
|
||||
<option
|
||||
@@ -1070,6 +1070,7 @@ onMounted(async () => {
|
||||
<label class="span-two">
|
||||
<span class="help-label" :data-help="fieldHelp('aliases')">{{ t('admin.shippingOrderSchema.aliases') }}</span>
|
||||
<input
|
||||
class="input-field"
|
||||
:value="selectedRuleConfig.aliases.join(', ')"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
@input="!isReadOnly && (selectedRuleConfig.aliases = splitValues(($event.target as HTMLInputElement).value))"
|
||||
@@ -1079,6 +1080,7 @@ onMounted(async () => {
|
||||
<span class="help-label" :data-help="fieldHelp('extractionInstruction')">{{ t('admin.shippingOrderSchema.extractionInstruction') }}</span>
|
||||
<textarea
|
||||
v-model="selectedRuleConfig.extraction_instruction"
|
||||
class="input-field"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
:placeholder="t('admin.shippingOrderSchema.extractionInstructionPlaceholder')"
|
||||
/>
|
||||
@@ -1105,6 +1107,7 @@ onMounted(async () => {
|
||||
<input
|
||||
v-if="selectedRuleConfig.auto_create_key_field"
|
||||
v-model.number="selectedRuleConfig.minimum_confidence"
|
||||
class="input-field"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
:required="selectedRuleConfig.auto_create_key_field"
|
||||
:aria-label="fieldHelp('minimumKeyFieldConfidence')"
|
||||
@@ -1158,6 +1161,7 @@ onMounted(async () => {
|
||||
<span class="help-label" :data-help="fieldHelp('normalizer')">{{ t('admin.shippingOrderSchema.normalizer') }}</span>
|
||||
<select
|
||||
v-model="selectedRuleConfig.normalizer_key"
|
||||
class="select-field"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
>
|
||||
<option v-for="item in compatibleRules(selectedRuleConfig, 'type_normalizers')" :key="item" :value="item">
|
||||
@@ -1169,6 +1173,7 @@ onMounted(async () => {
|
||||
<span class="help-label" :data-help="fieldHelp('comparator')">{{ t('admin.shippingOrderSchema.comparator') }}</span>
|
||||
<select
|
||||
v-model="selectedRuleConfig.comparator_key"
|
||||
class="select-field"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
>
|
||||
<option v-for="item in compatibleRules(selectedRuleConfig, 'type_comparators')" :key="item" :value="item">
|
||||
@@ -1180,6 +1185,7 @@ onMounted(async () => {
|
||||
<span class="help-label" :data-help="fieldHelp('relationRole')">{{ t('admin.shippingOrderSchema.relationRole') }}</span>
|
||||
<select
|
||||
v-model="selectedRuleConfig.relation_role"
|
||||
class="select-field"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
>
|
||||
<option :value="null">{{ t('admin.shippingOrderSchema.notSet') }}</option>
|
||||
@@ -1192,6 +1198,7 @@ onMounted(async () => {
|
||||
<span class="help-label" :data-help="fieldHelp('conflictPolicy')">{{ t('admin.shippingOrderSchema.conflictPolicy') }}</span>
|
||||
<select
|
||||
v-model="selectedRuleConfig.evidence_policy.conflict_policy"
|
||||
class="select-field"
|
||||
:disabled="isReadOnly || !selectedDraftField?.enabled"
|
||||
>
|
||||
<option v-for="item in state?.catalog.conflict_policies || []" :key="item" :value="item">
|
||||
@@ -1250,9 +1257,9 @@ onMounted(async () => {
|
||||
<footer v-if="!isReadOnly" class="rule-footer">
|
||||
<label>
|
||||
<span>{{ t('admin.shippingOrderSchema.changeNote') }}</span>
|
||||
<input v-model="changeNote" :placeholder="t('admin.shippingOrderSchema.changeNotePlaceholder')">
|
||||
<input v-model="changeNote" class="input-field" :placeholder="t('admin.shippingOrderSchema.changeNotePlaceholder')">
|
||||
</label>
|
||||
<button type="button" :disabled="saving" class="text-danger" @click="deleteDraft">
|
||||
<button type="button" :disabled="saving" class="btn-danger btn-sm" @click="deleteDraft">
|
||||
{{ t('admin.shippingOrderSchema.deleteDraft') }}
|
||||
</button>
|
||||
</footer>
|
||||
@@ -1308,7 +1315,7 @@ onMounted(async () => {
|
||||
<section class="impact-dialog">
|
||||
<header>
|
||||
<h2>{{ t('admin.shippingOrderSchema.autoCreationConfirmTitle') }}</h2>
|
||||
<button type="button" class="text-button" @click="cancelAutoCreationToggle">{{ t('common.close') }}</button>
|
||||
<button type="button" class="btn-ghost btn-sm" @click="cancelAutoCreationToggle">{{ t('common.close') }}</button>
|
||||
</header>
|
||||
<p>
|
||||
{{ t('admin.shippingOrderSchema.autoCreationConfirmBody', {
|
||||
@@ -1322,8 +1329,8 @@ onMounted(async () => {
|
||||
</p>
|
||||
<p class="muted">{{ t('admin.shippingOrderSchema.autoCreationConfirmHint') }}</p>
|
||||
<footer>
|
||||
<button type="button" class="secondary-button" @click="cancelAutoCreationToggle">{{ t('common.cancel') }}</button>
|
||||
<button type="button" class="primary-button" @click="confirmAutoCreationToggle">
|
||||
<button type="button" class="btn-secondary" @click="cancelAutoCreationToggle">{{ t('common.cancel') }}</button>
|
||||
<button type="button" class="btn-primary" @click="confirmAutoCreationToggle">
|
||||
{{ t('admin.shippingOrderSchema.autoCreationConfirmAction') }}
|
||||
</button>
|
||||
</footer>
|
||||
@@ -1334,7 +1341,7 @@ onMounted(async () => {
|
||||
<section class="impact-dialog">
|
||||
<header>
|
||||
<h2>{{ t('admin.shippingOrderSchema.profileImpactTitle') }}</h2>
|
||||
<button type="button" class="text-button" @click="profileImpactOpen = false">{{ t('common.close') }}</button>
|
||||
<button type="button" class="btn-ghost btn-sm" @click="profileImpactOpen = false">{{ t('common.close') }}</button>
|
||||
</header>
|
||||
<p>{{ t('admin.shippingOrderSchema.profileImpactSummary', profileImpact.summary) }}</p>
|
||||
<div class="impact-list">
|
||||
@@ -1349,8 +1356,8 @@ onMounted(async () => {
|
||||
</article>
|
||||
</div>
|
||||
<footer>
|
||||
<button type="button" class="secondary-button" @click="profileImpactOpen = false">{{ t('common.cancel') }}</button>
|
||||
<button type="button" class="primary-button" :disabled="saving" @click="confirmPublishWithImpact">
|
||||
<button type="button" class="btn-secondary" @click="profileImpactOpen = false">{{ t('common.cancel') }}</button>
|
||||
<button type="button" class="btn-primary" :disabled="saving" @click="confirmPublishWithImpact">
|
||||
{{ t('admin.shippingOrderSchema.confirmImpactPublish') }}
|
||||
</button>
|
||||
</footer>
|
||||
@@ -1361,7 +1368,7 @@ onMounted(async () => {
|
||||
<section class="impact-dialog suggest-preview-dialog">
|
||||
<header>
|
||||
<h2>{{ t('admin.shippingOrderSchema.suggestPreviewTitle') }}</h2>
|
||||
<button type="button" class="text-button" @click="suggestPreviewOpen = false">{{ t('common.close') }}</button>
|
||||
<button type="button" class="btn-ghost btn-sm" @click="suggestPreviewOpen = false">{{ t('common.close') }}</button>
|
||||
</header>
|
||||
<p v-if="suggestedPreviewCount">
|
||||
{{ t('admin.shippingOrderSchema.suggestPreviewIntro', { count: suggestedPreviewCount }) }}
|
||||
@@ -1374,12 +1381,12 @@ onMounted(async () => {
|
||||
</li>
|
||||
</ul>
|
||||
<footer>
|
||||
<button type="button" class="secondary-button" @click="suggestPreviewOpen = false">
|
||||
<button type="button" class="btn-secondary" @click="suggestPreviewOpen = false">
|
||||
{{ t('admin.shippingOrderSchema.suggestCancel') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="primary-button"
|
||||
class="btn-primary"
|
||||
:disabled="!suggestedPreviewCount"
|
||||
@click="confirmAdoptSuggested"
|
||||
>
|
||||
@@ -1392,14 +1399,9 @@ onMounted(async () => {
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.primary-button, .secondary-button, .text-button { border: 0; border-radius: 6px; padding: 8px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
|
||||
.primary-button { background: #0ea5e9; color: #fff; }
|
||||
.secondary-button { border: 1px solid #d7e0ea; background: #fff; color: #475569; }
|
||||
.compact-button { padding: 6px 10px; font-size: 12px; }
|
||||
.text-button { background: transparent; color: #64748b; }
|
||||
.primary-button:disabled, .secondary-button:disabled { cursor: not-allowed; opacity: .55; }
|
||||
.impact-overlay { position: fixed; z-index: 60; inset: 0; display: grid; place-items: center; background: rgb(15 23 42 / .42); padding: 24px; }
|
||||
.impact-dialog { display: grid; width: min(720px, 96vw); max-height: 82vh; gap: 14px; overflow: hidden; border-radius: 12px; background: #fff; padding: 18px; box-shadow: 0 24px 64px rgb(15 23 42 / .24); }
|
||||
.impact-overlay { position: fixed; z-index: 60; inset: 0; display: grid; place-items: center; background: var(--overlay-soft); padding: 24px; }
|
||||
.impact-dialog { display: grid; width: min(720px, 96vw); max-height: 82vh; gap: 14px; overflow: hidden; border-radius: 12px; background: var(--bg-surface); padding: 18px; box-shadow: 0 24px 64px rgb(15 23 42 / .24); }
|
||||
.impact-dialog header, .impact-dialog footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
|
||||
.impact-dialog h2, .impact-dialog p { margin: 0; }
|
||||
.impact-list { display: grid; gap: 8px; overflow: auto; }
|
||||
@@ -1439,11 +1441,8 @@ onMounted(async () => {
|
||||
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 16px 10px; }
|
||||
.panel-heading h2, .rule-heading h2 { margin: 0; color: #1e293b; font-size: 15px; font-weight: 600; }
|
||||
.panel-heading p { margin: 5px 0 0; color: #94a3b8; font-size: 12px; line-height: 1.5; }
|
||||
.adopt-suggested-button { flex: 0 0 auto; border: 1px solid #bae6fd; border-radius: 6px; background: #f0f9ff; padding: 6px 10px; color: #0369a1; font: inherit; font-size: 11px; font-weight: 600; cursor: pointer; white-space: nowrap; }
|
||||
.adopt-suggested-button:disabled { cursor: not-allowed; opacity: .55; }
|
||||
.field-search { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid #e5ebf1; padding: 8px 12px 12px; }
|
||||
.field-search input { min-width: 0; flex: 1; border: 1px solid #d9e2ec; border-radius: 6px; background: #fff; padding: 7px 9px; color: #334155; font: inherit; font-size: 12px; outline: none; }
|
||||
.field-search input:focus { border-color: #38bdf8; box-shadow: 0 0 0 2px rgb(56 189 248 / 12%); }
|
||||
.field-search .input-field { min-width: 0; flex: 1; padding: 7px 9px; font: inherit; font-size: 12px; }
|
||||
.field-search span { flex: 0 0 auto; color: #94a3b8; font-size: 11px; }
|
||||
.adoption-guide { margin: 0 12px 8px; border: 1px solid #dbe6ef; border-radius: 7px; background: #f8fafc; padding: 8px 9px; color: #64748b; font-size: 11px; line-height: 1.4; }
|
||||
.field-list { min-height: 0; flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain; padding: 0 8px 12px; }
|
||||
@@ -1487,8 +1486,7 @@ onMounted(async () => {
|
||||
.rule-basics .span-two { grid-column: 1 / -1; }
|
||||
.rule-basics { border: 1px solid #edf1f5; border-radius: 8px; background: #fcfdff; padding: 12px; }
|
||||
.rule-body label, .rule-footer label { display: grid; gap: 3px; color: #64748b; font-size: 12px; }
|
||||
.rule-body input:not([type="checkbox"]):not([type="radio"]), .rule-body select, .rule-body textarea, .rule-footer input { min-width: 0; border: 1px solid #d9e2ec; border-radius: 6px; background: #fff; padding: 6px 8px; color: #334155; font: inherit; font-size: 13px; outline: none; }
|
||||
.rule-body input:not([type="checkbox"]):not([type="radio"]):focus, .rule-body select:focus, .rule-body textarea:focus, .rule-footer input:focus { border-color: #38bdf8; box-shadow: 0 0 0 2px rgb(56 189 248 / 12%); }
|
||||
.rule-body .input-field, .rule-body .select-field, .rule-footer .input-field { min-width: 0; padding: 6px 8px; font: inherit; font-size: 13px; }
|
||||
.rule-body input:disabled, .rule-body select:disabled, .rule-body textarea:disabled { background: #f8fafc; color: #64748b; }
|
||||
.rule-body input[type="checkbox"]:disabled { appearance: auto; opacity: 1; accent-color: #0ea5e9; }
|
||||
.rule-body textarea { min-height: 56px; resize: vertical; }
|
||||
@@ -1515,7 +1513,6 @@ onMounted(async () => {
|
||||
.compact-check-row label { border: 1px solid #e5ebf1; border-radius: 6px; background: #f8fafc; padding: 5px 8px; font-size: 12px; }
|
||||
.rule-footer { display: flex; flex: 0 0 auto; align-items: flex-end; justify-content: space-between; gap: 16px; border-top: 1px solid #e5ebf1; background: #fbfcfe; padding: 12px 24px; }
|
||||
.rule-footer label { flex: 1; }
|
||||
.text-danger { border: 0; background: transparent; color: #ef4444; font: inherit; font-size: 12px; cursor: pointer; }
|
||||
.rule-empty { display: grid; min-height: 360px; place-content: center; gap: 8px; padding: 24px; color: #94a3b8; text-align: center; font-size: 13px; }
|
||||
.rule-empty-hint { margin: 0; color: #64748b; font-size: 12px; }
|
||||
@media (max-width: 900px) {
|
||||
|
||||
+64
-5
@@ -2,7 +2,7 @@
|
||||
features/admin/modules/shipping-order-schema/components/SchemaAuditTimeline.vue
|
||||
用途:展示订单 Schema 配置的追加式审计时间线。
|
||||
依赖:ShippingOrderSchemaAuditEvent DTO、Vue I18n。
|
||||
逻辑:父组件分页读取最小审计摘要,本组件不展示完整前后配置快照或提供修改操作。
|
||||
逻辑:父组件分页读取最小审计摘要;展示字段集合变更与自动建单策略变更,不展示完整快照。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
@@ -12,24 +12,72 @@ defineProps<{ events: ShippingOrderSchemaAuditEvent[]; total: number; loading: b
|
||||
const emit = defineEmits<{ loadMore: [] }>();
|
||||
const { t } = useI18n();
|
||||
|
||||
/** 使用本地时间展示事件发生时刻,缺失时间维持审计可读性。 */
|
||||
/**
|
||||
* 使用本地时间展示事件发生时刻,缺失时间维持审计可读性。
|
||||
* @param value - ISO 时间字符串
|
||||
*/
|
||||
const formatDate = (value?: string | null): string => value
|
||||
? new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'short' }).format(new Date(value))
|
||||
: t('admin.shippingOrderSchema.historyUnknownTime');
|
||||
|
||||
/** 将事件类型映射为面向业务人员的动作,未知类型保留其原值。 */
|
||||
/**
|
||||
* 将事件类型映射为面向业务人员的动作,未知类型保留其原值。
|
||||
* @param eventType - 审计事件类型码
|
||||
*/
|
||||
const eventLabel = (eventType: string): string => {
|
||||
const key = `admin.shippingOrderSchema.auditEvent.${eventType}`;
|
||||
const translated = t(key);
|
||||
return translated === key ? eventType : translated;
|
||||
};
|
||||
|
||||
/** 只有字段集合确有变化时才显示计数摘要,避免目录事件出现无意义的全零提示。 */
|
||||
/**
|
||||
* 将自动建单 enabled 布尔值映射为「开启/关闭」文案。
|
||||
* @param enabled - 策略开关
|
||||
*/
|
||||
const autoCreationStateLabel = (enabled: boolean): string => (
|
||||
enabled
|
||||
? t('admin.shippingOrderSchema.autoCreationOn')
|
||||
: t('admin.shippingOrderSchema.autoCreationOff')
|
||||
);
|
||||
|
||||
/**
|
||||
* 只有字段集合确有变化时才显示计数摘要,避免目录事件出现无意义的全零提示。
|
||||
* @param event - 审计事件
|
||||
*/
|
||||
const hasFieldChanges = (event: ShippingOrderSchemaAuditEvent): boolean => [
|
||||
event.change_summary.added_field_ids,
|
||||
event.change_summary.removed_field_ids,
|
||||
event.change_summary.changed_field_ids,
|
||||
].some((fieldIds) => Array.isArray(fieldIds) && fieldIds.length > 0);
|
||||
|
||||
/**
|
||||
* 判断审计摘要是否包含自动建单策略变更(含 before/after)。
|
||||
* @param event - 审计事件
|
||||
*/
|
||||
const hasAutoCreationChange = (event: ShippingOrderSchemaAuditEvent): boolean => {
|
||||
if (event.change_summary.auto_creation_policy_changed === true) return true;
|
||||
const policy = event.change_summary.auto_creation_policy;
|
||||
return Boolean(policy && typeof policy === 'object');
|
||||
};
|
||||
|
||||
/**
|
||||
* 生成「自动建单:关闭 → 开启」业务摘要;无法解析时返回空串。
|
||||
* @param event - 审计事件
|
||||
*/
|
||||
const autoCreationSummary = (event: ShippingOrderSchemaAuditEvent): string => {
|
||||
const raw = event.change_summary.auto_creation_policy;
|
||||
if (!raw || typeof raw !== 'object') return '';
|
||||
const policy = raw as { before?: { enabled?: unknown }; after?: { enabled?: unknown } };
|
||||
const beforeEnabled = policy.before?.enabled === true;
|
||||
const afterEnabled = policy.after?.enabled === true;
|
||||
if (beforeEnabled === afterEnabled && event.change_summary.auto_creation_policy_changed !== true) {
|
||||
return '';
|
||||
}
|
||||
return t('admin.shippingOrderSchema.auditAutoCreationSummary', {
|
||||
before: autoCreationStateLabel(beforeEnabled),
|
||||
after: autoCreationStateLabel(afterEnabled),
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -40,11 +88,22 @@ const hasFieldChanges = (event: ShippingOrderSchemaAuditEvent): boolean => [
|
||||
<strong>{{ eventLabel(event.event_type) }}</strong><span v-if="event.version">V{{ event.version.version }}</span>
|
||||
<p>{{ formatDate(event.created_at) }} · {{ event.actor?.display_name || t('admin.shippingOrderSchema.historyUnknownActor') }}</p>
|
||||
<small v-if="hasFieldChanges(event)">{{ t('admin.shippingOrderSchema.auditFieldSummary', { added: (event.change_summary.added_field_ids as string[] | undefined)?.length || 0, removed: (event.change_summary.removed_field_ids as string[] | undefined)?.length || 0, changed: (event.change_summary.changed_field_ids as string[] | undefined)?.length || 0 }) }}</small>
|
||||
<small v-if="hasAutoCreationChange(event) && autoCreationSummary(event)" class="audit-auto-creation">{{ autoCreationSummary(event) }}</small>
|
||||
</article>
|
||||
<button v-if="events.length < total" type="button" :disabled="loading" @click="emit('loadMore')">{{ loading ? t('common.loading') : t('admin.shippingOrderSchema.auditLoadMore') }}</button>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.audit-timeline { margin-top: 22px; border-top: 1px solid #e5ebf1; padding-top: 18px; }.audit-heading { display: flex; align-items: center; gap: 8px; color: #64748b; font-size: 12px; font-weight: 700; }.audit-heading small { border-radius: 999px; background: #e0f2fe; padding: 2px 7px; color: #0369a1; }.audit-event { position: relative; margin: 10px 0 0 6px; border-left: 2px solid #bae6fd; padding: 0 0 10px 13px; }.audit-event::before { position: absolute; top: 3px; left: -5px; width: 8px; height: 8px; border-radius: 50%; background: #0ea5e9; content: ''; }.audit-event strong { color: #334155; font-size: 12px; }.audit-event > span { margin-left: 6px; color: #0369a1; font-size: 11px; }.audit-event p, .audit-event small { display: block; margin: 4px 0 0; color: #94a3b8; font-size: 11px; }.audit-timeline > button { width: 100%; border: 1px dashed #cbd5e1; border-radius: 7px; background: transparent; padding: 8px; color: #0284c7; font: inherit; font-size: 12px; cursor: pointer; }.audit-empty { color: #94a3b8; font-size: 12px; }
|
||||
.audit-timeline { margin-top: 22px; border-top: 1px solid #e5ebf1; padding-top: 18px; }
|
||||
.audit-heading { display: flex; align-items: center; gap: 8px; color: #64748b; font-size: 12px; font-weight: 700; }
|
||||
.audit-heading small { border-radius: 999px; background: #e0f2fe; padding: 2px 7px; color: #0369a1; }
|
||||
.audit-event { position: relative; margin: 10px 0 0 6px; border-left: 2px solid #bae6fd; padding: 0 0 10px 13px; }
|
||||
.audit-event::before { position: absolute; top: 3px; left: -5px; width: 8px; height: 8px; border-radius: 50%; background: #0ea5e9; content: ''; }
|
||||
.audit-event strong { color: #334155; font-size: 12px; }
|
||||
.audit-event > span { margin-left: 6px; color: #0369a1; font-size: 11px; }
|
||||
.audit-event p, .audit-event small { display: block; margin: 4px 0 0; color: #94a3b8; font-size: 11px; }
|
||||
.audit-auto-creation { color: #0f766e !important; }
|
||||
.audit-timeline > button { width: 100%; border: 1px dashed #cbd5e1; border-radius: 7px; background: transparent; padding: 8px; color: #0284c7; font: inherit; font-size: 12px; cursor: pointer; }
|
||||
.audit-empty { color: #94a3b8; font-size: 12px; }
|
||||
</style>
|
||||
@@ -28,8 +28,8 @@ export interface OrderProfileRelativeRegion { x0: number; y0: number; x1: number
|
||||
export interface OrderProfileAnchorRelativeRegion { x0: number; y0: number; x1: number; y1: number; }
|
||||
export interface OrderProfileAnchorRule { anchor_id: string; text: string; aliases?: string[]; match_mode: 'exact' | 'contains'; region?: OrderProfileRelativeRegion | null; minimum_evidence_level: OrderProfileEvidenceLevel; }
|
||||
export interface OrderProfileFieldRegion { field_id: string; field_code: string; region: OrderProfileRelativeRegion; extractor_key: OrderProfileExtractorKey; allowed_sources: OrderProfileAllowedSource[]; minimum_evidence_level: OrderProfileEvidenceLevel; target_fields?: Array<{ field_id: string; field_code: string }>; }
|
||||
export interface OrderProfileOrderFieldLayout { layout_id: string; field_id: string; field_code: string; page_scope: 'first_page' | 'all_pages' | 'exact_page'; page_no?: number | null; anchor?: OrderProfileAnchorRule | null; value_region?: OrderProfileAnchorRelativeRegion | null; fallback_value_region?: OrderProfileRelativeRegion | null; value_mode: 'single_line' | 'multi_line' | 'right_of_anchor' | 'below_anchor'; stop_anchors: OrderProfileAnchorRule[]; normalizer_key?: string | null; required: boolean; minimum_evidence_level: OrderProfileEvidenceLevel; }
|
||||
export interface OrderProfileDraftUnboundOrderFieldLayout { layout_id: string; label: string; page_scope: 'first_page' | 'all_pages' | 'exact_page'; page_no?: number | null; anchor?: OrderProfileAnchorRule | null; value_region?: OrderProfileAnchorRelativeRegion | null; fallback_value_region?: OrderProfileRelativeRegion | null; value_mode: 'single_line' | 'multi_line' | 'right_of_anchor' | 'below_anchor'; stop_anchors: OrderProfileAnchorRule[]; minimum_evidence_level: OrderProfileEvidenceLevel; }
|
||||
export interface OrderProfileOrderFieldLayout { layout_id: string; field_id: string; field_code: string; page_scope: 'first_page' | 'all_pages' | 'exact_page'; page_no?: number | null; anchor?: OrderProfileAnchorRule | null; value_region?: OrderProfileAnchorRelativeRegion | null; absolute_value_region?: OrderProfileRelativeRegion | null; fallback_value_region?: OrderProfileRelativeRegion | null; value_mode: 'single_line' | 'multi_line' | 'right_of_anchor' | 'below_anchor'; stop_anchors: OrderProfileAnchorRule[]; normalizer_key?: string | null; required: boolean; minimum_evidence_level: OrderProfileEvidenceLevel; }
|
||||
export interface OrderProfileDraftUnboundOrderFieldLayout { layout_id: string; label: string; page_scope: 'first_page' | 'all_pages' | 'exact_page'; page_no?: number | null; anchor?: OrderProfileAnchorRule | null; value_region?: OrderProfileAnchorRelativeRegion | null; absolute_value_region?: OrderProfileRelativeRegion | null; fallback_value_region?: OrderProfileRelativeRegion | null; value_mode: 'single_line' | 'multi_line' | 'right_of_anchor' | 'below_anchor'; stop_anchors: OrderProfileAnchorRule[]; minimum_evidence_level: OrderProfileEvidenceLevel; }
|
||||
export interface OrderProfileHeaderLayout { layout_id: string; region: OrderProfileRelativeRegion; field_regions: OrderProfileFieldRegion[]; }
|
||||
export interface OrderProfileLineLayout { layout_id: string; row_offset: number; role: 'main' | 'continuation'; region: OrderProfileRelativeRegion; field_regions: OrderProfileFieldRegion[]; new_line_anchor?: OrderProfileAnchorRule | null; continuation_conditions: OrderProfileAnchorRule[]; required_fields: string[]; allowed_empty_fields: string[]; }
|
||||
export interface OrderProfileTableRegion { region_id: string; page_scope: 'first_page' | 'all_pages' | 'continuation_pages' | 'exact_page'; page_no?: number | null; region: OrderProfileRelativeRegion; header_layouts: OrderProfileHeaderLayout[]; line_layouts: OrderProfileLineLayout[]; continuation_rule: { allow_cross_page: boolean; required_anchor_ids: string[] }; termination_rules: Array<{ rule_id: string; anchor: OrderProfileAnchorRule }>; exclusion_regions: OrderProfileRelativeRegion[]; draft_unbound_field_regions?: Array<{ region_id: string; parent_layout_id: string; label: string; region: OrderProfileRelativeRegion }>; }
|
||||
|
||||
@@ -259,36 +259,3 @@ export interface ShippingOrderSchemaState {
|
||||
}>;
|
||||
}>;
|
||||
}
|
||||
|
||||
/** 受控货代履约能力及其版本化字段绑定。 */
|
||||
export interface ShippingFulfillmentCapability {
|
||||
capability_code: string;
|
||||
scope: ShippingOrderField['scope'];
|
||||
value_type: ShippingOrderField['value_type'];
|
||||
required: boolean;
|
||||
}
|
||||
|
||||
export interface ShippingFulfillmentPolicyBinding {
|
||||
capability_code: string;
|
||||
field_id: string;
|
||||
field_code: string;
|
||||
scope: ShippingOrderField['scope'];
|
||||
value_type: ShippingOrderField['value_type'];
|
||||
}
|
||||
|
||||
export interface ShippingFulfillmentPolicy {
|
||||
id: number;
|
||||
policy_code: 'SHIP_AVAILABLE_ROLLING_V1';
|
||||
version: number;
|
||||
status: 'draft' | 'published' | 'retired';
|
||||
definition: { field_bindings: ShippingFulfillmentPolicyBinding[] };
|
||||
checksum: string | null;
|
||||
lock_version: number;
|
||||
change_note: string | null;
|
||||
published_at: string | null;
|
||||
}
|
||||
|
||||
export interface ShippingFulfillmentPolicyState {
|
||||
capabilities: ShippingFulfillmentCapability[];
|
||||
policies: ShippingFulfillmentPolicy[];
|
||||
}
|
||||
@@ -146,6 +146,11 @@ export interface ShippingTaskSummary {
|
||||
export interface ShippingTaskEvent {
|
||||
event_type: string;
|
||||
detail_json?: Record<string, unknown> | null;
|
||||
actor_id?: number | null;
|
||||
request_id?: string | null;
|
||||
source?: string | null;
|
||||
before_json?: Record<string, unknown> | null;
|
||||
after_json?: Record<string, unknown> | null;
|
||||
created_at?: string | null;
|
||||
}
|
||||
|
||||
@@ -602,7 +607,7 @@ export interface ShippingNoticeLayoutSummary {
|
||||
}
|
||||
|
||||
export interface ShippingInventoryVerificationLine {
|
||||
reservation_id: number;
|
||||
reservation_id: string;
|
||||
required_qty: string;
|
||||
available_qty: string;
|
||||
status: 'available' | 'shortage' | 'invalid' | string;
|
||||
@@ -624,7 +629,7 @@ export interface ShippingExportArtifact {
|
||||
file_name: string;
|
||||
file_size: number;
|
||||
created_at?: string | null;
|
||||
reservation_ids: number[];
|
||||
reservation_ids: string[];
|
||||
}
|
||||
|
||||
export interface ShippingUploadAttempt {
|
||||
|
||||
@@ -29,7 +29,10 @@ defineProps<{
|
||||
<div class="flex flex-wrap gap-x-3 gap-y-1 text-xs">
|
||||
<span class="font-medium text-secondary">{{ event.event_type }}</span>
|
||||
<span class="text-muted">{{ formatLocalDateTime(event.created_at) }}</span>
|
||||
<span v-if="event.actor_id" class="text-muted">{{ $t('workspace.shippingNotice.operator', { id: event.actor_id }) }}</span>
|
||||
</div>
|
||||
<pre v-if="event.detail_json && Object.keys(event.detail_json).length" class="mt-1 whitespace-pre-wrap break-words text-xs text-muted">{{ JSON.stringify(event.detail_json, null, 2) }}</pre>
|
||||
<pre v-if="event.before_json || event.after_json" class="mt-1 whitespace-pre-wrap break-words text-xs text-muted">{{ JSON.stringify({ before: event.before_json, after: event.after_json }, null, 2) }}</pre>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -274,6 +274,7 @@
|
||||
"auditEmpty": "No configuration audit events",
|
||||
"auditLoadMore": "Load more audit events",
|
||||
"auditFieldSummary": "Added {added}, removed {removed}, changed {changed} fields",
|
||||
"auditAutoCreationSummary": "Automatic task creation: {before} → {after}",
|
||||
"auditEvent": {
|
||||
"draft_created": "Created draft",
|
||||
"draft_saved": "Saved draft",
|
||||
@@ -2687,6 +2688,7 @@
|
||||
"orderProfileValidation": {
|
||||
"eyebrow": "DRAFT VALIDATION",
|
||||
"title": "Validate Order Document Profile",
|
||||
"validateTemplate": "Validate template",
|
||||
"description": "Run summaries exclude PDFs, object-storage addresses, and blind-test ground truth. Historical runs become stale after a draft change.",
|
||||
"backToEditor": "Back to editor",
|
||||
"instantCheck": "Run instant check",
|
||||
@@ -2699,13 +2701,15 @@
|
||||
"time": "Created",
|
||||
"empty": "No validation runs yet.",
|
||||
"completed": "Validation run completed.",
|
||||
"failed": "Validation run failed."
|
||||
"failed": "Validation run failed.",
|
||||
"currentDraft": "Current draft validation", "currentDraftHint": "The system checks the configuration and reads the current sample once.", "validateCurrent": "Validate current draft", "validating": "Validating...", "goPublishCheck": "Continue to publish check", "structureCheck": "Configuration check", "structureCheckHint": "Checks bindings, page coordinates, scopes, and line structure.", "sampleCheck": "Current sample read", "sampleCheckHint": "Checks whether the annotated sample returns fields and line items.",
|
||||
"state": { "ready": "Current draft can enter publish check", "stale": "Configuration changed; validate again", "failed": "Validation failed; return to the editor", "pending": "Current draft has not been validated" }, "stateHint": { "ready": "Both configuration and sample checks passed.", "stale": "Historical validation belongs to an earlier draft and cannot publish.", "failed": "Fix the annotations and validate again.", "pending": "Save the annotations, then validate once." }, "runStatus": { "passed": "Passed", "failed": "Failed", "stale": "Stale", "pending": "Not run", "running": "Running" }, "resultsTitle": "Current sample results", "resultsHint": "Only reads from the current draft and current annotations. Deleted lines are shown for review only and are excluded from the order result.", "refreshResults": "Read again", "resultsLoading": "Reading current sample...", "resultsFailed": "No value was read or the read failed. Check the annotations in the editor.", "headerResults": "Order header", "lineResults": "Order lines", "noHeaderResults": "No order header fields were read from the current sample.", "noLineResults": "No order lines were read from the current sample.", "noValue": "No value read", "rowStatus": "Status", "deleted": "Deleted; excluded", "read": "Read"
|
||||
},
|
||||
"orderProfilePublishCheck": {
|
||||
"eyebrow": "PUBLISH GATE",
|
||||
"title": "Confirm Order Document Profile Publication",
|
||||
"description": "The report freezes the draft version and becomes invalid when the draft changes.",
|
||||
"back": "Back",
|
||||
"back": "Back to validation",
|
||||
"selectRun": "Select a passing validation run",
|
||||
"noRun": "The current draft has no passing validation run for publication.",
|
||||
"create": "Create publish-check report",
|
||||
@@ -2715,7 +2719,7 @@
|
||||
"noBlocking": "No blocking items.",
|
||||
"warnings": "Warnings (confirm each item)",
|
||||
"confirm": "Confirm publication",
|
||||
"failed": "Publish check failed."
|
||||
"failed": "Publish check failed.", "readyTitle": "Validated draft", "readyHint": "The current-sample validation passed. Generate a check to review prerequisites and changes.", "reportTitle": "Publish check result", "blockedHint": "These issues must be fixed and cannot be acknowledged away.", "reviewHint": "Confirm all listed changes to publish this template version.", "confirmHint": "Confirm that you reviewed the changes above.", "currentValidationRequired": "The current draft must pass current-sample validation first.", "semanticDiffReview": "This version has semantic changes. Confirm that you reviewed them.", "unknownIssue": "The publish check found an issue that needs attention."
|
||||
},
|
||||
"shippingOrderProfiles": {
|
||||
"title": "Order Document Profiles",
|
||||
@@ -2737,10 +2741,10 @@
|
||||
"wizard": {
|
||||
"title": "Create order document template",
|
||||
"steps": "Step {step} of 3",
|
||||
"description": "Define the template, then choose a sample for annotation.",
|
||||
"description": "Define the template, then choose the first modelling and training sample for annotation.",
|
||||
"stepLabel": "Step {step}",
|
||||
"identityStep": "Basics",
|
||||
"sampleStep": "Choose sample",
|
||||
"sampleStep": "Choose modelling sample",
|
||||
"tableStep": "Choose order line table",
|
||||
"namePlaceholder": "For example: ACME purchase order",
|
||||
"systemCodeHint": "The system creates an immutable code after creation for versions, routing, and audit.",
|
||||
@@ -2762,7 +2766,7 @@
|
||||
"incomplete": "Complete the required fields before continuing.",
|
||||
"loadFailed": "Failed to load wizard options.",
|
||||
"uploadFailed": "Failed to upload the template sample.",
|
||||
"sampleHint": "Uploading or selecting a sample does not create a template.",
|
||||
"sampleHint": "Uploading or selecting a sample does not create a template; once created, it becomes both annotation and training evidence.",
|
||||
"tableLoadFailed": "Failed to load sample tables.",
|
||||
"tableOption": "Page {page} · {rows} rows · {columns} columns",
|
||||
"orderLineTable": "Order line table",
|
||||
@@ -2878,6 +2882,7 @@
|
||||
"continueEditing": "Continue editing",
|
||||
"viewVersion": "View version",
|
||||
"familyVersions": "Version navigation",
|
||||
"technicalDetails": "Technical details",
|
||||
"loading": "Loading version detail...",
|
||||
"tabsLabel": "Profile version detail tabs",
|
||||
"tabs": {
|
||||
@@ -3056,9 +3061,12 @@
|
||||
"sampleSummaryTitle": "Sample summary",
|
||||
"annotationCount": "Annotation samples",
|
||||
"trainingCount": "Training samples",
|
||||
"blindTestCount": "Blind-test samples",
|
||||
"boundBlindTestCount": "Bound blind-test samples",
|
||||
"firstSample": "First sample",
|
||||
"testSummaryTitle": "Test summary",
|
||||
"testSummaryTitle": "Blind-test suite",
|
||||
"blindTestSuiteSampleCount": "Blind-test suite samples",
|
||||
"serviceUnavailable": "The service is temporarily unavailable. Confirm the local backend is running, then try again.",
|
||||
"retry": "Reload",
|
||||
"approvedAt": "Approved at",
|
||||
"latestRun": "Latest run",
|
||||
"sourceVersionTitle": "Source version",
|
||||
@@ -3101,10 +3109,17 @@
|
||||
"noCandidateRows": "No valid item was detected. Check the physical lines, line_no, and field regions.",
|
||||
"blindTest": {
|
||||
"title": "Blind test",
|
||||
"gateTitle": "Pre-publish blind test",
|
||||
"gateRequiredHint": "Complete and approve an independent blind test before entering the publish check.",
|
||||
"gateApprovedHint": "The blind test for this draft is approved; you can enter the publish check.",
|
||||
"status": { "missing": "Not created", "draft": "Action required", "approved": "Approved", "superseded": "Superseded" },
|
||||
"samples": "Samples: {count} · {status}",
|
||||
"notRun": "not run",
|
||||
"approvedHint": "This blind test is approved; no further run or approval is needed.",
|
||||
"selectIndependentSample": "Select independent sample",
|
||||
"loadIndependentSamples": "Load available samples",
|
||||
"loadingIndependentSamples": "Loading available samples…",
|
||||
"loadIndependentSamplesHint": "Load candidates only when adding a blind-test sample, so opening this page does not wait for historical-sample scanning.",
|
||||
"selectSamplePlaceholder": "Select an order not used to annotate this template",
|
||||
"noIndependentSamples": "No independent sample is available. Upload and parse another matching order first.",
|
||||
"reviewHint": "Mark every item correct or incorrect. Provide a correction for incorrect items; unreviewed items cannot be added.",
|
||||
@@ -3123,32 +3138,44 @@
|
||||
"expectedOrderFieldsInvalid": "Order field truth must be a JSON object.",
|
||||
"trainingAdded": "Current training sample bound",
|
||||
"addTrainingSample": "Add training sample",
|
||||
"trainingRequired": "Before approval, add the current annotation sample as a training sample in the editor.",
|
||||
"goToEditor": "Return to editor to bind training sample",
|
||||
"addedSamples": "Added blind-test samples",
|
||||
"addedSamplesHint": "Draft samples can be removed; approved samples remain auditable.",
|
||||
"removeSample": "Remove sample",
|
||||
"sampleRemoved": "Blind-test sample removed",
|
||||
"addCurrentSample": "Add current blind sample",
|
||||
"backToValidation": "Back to validation",
|
||||
"goPublishCheck": "Go to publish check",
|
||||
"latestResult": "Latest run: {status} ({passed}/{count} passed)",
|
||||
"candidateRowsEmpty": "This sample produced no line items and cannot become blind-test truth.",
|
||||
"correctedValue": "Enter human-corrected value",
|
||||
"execution": "Run and approve",
|
||||
"runHint": "Run reparses every blind-test sample with the current draft; all samples must pass before approval.",
|
||||
"unknownSample": "Unknown sample",
|
||||
"failure": { "title": "Execution failure details", "hint": "Use the reason to adjust annotations or reconfirm blind-test truth, then run again.", "fieldMismatch": "{sample}: the reread value for order field {field} differs from the human truth.", "fieldNeedsReview": "{sample}: order field {field} is not confirmed; check its anchor and coordinate range.", "fieldUnavailable": "{sample}: no usable value was read for order field {field}; check its anchor, page, and coordinate evidence.", "coordinateEvidenceMissing": "{sample}: table or page coordinate evidence is missing, so the blind test cannot run.", "rowsMismatch": "{sample}: reread order lines differ from the human truth.", "unknown": "{sample}: the blind test did not pass; check the raw diagnostic code below." },
|
||||
"run": "Run",
|
||||
"approve": "Approve"
|
||||
},
|
||||
"workbench": {
|
||||
"boundHistoricalSchema": "bound historical version",
|
||||
"intro": "Drag evidence regions on a controlled document page; saved definitions contain no HTML or storage URL.",
|
||||
"intro": "Drag evidence regions on a controlled document page; saved definitions contain no HTML or storage URL.", "returnToLibrary": "Back to document templates",
|
||||
"structure": "Structure",
|
||||
"saveStatus": {
|
||||
"saved": "Saved",
|
||||
"saving": "Saving",
|
||||
"failed": "Save failed; local edits are retained",
|
||||
"readonly": "Read-only: edit lease expired"
|
||||
"readonly": "Read-only: edit lease unavailable"
|
||||
},
|
||||
"exportLocalDraft": "Export local draft",
|
||||
"recoverLease": "Reacquire lease",
|
||||
"takeOverLease": "Take over lease",
|
||||
"invalidDefinitionPath": "Template configuration is invalid: {path}",
|
||||
"suggestionReadyForDecision": "Suggestion is ready for a decision",
|
||||
"acceptSuggestion": "Accept",
|
||||
"acceptAdjustedSuggestion": "Accept with adjustments",
|
||||
"rejectSuggestion": "Reject",
|
||||
"suggestionAdjustmentField": "Choose replacement field",
|
||||
"suggestionAdjustmentField": "Choose replacement field", "sampleValueUnavailable": "No value read", "orderFieldValueReading": "Reading", "orderFieldValueFailed": "Read failed", "currentSampleValue": "Current sample value", "selectedRegion": "Selected annotation", "recognitionResults": "Recognition results", "orderHeaderResults": "Order header fields", "orderLineResults": "Order line fields", "noRecognitionResults": "No structured result available", "lineResultField": "Line {row} · {field}", "previewState": { "idle": "Waiting", "updating": "Reading", "ready": "Updated", "failed": "Read failed" }, "evidenceStatus": { "read": "Read", "review": "Needs review", "loading": "Reading", "failed": "Read failed", "deleted": "Deleted; excluded from results", "unavailable": "No value read" },
|
||||
"openCanvas": "Create draft and open canvas",
|
||||
"loadingPage": "Loading page...",
|
||||
"canvasZoom": "Page zoom",
|
||||
@@ -3164,7 +3191,7 @@
|
||||
"autoSuggestOcr": "Coordinates are missing; generating OCR coordinate evidence...",
|
||||
"autoSuggestAnalyzing": "Analyzing physical rows and column boundaries...",
|
||||
"autoSuggestApplying": "Generating review markers...",
|
||||
"autoSuggestComplete": "Auto-marking completed. Review the results.",
|
||||
"autoSuggestComplete": "Suggestion generated; it has not been saved.",
|
||||
"autoSuggestNoRows": "No item rows were detected for marking.",
|
||||
"autoSuggestFailed": "Auto-marking failed. See the reason below.",
|
||||
"schemaCompatible": "Field-compatible; can be inherited automatically",
|
||||
@@ -3350,6 +3377,33 @@
|
||||
"auditSnapshot": "Change snapshot",
|
||||
"auditSnapshotRaw": "Raw JSON snapshot",
|
||||
"auditDiffEmpty": "No property-level differences",
|
||||
"auditValueNull": "null",
|
||||
"auditValueYes": "Yes",
|
||||
"auditValueNo": "No",
|
||||
"auditValueEmpty": "(empty)",
|
||||
"auditValueEmptyList": "(empty list)",
|
||||
"auditValueObjectList": "{count} items",
|
||||
"auditArrayLength": "{path} count",
|
||||
"auditProperty": {
|
||||
"field_code": "Field code",
|
||||
"display_name": "Display name",
|
||||
"display_name_default": "Default display name",
|
||||
"semantic_description": "Semantic description",
|
||||
"status": "Status",
|
||||
"scope": "Scope",
|
||||
"value_type": "Type",
|
||||
"asset_kind": "Asset kind",
|
||||
"storage_mode": "Storage mode",
|
||||
"storage_column": "Storage column",
|
||||
"storage_path": "Storage path",
|
||||
"retired_reason": "Retirement reason",
|
||||
"reason": "Reason",
|
||||
"action": "Action",
|
||||
"blocking_count": "Blocking references",
|
||||
"updated_at": "Updated at",
|
||||
"created_at": "Created at",
|
||||
"display_sequence": "Catalog sequence"
|
||||
},
|
||||
"auditEvent": {
|
||||
"field_adopted": "Field adopted in Schema",
|
||||
"field_unadopted": "Field un-adopted in Schema",
|
||||
|
||||
@@ -278,6 +278,7 @@
|
||||
"sku": "SKU"
|
||||
},
|
||||
"events": "Event log",
|
||||
"operator": "Operator ID: {id}",
|
||||
"filters": {
|
||||
"status": "Status",
|
||||
"lifecycle": "Task state"
|
||||
|
||||
@@ -273,6 +273,7 @@
|
||||
"auditEmpty": "ยังไม่มีเหตุการณ์ตรวจสอบการตั้งค่า",
|
||||
"auditLoadMore": "โหลดเหตุการณ์ตรวจสอบเพิ่มเติม",
|
||||
"auditFieldSummary": "เพิ่ม {added}, ลบ {removed}, แก้ไข {changed} ฟิลด์",
|
||||
"auditAutoCreationSummary": "สร้างงานอัตโนมัติ: {before} → {after}",
|
||||
"auditEvent": {
|
||||
"draft_created": "สร้างฉบับร่าง",
|
||||
"draft_saved": "บันทึกฉบับร่าง",
|
||||
@@ -2555,6 +2556,7 @@
|
||||
"orderProfileValidation": {
|
||||
"eyebrow": "การตรวจสอบฉบับร่าง",
|
||||
"title": "ตรวจสอบโปรไฟล์เอกสารคำสั่งซื้อ",
|
||||
"validateTemplate": "ตรวจสอบเทมเพลต",
|
||||
"description": "สรุปผลไม่รวม PDF ที่อยู่ object storage หรือข้อมูลจริงของ blind test และผลเก่าจะล้าสมัยเมื่อร่างเปลี่ยนแปลง",
|
||||
"backToEditor": "กลับไปยังตัวแก้ไข",
|
||||
"instantCheck": "เรียกใช้การตรวจสอบทันที",
|
||||
@@ -2567,13 +2569,13 @@
|
||||
"time": "เวลาสร้าง",
|
||||
"empty": "ยังไม่มีผลการตรวจสอบ",
|
||||
"completed": "ตรวจสอบเสร็จแล้ว",
|
||||
"failed": "ตรวจสอบล้มเหลว"
|
||||
"failed": "ตรวจสอบล้มเหลว", "currentDraft": "ตรวจสอบฉบับร่างปัจจุบัน", "currentDraftHint": "ระบบจะตรวจการตั้งค่าและอ่านตัวอย่างปัจจุบันหนึ่งครั้ง", "validateCurrent": "ตรวจสอบฉบับร่างปัจจุบัน", "validating": "กำลังตรวจสอบ…", "goPublishCheck": "ไปยังการตรวจสอบก่อนเผยแพร่", "structureCheck": "ตรวจสอบการตั้งค่า", "structureCheckHint": "ตรวจการผูกฟิลด์ พิกัดหน้า ขอบเขต และโครงสร้างรายการ", "sampleCheck": "อ่านตัวอย่างปัจจุบัน", "sampleCheckHint": "ตรวจว่าตัวอย่างที่ทำเครื่องหมายอ่านฟิลด์และรายการได้หรือไม่", "state": { "ready": "ฉบับร่างปัจจุบันพร้อมตรวจสอบก่อนเผยแพร่", "stale": "การตั้งค่าเปลี่ยนแล้ว โปรดตรวจสอบอีกครั้ง", "failed": "ตรวจสอบไม่ผ่าน โปรดกลับไปแก้ไข", "pending": "ยังไม่ได้ตรวจสอบฉบับร่างปัจจุบัน" }, "stateHint": { "ready": "การตรวจการตั้งค่าและตัวอย่างผ่านแล้ว", "stale": "ผลเก่าเป็นของฉบับร่างก่อนหน้าและใช้เผยแพร่ไม่ได้", "failed": "แก้ไขเครื่องหมายแล้วตรวจสอบอีกครั้ง", "pending": "บันทึกเครื่องหมายแล้วจึงตรวจสอบ" }, "runStatus": { "passed": "ผ่าน", "failed": "ไม่ผ่าน", "stale": "ล้าสมัย", "pending": "ยังไม่ทำ", "running": "กำลังตรวจสอบ" }, "resultsTitle": "ผลการอ่านตัวอย่างปัจจุบัน", "resultsHint": "แสดงเฉพาะผลที่อ่านแบบเรียลไทม์จากฉบับร่างและการทำเครื่องหมายปัจจุบัน แถวที่ลบมีไว้ตรวจสอบและจะไม่เข้าผลลัพธ์คำสั่งซื้อ", "refreshResults": "อ่านอีกครั้ง", "resultsLoading": "กำลังอ่านตัวอย่างปัจจุบัน...", "resultsFailed": "ไม่พบค่าหรืออ่านล้มเหลว โปรดตรวจสอบการทำเครื่องหมายในตัวแก้ไข", "headerResults": "ส่วนหัวคำสั่งซื้อ", "lineResults": "รายการคำสั่งซื้อ", "noHeaderResults": "ไม่พบฟิลด์ส่วนหัวจากตัวอย่างปัจจุบัน", "noLineResults": "ไม่พบรายการจากตัวอย่างปัจจุบัน", "noValue": "ไม่พบค่า", "rowStatus": "สถานะ", "deleted": "ลบแล้ว ไม่นับผล", "read": "อ่านแล้ว"
|
||||
},
|
||||
"orderProfilePublishCheck": {
|
||||
"eyebrow": "ด่านเผยแพร่",
|
||||
"title": "ยืนยันการเผยแพร่โปรไฟล์เอกสารคำสั่งซื้อ",
|
||||
"description": "รายงานจะตรึงรุ่นฉบับร่างและจะใช้งานไม่ได้เมื่อฉบับร่างเปลี่ยน",
|
||||
"back": "กลับ",
|
||||
"back": "กลับไปตรวจสอบ",
|
||||
"selectRun": "เลือกผลตรวจสอบที่ผ่าน",
|
||||
"noRun": "ฉบับร่างปัจจุบันไม่มีผลตรวจสอบที่ผ่านสำหรับการเผยแพร่",
|
||||
"create": "สร้างรายงานตรวจสอบการเผยแพร่",
|
||||
@@ -2583,7 +2585,7 @@
|
||||
"noBlocking": "ไม่มีรายการที่ขัดขวาง",
|
||||
"warnings": "คำเตือน (ยืนยันแต่ละรายการ)",
|
||||
"confirm": "ยืนยันการเผยแพร่",
|
||||
"failed": "ตรวจสอบการเผยแพร่ล้มเหลว"
|
||||
"failed": "ตรวจสอบการเผยแพร่ล้มเหลว", "readyTitle": "ฉบับร่างที่ตรวจสอบแล้ว", "readyHint": "การตรวจตัวอย่างปัจจุบันผ่านแล้ว สร้างรายงานเพื่อตรวจเงื่อนไขและการเปลี่ยนแปลง", "reportTitle": "ผลการตรวจสอบก่อนเผยแพร่", "blockedHint": "ต้องแก้ปัญหาเหล่านี้ ไม่สามารถยืนยันเพื่อข้ามได้", "reviewHint": "ยืนยันการเปลี่ยนแปลงที่แสดงทั้งหมดเพื่อเผยแพร่รุ่นนี้", "confirmHint": "โปรดยืนยันว่าได้ตรวจสอบการเปลี่ยนแปลงข้างต้นแล้ว", "currentValidationRequired": "ฉบับร่างปัจจุบันต้องผ่านการตรวจตัวอย่างก่อน", "semanticDiffReview": "รุ่นนี้มีความแตกต่างเชิงความหมาย โปรดยืนยันว่าได้ตรวจสอบแล้ว", "unknownIssue": "การตรวจสอบก่อนเผยแพร่พบปัญหาที่ต้องจัดการ"
|
||||
},
|
||||
"shippingOrderProfiles": {
|
||||
"title": "โปรไฟล์เอกสารคำสั่งซื้อ",
|
||||
@@ -2605,10 +2607,10 @@
|
||||
"wizard": {
|
||||
"title": "สร้างเทมเพลตเอกสารคำสั่งซื้อ",
|
||||
"steps": "ขั้นตอน {step} จาก 3",
|
||||
"description": "กำหนดเทมเพลตก่อน แล้วเลือกตัวอย่างเพื่อเริ่มทำคำอธิบายประกอบ",
|
||||
"description": "กำหนดเทมเพลตก่อน แล้วเลือกตัวอย่างแรกสำหรับการสร้างแบบจำลองและการฝึกเพื่อเริ่มทำคำอธิบายประกอบ",
|
||||
"stepLabel": "ขั้นตอน {step}",
|
||||
"identityStep": "ข้อมูลพื้นฐาน",
|
||||
"sampleStep": "เลือกตัวอย่าง",
|
||||
"sampleStep": "เลือกตัวอย่างสำหรับการสร้างแบบจำลอง",
|
||||
"tableStep": "เลือกตารางรายการสั่งซื้อ",
|
||||
"namePlaceholder": "ตัวอย่าง: ใบสั่งซื้อ ACME",
|
||||
"systemCodeHint": "ระบบจะสร้างรหัสถาวรหลังสร้าง เพื่อใช้กับเวอร์ชัน routing และการตรวจสอบ",
|
||||
@@ -2630,7 +2632,7 @@
|
||||
"incomplete": "กรอกข้อมูลที่จำเป็นก่อนดำเนินการ",
|
||||
"loadFailed": "โหลดตัวเลือกตัวช่วยสร้างไม่สำเร็จ",
|
||||
"uploadFailed": "อัปโหลดตัวอย่างเทมเพลตไม่สำเร็จ",
|
||||
"sampleHint": "การอัปโหลดหรือเลือกตัวอย่างจะไม่สร้างเทมเพลต",
|
||||
"sampleHint": "การอัปโหลดหรือเลือกตัวอย่างจะไม่สร้างเทมเพลต; เมื่อสร้างแล้ว ตัวอย่างนี้จะเป็นหลักฐานทั้งการทำคำอธิบายประกอบและการฝึก",
|
||||
"tableLoadFailed": "โหลดตารางตัวอย่างไม่สำเร็จ",
|
||||
"tableOption": "หน้า {page} · {rows} แถว · {columns} คอลัมน์",
|
||||
"orderLineTable": "ตารางรายการสั่งซื้อ",
|
||||
@@ -2746,6 +2748,7 @@
|
||||
"continueEditing": "แก้ไขต่อ",
|
||||
"viewVersion": "ดูเวอร์ชัน",
|
||||
"familyVersions": "การนำทางเวอร์ชัน",
|
||||
"technicalDetails": "ข้อมูลทางเทคนิค",
|
||||
"loading": "กำลังโหลดรายละเอียดเวอร์ชัน...",
|
||||
"tabsLabel": "แท็บรายละเอียดเวอร์ชันเทมเพลต",
|
||||
"tabs": {
|
||||
@@ -2924,9 +2927,12 @@
|
||||
"sampleSummaryTitle": "สรุปตัวอย่าง",
|
||||
"annotationCount": "ตัวอย่างการทำเครื่องหมาย",
|
||||
"trainingCount": "ตัวอย่างการฝึก",
|
||||
"blindTestCount": "ตัวอย่างทดสอบแบบปิดบัง",
|
||||
"boundBlindTestCount": "ตัวอย่าง blind test ที่ผูกไว้",
|
||||
"firstSample": "ตัวอย่างแรก",
|
||||
"testSummaryTitle": "สรุปการทดสอบ",
|
||||
"testSummaryTitle": "ชุด blind test",
|
||||
"blindTestSuiteSampleCount": "ตัวอย่างในชุด blind test",
|
||||
"serviceUnavailable": "บริการไม่พร้อมใช้งานชั่วคราว โปรดยืนยันว่า backend ภายในเครื่องทำงานอยู่แล้วลองใหม่อีกครั้ง",
|
||||
"retry": "โหลดใหม่",
|
||||
"approvedAt": "เวลาอนุมัติ",
|
||||
"latestRun": "การรันล่าสุด",
|
||||
"sourceVersionTitle": "เวอร์ชันต้นทาง",
|
||||
@@ -2969,10 +2975,17 @@
|
||||
"noCandidateRows": "ไม่พบรายการที่ถูกต้อง โปรดตรวจสอบแถวจริง line_no และขอบเขตฟิลด์",
|
||||
"blindTest": {
|
||||
"title": "การทดสอบแบบปิดบัง",
|
||||
"gateTitle": "การทดสอบแบบปิดบังก่อนเผยแพร่",
|
||||
"gateRequiredHint": "ต้องทำและอนุมัติการทดสอบแบบปิดบังด้วยตัวอย่างอิสระก่อนเข้าสู่การตรวจสอบก่อนเผยแพร่",
|
||||
"gateApprovedHint": "การทดสอบแบบปิดบังของฉบับร่างนี้ได้รับอนุมัติแล้ว สามารถเข้าสู่การตรวจสอบก่อนเผยแพร่ได้",
|
||||
"status": { "missing": "ยังไม่ได้สร้าง", "draft": "ต้องดำเนินการ", "approved": "อนุมัติแล้ว", "superseded": "หมดอายุแล้ว" },
|
||||
"samples": "ตัวอย่าง: {count} · {status}",
|
||||
"notRun": "ยังไม่ดำเนินการ",
|
||||
"approvedHint": "การทดสอบแบบปิดบังนี้ได้รับอนุมัติแล้ว ไม่ต้องดำเนินการหรืออนุมัติซ้ำ",
|
||||
"selectIndependentSample": "เลือกตัวอย่างอิสระ",
|
||||
"loadIndependentSamples": "โหลดตัวอย่างที่ใช้ได้",
|
||||
"loadingIndependentSamples": "กำลังโหลดตัวอย่างที่ใช้ได้…",
|
||||
"loadIndependentSamplesHint": "โหลดตัวเลือกเมื่อต้องเพิ่มตัวอย่างทดสอบเท่านั้น เพื่อไม่ให้การเปิดหน้านี้ต้องรอการสแกนตัวอย่างเดิมทั้งหมด",
|
||||
"selectSamplePlaceholder": "เลือกคำสั่งซื้อที่ไม่ได้ใช้ทำเครื่องหมายเทมเพลตนี้",
|
||||
"noIndependentSamples": "ไม่มีตัวอย่างอิสระ โปรดอัปโหลดและแยกข้อมูลคำสั่งซื้อประเภทเดียวกันอีกฉบับก่อน",
|
||||
"reviewHint": "ทำเครื่องหมายแต่ละรายการว่าถูกต้องหรือผิดพลาด หากผิดพลาดต้องระบุค่าที่แก้ไข รายการที่ยังไม่ตรวจทานจะเพิ่มไม่ได้",
|
||||
@@ -2991,32 +3004,44 @@
|
||||
"expectedOrderFieldsInvalid": "ข้อมูลจริงของฟิลด์คำสั่งซื้อต้องเป็นออบเจ็กต์ JSON.",
|
||||
"trainingAdded": "ผูกตัวอย่างการฝึกปัจจุบันแล้ว",
|
||||
"addTrainingSample": "เพิ่มตัวอย่างการฝึก",
|
||||
"trainingRequired": "ก่อนอนุมัติ โปรดเพิ่มตัวอย่างคำอธิบายประกอบปัจจุบันเป็นตัวอย่างการฝึกในตัวแก้ไข",
|
||||
"goToEditor": "กลับไปผูกตัวอย่างการฝึกในตัวแก้ไข",
|
||||
"addedSamples": "ตัวอย่างการทดสอบที่เพิ่มแล้ว",
|
||||
"addedSamplesHint": "ลบได้ในฉบับร่าง; หลังอนุมัติจะเก็บบันทึกการตรวจสอบไว้",
|
||||
"removeSample": "ลบตัวอย่าง",
|
||||
"sampleRemoved": "ลบตัวอย่างการทดสอบแล้ว",
|
||||
"addCurrentSample": "เพิ่มตัวอย่างทดสอบปัจจุบัน",
|
||||
"backToValidation": "กลับไปตรวจสอบ",
|
||||
"goPublishCheck": "ไปยังการตรวจสอบก่อนเผยแพร่",
|
||||
"latestResult": "ผลการรันล่าสุด: {status} ({passed}/{count} ผ่าน)",
|
||||
"candidateRowsEmpty": "ตัวอย่างนี้ไม่พบรายการ จึงใช้เป็นข้อมูลจริงของการทดสอบแบบปิดบังไม่ได้",
|
||||
"correctedValue": "กรอกค่าที่แก้ไขโดยผู้ตรวจ",
|
||||
"execution": "ดำเนินการและอนุมัติ",
|
||||
"runHint": "การดำเนินการจะวิเคราะห์ตัวอย่างทดสอบทั้งหมดด้วยฉบับร่างปัจจุบันใหม่ และต้องผ่านทั้งหมดจึงอนุมัติได้",
|
||||
"unknownSample": "ตัวอย่างที่ไม่ทราบ",
|
||||
"failure": { "title": "รายละเอียดการดำเนินการที่ล้มเหลว", "hint": "ใช้เหตุผลเพื่อปรับคำอธิบายประกอบหรือยืนยันข้อมูลจริงของการทดสอบใหม่ แล้วดำเนินการอีกครั้ง", "fieldMismatch": "{sample}: ค่าที่อ่านใหม่ของฟิลด์คำสั่งซื้อ {field} ไม่ตรงกับข้อมูลจริงที่ยืนยันโดยคน", "fieldNeedsReview": "{sample}: ฟิลด์คำสั่งซื้อ {field} ยังไม่อยู่ในสถานะยืนยัน โปรดตรวจจุดยึดและช่วงพิกัด", "fieldUnavailable": "{sample}: ไม่พบค่าที่ใช้ได้ของฟิลด์คำสั่งซื้อ {field} โปรดตรวจจุดยึด หน้าเอกสาร และหลักฐานพิกัด", "coordinateEvidenceMissing": "{sample}: ไม่มีหลักฐานพิกัดของตารางหรือหน้า จึงดำเนินการทดสอบไม่ได้", "rowsMismatch": "{sample}: รายการคำสั่งซื้อที่อ่านใหม่ไม่ตรงกับข้อมูลจริงที่ยืนยันโดยคน", "unknown": "{sample}: การทดสอบแบบปิดบังไม่ผ่าน โปรดตรวจรหัสวินิจฉัยด้านล่าง" },
|
||||
"run": "ดำเนินการ",
|
||||
"approve": "อนุมัติ"
|
||||
},
|
||||
"workbench": {
|
||||
"boundHistoricalSchema": "เวอร์ชันประวัติที่ผูกไว้",
|
||||
"intro": "ลากพื้นที่หลักฐานบนหน้าเอกสารที่ควบคุมไว้ คำนิยามที่บันทึกไม่มี HTML หรือ URL ที่เก็บข้อมูล",
|
||||
"intro": "ลากพื้นที่หลักฐานบนหน้าเอกสารที่ควบคุมไว้ คำนิยามที่บันทึกไม่มี HTML หรือ URL ที่เก็บข้อมูล", "returnToLibrary": "กลับไปยังเทมเพลตเอกสาร",
|
||||
"structure": "โครงสร้าง",
|
||||
"saveStatus": {
|
||||
"saved": "บันทึกแล้ว",
|
||||
"saving": "กำลังบันทึก",
|
||||
"failed": "บันทึกล้มเหลว แต่การแก้ไขในเครื่องยังคงอยู่",
|
||||
"readonly": "อ่านอย่างเดียว: สัญญาเช่าแก้ไขหมดอายุ"
|
||||
"readonly": "อ่านอย่างเดียว: สัญญาเช่าแก้ไขไม่พร้อมใช้งาน"
|
||||
},
|
||||
"exportLocalDraft": "ส่งออกฉบับร่างในเครื่อง",
|
||||
"recoverLease": "รับสัญญาเช่าใหม่",
|
||||
"takeOverLease": "ยืนยันรับช่วงสัญญาเช่า",
|
||||
"invalidDefinitionPath": "การตั้งค่าเทมเพลตไม่ถูกต้อง: {path}",
|
||||
"suggestionReadyForDecision": "ข้อเสนอแนะพร้อมให้ตัดสินใจ",
|
||||
"acceptSuggestion": "ยอมรับ",
|
||||
"acceptAdjustedSuggestion": "ยอมรับหลังปรับ",
|
||||
"rejectSuggestion": "ปฏิเสธ",
|
||||
"suggestionAdjustmentField": "เลือกฟิลด์ทดแทน",
|
||||
"suggestionAdjustmentField": "เลือกฟิลด์ทดแทน", "sampleValueUnavailable": "ไม่พบค่าที่อ่านได้", "orderFieldValueReading": "กำลังอ่าน", "orderFieldValueFailed": "อ่านไม่สำเร็จ", "currentSampleValue": "ค่าจากตัวอย่างปัจจุบัน", "selectedRegion": "คำอธิบายประกอบที่เลือก", "recognitionResults": "ผลลัพธ์การรู้จำ", "orderHeaderResults": "ฟิลด์ส่วนหัวคำสั่งซื้อ", "orderLineResults": "ฟิลด์รายการคำสั่งซื้อ", "noRecognitionResults": "ยังไม่มีผลลัพธ์แบบมีโครงสร้าง", "lineResultField": "แถว {row} · {field}", "previewState": { "idle": "กำลังรอ", "updating": "กำลังอ่าน", "ready": "อัปเดตแล้ว", "failed": "อ่านไม่สำเร็จ" }, "evidenceStatus": { "read": "อ่านแล้ว", "review": "ต้องตรวจทาน", "loading": "กำลังอ่าน", "failed": "อ่านไม่สำเร็จ", "deleted": "ลบแล้ว ไม่นับในผลลัพธ์", "unavailable": "ไม่พบค่าที่อ่านได้" },
|
||||
"openCanvas": "สร้างฉบับร่างและเปิดผืนงาน",
|
||||
"loadingPage": "กำลังโหลดหน้า...",
|
||||
"canvasZoom": "การซูมหน้า",
|
||||
@@ -3032,7 +3057,7 @@
|
||||
"autoSuggestOcr": "ไม่มีพิกัด กำลังสร้างหลักฐานพิกัดด้วย OCR...",
|
||||
"autoSuggestAnalyzing": "กำลังวิเคราะห์แถวจริงและขอบเขตคอลัมน์...",
|
||||
"autoSuggestApplying": "กำลังสร้างเครื่องหมายสำหรับตรวจทาน...",
|
||||
"autoSuggestComplete": "ทำเครื่องหมายอัตโนมัติเสร็จแล้ว โปรดตรวจทานผลลัพธ์",
|
||||
"autoSuggestComplete": "สร้างข้อเสนอแนะแล้ว แต่ยังไม่ได้บันทึก",
|
||||
"autoSuggestNoRows": "ไม่พบแถวรายการสำหรับทำเครื่องหมาย",
|
||||
"autoSuggestFailed": "ทำเครื่องหมายอัตโนมัติไม่สำเร็จ โปรดดูสาเหตุด้านล่าง",
|
||||
"schemaCompatible": "ฟิลด์เข้ากันได้ สามารถสืบทอดอัตโนมัติ",
|
||||
@@ -3218,6 +3243,33 @@
|
||||
"auditSnapshot": "สแนปช็อตการเปลี่ยนแปลง",
|
||||
"auditSnapshotRaw": "สแนปช็อต JSON ต้นฉบับ",
|
||||
"auditDiffEmpty": "ไม่มีความต่างระดับคุณสมบัติ",
|
||||
"auditValueNull": "ว่าง",
|
||||
"auditValueYes": "ใช่",
|
||||
"auditValueNo": "ไม่",
|
||||
"auditValueEmpty": "(ว่าง)",
|
||||
"auditValueEmptyList": "(รายการว่าง)",
|
||||
"auditValueObjectList": "{count} รายการ",
|
||||
"auditArrayLength": "จำนวน {path}",
|
||||
"auditProperty": {
|
||||
"field_code": "รหัสฟิลด์",
|
||||
"display_name": "ชื่อที่แสดง",
|
||||
"display_name_default": "ชื่อที่แสดงเริ่มต้น",
|
||||
"semantic_description": "คำอธิบายเชิงความหมาย",
|
||||
"status": "สถานะ",
|
||||
"scope": "ขอบเขต",
|
||||
"value_type": "ประเภท",
|
||||
"asset_kind": "ชนิดสินทรัพย์",
|
||||
"storage_mode": "โหมดจัดเก็บ",
|
||||
"storage_column": "คอลัมน์จัดเก็บ",
|
||||
"storage_path": "พาธจัดเก็บ",
|
||||
"retired_reason": "เหตุผลเลิกใช้",
|
||||
"reason": "เหตุผล",
|
||||
"action": "การกระทำ",
|
||||
"blocking_count": "จำนวนการอ้างอิงที่บล็อก",
|
||||
"updated_at": "อัปเดตเมื่อ",
|
||||
"created_at": "สร้างเมื่อ",
|
||||
"display_sequence": "ลำดับแคตตาล็อก"
|
||||
},
|
||||
"auditEvent": {
|
||||
"field_adopted": "Schema นำฟิลด์มาใช้",
|
||||
"field_unadopted": "Schema ยกเลิกการนำมาใช้",
|
||||
|
||||
@@ -219,6 +219,7 @@
|
||||
"sku": "SKU"
|
||||
},
|
||||
"events": "บันทึกเหตุการณ์",
|
||||
"operator": "รหัสผู้ปฏิบัติงาน: {id}",
|
||||
"filters": {
|
||||
"status": "สถานะ",
|
||||
"lifecycle": "สถานะงาน"
|
||||
|
||||
@@ -123,6 +123,33 @@
|
||||
"auditSnapshot": "变更快照",
|
||||
"auditSnapshotRaw": "原始 JSON 快照",
|
||||
"auditDiffEmpty": "无属性级差异",
|
||||
"auditValueNull": "空",
|
||||
"auditValueYes": "是",
|
||||
"auditValueNo": "否",
|
||||
"auditValueEmpty": "(空)",
|
||||
"auditValueEmptyList": "(空列表)",
|
||||
"auditValueObjectList": "{count} 项",
|
||||
"auditArrayLength": "{path} 数量",
|
||||
"auditProperty": {
|
||||
"field_code": "字段编码",
|
||||
"display_name": "显示名",
|
||||
"display_name_default": "默认显示名",
|
||||
"semantic_description": "语义说明",
|
||||
"status": "状态",
|
||||
"scope": "范围",
|
||||
"value_type": "类型",
|
||||
"asset_kind": "资产类型",
|
||||
"storage_mode": "存储模式",
|
||||
"storage_column": "存储列",
|
||||
"storage_path": "存储路径",
|
||||
"retired_reason": "弃用原因",
|
||||
"reason": "原因",
|
||||
"action": "动作",
|
||||
"blocking_count": "阻断引用数",
|
||||
"updated_at": "更新时间",
|
||||
"created_at": "创建时间",
|
||||
"display_sequence": "目录顺序"
|
||||
},
|
||||
"auditEvent": {
|
||||
"field_adopted": "Schema 采用字段",
|
||||
"field_unadopted": "Schema 取消采用",
|
||||
@@ -314,6 +341,7 @@
|
||||
"auditEmpty": "暂无配置审计事件",
|
||||
"auditLoadMore": "加载更多审计事件",
|
||||
"auditFieldSummary": "新增 {added},移除 {removed},修改 {changed} 个字段",
|
||||
"auditAutoCreationSummary": "自动建单:{before} → {after}",
|
||||
"auditEvent": {
|
||||
"draft_created": "创建草稿",
|
||||
"draft_saved": "保存草稿",
|
||||
@@ -2705,6 +2733,7 @@
|
||||
"orderProfileValidation": {
|
||||
"eyebrow": "草稿验证",
|
||||
"title": "验证订单文档模板",
|
||||
"validateTemplate": "验证模板",
|
||||
"description": "运行摘要不包含 PDF、对象存储地址或盲测真值;草稿变更后历史运行将标记为过期。",
|
||||
"backToEditor": "返回编辑器",
|
||||
"instantCheck": "运行即时检查",
|
||||
@@ -2717,15 +2746,24 @@
|
||||
"time": "创建时间",
|
||||
"empty": "尚无验证运行。",
|
||||
"completed": "验证运行已完成。",
|
||||
"failed": "验证运行失败。"
|
||||
"failed": "验证运行失败。",
|
||||
"currentDraft": "当前草稿验证",
|
||||
"currentDraftHint": "系统将检查配置,并用当前样本读取一次结果。",
|
||||
"validateCurrent": "验证当前草稿", "validating": "正在验证…", "goPublishCheck": "进入发布检查",
|
||||
"structureCheck": "配置检查", "structureCheckHint": "检查字段绑定、坐标范围、页码和明细结构。",
|
||||
"sampleCheck": "当前样本试读", "sampleCheckHint": "检查当前标注能否从样本中读取字段和明细。",
|
||||
"state": { "ready": "当前草稿可进入发布检查", "stale": "配置已改变,请重新验证", "failed": "验证未通过,请返回编辑器修复", "pending": "尚未验证当前草稿" },
|
||||
"stateHint": { "ready": "配置检查和当前样本试读均已通过。", "stale": "历史验证属于较早草稿,不能用于发布。", "failed": "请根据失败项调整标注后再次验证。", "pending": "完成标注并保存后,运行一次验证。" },
|
||||
"runStatus": { "passed": "已通过", "failed": "未通过", "stale": "已过期", "pending": "未执行", "running": "验证中" },
|
||||
"resultsTitle": "本次样本识别结果", "resultsHint": "仅显示当前草稿按当前标注实时读取的结果;已删除明细仅供核对,不会进入订单结果。", "refreshResults": "重新读取", "resultsLoading": "正在读取当前样本...", "resultsFailed": "未读取到值或读取失败,请返回编辑器检查标注。", "headerResults": "订单表头", "lineResults": "订单明细", "noHeaderResults": "当前样本未读取到订单表头字段。", "noLineResults": "当前样本未读取到订单明细。", "noValue": "未读取到值", "rowStatus": "状态", "deleted": "已删除,不纳入结果", "read": "已读取"
|
||||
},
|
||||
"orderProfilePublishCheck": {
|
||||
"eyebrow": "发布门禁", "title": "确认发布订单文档模板", "description": "报告冻结草稿版本;草稿改变后报告自动失效。", "back": "返回", "selectRun": "选择通过的验证运行", "noRun": "当前草稿没有可用于发布的通过验证运行。", "create": "生成发布检查报告", "report": "报告 {reportNo}", "status": "状态:{status} · Revision {revision}", "blocking": "阻断项", "noBlocking": "无阻断项。", "warnings": "警告(必须逐项确认)", "confirm": "确认发布", "failed": "发布检查失败。"
|
||||
"eyebrow": "发布门禁", "title": "确认发布订单文档模板", "description": "报告冻结草稿版本;草稿改变后报告自动失效。", "back": "返回验证", "selectRun": "选择通过的验证运行", "noRun": "当前草稿没有可用于发布的当前样本验证;请先返回验证页面。", "create": "生成发布检查报告", "report": "报告 {reportNo}", "status": "状态:{status} · Revision {revision}", "blocking": "阻断项", "noBlocking": "无阻断项。", "warnings": "需要确认的变更", "confirm": "确认发布", "failed": "发布检查失败。", "readyTitle": "已验证草稿", "readyHint": "当前样本验证已通过。生成检查后可查看盲测、差异和发布前置条件。", "reportTitle": "发布检查结果", "blockedHint": "以下问题必须修复,不能通过确认绕过。", "reviewHint": "确认所有变更后即可发布当前模板版本。", "confirmHint": "请确认已审核上述变更。", "currentValidationRequired": "当前草稿必须先完成并通过当前样本验证。", "semanticDiffReview": "此版本包含语义差异,请确认已审核。", "unknownIssue": "发布检查发现需要处理的问题。"
|
||||
},
|
||||
"shippingOrderProfiles": {
|
||||
"title": "订单文档模板",
|
||||
"library": { "title": "订单文档模板", "subtitle": "管理模板族、草稿、已发布版本和历史查看。", "create": "创建模板", "search": "搜索模板", "status": "当前状态", "actions": "操作", "draft": "草稿", "published": "已发布 v{version}", "retired": "已退役", "loading": "正在加载模板...", "empty": "暂无模板。", "loadFailed": "加载模板失败。", "createFailed": "创建新版本草稿失败。" },
|
||||
"wizard": { "title": "创建订单文档模板", "description": "先明确模板用途,再选择样本开始标注。", "steps": "第 {step} 步,共 3 步", "stepLabel": "步骤 {step}", "identityStep": "基本信息", "sampleStep": "选择样本", "tableStep": "选择订单明细表", "namePlaceholder": "例如:ACME 采购订单", "systemCodeHint": "系统会在创建后自动生成不可变编码,用于版本、路由和审计。", "schemaRequired": "请先在订单 Schema 页面发布一个可用版本,再创建模板。", "selectSchema": "选择已发布 Schema", "uploadNewSample": "上传新样本", "uploadNewSampleHint": "上传后系统会自动解析;完成后自动选中该文件。", "uploading": "正在上传", "sampleParsing": "正在解析,完成后会自动选中。", "sampleParseFailed": "解析失败,请重新上传或选择已有样本。", "sampleReady": "样本已解析并自动选中,可继续下一步。", "sampleSelected": "当前样本", "reuseSample": "复用已有样本", "reuseSampleHint": "仅展示已解析完成的模板专用样本。", "previous": "上一步", "next": "下一步", "createDraft": "创建草稿", "createAndEdit": "创建并进入标注", "incomplete": "请先完成必填信息。", "loadFailed": "加载向导选项失败。", "uploadFailed": "上传模板样本失败。", "sampleHint": "上传或选择样本不会创建模板。", "tableLoadFailed": "加载样本表格失败。", "tableOption": "第 {page} 页 · {rows} 行 · {columns} 列", "orderLineTable": "订单明细表", "orderLineTableHint": "后续标注和订单明细行识别都以此表为基准。", "noTable": "该样本没有可用表格,请选择其他已解析样本。", "createFailed": "模板草稿创建失败,未保留半成品。" },
|
||||
"wizard": { "title": "创建订单文档模板", "description": "先明确模板用途,再选择首份建模与训练样本开始标注。", "steps": "第 {step} 步,共 3 步", "stepLabel": "步骤 {step}", "identityStep": "基本信息", "sampleStep": "选择建模样本", "tableStep": "选择订单明细表", "namePlaceholder": "例如:ACME 采购订单", "systemCodeHint": "系统会在创建后自动生成不可变编码,用于版本、路由和审计。", "schemaRequired": "请先在订单 Schema 页面发布一个可用版本,再创建模板。", "selectSchema": "选择已发布 Schema", "uploadNewSample": "上传新样本", "uploadNewSampleHint": "上传后系统会自动解析;完成后自动选中该文件。", "uploading": "正在上传", "sampleParsing": "正在解析,完成后会自动选中。", "sampleParseFailed": "解析失败,请重新上传或选择已有样本。", "sampleReady": "样本已解析并自动选中,可继续下一步。", "sampleSelected": "当前样本", "reuseSample": "复用已有样本", "reuseSampleHint": "仅展示已解析完成的模板专用样本。", "previous": "上一步", "next": "下一步", "createDraft": "创建草稿", "createAndEdit": "创建并进入标注", "incomplete": "请先完成必填信息。", "loadFailed": "加载向导选项失败。", "uploadFailed": "上传模板样本失败。", "sampleHint": "上传或选择样本不会创建模板;创建后该样本会同时作为标注和训练证据。", "tableLoadFailed": "加载样本表格失败。", "tableOption": "第 {page} 页 · {rows} 行 · {columns} 列", "orderLineTable": "订单明细表", "orderLineTableHint": "后续标注和订单明细行识别都以此表为基准。", "noTable": "该样本没有可用表格,请选择其他已解析样本。", "createFailed": "模板草稿创建失败,未保留半成品。" },
|
||||
"subtitle": "从 MinerU 表格样本可视化配置精确列映射;无需编辑 JSON 或结构指纹。",
|
||||
"structureBlocked": "该表格结构异常,不能创建模板。请等待坐标证据重建后再复核,勿通过字段映射修复原始网格。",
|
||||
"reconstructionRequired": "此表头混入明细,需先确认列边界并重建表格;重建结果必须人工审核。",
|
||||
@@ -2834,6 +2872,7 @@
|
||||
"continueEditing": "继续编辑",
|
||||
"viewVersion": "查看版本",
|
||||
"familyVersions": "版本导航",
|
||||
"technicalDetails": "技术信息",
|
||||
"loading": "正在加载版本详情...",
|
||||
"tabsLabel": "模板版本详情页签",
|
||||
"tabs": {
|
||||
@@ -3012,9 +3051,12 @@
|
||||
"sampleSummaryTitle": "样本摘要",
|
||||
"annotationCount": "标注样本",
|
||||
"trainingCount": "训练样本",
|
||||
"blindTestCount": "盲测样本",
|
||||
"boundBlindTestCount": "已绑定盲测样本",
|
||||
"firstSample": "首个样本",
|
||||
"testSummaryTitle": "测试摘要",
|
||||
"testSummaryTitle": "盲测套件",
|
||||
"blindTestSuiteSampleCount": "盲测套件样本",
|
||||
"serviceUnavailable": "服务暂不可用,请确认本地后端已启动后重试。",
|
||||
"retry": "重新加载",
|
||||
"approvedAt": "批准时间",
|
||||
"latestRun": "最近运行",
|
||||
"sourceVersionTitle": "来源版本",
|
||||
@@ -3058,10 +3100,17 @@
|
||||
"noCandidateRows": "当前标注没有识别到有效明细,请检查物理行、line_no 和字段范围。",
|
||||
"blindTest": {
|
||||
"title": "盲测",
|
||||
"gateTitle": "发布前盲测",
|
||||
"gateRequiredHint": "需完成独立样本盲测并批准后,才能进入发布检查。",
|
||||
"gateApprovedHint": "当前草稿的盲测已批准,可进入发布检查。",
|
||||
"status": { "missing": "未建立", "draft": "待完成", "approved": "已批准", "superseded": "已失效" },
|
||||
"samples": "样本:{count} · {status}",
|
||||
"notRun": "未执行",
|
||||
"approvedHint": "盲测已批准,无需重复执行或批准。",
|
||||
"selectIndependentSample": "选择独立样本",
|
||||
"loadIndependentSamples": "加载可选样本",
|
||||
"loadingIndependentSamples": "正在加载可选样本…",
|
||||
"loadIndependentSamplesHint": "需要新增盲测样本时再加载候选,避免打开页面等待历史样本扫描。",
|
||||
"selectSamplePlaceholder": "请选择未参与当前模板标注的订单",
|
||||
"noIndependentSamples": "没有可用的独立样本;请先上传并完成解析另一份同类订单。",
|
||||
"reviewHint": "请逐项勾选正确或错误;标为错误时填写更正值,未勾选不能加入盲测。",
|
||||
@@ -3078,19 +3127,30 @@
|
||||
"expectedOrderFieldsPlaceholder": "{\"customer_po\": \"PO-45001\"}",
|
||||
"expectedOrderFieldsHint": "配置订单字段时,必须填写每个字段的人工确认值。",
|
||||
"expectedOrderFieldsInvalid": "订单字段真值必须是 JSON 对象。",
|
||||
"trainingAdded": "已绑定当前训练样本",
|
||||
"addTrainingSample": "添加训练样本",
|
||||
"trainingAdded": "已绑定当前训练样本",
|
||||
"addTrainingSample": "添加训练样本",
|
||||
"trainingRequired": "批准前请先在编辑器将当前标注样本加入训练样本。",
|
||||
"goToEditor": "返回编辑器绑定训练样本",
|
||||
"addedSamples": "已加入的盲测样本",
|
||||
"addedSamplesHint": "草稿可移除;批准后保留审计记录。",
|
||||
"removeSample": "移除样本",
|
||||
"sampleRemoved": "盲测样本已移除",
|
||||
"addCurrentSample": "添加当前盲测样本",
|
||||
"addCurrentSample": "添加当前盲测样本",
|
||||
"backToValidation": "返回验证",
|
||||
"goPublishCheck": "进入发布检查",
|
||||
"latestResult": "最近执行:{status}({passed}/{count} 通过)",
|
||||
"candidateRowsEmpty": "当前样本未识别到明细,不能作为盲测真值。",
|
||||
"correctedValue": "填写人工更正值",
|
||||
"execution": "执行与批准",
|
||||
"runHint": "执行会按当前草稿重新解析全部盲测样本;只有全量通过才能批准。",
|
||||
"unknownSample": "未知样本",
|
||||
"failure": { "title": "本次执行失败明细", "hint": "请按原因返回编辑器调整标注或重新确认盲测真值,再次执行。", "fieldMismatch": "{sample}:订单字段 {field} 的重新读取值与人工真值不一致。", "fieldNeedsReview": "{sample}:订单字段 {field} 未达到可确认状态,请检查锚点和坐标范围。", "fieldUnavailable": "{sample}:订单字段 {field} 未读取到可用值,请检查锚点、页面和坐标证据。", "coordinateEvidenceMissing": "{sample}:缺少表格或页面坐标证据,无法完成盲测。", "rowsMismatch": "{sample}:重新解析的订单明细与人工真值不一致。", "unknown": "{sample}:盲测执行未通过,请检查下方原始诊断码。" },
|
||||
"run": "执行",
|
||||
"approve": "批准"
|
||||
},
|
||||
"workbench": {
|
||||
"boundHistoricalSchema": "已绑定历史版本",
|
||||
"intro": "在受控文档页面拖拽证据区域;保存定义不含 HTML 或存储地址。", "structure": "结构", "saveStatus": { "saved": "已保存", "saving": "正在保存", "failed": "保存失败,将保留本地修改", "readonly": "只读:编辑租约已失效" }, "exportLocalDraft": "导出本地草稿", "recoverLease": "重新获取租约", "takeOverLease": "确认接管租约", "suggestionReadyForDecision": "建议已生成,请确认决定", "acceptSuggestion": "接受", "acceptAdjustedSuggestion": "调整后接受", "rejectSuggestion": "拒绝", "suggestionAdjustmentField": "选择替代字段",
|
||||
"intro": "在受控文档页面拖拽证据区域;保存定义不含 HTML 或存储地址。", "structure": "结构", "returnToLibrary": "返回文档模板", "saveStatus": { "saved": "已保存", "saving": "正在保存", "failed": "保存失败,将保留本地修改", "readonly": "只读:编辑租约不可用" }, "exportLocalDraft": "导出本地草稿", "recoverLease": "重新获取租约", "takeOverLease": "确认接管租约", "invalidDefinitionPath": "模板配置无效:{path}", "suggestionReadyForDecision": "建议已生成,请确认决定", "acceptSuggestion": "接受", "acceptAdjustedSuggestion": "调整后接受", "rejectSuggestion": "拒绝", "suggestionAdjustmentField": "选择替代字段", "sampleValueUnavailable": "未读取到值", "orderFieldValueReading": "读取中", "orderFieldValueFailed": "读取失败", "currentSampleValue": "当前样本值", "selectedRegion": "当前标注", "recognitionResults": "识别结果", "orderHeaderResults": "订单表头字段", "orderLineResults": "订单明细行字段", "noRecognitionResults": "暂未读取到结构化结果", "lineResultField": "第 {row} 行 · {field}", "previewState": { "idle": "等待识别", "updating": "正在识别", "ready": "已更新", "failed": "识别失败" }, "evidenceStatus": { "read": "已读取", "review": "需复核", "loading": "读取中", "failed": "读取失败", "deleted": "已删除,不纳入结果", "unavailable": "未读取到值" },
|
||||
"openCanvas": "创建草稿并打开画布",
|
||||
"loadingPage": "正在加载页面…",
|
||||
"canvasZoom": "页面缩放",
|
||||
@@ -3106,7 +3166,7 @@
|
||||
"autoSuggestOcr": "缺少坐标,正在生成 OCR 坐标证据…",
|
||||
"autoSuggestAnalyzing": "正在分析物理行与列边界…",
|
||||
"autoSuggestApplying": "正在生成待复核标记…",
|
||||
"autoSuggestComplete": "自动标记完成,请复核结果。",
|
||||
"autoSuggestComplete": "已生成建议,尚未保存。",
|
||||
"autoSuggestNoRows": "未检测到可用于标记的明细行。",
|
||||
"autoSuggestFailed": "自动标记失败,请查看下方原因。",
|
||||
"schemaCompatible": "字段兼容,可自动继承",
|
||||
|
||||
@@ -279,6 +279,7 @@
|
||||
"sku": "SKU"
|
||||
},
|
||||
"events": "事件记录",
|
||||
"operator": "操作人 ID:{id}",
|
||||
"filters": {
|
||||
"status": "状态",
|
||||
"lifecycle": "任务状态"
|
||||
@@ -335,7 +336,7 @@
|
||||
"inventoryTitle": "库存核验历史",
|
||||
"verificationLine": "预约 {reservationId}:{availableQty}/{requiredQty}({status})",
|
||||
"artifactTitle": "Excel Artifact 时间线",
|
||||
"reservationIds": "包含预约单 ID:{reservationIds}",
|
||||
"reservationIds": "包含预约单:{reservationIds}",
|
||||
"uploadTitle": "上传 Attempt 时间线",
|
||||
"uploadAttempt": "Artifact #{artifactId} / Attempt {attemptNo}",
|
||||
"freightRef": "货代参考号:{freightRefNo}",
|
||||
|
||||
@@ -273,6 +273,7 @@
|
||||
"auditEmpty": "暫無設定審計事件",
|
||||
"auditLoadMore": "載入更多審計事件",
|
||||
"auditFieldSummary": "新增 {added},移除 {removed},修改 {changed} 個欄位",
|
||||
"auditAutoCreationSummary": "自動建單:{before} → {after}",
|
||||
"auditEvent": {
|
||||
"draft_created": "建立草稿",
|
||||
"draft_saved": "儲存草稿",
|
||||
@@ -2555,6 +2556,7 @@
|
||||
"orderProfileValidation": {
|
||||
"eyebrow": "草稿驗證",
|
||||
"title": "驗證訂單文件範本",
|
||||
"validateTemplate": "驗證範本",
|
||||
"description": "執行摘要不包含 PDF、物件儲存位址或盲測真值;草稿變更後歷史執行將標示為過期。",
|
||||
"backToEditor": "返回編輯器",
|
||||
"instantCheck": "執行即時檢查",
|
||||
@@ -2567,13 +2569,13 @@
|
||||
"time": "建立時間",
|
||||
"empty": "尚無驗證執行。",
|
||||
"completed": "驗證執行已完成。",
|
||||
"failed": "驗證執行失敗。"
|
||||
"failed": "驗證執行失敗。", "currentDraft": "目前草稿驗證", "currentDraftHint": "系統會檢查設定,並以目前樣本試讀一次。", "validateCurrent": "驗證目前草稿", "validating": "驗證中…", "goPublishCheck": "進入發布檢查", "structureCheck": "設定檢查", "structureCheckHint": "檢查欄位繫結、座標範圍、頁碼及明細結構。", "sampleCheck": "目前樣本試讀", "sampleCheckHint": "檢查目前標註能否從樣本讀取欄位與明細。", "state": { "ready": "目前草稿可進入發布檢查", "stale": "設定已變更,請重新驗證", "failed": "驗證未通過,請返回編輯器修正", "pending": "尚未驗證目前草稿" }, "stateHint": { "ready": "設定檢查和目前樣本試讀均已通過。", "stale": "歷史驗證屬於較早草稿,不能用於發布。", "failed": "請調整標註後再次驗證。", "pending": "完成標註並儲存後,執行一次驗證。" }, "runStatus": { "passed": "已通過", "failed": "未通過", "stale": "已過期", "pending": "未執行", "running": "驗證中" }, "resultsTitle": "本次樣本辨識結果", "resultsHint": "只顯示目前草稿依目前標註即時讀取的結果;已刪除明細僅供核對,不會進入訂單結果。", "refreshResults": "重新讀取", "resultsLoading": "正在讀取目前樣本...", "resultsFailed": "未讀取到值或讀取失敗,請返回編輯器檢查標註。", "headerResults": "訂單表頭", "lineResults": "訂單明細", "noHeaderResults": "目前樣本未讀取到訂單表頭欄位。", "noLineResults": "目前樣本未讀取到訂單明細。", "noValue": "未讀取到值", "rowStatus": "狀態", "deleted": "已刪除,不納入結果", "read": "已讀取"
|
||||
},
|
||||
"orderProfilePublishCheck": {
|
||||
"eyebrow": "發布閘門",
|
||||
"title": "確認發布訂單文件範本",
|
||||
"description": "報告會凍結草稿版本;草稿變更後報告自動失效。",
|
||||
"back": "返回",
|
||||
"back": "返回驗證",
|
||||
"selectRun": "選擇通過的驗證執行",
|
||||
"noRun": "目前草稿沒有可供發布的通過驗證執行。",
|
||||
"create": "建立發布檢查報告",
|
||||
@@ -2583,7 +2585,7 @@
|
||||
"noBlocking": "無阻斷項。",
|
||||
"warnings": "警告(必須逐項確認)",
|
||||
"confirm": "確認發布",
|
||||
"failed": "發布檢查失敗。"
|
||||
"failed": "發布檢查失敗。", "readyTitle": "已驗證草稿", "readyHint": "目前樣本驗證已通過。產生檢查後可查看發布前置條件和變更。", "reportTitle": "發布檢查結果", "blockedHint": "以下問題必須修正,不能透過確認略過。", "reviewHint": "確認所有列出的變更後即可發布此版本。", "confirmHint": "請確認已審核上述變更。", "currentValidationRequired": "目前草稿必須先通過目前樣本驗證。", "semanticDiffReview": "此版本包含語義差異,請確認已審核。", "unknownIssue": "發布檢查發現需要處理的問題。"
|
||||
},
|
||||
"shippingOrderProfiles": {
|
||||
"title": "訂單文件範本",
|
||||
@@ -2605,10 +2607,10 @@
|
||||
"wizard": {
|
||||
"title": "建立訂單文件範本",
|
||||
"steps": "第 {step} 步,共 3 步",
|
||||
"description": "先定義範本用途,再選擇樣本開始標註。",
|
||||
"description": "先定義範本用途,再選擇首份建模與訓練樣本開始標註。",
|
||||
"stepLabel": "步驟 {step}",
|
||||
"identityStep": "基本資訊",
|
||||
"sampleStep": "選擇樣本",
|
||||
"sampleStep": "選擇建模樣本",
|
||||
"tableStep": "選擇訂單明細表",
|
||||
"namePlaceholder": "例如:ACME 採購訂單",
|
||||
"systemCodeHint": "系統會在建立後自動產生不可變編碼,供版本、路由與稽核使用。",
|
||||
@@ -2630,7 +2632,7 @@
|
||||
"incomplete": "請先完成必填資訊。",
|
||||
"loadFailed": "載入精靈選項失敗。",
|
||||
"uploadFailed": "上傳範本樣本失敗。",
|
||||
"sampleHint": "上傳或選擇樣本不會建立範本。",
|
||||
"sampleHint": "上傳或選擇樣本不會建立範本;建立後該樣本會同時作為標註和訓練證據。",
|
||||
"tableLoadFailed": "載入樣本表格失敗。",
|
||||
"tableOption": "第 {page} 頁 · {rows} 列 · {columns} 欄",
|
||||
"orderLineTable": "訂單明細表",
|
||||
@@ -2746,6 +2748,7 @@
|
||||
"continueEditing": "繼續編輯",
|
||||
"viewVersion": "查看版本",
|
||||
"familyVersions": "版本導覽",
|
||||
"technicalDetails": "技術資訊",
|
||||
"loading": "正在載入版本詳情...",
|
||||
"tabsLabel": "範本版本詳情頁籤",
|
||||
"tabs": {
|
||||
@@ -2924,9 +2927,12 @@
|
||||
"sampleSummaryTitle": "樣本摘要",
|
||||
"annotationCount": "標註樣本",
|
||||
"trainingCount": "訓練樣本",
|
||||
"blindTestCount": "盲測樣本",
|
||||
"boundBlindTestCount": "已綁定盲測樣本",
|
||||
"firstSample": "首個樣本",
|
||||
"testSummaryTitle": "測試摘要",
|
||||
"testSummaryTitle": "盲測套件",
|
||||
"blindTestSuiteSampleCount": "盲測套件樣本",
|
||||
"serviceUnavailable": "服務暫時無法使用,請確認本機後端已啟動後再試。",
|
||||
"retry": "重新載入",
|
||||
"approvedAt": "批准時間",
|
||||
"latestRun": "最近執行",
|
||||
"sourceVersionTitle": "來源版本",
|
||||
@@ -2969,10 +2975,17 @@
|
||||
"noCandidateRows": "目前標註未識別到有效明細,請檢查實體行、line_no 與欄位範圍。",
|
||||
"blindTest": {
|
||||
"title": "盲測",
|
||||
"gateTitle": "發佈前盲測",
|
||||
"gateRequiredHint": "必須完成獨立樣本盲測並批准後,才能進入發佈檢查。",
|
||||
"gateApprovedHint": "目前草稿的盲測已批准,可進入發佈檢查。",
|
||||
"status": { "missing": "未建立", "draft": "待完成", "approved": "已批准", "superseded": "已失效" },
|
||||
"samples": "樣本:{count} · {status}",
|
||||
"notRun": "尚未執行",
|
||||
"approvedHint": "盲測已批准,無須重複執行或批准。",
|
||||
"selectIndependentSample": "選擇獨立樣本",
|
||||
"loadIndependentSamples": "載入可選樣本",
|
||||
"loadingIndependentSamples": "正在載入可選樣本…",
|
||||
"loadIndependentSamplesHint": "需要新增盲測樣本時再載入候選,避免開啟頁面時等待歷史樣本掃描。",
|
||||
"selectSamplePlaceholder": "請選擇未參與目前範本標註的訂單",
|
||||
"noIndependentSamples": "沒有可用的獨立樣本;請先上傳並完成解析另一份同類訂單。",
|
||||
"reviewHint": "請逐項勾選正確或錯誤;標示錯誤時填寫更正值,未勾選不能加入盲測。",
|
||||
@@ -2991,32 +3004,44 @@
|
||||
"expectedOrderFieldsInvalid": "訂單欄位真值必須是 JSON 物件。",
|
||||
"trainingAdded": "已綁定目前訓練樣本",
|
||||
"addTrainingSample": "新增訓練樣本",
|
||||
"trainingRequired": "批准前請先在編輯器將目前標註樣本加入訓練樣本。",
|
||||
"goToEditor": "返回編輯器綁定訓練樣本",
|
||||
"addedSamples": "已加入的盲測樣本",
|
||||
"addedSamplesHint": "草稿可移除;批准後保留稽核記錄。",
|
||||
"removeSample": "移除樣本",
|
||||
"sampleRemoved": "盲測樣本已移除",
|
||||
"addCurrentSample": "新增目前盲測樣本",
|
||||
"backToValidation": "返回驗證",
|
||||
"goPublishCheck": "進入發佈檢查",
|
||||
"latestResult": "最近執行:{status}({passed}/{count} 通過)",
|
||||
"candidateRowsEmpty": "目前樣本未識別到明細,不能作為盲測真值。",
|
||||
"correctedValue": "填寫人工更正值",
|
||||
"execution": "執行與批准",
|
||||
"runHint": "執行會按目前草稿重新解析全部盲測樣本;只有全數通過才能批准。",
|
||||
"unknownSample": "未知樣本",
|
||||
"failure": { "title": "本次執行失敗明細", "hint": "請依原因返回編輯器調整標註或重新確認盲測真值,再次執行。", "fieldMismatch": "{sample}:訂單欄位 {field} 的重新讀取值與人工真值不一致。", "fieldNeedsReview": "{sample}:訂單欄位 {field} 未達可確認狀態,請檢查錨點和座標範圍。", "fieldUnavailable": "{sample}:訂單欄位 {field} 未讀取到可用值,請檢查錨點、頁面和座標證據。", "coordinateEvidenceMissing": "{sample}:缺少表格或頁面座標證據,無法完成盲測。", "rowsMismatch": "{sample}:重新解析的訂單明細與人工真值不一致。", "unknown": "{sample}:盲測執行未通過,請檢查下方原始診斷碼。" },
|
||||
"run": "執行",
|
||||
"approve": "批准"
|
||||
},
|
||||
"workbench": {
|
||||
"boundHistoricalSchema": "已綁定歷史版本",
|
||||
"intro": "在受控文件頁面拖曳證據區域;儲存定義不含 HTML 或儲存位址。",
|
||||
"intro": "在受控文件頁面拖曳證據區域;儲存定義不含 HTML 或儲存位址。", "returnToLibrary": "返回文件範本",
|
||||
"structure": "結構",
|
||||
"saveStatus": {
|
||||
"saved": "已儲存",
|
||||
"saving": "正在儲存",
|
||||
"failed": "儲存失敗,將保留本機修改",
|
||||
"readonly": "唯讀:編輯租約已失效"
|
||||
"readonly": "唯讀:編輯租約不可用"
|
||||
},
|
||||
"exportLocalDraft": "匯出本機草稿",
|
||||
"recoverLease": "重新取得租約",
|
||||
"takeOverLease": "確認接管租約",
|
||||
"invalidDefinitionPath": "模板設定無效:{path}",
|
||||
"suggestionReadyForDecision": "建議已產生,請確認決定",
|
||||
"acceptSuggestion": "接受",
|
||||
"acceptAdjustedSuggestion": "調整後接受",
|
||||
"rejectSuggestion": "拒絕",
|
||||
"suggestionAdjustmentField": "選擇替代欄位",
|
||||
"suggestionAdjustmentField": "選擇替代欄位", "sampleValueUnavailable": "未讀取到值", "orderFieldValueReading": "讀取中", "orderFieldValueFailed": "讀取失敗", "currentSampleValue": "目前樣本值", "selectedRegion": "目前標註", "recognitionResults": "識別結果", "orderHeaderResults": "訂單表頭欄位", "orderLineResults": "訂單明細行欄位", "noRecognitionResults": "暫未讀取到結構化結果", "lineResultField": "第 {row} 行 · {field}", "previewState": { "idle": "等待識別", "updating": "正在識別", "ready": "已更新", "failed": "識別失敗" }, "evidenceStatus": { "read": "已讀取", "review": "需覆核", "loading": "讀取中", "failed": "讀取失敗", "deleted": "已刪除,不納入結果", "unavailable": "未讀取到值" },
|
||||
"openCanvas": "建立草稿並開啟畫布",
|
||||
"loadingPage": "正在載入頁面…",
|
||||
"canvasZoom": "頁面縮放",
|
||||
@@ -3032,7 +3057,7 @@
|
||||
"autoSuggestOcr": "缺少座標,正在產生 OCR 座標證據…",
|
||||
"autoSuggestAnalyzing": "正在分析實體行與欄位邊界…",
|
||||
"autoSuggestApplying": "正在產生待複核標記…",
|
||||
"autoSuggestComplete": "自動標記完成,請複核結果。",
|
||||
"autoSuggestComplete": "已產生建議,尚未儲存。",
|
||||
"autoSuggestNoRows": "未偵測到可用於標記的明細行。",
|
||||
"autoSuggestFailed": "自動標記失敗,請查看下方原因。",
|
||||
"schemaCompatible": "欄位相容,可自動繼承",
|
||||
@@ -3218,6 +3243,33 @@
|
||||
"auditSnapshot": "變更快照",
|
||||
"auditSnapshotRaw": "原始 JSON 快照",
|
||||
"auditDiffEmpty": "無屬性級差異",
|
||||
"auditValueNull": "空",
|
||||
"auditValueYes": "是",
|
||||
"auditValueNo": "否",
|
||||
"auditValueEmpty": "(空)",
|
||||
"auditValueEmptyList": "(空列表)",
|
||||
"auditValueObjectList": "{count} 項",
|
||||
"auditArrayLength": "{path} 數量",
|
||||
"auditProperty": {
|
||||
"field_code": "欄位編碼",
|
||||
"display_name": "顯示名",
|
||||
"display_name_default": "預設顯示名",
|
||||
"semantic_description": "語義說明",
|
||||
"status": "狀態",
|
||||
"scope": "範圍",
|
||||
"value_type": "類型",
|
||||
"asset_kind": "資產類型",
|
||||
"storage_mode": "儲存模式",
|
||||
"storage_column": "儲存欄",
|
||||
"storage_path": "儲存路徑",
|
||||
"retired_reason": "棄用原因",
|
||||
"reason": "原因",
|
||||
"action": "動作",
|
||||
"blocking_count": "阻斷引用數",
|
||||
"updated_at": "更新時間",
|
||||
"created_at": "建立時間",
|
||||
"display_sequence": "目錄順序"
|
||||
},
|
||||
"auditEvent": {
|
||||
"field_adopted": "Schema 採用欄位",
|
||||
"field_unadopted": "Schema 取消採用",
|
||||
|
||||
@@ -279,6 +279,7 @@
|
||||
"sku": "SKU"
|
||||
},
|
||||
"events": "事件記錄",
|
||||
"operator": "操作人 ID:{id}",
|
||||
"filters": {
|
||||
"status": "狀態",
|
||||
"lifecycle": "任務狀態"
|
||||
|
||||
+11
-1
@@ -106,8 +106,18 @@
|
||||
}
|
||||
|
||||
.select-field {
|
||||
@apply input-field cursor-pointer;
|
||||
@apply input-field cursor-pointer pr-10;
|
||||
appearance: none;
|
||||
background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
|
||||
background-position: calc(100% - 1.1rem) 50%, calc(100% - 0.8rem) 50%;
|
||||
background-repeat: no-repeat;
|
||||
background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
|
||||
}
|
||||
|
||||
.select-field[multiple] {
|
||||
@apply pr-4;
|
||||
appearance: auto;
|
||||
background-image: none;
|
||||
}
|
||||
|
||||
.label-field {
|
||||
|
||||
Reference in new issue
Block a user