feat: 费用模块重构 + 项目模块优化 + 数据库迁移
费用模块: - 字段精简为5个:费用类型(下拉6选)、月份(3年36月下拉)、金额、已发生金额、费用说明(textarea) - 三视图切换(总/季度/月度),按expense_month筛选,汇总卡片实时更新 - 类型筛选功能,Toolbar+汇总+表格三段式布局 - 删除按钮移至关闭按钮左侧,间距8px - 费用记录删除合计行,列宽固定200px,居中 项目模块: - 卡片网格6→7列(14卡片7×2满排),配置驱动 METRIC_CARDS - 新增费用/利润字段,利润=毛利-费用 - 表格行添加费用、利润列,比率列text-xs→text-sm - 项目流水tab费用与已付列对调,汇总卡片6→1×6 - 修复月度/季度切换时汇总卡片不更新 - 筛选区统一为卡片,去除'筛选:'前缀 数据库: - expense_records新增expense_type/expense_month/incurred_amount列 - migrations/columns.py幂等迁移,启动时自动执行
This commit is contained in:
@@ -98,6 +98,13 @@ def migrate_add_columns():
|
||||
"ALTER TABLE project_finances ADD COLUMN contact_phone VARCHAR(50) NOT NULL DEFAULT ''")
|
||||
_add_column_if_missing(conn, "project_finances", "other_info",
|
||||
"ALTER TABLE project_finances ADD COLUMN other_info VARCHAR(500) NOT NULL DEFAULT ''")
|
||||
# expense_records 字段迁移(重构为费用类型+月份+金额+已发生金额+费用说明)
|
||||
_add_column_if_missing(conn, "expense_records", "expense_type",
|
||||
"ALTER TABLE expense_records ADD COLUMN expense_type VARCHAR(100) NOT NULL DEFAULT ''")
|
||||
_add_column_if_missing(conn, "expense_records", "expense_month",
|
||||
"ALTER TABLE expense_records ADD COLUMN expense_month VARCHAR(20) NOT NULL DEFAULT ''")
|
||||
_add_column_if_missing(conn, "expense_records", "incurred_amount",
|
||||
"ALTER TABLE expense_records ADD COLUMN incurred_amount DOUBLE NOT NULL DEFAULT 0")
|
||||
|
||||
conn.commit()
|
||||
print("[migrate] 加列迁移完成")
|
||||
|
||||
@@ -150,13 +150,10 @@ def migrate_create_tables():
|
||||
"""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 '',
|
||||
purchase_item VARCHAR(300) NOT NULL DEFAULT '',
|
||||
supplier VARCHAR(200) NOT NULL DEFAULT '',
|
||||
expense_type VARCHAR(100) NOT NULL DEFAULT '',
|
||||
expense_month VARCHAR(20) NOT NULL DEFAULT '',
|
||||
amount DOUBLE NOT NULL DEFAULT 0,
|
||||
purchase_date VARCHAR(30) NOT NULL DEFAULT '',
|
||||
status VARCHAR(50) NOT NULL DEFAULT '待审批',
|
||||
category VARCHAR(100) NOT NULL DEFAULT '',
|
||||
incurred_amount DOUBLE NOT NULL DEFAULT 0,
|
||||
notes VARCHAR(1000) NOT NULL DEFAULT '',
|
||||
created_at VARCHAR(30) NOT NULL DEFAULT '',
|
||||
updated_at VARCHAR(30) 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"]),
|
||||
"expense": ("expense_records", ["project_name", "purchase_item", "supplier", "amount", "purchase_date", "status", "category", "notes", "tenant"]),
|
||||
"expense": ("expense_records", ["expense_type", "expense_month", "amount", "incurred_amount", "notes", "tenant"]),
|
||||
}
|
||||
|
||||
# ---------- 鉴权装饰器 ----------
|
||||
|
||||
Reference in New Issue
Block a user