From d98ef560c0b69f99648623a385f796e6f66fa8b5 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Mon, 15 Jun 2026 16:24:02 +0800 Subject: [PATCH] feat: add Excel export for leads and content - export_leads.dspy: generate xlsx with openpyxl, base64 return - export_content.dspy: generate xlsx for content list - admin.ui: add export section with download buttons - load_path.py: register export endpoints for RBAC - pyproject.toml: add openpyxl dependency --- pyproject.toml | 1 + scripts/load_path.py | 3 ++ wwwroot/admin.ui | 60 +++++++++++++++++++++++++++++++ wwwroot/api/export_content.dspy | 63 ++++++++++++++++++++++++++++++++ wwwroot/api/export_leads.dspy | 64 +++++++++++++++++++++++++++++++++ 5 files changed, 191 insertions(+) create mode 100644 wwwroot/api/export_content.dspy create mode 100644 wwwroot/api/export_leads.dspy diff --git a/pyproject.toml b/pyproject.toml index e68c50c..67d0099 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,6 +11,7 @@ dependencies = [ "sqlor", "bricks_for_python", "requests", + "openpyxl", ] [tool.setuptools.packages.find] diff --git a/scripts/load_path.py b/scripts/load_path.py index 4792491..30d071b 100644 --- a/scripts/load_path.py +++ b/scripts/load_path.py @@ -92,6 +92,9 @@ PATHS = [ # DingTalk f"/{MOD}/api/submit_approval.dspy", f"/{MOD}/api/dingtalk_callback.dspy", + # Export + f"/{MOD}/api/export_leads.dspy", + f"/{MOD}/api/export_content.dspy", ] def run(role, paths): diff --git a/wwwroot/admin.ui b/wwwroot/admin.ui index 30fa308..9bbd987 100644 --- a/wwwroot/admin.ui +++ b/wwwroot/admin.ui @@ -309,6 +309,66 @@ } ] }, + { + "widgettype": "HBox", + "options": { + "width": "100%", + "gap": "12px", + "marginTop": "16px", + "padding": "12px", + "css": "card", + "alignItems": "center" + }, + "subwidgets": [ + { + "widgettype": "Text", + "options": { + "text": "📥 数据导出", + "fontSize": "16px", + "fontWeight": "bold" + } + }, + { + "widgettype": "Filler" + }, + { + "widgettype": "Button", + "id": "btn_export_leads", + "options": { + "label": "导出商机线索", + "css": "primary" + }, + "binds": [ + { + "wid": "self", + "event": "click", + "actiontype": "script", + "options": { + "code": "var btn=this;btn.setLabel('生成中...');fetch(bricks.absurl('/cms/api/export_leads.dspy',btn)).then(function(r){return r.json()}).then(function(d){if(d.status==='ok'){var bin=atob(d.data);var bytes=new Uint8Array(bin.length);for(var i=0;i