diff --git a/backend/migrations/columns.py b/backend/migrations/columns.py index bcd994f..a5949f0 100644 --- a/backend/migrations/columns.py +++ b/backend/migrations/columns.py @@ -114,5 +114,14 @@ def migrate_add_columns(): conn.commit() print("[migrate] 加列迁移完成") + + # 删除 plan_finances.status 列(计划模块不再需要状态字段) + cur = conn.cursor() + cur.execute("SHOW COLUMNS FROM plan_finances LIKE 'status'") + if cur.fetchone(): + cur.execute("ALTER TABLE plan_finances DROP COLUMN status") + conn.commit() + print("[migrate] plan_finances.status 列已删除") + cur.close() finally: conn.close() diff --git a/backend/migrations/data_fixes.py b/backend/migrations/data_fixes.py index fd74b70..0a3a384 100644 --- a/backend/migrations/data_fixes.py +++ b/backend/migrations/data_fixes.py @@ -121,11 +121,16 @@ def migrate_move_pending_to_plan(): conn = db() try: cur = conn.cursor() + # 获取 plan_finances 的列名(排除 status,因计划模块已删除该列) + cur.execute("SHOW COLUMNS FROM plan_finances") + plan_cols = [row[0] for row in cur.fetchall()] + col_list = ", ".join(plan_cols) + # 仅迁移 id 不存在于计划表的待签约项目 cur.execute( - "INSERT INTO plan_finances " - "SELECT * FROM project_finances WHERE status='待签约' " - "AND id NOT IN (SELECT id FROM plan_finances)" + f"INSERT INTO plan_finances ({col_list}) " + f"SELECT {col_list} FROM project_finances WHERE status='待签约' " + f"AND id NOT IN (SELECT id FROM plan_finances)" ) moved = cur.rowcount if moved: diff --git a/backend/routes.py b/backend/routes.py index eba32ed..bbbe99c 100644 --- a/backend/routes.py +++ b/backend/routes.py @@ -25,7 +25,7 @@ TABLES = { "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", "expense_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", ["expense_type", "expense_month", "amount", "incurred_amount", "notes", "status", "tenant"]), - "planFinances": ("plan_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", "expense_data", "start_date", "end_date", "task_type", "task_count", "service_fee_standard", "project_manager", "task_data", "project_code", "contact_name", "contact_phone", "other_info"]), + "planFinances": ("plan_finances", ["project_id", "tenant", "business_type", "customer_name", "sign_amount", "sign_month", "sales_person", "owner", "total_rev", "total_gross", "total_payment", "total_cost", "total_paid", "budget_data", "expense_data", "start_date", "end_date", "task_type", "task_count", "service_fee_standard", "project_manager", "task_data", "project_code", "contact_name", "contact_phone", "other_info"]), "planExpense": ("plan_expense_records", ["expense_type", "expense_month", "amount", "incurred_amount", "notes", "status", "tenant"]), } diff --git a/static/modules/plan.js b/static/modules/plan.js index 07e4148..5375c60 100644 --- a/static/modules/plan.js +++ b/static/modules/plan.js @@ -22,8 +22,8 @@ function renderPlan() { const months = displayMonths.map(d => d.key); const monthLabels = displayMonths.map(d => d.label); - const signed = pfs.filter(x => x.status === "已签约"); - const pending = pfs.filter(x => x.status === "待签约"); + const signed = pfs; + const pending = pfs; const sumSign = Math.round(signed.reduce((s,x) => s + (x.sign_amount||0), 0)); const sumPending = Math.round(pending.reduce((s,x) => s + (x.sign_amount||0), 0)); @@ -114,9 +114,13 @@ function renderPlan() { const finHeaderBase = `视图:${toolDateSelect}`; const finAddBtn = ``; - const planFilterTabs = `
`; + const planFilterTabs = `
`; document.querySelector("#plan").innerHTML = `
+
+ + 计划提醒:计划也是预算,只有真正能够列出计划的预算,才有靠谱的落地可能性 +
${planFilterTabs} ${state.planFilter !== 'expense' && state.planFilter !== 'overview' ? card(`
${finHeaderBase}
${finAddBtn}
`, "p-4") : ''}