Compare commits

...

51 Commits

Author SHA1 Message Date
mac
4911f24d40 v3.1.4 — 修复pfs变量丢失导致加载失败 2026-06-17 13:13:27 +08:00
mac
8c24abd53e v3.1.3 — 财务弹窗UI优化:分区卡片布局+月网格+圆角+更大尺寸 2026-06-17 13:12:39 +08:00
mac
0a7f70757d v3.1.2 — 财务弹窗按工作台显示项目和业务类型 2026-06-17 13:11:06 +08:00
mac
29dc7e040e v3.1.1 — 科普·无界新增"全品类科普"类型 2026-06-17 13:07:36 +08:00
mac
c8387011cc v3.1.0 — 财务分类重构:三大工作台13种业务类型+66条重新分配 2026-06-17 13:05:58 +08:00
mac
5061de70f8 v3.0.4 — 点击项目行弹出编辑弹窗+PUT保存 2026-06-17 11:27:29 +08:00
mac
ea3ba25da5 v3.0.3 — 修复:新增财务项目改为弹窗按钮+finFilter+createFinance修正 2026-06-17 11:17:12 +08:00
mac
bd7125fab8 v3.0.2 — 新增财务项目改为弹窗按钮+月度趋势缩减为6个月 2026-06-16 17:11:02 +08:00
mac
94dd1fe677 v3.0.1 — 财务项目明细已签/待签分Tab展示 2026-06-16 16:57:13 +08:00
mac
fa6c9b1711 v3.0 — 财务重构为项目财务视图:汇总卡片+项目明细+月度确收/毛利 2026-06-16 16:43:44 +08:00
mac
f4eacfafe2 v2.0.9 — 业务方案删除按钮改为通用deleteDrawerItem支持所有资源 2026-06-16 16:03:33 +08:00
mac
f8c816dc38 v2.0.8 — 任务行添加拖拽手柄图标(grip-vertical) 2026-06-16 16:01:54 +08:00
mac
e2d9049e45 v2.0.7 — 标题随项目切换动态变化:科普/科研/医患 OPC 工作台 2026-06-16 15:57:18 +08:00
mac
1b0049e342 v2.0.6 — X轴12月(前9+当前+后2) + Y轴万元 + 净利口径=确认收入-人力-费用-采购 2026-06-16 15:56:21 +08:00
mac
87a5d4f81d v2.0.5 — 财务曲线改为5类对应+月度净利=确认收入-人力成本-费用-外部采购 2026-06-16 15:54:24 +08:00
mac
d6ec7b24ec v2.0.4 — 曲线图默认折叠可展开,明细列表默认展示 2026-06-16 15:51:09 +08:00
mac
194c91cf25 v2.0.3 — 财务增加费用说明输入框 + 明细表默认折叠可展开 2026-06-16 15:49:35 +08:00
mac
68797e4fb5 v2.0.2 — 财务类型改为5类:签单/确认收入/人力成本/费用/外部采购 2026-06-16 15:47:44 +08:00
mac
af4ae1cbc3 v2.0.1 — 财务表单简化:日月合并+去类型+分类含签单+日历控件 2026-06-16 15:47:04 +08:00
mac
c42abb05da v2.0 — 多项目支持:右上角下拉切换科普/科研/医患三个项目 2026-06-16 15:42:28 +08:00
mac
4d1dc3b355 v1.8.1 — 新增项目表单默认展开 + 去掉按钮 + 按钮文字改为新增项目 2026-06-16 15:15:52 +08:00
mac
60bae583b2 v1.8.0 — 任务checkbox+删除线 + 拖拽排序 + 抽屉删除按钮 2026-06-16 15:14:31 +08:00
mac
c68fcaadcc v1.7.10 — 首页指标简化为6卡片:重点项目/业务方案/产品版本/本月确收/本月毛利/本月净利 2026-06-16 15:09:49 +08:00
mac
2c199aae76 v1.7.9 — 修复首页丢失 m 变量定义 2026-06-16 15:05:11 +08:00
mac
be6a7f5c38 v1.7.8 — 首页改为3表格卡片(合同/确收/毛利) + 合同时间维指标 2026-06-16 14:21:57 +08:00
mac
6adc00a8a7 v1.7.7 — 更新产品文档 PRD v2.0 + CHANGELOG v1.0→v2.0 2026-06-16 14:18:32 +08:00
mac
c4aacd5096 v1.7.6 — 项目抽屉增加红色删除按钮+确认对话框 2026-06-16 14:16:32 +08:00
mac
4f7db75a7f v1.7.5 — 任务页工具栏与卡片对齐 2026-06-16 11:26:17 +08:00
mac
9707009895 v1.7.4 — 项目抽屉「当前阶段」改为6阶段下拉 + select自动保存 2026-06-16 11:25:18 +08:00
mac
6defe95a3f v1.7.3 — 项目抽屉简化为6字段:名称/负责人/阶段/截止/金额/说明 2026-06-16 11:22:47 +08:00
mac
a1b154abd7 v1.7.2 — 返回项目列表后 Lucide 图标刷新 2026-06-16 11:20:10 +08:00
mac
fc0ee66064 v1.7.1 — 任务抽屉改为 fixed 定位,长列表不丢失 2026-06-16 11:18:04 +08:00
mac
5af58c8faa v1.7.0 — 任务清单改为 Tab 内二级页面,不再使用独立弹窗 2026-06-16 11:15:55 +08:00
mac
b682427ea0 v1.6.1 — 去除重点项目顶部阶段筛选分类标签 2026-06-16 11:13:30 +08:00
mac
ec83bb5e22 v1.6.0 — 任务编辑改为右侧抽屉滑入,顶栏不再内嵌表单 2026-06-16 11:11:34 +08:00
mac
921afd198b v1.5.1 — 修复编辑任务后误删DOM导致只剩一条 2026-06-16 10:57:29 +08:00
mac
850ad340e5 v1.5.0 — 项目阶段改为6阶段:商务洽谈/系统上线/团队分工/项目交付/上线推广/结项验收 2026-06-16 10:54:55 +08:00
mac
cec3e3a2ad v1.4.1 — 任务表单增加「卡点&备注」字段,任务行显示卡点红色标记 2026-06-16 10:33:58 +08:00
mac
e02c0bd183 v1.4.0 — 任务面板统一亮色 + 点击任务可编辑 + 任务说明自动换行 2026-06-16 10:32:34 +08:00
mac
853344fb26 v1.3.9 — 任务面板加宽到1000px + 横向表格布局 + 空分组自动隐藏 2026-06-16 10:28:48 +08:00
mac
386f780d00 v1.3.8 — 任务行始终渲染负责人和日期 + 加emoji图标 + 提亮颜色 2026-06-16 10:26:13 +08:00
mac
dd0c7d615f v1.3.7 — 加宽任务面板到800px + 显示任务说明+负责人+截止时间 2026-06-16 10:04:34 +08:00
mac
289529dc73 v1.3.6 — 合并负责人与截止时间到同一标签显示 2026-06-16 09:44:40 +08:00
mac
19dcbdbb51 v1.3.5 — 任务行增加负责人和截止时间显示 2026-06-16 09:42:07 +08:00
mac
b1a82d27e3 v1.3.4 — 修复新增任务递归调用导致创建失败 2026-06-16 09:40:08 +08:00
mac
ac5f9f2de9 v1.3.3 — 任务浮层新增统一「新增任务」按钮+表单弹窗 2026-06-16 09:14:38 +08:00
mac
a506b52506 v1.3.2 — 新增按钮移到右上角 + 收起表单 + 阶段筛选 2026-06-15 17:50:34 +08:00
mac
7ad363f39e v1.3.1 — 任务浮层 Plane 深色风格 + 项目去版本号 + 添加任务按钮 2026-06-15 17:33:34 +08:00
mac
938ec8d181 v1.3.0 — 重点项目简化:6列表格 + 进展按钮弹任务浮层(4阶段) 2026-06-15 12:02:27 +08:00
mac
55e7a3a4dc v1.2.1 — 修复合并时误删 renderProposals/fileGroup/fileItem 2026-06-15 11:13:46 +08:00
mac
301dfd0dfb v1.2.0 — 合并业务机会+运营为重点项目 Tab,新增项目任务时间线 2026-06-15 10:01:31 +08:00
8 changed files with 1064 additions and 114 deletions

