feat(shipping-notice): 通知准备履约字段就地编辑并修复缺口复核入口
- 编辑闸门翻转为状态制:Excel 生成前+无活动 Attempt 即可编辑,原因不强制(审计自动记录操作人与变更) - 修复 Decimal 字段人工编辑无法持久化(单字段+整行替换两路径) - 预约注册与核验比对改读有效订单值视图,消除编辑后重匹配 RESERVATION_MISMATCH 阻断 - 通知准备值列改读有效视图:保存即显新值,匹配结果列保持最近一轮事实 - 行编辑入口为更多操作列编辑按钮;编辑态替换为保存/取消;库存源行内改选随保存统一提交 - 展示态动作收纳进更多菜单(Teleport 浮层,防表格 overflow 裁剪) - 修复缺口复核投影键错位(has_shortage 恒 False 致入口隐藏)并补齐行级结案入口 - 缺口放行改行内补录条(菜单放行或缺 N 项徽标展开,确认放行/取消收起),放行原因可选 - i18n 四语言;technical.md/funclist.md 语义文档同步
This commit is contained in:
1 parent
4d879dd8ea
commit
eed1068ae3
29 files changed
+1981
-218
No files matched your search
@@ -508,6 +508,26 @@ def load_current_match_facts_by_task(task_id: int | None) -> dict[int, dict[str,
|
||||
return out
|
||||
|
||||
|
||||
def load_current_match_facts_by_line_index(task_id: int | None) -> dict[int, dict[str, Any]]:
|
||||
"""按 line_index 索引当前匹配事实(Case 履约投影专用)。
|
||||
|
||||
核心逻辑:与 load_current_match_facts_by_task 同一查询;Case 草稿行只有
|
||||
_line_index 没有 snapshot_line_id,必须按行号索引才能关联上事实。
|
||||
"""
|
||||
if task_id is None:
|
||||
return {}
|
||||
rows = (
|
||||
ShippingNoticeLineInventoryMatch.query
|
||||
.filter_by(task_id=int(task_id), is_current=True)
|
||||
.all()
|
||||
)
|
||||
return {
|
||||
int(row.line_index): serialize_match_fact(row)
|
||||
for row in rows
|
||||
if row.line_index is not None
|
||||
}
|
||||
|
||||
|
||||
def aggregate_match_status_for_task(task_id: int | None) -> str | None:
|
||||
"""根据当前行级 Match 聚合任务匹配状态,禁止读取 OT/Notice 缓存字段。"""
|
||||
facts = list(load_current_match_facts_by_task(task_id).values())
|
||||
|
||||
@@ -771,7 +771,6 @@ def project_review_case_line_decisions(
|
||||
"""
|
||||
from app.services.shipping_notice.line_inventory_match_projection import (
|
||||
line_auto_fulfill_enabled,
|
||||
load_current_match_facts_by_task,
|
||||
project_line_inventory_view,
|
||||
)
|
||||
from app.services.shipping_notice.order_review_workbench_projection import (
|
||||
@@ -818,7 +817,11 @@ def project_review_case_line_decisions(
|
||||
'status': 'resolving',
|
||||
'source': 'inventory_source_clue',
|
||||
}
|
||||
match_facts = load_current_match_facts_by_task(formal_ot.get('task_id'))
|
||||
# [BE-键修复] Case 草稿行只有 _line_index;补一条按行号索引的事实通道。
|
||||
from app.services.shipping_notice.line_inventory_match_projection import (
|
||||
load_current_match_facts_by_line_index,
|
||||
)
|
||||
match_facts_by_line = load_current_match_facts_by_line_index(formal_ot.get('task_id'))
|
||||
labels = dict(source_labels or {})
|
||||
if not labels:
|
||||
draft = getattr(case, 'current_draft', None)
|
||||
@@ -843,7 +846,12 @@ def project_review_case_line_decisions(
|
||||
decision = by_key.get(key)
|
||||
# 正式 OT 的库存数量以当前行匹配事实为准;草稿 validation_result 只保留
|
||||
# 解析阶段投影,不能因为其中没有 available_qty 就错误阻断人工出单。
|
||||
fact = match_facts.get(key)
|
||||
# [BE-键修复] 草稿行只有 _line_index;旧实现误用 draft_line_id 查 snapshot_line_id 键,恒 miss。
|
||||
line_index = draft_line.get('_line_index')
|
||||
fact = (
|
||||
match_facts_by_line.get(int(line_index))
|
||||
if line_index is not None else None
|
||||
)
|
||||
fact_detail = dict((fact or {}).get('detail_json') or {}) if isinstance(fact, dict) else {}
|
||||
fulfill_proj = dict(proj)
|
||||
if isinstance(fact, dict):
|
||||
@@ -1091,7 +1099,7 @@ def decide_review_line_fulfillment(
|
||||
case_no: Case 编号。
|
||||
draft_line_id: 草稿行键。
|
||||
decision_code: 决定码。
|
||||
reason: 关闭/重开/短缺放行必填原因。
|
||||
reason: 关闭/重开必填原因;短缺放行可选(人工放行事实由审计链记录)。
|
||||
release_field_values: 短缺放行时模板行级库存字段的人工补录值。
|
||||
expected_draft_version: 可选草稿乐观锁。
|
||||
actor_is_admin: 是否管理员(重开授权)。
|
||||
@@ -1106,7 +1114,9 @@ def decide_review_line_fulfillment(
|
||||
code='SHIPPING.REVIEW_LINE_DECISION_INVALID',
|
||||
details={'decision_code': code},
|
||||
)
|
||||
if code in {DECISION_CLOSE, DECISION_REOPEN, DECISION_RELEASE_SHORTAGE} and not str(reason or '').strip():
|
||||
# [BE-放行免因] 短缺放行不强制原因:人工放行事实已由审计链完整记录
|
||||
# (操作人 + 时间 + 决定快照 release_field_values);结案/重开仍要求原因。
|
||||
if code in {DECISION_CLOSE, DECISION_REOPEN} and not str(reason or '').strip():
|
||||
raise ValidationError(
|
||||
'Reason is required',
|
||||
code='SHIPPING.REVIEW_LINE_DECISION_REASON_REQUIRED',
|
||||
|
||||
@@ -2,8 +2,9 @@
|
||||
services/shipping_notice/reservation_service.py
|
||||
|
||||
用途:管理冻结订单预约单的注册、库存核验轮次和滚动制单占用。
|
||||
依赖:ShippingOrderSnapshot、履约 ORM、统一 AppError。
|
||||
逻辑:每轮核验追加记录;只有本轮全部满足的预约单可被同一事务选择并绑定到一个新 Artifact。
|
||||
依赖:ShippingOrderSnapshot、effective_order_view(有效订单值视图)、履约 ORM、统一 AppError。
|
||||
逻辑:预约身份按「冻结快照 + 冻结后已接受人工修正」的有效值注册;每轮核验追加记录;
|
||||
只有本轮全部满足的预约单可被同一事务选择并绑定到一个新 Artifact。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -40,17 +41,37 @@ def _decimal(value: Any) -> Decimal:
|
||||
|
||||
|
||||
def ensure_task_reservations(task: ShippingOrderTask) -> list[ShippingReservation]:
|
||||
"""由冻结 Snapshot 注册全局预约号;同 PO 的变更只能作为人工修订候选。"""
|
||||
"""
|
||||
由有效订单视图(冻结快照 + 已接受人工修正)注册全局预约号;同 PO 的料号/数量
|
||||
变更按同一 OT 确认修订自动接替,跨任务或已占用预约仍走人工复核/锁定拒绝。
|
||||
|
||||
核心逻辑:预约身份(预约号/料号/数量)以 effective_line_facts_for_notice 的有效值为准;
|
||||
否则就地编辑料号/数量后,重匹配写入的有效值与按冻结列注册的预约不一致,
|
||||
核验比对必抛 RESERVATION_MISMATCH 使核验轮次无法创建、任务卡死。
|
||||
行集替换等无法按行对位的场景(ValueError)保守回退冻结快照列,
|
||||
由行集有效视图特性统一承接。
|
||||
"""
|
||||
snapshot = db.session.get(ShippingOrderSnapshot, task.order_snapshot_id) if task.order_snapshot_id else None
|
||||
if snapshot is None:
|
||||
raise ValidationError('Frozen order snapshot is required', code='SHIPPING.ORDER_SNAPSHOT_REQUIRED')
|
||||
po_number = normalize_po_number(snapshot.customer_po_number).upper()
|
||||
# [BE-有效视图] 延迟导入避免与 export 的模块级循环依赖(export 反向惰性引用本模块)。
|
||||
from app.services.shipping_notice.effective_order_view import effective_line_facts_for_notice
|
||||
try:
|
||||
effective_facts = effective_line_facts_for_notice(task)
|
||||
except ValueError:
|
||||
effective_facts = {}
|
||||
registered: list[ShippingReservation] = []
|
||||
seen: set[str] = set()
|
||||
for line in snapshot.lines:
|
||||
reservation_id = validated_reservation_id(line.reservation_id)
|
||||
part_number = str(line.part_number or '').strip()
|
||||
if not reservation_id or not part_number or line.qty is None:
|
||||
eff = effective_facts.get(int(line.id)) or {}
|
||||
# 有效事实优先,None(无规则映射/值非法)回退冻结快照列。
|
||||
effective_reservation_id = eff.get('reservation_id') if eff.get('reservation_id') is not None else line.reservation_id
|
||||
effective_part_number = eff.get('part_number') if eff.get('part_number') is not None else line.part_number
|
||||
effective_qty = eff.get('qty') if eff.get('qty') is not None else line.qty
|
||||
reservation_id = validated_reservation_id(effective_reservation_id)
|
||||
part_number = str(effective_part_number or '').strip()
|
||||
if not reservation_id or not part_number or effective_qty is None:
|
||||
raise ValidationError('Reservation id, part number and quantity are required', code='SHIPPING.RESERVATION_INVALID')
|
||||
if reservation_id in seen:
|
||||
raise ConflictError('Reservation is duplicated in the frozen order', code='SHIPPING.RESERVATION_DUPLICATED_IN_ORDER')
|
||||
@@ -59,7 +80,7 @@ def ensure_task_reservations(task: ShippingOrderTask) -> list[ShippingReservatio
|
||||
if row is None:
|
||||
row = ShippingReservation(
|
||||
task_id=task.id, snapshot_line_id=line.id, reservation_id=reservation_id,
|
||||
po_number_normalized=po_number, part_number=part_number, required_qty=_decimal(line.qty), status='pending',
|
||||
po_number_normalized=po_number, part_number=part_number, required_qty=_decimal(effective_qty), status='pending',
|
||||
)
|
||||
db.session.add(row)
|
||||
elif not po_number:
|
||||
@@ -77,15 +98,16 @@ def ensure_task_reservations(task: ShippingOrderTask) -> list[ShippingReservatio
|
||||
row.task_id != task.id
|
||||
or row.snapshot_line_id != line.id
|
||||
or row.part_number != part_number
|
||||
or row.required_qty != _decimal(line.qty)
|
||||
or row.required_qty != _decimal(effective_qty)
|
||||
):
|
||||
if row.current_artifact_id is not None or row.status in {'artifact_reserved', 'uploaded'}:
|
||||
raise ConflictError('Reservation cannot be revised after export or upload', code='SHIPPING.RESERVATION_REVISION_LOCKED')
|
||||
if row.part_number != part_number or row.required_qty != _decimal(line.qty):
|
||||
if row.part_number != part_number or row.required_qty != _decimal(effective_qty):
|
||||
# 同一 OT 的确认修订复用该 OT(仅 bump order_data_version/progress_version),
|
||||
# Reservation 与审计事件仍指向该 OT,不新建任务;跨任务变更须人工复核。
|
||||
# [BE-有效视图] 编辑料号/数量后的差异在此自动完成接替,核验得以继续。
|
||||
if row.task_id == task.id:
|
||||
_transfer_confirmed_revision(row, task=task, line=line, part_number=part_number)
|
||||
_transfer_confirmed_revision(row, task=task, line=line, part_number=part_number, qty=effective_qty)
|
||||
registered.append(row)
|
||||
continue
|
||||
raise ConflictError(
|
||||
@@ -95,7 +117,7 @@ def ensure_task_reservations(task: ShippingOrderTask) -> list[ShippingReservatio
|
||||
'reservation_id': reservation_id,
|
||||
'registered_task_id': row.task_id,
|
||||
'previous': {'part_number': row.part_number, 'qty': str(row.required_qty)},
|
||||
'proposed': {'part_number': part_number, 'qty': str(_decimal(line.qty))},
|
||||
'proposed': {'part_number': part_number, 'qty': str(_decimal(effective_qty))},
|
||||
},
|
||||
)
|
||||
raise ConflictError('Reservation is already registered by another order version', code='SHIPPING.RESERVATION_ALREADY_REGISTERED')
|
||||
@@ -120,12 +142,20 @@ def _transfer_confirmed_revision(
|
||||
*, task: ShippingOrderTask,
|
||||
line: Any,
|
||||
part_number: str,
|
||||
qty: Any | None = None,
|
||||
) -> None:
|
||||
"""
|
||||
同一 OT 的已确认修订:复用该 OT(版本 bump),接替未履约 Reservation,并落 OT 级审计。
|
||||
|
||||
核心逻辑:修订不新建任务行;仅递增 ``order_data_version`` / ``progress_version``,
|
||||
Reservation 与 ShippingTaskEvent 均保持指向该 OT,避免写入 Notice id 造成错误外键。
|
||||
|
||||
Args:
|
||||
reservation: 待接替的未履约预约单。
|
||||
task: 当前归属 OT(或可解析到 OT 的任务)。
|
||||
line: 预约对应的冻结快照行(修订后 snapshot_line_id 仍指向该行)。
|
||||
part_number: 有效料号(已 strip)。
|
||||
qty: 有效数量;缺省时回退冻结行数量 ``line.qty``(供既有调用方兼容)。
|
||||
"""
|
||||
owner = _owner_task(task)
|
||||
previous = {
|
||||
@@ -140,7 +170,8 @@ def _transfer_confirmed_revision(
|
||||
reservation.task_id = owner.id
|
||||
reservation.snapshot_line_id = line.id
|
||||
reservation.part_number = part_number
|
||||
reservation.required_qty = _decimal(line.qty)
|
||||
# [BE-有效视图] 数量以有效值为准;行集替换等回退场景沿用冻结行数量。
|
||||
reservation.required_qty = _decimal(qty if qty is not None else line.qty)
|
||||
reservation.status = 'pending'
|
||||
reservation.current_artifact_id = None
|
||||
details = {
|
||||
@@ -175,11 +206,13 @@ def record_inventory_verification(
|
||||
reservation_id = validated_reservation_id(item.get('reservation_id'))
|
||||
part_number = str(item.get('part_number') or '').strip()
|
||||
reservation = by_key.get(reservation_id)
|
||||
if reservation is None or reservation.part_number != part_number:
|
||||
# [BE-有效视图] 料号比对两侧归一化(strip + upper):匹配结果与注册值可能仅存在
|
||||
# 大小写/空白差异,直接比较会造成假阳性 RESERVATION_MISMATCH 阻断核验。
|
||||
if reservation is None or str(reservation.part_number or '').strip().upper() != str(part_number or '').strip().upper():
|
||||
raise ValidationError('Inventory result does not map to a frozen reservation', code='SHIPPING.RESERVATION_MISMATCH')
|
||||
required = _decimal(item.get('required_qty'))
|
||||
# The frozen order is the quantity authority. A reduced or duplicate result
|
||||
# must not turn an insufficient reservation into an exportable line.
|
||||
# [BE-有效视图] 数量权威是按有效订单值视图注册的预约值(非冻结快照列);
|
||||
# 缩量/重复的核验结果不得把短缺行升级为可导出行。
|
||||
if reservation_id in seen_reservation_ids or required != reservation.required_qty:
|
||||
raise ValidationError('Inventory result quantity is inconsistent with the frozen reservation', code='SHIPPING.RESERVATION_MISMATCH')
|
||||
seen_reservation_ids.add(reservation_id)
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
"""
|
||||
services/shipping_notice/schema_edit_policy.py
|
||||
|
||||
用途:正式任务字段编辑策略(Schema 显式放行;无策略默认只读;Excel ready 硬冻结)。
|
||||
用途:正式任务字段编辑策略(状态制:无策略默认可写;显式 editable=False 反向锁;Excel ready 硬冻结)。
|
||||
依赖:task_order_field_editor(锁定 Schema)、ShippingExportArtifact、ConflictError;
|
||||
被 task_workflow / 复核 formal patch / 投影 formal_editable_field_ids 引用。
|
||||
逻辑:默认 editable_after_task_creation=False;仅 Schema editable=True 可写;
|
||||
Excel ready = ready Artifact 匹配路径 + 可选 order_data_version 指纹;
|
||||
change_effect 供 task_workflow 下游失效编排消费。不考虑 legacy 白名单兼容绕过。
|
||||
逻辑:默认 editable_after_task_creation=True(建单后 Excel 生成前可编辑);
|
||||
仅 Schema 显式 editable=False 反向关闭;Excel ready = ready Artifact 匹配路径 +
|
||||
可选 order_data_version 指纹;change_effect 供 task_workflow 下游失效编排消费。
|
||||
不考虑 legacy 白名单兼容绕过。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -18,8 +19,8 @@ from app.core.errors import ConflictError
|
||||
if TYPE_CHECKING:
|
||||
from app.models import ShippingNotice
|
||||
|
||||
# 默认:创建正式任务后字段不可编辑。
|
||||
DEFAULT_EDITABLE_AFTER_TASK_CREATION: Final[bool] = False
|
||||
# 默认:建单后 Excel 生成前字段可编辑(状态制);个别字段需要锁定时在 Schema 配置 editable=false 反向关闭。
|
||||
DEFAULT_EDITABLE_AFTER_TASK_CREATION: Final[bool] = True
|
||||
|
||||
# 允许的 change_effect。
|
||||
ALLOWED_CHANGE_EFFECTS: Final[frozenset[str]] = frozenset({
|
||||
@@ -36,7 +37,7 @@ _AUDIT_VALUE_MAX_CHARS: Final[int] = 256
|
||||
|
||||
def field_task_edit_policy(field_config: dict[str, Any] | None) -> dict[str, Any]:
|
||||
"""
|
||||
读取 Schema 字段上的 task_edit_policy;缺省返回安全只读策略。
|
||||
读取 Schema 字段上的 task_edit_policy;无策略时按状态制默认(Excel ready 前可写)。
|
||||
|
||||
Args:
|
||||
field_config: Schema 单字段配置。
|
||||
@@ -46,7 +47,8 @@ def field_task_edit_policy(field_config: dict[str, Any] | None) -> dict[str, Any
|
||||
"""
|
||||
raw = field_config.get('task_edit_policy') if isinstance(field_config, dict) else None
|
||||
policy = dict(raw) if isinstance(raw, dict) else {}
|
||||
editable = bool(policy.get('editable')) if policy else False
|
||||
# 无策略时初始化为全局默认开关;显式 editable=false 的反向锁优先于默认值。
|
||||
editable = bool(policy.get('editable')) if policy else DEFAULT_EDITABLE_AFTER_TASK_CREATION
|
||||
if not DEFAULT_EDITABLE_AFTER_TASK_CREATION and 'editable' not in policy:
|
||||
editable = False
|
||||
effect = str(policy.get('change_effect') or 'none').strip() or 'none'
|
||||
@@ -98,7 +100,8 @@ def is_field_editable_for_formal_task(
|
||||
"""
|
||||
判断正式任务下该字段是否可编辑。
|
||||
|
||||
核心逻辑:Excel ready 时一律不可编辑;否则必须 Schema 显式 editable=True;
|
||||
核心逻辑:Excel ready 时一律不可编辑;否则按状态制默认可写,
|
||||
仅 Schema 显式 editable=False 反向关闭;
|
||||
若 editable_until=excel_ready 且 Excel 已就绪则关闭(与全局冻结一致)。
|
||||
|
||||
Args:
|
||||
@@ -182,7 +185,7 @@ def is_formal_field_code_editable(
|
||||
"""
|
||||
判断正式任务下 field_code 是否允许写入。
|
||||
|
||||
核心逻辑:仅 Schema 显式 editable=True 且未 Excel 冻结时放行;无 legacy 白名单。
|
||||
核心逻辑:未 Excel 冻结时按状态制默认放行,仅 Schema 显式 editable=False 反向关闭;无 legacy 白名单。
|
||||
|
||||
Args:
|
||||
task: 目标 ShippingNotice。
|
||||
|
||||
@@ -9,6 +9,7 @@ services/shipping_notice/task_order_field_editor.py
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import date
|
||||
from decimal import Decimal, InvalidOperation
|
||||
from typing import Any
|
||||
|
||||
@@ -177,6 +178,19 @@ def _normalized_value(value: Any, config: dict[str, Any]) -> Any:
|
||||
return str(value).strip()
|
||||
|
||||
|
||||
def _json_value(value: Any) -> Any:
|
||||
"""把人工输入转为 JSON 列可序列化形状;与 order_schema.runtime._json_value 对齐。
|
||||
|
||||
核心逻辑:Decimal → format(normalize, 'f') 字符串(保留精度且 json.dumps 可序列化),
|
||||
date → isoformat;其余原样。类型化列(value_decimal 等)仍保存原生值。
|
||||
"""
|
||||
if isinstance(value, Decimal):
|
||||
return format(value.normalize(), 'f')
|
||||
if isinstance(value, date):
|
||||
return value.isoformat()
|
||||
return value
|
||||
|
||||
|
||||
def _field_value_columns(value: Any, value_type: str) -> dict[str, Any]:
|
||||
"""生成唯一 FieldValue 的类型化列,JSON 值始终作为下游读取的统一入口。"""
|
||||
return {
|
||||
@@ -185,7 +199,7 @@ def _field_value_columns(value: Any, value_type: str) -> dict[str, Any]:
|
||||
'value_integer': value if value_type == 'integer' else None,
|
||||
'value_date': value if value_type == 'date' else None,
|
||||
'value_boolean': value if value_type == 'boolean' else None,
|
||||
'value_json': value,
|
||||
'value_json': _json_value(value),
|
||||
}
|
||||
|
||||
|
||||
@@ -222,7 +236,7 @@ def replace_current_line_field_value(*, task: ShippingNotice, position: int, fie
|
||||
raise ConflictError('Order field decision is unavailable', code='SHIPPING.ORDER_FIELD_EDIT_BLOCKED')
|
||||
# 人工复核后的值成为当前决策真相,保留原 Observation 与冲突审计链。
|
||||
decision.decision_status = 'accepted'
|
||||
decision.resolved_value_json = normalized
|
||||
decision.resolved_value_json = _json_value(normalized)
|
||||
columns = _field_value_columns(normalized, str(config.get('value_type') or 'string'))
|
||||
if field_value is None:
|
||||
field_value = ShippingOrderFieldValue(
|
||||
@@ -264,7 +278,7 @@ def replace_current_header_field_value(*, task: ShippingNotice, field_code: str,
|
||||
if decision is None:
|
||||
raise ConflictError('Order header decision is unavailable', code='SHIPPING.ORDER_FIELD_EDIT_BLOCKED')
|
||||
decision.decision_status = 'accepted'
|
||||
decision.resolved_value_json = normalized
|
||||
decision.resolved_value_json = _json_value(normalized)
|
||||
columns = _field_value_columns(normalized, str(config.get('value_type') or 'string'))
|
||||
if field_value is None:
|
||||
db.session.add(ShippingOrderFieldValue(
|
||||
@@ -349,7 +363,7 @@ def replace_current_line_fields(*, task: ShippingNotice, lines: list[dict[str, A
|
||||
line_id=line.id,
|
||||
field_id=str(config['field_id']),
|
||||
decision_status='accepted' if value is not None else 'missing',
|
||||
resolved_value_json=value,
|
||||
resolved_value_json=_json_value(value),
|
||||
supporting_observation_ids_json=[],
|
||||
reason_code='human_line_set' if value is not None else 'missing',
|
||||
)
|
||||
|
||||
@@ -920,7 +920,8 @@ def _commit_notice_edit(
|
||||
reviewed_by_id = review_context.get('reviewed_by_id')
|
||||
evidence_ref = str(review_context.get('evidence_ref') or '')
|
||||
reason = str(review_context.get('reason') or '')
|
||||
if not reviewed_by_id or not evidence_ref or not reason:
|
||||
# 仅操作人身份是审计底线;reason/evidence_ref 已由 _prepare_review_context 哨兵兜底。
|
||||
if not reviewed_by_id:
|
||||
raise ConflictError('Review evidence is required', code='SHIPPING.ORDER_REVIEW_EVIDENCE_REQUIRED')
|
||||
# [STEP 1] 人工编辑后的业务值拥有最终优先级,但仍必须通过同一流程字段契约。
|
||||
order_task = _resolve_order_task_for_notice(task)
|
||||
@@ -1029,7 +1030,7 @@ def _commit_notice_edit(
|
||||
|
||||
|
||||
def _prepare_review_context(task: ShippingNotice, payload: dict[str, Any]) -> tuple[dict[str, Any] | None, dict[str, Any] | None]:
|
||||
"""校验正式编辑的操作者、证据和原因;Excel ready 后拒绝写入。"""
|
||||
"""校验正式编辑的操作者身份;reason/evidence 可缺省并落哨兵值;Excel ready 后拒绝写入。"""
|
||||
from app.services.shipping_notice.schema_edit_policy import assert_formal_task_not_excel_frozen
|
||||
|
||||
try:
|
||||
@@ -1050,14 +1051,18 @@ def _prepare_review_context(task: ShippingNotice, payload: dict[str, Any]) -> tu
|
||||
actor_id = int(payload.get('reviewed_by_id'))
|
||||
except (TypeError, ValueError):
|
||||
return None, tool_response(status='failed', task=task, message='缺少复核人员', data={'error_code': 'SHIPPING.ORDER_REVIEW_EVIDENCE_REQUIRED'})
|
||||
reason = str(payload.get('reason') or payload.get('comment') or '').strip()
|
||||
if not reason:
|
||||
return None, tool_response(status='failed', task=task, message='人工纠错必须提供证据和原因', data={'error_code': 'SHIPPING.ORDER_REVIEW_EVIDENCE_REQUIRED'})
|
||||
# 快捷就地编辑不强制填写原因/证据:审计链自动记录 old→new + 操作人 + 时间;
|
||||
# 提供了证据时仍走原校验。哨兵值满足 shipping_order_review_events 的 NOT NULL 列。
|
||||
reason = str(payload.get('reason') or payload.get('comment') or '').strip() or 'quick_field_edit'
|
||||
from app.services.shipping_notice.review_evidence_service import validate_review_evidence
|
||||
try:
|
||||
evidence_ref = validate_review_evidence(task=task, evidence=payload.get('evidence'), reason=reason)
|
||||
except ValidationError as exc:
|
||||
return None, tool_response(status='failed', task=task, message='人工纠错证据无效', data={'error_code': exc.code})
|
||||
evidence = payload.get('evidence') or None
|
||||
if evidence is not None:
|
||||
try:
|
||||
evidence_ref = validate_review_evidence(task=task, evidence=evidence, reason=reason)
|
||||
except ValidationError as exc:
|
||||
return None, tool_response(status='failed', task=task, message='人工纠错证据无效', data={'error_code': exc.code})
|
||||
else:
|
||||
evidence_ref = 'inline:match-table'
|
||||
return {'reviewed_by_id': actor_id, 'evidence_ref': evidence_ref, 'reason': reason}, None
|
||||
|
||||
|
||||
|
||||
@@ -11,7 +11,9 @@ services/shipping_notice/ui_state.py
|
||||
Gate 摘要经 Notice.order_task_id→OT 查 Execution(禁止用 Notice.id);
|
||||
五阶段 processing_stage 同样经 Notice→OT.stage(Notice 无 stage 列),
|
||||
禁止仅靠 Gate 兜底把 order_freeze 误映射为订单复核;
|
||||
stage_context.preparation 以 Snapshot 行 + 当前 Match 投影(Notice 经 order_task_id→OT),
|
||||
stage_context.preparation 值列(预约号/料号/需求数量)有效值优先(快照 + 已接受修正,
|
||||
经 effective_line_facts_for_notice),无有效值时回退快照列;匹配结果列仍以 Snapshot 行
|
||||
+ 当前 Match 投影诚实反映最近一轮(Notice 经 order_task_id→OT),
|
||||
行级拆 selected_source_code(CandidateSet 取数目标)与 source_code(Match 正式源);
|
||||
短缺行复用放行模板字段;匹配成功无短缺下发 can_fulfill_complete_line;
|
||||
下发 source_options 与 capabilities(阶段能力,供右卡点击 stageCapabilityBypass);
|
||||
@@ -830,6 +832,7 @@ def _build_stage_context(
|
||||
_shortage_release_required_fields,
|
||||
)
|
||||
from app.services.shipping_notice.upload_attempt_service import latest_export_artifact
|
||||
from app.services.shipping_notice.effective_order_view import effective_line_facts_for_notice
|
||||
|
||||
facts = stp_facts if isinstance(stp_facts, dict) else {}
|
||||
# [STEP 1] Snapshot/Match/Candidate 归属 OT;Notice 详情入口必须经 order_task_id 解析,
|
||||
@@ -846,6 +849,19 @@ def _build_stage_context(
|
||||
if snapshot is not None else []
|
||||
)
|
||||
match_by_snapshot_line_id = load_current_match_facts_by_task(getattr(order_task, 'id', None))
|
||||
# [BE-有效视图] 值列消费有效订单值(快照 + 已接受修正):保存即显新值,
|
||||
# 匹配结果列仍读当前匹配事实,诚实反映最近一轮匹配结论。
|
||||
# 全循环只算一次,行内按 snapshot_line_id 取用;无冻结快照(如未绑定 OT 的 Notice)
|
||||
# 保持空映射,行级回退快照列。有效视图解析失败(如历史/合成数据缺 Schema 版本)
|
||||
# 与 ODM 投影同款降级:不阻断工作台渲染,值列退回快照列(此时有效值=快照值)。
|
||||
effective_facts: dict[int, dict[str, Any]] = {}
|
||||
if order_task is not None and getattr(order_task, 'order_snapshot_id', None):
|
||||
try:
|
||||
effective_facts = effective_line_facts_for_notice(order_task)
|
||||
except Exception: # 遗留/合成快照缺 Schema 版本等:回退冻结列展示
|
||||
from flask import current_app
|
||||
current_app.logger.warning('effective order view resolution failed; falling back to frozen columns', exc_info=True)
|
||||
effective_facts = {}
|
||||
# [STEP] 与 Case 投影同源:库存 RPA 运行态只查一次 Attempt(请求内 memo),再传入各行纯函数。
|
||||
inventory_rpa_running = inventory_rpa_is_running(order_task)
|
||||
candidate_codes_by_line_no: dict[int, list[str]] = {}
|
||||
@@ -869,17 +885,38 @@ def _build_stage_context(
|
||||
for snapshot_line in snapshot_lines:
|
||||
qty_text = str(snapshot_line.qty) if snapshot_line.qty is not None else None
|
||||
line_no = int(snapshot_line.line_no) if snapshot_line.line_no is not None else None
|
||||
# [BE-有效视图] 冻结订单行值列有效值优先(预约号/料号/需求数量):行内按
|
||||
# snapshot_line_id 取有效事实,取不到(None)时回退冻结快照列;键名与前端
|
||||
# 契约稳定不动(shipping.api.types.ts ShippingOrderFrozenLine)。
|
||||
eff = effective_facts.get(int(snapshot_line.id)) or {}
|
||||
frozen_order_lines.append({
|
||||
'snapshot_line_id': int(snapshot_line.id),
|
||||
'line_no': line_no,
|
||||
'reservation_id': snapshot_line.reservation_id,
|
||||
'part_number': snapshot_line.part_number,
|
||||
'required_qty': qty_text,
|
||||
'reservation_id': eff.get('reservation_id') if eff.get('reservation_id') is not None else snapshot_line.reservation_id,
|
||||
'part_number': eff.get('part_number') if eff.get('part_number') is not None else snapshot_line.part_number,
|
||||
'required_qty': str(eff['qty']) if eff.get('qty') is not None else qty_text,
|
||||
})
|
||||
fact = match_by_snapshot_line_id.get(int(snapshot_line.id))
|
||||
required_qty = (fact or {}).get('required_qty')
|
||||
# [BE-有效视图] 需求数量:有效事实 → 匹配事实 → 快照列(Decimal 需 str 化)。
|
||||
required_qty = (
|
||||
str(eff['qty'])
|
||||
if eff.get('qty') is not None
|
||||
else (fact or {}).get('required_qty')
|
||||
)
|
||||
if required_qty is None:
|
||||
required_qty = qty_text
|
||||
# [BE-有效视图] 预约号/料号:有效事实 → 匹配事实 → 快照列;保存修正后即使
|
||||
# 匹配事实未刷新,prep 覆盖合并也立即显示新值。
|
||||
reservation_id_value = (
|
||||
eff.get('reservation_id')
|
||||
if eff.get('reservation_id') is not None
|
||||
else (fact or {}).get('reservation_id') or snapshot_line.reservation_id
|
||||
)
|
||||
part_number_value = (
|
||||
eff.get('part_number')
|
||||
if eff.get('part_number') is not None
|
||||
else (fact or {}).get('part_number') or snapshot_line.part_number
|
||||
)
|
||||
inv_view = project_line_inventory_view(
|
||||
has_formal_ot=has_formal_ot,
|
||||
fact=fact,
|
||||
@@ -934,8 +971,8 @@ def _build_stage_context(
|
||||
field_id_by_code,
|
||||
'customer_po_line_no',
|
||||
),
|
||||
'reservation_id': (fact or {}).get('reservation_id') or snapshot_line.reservation_id,
|
||||
'part_number': (fact or {}).get('part_number') or snapshot_line.part_number,
|
||||
'reservation_id': reservation_id_value,
|
||||
'part_number': part_number_value,
|
||||
'required_qty': required_qty,
|
||||
'available_qty': inv_view.get('available_qty'),
|
||||
'shortage_qty': inv_view.get('shortage_qty'),
|
||||
|
||||
@@ -130,8 +130,8 @@ def test_line_set_replacement_skips_line_overlay(app):
|
||||
"""整行替换后 position 不再可比:行级叠加保守跳过,返回冻结行值。"""
|
||||
with app.app_context():
|
||||
fixture = _seed_frozen_order()
|
||||
# 注:替换行不带 qty——编辑服务会把 decimal 字段归一为 Decimal 写入 JSON 列(SQLite/PG
|
||||
# 默认 json.dumps 均不可序列化),此既有路径与本测试的行集替换守卫无关,故省略。
|
||||
# 注:替换行不带 qty——本测试只验证行集替换守卫;decimal 经整行替换路径的可持久化
|
||||
# 已由 test_line_set_replacement_with_decimal_persists_without_json_error 单独覆盖。
|
||||
replace_current_line_fields(task=fixture.order, lines=[
|
||||
{'part_number': 'D4-A08AR12000002', 'reservation_id': 'RSV-1'},
|
||||
])
|
||||
@@ -156,6 +156,48 @@ def test_effective_line_facts_for_notice(app):
|
||||
assert first['field_values']['f-rsv'] == 'RSV-1'
|
||||
|
||||
|
||||
def test_decimal_edit_persists_without_json_error(app):
|
||||
"""数量(decimal 字段)人工编辑必须可持久化:value_json 存字符串、value_decimal 存 Decimal。"""
|
||||
with app.app_context():
|
||||
fixture = _seed_frozen_order()
|
||||
replace_current_line_field_value(
|
||||
task=fixture.order, position=0, field_code='qty', value='12.5',
|
||||
)
|
||||
rows = [
|
||||
item for item in ShippingOrderFieldValue.query.filter_by(
|
||||
extraction_id=fixture.extraction.id,
|
||||
).all()
|
||||
if item.value_json is not None
|
||||
]
|
||||
# 夹具两行均预置了 f-qty FieldValue(未编辑行 value_json='10'),须限定被编辑的第 0 行再断言。
|
||||
edited_line = ShippingOrderLine.query.filter_by(
|
||||
extraction_id=fixture.extraction.id, position=0,
|
||||
).one()
|
||||
qty_rows = [item for item in rows if item.field_id == 'f-qty' and item.line_id == edited_line.id]
|
||||
# 断言:JSON 列存规范字符串(与机器路径 _json_value 对齐),类型列保留 Decimal。
|
||||
assert qty_rows, 'qty FieldValue 必须存在'
|
||||
assert all(item.value_json == '12.5' for item in qty_rows)
|
||||
assert any(item.value_decimal == Decimal('12.5') for item in qty_rows)
|
||||
|
||||
|
||||
def test_line_set_replacement_with_decimal_persists_without_json_error(app):
|
||||
"""整行替换带 decimal 字段必须同样可持久化:新当前 Extraction 的 qty JSON 列存字符串、类型列存 Decimal。"""
|
||||
with app.app_context():
|
||||
fixture = _seed_frozen_order()
|
||||
replace_current_line_fields(task=fixture.order, lines=[
|
||||
{'part_number': 'D4-A08AR12000002', 'reservation_id': 'RSV-1', 'qty': '12.5'},
|
||||
])
|
||||
rows = ShippingOrderFieldValue.query.filter_by(
|
||||
extraction_id=fixture.order.current_order_extraction_id,
|
||||
field_id='f-qty',
|
||||
).all()
|
||||
line_qty_rows = [item for item in rows if item.line_id is not None]
|
||||
# 断言:整行替换路径的 Decision/FieldValue 均经 _json_value 落库且不得抛序列化错误。
|
||||
assert line_qty_rows, '替换行集的 qty FieldValue 必须存在'
|
||||
assert all(item.value_json == '12.5' for item in line_qty_rows)
|
||||
assert all(item.value_decimal == Decimal('12.5') for item in line_qty_rows)
|
||||
|
||||
|
||||
def test_matching_purpose_values_use_effective_view(app):
|
||||
"""库存匹配用途投影必须读到修正后的料号(修复改值不进匹配的断层)。"""
|
||||
with app.app_context():
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
"""
|
||||
tests/test_reservation_effective_view.py
|
||||
|
||||
用途:验证预约注册与核验比对消费「冻结快照 + 已接受人工修正」的有效订单值视图
|
||||
(修复编辑料号/数量后核验必抛 SHIPPING.RESERVATION_MISMATCH 的阻断缺陷)。
|
||||
依赖:pytest、reservation_service、task_order_field_editor、test_effective_order_view 夹具。
|
||||
逻辑:先按冻结值注册预约 → 就地编辑料号/数量 → 再次 ensure 应走同 OT 确认修订
|
||||
(transfer,自动接替未履约预约)而非抛错;核验比对按归一化料号匹配有效值。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from decimal import Decimal
|
||||
|
||||
import pytest
|
||||
|
||||
from app import db
|
||||
from app.core.errors import ConflictError, ValidationError
|
||||
from app.models import (
|
||||
ShippingOrderFieldDecision,
|
||||
ShippingOrderFieldValue,
|
||||
ShippingOrderLine,
|
||||
ShippingReservation,
|
||||
)
|
||||
from app.services.shipping_notice.reservation_service import (
|
||||
ensure_task_reservations,
|
||||
record_inventory_verification,
|
||||
)
|
||||
from app.services.shipping_notice.task_order_field_editor import replace_current_line_field_value
|
||||
from tests.test_effective_order_view import _seed_frozen_order
|
||||
|
||||
|
||||
# 预约层契约只接受 5/10 位纯数字预约号(validated_reservation_id);夹具的 'RSV-*'
|
||||
# 为占位值,须补成契约内值才能驱动预约注册,同时补 PO 以支撑二次注册的归属校验。
|
||||
_NUMERIC_RESERVATION_IDS = ('1234567890', '2234567890')
|
||||
|
||||
|
||||
def _seed_frozen_order_for_reservations():
|
||||
"""复用有效视图夹具并补齐预约层契约值:纯数字预约号 + 单头 PO。"""
|
||||
fixture = _seed_frozen_order()
|
||||
for snap_line, reservation_id in zip(fixture.snap_lines, _NUMERIC_RESERVATION_IDS):
|
||||
snap_line.reservation_id = reservation_id
|
||||
fixture.snapshot.customer_po_number = 'PO-0001'
|
||||
order_lines = ShippingOrderLine.query.filter_by(
|
||||
extraction_id=fixture.extraction.id,
|
||||
).order_by(ShippingOrderLine.position).all()
|
||||
for line, reservation_id in zip(order_lines, _NUMERIC_RESERVATION_IDS):
|
||||
for item in ShippingOrderFieldValue.query.filter_by(
|
||||
extraction_id=fixture.extraction.id, line_id=line.id, field_id='f-rsv',
|
||||
).all():
|
||||
item.value_text = reservation_id
|
||||
item.value_json = reservation_id
|
||||
for item in ShippingOrderFieldDecision.query.filter_by(
|
||||
extraction_id=fixture.extraction.id, line_id=line.id, field_id='f-rsv',
|
||||
).all():
|
||||
item.resolved_value_json = reservation_id
|
||||
db.session.flush()
|
||||
return fixture
|
||||
|
||||
|
||||
def _registered_reservation(fixture, index: int = 0) -> ShippingReservation:
|
||||
"""按夹具第 index 行的预约号取全局预约注册行。"""
|
||||
return ShippingReservation.query.filter_by(
|
||||
task_id=fixture.order.id, reservation_id=_NUMERIC_RESERVATION_IDS[index],
|
||||
).one()
|
||||
|
||||
|
||||
def test_ensure_task_reservations_follows_effective_values(app):
|
||||
"""预约注册必须消费有效值:编辑料号后再次 ensure 应自动修订(transfer)而非校验失败。"""
|
||||
with app.app_context():
|
||||
fixture = _seed_frozen_order_for_reservations()
|
||||
# 第一次注册:按冻结值(带尾巴的旧料号)建预约。
|
||||
ensure_task_reservations(fixture.order)
|
||||
reservation = _registered_reservation(fixture)
|
||||
# 断言:初始注册值为冻结快照列原值。
|
||||
assert reservation.part_number == 'D4-A08AR12000002-'
|
||||
# 就地编辑第 0 行料号为正确值。
|
||||
replace_current_line_field_value(
|
||||
task=fixture.order, position=0, field_code='part_number', value='D4-A08AR12000002',
|
||||
)
|
||||
# 第二次 ensure(重匹配核验前的真实调用时序):必须成功且预约更新为有效值。
|
||||
ensure_task_reservations(fixture.order)
|
||||
db.session.refresh(reservation)
|
||||
# 断言:预约料号已随有效值修订,状态回 pending(可重新核验)。
|
||||
assert reservation.part_number == 'D4-A08AR12000002'
|
||||
assert reservation.status == 'pending'
|
||||
# 断言:修订走同 OT 确认修订路径,落 reservation_revision_confirmed 审计事件。
|
||||
assert any(
|
||||
event.event_type == 'reservation_revision_confirmed'
|
||||
for event in fixture.order.events
|
||||
)
|
||||
|
||||
|
||||
def test_ensure_task_reservations_revises_required_qty_from_effective_value(app):
|
||||
"""编辑数量后再次 ensure 必须按有效数量修订预约,而非保持冻结数量。"""
|
||||
with app.app_context():
|
||||
fixture = _seed_frozen_order_for_reservations()
|
||||
ensure_task_reservations(fixture.order)
|
||||
reservation = _registered_reservation(fixture)
|
||||
# 断言:初始注册数量为冻结值 10。
|
||||
assert reservation.required_qty == Decimal('10')
|
||||
replace_current_line_field_value(
|
||||
task=fixture.order, position=0, field_code='qty', value='15',
|
||||
)
|
||||
ensure_task_reservations(fixture.order)
|
||||
db.session.refresh(reservation)
|
||||
# 断言:需求数量已随有效值修订为 15,且版本在原 OT 上递增(不新建任务)。
|
||||
# order_data_version 经历两次 bump:编辑器写修正 +1,确认修订接替 +1。
|
||||
assert reservation.required_qty == Decimal('15')
|
||||
assert reservation.status == 'pending'
|
||||
assert fixture.order.order_data_version == 3
|
||||
assert fixture.order.progress_version == 2
|
||||
|
||||
|
||||
def test_record_inventory_verification_maps_effective_part_number(app):
|
||||
"""编辑料号后的库存核验必须能按有效料号(归一化后)映射预约,不再抛 RESERVATION_MISMATCH。"""
|
||||
with app.app_context():
|
||||
fixture = _seed_frozen_order_for_reservations()
|
||||
ensure_task_reservations(fixture.order)
|
||||
replace_current_line_field_value(
|
||||
task=fixture.order, position=0, field_code='part_number', value='D4-A08AR12000002',
|
||||
)
|
||||
# 模拟重匹配写入的有效值事实:第 0 行料号带大小写/空白差异(归一化后应相等)。
|
||||
verification = record_inventory_verification(
|
||||
fixture.order, inventory_snapshot_id=None, source_config_version='v1',
|
||||
line_results=[
|
||||
{
|
||||
'reservation_id': '1234567890', 'part_number': ' d4-a08ar12000002 ',
|
||||
'required_qty': Decimal('10'), 'available_qty': Decimal('10'), 'line_status': 'ok',
|
||||
},
|
||||
{
|
||||
'reservation_id': '2234567890', 'part_number': 'D4-B07BR07000001',
|
||||
'required_qty': Decimal('10'), 'available_qty': Decimal('10'), 'line_status': 'ok',
|
||||
},
|
||||
],
|
||||
)
|
||||
# 断言:核验轮次成功创建,修订后的预约按有效值完整满足并转 available。
|
||||
assert verification.lines[0].status == 'available'
|
||||
assert verification.result_json['available_count'] == 2
|
||||
|
||||
|
||||
def test_locked_reservation_still_rejects_effective_revision(app):
|
||||
"""已占用/已上传的预约不受有效值自动修订影响:保留 RESERVATION_REVISION_LOCKED 拒绝。"""
|
||||
with app.app_context():
|
||||
fixture = _seed_frozen_order_for_reservations()
|
||||
ensure_task_reservations(fixture.order)
|
||||
reservation = _registered_reservation(fixture)
|
||||
reservation.status = 'artifact_reserved'
|
||||
db.session.flush()
|
||||
replace_current_line_field_value(
|
||||
task=fixture.order, position=0, field_code='part_number', value='D4-A08AR12000002',
|
||||
)
|
||||
# 断言:带 Artifact 锁的预约不得自动修订,必须走人工复核。
|
||||
with pytest.raises(ConflictError) as locked:
|
||||
ensure_task_reservations(fixture.order)
|
||||
assert locked.value.code == 'SHIPPING.RESERVATION_REVISION_LOCKED'
|
||||
db.session.refresh(reservation)
|
||||
# 断言:预约料号保持注册原值,未被静默改写。
|
||||
assert reservation.part_number == 'D4-A08AR12000002-'
|
||||
@@ -0,0 +1,46 @@
|
||||
"""
|
||||
tests/test_review_line_fulfillment_shortage_projection.py
|
||||
|
||||
用途:锁定行级履约投影的匹配事实关联(修复草稿行ID vs 快照行ID 键错位)。
|
||||
依赖:pytest、order_review_fulfillment_decision_service、有效视图夹具。
|
||||
逻辑:确认 Case + 短缺匹配事实下,投影必须报 has_shortage=True 且行级 is_shortage=True。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app import db
|
||||
from app.models import ShippingNoticeLineInventoryMatch, ShippingOrderReviewCase, ShippingOrderReviewDraft
|
||||
from app.services.shipping_notice.order_review_fulfillment_decision_service import (
|
||||
project_review_case_line_decisions,
|
||||
)
|
||||
from tests.test_effective_order_view import _seed_frozen_order
|
||||
|
||||
|
||||
def test_line_fulfillment_has_shortage_with_match_facts(app):
|
||||
"""修复键错位:草稿行经 _line_index 关联匹配事实,has_shortage 必须为真。"""
|
||||
with app.app_context():
|
||||
fixture = _seed_frozen_order()
|
||||
# 短缺事实:第 0 行 not_found、缺 10。
|
||||
db.session.add(ShippingNoticeLineInventoryMatch(
|
||||
task_id=fixture.order.id, snapshot_line_id=fixture.snap_lines[0].id,
|
||||
line_no=1, line_index=0, match_result='not_found', inventory_status='ready',
|
||||
required_qty='10', available_qty='0', shortage_qty='10',
|
||||
reservation_id='RSV-1', part_number='D4-A08AR12000002-', is_current=True,
|
||||
))
|
||||
case = ShippingOrderReviewCase(
|
||||
case_no='SNRC-SHORTAGE-PROJ', run_id=911, unit_id=912, document_id=913,
|
||||
owner_user_id=fixture.user.id, status='confirmed', confirmed_task_id=fixture.order.id,
|
||||
)
|
||||
db.session.add(case)
|
||||
db.session.flush()
|
||||
db.session.add(ShippingOrderReviewDraft(
|
||||
case_id=case.id, draft_version=1, schema_version_id=fixture.snapshot.schema_version_id,
|
||||
header_values_json={}, lines_json=[{'draft_line_id': 'line-1', 'part_number': 'D4-A08AR12000002-'}],
|
||||
))
|
||||
db.session.flush()
|
||||
case.current_draft_id = case.drafts[0].id if case.drafts else None
|
||||
db.session.flush()
|
||||
result = project_review_case_line_decisions(case)
|
||||
# 断言:修复前 has_shortage 恒 False(键错位);修复后为 True。
|
||||
assert result['has_shortage'] is True
|
||||
assert result['lines'][0]['is_shortage'] is True
|
||||
@@ -1,22 +1,28 @@
|
||||
"""
|
||||
backend/tests/test_shipping_formal_task_edit_audit.py
|
||||
|
||||
用途:验收正式任务编辑成功/拒绝与 change_effect 失效写入 ShippingAuditEvent。
|
||||
用途:验收正式任务编辑成功审计、反向锁拒绝审计与 change_effect 失效写入 ShippingAuditEvent。
|
||||
依赖:task_workflow、ShippingAuditEvent、test_shipping_review_formal_task_edit 种子助手。
|
||||
逻辑:editable 拒绝写 formal_task_edit_rejected;inventory 失效写
|
||||
formal_task_field_edited + inventory_match_invalidated + excel_export_invalidated。
|
||||
逻辑:未配置策略字段编辑成功写 formal_task_field_edited(old→new;reason/evidence 缺省落哨兵值);
|
||||
显式 editable=False 反向锁仍拒绝并写 formal_task_edit_rejected;Excel ready 冻结仍拒绝;
|
||||
inventory 失效写 formal_task_field_edited + inventory_match_invalidated + excel_export_invalidated。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app import db
|
||||
from app.models import ShippingAuditEvent, ShippingNoticeLineInventoryMatch
|
||||
from app.models import (
|
||||
ShippingAuditEvent,
|
||||
ShippingNoticeLineInventoryMatch,
|
||||
ShippingOrderReviewEvent,
|
||||
)
|
||||
from app.services.shipping_notice.progress_audit_contract import FORMAL_TASK_EDIT_AUDIT_EVENT_TYPES
|
||||
from app.services.shipping_notice.task_workflow import update_notice_line
|
||||
from tests.test_shipping_review_formal_task_edit import (
|
||||
_attach_extraction,
|
||||
_link_order_task,
|
||||
_review_payload,
|
||||
_seed_ready_export_artifact,
|
||||
_task,
|
||||
)
|
||||
|
||||
@@ -31,10 +37,75 @@ def test_formal_task_edit_audit_event_types_frozen():
|
||||
})
|
||||
|
||||
|
||||
def test_formal_edit_rejection_writes_audit_event(app):
|
||||
"""Schema 禁止编辑时仍落 formal_task_edit_rejected,可被审计中心检索。"""
|
||||
def test_unconfigured_field_edit_writes_formal_task_edited_audit(app):
|
||||
"""新契约:未配置策略字段编辑成功,写 formal_task_field_edited(old→new 可检索)。"""
|
||||
with app.app_context():
|
||||
task = _task(task_no='SN-FORMAL-AUDIT-REJ-001')
|
||||
task = _task(task_no='SN-FORMAL-AUDIT-EDIT-001')
|
||||
_attach_extraction(
|
||||
task,
|
||||
[{'part_number': 'A001', 'qty': 10, 'reservation_id': '3000000001'}],
|
||||
)
|
||||
db.session.commit()
|
||||
|
||||
response = update_notice_line({
|
||||
'task_no': task.task_no,
|
||||
'line_index': 0,
|
||||
'patch': {'reservation_id': '3000092917'},
|
||||
**_review_payload(),
|
||||
})
|
||||
assert response['status'] == 'ok'
|
||||
|
||||
edited = (
|
||||
ShippingAuditEvent.query
|
||||
.filter_by(task_no=task.task_no, event_type='formal_task_field_edited')
|
||||
.one()
|
||||
)
|
||||
assert edited.result == 'success'
|
||||
meta = edited.metadata_json or {}
|
||||
field_changes = meta.get('field_changes') or []
|
||||
assert field_changes
|
||||
assert field_changes[0]['previous_value'] == '3000000001'
|
||||
assert field_changes[0]['new_value'] == '3000092917'
|
||||
|
||||
|
||||
def test_quick_edit_without_reason_evidence_uses_sentinel_audit_values(app):
|
||||
"""新契约:reason/evidence 缺省时编辑成功,审计落哨兵值(NOT NULL 审计列不破坏)。"""
|
||||
with app.app_context():
|
||||
task = _task(task_no='SN-FORMAL-AUDIT-SENTINEL-001')
|
||||
_attach_extraction(
|
||||
task,
|
||||
[{'part_number': 'A001', 'qty': 10, 'reservation_id': '3000000001'}],
|
||||
)
|
||||
db.session.commit()
|
||||
|
||||
response = update_notice_line({
|
||||
'task_no': task.task_no,
|
||||
'line_index': 0,
|
||||
'patch': {'reservation_id': '3000092917'},
|
||||
'event_source': 'workspace_api',
|
||||
'reviewed_by_id': 1,
|
||||
'expected_order_data_version': 1,
|
||||
})
|
||||
assert response['status'] == 'ok'
|
||||
|
||||
edited = (
|
||||
ShippingAuditEvent.query
|
||||
.filter_by(task_no=task.task_no, event_type='formal_task_field_edited')
|
||||
.one()
|
||||
)
|
||||
assert edited.result == 'success'
|
||||
assert (edited.metadata_json or {}).get('evidence_ref') == 'inline:match-table'
|
||||
|
||||
event = ShippingOrderReviewEvent.query.filter_by(task_id=task.id).one()
|
||||
assert event.evidence_ref == 'inline:match-table'
|
||||
assert event.reason == 'quick_field_edit'
|
||||
assert int(event.reviewed_by_id) == 1
|
||||
|
||||
|
||||
def test_explicit_readonly_field_still_rejected_with_audit(app):
|
||||
"""状态制下显式 editable=false 仍为反向锁:拒绝写入并落 formal_task_edit_rejected 审计。"""
|
||||
with app.app_context():
|
||||
task = _task(task_no='SN-FORMAL-AUDIT-RELOCK-001')
|
||||
_attach_extraction(
|
||||
task,
|
||||
[{'part_number': 'A001', 'qty': 10, 'reservation_id': '3000000001'}],
|
||||
@@ -50,6 +121,9 @@ def test_formal_edit_rejection_writes_audit_event(app):
|
||||
})
|
||||
assert response['status'] == 'failed'
|
||||
assert response['data']['error_code'] == 'SHIPPING.ORDER_FIELD_EDIT_FORBIDDEN'
|
||||
# Excel 未 ready(无冻结),拒绝必须来自策略反向锁而非冻结门。
|
||||
from app.services.shipping_notice.schema_edit_policy import is_excel_ready_for_task
|
||||
assert is_excel_ready_for_task(task) is False
|
||||
|
||||
events = (
|
||||
ShippingAuditEvent.query
|
||||
@@ -59,6 +133,36 @@ def test_formal_edit_rejection_writes_audit_event(app):
|
||||
assert len(events) == 1
|
||||
assert events[0].result == 'rejected'
|
||||
assert events[0].error_code == 'SHIPPING.ORDER_FIELD_EDIT_FORBIDDEN'
|
||||
meta = events[0].metadata_json or {}
|
||||
assert meta.get('scope') == 'line'
|
||||
assert meta.get('field_codes') == ['reservation_id']
|
||||
|
||||
|
||||
def test_excel_ready_freeze_still_rejects_edit(app):
|
||||
"""Excel ready(ready Artifact)后全局冻结仍拒绝编辑,即使字段处于默认可编辑状态。"""
|
||||
with app.app_context():
|
||||
task = _task(task_no='SN-FORMAL-AUDIT-FROZEN-001')
|
||||
_attach_extraction(
|
||||
task,
|
||||
[{'part_number': 'A001', 'qty': 10, 'reservation_id': '3000000001'}],
|
||||
)
|
||||
_seed_ready_export_artifact(task)
|
||||
db.session.commit()
|
||||
|
||||
response = update_notice_line({
|
||||
'task_no': task.task_no,
|
||||
'line_index': 0,
|
||||
'patch': {'reservation_id': '3000092917'},
|
||||
**_review_payload(),
|
||||
})
|
||||
assert response['status'] == 'failed'
|
||||
assert response['data']['error_code'] == 'SHIPPING.ORDER_EXCEL_FROZEN'
|
||||
# 冻结门位于 _prepare_review_context(策略检查之前),当前不写 formal_task_edit_rejected 审计。
|
||||
assert (
|
||||
ShippingAuditEvent.query
|
||||
.filter_by(task_no=task.task_no, event_type='formal_task_edit_rejected')
|
||||
.count()
|
||||
) == 0
|
||||
|
||||
|
||||
def test_inventory_invalidation_writes_formal_edit_audit_chain(app):
|
||||
|
||||
@@ -451,7 +451,9 @@ def test_confirmed_review_case_serializes_editability_from_formal_order_task(app
|
||||
payload = serialize_review_case(case)
|
||||
|
||||
assert payload['has_formal_ot'] is True
|
||||
assert payload['formal_editable_field_ids'] == []
|
||||
# 新契约(状态制):冻结 Schema 未配置 task_edit_policy 的 qty-id 默认可编辑;
|
||||
# 正式 OT 无 ready Artifact(Excel 未就绪)不冻结,投影按状态制从 OT 判定可编辑字段。
|
||||
assert payload['formal_editable_field_ids'] == ['qty-id']
|
||||
from app.services.shipping_notice.order_review_draft_service import (
|
||||
add_line,
|
||||
build_confirmable_draft_summary,
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
"""
|
||||
backend/tests/test_shipping_review_formal_task_edit.py
|
||||
|
||||
用途:验收正式任务字段写路径(Schema 策略 + order_data_version)与 change_effect 下游失效。
|
||||
用途:验收正式任务字段写路径(状态制编辑闸门 + order_data_version)与 change_effect 下游失效。
|
||||
依赖:task_workflow、schema_edit_policy、order_schema_service、ShippingOrderTask。
|
||||
逻辑:默认 reservation_id 不可写;Schema editable=True 可写并递增版本;
|
||||
rerun_inventory_matching / regenerate_excel 分别失效匹配或导出并置 invalidated_from_stage;
|
||||
正式字段编辑以 Excel ready 为硬冻结,不再用 order_snapshot_id 阻断。
|
||||
逻辑:未配置 task_edit_policy 的字段默认可写(状态制),显式 editable=False 反向锁;
|
||||
可写成功递增 order_data_version;Excel ready 为硬冻结;
|
||||
rerun_inventory_matching / regenerate_excel 分别失效匹配或导出并置 invalidated_from_stage。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -284,16 +284,13 @@ def _seed_ready_export_artifact(task: ShippingOrderTask, *, path: str | None = N
|
||||
return artifact
|
||||
|
||||
|
||||
def test_formal_edit_rejects_default_readonly_field(app):
|
||||
"""Schema 显式 editable=false 时拒绝,即使字段在 legacy 白名单内。"""
|
||||
def test_formal_edit_accepts_unconfigured_field_by_default(app):
|
||||
"""新契约:未配置 task_edit_policy 的字段在 Excel 未就绪时可直接编辑。"""
|
||||
with app.app_context():
|
||||
task = _task()
|
||||
_attach_extraction(
|
||||
task,
|
||||
[{'part_number': 'A001', 'qty': 10, 'reservation_id': '3000000001'}],
|
||||
field_policies={
|
||||
'reservation_id': {'editable': False},
|
||||
},
|
||||
)
|
||||
db.session.commit()
|
||||
|
||||
@@ -303,8 +300,9 @@ def test_formal_edit_rejects_default_readonly_field(app):
|
||||
'patch': {'reservation_id': '3000092917'},
|
||||
**_review_payload(),
|
||||
})
|
||||
assert response['status'] == 'failed'
|
||||
assert response['data']['error_code'] == 'SHIPPING.ORDER_FIELD_EDIT_FORBIDDEN'
|
||||
assert response['status'] == 'ok'
|
||||
refreshed = db.session.get(ShippingOrderTask, task.id)
|
||||
assert int(refreshed.order_data_version) == 2
|
||||
|
||||
|
||||
def test_formal_edit_accepts_schema_allowed_field_and_bumps_version(app):
|
||||
|
||||
@@ -28,6 +28,7 @@ from app.services.shipping_notice.reservation_service import (
|
||||
record_inventory_verification,
|
||||
)
|
||||
from app.services.shipping_notice.fulfillment_workflow import excel_gate_error
|
||||
from app.services.shipping_notice.task_order_field_editor import replace_current_line_field_value
|
||||
from tests.services.shipping_notice.test_shipping_order_snapshot import _build_accepted_order
|
||||
from app.services.shipping_notice.order_freeze_service import freeze_order_snapshot
|
||||
|
||||
@@ -240,26 +241,30 @@ def test_confirmed_task_revision_transfers_unfulfilled_reservation_with_audit(ap
|
||||
ensure_task_reservations(first_task)
|
||||
db.session.flush()
|
||||
original = ShippingReservation.query.filter_by(reservation_id=first_snapshot.lines[0].reservation_id).one()
|
||||
line = first_snapshot.lines[0]
|
||||
ot_id = int(first_task.id)
|
||||
ot_count = ShippingOrderTask.query.count()
|
||||
|
||||
# 修订沿用同一 OT:不新建任务/快照,仅改写冻结行数据并沿用该 OT,
|
||||
# 由 _transfer_confirmed_revision 完成 version bump 与 Reservation 接替。
|
||||
line = first_snapshot.lines[0]
|
||||
line.part_number = '000123-REV'
|
||||
line.qty = Decimal('13.5')
|
||||
# 修订沿用同一 OT:不新建任务/快照。契约翻转(有效视图):冻结快照不再就地改写,
|
||||
# 改经人工字段编辑器写入已接受修正,由预约层按有效值自动完成 transfer 接替。
|
||||
replace_current_line_field_value(task=first_task, position=0, field_code='part_number', value='000123-REV')
|
||||
replace_current_line_field_value(task=first_task, position=0, field_code='qty', value='13.5')
|
||||
db.session.flush()
|
||||
|
||||
registered = ensure_task_reservations(first_task)
|
||||
|
||||
# 同一 OT 上完成接替:不新建任务行,仅版本 bump,Reservation 仍指向该 OT。
|
||||
# (order_data_version 在冻结值 7 之上经历两次编辑器 bump 与一次确认修订 bump。)
|
||||
assert registered == [original]
|
||||
assert original.task_id == ot_id
|
||||
assert original.snapshot_line_id == line.id
|
||||
assert original.part_number == '000123-REV'
|
||||
assert original.required_qty == Decimal('13.5')
|
||||
assert first_task.order_data_version == 8
|
||||
assert first_task.order_data_version == 10
|
||||
assert first_task.progress_version == 2
|
||||
# 冻结快照保持审计锚点:强类型列不得被修订改写。
|
||||
assert line.part_number == '000123'
|
||||
assert line.qty == Decimal('12.50000000')
|
||||
# 不产生重复 OT 行。
|
||||
assert ShippingOrderTask.query.count() == ot_count
|
||||
# 审计事件落在该 OT 上。
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
"""
|
||||
backend/tests/test_shipping_schema_edit_policy.py
|
||||
|
||||
用途:验收正式任务 Schema 编辑策略默认只读与显式放行(无 legacy 绕过)。
|
||||
用途:验收正式任务 Schema 编辑策略状态制默认(未配置默认可写)与显式反向锁。
|
||||
依赖:schema_edit_policy、pytest。
|
||||
逻辑:无 task_edit_policy → 不可编辑;显式 editable=True → 可编辑;
|
||||
excel_ready 后全局关闭。
|
||||
逻辑:无 task_edit_policy → 默认可编辑(Excel ready 前状态制放行);显式 editable=False → 反向锁;
|
||||
excel_ready 后全局硬冻结。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.services.shipping_notice.schema_edit_policy import (
|
||||
DEFAULT_EDITABLE_AFTER_TASK_CREATION,
|
||||
field_task_edit_policy,
|
||||
is_excel_ready_for_task,
|
||||
is_field_editable_for_formal_task,
|
||||
list_editable_formal_field_ids,
|
||||
@@ -18,13 +19,20 @@ from app.services.shipping_notice.schema_edit_policy import (
|
||||
)
|
||||
|
||||
|
||||
def test_default_formal_fields_are_readonly() -> None:
|
||||
"""默认创建任务后不可编辑。"""
|
||||
assert DEFAULT_EDITABLE_AFTER_TASK_CREATION is False
|
||||
assert not is_field_editable_for_formal_task({'field_id': 'po-id'})
|
||||
def test_default_formal_fields_are_editable_until_excel_ready() -> None:
|
||||
"""新契约:未配置策略的字段默认可编辑(状态制),显式 editable=false 仍可反向锁。"""
|
||||
assert DEFAULT_EDITABLE_AFTER_TASK_CREATION is True
|
||||
assert field_task_edit_policy(None)['editable'] is True
|
||||
assert field_task_edit_policy({'task_edit_policy': {'editable': False}})['editable'] is False
|
||||
# Excel 未就绪时未配置策略字段可写;Excel ready 后仍全局硬冻结。
|
||||
assert is_field_editable_for_formal_task({'field_id': 'po-id'}, excel_ready=False) is True
|
||||
assert is_field_editable_for_formal_task({'field_id': 'po-id'}, excel_ready=True) is False
|
||||
assert list_editable_formal_field_ids([
|
||||
{'field_id': 'po-id', 'field_code': 'po_number'},
|
||||
]) == []
|
||||
], excel_ready=False) == ['po-id']
|
||||
assert list_editable_formal_field_ids([
|
||||
{'field_id': 'po-id', 'field_code': 'po_number'},
|
||||
], excel_ready=True) == []
|
||||
|
||||
|
||||
def test_schema_explicit_editable_is_honored_until_excel_ready() -> None:
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
"""
|
||||
tests/test_ui_state_effective_values.py
|
||||
|
||||
用途:验证通知准备投影的值列(预约号/料号/需求数量)消费有效订单值视图。
|
||||
依赖:pytest、ui_state._build_stage_context 阶段上下文构建、有效视图夹具 _seed_frozen_order。
|
||||
逻辑:编辑料号后(重匹配前),frozen_order_lines 与 preparation.lines 的值列必须立即显示
|
||||
新值(有效值优先、快照列回退);匹配结果列不受影响,仍诚实反映最近一轮匹配。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.services.shipping_notice.task_order_field_editor import replace_current_line_field_value
|
||||
from tests.test_effective_order_view import _seed_frozen_order
|
||||
|
||||
|
||||
def test_preparation_value_columns_follow_effective_values(app):
|
||||
"""保存修正后(重匹配前)值列立即显示新值。"""
|
||||
with app.app_context():
|
||||
fixture = _seed_frozen_order()
|
||||
replace_current_line_field_value(
|
||||
task=fixture.order, position=0, field_code='part_number', value='D4-A08AR12000002',
|
||||
)
|
||||
from app.services.shipping_notice import ui_state
|
||||
# _build_stage_context 实签名为 (task, *, lifecycle_stage, stp_facts, process_gate);
|
||||
# 直接传正式 OT(夹具即 OT),经 _resolve_order_task_for_gate_lookup 原样返回。
|
||||
context = ui_state._build_stage_context(
|
||||
fixture.order,
|
||||
lifecycle_stage='fulfillment_prep',
|
||||
stp_facts=None,
|
||||
process_gate=None,
|
||||
)
|
||||
preparation = context['preparation']
|
||||
frozen_lines = preparation['frozen_order_lines']
|
||||
prep_lines = preparation['lines']
|
||||
# 断言:值列为有效值(而非快照冻结的带尾巴旧值)。
|
||||
assert frozen_lines[0]['part_number'] == 'D4-A08AR12000002'
|
||||
assert prep_lines[0]['part_number'] == 'D4-A08AR12000002'
|
||||
# 断言:未被编辑的第 1 行保持冻结值(对位叠加只影响被改行)。
|
||||
assert frozen_lines[1]['part_number'] == 'D4-B07BR07000001'
|
||||
assert prep_lines[1]['part_number'] == 'D4-B07BR07000001'
|
||||
@@ -729,6 +729,23 @@ export / exportable_snapshot_line_ids)无论库存状态一律剔除结案行
|
||||
|
||||
**结案时序边界(操作规约)**:结案触发自动推进存在时序边界——多行订单若先结案短缺行使整单立即满足,异步编排会把“尚未结案的有库存行”一并建入通知。规约:多行结案必须使用缺口复核的批量关行(close_remaining_fulfillment,多选行单事务提交,Worker 只见终态),或按「先结有库存行、最后结短缺行」的顺序逐行结案;自动履约的“恰好单一开放行”守卫(line_auto_fulfill_coordinator)保证多条开放行永不自动合并。
|
||||
|
||||
### 通知准备就地编辑与入口修复(2026-09-18)
|
||||
|
||||
**编辑权限状态制**:正式订单字段(含履约三要素 料号/预约号/数量)默认在
|
||||
「Excel 未生成 + 无活动 Attempt」时可编辑(DEFAULT_EDITABLE_AFTER_TASK_CREATION=True,
|
||||
Schema task_edit_policy 退化为反向锁);原因/证据不强制,审计链自动记录 old→new
|
||||
(shipping_order_review_events / formal_task_field_edited)。通知准备匹配表三单元格
|
||||
就地编辑 → 保存(order_data_version+1)→ 手动「重新匹配库存」生效。
|
||||
|
||||
**有效值消费面补全**:通知准备值列、预约注册(ensure_task_reservations)与核验比对
|
||||
(record_inventory_verification)均改读有效订单值视图——修复编辑后重匹配必抛
|
||||
RESERVATION_MISMATCH 的阻断;匹配结果列仍反映最近一轮匹配事实。
|
||||
|
||||
**缺口复核入口修复**:行级履约投影的匹配事实关联由 draft_line_id 改为 line_index
|
||||
(修复 has_shortage 恒 False 导致入口被隐藏);prep 表新增行级结案入口,滚动锚指向
|
||||
prep 工作区。**边界**:Excel ready 后编辑硬冻结;通知已存在后编辑不重物化通知行
|
||||
(可达窗口窄,声明边界);done_line_report/OT 通知列表投影仍显示冻结原值(历史定格语义)。
|
||||
|
||||
### 2026-07-21 文档级抽取优化历史阶段与 Review 门禁
|
||||
|
||||
> 本路线描述“避免把邮件和全部附件一次性丢给单个 LLM”的目标架构,不沿用旧整单/整封邮件单次模型调用作为兼容路径。各阶段必须按顺序实施;阶段内测试、自检和 Review 的阻断问题全部关闭并满足验收标准后,才能自动进入下一阶段。Dify 画布由管理员按本文档手工修改,代码阶段不直接操作 Dify。
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
- 我的待办改版(2026-09-16):紧凑表格 + 按需详情抽屉;阶段筛选 tab 计数后端全量聚合(仅四个可动作阶段);批量操作仅货代上传阶段可勾选、勾选后浮动操作条;已完成桶拆子视图——「通知完成」为跨单平铺明细报表(客户/料号/发货通知日期筛选,按明细行分页,导出严格 12 列标准 Excel),「复核驳回/已作废」为任务表 + 抽屉。
|
||||
- 阻塞原因具体化(2026-09-17):批次中心/工作台对建单前 Case 回退消费草稿校验快照的首要阻断 issue(冻结 explainability 契约透传 code/message/next_action),展示「客户尚未确认」等具体原因;「下一步」渲染建议动作文案;通用兜底码不再渲染,同卡重复原因行去重。
|
||||
- 订单冻结后的人工字段修正(料号等)现可进入库存匹配、Excel 与通知行(有效订单值视图);缺口复核中的行结案(close_unfulfillable)现具备端到端豁免(不再阻塞整单,导出/建通知自动剔除结案行)。
|
||||
- 通知准备界面支持料号/预约号/数量就地编辑(保存后手动重新匹配库存生效);缺口复核入口与行结案按钮修复可见;编辑权限为状态制(Excel 生成前可改)。
|
||||
- 通知完成:只读展示已核验的上传成功证据;仅 Task 聚合、全部预约单与成功 Upload Attempt 同时满足时显示并计入完成。
|
||||
- 通知完成:上传通知或登记上传回执;仅服务端确认的上传 Attempt 成功后显示完成结果。
|
||||
- 货代发货会话主区域为批次进度中心:有会话即全屏常驻展示(不可关闭),无会话显示欢迎页与附件提交入口;历史会话点击直达中心
|
||||
|
||||
@@ -0,0 +1,797 @@
|
||||
# 货代发货通知:通知准备就地编辑 + 入口修复 实施计划
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** 让订单确认后(Excel 生成前)的履约字段(料号/预约号/数量)在通知准备界面就地编辑并持久化,编辑后手点「重新匹配库存」全链路生效;同时修复缺口复核面板的两个入口 bug,让"不发货的行"有结案出路。
|
||||
|
||||
**Architecture:** 编辑权限从「字段字典逐字段配置」翻转为「状态制」(Excel 未生成 + 无活动 Attempt = 可编辑,字段配置退化为反向锁);写路径完全复用现有 `update-notice-line`(Decision/FieldValue + 版本号 + 自动 old→new 审计),零新增端点、零白名单、零新表。读路径把三处仍锚定冻结快照列的消费方(通知准备值列、预约/核验层)切到已有的有效订单值视图(`effective_order_view`)。前端在匹配表三个单元格加编辑框。另修缺口复核面板的键错位与结案入口。
|
||||
|
||||
**Tech Stack:** Flask + SQLAlchemy 2.0(后端既有栈);Vue 3 + TypeScript + i18n 四语言(前端);pytest + vitest。
|
||||
|
||||
**Spec:** 2026-09-17/18 头脑风暴对话结论(用户逐项确认的 6 项清单 + 三次设计简化裁决:无原因必填、无白名单、无候选值接口、编辑框样式、无自动触发)。前置分支成果:`051f80e1e`(有效视图 + 行结案豁免,已在 hugo-shipping-notice)。
|
||||
|
||||
## Global Constraints
|
||||
|
||||
- 分支:从 `hugo-shipping-notice` 切 worktree 分支 `fix/shipping-notice-inline-edit-entry-repair` 实施;完成后按用户惯例并入 `hugo-shipping-notice`。
|
||||
- Conventional Commits:`<type>(shipping-notice): 中文主题`,≤100 字符。
|
||||
- 注释三层结构(AGENTS.md §5):修改逻辑必须同步更新受影响注释。
|
||||
- **无数据库迁移**(无模型变更);无新错误码 → **除前端新增文案外无新增 errors.json 键**。
|
||||
- **i18n 四语言强制**:前端新增文案必须同时补 `zh-CN / zh-TW / en / th`(AGENTS.md §8)。
|
||||
- 前端改动必须保证 `npm run build`(含 vue-tsc)通过。
|
||||
- 测试命令(worktree 内,需先做 Task 0 的 junction):
|
||||
- 后端 `cd backend && ./.venv/Scripts/python.exe -m pytest <目标> -v`
|
||||
- 前端 `cd frontend && npx vue-tsc -b --pretty false && npm run build`
|
||||
- **禁止 `git stash`**(共享 stash 栈有用户条目);验证用 `git diff` / 临时 commit。
|
||||
- 下游追踪结论(2026-09-18 探查报告)作为本计划的边界事实:Excel ready 后编辑被硬冻结(不可达窗口不做);「通知已存在后编辑不重物化通知行」为本期声明边界,不在本包修。
|
||||
|
||||
---
|
||||
|
||||
### Task 0: 环境准备(worktree + junction)
|
||||
|
||||
**Files:** 无代码变更。
|
||||
|
||||
- [ ] **Step 1: 创建 worktree 并接好依赖 junction**
|
||||
|
||||
```bash
|
||||
cd "D:/Workspace/HxProjects/hxops"
|
||||
git worktree add .worktrees/editfeat -b fix/shipping-notice-inline-edit-entry-repair hugo-shipping-notice
|
||||
cd .worktrees/editfeat
|
||||
powershell -Command "New-Item -ItemType Junction -Path node_modules -Target 'D:\Workspace\HxProjects\hxops\node_modules'"
|
||||
powershell -Command "New-Item -ItemType Junction -Path backend\.venv -Target 'D:\Workspace\HxProjects\hxops\backend\.venv'"
|
||||
mkdir backend/.pytest_tmp
|
||||
```
|
||||
|
||||
(注意用 PowerShell 建 junction,Git Bash 的 `cmd //c mklink` 会篡改路径为 `D:\D:\...`。)
|
||||
|
||||
- [ ] **Step 2: 冒烟验证**
|
||||
|
||||
Run: `cd backend && ./.venv/Scripts/python.exe -m pytest tests/test_effective_order_view.py -q`
|
||||
Expected: 5 passed
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Decimal 写 JSON 列 bug 修复(数量编辑的前提)
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/services/shipping_notice/task_order_field_editor.py`(`_field_value_columns` :180-189、`replace_current_line_field_value` :225、`replace_current_header_field_value` :267)
|
||||
- Test: `backend/tests/test_effective_order_view.py`(追加)
|
||||
|
||||
**Interfaces:**
|
||||
- Produces: 编辑 decimal 字段不再抛 `TypeError: Object of type Decimal is not JSON serializable`;`value_json`/`resolved_value_json` 对 decimal 存 `format(value.normalize(), 'f')` 字符串(与机器路径 `order_schema/runtime.py:119-125 _json_value` 对齐),`value_decimal` 列仍存真 Decimal。
|
||||
|
||||
- [ ] **Step 1: 写失败测试**
|
||||
|
||||
在 `backend/tests/test_effective_order_view.py` 追加(文件已有 import 区,补 `replace_current_line_field_value` 已存在的无需重复;补 `from app.models import ShippingOrderFieldValue` 若缺失):
|
||||
|
||||
```python
|
||||
def test_decimal_edit_persists_without_json_error(app):
|
||||
"""数量(decimal 字段)人工编辑必须可持久化:value_json 存字符串、value_decimal 存 Decimal。"""
|
||||
with app.app_context():
|
||||
fixture = _seed_frozen_order()
|
||||
# 修复前此处抛 TypeError: Object of type Decimal is not JSON serializable。
|
||||
replace_current_line_field_value(
|
||||
task=fixture.order, position=0, field_code='qty', value='12.5',
|
||||
)
|
||||
row = ShippingOrderFieldValue.query.filter_by(
|
||||
extraction_id=fixture.extraction.id, line_id=fixture.snap_lines[0].__dict__['_sa_instance_state'].dict['id'] if False else None,
|
||||
)
|
||||
```
|
||||
|
||||
上面的查询写法不对,直接用关系取(替换为以下最终版本):
|
||||
|
||||
```python
|
||||
def test_decimal_edit_persists_without_json_error(app):
|
||||
"""数量(decimal 字段)人工编辑必须可持久化:value_json 存字符串、value_decimal 存 Decimal。"""
|
||||
with app.app_context():
|
||||
fixture = _seed_frozen_order()
|
||||
replace_current_line_field_value(
|
||||
task=fixture.order, position=0, field_code='qty', value='12.5',
|
||||
)
|
||||
rows = [
|
||||
item for item in ShippingOrderFieldValue.query.filter_by(
|
||||
extraction_id=fixture.extraction.id,
|
||||
).all()
|
||||
if item.value_json is not None
|
||||
]
|
||||
qty_rows = [item for item in rows if item.field_id == 'f-qty' and item.line_id is not None]
|
||||
# 断言:JSON 列存规范字符串(与机器路径 _json_value 对齐),类型列保留 Decimal。
|
||||
assert qty_rows, 'qty FieldValue 必须存在'
|
||||
assert all(item.value_json == '12.5' for item in qty_rows)
|
||||
assert any(item.value_decimal == Decimal('12.5') for item in qty_rows)
|
||||
```
|
||||
|
||||
- [ ] **Step 2: 运行确认失败**
|
||||
|
||||
Run: `cd "D:/Workspace/HxProjects/hxops/.worktrees/editfeat/backend" && ./.venv/Scripts/python.exe -m pytest tests/test_effective_order_view.py::test_decimal_edit_persists_without_json_error -v`
|
||||
Expected: FAIL,`TypeError: Object of type Decimal is not JSON serializable`(flush 时)
|
||||
|
||||
- [ ] **Step 3: 实现**
|
||||
|
||||
`task_order_field_editor.py`:
|
||||
|
||||
(a) 在 `_field_value_columns`(:180)之前新增:
|
||||
|
||||
```python
|
||||
def _json_value(value: Any) -> Any:
|
||||
"""把人工输入转为 JSON 列可序列化形状;与 order_schema.runtime._json_value 对齐。
|
||||
|
||||
核心逻辑:Decimal → format(normalize, 'f') 字符串(保留精度且 json.dumps 可序列化),
|
||||
date → isoformat;其余原样。类型化列(value_decimal 等)仍保存原生值。
|
||||
"""
|
||||
if isinstance(value, Decimal):
|
||||
return format(value.normalize(), 'f')
|
||||
if isinstance(value, date):
|
||||
return value.isoformat()
|
||||
return value
|
||||
```
|
||||
|
||||
(文件顶部 import 区补 `from datetime import date`。)
|
||||
|
||||
(b) `_field_value_columns`(:180-189)中 `'value_json': value,` 改为 `'value_json': _json_value(value),`。
|
||||
|
||||
(c) `replace_current_line_field_value` :225 `decision.resolved_value_json = normalized` 改为 `decision.resolved_value_json = _json_value(normalized)`;`replace_current_header_field_value` :267 同样处理。
|
||||
|
||||
- [ ] **Step 4: 运行确认通过**
|
||||
|
||||
Run: `cd "D:/Workspace/HxProjects/hxops/.worktrees/editfeat/backend" && ./.venv/Scripts/python.exe -m pytest tests/test_effective_order_view.py tests/test_shipping_review_formal_task_edit.py -v`
|
||||
Expected: 全部 PASS(新增 1 + 既有 5/10+)
|
||||
|
||||
- [ ] **Step 5: 提交**
|
||||
|
||||
```bash
|
||||
git add backend/app/services/shipping_notice/task_order_field_editor.py backend/tests/test_effective_order_view.py
|
||||
git commit -m "fix(shipping-notice): 人工编辑decimal字段可持久化并保留原始JSON形状"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 2: 编辑闸门翻转为状态制 + 原因/证据改可选
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/services/shipping_notice/schema_edit_policy.py`(:22 常量、:49-51 初始化)
|
||||
- Modify: `backend/app/services/shipping_notice/task_workflow.py`(`_prepare_review_context` :1031-1061、`_commit_notice_edit` :923-924)
|
||||
- Test: `backend/tests/test_shipping_schema_edit_policy.py`(:21-23 改写)、`backend/tests/test_shipping_review_formal_task_edit.py`(:287-307 改写)、`backend/tests/test_shipping_formal_task_edit_audit.py`(:34-61 改写)
|
||||
|
||||
**Interfaces:**
|
||||
- Produces: 未配置 `task_edit_policy` 的字段默认可编辑(Excel ready 仍硬冻结;显式 `editable:false` 仍可反向锁);`reason`/`evidence` 缺省时自动落哨兵值(审计列 NOT NULL 不破坏)。
|
||||
|
||||
- [ ] **Step 1: 改写三个测试为新契约(先写失败)**
|
||||
|
||||
`backend/tests/test_shipping_schema_edit_policy.py` :21-23 原断言 `DEFAULT_EDITABLE_AFTER_TASK_CREATION is False` 改为:
|
||||
|
||||
```python
|
||||
def test_default_formal_fields_are_editable_until_excel_ready():
|
||||
"""新契约:未配置策略的字段默认可编辑(状态制),显式 editable=false 仍可反向锁。"""
|
||||
assert DEFAULT_EDITABLE_AFTER_TASK_CREATION is True
|
||||
assert field_task_edit_policy(None)['editable'] is True
|
||||
assert field_task_edit_policy({'task_edit_policy': {'editable': False}})['editable'] is False
|
||||
```
|
||||
|
||||
(import 区按该文件现有导入补 `DEFAULT_EDITABLE_AFTER_TASK_CREATION`。)
|
||||
|
||||
`backend/tests/test_shipping_review_formal_task_edit.py` :287-307 `test_formal_edit_rejects_default_readonly_field` 改写为 accepts 语义(保留原夹具调用方式,仅翻转断言):
|
||||
|
||||
```python
|
||||
def test_formal_edit_accepts_unconfigured_field_by_default():
|
||||
"""新契约:未配置 task_edit_policy 的字段在 Excel 未就绪时可直接编辑。"""
|
||||
# 沿用本文件既有夹具构造正式任务与请求体,字段用夹具中未配置策略的行字段;
|
||||
# 响应断言 success(不再抛 ORDER_FIELD_EDIT_FORBIDDEN),order_data_version 递增。
|
||||
```
|
||||
|
||||
(实现者按该文件 :287-307 原用例的夹具与请求构造照抄,仅把「断言拒绝」换成「断言成功 + 版本递增」;原用例中若显式传了 `task_edit_policy` 夹具则去掉该配置。)
|
||||
|
||||
`backend/tests/test_shipping_formal_task_edit_audit.py` :34-61 同理:原断言拒绝+`ORDER_FIELD_EDIT_FORBIDDEN` 审计,改为断言编辑成功且审计事件为 `formal_task_field_edited`(old→new 存在)。
|
||||
|
||||
同时 grep 证据必填断言:`grep -rn "ORDER_REVIEW_EVIDENCE_REQUIRED" backend/tests` ——列出后逐个改写为「缺省时成功且审计 evidence_ref 为哨兵值」。
|
||||
|
||||
- [ ] **Step 2: 运行确认失败**
|
||||
|
||||
Run: `cd "D:/Workspace/HxProjects/hxops/.worktrees/editfeat/backend" && ./.venv/Scripts/python.exe -m pytest tests/test_shipping_schema_edit_policy.py tests/test_shipping_review_formal_task_edit.py tests/test_shipping_formal_task_edit_audit.py -v`
|
||||
Expected: FAIL(新契约断言失败,旧实现返回 False / 拒绝)
|
||||
|
||||
- [ ] **Step 3: 实现**
|
||||
|
||||
(a) `schema_edit_policy.py` :22 改为:
|
||||
|
||||
```python
|
||||
# 默认:建单后 Excel 生成前字段可编辑(状态制);个别字段需要锁定时在 Schema 配置 editable=false 反向关闭。
|
||||
DEFAULT_EDITABLE_AFTER_TASK_CREATION: Final[bool] = True
|
||||
```
|
||||
|
||||
(b) `field_task_edit_policy` :49-51 改为(**注意:只改常量不够,初始化必须同步**,否则无配置字段仍为 False):
|
||||
|
||||
```python
|
||||
editable = bool(policy.get('editable')) if policy else DEFAULT_EDITABLE_AFTER_TASK_CREATION
|
||||
if not DEFAULT_EDITABLE_AFTER_TASK_CREATION and 'editable' not in policy:
|
||||
editable = False
|
||||
```
|
||||
|
||||
(c) `task_workflow.py` `_prepare_review_context`(:1031-1061):`reason` 缺省改为哨兵、`evidence` 缺省跳过校验(先读全函数再落改):
|
||||
|
||||
```python
|
||||
# 快捷就地编辑不强制填写原因/证据:审计链自动记录 old→new + 操作人 + 时间;
|
||||
# 提供了证据时仍走原校验。哨兵值满足 shipping_order_review_events 的 NOT NULL 列。
|
||||
reason = str(review_context.get('reason') or '').strip() or 'quick_field_edit'
|
||||
evidence = review_context.get('evidence') or None
|
||||
if evidence is not None:
|
||||
validate_review_evidence(evidence) # 原 :1047-1061 的校验调用保持
|
||||
evidence_ref = ... # 原有证据引用构建逻辑
|
||||
else:
|
||||
evidence_ref = 'inline:match-table'
|
||||
```
|
||||
|
||||
(`reviewed_by_id` 与 `event_source='workspace_api'` 的要求**保留不变**——操作人身份是审计底线。)
|
||||
|
||||
(d) `_commit_notice_edit` :923-924 的 `if not reviewed_by_id or not evidence_ref or not reason: raise` 改为仅 `if not reviewed_by_id: raise`(evidence_ref/reason 已由上游哨兵兜底)。
|
||||
|
||||
- [ ] **Step 4: 运行确认通过 + 契约域回归**
|
||||
|
||||
Run: `cd "D:/Workspace/HxProjects/hxops/.worktrees/editfeat/backend" && ./.venv/Scripts/python.exe -m pytest tests/test_shipping_schema_edit_policy.py tests/test_shipping_review_formal_task_edit.py tests/test_shipping_formal_task_edit_audit.py tests/test_effective_order_view.py -v`
|
||||
Expected: 全部 PASS。再跑 `grep -rn "ORDER_FIELD_EDIT_FORBIDDEN" backend/tests | grep -v test_shipping_schema_edit_policy` 核对无遗漏的旧契约断言(有则一并改写为新契约)。
|
||||
|
||||
- [ ] **Step 5: 提交**
|
||||
|
||||
```bash
|
||||
git add backend/app/services/shipping_notice/schema_edit_policy.py backend/app/services/shipping_notice/task_workflow.py backend/tests/test_shipping_schema_edit_policy.py backend/tests/test_shipping_review_formal_task_edit.py backend/tests/test_shipping_formal_task_edit_audit.py
|
||||
git commit -m "feat(shipping-notice): 编辑闸门翻转为状态制并放宽原因证据必填"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 3: 预约/核验层切有效视图(修 RESERVATION_MISMATCH 阻断)
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/services/shipping_notice/reservation_service.py`(`ensure_task_reservations` :42-104、`record_inventory_verification` :178-184)
|
||||
- Test: `backend/tests/test_reservation_effective_view.py`(新建)
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: `effective_order_view.effective_line_facts_for_notice(owner: ShippingOrderTask) -> {int: {'part_number','reservation_id','qty','field_values'}}`(已存在)。
|
||||
- Produces: 预约注册/核验比对以有效值为准;编辑后重匹配不再抛 `SHIPPING.RESERVATION_MISMATCH`。
|
||||
|
||||
- [ ] **Step 1: 写失败测试**
|
||||
|
||||
创建 `backend/tests/test_reservation_effective_view.py`:
|
||||
|
||||
```python
|
||||
"""
|
||||
tests/test_reservation_effective_view.py
|
||||
|
||||
用途:验证预约注册与核验比对消费有效订单值视图(编辑后不再 RESERVATION_MISMATCH)。
|
||||
依赖:pytest、reservation_service、task_order_field_editor、effective view 夹具。
|
||||
逻辑:先按冻结值注册预约 → 就地编辑料号 → 再次 ensure 应自动修订(transfer)而非抛错。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app import db
|
||||
from app.models import ShippingReservation
|
||||
from app.services.shipping_notice.reservation_service import ensure_task_reservations
|
||||
from app.services.shipping_notice.task_order_field_editor import replace_current_line_field_value
|
||||
from tests.test_effective_order_view import _seed_frozen_order
|
||||
|
||||
|
||||
def test_ensure_task_reservations_follows_effective_values(app):
|
||||
"""预约注册必须消费有效值:编辑料号后再次 ensure 应更新预约(修订)而非校验失败。"""
|
||||
with app.app_context():
|
||||
fixture = _seed_frozen_order()
|
||||
# 第一次注册:按冻结值(带尾巴的旧料号)建预约。
|
||||
ensure_task_reservations(fixture.order)
|
||||
reservation = ShippingReservation.query.filter_by(
|
||||
task_id=fixture.order.id,
|
||||
).one()
|
||||
# 断言:初始注册值为冻结快照列原值。
|
||||
assert reservation.part_number == 'D4-A08AR12000002-'
|
||||
# 就地编辑第 0 行料号为正确值。
|
||||
replace_current_line_field_value(
|
||||
task=fixture.order, position=0, field_code='part_number', value='D4-A08AR12000002',
|
||||
)
|
||||
# 第二次 ensure(重匹配核验前的真实调用时序):必须成功且预约更新为有效值。
|
||||
ensure_task_reservations(fixture.order)
|
||||
db.session.refresh(reservation)
|
||||
# 断言:预约料号已随有效值修订,状态回 pending(可重新核验)。
|
||||
assert reservation.part_number == 'D4-A08AR12000002'
|
||||
```
|
||||
|
||||
(若 `ensure_task_reservations` 的实际入参/返回与上述调用不符,以 `reservation_service.py:42-104` 实际签名为准适配调用方式,断言语义不变。)
|
||||
|
||||
- [ ] **Step 2: 运行确认失败**
|
||||
|
||||
Run: `cd "D:/Workspace/HxProjects/hxops/.worktrees/editfeat/backend" && ./.venv/Scripts/python.exe -m pytest tests/test_reservation_effective_view.py -v`
|
||||
Expected: FAIL——第二次调用抛 `SHIPPING.RESERVATION_MISMATCH` 或 `RESERVATION_REVISION_REVIEW_REQUIRED`(编辑后有效值 ≠ 注册值)
|
||||
|
||||
- [ ] **Step 3: 实现**
|
||||
|
||||
先通读 `ensure_task_reservations`(:42-104)与 `_transfer_confirmed_revision`(:118-156)全函数再落改。语义目标:
|
||||
|
||||
(a) `ensure_task_reservations` :50-54 的快照列读取改为有效事实优先:
|
||||
|
||||
```python
|
||||
# [BE-有效视图] 预约身份以有效订单值为准(冻结快照 + 已接受修正),
|
||||
# 否则就地编辑料号/数量后核验比对必抛 RESERVATION_MISMATCH。
|
||||
from app.services.shipping_notice.effective_order_view import effective_line_facts_for_notice
|
||||
effective_facts = effective_line_facts_for_notice(task)
|
||||
for line in snapshot.lines:
|
||||
eff = effective_facts.get(int(line.id)) or {}
|
||||
reservation_id_value = eff.get('reservation_id') if eff.get('reservation_id') is not None else line.reservation_id
|
||||
part_number_value = eff.get('part_number') if eff.get('part_number') is not None else line.part_number
|
||||
qty_value = eff.get('qty') if eff.get('qty') is not None else line.qty
|
||||
# ……后续 :55-101 的重复/冲突/注册/修订判定全部改用以上三个值
|
||||
```
|
||||
|
||||
(b) part/qty 不一致分支:当该行**无 Artifact 锁**(:82-83 既有锁判断)且预约属于同一 OT 时,走 `_transfer_confirmed_revision`(:118-156,其内部已有 bump 版本 + `reservation_revision_confirmed` 事件 + status 回 pending)完成自动修订;仅当行已锁定(已导出)时保留原 `RESERVATION_REVISION_REVIEW_REQUIRED` 拒绝。
|
||||
|
||||
(c) `record_inventory_verification` :178-184 的料号比对改为两侧归一化(消除大小写/空白造成的假阳性,数量比对逻辑不变):
|
||||
|
||||
```python
|
||||
if reservation is None or str(reservation.part_number or '').strip().upper() != str(part_number or '').strip().upper():
|
||||
```
|
||||
|
||||
- [ ] **Step 4: 运行确认通过 + 预约域回归**
|
||||
|
||||
Run: `cd "D:/Workspace/HxProjects/hxops/.worktrees/editfeat/backend" && ./.venv/Scripts/python.exe -m pytest tests/test_reservation_effective_view.py -v` 后追加:`grep -rln "ensure_task_reservations\|RESERVATION_MISMATCH" backend/tests | head` 找到既有预约测试文件并全量跑(FAIL 的按新契约逐个核对:若断言"快照值注册"则更新为有效值语义)。
|
||||
Expected: 全部 PASS
|
||||
|
||||
- [ ] **Step 5: 提交**
|
||||
|
||||
```bash
|
||||
git add backend/app/services/shipping_notice/reservation_service.py backend/tests/test_reservation_effective_view.py
|
||||
git commit -m "fix(shipping-notice): 预约注册与核验比对改读有效订单值视图"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 4: 通知准备值列切有效视图
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/services/shipping_notice/ui_state.py`(`frozen_order_lines` :867-878、`preparation_lines` :880-882/:937-938)
|
||||
- Test: `backend/tests/test_ui_state_effective_values.py`(新建)
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: `effective_line_facts_for_notice(order_task)`(Task 3 同款)。
|
||||
- Produces: 前端 `formalPreparationDisplayLines`(ShippingOrderReviewView.vue:2562-2572 以 `frozen_order_lines` 为底、prep.lines 覆盖)在保存后**立即显示新值**;匹配结果列仍来自匹配事实(诚实反映最近一轮)。
|
||||
|
||||
- [ ] **Step 1: 写失败测试**
|
||||
|
||||
创建 `backend/tests/test_ui_state_effective_values.py`:
|
||||
|
||||
```python
|
||||
"""
|
||||
tests/test_ui_state_effective_values.py
|
||||
|
||||
用途:验证通知准备投影的值列(预约号/料号/需求数量)消费有效订单值视图。
|
||||
依赖:pytest、ui_state 阶段上下文构建、有效视图夹具。
|
||||
逻辑:编辑料号后(重匹配前),值列必须立即显示新值;匹配状态列不受影响。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app import db
|
||||
from app.services.shipping_notice.task_order_field_editor import replace_current_line_field_value
|
||||
from tests.test_effective_order_view import _seed_frozen_order
|
||||
|
||||
|
||||
def test_preparation_value_columns_follow_effective_values(app):
|
||||
"""保存修正后(重匹配前)值列立即显示新值。"""
|
||||
with app.app_context():
|
||||
fixture = _seed_frozen_order()
|
||||
replace_current_line_field_value(
|
||||
task=fixture.order, position=0, field_code='part_number', value='D4-A08AR12000002',
|
||||
)
|
||||
from app.services.shipping_notice import ui_state
|
||||
context = ui_state._build_stage_context(fixture.order)
|
||||
lines = context['preparation']['frozen_order_lines'] if 'preparation' in context else context.get('frozen_order_lines', [])
|
||||
# 断言:值列为有效值(而非快照冻结的带尾巴旧值)。
|
||||
assert lines[0]['part_number'] == 'D4-A08AR12000002'
|
||||
```
|
||||
|
||||
(`_build_stage_context` 的实际函数名/返回形状以 ui_state.py:793-794 与 :1067-1068 为准适配;断言语义不变:值列 = 有效值。若该构建函数需要更多入参,参照其既有测试或调用方 `query_service` 的传参方式构造。)
|
||||
|
||||
- [ ] **Step 2: 运行确认失败**
|
||||
|
||||
Run: `cd "D:/Workspace/HxProjects/hxops/.worktrees/editfeat/backend" && ./.venv/Scripts/python.exe -m pytest tests/test_ui_state_effective_values.py -v`
|
||||
Expected: FAIL,`part_number == 'D4-A08AR12000002-'`(仍读冻结列)
|
||||
|
||||
- [ ] **Step 3: 实现**
|
||||
|
||||
`ui_state.py`(先读 :837-960 全段):
|
||||
|
||||
(a) :848 之后(snapshot 解析完成处)计算一次有效事实:
|
||||
|
||||
```python
|
||||
# [BE-有效视图] 值列消费有效订单值(快照 + 已接受修正):保存即显新值,
|
||||
# 匹配结果列仍读当前匹配事实,诚实反映最近一轮匹配结论。
|
||||
from app.services.shipping_notice.effective_order_view import effective_line_facts_for_notice
|
||||
effective_facts = (
|
||||
effective_line_facts_for_notice(order_task)
|
||||
if order_task is not None and getattr(order_task, 'order_snapshot_id', None) else {}
|
||||
)
|
||||
```
|
||||
|
||||
(b) `frozen_order_lines`(:867-878):`reservation_id`/`part_number`/`required_qty` 改为有效值优先、快照列回退:
|
||||
|
||||
```python
|
||||
eff = effective_facts.get(int(snapshot_line.id)) or {}
|
||||
frozen_order_lines.append({
|
||||
'snapshot_line_id': int(snapshot_line.id),
|
||||
'line_no': line_no,
|
||||
'reservation_id': eff.get('reservation_id') if eff.get('reservation_id') is not None else snapshot_line.reservation_id,
|
||||
'part_number': eff.get('part_number') if eff.get('part_number') is not None else snapshot_line.part_number,
|
||||
'required_qty': str(eff['qty']) if eff.get('qty') is not None else qty_text,
|
||||
})
|
||||
```
|
||||
|
||||
(键名不动——前端类型 `shipping.api.types.ts:1490-1497` 契约稳定;注释同步改为「有效值优先」。)
|
||||
|
||||
(c) `preparation_lines` 的三处(:880-882 required_qty、:937 reservation_id、:938 part_number):把「fact → 快照」的回退链改为「**有效事实 → fact → 快照**」——保存后即使 fact 未刷新,覆盖合并(前端 :2570 prep 覆盖 frozen)也显示新值:
|
||||
|
||||
```python
|
||||
eff = effective_facts.get(int(snapshot_line.id)) or {}
|
||||
# part_number:有效事实 → 匹配事实 → 快照列
|
||||
part_number_value = (
|
||||
eff.get('part_number')
|
||||
if eff.get('part_number') is not None
|
||||
else (fact or {}).get('part_number') or snapshot_line.part_number
|
||||
)
|
||||
# reservation_id / required_qty 同构(required_qty 记得 str() 化)
|
||||
```
|
||||
|
||||
- [ ] **Step 4: 运行确认通过 + ui_state 域回归**
|
||||
|
||||
Run: `cd "D:/Workspace/HxProjects/hxops/.worktrees/editfeat/backend" && ./.venv/Scripts/python.exe -m pytest tests/test_ui_state_effective_values.py -v`;再 `grep -rln "ui_state" backend/tests | head -8` 跑既有 ui_state 相关测试(FAIL 的核对:若断言值列为冻结值,更新为有效值语义)。
|
||||
Expected: 全部 PASS
|
||||
|
||||
- [ ] **Step 5: 提交**
|
||||
|
||||
```bash
|
||||
git add backend/app/services/shipping_notice/ui_state.py backend/tests/test_ui_state_effective_values.py
|
||||
git commit -m "fix(shipping-notice): 通知准备值列改读有效订单值视图"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 5: 前端匹配表三单元格编辑框(+ i18n 四语言)
|
||||
|
||||
**Files:**
|
||||
- Modify: `frontend/src/features/chat/views/ShippingOrderReviewView.vue`(表格 :4936-4952 区段;保存逻辑复用 :2859 `loadFormalTaskDetail`)
|
||||
- Modify: `frontend/src/features/chat/api/shipping.api.ts`(`updateWorkspaceShippingNoticeLine` :1205-1225 的 evidence/reason 参数改可选)
|
||||
- Modify: `frontend/src/locales/{zh-CN,zh-TW,en,th}/chat.json`(`shippingOrderReview` 子树新增 3 键)
|
||||
- Test: 手动走查(前端无既有组件测试基建覆盖该区段;`npx vue-tsc -b` + build 为门禁)
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: `updateWorkspaceShippingNoticeLine(taskNo, lineIndex, patch, comment, options)`(lineIndex = `line.line_no - 1`,与后端 `ShippingOrderLine.position` 0 基对齐);Task 2 后 evidence/reason 可选。
|
||||
- Produces: 料号/预约号/需求数量三单元格点击变编辑框,保存成功后刷新并提示「请点击重新匹配库存」。
|
||||
|
||||
- [ ] **Step 1: api 签名放宽**
|
||||
|
||||
`shipping.api.ts` :1205-1225 `updateWorkspaceShippingNoticeLine` 的 options 中 `evidence`/`reason` 改为可选(`evidence?`/`reason?`),未传时不带这两个字段。同步改 :1177 `updateWorkspaceShippingNoticeFields` 同构参数。
|
||||
|
||||
- [ ] **Step 2: 表格单元格改造**
|
||||
|
||||
在 ShippingOrderReviewView.vue 的 prep 表格(:4952 行)把三个 `<td>` 的纯文本改为「文本 + 点击进入编辑」模式(普通编辑框,不抄下拉):
|
||||
|
||||
```vue
|
||||
<td>
|
||||
<input
|
||||
v-if="editingLine?.snapshot_line_id === line.snapshot_line_id"
|
||||
v-model="editingLine.part_number"
|
||||
class="..."
|
||||
:disabled="inlineEditSaving"
|
||||
@keyup.enter="saveInlineEdit(line)"
|
||||
@keyup.esc="cancelInlineEdit"
|
||||
/>
|
||||
<span v-else class="cursor-pointer" @click="startInlineEdit(line)">{{ line.part_number || '—' }}</span>
|
||||
</td>
|
||||
```
|
||||
|
||||
(`reservation_id`、`required_qty` 两个 td 同构;`required_qty` 用 `type="number"` 输入。)
|
||||
|
||||
script 区新增状态与方法(放在 :2792 附近的行级操作函数区):
|
||||
|
||||
```typescript
|
||||
/** 就地编辑状态:仅一行处于编辑态;保存走既有 update-notice-line 通道。 */
|
||||
const editingLine = ref<{ snapshot_line_id: number; line_no: number; part_number: string; reservation_id: string; required_qty: string } | null>(null);
|
||||
const inlineEditSaving = ref(false);
|
||||
|
||||
function startInlineEdit(line: { snapshot_line_id: number; line_no: number; part_number?: string | null; reservation_id?: string | null; required_qty?: string | null }) {
|
||||
editingLine.value = {
|
||||
snapshot_line_id: line.snapshot_line_id,
|
||||
line_no: line.line_no,
|
||||
part_number: String(line.part_number ?? ''),
|
||||
reservation_id: String(line.reservation_id ?? ''),
|
||||
required_qty: String(line.required_qty ?? ''),
|
||||
};
|
||||
}
|
||||
|
||||
function cancelInlineEdit() { editingLine.value = null; }
|
||||
|
||||
async function saveInlineEdit(line: { snapshot_line_id: number }) {
|
||||
const draft = editingLine.value;
|
||||
if (!draft || inlineEditSaving.value) return;
|
||||
const patch: Record<string, string> = {};
|
||||
if (draft.part_number !== String(line.part_number ?? '')) patch.part_number = draft.part_number;
|
||||
if (draft.reservation_id !== String(line.reservation_id ?? '')) patch.reservation_id = draft.reservation_id;
|
||||
if (draft.required_qty !== String(line.required_qty ?? '')) patch.qty = draft.required_qty;
|
||||
if (!Object.keys(patch).length) { cancelInlineEdit(); return; }
|
||||
inlineEditSaving.value = true;
|
||||
try {
|
||||
await updateWorkspaceShippingNoticeLine(
|
||||
/* taskNo */ formalTaskDetail.value?.task_no ?? '',
|
||||
/* lineIndex */ draft.line_no - 1,
|
||||
patch,
|
||||
/* comment */ '',
|
||||
{ expectedOrderDataVersion: formalTaskDetail.value?.order_data_version },
|
||||
);
|
||||
cancelInlineEdit();
|
||||
useMessage().success(t('chat.shippingOrderReview.inlineEdit.saved'));
|
||||
await loadFormalTaskDetail();
|
||||
} finally {
|
||||
inlineEditSaving.value = false;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
(`taskNo`/`order_data_version` 的实际取值字段以 `formalTaskDetail` 类型为准适配;`useMessage`/`t` 按该文件既有用法。失败提示走既有 HTTP 客户端 BusinessError 通道,不重复实现。)
|
||||
|
||||
禁用态:`inventory_rpa_is_running`(`formalTaskDetail.ui_state.preparation` 内字段,见类型 :1490-1497)为 true 时,`startInlineEdit` 直接 return 并提示 `inlineEdit.busy`。
|
||||
|
||||
- [ ] **Step 3: i18n 四语言**
|
||||
|
||||
在 `frontend/src/locales/{zh-CN,zh-TW,en,th}/chat.json` 的 `shippingOrderReview` 子树下新增:
|
||||
|
||||
```json
|
||||
"inlineEdit": {
|
||||
"saved": "已保存,请点击「重新匹配库存」生效",
|
||||
"busy": "系统处理中,请稍后再修改"
|
||||
}
|
||||
```
|
||||
|
||||
zh-TW:`已儲存,請點擊「重新匹配庫存」生效` / `系統處理中,請稍後再修改`;en:`Saved. Click "Re-match inventory" to apply` / `System is busy. Please try again later`;th:`บันทึกแล้ว กด "จับคู่สินค้าคงเหลือใหม่" เพื่อใช้งาน` / `ระบบกำลังประมวลผล โปรดลองอีกครั้งภายหลัง`。
|
||||
|
||||
- [ ] **Step 4: 构建门禁**
|
||||
|
||||
Run: `cd "D:/Workspace/HxProjects/hxops/.worktrees/editfeat/frontend" && npx vue-tsc -b --pretty false && npm run build`
|
||||
Expected: 0 error
|
||||
|
||||
- [ ] **Step 5: 提交**
|
||||
|
||||
```bash
|
||||
git add frontend/src/features/chat/views/ShippingOrderReviewView.vue frontend/src/features/chat/api/shipping.api.ts frontend/src/locales
|
||||
git commit -m "feat(shipping-notice): 通知准备匹配表支持履约字段就地编辑"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 6: 缺口复核入口修复(键错位 + 结案按钮 + 滚动锚)
|
||||
|
||||
**Files:**
|
||||
- Modify: `backend/app/services/shipping_notice/line_inventory_match_projection.py`(:472-508 后新增按 line_index 的加载器)
|
||||
- Modify: `backend/app/services/shipping_notice/order_review_fulfillment_decision_service.py`(:821/:846 键修复)
|
||||
- Modify: `frontend/src/features/chat/views/ShippingOrderReviewView.vue`(结案按钮 + 滚动锚 :3823-3832)
|
||||
- Modify: `frontend/src/locales/{zh-CN,zh-TW,en,th}/chat.json`(结案文案)
|
||||
- Test: `backend/tests/test_review_line_fulfillment_shortage_projection.py`(新建)
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: 匹配事实行内 `line_index`;`decide_review_line_fulfillment`(既有 API `POST /shipping-notice/order-review-cases/<case_no>/line-fulfillment/decide`)。
|
||||
- Produces: `line_fulfillment.has_shortage` 正确 → `hasInventoryIssues=True` → `open_shortage_review` 动作可见;prep 表「更多操作」新增结案入口。
|
||||
|
||||
- [ ] **Step 1: 写失败测试(键错位)**
|
||||
|
||||
创建 `backend/tests/test_review_line_fulfillment_shortage_projection.py`:
|
||||
|
||||
```python
|
||||
"""
|
||||
tests/test_review_line_fulfillment_shortage_projection.py
|
||||
|
||||
用途:锁定行级履约投影的匹配事实关联(修复草稿行ID vs 快照行ID 键错位)。
|
||||
依赖:pytest、order_review_fulfillment_decision_service、有效视图夹具。
|
||||
逻辑:确认 Case + 短缺匹配事实下,投影必须报 has_shortage=True 且行级 is_shortage=True。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app import db
|
||||
from app.models import ShippingNoticeLineInventoryMatch, ShippingOrderReviewCase, ShippingOrderReviewDraft
|
||||
from app.services.shipping_notice.order_review_fulfillment_decision_service import (
|
||||
project_review_case_line_decisions,
|
||||
)
|
||||
from tests.test_effective_order_view import _seed_frozen_order
|
||||
|
||||
|
||||
def test_line_fulfillment_has_shortage_with_match_facts(app):
|
||||
"""修复键错位:草稿行经 _line_index 关联匹配事实,has_shortage 必须为真。"""
|
||||
with app.app_context():
|
||||
fixture = _seed_frozen_order()
|
||||
# 短缺事实:第 0 行 not_found、缺 10。
|
||||
db.session.add(ShippingNoticeLineInventoryMatch(
|
||||
task_id=fixture.order.id, snapshot_line_id=fixture.snap_lines[0].id,
|
||||
line_no=1, line_index=0, match_result='not_found', inventory_status='ready',
|
||||
required_qty='10', available_qty='0', shortage_qty='10',
|
||||
reservation_id='RSV-1', part_number='D4-A08AR12000002-', is_current=True,
|
||||
))
|
||||
case = ShippingOrderReviewCase(
|
||||
case_no='SNRC-SHORTAGE-PROJ', run_id=911, unit_id=912, document_id=913,
|
||||
owner_user_id=fixture.user.id, status='confirmed', confirmed_task_id=fixture.order.id,
|
||||
)
|
||||
db.session.add(case)
|
||||
db.session.flush()
|
||||
db.session.add(ShippingOrderReviewDraft(
|
||||
case_id=case.id, draft_version=1, schema_version_id=fixture.snapshot.schema_version_id,
|
||||
header_values_json={}, lines_json=[{'draft_line_id': 'line-1', 'part_number': 'D4-A08AR12000002-'}],
|
||||
))
|
||||
db.session.flush()
|
||||
case.current_draft_id = case.drafts[0].id if case.drafts else None
|
||||
db.session.flush()
|
||||
result = project_review_case_line_decisions(case)
|
||||
# 断言:修复前 has_shortage 恒 False(键错位);修复后为 True。
|
||||
assert result['has_shortage'] is True
|
||||
assert result['lines'][0]['is_shortage'] is True
|
||||
```
|
||||
|
||||
(`ShippingOrderReviewDraft` 必填列以模型为准适配;`current_draft` 关系按 :128-130 `post_update` 语义先 flush 再回填 current_draft_id。)
|
||||
|
||||
- [ ] **Step 2: 运行确认失败**
|
||||
|
||||
Run: `cd "D:/Workspace/HxProjects/hxops/.worktrees/editfeat/backend" && ./.venv/Scripts/python.exe -m pytest tests/test_review_line_fulfillment_shortage_projection.py -v`
|
||||
Expected: FAIL,`has_shortage` 为 False
|
||||
|
||||
- [ ] **Step 3: 实现后端键修复**
|
||||
|
||||
(a) `line_inventory_match_projection.py` :508 后新增:
|
||||
|
||||
```python
|
||||
def load_current_match_facts_by_line_index(task_id: int) -> dict[int, dict[str, Any]]:
|
||||
"""按 line_index 索引当前匹配事实(Case 履约投影专用)。
|
||||
|
||||
核心逻辑:与 load_current_match_facts_by_task 同一查询;Case 草稿行只有
|
||||
_line_index 没有 snapshot_line_id,必须按行号索引才能关联上事实。
|
||||
"""
|
||||
rows = (
|
||||
ShippingNoticeLineInventoryMatch.query
|
||||
.filter_by(task_id=int(task_id), is_current=True)
|
||||
.all()
|
||||
)
|
||||
return {
|
||||
int(row.line_index): serialize_match_fact(row)
|
||||
for row in rows
|
||||
if row.line_index is not None
|
||||
}
|
||||
```
|
||||
|
||||
(`serialize_match_fact` 与查询结构照抄 :496-508 既有实现;不共享 g memo 亦可,或复用同款 memo。)
|
||||
|
||||
(b) `order_review_fulfillment_decision_service.py` :821 加载改双通道、:846 查找改行号:
|
||||
|
||||
```python
|
||||
match_facts = load_current_match_facts_by_task(formal_ot.get('task_id'))
|
||||
from app.services.shipping_notice.line_inventory_match_projection import load_current_match_facts_by_line_index
|
||||
match_facts_by_line = load_current_match_facts_by_line_index(int(formal_ot.get('task_id')))
|
||||
```
|
||||
|
||||
```python
|
||||
# [BE-键修复] 草稿行只有 _line_index;旧实现误用 draft_line_id 查 snapshot_line_id 键,恒 miss。
|
||||
line_index = draft_line.get('_line_index')
|
||||
fact = (
|
||||
match_facts_by_line.get(int(line_index))
|
||||
if line_index is not None else None
|
||||
)
|
||||
```
|
||||
|
||||
- [ ] **Step 4: 运行确认通过 + 决定域回归**
|
||||
|
||||
Run: `cd "D:/Workspace/HxProjects/hxops/.worktrees/editfeat/backend" && ./.venv/Scripts/python.exe -m pytest tests/test_review_line_fulfillment_shortage_projection.py tests/test_shipping_review_line_fulfillment_decision.py tests/test_line_closure_gate_sync.py -v`
|
||||
Expected: 全部 PASS
|
||||
|
||||
- [ ] **Step 5: 前端结案按钮 + 滚动锚**
|
||||
|
||||
(a) `ShippingOrderReviewView.vue` prep 表「更多操作」td(:4952 行尾)追加结案按钮(与既有放行缺口按钮 `openReleaseInventoryShortage` 同款交互:弹原因输入):
|
||||
|
||||
```vue
|
||||
<button
|
||||
v-if="formalPreparationLineAllows(line, 'close')"
|
||||
class="..."
|
||||
:title="t('chat.shippingOrderReview.lineActions.closeLine')"
|
||||
@click="openCloseLineDialog(line)"
|
||||
>⨂</button>
|
||||
```
|
||||
|
||||
script 区(放行按钮函数旁)新增:通过 `activeCase.value.line_fulfillment.lines` 按 `snapshot_line_id`(或 line_index)找到 `draft_line_id`,调用既有 line-fulfillment decide API:
|
||||
|
||||
```typescript
|
||||
async function confirmCloseLine(lineIndex: number, reason: string) {
|
||||
const caseNo = activeCase.value?.case_no;
|
||||
const target = (activeCase.value?.line_fulfillment?.lines || []).find(
|
||||
(item) => item.line_index === lineIndex,
|
||||
);
|
||||
if (!caseNo || !target?.draft_line_id) return;
|
||||
await closeReviewLineFulfillment(caseNo, target.draft_line_id, reason); // 既有/新增 api 封装,decision_code='close_unfulfillable'
|
||||
await loadFormalTaskDetail();
|
||||
}
|
||||
```
|
||||
|
||||
(api 层若无 close 封装,按 :2149 decide API 的既有调用模式加 `decideReviewLineFulfillment(caseNo, draftLineId, decisionCode, reason)`;原因输入复用放行缺口的弹层模式。)
|
||||
|
||||
(b) 滚动锚 :3823-3832:`hasFormalOt` 分支的 `review-order-lines-table` 改为 `review-fulfillment-prep-workspace`(缺口语境的真实宿主)。
|
||||
|
||||
(c) i18n 四语言 `chat.json` `shippingOrderReview.lineActions`:
|
||||
|
||||
```json
|
||||
"closeLine": "结案(不再发货)",
|
||||
"closeLineReason": "请填写结案原因",
|
||||
"closeLineConfirm": "确认结案"
|
||||
```
|
||||
|
||||
zh-TW:`結案(不再發貨)`/`請填寫結案原因`/`確認結案`;en:`Close line (no shipment)`/`Enter a reason to close`/`Confirm close`;th:`ปิดบรรทัด (ไม่จัดส่ง)`/`กรอกเหตุผลเพื่อปิด`/`ยืนยันการปิด`。
|
||||
|
||||
- [ ] **Step 6: 构建门禁 + 提交**
|
||||
|
||||
Run: `cd "D:/Workspace/HxProjects/hxops/.worktrees/editfeat/frontend" && npx vue-tsc -b --pretty false && npm run build`
|
||||
|
||||
```bash
|
||||
git add backend/app/services/shipping_notice/line_inventory_match_projection.py backend/app/services/shipping_notice/order_review_fulfillment_decision_service.py backend/tests/test_review_line_fulfillment_shortage_projection.py frontend/src/features/chat/views/ShippingOrderReviewView.vue frontend/src/locales
|
||||
git commit -m "fix(shipping-notice): 修复缺口投影键错位并补齐结案入口"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 7: 文档同步与回归
|
||||
|
||||
**Files:**
|
||||
- Modify: `docs/features/shipping-notice/technical.md`(在「有效订单值视图与行结案豁免(2026-09-17)」小节后追加)
|
||||
- Modify: `docs/funclist.md`
|
||||
|
||||
- [ ] **Step 1: technical.md 追加小节**
|
||||
|
||||
```markdown
|
||||
### 通知准备就地编辑与入口修复(2026-09-18)
|
||||
|
||||
**编辑权限状态制**:正式订单字段(含履约三要素 料号/预约号/数量)默认在
|
||||
「Excel 未生成 + 无活动 Attempt」时可编辑(DEFAULT_EDITABLE_AFTER_TASK_CREATION=True,
|
||||
Schema task_edit_policy 退化为反向锁);原因/证据不强制,审计链自动记录 old→new
|
||||
(shipping_order_review_events / formal_task_field_edited)。通知准备匹配表三单元格
|
||||
就地编辑 → 保存(order_data_version+1)→ 手动「重新匹配库存」生效。
|
||||
|
||||
**有效值消费面补全**:通知准备值列、预约注册(ensure_task_reservations)与核验比对
|
||||
(record_inventory_verification)均改读有效订单值视图——修复编辑后重匹配必抛
|
||||
RESERVATION_MISMATCH 的阻断;匹配结果列仍反映最近一轮匹配事实。
|
||||
|
||||
**缺口复核入口修复**:行级履约投影的匹配事实关联由 draft_line_id 改为 line_index
|
||||
(修复 has_shortage 恒 False 导致入口被隐藏);prep 表新增行级结案入口,滚动锚指向
|
||||
prep 工作区。**边界**:Excel ready 后编辑硬冻结;通知已存在后编辑不重物化通知行
|
||||
(可达窗口窄,声明边界);done_line_report/OT 通知列表投影仍显示冻结原值(历史定格语义)。
|
||||
```
|
||||
|
||||
- [ ] **Step 2: funclist.md 追加一行**
|
||||
|
||||
```markdown
|
||||
- 通知准备界面支持料号/预约号/数量就地编辑(保存后手动重新匹配库存生效);缺口复核入口与行结案按钮修复可见;编辑权限为状态制(Excel 生成前可改)。
|
||||
```
|
||||
|
||||
- [ ] **Step 3: 后端定向回归 + 前端构建**
|
||||
|
||||
Run: `cd "D:/Workspace/HxProjects/hxops/.worktrees/editfeat/backend" && ./.venv/Scripts/python.exe -m pytest tests/test_effective_order_view.py tests/test_reservation_effective_view.py tests/test_ui_state_effective_values.py tests/test_review_line_fulfillment_shortage_projection.py tests/test_shipping_schema_edit_policy.py tests/test_shipping_review_formal_task_edit.py tests/test_shipping_formal_task_edit_audit.py tests/test_shipping_stp_phase4_line_inventory_match.py tests/test_shipping_review_line_fulfillment_decision.py tests/test_line_closure_gate_sync.py tests/test_reservation_effective_view.py -q`
|
||||
Run: `cd frontend && npx vue-tsc -b --pretty false && npm run build`
|
||||
Expected: 全绿(前端 0 error)。域内回归为主口径(与用户确认的回归策略一致)。
|
||||
|
||||
- [ ] **Step 4: 手工走查清单(并入交付说明)**
|
||||
|
||||
1. 卡匹配订单:匹配表改料号(去尾部 `-`)→ 保存 → 值列立即显示新值 → 点「重新匹配库存」→ 匹配/核验通过(不再 RESERVATION_MISMATCH)。
|
||||
2. 改需求数量 → 保存 → 重匹配 → 缺口数量按新值计算。
|
||||
3. 系统处理中(RPA 运行)时编辑框不可进入。
|
||||
4. 缺口状态订单:订单复核工作台出现缺口复核入口(open_shortage_review 可见可点,滚动到 prep 工作区);prep 表行级「结案」可用 → 结案后整单不再被该行阻断。
|
||||
5. Excel 生成后:编辑框不可进入(冻结)。
|
||||
|
||||
- [ ] **Step 5: 提交**
|
||||
|
||||
```bash
|
||||
git add docs/features/shipping-notice/technical.md docs/funclist.md
|
||||
git commit -m "docs(shipping-notice): 补充就地编辑与入口修复语义文档"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Self-Review(已执行)
|
||||
|
||||
1. **覆盖度**:清单 6 项 ↔ 任务:闸门翻转+原因可选=T2;值列=T4;预约/核验=T3;编辑框+样式=i18n=T5;Decimal=T1;面板两 bug=T6(键修复+结案按钮+滚动锚;死组件 ReviewInventoryIssueList 明确**不挂载**——其职能由 prep 表内嵌入口承接,清理列后续);文档回归=T7。✔
|
||||
2. **占位符**:T2 Step1 的两个测试改写给出了断言语义+「照抄原夹具」指引(原夹具代码未在侦察中展开,属于对实现者的定向指令而非 TBD);T3/T4 的适配注记同性质。其余步骤均有完整代码。✔(有意为之的例外已标注。)
|
||||
3. **类型一致性**:`effective_line_facts_for_notice(owner)`(既有,T3/T4 消费一致);`load_current_match_facts_by_line_index(task_id)`(T6 定义与使用一致);前端 `updateWorkspaceShippingNoticeLine(taskNo, lineIndex, patch, comment, options)`(既有签名,T5 传参对齐);i18n 键名 T5/T6 与 Step 中引用一致。✔
|
||||
4. **已知风险**:T2 契约翻转的测试改动面依赖 grep 兜底(步骤内含);T3 的 ensure_task_reservations 分支结构需先通读再落改(语义表已给);T4 `_build_stage_context` 函数名/返回形状按实际适配;T6 结案按钮的 draft_line_id 解析依赖 T6 键修复后的投影行(有 snapshot_line_id/line_index 可依)。
|
||||
@@ -1178,7 +1178,7 @@ export async function updateWorkspaceShippingNoticeFields(
|
||||
taskNo: string,
|
||||
fields: Partial<ShippingNoticeHeader>,
|
||||
comment: string | undefined,
|
||||
options: { expectedOrderDataVersion: number; idempotencyKey?: string; evidence: ShippingReviewEvidence; reason: string },
|
||||
options: { expectedOrderDataVersion: number; idempotencyKey?: string; evidence?: ShippingReviewEvidence; reason?: string },
|
||||
) {
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/update-notice-fields`,
|
||||
@@ -1186,8 +1186,9 @@ export async function updateWorkspaceShippingNoticeFields(
|
||||
fields,
|
||||
...(comment ? { comment } : {}),
|
||||
expected_order_data_version: options.expectedOrderDataVersion,
|
||||
evidence: options.evidence,
|
||||
reason: options.reason,
|
||||
// 证据/理由改为可选:未传时不带字段,与后端免证据编辑通道(Task 2)对齐。
|
||||
...(options.evidence ? { evidence: options.evidence } : {}),
|
||||
...(options.reason ? { reason: options.reason } : {}),
|
||||
...(options.idempotencyKey ? { idempotency_key: options.idempotencyKey } : {}),
|
||||
}),
|
||||
);
|
||||
@@ -1207,7 +1208,7 @@ export async function updateWorkspaceShippingNoticeLine(
|
||||
lineIndex: number,
|
||||
patch: Partial<ShippingNoticeLine> & { quantity?: number },
|
||||
comment: string | undefined,
|
||||
options: { expectedOrderDataVersion: number; idempotencyKey?: string; evidence: ShippingReviewEvidence; reason: string },
|
||||
options: { expectedOrderDataVersion: number; idempotencyKey?: string; evidence?: ShippingReviewEvidence; reason?: string },
|
||||
) {
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/update-notice-line`,
|
||||
@@ -1216,8 +1217,9 @@ export async function updateWorkspaceShippingNoticeLine(
|
||||
patch,
|
||||
...(comment ? { comment } : {}),
|
||||
expected_order_data_version: options.expectedOrderDataVersion,
|
||||
evidence: options.evidence,
|
||||
reason: options.reason,
|
||||
// 证据/理由改为可选:未传时不带字段,与后端免证据编辑通道(Task 2)对齐。
|
||||
...(options.evidence ? { evidence: options.evidence } : {}),
|
||||
...(options.reason ? { reason: options.reason } : {}),
|
||||
...(options.idempotencyKey ? { idempotency_key: options.idempotencyKey } : {}),
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -17,8 +17,9 @@
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, defineAsyncComponent, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import type { Component } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { Bot, Check, ChevronDown, Crosshair, Download, MoreHorizontal, Plus, RefreshCw, Undo2, Copy, Trash2 } from 'lucide-vue-next';
|
||||
import { Bot, Check, ChevronDown, Crosshair, Download, MoreHorizontal, Pencil, Plus, RefreshCw, Undo2, Copy, Trash2, X } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
@@ -37,6 +38,7 @@ import {
|
||||
retryWorkspaceShippingOrderStpAutoCreate,
|
||||
retryShippingNoticeIntake,
|
||||
decideWorkspaceShippingOrderReviewLineFulfillment,
|
||||
updateWorkspaceShippingNoticeLine,
|
||||
waveWorkspaceShippingOrderReviewLineFulfillment,
|
||||
setWorkspaceShippingTaskOdmChoice,
|
||||
viewWorkspaceShippingOrderReviewHighlightDiagnostic,
|
||||
@@ -1930,7 +1932,8 @@ async function handleCurrentTaskAction(
|
||||
break;
|
||||
case 'open_inventory_match_review':
|
||||
if (hasFormalOt.value) {
|
||||
scrollWorkbenchAnchor('review-order-lines-table');
|
||||
// 正式 OT 后匹配/缺口语境的真实宿主是通知准备工作区;订单明细表不承载库存结果。
|
||||
scrollWorkbenchAnchor('review-fulfillment-prep-workspace');
|
||||
} else {
|
||||
workbenchMode.value = 'inventory';
|
||||
scrollWorkbenchAnchor('review-inventory-issue-list');
|
||||
@@ -2603,9 +2606,8 @@ function formalPreparationLineSource(line: {
|
||||
|
||||
/** 锁定边界 = Excel 生成(D7):后端 preparation.source_locked 下发,生成后行源只读。 */
|
||||
const formalPreparationSourceLocked = computed(() => Boolean(formalPreparationContext.value?.source_locked));
|
||||
/** 多文件冲突行的行内选源暂存(line_no → 选定 source_code),提交后由后端映射快照行并重匹配。 */
|
||||
const lineSourceSelections = ref<Record<string, string>>({});
|
||||
const lineSourceBusy = ref(false);
|
||||
/** 库存源选择不再有独立确认流:行进入就地编辑态后在下拉中改选,随行级「保存」统一提交
|
||||
* (override_line_inventory_source Gate 动作,见 saveInlineEdit);展示态回退为文本。 */
|
||||
|
||||
/** 选源下拉项文案:源编码始终可见(等宽语义由样式层保证)。 */
|
||||
function lineSourceOptionLabel(code: string): string {
|
||||
@@ -2613,58 +2615,14 @@ function lineSourceOptionLabel(code: string): string {
|
||||
return String(code || '').trim().toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交歧义行选定源:走正式 Gate 动作 override_line_inventory_source(方案 3·放开,唯一选源入口),
|
||||
* 后端校验启用/Excel 锁并仅重匹配该行;成功后清空行内暂存并刷新任务详情。
|
||||
*/
|
||||
async function submitLineSourceSelection(line: { snapshot_line_id?: number | null; line_no?: string | number | null }) {
|
||||
const selectionKey = String(line.snapshot_line_id ?? '');
|
||||
const sourceCode = String(lineSourceSelections.value[selectionKey] || '').trim();
|
||||
const lineNo = Number(line.line_no);
|
||||
if (!sourceCode || !Number.isInteger(lineNo) || lineNo < 1 || lineSourceBusy.value) return;
|
||||
lineSourceBusy.value = true;
|
||||
try {
|
||||
await submitFormalGateAction('override_line_inventory_source', {
|
||||
line_no: lineNo,
|
||||
source_code: sourceCode,
|
||||
});
|
||||
delete lineSourceSelections.value[selectionKey];
|
||||
} finally {
|
||||
lineSourceBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 人工覆写库存源(方案 3·放开):后端下发全部已启用源 source_options,供行级下拉人工指定。 */
|
||||
const formSourceOptions = computed(() => formalPreparationContext.value?.source_options || []);
|
||||
const overrideSourceSelections = ref<Record<string, string>>({});
|
||||
const overrideSourceBusy = ref(false);
|
||||
|
||||
function overrideSourceOptionLabel(code: string): string {
|
||||
// 兜底:下拉只展示源编码(如 DSV360_AWSSG),不展示冗长 display_name,便于快速识别。
|
||||
return String(code || '').trim().toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交人工覆写行库存源:走正式 Gate 动作 override_line_inventory_source(方案 3·放开),
|
||||
* 后端校验源启用/Excel 锁并仅重匹配该行;成功后清空暂存并刷新任务详情。
|
||||
*/
|
||||
async function submitOverrideSource(line: { snapshot_line_id?: number | null; line_no?: string | number | null }) {
|
||||
const selectionKey = String(line.snapshot_line_id ?? '');
|
||||
const sourceCode = String(overrideSourceSelections.value[selectionKey] || '').trim();
|
||||
const lineNo = Number(line.line_no);
|
||||
if (!sourceCode || !Number.isInteger(lineNo) || lineNo < 1 || overrideSourceBusy.value) return;
|
||||
overrideSourceBusy.value = true;
|
||||
try {
|
||||
await submitFormalGateAction('override_line_inventory_source', {
|
||||
line_no: lineNo,
|
||||
source_code: sourceCode,
|
||||
});
|
||||
delete overrideSourceSelections.value[selectionKey];
|
||||
} finally {
|
||||
overrideSourceBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 整单 ODM 裁决列可见性:任一行候选多于一个时展示(候选已经客户范围过滤)。 */
|
||||
const formalPreparationOdmColumnVisible = computed(() =>
|
||||
(formalPreparationContext.value?.lines || []).some((line) => (line.odm_values?.length || 0) > 1),
|
||||
@@ -2761,7 +2719,7 @@ async function confirmReleaseInventoryShortage() {
|
||||
const caseNo = activeCase.value?.case_no;
|
||||
const reason = releaseInventoryReason.value.trim();
|
||||
const requiredFields = line?.release_required_fields || [];
|
||||
if (!line || !caseNo || !reason || requiredFields.some((field) => !releaseInventoryFieldValues.value[field.field_id]?.trim()) || releaseInventoryBusy.value) return;
|
||||
if (!line || !caseNo || requiredFields.some((field) => !releaseInventoryFieldValues.value[field.field_id]?.trim()) || releaseInventoryBusy.value) return;
|
||||
releaseInventoryBusy.value = true;
|
||||
try {
|
||||
await decideWorkspaceShippingOrderReviewLineFulfillment(caseNo, {
|
||||
@@ -2788,6 +2746,160 @@ function formalPreparationLineInventoryFileNo(line: { snapshot_line_id?: number
|
||||
return String(line.inventory_file_no || fulfillment?.inventory_file_no || '').trim();
|
||||
}
|
||||
|
||||
/** 行内放行补录条(常显子行):短缺行携带必填放行字段时直接在行下补填,替代弹窗。 */
|
||||
const releaseBarValues = ref<Record<string, Record<string, string>>>({});
|
||||
const releaseBarBusy = ref<Record<string, boolean>>({});
|
||||
|
||||
function releaseBarKey(line: { snapshot_line_id?: number | null }): string {
|
||||
return String(line.snapshot_line_id ?? '');
|
||||
}
|
||||
|
||||
/** 放行必填字段:仅短缺行且投影声明了必填补录项(有候选缺失才需要补录)。 */
|
||||
function releaseBarLineRequiredFields(line: { snapshot_line_id?: number | null }) {
|
||||
const fulfillment = formalPreparationLineFulfillment(line);
|
||||
return fulfillment?.release_required_fields || [];
|
||||
}
|
||||
|
||||
/** 缺字段型短缺行:放行走行内补录(而非仅原因的旧弹窗路径)。 */
|
||||
function releaseBarHasFields(line: {
|
||||
snapshot_line_id?: number | null;
|
||||
shortage_qty?: string | number | null;
|
||||
}): boolean {
|
||||
return Number(line.shortage_qty || 0) > 0 && releaseBarLineRequiredFields(line).length > 0;
|
||||
}
|
||||
|
||||
/** 补录条展开态:默认收起(表格保持干净),由 ⋯ 菜单「放行缺口」或缺 N 项徽标点击展开。 */
|
||||
const releaseBarExpandedFor = ref<string | null>(null);
|
||||
|
||||
function expandReleaseBar(line: { snapshot_line_id?: number | null }) {
|
||||
if (inlineEditBusy.value) {
|
||||
msg.warning(t('chat.shippingOrderReview.inlineEdit.busy'));
|
||||
return;
|
||||
}
|
||||
releaseBarExpandedFor.value = releaseBarKey(line);
|
||||
}
|
||||
|
||||
function releaseBarValue(
|
||||
line: { snapshot_line_id?: number | null },
|
||||
field: { field_id?: string | null },
|
||||
): string {
|
||||
return releaseBarValues.value[releaseBarKey(line)]?.[String(field.field_id)] ?? '';
|
||||
}
|
||||
|
||||
function updateReleaseBarValue(
|
||||
line: { snapshot_line_id?: number | null },
|
||||
field: { field_id?: string | null },
|
||||
value: string,
|
||||
) {
|
||||
const key = releaseBarKey(line);
|
||||
releaseBarValues.value = {
|
||||
...releaseBarValues.value,
|
||||
[key]: { ...(releaseBarValues.value[key] || {}), [String(field.field_id)]: value },
|
||||
};
|
||||
}
|
||||
|
||||
/** 放行按钮可用性:后端授权 + 必填补录项全部已填 + 非保存中。 */
|
||||
function releaseBarReadyFor(line: { snapshot_line_id?: number | null }): boolean {
|
||||
const fulfillment = formalPreparationLineFulfillment(line);
|
||||
const required = releaseBarLineRequiredFields(line);
|
||||
return Boolean(
|
||||
fulfillment?.line_allowed_actions?.includes('release_inventory_shortage')
|
||||
&& required.every((field) => releaseBarValue(line, field).trim())
|
||||
&& !releaseBarBusy.value[releaseBarKey(line)],
|
||||
);
|
||||
}
|
||||
|
||||
/** 行内放行提交:走既有 decide 通道;原因可选(人工放行事实由审计链记录)。 */
|
||||
async function confirmReleaseBar(line: { snapshot_line_id?: number | null }) {
|
||||
const caseNo = activeCase.value?.case_no;
|
||||
const fulfillment = formalPreparationLineFulfillment(line);
|
||||
const key = releaseBarKey(line);
|
||||
const required = releaseBarLineRequiredFields(line);
|
||||
if (
|
||||
!caseNo || !fulfillment?.draft_line_id
|
||||
|| !required.every((field) => releaseBarValue(line, field).trim())
|
||||
|| releaseBarBusy.value[key]
|
||||
) return;
|
||||
releaseBarBusy.value = { ...releaseBarBusy.value, [key]: true };
|
||||
try {
|
||||
await decideWorkspaceShippingOrderReviewLineFulfillment(caseNo, {
|
||||
draft_line_id: String(fulfillment.draft_line_id || ''),
|
||||
decision_code: 'release_inventory_shortage',
|
||||
reason: '',
|
||||
release_field_values: { ...(releaseBarValues.value[key] || {}) },
|
||||
expected_draft_version: activeCase.value?.draft?.draft_version,
|
||||
});
|
||||
const next = { ...releaseBarValues.value };
|
||||
delete next[key];
|
||||
releaseBarValues.value = next;
|
||||
// 放行写入成功即结束用户交互;Notice/Excel 由后端 Job 异步创建(与原弹窗通道一致)。
|
||||
handleGateRecoveryAccepted({ releaseAutoAdvance: true });
|
||||
} catch (error) {
|
||||
msg.warning(error instanceof Error ? error.message : t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
} finally {
|
||||
releaseBarBusy.value = { ...releaseBarBusy.value, [key]: false };
|
||||
}
|
||||
}
|
||||
|
||||
/** 行结案弹窗状态;与放行缺口弹窗同款交互(原因必填),走 line-fulfillment decide 通道。 */
|
||||
const closeLineDialogLine = ref<ShippingOrderReviewLineFulfillmentLine | null>(null);
|
||||
const closeLineReason = ref('');
|
||||
const closeLineBusy = ref(false);
|
||||
|
||||
/**
|
||||
* 结案按钮可见性:仅「无货可发」的未终态 prep 行开放。
|
||||
* 核心逻辑:line_allowed_actions 由后端投影下发(终态行返回空数组,天然排除已结案/
|
||||
* 已放行/已入波次行),前端再叠加短缺信号(is_shortage / 缺量>0 / not_found)过滤;
|
||||
* 后端 decide API 才是权威闸门,这里只做入口收敛。
|
||||
*/
|
||||
function formalPreparationLineCloseVisible(line: { snapshot_line_id?: number | null; shortage_qty?: string | number | null }): boolean {
|
||||
if (!formalPreparationLineAllows(line, 'close_unfulfillable')) return false;
|
||||
const fulfillment = formalPreparationLineFulfillment(line);
|
||||
if (fulfillment?.decision?.decision_code === 'close_unfulfillable') return false;
|
||||
const notFound = String(fulfillment?.match_result || '').trim().toLowerCase() === 'not_found';
|
||||
const shortageQty = Number(line.shortage_qty ?? fulfillment?.shortage_qty ?? 0) > 0;
|
||||
return Boolean(fulfillment?.is_shortage) || shortageQty || notFound;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开行结案弹窗:按快照行身份定位履约投影行(携带 draft_line_id)。
|
||||
* 核心逻辑:与行内编辑互斥——弹窗打开即取消该行编辑态,避免两套写路径叠加。
|
||||
*/
|
||||
function openCloseLineDialog(line: { snapshot_line_id?: number | null }) {
|
||||
const fulfillment = formalPreparationLineFulfillment(line);
|
||||
if (!fulfillment) return;
|
||||
cancelInlineEdit();
|
||||
closeLineDialogLine.value = fulfillment;
|
||||
closeLineReason.value = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交行结案决定(decision_code='close_unfulfillable',原因必填)。
|
||||
* 核心逻辑:复用既有 line-fulfillment decide API;成功后走恢复协调刷新三投影,
|
||||
* prep 表即时反映已结案状态(后端拒绝无效流转时以 BusinessError 文案提示)。
|
||||
*/
|
||||
async function confirmCloseLine() {
|
||||
const line = closeLineDialogLine.value;
|
||||
const caseNo = activeCase.value?.case_no;
|
||||
const reason = closeLineReason.value.trim();
|
||||
if (!line || !caseNo || !reason || closeLineBusy.value) return;
|
||||
closeLineBusy.value = true;
|
||||
try {
|
||||
await decideWorkspaceShippingOrderReviewLineFulfillment(caseNo, {
|
||||
draft_line_id: String(line.draft_line_id || ''),
|
||||
decision_code: 'close_unfulfillable',
|
||||
reason,
|
||||
expected_draft_version: activeCase.value?.draft?.draft_version,
|
||||
});
|
||||
closeLineDialogLine.value = null;
|
||||
handleGateRecoveryAccepted();
|
||||
} catch (error) {
|
||||
msg.warning(error instanceof Error ? error.message : t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
} finally {
|
||||
closeLineBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 下载行级实际匹配快照,禁止退回到任务级 active link。 */
|
||||
async function downloadFormalPreparationLineInventoryFile(line: {
|
||||
snapshot_line_id?: number | null;
|
||||
@@ -2812,6 +2924,257 @@ async function retryFormalPreparationLine(
|
||||
await submitFormalGateAction(actionCode, { snapshot_line_id: Number(snapshotLineId) });
|
||||
}
|
||||
|
||||
/**
|
||||
* 库存 RPA 是否运行中(就地编辑的 busy 禁用条件)。
|
||||
* 核心逻辑:后端 preparation 摘要当前未下发 inventory_rpa_is_running(仅内部计算),
|
||||
* 故先消费可选下发字段(后端补发即生效),缺失时以 status==='processing'
|
||||
* (尚无匹配结果且无门禁 → 首轮抓取进行中)兜底;重匹配期间的写冲突由
|
||||
* 后端 SHIPPING.EDIT_WINDOW_SYSTEM_BUSY 守卫兜底。
|
||||
*/
|
||||
const inlineEditBusy = computed(() => {
|
||||
const preparation = formalTaskDetail.value?.ui_state?.stage_context?.preparation;
|
||||
if (!preparation) return false;
|
||||
const running = (preparation as { inventory_rpa_is_running?: unknown }).inventory_rpa_is_running;
|
||||
if (typeof running === 'boolean') return running;
|
||||
return preparation.status === 'processing';
|
||||
});
|
||||
|
||||
/** 就地编辑状态:仅一行处于编辑态;保存走既有 update-notice-line 通道(免证据人工修订)。
|
||||
* 编辑入口 = 行级「编辑」按钮(防单元格误触);编辑态下更多操作列替换为保存/取消。 */
|
||||
const editingLine = ref<{
|
||||
snapshot_line_id: number;
|
||||
line_no: number;
|
||||
part_number: string;
|
||||
reservation_id: string;
|
||||
required_qty: string;
|
||||
source_code: string;
|
||||
} | null>(null);
|
||||
const inlineEditSaving = ref(false);
|
||||
|
||||
/**
|
||||
* 就地编辑草稿种子值:把展示占位「—」还原为空串,避免占位符被当作真实值提交。
|
||||
* @param value - prep 行展示值(可能为 null / '—' / 数字)
|
||||
* @returns 可直接进入输入框的字符串
|
||||
*/
|
||||
function inlineEditSeedValue(value: unknown): string {
|
||||
const text = String(value ?? '').trim();
|
||||
return text === '—' ? '' : text;
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入单个准备行的就地编辑(料号 / 预约号 / 需求数量三个值列)。
|
||||
* @param line - prep 展示行;snapshot_line_id 定位编辑行,line_no-1 与后端 line_index 0 基对齐
|
||||
*/
|
||||
function startInlineEdit(line: {
|
||||
snapshot_line_id?: number | null;
|
||||
line_no?: string | number | null;
|
||||
part_number?: string | null;
|
||||
reservation_id?: string | null;
|
||||
required_qty?: string | number | null;
|
||||
selected_source_code?: string | null;
|
||||
source_code?: string | null;
|
||||
}) {
|
||||
if (!line.snapshot_line_id || inlineEditSaving.value) return;
|
||||
// 库存 RPA 运行中禁止改值:匹配进行中修改会与重匹配竞态。
|
||||
if (inlineEditBusy.value) {
|
||||
msg.warning(t('chat.shippingOrderReview.inlineEdit.busy'));
|
||||
return;
|
||||
}
|
||||
editingLine.value = {
|
||||
snapshot_line_id: Number(line.snapshot_line_id),
|
||||
line_no: Number(line.line_no || 0),
|
||||
part_number: inlineEditSeedValue(line.part_number),
|
||||
reservation_id: inlineEditSeedValue(line.reservation_id),
|
||||
required_qty: inlineEditSeedValue(line.required_qty),
|
||||
source_code: inlineEditSeedValue(line.selected_source_code || line.source_code),
|
||||
};
|
||||
}
|
||||
|
||||
/** 行是否处于就地编辑态(统一 Number 收敛,避免模板严格等于的类型漂移)。 */
|
||||
function isInlineEditing(line: { snapshot_line_id?: number | null }): boolean {
|
||||
return editingLine.value?.snapshot_line_id === Number(line.snapshot_line_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑态库存源下拉选项:多文件冲突行优先取候选源,其余行取全部已启用源;
|
||||
* 无可用项返回空——此时编辑态库存源保持文本展示(无可选即不可改)。
|
||||
*/
|
||||
function inlineSourceOptions(line: {
|
||||
source_ambiguous?: boolean;
|
||||
source_candidates?: Array<string>;
|
||||
}): Array<{ value: string; label: string }> {
|
||||
if (line.source_ambiguous && (line.source_candidates?.length || 0) > 0) {
|
||||
return (line.source_candidates || []).map((code) => ({ value: String(code), label: lineSourceOptionLabel(String(code)) }));
|
||||
}
|
||||
if (formSourceOptions.value.length) {
|
||||
return formSourceOptions.value.map((s) => ({ value: String(s.source_code), label: overrideSourceOptionLabel(String(s.source_code)) }));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
/** 同步编辑态库存源草稿(与三个值列一致:改动仅在保存时提交)。 */
|
||||
function updateInlineEditSource(value: string) {
|
||||
if (editingLine.value) editingLine.value.source_code = value;
|
||||
}
|
||||
|
||||
/** 行级动作收纳菜单(⋯)打开状态:键 = snapshot_line_id,单行互斥;坐标视口固定定位,
|
||||
* Teleport 到 body——表格祖先容器 overflow-auto 会裁剪 absolute 浮层并转为滚动高度。 */
|
||||
const overflowMenuOpenFor = ref<string | null>(null);
|
||||
const overflowMenuPos = ref<{ top: number; left: number }>({ top: 0, left: 0 });
|
||||
|
||||
function toggleOverflowMenu(key: string, event?: MouseEvent) {
|
||||
if (overflowMenuOpenFor.value === key) {
|
||||
overflowMenuOpenFor.value = null;
|
||||
return;
|
||||
}
|
||||
const rect = (event?.currentTarget as HTMLElement | undefined)?.getBoundingClientRect();
|
||||
const menuWidth = 176;
|
||||
overflowMenuPos.value = {
|
||||
top: rect ? Math.min(rect.bottom + 4, window.innerHeight - 8) : 0,
|
||||
left: rect ? Math.max(8, Math.min(rect.right - menuWidth, window.innerWidth - menuWidth - 8)) : 0,
|
||||
};
|
||||
overflowMenuOpenFor.value = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* 行级收纳菜单项:低频/诊断类动作入口(守卫条件与原常显按钮完全一致),
|
||||
* 高频的「编辑」保持常显;无可用项时 ⋯ 整体不渲染。
|
||||
*/
|
||||
function overflowItems(line: {
|
||||
snapshot_line_id?: number | null;
|
||||
shortage_qty?: string | number | null;
|
||||
}): Array<{ key: string; icon: Component; labelKey: string; run: () => void | Promise<void> }> {
|
||||
const items: Array<{ key: string; icon: Component; labelKey: string; run: () => void | Promise<void> }> = [];
|
||||
if (formalPreparationLineAllows(line, 'retry_inventory_matching')) {
|
||||
items.push({
|
||||
key: 'retry_inventory_matching',
|
||||
icon: RefreshCw,
|
||||
labelKey: inventoryActionLabelKey('retry_inventory_matching')!,
|
||||
run: () => retryFormalPreparationLine(Number(line.snapshot_line_id), 'retry_inventory_matching'),
|
||||
});
|
||||
}
|
||||
// 放行缺口:缺字段型短缺行 → 行内展开补录条(替代弹窗);仅缺原因的行 → 旧弹窗(原因已可选)。
|
||||
if (formalPreparationLineAllows(line, 'release_inventory_shortage')) {
|
||||
items.push({
|
||||
key: 'release_inventory_shortage',
|
||||
icon: Check,
|
||||
labelKey: inventoryActionLabelKey('release_inventory_shortage')!,
|
||||
run: () => {
|
||||
if (releaseBarHasFields(line)) expandReleaseBar(line);
|
||||
else openReleaseInventoryShortage(line);
|
||||
},
|
||||
});
|
||||
}
|
||||
if (formalPreparationLineCloseVisible(line)) {
|
||||
items.push({
|
||||
key: 'close_unfulfillable',
|
||||
icon: X,
|
||||
labelKey: 'chat.shippingOrderReview.lineActions.closeLine',
|
||||
run: () => openCloseLineDialog(line),
|
||||
});
|
||||
}
|
||||
if (formalPreparationLineAllows(line, 'retry_inventory_preparation')) {
|
||||
items.push({
|
||||
key: 'retry_inventory_preparation',
|
||||
icon: Bot,
|
||||
labelKey: inventoryActionLabelKey('retry_inventory_preparation')!,
|
||||
run: () => retryFormalPreparationLine(Number(line.snapshot_line_id), 'retry_inventory_preparation'),
|
||||
});
|
||||
}
|
||||
if (formalPreparationLineInventoryFileNo(line)) {
|
||||
items.push({
|
||||
key: 'download_inventory_file',
|
||||
icon: Download,
|
||||
labelKey: inventoryActionLabelKey('download_inventory_file') || 'chat.shippingOrderReview.lifecycle.prepare.downloadInventory',
|
||||
run: () => downloadFormalPreparationLineInventoryFile(line),
|
||||
});
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
/** 同步需求数量输入:数字输入框经 @input 手动回写,避免 v-model 的隐式 number 转型。 */
|
||||
function updateInlineEditQty(value: string) {
|
||||
if (editingLine.value) editingLine.value.required_qty = value;
|
||||
}
|
||||
|
||||
/** 退出就地编辑并丢弃未保存修改。 */
|
||||
function cancelInlineEdit() {
|
||||
editingLine.value = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存就地编辑:仅提交有变化且非空的字段(part_number / reservation_id / qty),
|
||||
* 成功后提示「请点击重新匹配库存」并刷新任务详情(值列即刻显示新值,重匹配仍需手动触发)。
|
||||
* @param line - 当前编辑行,用于与编辑起始值比对计算差量补丁
|
||||
*/
|
||||
async function saveInlineEdit(line: {
|
||||
snapshot_line_id?: number | null;
|
||||
part_number?: string | null;
|
||||
reservation_id?: string | null;
|
||||
required_qty?: string | number | null;
|
||||
selected_source_code?: string | null;
|
||||
source_code?: string | null;
|
||||
}) {
|
||||
const draft = editingLine.value;
|
||||
if (!draft || !draft.snapshot_line_id || inlineEditSaving.value) return;
|
||||
// 编辑态行与触发行的快照身份不一致(如刷新后错位)时直接丢弃,禁止错行提交。
|
||||
if (draft.snapshot_line_id !== Number(line.snapshot_line_id)) {
|
||||
cancelInlineEdit();
|
||||
return;
|
||||
}
|
||||
const taskNo = String(formalTaskDetail.value?.task_no || '').trim();
|
||||
const lineIndex = Number(draft.line_no) - 1;
|
||||
if (!taskNo || !Number.isInteger(lineIndex) || lineIndex < 0) {
|
||||
cancelInlineEdit();
|
||||
return;
|
||||
}
|
||||
const patch: Record<string, string> = {};
|
||||
const nextPartNumber = draft.part_number.trim();
|
||||
if (nextPartNumber !== inlineEditSeedValue(line.part_number)) patch.part_number = nextPartNumber;
|
||||
const nextReservationId = draft.reservation_id.trim();
|
||||
if (nextReservationId !== inlineEditSeedValue(line.reservation_id)) patch.reservation_id = nextReservationId;
|
||||
const nextQty = draft.required_qty.trim();
|
||||
if (nextQty !== inlineEditSeedValue(line.required_qty) && nextQty) patch.qty = nextQty;
|
||||
// 库存源草稿与进入编辑时的种子值比对:变化即随保存提交行级源覆写。
|
||||
const seedSourceCode = inlineEditSeedValue(line.selected_source_code || line.source_code);
|
||||
const nextSourceCode = draft.source_code.trim();
|
||||
const sourceChanged = Boolean(nextSourceCode) && nextSourceCode !== seedSourceCode;
|
||||
if (!Object.keys(patch).length && !sourceChanged) {
|
||||
cancelInlineEdit();
|
||||
return;
|
||||
}
|
||||
inlineEditSaving.value = true;
|
||||
try {
|
||||
// 字段值先落库(update-notice-line);随后的源覆写会触发单行重匹配,读到的是修正后的字段值。
|
||||
if (Object.keys(patch).length) {
|
||||
await updateWorkspaceShippingNoticeLine(
|
||||
taskNo,
|
||||
lineIndex,
|
||||
patch,
|
||||
undefined,
|
||||
// 免证据人工修订(后端 Task 2 已放宽 evidence/reason);乐观锁版本缺失时
|
||||
// 退回后端初值 1,冲突由后端 ORDER_DATA_VERSION_MISMATCH 的 409 语义兜底。
|
||||
{ expectedOrderDataVersion: Number(formalTaskDetail.value?.order_data_version ?? 1) },
|
||||
);
|
||||
}
|
||||
// 库存源覆写沿用既有 Gate 动作(override_line_inventory_source),后端校验后仅重匹配该行。
|
||||
if (sourceChanged) {
|
||||
await submitFormalGateAction('override_line_inventory_source', {
|
||||
line_no: draft.line_no,
|
||||
source_code: nextSourceCode,
|
||||
});
|
||||
}
|
||||
cancelInlineEdit();
|
||||
msg.success(t('chat.shippingOrderReview.inlineEdit.saved'));
|
||||
await loadFormalTaskDetail();
|
||||
} catch (error) {
|
||||
// BusinessError.message 即后端业务文案(版本冲突 / 系统处理中),复用既有提示通道。
|
||||
msg.warning(error instanceof Error ? error.message : t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
} finally {
|
||||
inlineEditSaving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 人工上传登记是后端 Gate 的受控写动作;仅进入「货代上传」工作面不构成授权。
|
||||
* [§2 单源] 授权从 A(shippingProcessingProjection.ui_state)读 —— §2.5 差异① 已归一,A 的
|
||||
@@ -4104,13 +4467,10 @@ const closeAuxiliaryPanelsForCaseSwitch = () => {
|
||||
llmSuggestionOpen: false,
|
||||
versionHistoryOpen: false,
|
||||
};
|
||||
// [NO-OPTIMISTIC MEMORY] 行级选源/覆写是「点保存才生效」的实提交,未保存的暂存选择
|
||||
// 不得跨文件/切换残留(否则会把上一文件的未保存意图带进新行)。切换即清空暂存,
|
||||
// 行回到后端 selected_source_code / source_code,用户须重新选择并点保存。
|
||||
lineSourceSelections.value = {};
|
||||
lineSourceBusy.value = false;
|
||||
overrideSourceSelections.value = {};
|
||||
overrideSourceBusy.value = false;
|
||||
// [NO-OPTIMISTIC MEMORY] 行级就地编辑是「点保存才生效」的实提交,未保存的编辑草稿
|
||||
// 不得跨文件/切换残留(否则会把上一文件的未保存意图带进新行)。切换即丢弃草稿,
|
||||
// 行回到后端 selected_source_code / source_code,用户须重新进入编辑并保存。
|
||||
cancelInlineEdit();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -4949,7 +5309,7 @@ watch(
|
||||
<div class="overflow-x-auto overscroll-x-contain" data-testid="review-fulfillment-prep-table-scroll">
|
||||
<table class="review-fulfillment-prep-table min-w-[1060px] text-xs">
|
||||
<thead class="border-b border-default bg-surface-muted/50 text-left"><tr><th v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="allPreparationWaveSelected" :disabled="!preparationWaveSelectableLines.length || preparationWaveBusy" :aria-label="t('chat.shippingOrderReview.fulfillmentDecision.selectReady')" @change="toggleAllPreparationLineSelection(($event.target as HTMLInputElement).checked)"></th><th v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationCustomerPoLineLabel() }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultReservation') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultPartNumber') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.requiredQty') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.inventorySource') }}</th><th v-if="formalPreparationOdmColumnVisible" class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.odmConflict.column') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.availableQty') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.shortage') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.lineStatus') }}</th><th class="review-fulfillment-sticky-action-head whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lineOps.moreActions') }}</th></tr></thead>
|
||||
<tbody><tr v-for="(line, lineIndex) in formalPreparationDisplayLines" :key="line.snapshot_line_id || `${line.reservation_id}-${line.part_number}`" :class="Number(line.shortage_qty || 0) > 0 ? 'border-b border-amber-100 bg-amber-50/40 last:border-0 dark:border-amber-950 dark:bg-amber-950/10' : 'border-b border-default last:border-0'"><td v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="selectedPreparationSnapshotLineIds.includes(String(line.snapshot_line_id))" :disabled="preparationWaveBusy || !preparationWaveSelectableLines.some((item) => String(item.snapshot_line_id) === String(line.snapshot_line_id))" :aria-label="`${t('chat.shippingOrderReview.fulfillmentDecision.selectReady')}: ${preparationLineCustomerPoLine(line)}`" :data-testid="`review-fulfillment-line-select-${line.snapshot_line_id || lineIndex}`" @change="togglePreparationLineSelection(String(line.snapshot_line_id || lineIndex), ($event.target as HTMLInputElement).checked)"></td><td v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationLineCustomerPoLine(line) }}</td><td class="whitespace-nowrap px-3 py-2 font-medium text-primary">{{ line.reservation_id || '—' }}</td><td class="max-w-[220px] truncate px-3 py-2" :title="line.part_number || '—'">{{ line.part_number || '—' }}</td><td class="whitespace-nowrap px-3 py-2">{{ line.required_qty ?? '—' }}</td><td class="max-w-[220px] px-3 py-2"><div v-if="line.source_ambiguous && !formalPreparationSourceLocked" class="flex items-center gap-1" :data-testid="`review-line-source-ambiguous-${line.snapshot_line_id || lineIndex}`" :title="t('chat.shippingOrderReview.lifecycle.prepare.sourceAmbiguous')"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-source-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="lineSourceSelections[String(line.snapshot_line_id || lineIndex)] || line.source_code || ''" @change="lineSourceSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.lifecycle.prepare.selectSource') }}</option><option v-for="code in line.source_candidates || []" :key="code" :value="code">{{ lineSourceOptionLabel(code) }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-source-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!lineSourceSelections[String(line.snapshot_line_id || lineIndex)] || lineSourceBusy || !preparationEditable" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" @click="submitLineSourceSelection(line)"><Check class="h-3.5 w-3.5" /></button></div><span v-else-if="line.source_ambiguous && formalPreparationSourceLocked" class="text-xs text-secondary" :title="t('chat.shippingOrderReview.lifecycle.prepare.sourceLocked')">{{ t('chat.shippingOrderReview.lifecycle.prepare.sourceLocked') }}</span><span v-else-if="!formalPreparationSourceLocked && formSourceOptions.length" class="flex items-center gap-1" :data-testid="`review-line-source-override-${line.snapshot_line_id || lineIndex}`" :title="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-source-override-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] || line.selected_source_code || line.source_code || ''" @change="overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.lifecycle.prepare.selectSource') }}</option><option v-for="s in formSourceOptions" :key="String(s.source_code)" :value="String(s.source_code)">{{ overrideSourceOptionLabel(String(s.source_code)) }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-source-override-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] || overrideSourceBusy" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :data-line-index="lineIndex" @click="submitOverrideSource(line)"><Check class="h-3.5 w-3.5" /></button></span><span v-else class="block max-w-[220px] truncate" :title="formalPreparationLineSource(line)">{{ formalPreparationLineSource(line) }}</span></td><td v-if="formalPreparationOdmColumnVisible" class="whitespace-nowrap px-3 py-2"><div v-if="(line.odm_values?.length || 0) > 1 && !formalLine truncated
|
||||
<tbody><template v-for="(line, lineIndex) in formalPreparationDisplayLines" :key="line.snapshot_line_id || `${line.reservation_id}-${line.part_number}`"><tr :class="Number(line.shortage_qty || 0) > 0 ? 'border-b border-amber-100 bg-amber-50/40 last:border-0 dark:border-amber-950 dark:bg-amber-950/10' : 'border-b border-default last:border-0'"><td v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="selectedPreparationSnapshotLineIds.includes(String(line.snapshot_line_id))" :disabled="preparationWaveBusy || !preparationWaveSelectableLines.some((item) => String(item.snapshot_line_id) === String(line.snapshot_line_id))" :aria-label="`${t('chat.shippingOrderReview.fulfillmentDecision.selectReady')}: ${preparationLineCustomerPoLine(line)}`" :data-testid="`review-fulfillment-line-select-${line.snapshot_line_id || lineIndex}`" @change="togglePreparationLineSelection(String(line.snapshot_line_id || lineIndex), ($event.target as HTMLInputElement).checked)"></td><td v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationLineCustomerPoLine(line) }}</td><td class="whitespace-nowrap px-3 py-2 font-medium text-primary"><template v-if="editingLine && isInlineEditing(line)"><input v-model="editingLine.reservation_id" type="text" class="w-28 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.workbench.resultReservation')" :data-testid="`review-fulfillment-line-edit-reservation-${line.snapshot_line_id}`" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else>{{ line.reservation_id || '—' }}</span></td><td class="max-w-[220px] px-3 py-2"><template v-if="editingLine && isInlineEditing(line)"><input v-model="editingLine.part_number" type="text" class="w-full min-w-0 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.workbench.resultPartNumber')" :data-testid="`review-fulfillment-line-edit-part-${line.snapshot_line_id}`" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else class="block max-w-[220px] truncate" :title="line.part_number || '—'">{{ line.part_number || '—' }}</span></td><td class="whitespace-nowrap px-3 py-2"><template v-if="editingLine && isInlineEditing(line)"><input :value="editingLine.required_qty" type="number" min="0" step="any" class="w-20 rounded border border-default bg-surface px-1.5 py-1 text-xs" :disabled="inlineEditSaving" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.requiredQty')" :data-testid="`review-fulfillment-line-edit-qty-${line.snapshot_line_id}`" @input="updateInlineEditQty(($event.target as HTMLInputElement).value)" @keyup.enter="saveInlineEdit(line)" @keyup.esc="cancelInlineEdit" /></template><span v-else>{{ line.required_qty ?? '—' }}</span></td><td class="max-w-[220px] px-3 py-2"><template v-if="isInlineEditing(line) && inlineSourceOptions(line).length"><select class="w-full min-w-0 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-fulfillment-line-edit-source-${line.snapshot_line_id}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="editingLine?.source_code" :disabled="inlineEditSaving" @change="updateInlineEditSource(($event.target as HTMLSelectElement).value)"><option v-for="option in inlineSourceOptions(line)" :key="option.value" :value="option.value">{{ option.label }}</option></select></template><span v-else class="block max-w-[220px] truncate" :title="formalPreparationLineSource(line)">{{ formalPreparationLineSource(line) || '—' }}</span></td><td v-if="formalPreparationOdmColumnVisible" class="whitespace-nowrap px-3 py-2"><div v-if="(line.odm_values?.length || 0) > 1 && !formalPreparationSourceLocked" class="flex items-center gap-1" :data-testid="`review-line-odm-${line.snapshot_line_id || lineIndex}`"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-odm-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.odmConflict.title')" :value="lineOdmSelections[String(line.snapshot_line_id || lineIndex)] || line.chosen_odm_id || ''" @change="lineOdmSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.odmConflict.placeholder') }}</option><option v-for="value in line.odm_values" :key="value" :value="value">{{ value }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-odm-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!lineOdmSelections[String(line.snapshot_line_id || lineIndex)] || lineOdmBusy" :aria-label="t('chat.shippingOrderReLine truncated
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -5728,7 +6088,31 @@ watch(
|
||||
</label>
|
||||
<div class="mt-4 flex justify-end gap-2">
|
||||
<button type="button" class="rounded border border-default px-3 py-1.5 text-sm" :disabled="releaseInventoryBusy" @click="releaseInventoryLine = null">{{ t('chat.shippingOrderReview.workbench.close') }}</button>
|
||||
<button type="button" class="rounded bg-amber-600 px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50" :disabled="releaseInventoryBusy || !releaseInventoryReason.trim() || (releaseInventoryLine.release_required_fields || []).some((field) => !releaseInventoryFieldValues[field.field_id]?.trim())" @click="confirmReleaseInventoryShortage">{{ t('chat.shippingOrderReview.lifecycle.prepare.releaseConfirm') }}</button>
|
||||
<button type="button" class="rounded bg-amber-600 px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50" :disabled="releaseInventoryBusy || (releaseInventoryLine.release_required_fields || []).some((field) => !releaseInventoryFieldValues[field.field_id]?.trim())" @click="confirmReleaseInventoryShortage">{{ t('chat.shippingOrderReview.lifecycle.prepare.releaseConfirm') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="closeLineDialogLine"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40 p-4"
|
||||
data-testid="review-close-line-dialog"
|
||||
@click.self="closeLineDialogLine = null"
|
||||
>
|
||||
<div class="w-full max-w-md rounded-xl border border-default bg-surface p-4 shadow-xl">
|
||||
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.lineActions.closeLine') }}</h2>
|
||||
<p class="mt-1 text-xs text-muted">{{ t('chat.shippingOrderReview.closeFulfillment.subtitle') }}</p>
|
||||
<textarea
|
||||
v-model="closeLineReason"
|
||||
rows="3"
|
||||
class="mt-3 w-full rounded-md border border-default bg-surface px-2.5 py-2 text-sm"
|
||||
data-testid="review-close-line-reason"
|
||||
:placeholder="t('chat.shippingOrderReview.lineActions.closeLineReason')"
|
||||
:disabled="closeLineBusy"
|
||||
/>
|
||||
<div class="mt-4 flex justify-end gap-2">
|
||||
<button type="button" class="rounded border border-default px-3 py-1.5 text-sm" :disabled="closeLineBusy" @click="closeLineDialogLine = null">{{ t('chat.shippingOrderReview.workbench.close') }}</button>
|
||||
<button type="button" class="rounded bg-rose-600 px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50" data-testid="review-close-line-submit" :disabled="closeLineBusy || !closeLineReason.trim()" @click="confirmCloseLine">{{ t('chat.shippingOrderReview.lineActions.closeLineConfirm') }}</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -629,14 +629,11 @@
|
||||
"orderSchemaRequired": "Publish an Order Fields version first; inventory parsing profiles, shipping Excel templates, and routing rules can then reference order fields.",
|
||||
"connections": "System Connections",
|
||||
"receiptReportConfig": "Receipt Report Configuration",
|
||||
"receiptReportConfigHint": "Separate from inventory report paths and inventory query parameters. DBS exports each Warehouse below separately; report date is never filtered.",
|
||||
"receiptReportEnabled": "Enable receipt export",
|
||||
"receiptWarehouses": "Receipt Warehouse list",
|
||||
"receiptWarehousesHint": "Separate multiple Warehouses with commas",
|
||||
"receiptOptionalParameters": "Optional query parameters (excluding report date)",
|
||||
"receiptReportConfigHint": "Same structure as inventory configuration: report path + query parameters. Each warehouse in the Warehouse condition exports one receipt file per schedule; report date is never filtered. Receipt has no separate switch and follows the site's unified enablement.",
|
||||
"receiptQueryParametersHint": "Same as inventory query parameters. Warehouse supports multiple values (comma-separated); each Warehouse exports one receipt file. Report date filtering is never allowed.",
|
||||
"receiptCraneFixedPath": "Crane receipt export is fixed to Inbound Details and is not split by Warehouse. No query conditions are maintained; execution directly runs the page defaults.",
|
||||
"saveReceiptReportConfig": "Save receipt configuration",
|
||||
"receiptReportSaved": "Receipt report configuration saved",
|
||||
"pathSectionConfigured": "Configured",
|
||||
"pathSectionNotConfigured": "Not configured",
|
||||
"parsingProfiles": "Inventory Parsing",
|
||||
"parsingProfilesHelp": "Maintain inventory file structures, field mappings, and order-field match keys shared by inventory sites.",
|
||||
"inventoryMapping": "Inventory Parsing",
|
||||
@@ -896,12 +893,11 @@
|
||||
"parsingBindingOperationBulk": "Bulk binding",
|
||||
"parsingBindingVersion": "Configuration version {before} to {after}",
|
||||
"sourceSavedDisabledHint": "The site remains disabled after its first save. Complete the test export, inventory parsing, and shipping template before activation.",
|
||||
"activationStatus": "Production Readiness",
|
||||
"readinessProgress": "{passed} of {total} complete",
|
||||
"activationRequiredTitle": "Next step",
|
||||
"activationRequiredHint": "Complete the current item and the system will continue deciding whether the site can be enabled automatically.",
|
||||
"readinessBlockedBy": "One step left before enablement: {requirement}",
|
||||
"readinessAutoEnableHint": "After completion the system will evaluate and enable the site automatically.",
|
||||
"readinessLastVerified": "Last verified {time}",
|
||||
"readinessOptionalPending": "{count} item(s) pending for later",
|
||||
"activationOptionalTitle": "Prepare later (does not block enablement)",
|
||||
"activationOptionalHint": "Complete when inventory exists or before an actual transfer.",
|
||||
"readinessState": {
|
||||
"passed": "Complete",
|
||||
"required": "Action required",
|
||||
@@ -918,12 +914,8 @@
|
||||
"configure_warehouse_mapping": "Configure warehouse mapping"
|
||||
},
|
||||
"saveBeforeReadinessAction": "Save the current inventory-site changes before taking this action.",
|
||||
"activationReady": "The inventory site is enabled and can run in production.",
|
||||
"activationDraft": "The inventory site is disabled. Complete the following items before activation.",
|
||||
"activationReady": "Site enabled. Inventory and receipt runs follow the site switch.",
|
||||
"activationCanEnable": "All enablement conditions pass. You can enable this inventory site.",
|
||||
"activationEnabledHint": "This site participates in production inventory runs.",
|
||||
"activationCanEnableHint": "Click Enable Inventory Site to start production runs, or run another successful test export to auto-enable.",
|
||||
"activationMissingHint": "Complete only the unfinished required items. Later preparation does not block enablement.",
|
||||
"activationRequirement": {
|
||||
"rpa_profile": "System connection is available",
|
||||
"parsing_profile": "Inventory file parsing profile",
|
||||
|
||||
@@ -2219,6 +2219,12 @@
|
||||
"hint": "Other lines on the same snapshot file use this ODM ID too; Excel generation retries automatically",
|
||||
"column": "ODM ID"
|
||||
},
|
||||
"inlineEdit": {
|
||||
"saved": "Saved. Click \"Re-match inventory\" to apply",
|
||||
"busy": "System is busy. Please try again later",
|
||||
"save": "Save",
|
||||
"cancel": "Cancel"
|
||||
},
|
||||
"fulfillmentDecision": {
|
||||
"title": "Line fulfillment decisions",
|
||||
"subtitle": "Select inventory-ready or manually released lines to create an independent shipping notice and Excel.",
|
||||
@@ -2354,6 +2360,13 @@
|
||||
"success": "Lines closed",
|
||||
"failed": "Close failed. Try again."
|
||||
},
|
||||
"lineActions": {
|
||||
"closeLine": "Close line (no shipment)",
|
||||
"closeLineReason": "Enter a reason to close",
|
||||
"closeLineConfirm": "Confirm close",
|
||||
"editLine": "Edit",
|
||||
"more": "More actions"
|
||||
},
|
||||
"auditTrail": {
|
||||
"open": "Audit trail",
|
||||
"title": "Operation audit",
|
||||
@@ -2742,6 +2755,10 @@
|
||||
"inventory_rpa_export_failed": "Inventory export failed",
|
||||
"inventory_file_empty": "Inventory file empty"
|
||||
}
|
||||
},
|
||||
"releaseBar": {
|
||||
"label": "Release info",
|
||||
"badge": "{n} missing release field(s)"
|
||||
}
|
||||
},
|
||||
"shippingOrderExtractionElapsed": "Elapsed {elapsed}",
|
||||
|
||||
@@ -629,14 +629,11 @@
|
||||
"orderSchemaRequired": "โปรดเผยแพร่เวอร์ชันฟิลด์คำสั่งซื้อก่อน เพื่อให้โปรไฟล์การแยกวิเคราะห์สต็อก เทมเพลต Excel สำหรับจัดส่ง และกฎการกำหนดเส้นทางอ้างอิงฟิลด์คำสั่งซื้อได้",
|
||||
"connections": "การเชื่อมต่อระบบ",
|
||||
"receiptReportConfig": "การตั้งค่ารายงานรับสินค้า",
|
||||
"receiptReportConfigHint": "แยกจากเส้นทางรายงานสต็อกและเงื่อนไขค้นหาสต็อก DBS ส่งออกแยกตาม Warehouse ด้านล่าง และไม่กรองวันที่รายงาน",
|
||||
"receiptReportEnabled": "เปิดใช้การส่งออกรับสินค้า",
|
||||
"receiptWarehouses": "รายการ Warehouse รับสินค้า",
|
||||
"receiptWarehousesHint": "คั่นหลาย Warehouse ด้วยเครื่องหมายจุลภาค",
|
||||
"receiptOptionalParameters": "เงื่อนไขค้นหาเพิ่มเติม (ไม่รวมวันที่รายงาน)",
|
||||
"receiptReportConfigHint": "โครงสร้างเหมือนการตั้งค่าสต็อก: เส้นทางรายงาน + เงื่อนไขค้นหา แต่ละ Warehouse ในเงื่อนไขจะส่งออกไฟล์รับสินค้าหนึ่งไฟล์ต่อรอบ และไม่กรองวันที่รายงาน การรับสินค้าไม่มีสวิตช์แยก และจะเปิดหรือปิดตามไซต์โดยรวม",
|
||||
"receiptQueryParametersHint": "เหมือนเงื่อนไขค้นหาสต็อก Warehouse รองรับหลายค่า (คั่นด้วยเครื่องหมายจุลภาค) แต่ละ Warehouse จะส่งออกไฟล์รับสินค้าหนึ่งไฟล์ และห้ามกรองวันที่รายงาน",
|
||||
"receiptCraneFixedPath": "การส่งออกรับสินค้าของ Crane ถูกกำหนดเป็น Inbound Details และไม่แยกตาม Warehouse ไม่มีการบำรุงรักษาเงื่อนไขค้นหา และระบบจะ Run Report ด้วยค่าเริ่มต้นของหน้าเว็บโดยตรง",
|
||||
"saveReceiptReportConfig": "บันทึกการตั้งค่ารับสินค้า",
|
||||
"receiptReportSaved": "บันทึกการตั้งค่ารายงานรับสินค้าแล้ว",
|
||||
"pathSectionConfigured": "ตั้งค่าแล้ว",
|
||||
"pathSectionNotConfigured": "ยังไม่ได้ตั้งค่า",
|
||||
"parsingProfiles": "แผนการแยกวิเคราะห์ไฟล์สต็อก",
|
||||
"parsingProfilesHelp": "จัดการโครงสร้างไฟล์สต็อก การจับคู่ฟิลด์ และคีย์จับคู่ฟิลด์คำสั่งซื้อที่ใช้ร่วมกันได้ระหว่างไซต์สต็อก",
|
||||
"inventoryMapping": "แผนการแยกวิเคราะห์ไฟล์สต็อก",
|
||||
@@ -896,12 +893,11 @@
|
||||
"parsingBindingOperationBulk": "ผูกแบบกลุ่ม",
|
||||
"parsingBindingVersion": "เวอร์ชันการตั้งค่า {before} → {after}",
|
||||
"sourceSavedDisabledHint": "ไซต์จะยังปิดใช้งานหลังบันทึกครั้งแรก โปรดทำการส่งออกทดสอบ แผนการอ่าน และเทมเพลตการจัดส่งให้เสร็จก่อนเปิดใช้งาน",
|
||||
"activationStatus": "การตรวจสอบก่อนใช้งานจริง",
|
||||
"readinessProgress": "เสร็จแล้ว {passed} / {total}",
|
||||
"activationRequiredTitle": "ขั้นตอนถัดไป",
|
||||
"activationRequiredHint": "ทำรายการปัจจุบันให้เสร็จ แล้วระบบจะพิจารณาการเปิดใช้งานอัตโนมัติต่อไป",
|
||||
"readinessBlockedBy": "เหลืออีกหนึ่งขั้นก่อนเปิดใช้งาน: {requirement}",
|
||||
"readinessAutoEnableHint": "เมื่อเสร็จแล้วระบบจะประเมินและเปิดใช้งานไซต์ให้อัตโนมัติ",
|
||||
"readinessLastVerified": "ตรวจสอบล่าสุด {time}",
|
||||
"readinessOptionalPending": "เหลือ {count} รายการที่ทำภายหลัง",
|
||||
"activationOptionalTitle": "การเตรียมภายหลัง (ไม่ขัดขวางการเปิดใช้งาน)",
|
||||
"activationOptionalHint": "ดำเนินการเมื่อมีสต็อกหรือก่อนโอนย้ายจริง",
|
||||
"readinessState": {
|
||||
"passed": "เสร็จสมบูรณ์",
|
||||
"required": "ต้องดำเนินการ",
|
||||
@@ -918,12 +914,8 @@
|
||||
"configure_warehouse_mapping": "ตั้งค่าการแมปคลังสินค้า"
|
||||
},
|
||||
"saveBeforeReadinessAction": "โปรดบันทึกการเปลี่ยนแปลงไซต์สต็อกปัจจุบันก่อนดำเนินการนี้",
|
||||
"activationReady": "เปิดใช้งานไซต์สต็อกแล้วและพร้อมใช้งานจริง",
|
||||
"activationDraft": "ไซต์สต็อกยังปิดใช้งาน โปรดทำรายการต่อไปนี้ให้เสร็จก่อนเปิดใช้งาน",
|
||||
"activationReady": "ไซต์เปิดใช้งานแล้ว งานสต็อกและรับสินค้าจะเปิดหรือปิดตามสวิตช์ไซต์",
|
||||
"activationCanEnable": "ผ่านทุกเงื่อนไขแล้ว สามารถเปิดใช้งานไซต์สต็อกนี้ได้",
|
||||
"activationEnabledHint": "ไซต์นี้เข้าร่วมการทำงานสต็อกจริงแล้ว",
|
||||
"activationCanEnableHint": "คลิกเปิดใช้งานไซต์สต็อกเพื่อเริ่มใช้งานจริง หรือทดสอบส่งออกอีกครั้ง ระบบจะเปิดใช้งานอัตโนมัติเมื่อผ่าน",
|
||||
"activationMissingHint": "ทำเฉพาะเงื่อนไขการเปิดใช้งานที่ยังไม่ผ่าน การเตรียมภายหลังไม่ขัดขวางการเปิดใช้งาน",
|
||||
"activationRequirement": {
|
||||
"rpa_profile": "การเชื่อมต่อระบบพร้อมใช้งาน",
|
||||
"parsing_profile": "แผนการแยกวิเคราะห์ไฟล์สต็อก",
|
||||
|
||||
@@ -2219,6 +2219,12 @@
|
||||
"hint": "แถวอื่นในไฟล์สแนปชอตเดียวกันจะใช้ ODM ID เดียวกัน และสร้าง Excel ใหม่โดยอัตโนมัติ",
|
||||
"column": "ODM ID"
|
||||
},
|
||||
"inlineEdit": {
|
||||
"saved": "บันทึกแล้ว กด \"จับคู่สินค้าคงเหลือใหม่\" เพื่อใช้งาน",
|
||||
"busy": "ระบบกำลังประมวลผล โปรดลองอีกครั้งภายหลัง",
|
||||
"save": "บันทึก",
|
||||
"cancel": "ยกเลิก"
|
||||
},
|
||||
"fulfillmentDecision": {
|
||||
"title": "การตัดสินใจการปฏิบัติตามบรรทัด",
|
||||
"subtitle": "เลือกหลายบรรทัดที่สต็อกพร้อมหรืออนุมัติด้วยมือ เพื่อสร้างใบแจ้งการจัดส่งและ Excel แยกอิสระ",
|
||||
@@ -2354,6 +2360,13 @@
|
||||
"success": "ปิดบรรทัดแล้ว",
|
||||
"failed": "ปิดล้มเหลว โปรดลองใหม่"
|
||||
},
|
||||
"lineActions": {
|
||||
"closeLine": "ปิดบรรทัด (ไม่จัดส่ง)",
|
||||
"closeLineReason": "กรอกเหตุผลเพื่อปิด",
|
||||
"closeLineConfirm": "ยืนยันการปิด",
|
||||
"editLine": "แก้ไข",
|
||||
"more": "การดำเนินการเพิ่มเติม"
|
||||
},
|
||||
"auditTrail": {
|
||||
"open": "บันทึก audit",
|
||||
"title": "Audit การดำเนินการ",
|
||||
@@ -2742,6 +2755,10 @@
|
||||
"inventory_rpa_export_failed": "ส่งออกสต็อกล้มเหลว",
|
||||
"inventory_file_empty": "ไฟล์สต็อกว่าง"
|
||||
}
|
||||
},
|
||||
"releaseBar": {
|
||||
"label": "ข้อมูลเพิ่มเติมเพื่อปล่อยของ",
|
||||
"badge": "ขาด {n} รายการก่อนปล่อย"
|
||||
}
|
||||
},
|
||||
"shippingOrderExtractionElapsed": "ใช้เวลา {elapsed}",
|
||||
|
||||
@@ -758,14 +758,11 @@
|
||||
"orderSchemaRequired": "请先在「订单 Schema」发布一个版本;库存解析、发货模板和路由规则才能引用订单字段。",
|
||||
"connections": "系统连接",
|
||||
"receiptReportConfig": "收料报表配置",
|
||||
"receiptReportConfigHint": "独立于库存报表路径与库存查询条件。DBS 会按下方每个 Warehouse 分别导出;报表日期固定不筛选。",
|
||||
"receiptReportEnabled": "启用收料导出",
|
||||
"receiptWarehouses": "收料 Warehouse 列表",
|
||||
"receiptWarehousesHint": "多个 Warehouse 用英文逗号分隔",
|
||||
"receiptOptionalParameters": "可选查询条件(不含报表日期)",
|
||||
"receiptReportConfigHint": "与库存配置同构:报表路径 + 查询条件。Warehouse 条件填几个仓,排程逐仓拆分导出几个收料文件;报表日期固定不筛选。收料无独立开关,随站点统一启停。",
|
||||
"receiptQueryParametersHint": "与库存查询条件一致。Warehouse 支持多值(英文逗号分隔),每个 Warehouse 拆分导出一个收料文件;报表日期固定禁填。",
|
||||
"receiptCraneFixedPath": "Crane 收料固定导出 Inbound Details,不按 Warehouse 拆分,也不维护查询条件;执行时直接使用页面默认条件点击 Run Report。",
|
||||
"saveReceiptReportConfig": "保存收料配置",
|
||||
"receiptReportSaved": "收料报表配置已保存",
|
||||
"pathSectionConfigured": "已配置",
|
||||
"pathSectionNotConfigured": "未配置",
|
||||
"parsingProfiles": "库存解析",
|
||||
"parsingProfilesHelp": "维护可由多个库存站点共享的库存文件结构、字段对应关系和订单字段匹配键。",
|
||||
"inventoryMapping": "库存解析",
|
||||
@@ -1025,12 +1022,11 @@
|
||||
"parsingBindingOperationBulk": "批量绑定",
|
||||
"parsingBindingVersion": "配置版本 {before} → {after}",
|
||||
"sourceSavedDisabledHint": "首次保存后站点保持停用;请完成测试导出、库存解析和发货模板配置后再启用。",
|
||||
"activationStatus": "正式运行检查",
|
||||
"readinessProgress": "{passed} / {total} 已完成",
|
||||
"activationRequiredTitle": "下一步",
|
||||
"activationRequiredHint": "完成当前项目后,系统会继续判断是否可以自动启用。",
|
||||
"readinessBlockedBy": "启用前还差一步:{requirement}",
|
||||
"readinessAutoEnableHint": "完成后系统会自动判断并启用站点。",
|
||||
"readinessLastVerified": "上次验证 {time}",
|
||||
"readinessOptionalPending": "{count} 项待后续完成",
|
||||
"activationOptionalTitle": "后续准备(不影响启用)",
|
||||
"activationOptionalHint": "有库存数据或实际调拨前再完成。",
|
||||
"readinessState": {
|
||||
"passed": "已完成",
|
||||
"required": "需要完成",
|
||||
@@ -1047,12 +1043,8 @@
|
||||
"configure_warehouse_mapping": "配置仓库映射"
|
||||
},
|
||||
"saveBeforeReadinessAction": "请先保存当前库存站点更改,再执行此操作。",
|
||||
"activationReady": "库存站点已启用,可进入正式库存运行。",
|
||||
"activationDraft": "库存站点当前停用;完成以下项目后才可启用。",
|
||||
"activationReady": "站点已启用,库存与收料随站点统一运行。",
|
||||
"activationCanEnable": "启用条件已满足,可启用该库存站点。",
|
||||
"activationEnabledHint": "站点已参与正式库存运行。",
|
||||
"activationCanEnableHint": "点击“启用库存站点”即可投入正式运行;也可再次测试导出,通过后仍会自动启用。",
|
||||
"activationMissingHint": "仅需完成“启用条件”中的未通过项目;后续准备不影响启用。",
|
||||
"activationRequirement": {
|
||||
"rpa_profile": "系统连接可用",
|
||||
"parsing_profile": "库存解析",
|
||||
|
||||
@@ -2326,6 +2326,12 @@
|
||||
"hint": "同一快照文件的其他行会同步使用该 ODM ID,确认后自动重试生成 Excel",
|
||||
"column": "ODM ID"
|
||||
},
|
||||
"inlineEdit": {
|
||||
"saved": "已保存,请点击「重新匹配库存」生效",
|
||||
"busy": "系统处理中,请稍后再修改",
|
||||
"save": "保存",
|
||||
"cancel": "取消"
|
||||
},
|
||||
"fulfillmentDecision": {
|
||||
"title": "行级履约决定",
|
||||
"subtitle": "可多选库存满足或已人工放行的明细,生成独立发货通知和 Excel。",
|
||||
@@ -2473,6 +2479,13 @@
|
||||
"success": "行已关闭",
|
||||
"failed": "关闭失败,请重试"
|
||||
},
|
||||
"lineActions": {
|
||||
"closeLine": "结案(不再发货)",
|
||||
"closeLineReason": "请填写结案原因",
|
||||
"closeLineConfirm": "确认结案",
|
||||
"editLine": "编辑",
|
||||
"more": "更多操作"
|
||||
},
|
||||
"auditTrail": {
|
||||
"open": "审计记录",
|
||||
"title": "操作审计",
|
||||
@@ -2850,6 +2863,10 @@
|
||||
"missing_order_table": "缺少订单表格",
|
||||
"other": "其他(须填写说明)"
|
||||
}
|
||||
},
|
||||
"releaseBar": {
|
||||
"label": "放行补录",
|
||||
"badge": "缺 {n} 项放行信息"
|
||||
}
|
||||
},
|
||||
"shippingProcessing": {
|
||||
|
||||
@@ -629,14 +629,11 @@
|
||||
"orderSchemaRequired": "請先在「訂單欄位規則」發佈一個版本;庫存解析、出貨範本和路由規則才能引用訂單欄位。",
|
||||
"connections": "系統連線",
|
||||
"receiptReportConfig": "收料報表設定",
|
||||
"receiptReportConfigHint": "獨立於庫存報表路徑與庫存查詢條件。DBS 會依下方每個 Warehouse 分別匯出;報表日期固定不篩選。",
|
||||
"receiptReportEnabled": "啟用收料匯出",
|
||||
"receiptWarehouses": "收料 Warehouse 清單",
|
||||
"receiptWarehousesHint": "多個 Warehouse 以英文逗號分隔",
|
||||
"receiptOptionalParameters": "可選查詢條件(不含報表日期)",
|
||||
"receiptReportConfigHint": "與庫存設定同構:報表路徑 + 查詢條件。Warehouse 條件填幾個倉,排程逐倉拆分匯出幾個收料檔案;報表日期固定不篩選。收料無獨立開關,隨站點統一啟停。",
|
||||
"receiptQueryParametersHint": "與庫存查詢條件一致。Warehouse 支援多值(英文逗號分隔),每個 Warehouse 拆分匯出一個收料檔案;報表日期固定禁填。",
|
||||
"receiptCraneFixedPath": "Crane 收料固定匯出 Inbound Details,不依 Warehouse 拆分,也不維護查詢條件;執行時直接使用頁面預設條件點擊 Run Report。",
|
||||
"saveReceiptReportConfig": "儲存收料設定",
|
||||
"receiptReportSaved": "收料報表設定已儲存",
|
||||
"pathSectionConfigured": "已設定",
|
||||
"pathSectionNotConfigured": "未設定",
|
||||
"parsingProfiles": "庫存解析",
|
||||
"parsingProfilesHelp": "維護可由多個庫存站點共用的庫存檔案結構、欄位對應與訂單欄位匹配鍵。",
|
||||
"inventoryMapping": "庫存解析",
|
||||
@@ -896,12 +893,11 @@
|
||||
"parsingBindingOperationBulk": "批量綁定",
|
||||
"parsingBindingVersion": "設定版本 {before} → {after}",
|
||||
"sourceSavedDisabledHint": "首次儲存後站點保持停用;請完成測試匯出、庫存解析與出貨範本設定後再啟用。",
|
||||
"activationStatus": "正式執行檢查",
|
||||
"readinessProgress": "已完成 {passed} / {total}",
|
||||
"activationRequiredTitle": "下一步",
|
||||
"activationRequiredHint": "完成目前項目後,系統會繼續判斷是否可自動啟用。",
|
||||
"readinessBlockedBy": "啟用前還差一步:{requirement}",
|
||||
"readinessAutoEnableHint": "完成後系統會自動判斷並啟用站點。",
|
||||
"readinessLastVerified": "上次驗證 {time}",
|
||||
"readinessOptionalPending": "{count} 項待後續完成",
|
||||
"activationOptionalTitle": "後續準備(不影響啟用)",
|
||||
"activationOptionalHint": "有庫存資料或實際調撥前再完成。",
|
||||
"readinessState": {
|
||||
"passed": "已完成",
|
||||
"required": "需要完成",
|
||||
@@ -918,12 +914,8 @@
|
||||
"configure_warehouse_mapping": "設定倉庫對應"
|
||||
},
|
||||
"saveBeforeReadinessAction": "請先儲存目前庫存站點的變更,再執行此操作。",
|
||||
"activationReady": "庫存站點已啟用,可進入正式庫存執行。",
|
||||
"activationDraft": "庫存站點目前停用;完成以下項目後才可啟用。",
|
||||
"activationReady": "站點已啟用,庫存與收料隨站點統一執行。",
|
||||
"activationCanEnable": "已符合啟用條件,可啟用此庫存站點。",
|
||||
"activationEnabledHint": "站點已參與正式庫存執行。",
|
||||
"activationCanEnableHint": "點選「啟用庫存站點」即可投入正式執行;也可再次測試匯出,通過後仍會自動啟用。",
|
||||
"activationMissingHint": "只需完成「啟用條件」中未通過的項目;後續準備不影響啟用。",
|
||||
"activationRequirement": {
|
||||
"rpa_profile": "系統連線可用",
|
||||
"parsing_profile": "庫存解析",
|
||||
|
||||
@@ -2219,6 +2219,12 @@
|
||||
"hint": "同一快照檔案的其他行會同步使用該 ODM ID,確認後自動重試產生 Excel",
|
||||
"column": "ODM ID"
|
||||
},
|
||||
"inlineEdit": {
|
||||
"saved": "已儲存,請點擊「重新匹配庫存」生效",
|
||||
"busy": "系統處理中,請稍後再修改",
|
||||
"save": "儲存",
|
||||
"cancel": "取消"
|
||||
},
|
||||
"fulfillmentDecision": {
|
||||
"title": "行級履約決定",
|
||||
"subtitle": "可多選庫存滿足或已人工放行的明細,產生獨立發貨通知和 Excel。",
|
||||
@@ -2354,6 +2360,13 @@
|
||||
"success": "行已關閉",
|
||||
"failed": "關閉失敗,請重試"
|
||||
},
|
||||
"lineActions": {
|
||||
"closeLine": "結案(不再發貨)",
|
||||
"closeLineReason": "請填寫結案原因",
|
||||
"closeLineConfirm": "確認結案",
|
||||
"editLine": "編輯",
|
||||
"more": "更多操作"
|
||||
},
|
||||
"auditTrail": {
|
||||
"open": "稽核記錄",
|
||||
"title": "操作稽核",
|
||||
@@ -2742,6 +2755,10 @@
|
||||
"inventory_rpa_export_failed": "庫存匯出失敗",
|
||||
"inventory_file_empty": "庫存檔案為空"
|
||||
}
|
||||
},
|
||||
"releaseBar": {
|
||||
"label": "放行補錄",
|
||||
"badge": "缺 {n} 項放行資訊"
|
||||
}
|
||||
},
|
||||
"shippingOrderExtractionElapsed": "已用時 {elapsed}",
|
||||
|
||||
Reference in new issue
Block a user