feat(chat): 完善固资预览与下载权限
This commit is contained in:
1 parent
6ce0942fef
commit
bf18a7ef1d
19 files changed
+1163
-86
No files matched your search
@@ -34,6 +34,19 @@ class FixedAssetsSnapshotService:
|
||||
|
||||
SNAPSHOT_SQL_MARKER = "SNAPSHOT://FIXED_ASSETS"
|
||||
SNAPSHOT_KIND = "fixed_assets_snapshot_preview"
|
||||
PREVIEW_COLUMNS = (
|
||||
"序号",
|
||||
"资产编号",
|
||||
"资产名称",
|
||||
"保管人",
|
||||
"保管部门",
|
||||
"图片",
|
||||
"账套",
|
||||
"供应商",
|
||||
"资产状态",
|
||||
"数量",
|
||||
"取得时间",
|
||||
)
|
||||
|
||||
VISIBLE_COLUMNS = (
|
||||
"资产编号",
|
||||
@@ -126,6 +139,33 @@ class FixedAssetsSnapshotService:
|
||||
return ""
|
||||
return str(value).strip()
|
||||
|
||||
@classmethod
|
||||
def _build_preview_row(
|
||||
cls,
|
||||
row_map: dict[str, Any],
|
||||
*,
|
||||
row_number: int,
|
||||
) -> tuple[Any, ...]:
|
||||
"""
|
||||
用途:把固资快照原始查询结果收敛成聊天/预览统一使用的展示行。
|
||||
核心逻辑:按前端固定列顺序输出,并补充“序号”和“图片=查看”两个展示列。
|
||||
参数约束:row_map 必须包含资产编号等基础字段;当资产编号为空时,“图片”列保持为空,避免误导用户点击。
|
||||
"""
|
||||
asset_no = cls._stringify(row_map.get("资产编号"))
|
||||
return (
|
||||
row_number,
|
||||
asset_no,
|
||||
cls._stringify(row_map.get("资产名称")),
|
||||
cls._stringify(row_map.get("保管人姓名")),
|
||||
cls._stringify(row_map.get("保管部门名称")),
|
||||
"查看" if asset_no else "",
|
||||
cls._stringify(row_map.get("账套")),
|
||||
cls._stringify(row_map.get("供应厂商")),
|
||||
cls._stringify(row_map.get("资产状态")),
|
||||
cls._stringify(row_map.get("数量")),
|
||||
cls._stringify(row_map.get("取得日期")),
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def _normalize_search_text(cls, text: str) -> str:
|
||||
cleaned = str(text or "").upper()
|
||||
@@ -871,9 +911,16 @@ SELECT COUNT(*) FROM {result_source_name} WHERE {where_sql}
|
||||
cursor.execute(count_sql, params)
|
||||
total_count = int(cursor.fetchone()[0] or 0)
|
||||
cursor.execute(list_sql, [*params, max(1, int(limit)), max(0, int(offset))])
|
||||
columns = [str(item[0] or "").strip() for item in cursor.description]
|
||||
rows = [tuple(row) for row in cursor.fetchall()]
|
||||
return columns, rows, total_count
|
||||
raw_columns = [str(item[0] or "").strip() for item in cursor.description]
|
||||
raw_rows = [tuple(row) for row in cursor.fetchall()]
|
||||
rows = []
|
||||
for index, row in enumerate(raw_rows, start=max(0, int(offset)) + 1):
|
||||
row_map = {
|
||||
raw_columns[column_index]: row[column_index]
|
||||
for column_index in range(min(len(raw_columns), len(row)))
|
||||
}
|
||||
rows.append(cls._build_preview_row(row_map, row_number=index))
|
||||
return list(cls.PREVIEW_COLUMNS), rows, total_count
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
Reference in new issue
Block a user