fix: 中文显示任务当前步骤 (#39)
This commit is contained in:
@@ -48,6 +48,19 @@ TASK_STATUS_TEXT = {
|
|||||||
TaskStatus.CANCELLED: "已取消",
|
TaskStatus.CANCELLED: "已取消",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CURRENT_STEP_TEXT = {
|
||||||
|
"open_goods": "正在打开商品页面",
|
||||||
|
"collecting": "正在采集商品信息",
|
||||||
|
"collect_skus": "正在采集颜色、价格和尺码",
|
||||||
|
"select_options": "正在选择商品规格",
|
||||||
|
"placing_order": "正在提交订单",
|
||||||
|
"reconcile_order": "正在核对订单",
|
||||||
|
"submit_result": "正在提交任务结果",
|
||||||
|
"completed": "已完成",
|
||||||
|
"failed": "执行失败",
|
||||||
|
"interrupted": "上次执行中断",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class ColorPriceView:
|
class ColorPriceView:
|
||||||
@@ -206,7 +219,11 @@ def build_task_detail_view_data(detail: TaskDetail) -> TaskDetailViewData:
|
|||||||
title=_non_empty_text(pdd_data.get("title")) or detail.title or "未采集",
|
title=_non_empty_text(pdd_data.get("title")) or detail.title or "未采集",
|
||||||
goods_id=_non_empty_text(pdd_data.get("goods_id")) or detail.goods_id or "—",
|
goods_id=_non_empty_text(pdd_data.get("goods_id")) or detail.goods_id or "—",
|
||||||
goods_url=detail.goods_url,
|
goods_url=detail.goods_url,
|
||||||
current_step=detail.current_step or "—",
|
current_step=(
|
||||||
|
CURRENT_STEP_TEXT.get(detail.current_step, "未知步骤")
|
||||||
|
if detail.current_step
|
||||||
|
else "—"
|
||||||
|
),
|
||||||
target_spec=target_spec,
|
target_spec=target_spec,
|
||||||
quantity=str(detail.quantity) if detail.quantity is not None else "—",
|
quantity=str(detail.quantity) if detail.quantity is not None else "—",
|
||||||
updated_at=detail.updated_at,
|
updated_at=detail.updated_at,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
from dataclasses import replace
|
||||||
|
|
||||||
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
||||||
|
|
||||||
@@ -109,6 +110,14 @@ class TaskDetailViewTest(unittest.TestCase):
|
|||||||
self.assertEqual(data.sizes, [])
|
self.assertEqual(data.sizes, [])
|
||||||
self.assertEqual(data.shop_name, "未采集")
|
self.assertEqual(data.shop_name, "未采集")
|
||||||
self.assertEqual(data.sales, "未采集")
|
self.assertEqual(data.sales, "未采集")
|
||||||
|
self.assertEqual(data.current_step, "已完成")
|
||||||
|
|
||||||
|
def test_unknown_current_step_does_not_show_english_to_buyer(self):
|
||||||
|
detail = replace(make_detail(), current_step="future_internal_step")
|
||||||
|
|
||||||
|
data = build_task_detail_view_data(detail)
|
||||||
|
|
||||||
|
self.assertEqual(data.current_step, "未知步骤")
|
||||||
|
|
||||||
def test_window_builds_color_section_before_size_section(self):
|
def test_window_builds_color_section_before_size_section(self):
|
||||||
window = TaskDetailWindow(make_detail(collected_data()))
|
window = TaskDetailWindow(make_detail(collected_data()))
|
||||||
|
|||||||
@@ -186,6 +186,8 @@ class TaskTableModel(QAbstractTableModel):
|
|||||||
|
|
||||||
当前 Client 使用可调整大小的非模态详情窗口。用户可以点击表格“详情”、双击任务行,或选中任务后按 Enter 打开。相同任务只保留一个详情窗口;再次打开时切回已有窗口。按 Esc 或“关闭”按钮返回任务列表。
|
当前 Client 使用可调整大小的非模态详情窗口。用户可以点击表格“详情”、双击任务行,或选中任务后按 Enter 打开。相同任务只保留一个详情窗口;再次打开时切回已有窗口。按 Esc 或“关闭”按钮返回任务列表。
|
||||||
|
|
||||||
|
详情面向采购人员,任务类型、状态、当前步骤和错误说明优先使用中文。数据库中的 `current_step` 等内部值只用于业务判断和日志,不直接显示;遇到尚未适配的新步骤时显示“未知步骤”。
|
||||||
|
|
||||||
采集规格按下面顺序展示:
|
采集规格按下面顺序展示:
|
||||||
|
|
||||||
1. **颜色:**放在上方,每个颜色旁边直接显示采集到的价格;未采集到价格时显示“价格未采集”。同一颜色意外出现多个价格时显示最低价到最高价,并显示“价格不一致”,方便检查采集结果。
|
1. **颜色:**放在上方,每个颜色旁边直接显示采集到的价格;未采集到价格时显示“价格未采集”。同一颜色意外出现多个价格时显示最低价到最高价,并显示“价格不一致”,方便检查采集结果。
|
||||||
|
|||||||
Reference in New Issue
Block a user