refactor: 项目模块重构 — 统一渲染 + 配置驱动 + 交互优化
核心重构: - 提取 renderView() / tdRow() 统一函数,消除三视图 16000+ 字符重复代码 - METRIC_CARDS 配置驱动,调整卡片顺序/单位只需改配置 - 筛选区统一为下拉框(视图 + 状态 + 日期),删除筛选:前缀 - 日历选择器移至顶部工具栏,卡片内不再重复 功能优化: - 项目状态简化为已签约/待签约 - 新增签约项目总数卡片(月度/季度按签约月份过滤) - 签约金额/已确收/已回款/应付/已付改为万元单位 - 项目名称固定300px + 省略号 + title悬停 - body min-width 1400px + overflow-x:auto - 首页费用金额→应付金额 代码清理: - 删除 monthOpts/quarterOpts/qLabels 等死代码 - 删除 purchase.js(采购→费用模块已另表迁移) - 财务→项目(侧边栏),采购→费用(全域重命名)
This commit is contained in:
@@ -147,7 +147,7 @@ def migrate_create_tables():
|
||||
created_at VARCHAR(30) NOT NULL DEFAULT '',
|
||||
updated_at VARCHAR(30) NOT NULL DEFAULT ''
|
||||
)""",
|
||||
"""CREATE TABLE IF NOT EXISTS purchase_records (
|
||||
"""CREATE TABLE IF NOT EXISTS expense_records (
|
||||
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||
tenant VARCHAR(100) NOT NULL DEFAULT '科普·无界',
|
||||
project_name VARCHAR(200) NOT NULL DEFAULT '',
|
||||
|
||||
@@ -24,7 +24,7 @@ TABLES = {
|
||||
"finance": ("finance_records", ["month", "project_name", "record_type", "category", "amount", "occurred_date", "notes", "tenant"]),
|
||||
"tasks": ("project_tasks", ["project_id", "phase", "milestone", "task", "owner", "due_date", "blockers", "notes", "status", "sort_order", "priority", "tenant"]),
|
||||
"projectFinances": ("project_finances", ["project_id", "tenant", "business_type", "customer_name", "sign_amount", "sign_month", "status", "sales_person", "owner", "total_rev", "total_gross", "total_payment", "total_cost", "total_paid", "budget_data", "start_date", "end_date", "task_type", "task_count", "service_fee_standard", "project_manager", "task_data", "project_code", "contact_name", "contact_phone", "other_info"]),
|
||||
"purchase": ("purchase_records", ["project_name", "purchase_item", "supplier", "amount", "purchase_date", "status", "category", "notes", "tenant"]),
|
||||
"expense": ("expense_records", ["project_name", "purchase_item", "supplier", "amount", "purchase_date", "status", "category", "notes", "tenant"]),
|
||||
}
|
||||
|
||||
# ---------- 鉴权装饰器 ----------
|
||||
@@ -322,7 +322,7 @@ def bootstrap():
|
||||
"recent": sorted(all_recent, key=lambda x: x.get("id", 0), reverse=True)[:8],
|
||||
"risks": [],
|
||||
}
|
||||
return jsonify({"summary": summary, "sales": [], "proposals": [], "operations": [], "products": [], "finance": [], "projectFinances": [], "financeMonthly": merged_monthly, "tasks": [], "purchase": [], "tenant": tenant, "tenants": allowed})
|
||||
return jsonify({"summary": summary, "sales": [], "proposals": [], "operations": [], "products": [], "finance": [], "projectFinances": [], "financeMonthly": merged_monthly, "tasks": [], "expense": [], "tenant": tenant, "tenants": allowed})
|
||||
|
||||
def q(sql, *args):
|
||||
return rows(conn, sql, args)
|
||||
@@ -333,7 +333,7 @@ def bootstrap():
|
||||
finance = q("SELECT * FROM finance_records WHERE tenant=? ORDER BY month DESC, id DESC", tenant)
|
||||
tasks = q("SELECT * FROM project_tasks WHERE tenant=? ORDER BY phase, sort_order, id", tenant)
|
||||
pfs = q("SELECT * FROM project_finances WHERE tenant=? ORDER BY id DESC", tenant)
|
||||
purchase = q("SELECT * FROM purchase_records WHERE tenant=? ORDER BY id DESC", tenant)
|
||||
expense = q("SELECT * FROM expense_records WHERE tenant=? ORDER BY id DESC", tenant)
|
||||
signed_pfs = [x for x in pfs if x["status"] == "已签约"]
|
||||
|
||||
def parse_budget(pf):
|
||||
@@ -436,7 +436,7 @@ def bootstrap():
|
||||
"recent": q("SELECT * FROM follow_up_records WHERE tenant=? ORDER BY id DESC LIMIT 8", tenant),
|
||||
"risks": [{"title": "执行提醒", "content": x["next_action"]} for x in operations if x["next_action"]][:5],
|
||||
}
|
||||
return jsonify({"summary": summary, "sales": sales, "proposals": proposals, "operations": operations, "products": products, "finance": finance, "projectFinances": pfs, "financeMonthly": monthly_finance(conn, tenant), "tasks": tasks, "purchase": purchase, "tenant": tenant, "tenants": allowed})
|
||||
return jsonify({"summary": summary, "sales": sales, "proposals": proposals, "operations": operations, "products": products, "finance": finance, "projectFinances": pfs, "financeMonthly": monthly_finance(conn, tenant), "tasks": tasks, "expense": expense, "tenant": tenant, "tenants": allowed})
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user