feat(system): add Excel export for operlog and dict type lists
Wire ListExportDropdown with filtered/selected backend xlsx export. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
1053e24896
commit
b3b6ec187a
8 files changed
+228
-3
No files matched your search
@@ -635,6 +635,56 @@ def list_dict_types(
|
||||
return success_response({"list": items, "total": total, "page": page, "pageSize": pageSize, "totalPages": tp})
|
||||
|
||||
|
||||
|
||||
DICT_TYPE_EXPORT_COLUMNS = [
|
||||
ExportColumn(title="字典名称", field="dictName"),
|
||||
ExportColumn(title="字典类型编码", field="dictType"),
|
||||
ExportColumn(title="备注", field="remark"),
|
||||
ExportColumn(title="创建时间", field="createTime"),
|
||||
]
|
||||
|
||||
|
||||
class DictTypeExportBody(BaseModel):
|
||||
keyword: Optional[str] = None
|
||||
ids: Optional[List[str]] = None
|
||||
columns: Optional[List[str]] = None
|
||||
|
||||
|
||||
@router.post("/dict-types/export")
|
||||
def export_dict_types(
|
||||
body: DictTypeExportBody,
|
||||
user: dict = Depends(require_menu_code("system:dict:list")),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""导出字典类型列表(当前筛选全量,或 ids 已选)。"""
|
||||
try:
|
||||
tenant_no = _get_tenant_no(db, user)
|
||||
items, _ = dict_type_svc.list_dict_types(
|
||||
db,
|
||||
page=1,
|
||||
page_size=EXPORT_MAX_ROWS,
|
||||
keyword=body.keyword,
|
||||
tenant_no=tenant_no,
|
||||
ids=body.ids,
|
||||
max_page_size=EXPORT_MAX_ROWS,
|
||||
user_info=user,
|
||||
)
|
||||
cols = filter_export_columns(DICT_TYPE_EXPORT_COLUMNS, body.columns)
|
||||
date_str = datetime.now().strftime("%Y%m%d")
|
||||
return export_rows_to_xlsx_response(
|
||||
db,
|
||||
tenant_no=tenant_no,
|
||||
sheet_title="字典类型",
|
||||
columns=cols,
|
||||
rows=items,
|
||||
filename_stem=f"字典类型_{date_str}",
|
||||
)
|
||||
except ExportValidationError as e:
|
||||
return error_response(400, str(e))
|
||||
except Exception as e:
|
||||
return error_response(500, str(e))
|
||||
|
||||
|
||||
@router.post("/dict-types")
|
||||
def create_dict_type(
|
||||
body: DictTypeCreateBody,
|
||||
|
||||
Reference in new issue
Block a user