财务项目详情升级:任务管理tab + 项目编号 + 执行信息 + 后端重构

后端重构:
- flask_app.py 拆分为 db.py/helpers.py/routes.py/seed_data.py + Blueprint
- 删除死代码 init_db/latest_followup,净减 240 行
- migrations 反向依赖消除

财务项目详情:
- 新增任务管理 tab(月份/类型/数量/已执行/差额/单价/执行金额/未执行金额)
- 新增项目编号、开始/结束时间、项目经理、合同服务费标准(5%-25%下拉)
- 科普业务类型新增科普专访、患教会
- task_data JSON 存储任务列表

财务视图:
- 只保留总视图和月度视图,去除确收/毛利和回款/应付视图
- 月度视图月份选择器
- 表格统一居中对齐
- 去除流程项目/流程金额卡片
This commit is contained in:
mac
2026-07-02 20:10:45 +08:00
parent caebf90438
commit 493150cb27
5 changed files with 171 additions and 7 deletions

View File

@@ -17,7 +17,7 @@ def run_migrations():
"""
from migrations.tables import migrate_create_tables
from migrations.columns import migrate_add_columns
from migrations.data_fixes import migrate_fix_task_status, migrate_rename_tenant, migrate_drop_product_fields
from migrations.data_fixes import migrate_fix_task_status, migrate_rename_tenant, migrate_drop_product_fields, migrate_fix_service_fee_standard
from migrations.seed import migrate_seed_users, migrate_seed_demo_data
migrate_create_tables()
@@ -25,5 +25,6 @@ def run_migrations():
migrate_fix_task_status()
migrate_rename_tenant()
migrate_drop_product_fields()
migrate_fix_service_fee_standard()
migrate_seed_users()
migrate_seed_demo_data()

View File

@@ -75,6 +75,24 @@ def migrate_add_columns():
_add_column_if_missing(conn, "project_finances", "total_paid",
"ALTER TABLE project_finances ADD COLUMN total_paid DOUBLE NOT NULL DEFAULT 0")
# project_finances 项目基本信息扩展字段
_add_column_if_missing(conn, "project_finances", "project_code",
"ALTER TABLE project_finances ADD COLUMN project_code VARCHAR(50) NOT NULL DEFAULT ''")
_add_column_if_missing(conn, "project_finances", "start_date",
"ALTER TABLE project_finances ADD COLUMN start_date VARCHAR(30) NOT NULL DEFAULT ''")
_add_column_if_missing(conn, "project_finances", "end_date",
"ALTER TABLE project_finances ADD COLUMN end_date VARCHAR(30) NOT NULL DEFAULT ''")
_add_column_if_missing(conn, "project_finances", "task_type",
"ALTER TABLE project_finances ADD COLUMN task_type VARCHAR(100) NOT NULL DEFAULT ''")
_add_column_if_missing(conn, "project_finances", "task_count",
"ALTER TABLE project_finances ADD COLUMN task_count DOUBLE NOT NULL DEFAULT 0")
_add_column_if_missing(conn, "project_finances", "service_fee_standard",
"ALTER TABLE project_finances ADD COLUMN service_fee_standard DOUBLE NOT NULL DEFAULT 0")
_add_column_if_missing(conn, "project_finances", "project_manager",
"ALTER TABLE project_finances ADD COLUMN project_manager VARCHAR(100) NOT NULL DEFAULT ''")
_add_column_if_missing(conn, "project_finances", "task_data",
"ALTER TABLE project_finances ADD COLUMN task_data TEXT")
conn.commit()
print("[migrate] 加列迁移完成")
finally:

View File

@@ -71,3 +71,24 @@ def migrate_drop_product_fields():
print(f"[migrate] 删除 {col} 失败: {e}")
finally:
conn.close()
def migrate_fix_service_fee_standard():
"""修正 project_finances.service_fee_standard 旧数据为默认值 55%"""
from db import db
conn = db()
try:
cur = conn.cursor()
cur.execute(
"UPDATE project_finances SET service_fee_standard = 5 "
"WHERE service_fee_standard = 0 OR service_fee_standard IS NULL "
"OR service_fee_standard NOT IN (5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25)"
)
affected = cur.rowcount
cur.close()
if affected:
conn.commit()
print(f"[migrate] project_finances: {affected} 条记录 service_fee_standard 修正为 5")
finally:
conn.close()

View File

@@ -23,7 +23,7 @@ TABLES = {
"products": ("product_versions", ["product_name", "version", "version_goal", "priority", "start_date", "plan_date", "dev_done_date", "test_date", "launch_date", "status", "notes", "tenant"]),
"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"]),
"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"]),
}
# ---------- 鉴权装饰器 ----------