feat(collect): show and filter product status
This commit is contained in:
+30
-4
@@ -2,7 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from .. import ai, appconfig, diagnostics
|
||||
from .. import ai, appconfig, diagnostics, product_status
|
||||
from ..collect_skip import skipped_stage_text
|
||||
from .widgets import *
|
||||
|
||||
@@ -10,7 +10,7 @@ from .widgets import *
|
||||
class TaskTableModel(QAbstractTableModel):
|
||||
"""Table model for task rows shared by workflow tabs."""
|
||||
|
||||
HEADERS = ["账号", "别名", "商品ID", "阶段"]
|
||||
HEADERS = ["账号", "别名", "商品ID", "阶段", "商品状态"]
|
||||
|
||||
STAGE_TEXT = {
|
||||
"imported": "待采集",
|
||||
@@ -89,9 +89,14 @@ class TaskTableModel(QAbstractTableModel):
|
||||
task = self.tasks[index.row()]
|
||||
if role == Qt.DisplayRole:
|
||||
return self._display_value(task, index.column())
|
||||
if role == Qt.ForegroundRole and index.column() == 3:
|
||||
return self._stage_color(task)
|
||||
if role == Qt.ForegroundRole:
|
||||
if index.column() == 3:
|
||||
return self._stage_color(task)
|
||||
if index.column() == 4:
|
||||
return self._product_status_color(task)
|
||||
if role == Qt.ToolTipRole:
|
||||
if index.column() == 4:
|
||||
return self._product_status_tooltip(task)
|
||||
error = getattr(task, "last_error", "") or ""
|
||||
if self.is_unmatched(task) or getattr(task, "status", "") == "skipped":
|
||||
if error:
|
||||
@@ -154,12 +159,33 @@ class TaskTableModel(QAbstractTableModel):
|
||||
return _qcolor(COLOR_SUCCESS)
|
||||
return _qcolor(COLOR_PENDING)
|
||||
|
||||
def _product_status_color(self, task):
|
||||
status = product_status.raw_status(getattr(task, "product_status", None))
|
||||
if status == product_status.STATUS_NORMAL:
|
||||
return _qcolor(COLOR_SUCCESS)
|
||||
if status == product_status.STATUS_UNLISTED:
|
||||
return _qcolor(COLOR_DANGER)
|
||||
if status == product_status.STATUS_REVIEWING:
|
||||
return _qcolor(COLOR_WARNING)
|
||||
return _qcolor(COLOR_MUTED)
|
||||
|
||||
def _product_status_tooltip(self, task):
|
||||
note = str(getattr(task, "product_status_note", "") or "").strip()
|
||||
detected_at = str(getattr(task, "product_status_at", "") or "").strip()
|
||||
lines = [note] if note else []
|
||||
if detected_at:
|
||||
lines.append(f"检测时间:{detected_at}")
|
||||
if not lines and product_status.raw_status(getattr(task, "product_status", None)) == product_status.STATUS_UNCHECKED:
|
||||
lines.append("尚未检测商品状态")
|
||||
return "\n".join(lines) or None
|
||||
|
||||
def _display_value(self, task, column):
|
||||
values = [
|
||||
self._account_name(task),
|
||||
task.alias,
|
||||
task.item_id,
|
||||
self._stage_text(task),
|
||||
product_status.display_status(getattr(task, "product_status", None)),
|
||||
]
|
||||
return values[column] if 0 <= column < len(values) else None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user