View File

@@ -1,5 +1,10 @@
# OPC Manager Version Log
## v1.2.0 — 2026-06-15
- 业务机会 + 运营管理合并为「重点项目」Tab统一表格展示
- 新增项目任务追踪:按阶段分组展示里程碑/执行项/负责人/截止日/卡点
- 新增 `project_tasks` 表,抽屉内展示项目时间线
## v1.1.0 — 2026-06-15
- 首页指标升级:增加已签约合同总额、合同流程中金额、年度/Q2 累计确收、年度/Q2 累计毛利、已签约未执行
- 运营表格增加「金额」列

View File

@@ -141,6 +141,19 @@ CREATE TABLE IF NOT EXISTS file_assets (
notes TEXT NOT NULL DEFAULT '',
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE IF NOT EXISTS project_tasks (
id INTEGER PRIMARY KEY AUTOINCREMENT,
project_id INTEGER NOT NULL,
phase TEXT NOT NULL DEFAULT '',
milestone TEXT NOT NULL DEFAULT '',
task TEXT NOT NULL DEFAULT '',
owner TEXT NOT NULL DEFAULT '',
due_date TEXT NOT NULL DEFAULT '',
blockers TEXT NOT NULL DEFAULT '',
notes TEXT NOT NULL DEFAULT '',
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
);
"""
)
@@ -242,6 +255,25 @@ CREATE TABLE IF NOT EXISTS file_assets (
(month, record_type, category, amount, f"{month}-01", notes),
)
# Seed project tasks for 信达科普文章项目 (project_id=1)
tasks_seed = [
("阶段1渠道与商务确认", "商务对接", "合同签订", "Anna", "2026-06-30", "法务审核中", "合同签订后开始执行"),
("阶段1渠道与商务确认", "官媒渠道确认", "沟通官媒确定", "段丽华", "2026-06-30", "官媒尽力推,以先达成合作为准", "集团支持"),
("阶段1渠道与商务确认", "官媒渠道确认", "官媒合作签约", "段丽华", "2026-06-18", "", "官媒确认细节"),
("阶段2系统与标准搭建", "系统开发上线", "音频专访系统开发上线", "戴敏/梁军营", "2026-06-18", "客户比较着急执行,需要技术的资源", ""),
("阶段2系统与标准搭建", "系统开发上线", "精品视频系统开发上线", "戴敏/梁军营", "2026-06-25", "", ""),
("阶段2系统与标准搭建", "标准与培训", "业务执行手册SOP", "胡龙飞", "2026-06-12", "", "系统开发上线"),
("阶段3人员与审核入驻", "团队组建", "医学审核人员到位", "胡龙飞", "2026-06-15", "", "审核人员招聘"),
("阶段3人员与审核入驻", "团队组建", "视频制作人员到位", "胡龙飞", "2026-06-18", "", "项目经理招聘"),
("阶段4供应链与制作", "供应商准入", "准入拍摄/剪辑/主持人", "胡龙飞/侯亚凤", "2026-06-18", "", ""),
("阶段2系统与标准搭建", "脚本生产及审核", "生产脚本", "军营", "2026-06-12", "脚本目前生产比较机械,需要提前准备", "细分标签领域完成"),
]
for phase, milestone, task, owner, due_date, blockers, notes in tasks_seed:
conn.execute(
"INSERT INTO project_tasks (project_id,phase,milestone,task,owner,due_date,blockers,notes) VALUES (?,?,?,?,?,?,?,?)",
(1, phase, milestone, task, owner, due_date, blockers, notes),
)
conn.commit()
conn.close()
@@ -284,13 +316,33 @@ def attach_common(conn, resource, items):
return items
def monthly_finance(conn):
def monthly_finance(conn, tenant="科普·无界"):
from datetime import date
today = date.today()
# 6 months: 3 before + current + 2 after
from dateutil.relativedelta import relativedelta
start = today + relativedelta(months=-3)
months = []
for i in range(6):
m = start + relativedelta(months=i)
months.append(m.strftime("%Y-%m"))
data = []
for item in rows(conn, "SELECT DISTINCT month FROM finance_records ORDER BY month"):
month = item["month"]
revenue = one(conn, "SELECT COALESCE(SUM(amount),0) AS v FROM finance_records WHERE month=? AND record_type='revenue'", (month,))["v"]
cost = one(conn, "SELECT COALESCE(SUM(amount),0) AS v FROM finance_records WHERE month=? AND record_type='cost_expense'", (month,))["v"]
data.append({"month": month, "revenue": revenue, "gross_profit": revenue - cost, "cost_expense": cost, "net_profit": revenue - cost})
for month in months:
col_month = month.replace("-", "_")
col_rev = f"rev_{col_month}"
col_gross = f"gross_{col_month}"
# Only project_finances has columns for 2026-06 through 2026-09
if month in ["2026-06", "2026-07", "2026-08", "2026-09"]:
revenue = one(conn, f"SELECT COALESCE(SUM({col_rev}),0) AS v FROM project_finances WHERE tenant=?", (tenant,))["v"]
gross = one(conn, f"SELECT COALESCE(SUM({col_gross}),0) AS v FROM project_finances WHERE tenant=?", (tenant,))["v"]
else:
revenue = 0
gross = 0
data.append({
"month": month, "revenue": revenue,
"labor": 0, "expense": 0, "purchase": 0,
"net_profit": gross,
})
return data
@@ -301,27 +353,41 @@ def index():
@app.route("/api/bootstrap")
def bootstrap():
tenant = request.args.get("tenant", "科普·无界")
conn = db()
try:
sales = attach_common(conn, "sales", rows(conn, "SELECT * FROM sales_leads ORDER BY id DESC"))
proposals = attach_common(conn, "proposals", rows(conn, "SELECT * FROM business_proposals ORDER BY id DESC"))
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")
def q(sql, *args):
return rows(conn, sql, args)
sales = attach_common(conn, "sales", q("SELECT * FROM sales_leads WHERE tenant=? ORDER BY id DESC", tenant))
proposals = attach_common(conn, "proposals", q("SELECT * FROM business_proposals WHERE tenant=? ORDER BY id DESC", tenant))
operations = attach_common(conn, "operations", q("SELECT * FROM operation_projects WHERE tenant=? ORDER BY id DESC", tenant))
products = attach_common(conn, "products", q("SELECT * FROM product_versions WHERE tenant=? ORDER BY id DESC", tenant))
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)
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
# Finance aggregates — from project_finances (project-based)
def pf_sum(field):
return sum(x[field] or 0 for x in pfs)
rev_month = pf_sum("rev_2026_06")
gross_month = pf_sum("gross_2026_06")
rev_q2 = pf_sum("rev_2026_06")
gross_q2 = pf_sum("gross_2026_06")
rev_annual = rev_q2
gross_annual = gross_q2
# Contract aggregates — time-based
signed_amount = sum(x["expected_contract_amount"] or 0 for x in operations if x["project_status"] == "已签约")
from datetime import date
today = date.today()
def contract_in_period(op, start, end):
if op["project_status"] != "已签约": return False
try:
d = date.fromisoformat(op["created_at"][:10])
return start <= d <= end
except: return False
signed_annual = sum(x["expected_contract_amount"] or 0 for x in operations if contract_in_period(x, date(2026,1,1), date(2026,12,31)))
signed_q2 = sum(x["expected_contract_amount"] or 0 for x in operations if contract_in_period(x, date(2026,4,1), date(2026,6,30)))
signed_month = sum(x["expected_contract_amount"] or 0 for x in operations if contract_in_period(x, date(2026,6,1), date(2026,6,30)))
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 = {
@@ -331,32 +397,41 @@ 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_month,
"monthly_net_profit": revenue_month - cost_month,
"monthly_revenue": rev_month,
"monthly_net_profit": gross_month,
"monthly_gross": gross_month,
"upcoming_products": len([x for x in products if x["status"] in ["规划中", "设计中", "开发中", "测试中"]]),
"total_projects": len(operations),
"total_proposals": len(proposals),
"total_products": len(products),
# Extended finance metrics
"signed_amount": signed_amount,
"signed_annual": signed_annual,
"signed_q2": signed_q2,
"signed_month": signed_month,
"pipeline_amount": pipeline_amount,
"revenue_annual": revenue_annual,
"revenue_q2": revenue_q2,
"gross_annual": revenue_annual - cost_annual,
"gross_q2": revenue_q2 - cost_q2,
"revenue_annual": rev_annual,
"revenue_q2": rev_q2,
"gross_annual": gross_annual,
"gross_q2": gross_q2,
"signed_not_executed": signed_not_executed,
},
"recent": rows(conn, "SELECT * FROM follow_up_records ORDER BY id DESC LIMIT 8"),
"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, "financeMonthly": monthly_finance(conn)})
return jsonify({"summary": summary, "sales": sales, "proposals": proposals, "operations": operations, "products": products, "finance": finance, "projectFinances": pfs, "financeMonthly": monthly_finance(conn, tenant), "tasks": tasks, "tenant": tenant, "tenants": ["科普·无界","科研·无界","医患·无界"]})
finally:
conn.close()
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", "platform", "notes"]),
"finance": ("finance_records", ["month", "project_name", "record_type", "category", "amount", "occurred_date", "notes"]),
"sales": ("sales_leads", ["target_customer", "priority", "status", "tenant"]),
"proposals": ("business_proposals", ["customer_or_project_name", "version", "description", "status", "created_date", "tenant"]),
"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", "tenant"]),
"products": ("product_versions", ["product_name", "version", "version_goal", "feature_list", "launch_date", "status", "platform", "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", "tenant"]),
"projectFinances": ("project_finances", ["project_id", "tenant", "business_type", "customer_name", "sign_amount", "sign_month", "status", "sales_person", "rev_2026_06", "rev_2026_07", "rev_2026_08", "rev_2026_09", "gross_2026_06", "gross_2026_07", "gross_2026_08", "gross_2026_09"]),
}
@@ -439,6 +514,19 @@ def delete_followup(followup_id):
conn.close()
@app.route("/api/tasks/batch-sort", methods=["POST"])
def batch_sort_tasks():
conn = db()
try:
items = request.get_json(force=True).get("items", [])
for item in items:
conn.execute("UPDATE project_tasks SET sort_order=? WHERE id=?", (item["sort_order"], item["id"]))
conn.commit()
return jsonify({"ok": True})
finally:
conn.close()
@app.route("/api/files/upload", methods=["POST"])
def upload_file():
file = request.files["file"]

View File

@@ -1 +1,2 @@
Flask==3.0.3
python-dateutil==2.9.0

View File

@@ -65,3 +65,89 @@
| v0.9 原始 PRD | `docs/prd-history/OPC管理系统PRD-V0.9.md` |
| v1.0 当前 PRD | `OPC管理系统PRD.md`(根目录) |
| 修改日志(本文件) | `docs/prd/CHANGELOG.md` |
---
## v1.0 → v2.02026-06-16
### 版本升级
- PRD 匹配 OPC-Manager v1.7.6 代码实现
- 新增 `OPC管理系统PRD-V2.0.md`
### 架构级变更
| 模块 | v1.0 | v2.0 | 原因 |
|------|------|------|------|
| 销售管理 + 运营管理 | 两个独立 Tab | 合并为「重点项目」Tab | 业务机会到执行是同一项目的不同阶段 |
| 任务追踪 | 无 | 6 阶段任务体系 + project_tasks 表 | 参考科普项目 Excel 台账管理 |
| 任务详情 | 无 | 二级页面Tab 内渲染) | 替代弹窗,完整页面体验 |
| 任务编辑 | 无 | 右侧抽屉fixed 定位420px | 不打断列表浏览 |
| 首页指标 | 7 项 | 14 项(两层:经营核心 + 财务分层) | 增加合同金额、年度/Q2 财务汇总 |
### Tab 数量变更
| v1.0 | v2.0 |
|------|------|
| 首页、销售管理、业务方案、运营管理、产品研发、财务管理6 Tab | 首页、重点项目、业务方案、产品研发、财务管理5 Tab |
### 重点项目详细变更
| 项 | v1.0 | v2.0 |
|----|------|------|
| 列表列 | 项目名称/类型/状态/金额/阶段/文件/跟进7 列) | 项目/说明/阶段/金额/负责人/进展6 列) |
| 筛选按钮 | 全部/业务机会/已签约执行 | 已去除,列表不做阶段筛选 |
| 抽屉字段 | 14 个字段 | 6 个字段(名称/阶段/金额/截止/负责人/说明)+ 删除按钮 |
| 当前阶段 | 文本输入 | 6 阶段下拉框change 自动保存) |
| 阶段体系 | 无标准 | 商务洽谈→系统上线→团队分工→项目交付→上线推广→结项验收 |
| 版本号 | 项目名称含版本号 | 去除,仅保留项目名称 |
### 新增数据表
**project_tasks**
| 字段 | 类型 | 说明 |
|------|------|------|
| project_id | INTEGER | 关联 operation_projects |
| phase | TEXT | 6 阶段之一 |
| milestone | TEXT | 里程碑 |
| task | TEXT | 任务名称 |
| owner | TEXT | 负责人 |
| due_date | TEXT | 截止时间 |
| blockers | TEXT | 卡点&备注 |
| notes | TEXT | 任务说明 |
### 产品 Tab 变更
| 项 | v1.0 | v2.0 |
|----|------|------|
| 平台字段 | 无 | 新增 platform 字段(真研平台/科普平台/关爱平台) |
| 列表列 | 产品/版本/目标/功能/日期/状态6 列) | 产品/版本/目标/功能/平台/日期/状态7 列) |
### 聚合指标变更
| 指标 | v1.0 | v2.0 |
|------|------|------|
| P0 客户数 | ✓ | ✓ |
| 跟进中销售机会 | ✓ | ✓ |
| 已签约执行项目 | ✓ | ✓ |
| 有风险项目 | ✓ | ✓ |
| 本月收入 | ✓ | ✓ |
| 本月净利 | ✓ | ✓ |
| 即将上线版本 | ✓ | ✓ |
| 已签约未执行金额 | — | ✓ 新增 |
| 已签约合同总额 | — | ✓ 新增 |
| 合同流程中金额 | — | ✓ 新增 |
| 年度累计确收 | — | ✓ 新增 |
| Q2 累计确收 | — | ✓ 新增 |
| 年度累计毛利 | — | ✓ 新增 |
| Q2 累计毛利 | — | ✓ 新增 |
### 技术实现变更
| 项 | v1.0 | v2.0 |
|----|------|------|
| 前端交互 | 弹窗 modal | Tab 内二级页面state.projectView |
| 任务编辑 | 无 | fixed 抽屉 + submitTaskForm/openTaskForm |
| 自动保存 | blur 事件 | blurinput+ changeselect |
| Lucide 刷新 | render() 统一调用 | 各 render 函数独立调用 createIcons() |

View File

@@ -0,0 +1,338 @@
# OPC 管理系统 PRD
版本v2.0
日期2026-06-16
阶段:当前落地版(匹配 OPC-Manager v1.7.6 代码实现)
定位:以科普(慰心斋)为单项目独立版本,打造 OPC 工作台,从全局首页、重点项目、业务方案、产品研发、财务管理 5 个视角,直观、清晰、全面地管理业务全貌。
> 历史版本参见 `OPC管理系统PRD-V1.0.md`、`OPC管理系统PRD-V0.9.md`,修改日志见 `CHANGELOG.md`。
---
## 1. 背景与目标
### 1.1 需求原文
以慰心斋为例,打造一个 OPC 工作台,让我能够直观地看到他销售、业务、运营、产品、财务的情况。另外,之前他为自己单独打造了一个财务体系,把这个财务 manager 系统直接合并进工作台里面,不再作为一个独立的系统。
### 1.2 背景与 v2.0 核心变更
v1.0 的 6 Tab 架构(销售管理 + 业务方案 + 运营管理 + 产品研发 + 财务管理 + 首页)在实际使用中暴露出销售与运营割裂的问题——业务机会和签约执行项目本质上是同一项目的不同阶段,分两个 Tab 管理不自然。
v2.0 做了以下架构级调整:
1. **合并销售 + 运营为「重点项目」**:一个 Tab 管全部项目,项目表格 6 列(项目/说明/阶段/金额/负责人/进展)。
2. **引入项目任务体系**:每个项目内嵌 6 阶段任务清单(商务洽谈→系统上线→团队分工→项目交付→上线推广→结项验收),支持增删改。
3. **任务详情改为页内二级页面**:点击「查看」进入项目任务页,有返回按钮,不弹出独立窗口。
4. **任务编辑改为右侧抽屉**:新增/编辑任务从右侧滑入表单,不打断任务列表浏览。
5. **首页指标分层**:从 7 项扩展到 14 项,分为经营核心层和财务分层。
6. **产品增加平台分类**:真研平台/科普平台/关爱平台三种归属。
本系统将承接并合并原有独立财务 manager 能力,财务不再作为单独系统存在,而是作为 OPC 管理系统中的一个 Tab。
### 1.3 样板范围
v2.0 以科普(慰心斋)作为首个单项目独立版本,当前包含信达·科普无界、圆心科技科普文章等多个重点项目。
首版只做单项目、单用户版本,不做多项目、多用户、权限体系。
---
## 2. 信息架构
系统顶部为全局标题和基础操作区,主体为 5 个一级 Tab
1. **首页** — 经营总览14 项指标 + 财务趋势 + 风险提醒 + 近期动态)
2. **重点项目** — 项目列表 + 点击进入任务清单6 阶段任务管理)
3. **业务方案** — 按版本管理方案/成本/SOP/财务流程文件
4. **产品研发** — 按版本管理产品目标/功能/日期(含平台分类)
5. **财务管理** — 趋势图 + 明细表(收入/成本/毛利/净利)
---
## 3. 功能需求
### 3.1 首页 Tab
首页是科普(慰心斋)单项目的经营总览页。
#### 3.1.1 关键指标14 项,两组 4 列网格)
**第一组 — 经营核心层8 项):**
- P0 客户数
- 跟进中销售机会数
- 已签约执行项目数
- 有风险项目数
- 本月收入
- 本月净利
- 即将上线产品版本数
- 已签约未执行金额
**第二组 — 财务分层6 项):**
- 已签约合同总额
- 合同流程中金额
- 年度累计确收
- Q2 累计确收
- 年度累计毛利
- Q2 累计毛利
> 以上指标由后端在 `/api/bootstrap` 中聚合计算(年度=2026年1-6月Q2=2026年4-6月。金钱单位统一为万元。
#### 3.1.2 财务趋势图
- 首页展示收入/成本月度折线图Chart.js固定高度 140px
- 财务 Tab 独立展示 4 条曲线(收入/毛利/成本/净利)。
#### 3.1.3 风险提醒与近期动态
- 风险提醒:从运营项目提取 next_action 非空的项目,最多展示 5 条。
- 近期动态:最近 8 条跟进记录时间线。
---
### 3.2 重点项目 Tab
> **v2.0 核心模块**,合并 v1.0 的「销售管理」和「运营管理」两个 Tab。
#### 3.2.1 项目列表
| 列 | 说明 |
|----|------|
| 项目 | 项目名称 |
| 项目说明 | customer_need 或 notes 字段 |
| 当前阶段 | 6 阶段之一badge 样式) |
| 项目金额 | expected_contract_amount万元 |
| 负责人 | owner |
| 进展 | 「查看」按钮,点击进入任务清单页 |
- 右上角「新增项目」按钮,点击展开创建表单。
- 表单字段:项目名称、当前阶段(下拉)、项目金额、负责人。
- 点击表格行打开右侧抽屉720px展示项目详情和评论区。
- 抽屉内新增「删除」按钮(红色,点击 confirm 确认后删除)。
#### 3.2.2 项目抽屉(详情)
6 个字段(失焦自动保存):
| 字段 | 类型 | 说明 |
|------|------|------|
| 项目名称 | text | project_name |
| 当前阶段 | select | 6 阶段下拉change 自动保存 |
| 截止时间 | text | expected_sign_date |
| 金额 | text | expected_contract_amount |
| 负责人 | text | owner |
| 项目说明 | textarea | notes多行文本 |
- 评论区保留,使用 Squire 富文本编辑器。
#### 3.2.3 任务清单页(二级页面)
点击「查看」进入项目任务清单页,在重点项目 Tab 内渲染:
- 顶部:「← 返回项目列表」按钮(左)+ 项目名(中)+「新增任务」按钮(右)
- 主体:按 6 阶段分组的任务卡片,空阶段自动隐藏
- 任务行格式:`○ 任务名 任务说明 | 负责人 截止时间`
- 卡点以红色 `⚠` 标记显示
#### 3.2.4 6 阶段体系
| 阶段 | 含义 |
|------|------|
| 商务洽谈 | 合同签订、渠道对接、接口推流等前期商务工作 |
| 系统上线 | 系统开发、SOP 制定、脚本生产等平台搭建 |
| 团队分工 | 人员招聘、审核人员到位等团队组建 |
| 项目交付 | 供应商准入、拍摄制作等执行交付 |
| 上线推广 | 项目启动上线、渠道全面推广 |
| 结项验收 | 客户验收、尾款结算等收尾工作 |
#### 3.2.5 任务编辑抽屉
- 点击任务行或「新增任务」→ 右侧抽屉滑入fixed 定位,始终可见)
- 表单字段:任务名称、任务阶段(下拉)、负责人、截止时间、任务说明、卡点&备注
- 新增时标题「新增任务」,编辑时「编辑任务」
- 提交后抽屉关闭,列表刷新
#### 3.2.6 数据模型
**project_tasks 表:**
| 字段 | 说明 |
|------|------|
| id | 主键 |
| project_id | 关联 operation_projects.id |
| phase | 阶段(商务洽谈/系统上线/团队分工/项目交付/上线推广/结项验收) |
| milestone | 里程碑 |
| task | 任务名称 |
| owner | 负责人 |
| due_date | 截止时间 |
| blockers | 卡点&备注 |
| notes | 任务说明 |
| created_at / updated_at | 时间戳 |
---
### 3.3 业务方案 Tab
与 v1.0 保持一致:
- 表格:客户/项目名称、版本号、状态、文件数
- 抽屉:属性(可编辑)+ 4 组文件(方案/成本/SOP/财务流程)
- 文件支持上传、预览、下载、删除
- 评论区支持 Squire 富文本
---
### 3.4 产品研发 Tab
与 v1.0 保持一致,增加平台分类:
- 表格:产品名称、版本号、版本目标、核心功能、平台、上线日期、状态
- 抽屉:可编辑版本详情 + 评论区
- 平台字段:下拉选择(真研平台/科普平台/关爱平台)
---
### 3.5 财务管理 Tab
与 v1.0 保持一致:
- 趋势图:收入/毛利/成本/净利 4 条月度曲线Chart.js
- 明细表:支持录入/编辑收入、成本/费用明细
- 月份格式 YYYY-MM
- 净利 = 收入 - 成本/费用
---
## 4. 数据对象
### 4.1 SalesLead销售线索
仍保留数据库表和 API但前端不再有独立 Tab。通过重点项目页可间接查看。
### 4.2 OperationProject运营项目
- id, project_name, project_version
- project_typeopportunity / execution现主要用于区分链路前端不做筛选
- current_stage6 阶段之一)
- owner, expected_contract_amount, expected_sign_date
- customer_need, notes
- project_status保留兼容不作为主要显示字段
- created_at, updated_at
### 4.3 ProjectTask项目任务—— v2.0 新增
- id, project_id
- phase, milestone, task
- owner, due_date
- blockers, notes
- created_at, updated_at
### 4.4 其他数据对象
BusinessProposal、ProductVersion、FinanceRecord、FileAsset、FollowUpRecord 与 v1.0 一致,详见 `OPC管理系统PRD-V1.0.md` 第 5 章。
---
## 5. 页面与交互规范
### 5.1 通用能力
- 所有列表支持新增(内联表单或右上角按钮)。
- 项目详情通过 720px 右侧抽屉展示和编辑。
- 任务清单在 Tab 内作为二级页面渲染,不弹出独立窗口。
- 任务编辑通过右侧抽屉420pxfixed 定位)。
- 字段失焦自动保存input/textarea → blurselect → change
- 评论区使用 Squire 富文本,支持 HTML 格式。
- 点击表格行打开抽屉,不需要单独的「详情」按钮。
### 5.2 抽屉交互
- 项目抽屉宽度 720px任务抽屉宽度 420px。
- 字段默认透明背景、hover 显示边框、focus 蓝色边框。
- 字段失焦/选择自动保存,保存状态有视觉反馈。
- 抽屉右上角关闭按钮关闭,项目抽屉额外有「删除」按钮。
- 评论提交后抽屉保持打开。
### 5.3 任务清单页交互
- 进入:点击项目行的「查看」按钮 → state.projectView = projectId → 刷新 Tab 内容。
- 退出:点击「返回项目列表」→ state.projectView = null → 回到列表。
- 工具栏与下方卡片使用相同的 20px 左右内边距px-5
- 空阶段分组不渲染(直接跳过)。
- 点击任务行打开编辑抽屉;点击「新增任务」打开空白新增抽屉。
- Lucide 图标在每次渲染后调用 `createIcons()` 刷新。
### 5.4 评论区
与 v1.0 一致,详见 `OPC管理系统PRD-V1.0.md` 第 6.4 节。
---
## 6. 技术栈与实现约束
与 v1.0 一致,核心为:
- **前端**Jinja2 + Tailwind CSS CDN + Vanilla JS + Chart.js + Lucide + Squire
- **后端**Flask + sqlite3无 ORM+ SQLite
- **单服务**Flask dev server, 端口 5177
- **不提交** `data/opc.sqlite`
详见 `OPC管理系统PRD-V1.0.md` 第 7 章。
**v2.0 新增数据表**`project_tasks`
---
## 7. 首页指标要求
v2.0 首页展示 14 项关键指标(两组 4 列网格):
**经营核心层:**
- P0 客户数、跟进中销售机会数、已签约执行项目数、有风险项目数
- 本月收入、本月净利、即将上线产品版本数、已签约未执行金额
**财务分层:**
- 已签约合同总额、合同流程中金额
- 年度累计确收、Q2 累计确收
- 年度累计毛利、Q2 累计毛利
---
## 8. 验收标准
### 首页
- 展示 14 项指标(两组 4 列网格)。
- 展示财务趋势图、风险提醒和近期动态。
- 点击指标可跳转到对应 Tab。
### 重点项目
- 项目列表 6 列展示(项目/说明/阶段/金额/负责人/进展)。
- 右上角「新增项目」展开表单。
- 点击行打开抽屉6 字段 + 评论 + 删除按钮)。
- 点击「查看」进入二级任务清单页。
- 任务清单按 6 阶段分组,空阶段隐藏。
- 任务行显示任务名、说明、负责人、截止时间、卡点。
- 点击任务行打开右侧编辑抽屉。
- 「新增任务」打开空白新增抽屉。
- 「返回项目列表」回到列表页。
- 任务保存后列表刷新、抽屉关闭。
### 业务方案、产品研发、财务管理
与 v1.0 验收标准一致,详见 `OPC管理系统PRD-V1.0.md` 第 11 章。
---
## 9. 版本历史
| 版本 | 日期 | 说明 |
|------|------|------|
| v0.9 | 2026-05-29 | 初始 PRD6 Tab 功能架构 |
| v1.0 | 2026-06-01 | 匹配 v1.0.2,卡片→表格,补充技术栈与交互细节 |
| v2.0 | 2026-06-16 | 匹配 v1.7.6,销售+运营合并为重点项目、6 阶段任务体系、二级页面、任务编辑抽屉、首页指标分层、产品平台分类 |
详细修改日志见 `CHANGELOG.md`

File diff suppressed because one or more lines are too long

View File

@@ -489,3 +489,96 @@ td {
color: #64748b;
margin: 4px 0;
}
/* Task Modal — Plane style */
.task-modal { display: none; }
.task-modal.active { display: block; }
.task-overlay {
position: fixed; inset: 0; background: rgba(15,23,42,0.35); z-index: 200;
display: flex; align-items: flex-start; justify-content: center;
padding-top: 48px; overflow-y: auto;
}
.task-panel {
background: #fff; border-radius: 12px; width: 1000px; max-width: 96vw;
box-shadow: 0 20px 60px rgba(0,0,0,0.12); margin-bottom: 48px;
overflow: hidden;
}
.task-header {
display: flex; align-items: center; justify-content: space-between;
padding: 16px 20px; border-bottom: 1px solid #e2e8f0;
}
.task-title { color: #1e293b; font-size: 15px; font-weight: 600; }
.task-close {
color: #94a3b8; background: none; border: none; cursor: pointer;
padding: 4px; border-radius: 6px; display: flex;
}
.task-close:hover { color: #475569; background: #f1f5f9; }
.task-body-wrap, .task-page-wrap { position: relative; overflow: hidden; }
.task-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; transition: margin-right 0.25s ease; }
.task-drawer {
position: fixed; top: 0; right: 0; width: 420px; height: 100vh;
background: #fff; border-left: 1px solid #e2e8f0;
transform: translateX(100%); transition: transform 0.25s ease;
z-index: 300; display: flex; flex-direction: column;
}
.task-drawer.open { transform: translateX(0); }
.task-drawer-hd {
display: flex; align-items: center; justify-content: space-between;
padding: 14px 20px; border-bottom: 1px solid #e2e8f0;
}
.task-drawer-title { font-size: 15px; font-weight: 600; color: #1e293b; }
.task-drawer-form { padding: 16px 20px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.task-group {
background: #fff; border-radius: 8px;
border: 1px solid #e2e8f0; overflow: hidden;
}
.task-group-hd {
display: flex; align-items: center; gap: 8px;
padding: 10px 16px; background: #f8fafc;
}
.task-group-icon { color: #64748b; display: flex; }
.task-group-label { color: #334155; font-size: 13px; font-weight: 600; }
.task-group-n {
background: #e2e8f0; color: #64748b; font-size: 11px;
padding: 1px 7px; border-radius: 10px;
}
.task-group-list { display: flex; flex-direction: column; }
.task-group-list.drag-over { background: #f0f9ff; }
.task-row {
display: flex; align-items: center; gap: 16px;
padding: 10px 16px; border-top: 1px solid #f1f5f9;
cursor: pointer; transition: background 0.15s;
}
.task-row.dragging { opacity: 0.4; background: #f1f5f9; }
.task-row.task-done .task-name { text-decoration: line-through; color: #94a3b8; }
.task-row:hover { background: #f8fafc; }
.task-dot { display: flex; color: #cbd5e1; flex-shrink: 0; cursor: pointer; }
.task-dot:hover { color: #6366f1; }
.task-grip { display: flex; color: #cbd5e1; flex-shrink: 0; cursor: grab; }
.task-grip:hover { color: #94a3b8; }
.task-grip:active { cursor: grabbing; }
.task-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.task-name { color: #1e293b; font-size: 13px; }
.task-desc { color: #94a3b8; font-size: 12px; word-wrap: break-word; overflow-wrap: break-word; }
.task-blocker { color: #dc2626; font-size: 12px; word-wrap: break-word; overflow-wrap: break-word; }
.task-col { color: #64748b; font-size: 12px; white-space: nowrap; width: 100px; text-align: right; }
.task-col-badge { color: #64748b; font-size: 12px; white-space: nowrap; width: 90px; text-align: right; }
.task-none { color: #94a3b8; font-size: 13px; padding: 12px 14px; text-align: center; border-top: 1px solid #f1f5f9; }
.task-form {
background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
padding: 14px; margin-bottom: 16px;
}
.task-field { display: flex; flex-direction: column; gap: 4px; }
.task-field span { color: #64748b; font-size: 12px; }
.task-field input, .task-field select, .task-field textarea {
background: #fff; border: 1px solid #e2e8f0; border-radius: 6px;
color: #1e293b; font-size: 13px; padding: 6px 10px; outline: none;
}
.task-field input:focus, .task-field select:focus, .task-field textarea:focus { border-color: #2563eb; }
.col-span-2 { grid-column: span 2; }
.task-group-add {
display: block; width: 100%; padding: 10px; text-align: center;
color: #6b6d75; font-size: 13px; background: none; border: none;
border-top: 1px solid #24272d; cursor: pointer;
}
.task-group-add:hover { color: #e4e5e7; background: #24272d; }

View File

@@ -27,32 +27,40 @@
</head>
<body class="min-h-screen bg-slate-50 text-slate-950">
<header class="topbar border-b border-slate-200 bg-white px-8 py-5">
<div>
<p class="eyebrow text-xs font-semibold uppercase tracking-[0.18em] text-blue-700">OPC Manager · 单用户 · 单项目</p>
<h1 class="mt-1 text-2xl font-semibold">科普慰心斋OPC 工作台</h1>
<div class="flex items-center gap-3">
<div>
<p class="eyebrow text-xs font-semibold uppercase tracking-[0.18em] text-blue-700">OPC Manager</p>
<div class="flex items-center gap-3 mt-1">
<h1 class="text-2xl font-semibold" id="workspaceTitle">科普 OPC 工作台</h1>
<select id="tenantSelect" class="rounded-md border border-slate-200 bg-white px-3 py-1.5 text-sm font-medium text-slate-700 outline-none focus:border-blue-500" onchange="switchTenant(this.value)">
<option value="科普·无界">科普·无界</option>
<option value="科研·无界">科研·无界</option>
<option value="医患·无界">医患·无界</option>
</select>
</div>
</div>
</div>
<button id="refreshBtn" class="rounded-md border border-slate-200 bg-white px-3 py-2 text-sm font-medium hover:bg-slate-50" type="button"><i data-lucide="refresh-cw"></i>刷新</button>
</header>
<nav class="tabs border-b border-slate-200 bg-white px-8" id="tabs">
<button class="active" data-tab="home"><i data-lucide="home"></i>首页</button>
<button data-tab="sales"><i data-lucide="briefcase-business"></i>业务机会</button>
<button data-tab="projects"><i data-lucide="briefcase-business"></i>重点项目</button>
<button data-tab="proposals"><i data-lucide="file-text"></i>业务方案</button>
<button data-tab="operations"><i data-lucide="activity"></i>运营管理</button>
<button data-tab="products"><i data-lucide="package"></i>产品研发</button>
<button data-tab="finance"><i data-lucide="wallet-cards"></i>财务管理</button>
</nav>
<main class="px-8 py-6">
<section id="home" class="panel active"></section>
<section id="sales" class="panel"></section>
<section id="projects" class="panel"></section>
<section id="proposals" class="panel"></section>
<section id="operations" class="panel"></section>
<section id="products" class="panel"></section>
<section id="finance" class="panel"></section>
</main>
<aside id="drawer" class="drawer" aria-hidden="true"></aside>
<div id="taskModal" class="task-modal"></div>
<script src="{{ url_for('static', filename='app.js') }}"></script>
</body>
</html>