diff --git a/backend/routes.py b/backend/routes.py index c8712e0..1acf410 100644 --- a/backend/routes.py +++ b/backend/routes.py @@ -666,6 +666,26 @@ def bootstrap(): # ---------- 通用 CRUD ---------- +@bp.route("/api//list", methods=["GET"]) +@login_required +def list_resource(resource): + """轻量级列表接口,只返回指定 tenant 的记录""" + if resource not in TABLES: + return jsonify({"error": "unknown resource"}), 404 + table, _ = TABLES[resource] + tenant = request.args.get("tenant", session.get("tenants", [""])[0]) + allowed = session.get("tenants", []) + allowed = [t if t != "总工作台" else "总览" for t in allowed] + allowed = [t if t != "学会·无界" else "学术·无界" for t in allowed] + if tenant not in allowed: + tenant = allowed[0] if allowed else "" + conn = db() + try: + result = rows(conn, f"SELECT * FROM {table} WHERE tenant=? ORDER BY id DESC", [tenant]) + return jsonify(result) + finally: + conn.close() + @bp.route("/api/", methods=["POST"]) @login_required def create_resource(resource): diff --git a/static/modules/plan_expense.js b/static/modules/plan_expense.js index 88b6312..98e2129 100644 --- a/static/modules/plan_expense.js +++ b/static/modules/plan_expense.js @@ -199,8 +199,10 @@ window.savePlanExpense = async function(event) { return; } closePlanExpModal(); - await load(); - renderPlanExpense(); + try { + state.data.planExpense = await api("/api/planExpense/list?tenant=" + encodeURIComponent(state.tenant)); + renderPlanExpense(); + } catch (e) { /* non-critical */ } }; window.deletePlanExpItem = async function() { @@ -213,6 +215,8 @@ window.deletePlanExpItem = async function() { return; } closePlanExpModal(); - await load(); - renderPlanExpense(); + try { + state.data.planExpense = await api("/api/planExpense/list?tenant=" + encodeURIComponent(state.tenant)); + renderPlanExpense(); + } catch (e) { /* non-critical */ } }; diff --git a/templates/index.html b/templates/index.html index 0b6da50..97d2007 100644 --- a/templates/index.html +++ b/templates/index.html @@ -76,7 +76,7 @@
-

OPC Manager v1.0.0.36

+

OPC Manager v1.0.0.37

科普 OPC 工作台