diff --git a/VERSION_LOG.md b/VERSION_LOG.md index 619f4a6..ea91c58 100644 --- a/VERSION_LOG.md +++ b/VERSION_LOG.md @@ -1,5 +1,10 @@ # OPC Manager Version Log +## v1.1.0 — 2026-06-15 +- 首页指标升级:增加已签约合同总额、合同流程中金额、年度/Q2 累计确收、年度/Q2 累计毛利、已签约未执行 +- 运营表格增加「金额」列 +- 产品研发增加「平台」字段(真研/科普/关爱),支持平台筛选 + ## v1.0.7 — 2026-06-04 - 修复新增表单 async 后 `event.currentTarget` 丢失导致页面不刷新(影响所有新增按钮) - `createResource` 改用预存 form 引用 + try/catch 错误提示 diff --git a/backend/flask_app.py b/backend/flask_app.py index 08f9ce4..2ccc9f9 100644 --- a/backend/flask_app.py +++ b/backend/flask_app.py @@ -144,6 +144,10 @@ CREATE TABLE IF NOT EXISTS file_assets ( ); """ ) + # Schema migrations + try: conn.execute("ALTER TABLE product_versions ADD COLUMN platform TEXT NOT NULL DEFAULT ''") + except: pass + if one(conn, "SELECT id FROM sales_leads LIMIT 1"): conn.close() return @@ -210,15 +214,15 @@ CREATE TABLE IF NOT EXISTS file_assets ( add_file_index(conn, "operation", project_id, version, category, op_dir / filename, external=True) products = [ - ("妙手医生服务小程序", "v1.1", "视频任务增强 + 积分商城", "草稿箱、批量上传、积分商城、消息通知", "2026-Q3", "规划中"), - ("数字化营销后台管理系统", "v1.2", "运营数据看板 + 智能审核", "医生活跃、任务完成率、AI 预审、渠道数据上报", "2026-Q3", "设计中"), - ("妙手患者服务", "v0.5", "科普浏览 + 医生主页 MVP", "科普文章/视频浏览、医生主页、搜索", "2026-Q3", "规划中"), - ("数字人内容平台", "v0.1", "基础数字人视频生成 MVP", "预设形象、AI 配音、脚本驱动、简单模板", "2026-Q3", "规划中"), - ("渠道分发引擎", "v1.0", "六渠道统一分发", "分发 API、内容适配、分发排期、效果追踪", "2027-Q1", "规划中"), + ("妙手医生服务小程序", "v1.1", "视频任务增强 + 积分商城", "草稿箱、批量上传、积分商城、消息通知", "2026-Q3", "规划中", "科普平台"), + ("数字化营销后台管理系统", "v1.2", "运营数据看板 + 智能审核", "医生活跃、任务完成率、AI 预审、渠道数据上报", "2026-Q3", "设计中", "真研平台"), + ("妙手患者服务", "v0.5", "科普浏览 + 医生主页 MVP", "科普文章/视频浏览、医生主页、搜索", "2026-Q3", "规划中", "科普平台"), + ("数字人内容平台", "v0.1", "基础数字人视频生成 MVP", "预设形象、AI 配音、脚本驱动、简单模板", "2026-Q3", "规划中", "科普平台"), + ("渠道分发引擎", "v1.0", "六渠道统一分发", "分发 API、内容适配、分发排期、效果追踪", "2027-Q1", "规划中", "科普平台"), ] for product in products: cur = conn.execute( - "INSERT INTO product_versions (product_name,version,version_goal,feature_list,launch_date,status) VALUES (?,?,?,?,?,?)", + "INSERT INTO product_versions (product_name,version,version_goal,feature_list,launch_date,status,platform) VALUES (?,?,?,?,?,?,?)", product, ) conn.execute( @@ -304,9 +308,22 @@ def bootstrap(): operations = attach_common(conn, "operations", rows(conn, "SELECT * FROM operation_projects ORDER BY id DESC")) products = attach_common(conn, "products", rows(conn, "SELECT * FROM product_versions ORDER BY id DESC")) finance = rows(conn, "SELECT * FROM finance_records ORDER BY month DESC, id DESC") - current_month = "2026-05" - revenue = sum(x["amount"] for x in finance if x["month"] == current_month and x["record_type"] == "revenue") - cost = sum(x["amount"] for x in finance if x["month"] == current_month and x["record_type"] == "cost_expense") + current_month = "2026-06" + # Finance aggregates + def sum_finance(months, rtype): + return sum(x["amount"] for x in finance if x["month"] in months and x["record_type"] == rtype) + months_2026 = [f"2026-{m:02d}" for m in range(1,7)] + months_q2 = ["2026-04","2026-05","2026-06"] + revenue_annual = sum_finance(months_2026, "revenue") + cost_annual = sum_finance(months_2026, "cost_expense") + revenue_q2 = sum_finance(months_q2, "revenue") + cost_q2 = sum_finance(months_q2, "cost_expense") + revenue_month = sum_finance([current_month], "revenue") + cost_month = sum_finance([current_month], "cost_expense") + # Contract aggregates + signed_amount = sum(x["expected_contract_amount"] or 0 for x in operations if x["project_status"] == "已签约") + pipeline_amount = sum(x["expected_contract_amount"] or 0 for x in operations if x["project_status"] not in ["已签约","已丢单","已归档","已完成"]) + signed_not_executed = sum(x["expected_contract_amount"] or 0 for x in operations if x["project_type"] == "execution" and x["execution_progress"] < 100) summary = { "project_name": "科普(慰心斋)", "metrics": { @@ -314,9 +331,17 @@ def bootstrap(): "active_sales": len([x for x in sales if x["status"] in ["待跟进", "跟进中", "方案中", "商务谈判"]]), "execution_projects": len([x for x in operations if x["project_type"] == "execution"]), "risk_projects": len([x for x in operations if x["project_status"] == "有风险" or x["risks"]]), - "monthly_revenue": revenue, - "monthly_net_profit": revenue - cost, + "monthly_revenue": revenue_month, + "monthly_net_profit": revenue_month - cost_month, "upcoming_products": len([x for x in products if x["status"] in ["规划中", "设计中", "开发中", "测试中"]]), + # Extended finance metrics + "signed_amount": signed_amount, + "pipeline_amount": pipeline_amount, + "revenue_annual": revenue_annual, + "revenue_q2": revenue_q2, + "gross_annual": revenue_annual - cost_annual, + "gross_q2": revenue_q2 - cost_q2, + "signed_not_executed": signed_not_executed, }, "recent": rows(conn, "SELECT * FROM follow_up_records ORDER BY id DESC LIMIT 8"), "risks": [{"title": "执行提醒", "content": x["next_action"]} for x in operations if x["next_action"]][:5], @@ -330,7 +355,7 @@ TABLES = { "sales": ("sales_leads", ["target_customer", "priority", "status"]), "proposals": ("business_proposals", ["customer_or_project_name", "version", "description", "status", "created_date"]), "operations": ("operation_projects", ["project_name", "project_version", "project_type", "project_status", "current_stage", "owner", "target_customer", "customer_need", "expected_contract_amount", "expected_sign_date", "sign_probability", "next_action", "sop_stage", "execution_progress", "current_deliverable", "risks", "notes"]), - "products": ("product_versions", ["product_name", "version", "version_goal", "feature_list", "launch_date", "status", "notes"]), + "products": ("product_versions", ["product_name", "version", "version_goal", "feature_list", "launch_date", "status", "platform", "notes"]), "finance": ("finance_records", ["month", "project_name", "record_type", "category", "amount", "occurred_date", "notes"]), } diff --git a/static/app.js b/static/app.js index 093671b..274c68b 100644 --- a/static/app.js +++ b/static/app.js @@ -4,6 +4,7 @@ const state = { opFilter: "all", chart: null, chart2: null, + productPlatform: "all", }; const money = (value) => `${Number(value || 0).toLocaleString("zh-CN")} 万`; @@ -104,8 +105,19 @@ function renderHome() { ["本月收入", money(m.monthly_revenue), "finance"], ["本月净利", money(m.monthly_net_profit), "finance"], ["即将上线版本", m.upcoming_products, "products"], + ["已签约未执行", money(m.signed_not_executed), "finance"], ].map(([label, value, tab]) => ``).join("")} +
+ ${[ + ["已签约合同总额", money(m.signed_amount), "operations"], + ["合同流程中", money(m.pipeline_amount), "operations"], + ["年度累计确收", money(m.revenue_annual), "finance"], + ["Q2 累计确收", money(m.revenue_q2), "finance"], + ["年度累计毛利", money(m.gross_annual), "finance"], + ["Q2 累计毛利", money(m.gross_q2), "finance"], + ].map(([label, value, tab]) => ``).join("")} +
${card(`

财务趋势

${badge("YYYY-MM")}
`, "p-4")} ${card(`

风险提醒

${(summary.risks.length ? summary.risks : [{ title: "暂无高风险", content: "当前无明确阻塞,按周更新即可。" }]).map((r) => `

${r.title}

${r.content}

`).join("")}
`, "p-5")} @@ -222,7 +234,7 @@ window.uploadFile = async (event, module, ownerId, version, category) => { function renderOperations() { const items = state.opFilter === "all" ? state.data.operations : state.data.operations.filter((x) => x.project_type === state.opFilter); - const opRows = items.map((x) => [`${x.project_name}

${x.project_version}

`, badge(x.project_type), badge(x.project_status), text(x.current_stage || x.sop_stage), `${x.files.length} 个`, text(x.latest_follow_up_record)]); + const opRows = items.map((x) => [`${x.project_name}

${x.project_version}

`, badge(x.project_type), badge(x.project_status), x.expected_contract_amount ? money(x.expected_contract_amount) : "—", text(x.current_stage || x.sop_stage), `${x.files.length} 个`, text(x.latest_follow_up_record)]); const opClicks = items.map((x) => ({ resource: "operations", id: x.id })); document.querySelector("#operations").innerHTML = `
${card(formHtml([ @@ -232,19 +244,22 @@ function renderOperations() { { label: "状态", input: `` }, ], { handler: "createOperation", text: "新增项目" }), "p-4")}
${[["all","全部项目"],["opportunity","业务机会项目"],["execution","已签约执行项目"]].map(([k,v]) => ``).join("")}
- ${renderTable(["项目名称", "类型", "状态", "当前阶段", "交付文件", "最新跟进"], opRows, opClicks)} + ${renderTable(["项目名称", "类型", "状态", "金额", "当前阶段", "交付文件", "最新跟进"], opRows, opClicks)}
`; } function renderProducts() { + const items = state.productPlatform === "all" ? state.data.products : state.data.products.filter((x) => (x.platform || "") === state.productPlatform); document.querySelector("#products").innerHTML = `
${card(formHtml([ { label: "产品名称", input: `` }, { label: "版本号", input: `` }, + { label: "平台", input: `` }, { label: "上线日期", input: `` }, { label: "状态", input: `` }, ], { handler: "createProduct", text: "新增版本" }), "p-4")} - ${renderTable(["产品名称", "版本号", "版本目标", "核心功能", "上线日期", "状态"], state.data.products.map((p) => [p.product_name, p.version, text(p.version_goal), text(p.feature_list), text(p.launch_date), badge(p.status)]), state.data.products.map((p) => ({ resource: "products", id: p.id })))} +
${[["all","全部"],["真研平台","真研"],["科普平台","科普"],["关爱平台","关爱"]].map(([k,v]) => ``).join("")}
+ ${renderTable(["产品名称", "版本号", "版本目标", "核心功能", "平台", "上线日期", "状态"], items.map((p) => [p.product_name, p.version, text(p.version_goal), text(p.feature_list), text(p.platform), text(p.launch_date), badge(p.status)]), items.map((p) => ({ resource: "products", id: p.id })))}
`; } @@ -304,14 +319,14 @@ function openDrawer(resource, id) { ? [["project_name","项目名称"],["project_version","项目版本"],["project_status","项目状态"],["current_stage","当前阶段"],["target_customer","业务机会"],["customer_need","客户需求"],["expected_contract_amount","预计签约金额"],["expected_sign_date","预计签约时间"],["sign_probability","签约概率"],["sop_stage","SOP 阶段"],["execution_progress","执行进度"],["current_deliverable","当前交付物"],["risks","风险与阻塞"],["next_action","下一步动作"]] : resource === "proposals" ? [["customer_or_project_name","客户/项目"],["version","版本号"],["description","版本说明"],["created_date","创建日期"],["status","状态"]] - : [["product_name","产品名称"],["version","版本号"],["version_goal","版本目标"],["feature_list","核心功能清单"],["launch_date","上线日期"],["status","当前状态"],["notes","备注"]]; + : [["product_name","产品名称"],["version","版本号"],["version_goal","版本目标"],["feature_list","核心功能清单"],["platform","平台"],["launch_date","上线日期"],["status","当前状态"],["notes","备注"]]; const fieldIcons = { target_customer: "user", priority: "flag", status: "circle-dot", project_name: "briefcase-business", project_version: "git-branch", project_status: "circle-dot", current_stage: "map-pin", customer_need: "file-text", expected_contract_amount: "banknote", expected_sign_date: "calendar", sign_probability: "percent", sop_stage: "list-checks", execution_progress: "activity", current_deliverable: "package", risks: "alert-triangle", next_action: "arrow-right", - product_name: "box", version: "tag", version_goal: "target", feature_list: "list", + product_name: "box", version: "tag", version_goal: "target", feature_list: "list", platform: "layers", launch_date: "calendar", notes: "sticky-note" }; const multilineFields = ["customer_need", "current_deliverable", "risks", "next_action", "version_goal", "feature_list", "notes"];