Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5061de70f8 | ||
|
|
ea3ba25da5 | ||
|
|
bd7125fab8 | ||
|
|
94dd1fe677 | ||
|
|
fa6c9b1711 | ||
|
|
f4eacfafe2 | ||
|
|
f8c816dc38 | ||
|
|
e2d9049e45 | ||
|
|
1b0049e342 | ||
|
|
87a5d4f81d | ||
|
|
d6ec7b24ec | ||
|
|
194c91cf25 | ||
|
|
68797e4fb5 | ||
|
|
af4ae1cbc3 | ||
|
|
c42abb05da | ||
|
|
4d1dc3b355 | ||
|
|
60bae583b2 | ||
|
|
c68fcaadcc | ||
|
|
2c199aae76 | ||
|
|
be6a7f5c38 | ||
|
|
6adc00a8a7 | ||
|
|
c4aacd5096 | ||
|
|
4f7db75a7f | ||
|
|
9707009895 | ||
|
|
6defe95a3f | ||
|
|
a1b154abd7 | ||
|
|
fc0ee66064 | ||
|
|
5af58c8faa | ||
|
|
b682427ea0 | ||
|
|
ec83bb5e22 | ||
|
|
921afd198b | ||
|
|
850ad340e5 | ||
|
|
cec3e3a2ad | ||
|
|
e02c0bd183 | ||
|
|
853344fb26 | ||
|
|
386f780d00 | ||
|
|
dd0c7d615f | ||
|
|
289529dc73 | ||
|
|
19dcbdbb51 | ||
|
|
b1a82d27e3 | ||
|
|
ac5f9f2de9 | ||
|
|
a506b52506 | ||
|
|
7ad363f39e | ||
|
|
938ec8d181 | ||
|
|
55e7a3a4dc | ||
|
|
301dfd0dfb | ||
|
|
9930727d14 | ||
|
|
c5180cafbd | ||
|
|
256767ff57 |
@@ -1,5 +1,29 @@
|
||||
# OPC Manager Version Log
|
||||
|
||||
## v1.2.0 — 2026-06-15
|
||||
- 业务机会 + 运营管理合并为「重点项目」Tab,统一表格展示
|
||||
- 新增项目任务追踪:按阶段分组展示里程碑/执行项/负责人/截止日/卡点
|
||||
- 新增 `project_tasks` 表,抽屉内展示项目时间线
|
||||
|
||||
## v1.1.0 — 2026-06-15
|
||||
- 首页指标升级:增加已签约合同总额、合同流程中金额、年度/Q2 累计确收、年度/Q2 累计毛利、已签约未执行
|
||||
- 运营表格增加「金额」列
|
||||
- 产品研发增加「平台」字段(真研/科普/关爱),支持平台筛选
|
||||
|
||||
## v1.0.7 — 2026-06-04
|
||||
- 修复新增表单 async 后 `event.currentTarget` 丢失导致页面不刷新(影响所有新增按钮)
|
||||
- `createResource` 改用预存 form 引用 + try/catch 错误提示
|
||||
|
||||
## v1.0.6 — 2026-06-04
|
||||
- 修复财务 Tab Chart 无限堆积:renderChartOn 缺少旧 chart 销毁 + state 跟踪
|
||||
- 财务图表容器加固定高度(300px),避免 resize 循环
|
||||
|
||||
## v1.0.5 — 2026-06-04
|
||||
- "销售管理" Tab 改为"业务机会","目标客户"字段统一改为"业务机会"
|
||||
|
||||
## v1.0.4 — 2026-06-04
|
||||
- CDN 全量本地化:Tailwind / Chart.js / Squire / Lucide 下载到 `static/vendor/`,不再依赖外部 CDN
|
||||
|
||||
## v1.0.3 — 2026-06-04
|
||||
- CDN 脚本加 `defer` + `preconnect`:解决 Chart.js / Squire / Lucide 同步加载阻塞页面渲染
|
||||
|
||||
|
||||
@@ -141,9 +141,26 @@ 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
|
||||
);
|
||||
"""
|
||||
)
|
||||
# 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 +227,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(
|
||||
@@ -238,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()
|
||||
|
||||
@@ -280,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
|
||||
|
||||
|
||||
@@ -297,16 +353,43 @@ 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")
|
||||
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")
|
||||
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 — 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 = {
|
||||
"project_name": "科普(慰心斋)",
|
||||
"metrics": {
|
||||
@@ -314,24 +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,
|
||||
"monthly_net_profit": revenue - cost,
|
||||
"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": 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", "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"]),
|
||||
}
|
||||
|
||||
|
||||
@@ -414,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"]
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
Flask==3.0.3
|
||||
python-dateutil==2.9.0
|
||||
|
||||
@@ -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.0(2026-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 事件 | blur(input)+ change(select) |
|
||||
| Lucide 刷新 | render() 统一调用 | 各 render 函数独立调用 createIcons() |
|
||||
|
||||
338
docs/prd/OPC管理系统PRD-V2.0.md
Normal file
338
docs/prd/OPC管理系统PRD-V2.0.md
Normal 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_type(opportunity / execution,现主要用于区分链路,前端不做筛选)
|
||||
- current_stage(6 阶段之一)
|
||||
- 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 内作为二级页面渲染,不弹出独立窗口。
|
||||
- 任务编辑通过右侧抽屉(420px,fixed 定位)。
|
||||
- 字段失焦自动保存(input/textarea → blur;select → 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 | 初始 PRD,6 Tab 功能架构 |
|
||||
| v1.0 | 2026-06-01 | 匹配 v1.0.2,卡片→表格,补充技术栈与交互细节 |
|
||||
| v2.0 | 2026-06-16 | 匹配 v1.7.6,销售+运营合并为重点项目、6 阶段任务体系、二级页面、任务编辑抽屉、首页指标分层、产品平台分类 |
|
||||
|
||||
详细修改日志见 `CHANGELOG.md`。
|
||||
484
static/app.js
484
static/app.js
@@ -1,8 +1,13 @@
|
||||
const state = {
|
||||
active: "home",
|
||||
data: null,
|
||||
tenant: "科普·无界",
|
||||
opFilter: "all",
|
||||
finFilter: "已签单",
|
||||
projectView: null,
|
||||
chart: null,
|
||||
chart2: null,
|
||||
productPlatform: "all",
|
||||
};
|
||||
|
||||
const money = (value) => `${Number(value || 0).toLocaleString("zh-CN")} 万`;
|
||||
@@ -45,7 +50,7 @@ function renderTable(headers, rows, rowClicks) {
|
||||
}
|
||||
|
||||
async function load() {
|
||||
state.data = await api("/api/bootstrap");
|
||||
state.data = await api(`/api/bootstrap?tenant=${encodeURIComponent(state.tenant)}`);
|
||||
render();
|
||||
}
|
||||
|
||||
@@ -59,9 +64,8 @@ function switchTab(tab) {
|
||||
function render() {
|
||||
if (!state.data) return;
|
||||
renderHome();
|
||||
renderSales();
|
||||
renderProjects();
|
||||
renderProposals();
|
||||
renderOperations();
|
||||
renderProducts();
|
||||
renderFinance();
|
||||
if (window.lucide) window.lucide.createIcons();
|
||||
@@ -92,19 +96,38 @@ function render() {
|
||||
function renderHome() {
|
||||
const { summary, financeMonthly } = state.data;
|
||||
const m = summary.metrics;
|
||||
const rows1 = [
|
||||
["年度累计签约", money(m.signed_annual || m.signed_amount)],
|
||||
["Q2 累计签约", money(m.signed_q2 || 0)],
|
||||
["本月新增签约", money(m.signed_month || 0)],
|
||||
["合同流程中", money(m.pipeline_amount)],
|
||||
];
|
||||
const rows2 = [
|
||||
["年度累计确收", money(m.revenue_annual)],
|
||||
["Q2 累计确收", money(m.revenue_q2)],
|
||||
["本月新增确收", money(m.monthly_revenue)],
|
||||
["已签约未执行", money(m.signed_not_executed)],
|
||||
];
|
||||
const rows3 = [
|
||||
["年度累计毛利", money(m.gross_annual)],
|
||||
["Q2 累计毛利", money(m.gross_q2)],
|
||||
["本月新增毛利", money(m.monthly_net_profit)],
|
||||
["合同毛利率", m.revenue_annual ? Math.round(m.gross_annual / m.revenue_annual * 100) + "%" : "—"],
|
||||
];
|
||||
const tblCard = (title, rows) => card(`<h3 class="text-sm font-bold text-slate-700 mb-3">${title}</h3><table class="w-full text-sm"><tbody>${rows.map(([label, value]) => `<tr class="border-b border-slate-100 last:border-0"><td class="py-2 pr-4 text-slate-500">${label}</td><td class="py-2 text-right font-semibold text-slate-800">${value}</td></tr>`).join("")}</tbody></table>`, "p-4");
|
||||
document.querySelector("#home").innerHTML = `
|
||||
<div class="grid gap-5">
|
||||
<div class="grid grid-cols-4 gap-3">
|
||||
<div class="grid grid-cols-6 gap-3">
|
||||
${[
|
||||
["P0 客户数", m.p0_customers, "sales"],
|
||||
["跟进中销售机会", m.active_sales, "sales"],
|
||||
["已签约执行项目", m.execution_projects, "operations"],
|
||||
["有风险项目", m.risk_projects, "operations"],
|
||||
["本月收入", money(m.monthly_revenue), "finance"],
|
||||
["重点项目", m.total_projects, "projects"],
|
||||
["业务方案", m.total_proposals, "proposals"],
|
||||
["产品版本", m.total_products, "products"],
|
||||
["本月确收", money(m.monthly_revenue), "finance"],
|
||||
["本月毛利", money(m.monthly_gross || m.monthly_net_profit), "finance"],
|
||||
["本月净利", money(m.monthly_net_profit), "finance"],
|
||||
["即将上线版本", m.upcoming_products, "products"],
|
||||
].map(([label, value, tab]) => `<button class="metric-card" onclick="switchTab('${tab}')"><span class="flex items-center gap-2 text-xs text-slate-500"><i data-lucide="gauge"></i>${label}</span><strong class="mt-2 block text-2xl">${value}</strong></button>`).join("")}
|
||||
</div>
|
||||
<div class="grid grid-cols-3 gap-5">${tblCard("合同金额", rows1)}${tblCard("确收金额", rows2)}${tblCard("确收毛利", rows3)}</div>
|
||||
<div class="grid grid-cols-2 gap-5">
|
||||
${card(`<div class="mb-3 flex items-center justify-between"><h2 class="text-sm font-bold text-slate-600">财务趋势</h2>${badge("YYYY-MM")}</div><div style="position:relative;height:140px"><canvas id="financeChart"></canvas></div>`, "p-4")}
|
||||
${card(`<h2 class="text-lg font-bold">风险提醒</h2><div class="mt-3 grid gap-2">${(summary.risks.length ? summary.risks : [{ title: "暂无高风险", content: "当前无明确阻塞,按周更新即可。" }]).map((r) => `<div class="rounded-md border border-amber-200 bg-amber-50 p-3"><p class="font-bold text-amber-900">${r.title}</p><p class="mt-1 text-sm text-amber-800 break-words">${r.content}</p></div>`).join("")}</div>`, "p-5")}
|
||||
@@ -143,34 +166,216 @@ function formHtml(fields, button) {
|
||||
|
||||
async function createResource(event, resource) {
|
||||
event.preventDefault();
|
||||
const data = Object.fromEntries(new FormData(event.currentTarget).entries());
|
||||
await api(`/api/${resource}`, { method: "POST", body: JSON.stringify({ data }) });
|
||||
event.currentTarget.reset();
|
||||
await load();
|
||||
const form = event.currentTarget;
|
||||
const data = Object.fromEntries(new FormData(form).entries());
|
||||
try {
|
||||
await api(`/api/${resource}`, { method: "POST", body: JSON.stringify({ data }) });
|
||||
form.reset();
|
||||
await load();
|
||||
} catch (error) {
|
||||
alert("创建失败:" + error.message);
|
||||
}
|
||||
}
|
||||
|
||||
window.createSales = (event) => createResource(event, "sales");
|
||||
window.createProposal = (event) => createResource(event, "proposals");
|
||||
window.createOperation = (event) => createResource(event, "operations");
|
||||
window.createProduct = (event) => createResource(event, "products");
|
||||
window.createFinance = (event) => createResource(event, "finance");
|
||||
window.switchTab = switchTab;
|
||||
|
||||
function renderSales() {
|
||||
const rows = state.data.sales.map((x) => [x.target_customer, badge(x.priority), badge(x.status), text(x.latest_follow_up_record)]);
|
||||
const salesClicks = state.data.sales.map((x) => ({ resource: "sales", id: x.id }));
|
||||
document.querySelector("#sales").innerHTML = `<div class="grid gap-4">
|
||||
${card(formHtml([
|
||||
{ label: "目标客户", input: `<input name="target_customer" required placeholder="客户名称">` },
|
||||
{ label: "优先级", input: `<select name="priority"><option>P0</option><option selected>P1</option><option>P2</option><option>P3</option></select>` },
|
||||
{ label: "状态", input: `<select name="status"><option>待跟进</option><option>跟进中</option><option>方案中</option><option>商务谈判</option><option>已签约</option><option>暂缓</option><option>已丢单</option></select>` },
|
||||
], { handler: "createSales", text: `<i data-lucide="plus"></i>新增客户` }), "p-4")}
|
||||
${renderTable(["目标客户", "优先级", "状态", "最新跟进记录"], rows, salesClicks)}
|
||||
window.openTaskForm = (projectId, taskId) => {
|
||||
const drawer = document.querySelector(`#task-drawer-${projectId}`);
|
||||
const titleEl = drawer.querySelector(".task-drawer-title");
|
||||
if (taskId === null) {
|
||||
document.querySelector(`#task-id-${projectId}`).value = "";
|
||||
document.querySelector(`#task-name-${projectId}`).value = "";
|
||||
document.querySelector(`#task-phase-${projectId}`).value = "商务洽谈";
|
||||
document.querySelector(`#task-owner-${projectId}`).value = "";
|
||||
document.querySelector(`#task-due-${projectId}`).value = "";
|
||||
document.querySelector(`#task-notes-${projectId}`).value = "";
|
||||
document.querySelector(`#task-blockers-${projectId}`).value = "";
|
||||
document.querySelector(`#task-submit-btn-${projectId}`).textContent = "确认新增";
|
||||
if (titleEl) titleEl.textContent = "新增任务";
|
||||
} else {
|
||||
const task = (state.data.tasks || []).find((t) => t.id === taskId);
|
||||
if (!task) return;
|
||||
document.querySelector(`#task-id-${projectId}`).value = task.id;
|
||||
document.querySelector(`#task-name-${projectId}`).value = task.task || "";
|
||||
document.querySelector(`#task-phase-${projectId}`).value = task.phase || "商务洽谈";
|
||||
document.querySelector(`#task-owner-${projectId}`).value = task.owner || "";
|
||||
document.querySelector(`#task-due-${projectId}`).value = task.due_date || "";
|
||||
document.querySelector(`#task-notes-${projectId}`).value = task.notes || "";
|
||||
document.querySelector(`#task-blockers-${projectId}`).value = task.blockers || "";
|
||||
document.querySelector(`#task-submit-btn-${projectId}`).textContent = "保存修改";
|
||||
if (titleEl) titleEl.textContent = "编辑任务";
|
||||
}
|
||||
drawer.classList.add("open");
|
||||
};
|
||||
window.closeTaskDrawer = (projectId) => {
|
||||
document.querySelector(`#task-drawer-${projectId}`).classList.remove("open");
|
||||
};
|
||||
|
||||
window.submitTaskForm = async (event, projectId) => {
|
||||
event.preventDefault();
|
||||
const data = Object.fromEntries(new FormData(event.currentTarget).entries());
|
||||
data.project_id = Number(projectId);
|
||||
const taskId = data.task_id;
|
||||
delete data.task_id;
|
||||
try {
|
||||
if (taskId) {
|
||||
await api(`/api/tasks/${taskId}`, { method: "PUT", body: JSON.stringify({ data }) });
|
||||
} else {
|
||||
await api("/api/tasks", { method: "POST", body: JSON.stringify({ data }) });
|
||||
}
|
||||
await load();
|
||||
} catch (error) {
|
||||
alert("保存失败:" + error.message);
|
||||
}
|
||||
};
|
||||
window.createFinance = async (event) => {
|
||||
event.preventDefault();
|
||||
const form = event.currentTarget;
|
||||
const data = Object.fromEntries(new FormData(form).entries());
|
||||
data.tenant = state.tenant;
|
||||
data.sign_amount = parseFloat(data.sign_amount) || 0;
|
||||
for (const m of ["2026-06","2026-07","2026-08","2026-09"]) {
|
||||
const k = m.replace("-","_");
|
||||
data["rev_"+k] = parseFloat(data["rev_"+k]) || 0;
|
||||
data["gross_"+k] = parseFloat(data["gross_"+k]) || 0;
|
||||
}
|
||||
const pfId = data.pf_id;
|
||||
delete data.pf_id;
|
||||
try {
|
||||
if (pfId) {
|
||||
await api("/api/projectFinances/" + pfId, { method: "PUT", body: JSON.stringify({ data }) });
|
||||
} else {
|
||||
await api("/api/projectFinances", { method: "POST", body: JSON.stringify({ data }) });
|
||||
}
|
||||
form.reset();
|
||||
document.querySelector("#pf-id-input").value = "";
|
||||
document.querySelector("#financeModalTitle").textContent = "新增项目财务";
|
||||
closeFinanceModal();
|
||||
await load();
|
||||
} catch (error) {
|
||||
alert("保存失败:" + error.message);
|
||||
}
|
||||
};
|
||||
window.switchTab = switchTab;
|
||||
window.switchTenant = (tenant) => {
|
||||
state.tenant = tenant;
|
||||
state.projectView = null;
|
||||
const label = tenant.replace("·无界", "");
|
||||
document.querySelector("#workspaceTitle").textContent = label + " OPC 工作台";
|
||||
load();
|
||||
};
|
||||
|
||||
function renderProjects() {
|
||||
// 二级页面:项目任务详情
|
||||
if (state.projectView) {
|
||||
return renderProjectTasks(state.projectView);
|
||||
}
|
||||
const items = state.data.operations;
|
||||
const rows = items.map((x) => [
|
||||
`<strong>${x.project_name}</strong>`,
|
||||
text(x.customer_need || x.notes),
|
||||
badge(x.current_stage || x.project_status),
|
||||
x.expected_contract_amount ? money(x.expected_contract_amount) : "—",
|
||||
text(x.owner || "—"),
|
||||
`<button class="btn btn-ghost btn-sm text-blue-600" onclick="event.stopPropagation(); state.projectView=${x.id}; renderProjects()"><i data-lucide="eye"></i>查看</button>`
|
||||
]);
|
||||
document.querySelector("#projects").innerHTML = `<div class="grid gap-4">
|
||||
<div id="project-form">
|
||||
${card(formHtml([
|
||||
{ label: "项目名称", input: `<input name="project_name" required>` },
|
||||
{ label: "当前阶段", input: `<select name="current_stage"><option>商务洽谈</option><option>系统上线</option><option>团队分工</option><option>项目交付</option><option>上线推广</option><option>结项验收</option></select>` },
|
||||
{ label: "项目金额", input: `<input name="expected_contract_amount" type="number" step="0.01" placeholder="万元">` },
|
||||
{ label: "负责人", input: `<input name="owner">` },
|
||||
], { handler: "createOperation", text: "新增项目" }), "p-4")}
|
||||
</div>
|
||||
${renderTable(["项目", "项目说明", "当前阶段", "项目金额", "负责人", "进展"], rows, items.map((x) => ({ resource: "operations", id: x.id })))}
|
||||
</div>`;
|
||||
if (window.lucide) window.lucide.createIcons();
|
||||
}
|
||||
|
||||
function renderProjectTasks(projectId) {
|
||||
const project = state.data.operations.find((x) => x.id === projectId);
|
||||
if (!project) { state.projectView = null; renderProjects(); return; }
|
||||
const tasks = (state.data.tasks || []).filter((t) => t.project_id === projectId);
|
||||
const phases = ["商务洽谈", "系统上线", "团队分工", "项目交付", "上线推广", "结项验收"];
|
||||
document.querySelector("#projects").innerHTML = `<div class="grid gap-4">
|
||||
<div class="flex items-center justify-between px-5">
|
||||
<button class="btn btn-ghost btn-sm" onclick="state.projectView=null;renderProjects()"><i data-lucide="arrow-left"></i>返回项目列表</button>
|
||||
<div class="flex items-center gap-3">
|
||||
<span class="text-sm font-semibold text-slate-700">${project.project_name}</span>
|
||||
<button class="btn btn-primary btn-sm" onclick="openTaskForm(${projectId}, null)"><i data-lucide="plus"></i>新增任务</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="task-page-wrap">
|
||||
<div class="task-body">
|
||||
${phases.map((phase) => {
|
||||
const pt = tasks.filter((t) => t.phase === phase);
|
||||
if (!pt.length) return "";
|
||||
return `<div class="task-group"><div class="task-group-hd"><span class="task-group-icon"><i data-lucide="layers"></i></span><span class="task-group-label">${phase}</span><span class="task-group-n">${pt.length}</span></div><div class="task-group-list" data-phase="${phase}" ondrop="handleTaskDrop(event, ${projectId}, '${phase}')" ondragover="event.preventDefault(); event.currentTarget.classList.add('drag-over')" ondragleave="event.currentTarget.classList.remove('drag-over')">${pt.map((t) => `<div class="task-row ${t.status === 'done' ? 'task-done' : ''}" data-id="${t.id}" draggable="true" ondragstart="handleTaskDragStart(event, ${t.id})" ondragend="event.currentTarget.classList.remove('dragging')"><span class="task-dot" onclick="event.stopPropagation(); toggleTaskDone(${t.id}, ${projectId})"><i data-lucide="${t.status === 'done' ? 'check-circle' : 'circle'}"></i></span><span class="task-grip"><i data-lucide="grip-vertical"></i></span><div class="task-main" onclick="openTaskForm(${projectId}, ${t.id})"><span class="task-name">${t.task}</span>${t.notes ? `<span class="task-desc">${t.notes}</span>` : ""}${t.blockers ? `<span class="task-blocker">⚠ ${t.blockers}</span>` : ""}</div><span class="task-col">${t.owner || ""}</span><span class="task-col-badge">${t.due_date || ""}</span></div>`).join("")}</div></div>`;
|
||||
}).join("")}
|
||||
</div>
|
||||
<div id="task-drawer-${projectId}" class="task-drawer">
|
||||
<div class="task-drawer-hd"><span class="task-drawer-title">编辑任务</span><div class="flex items-center gap-2"><button type="button" class="btn btn-ghost btn-sm text-red-600 hover:bg-red-50" onclick="deleteTask(${projectId})"><i data-lucide="trash-2"></i>删除</button><button class="task-close" onclick="closeTaskDrawer(${projectId})"><i data-lucide="x"></i></button></div></div>
|
||||
<form class="task-drawer-form" onsubmit="submitTaskForm(event, ${projectId})">
|
||||
<input type="hidden" name="task_id" id="task-id-${projectId}" value="">
|
||||
<label class="task-field"><span>任务名称</span><input name="task" required id="task-name-${projectId}"></label>
|
||||
<label class="task-field"><span>任务阶段</span><select name="phase" id="task-phase-${projectId}">${phases.map((p) => `<option>${p}</option>`).join("")}</select></label>
|
||||
<label class="task-field"><span>负责人</span><input name="owner" id="task-owner-${projectId}"></label>
|
||||
<label class="task-field"><span>截止时间</span><input name="due_date" type="date" id="task-due-${projectId}"></label>
|
||||
<label class="task-field"><span>任务说明</span><textarea name="notes" rows="3" id="task-notes-${projectId}"></textarea></label>
|
||||
<label class="task-field"><span>卡点&备注</span><textarea name="blockers" rows="2" id="task-blockers-${projectId}" placeholder="风险卡点、依赖项等"></textarea></label>
|
||||
<div class="flex justify-end gap-2 mt-4 pt-3 border-t border-slate-100">
|
||||
<button type="button" class="btn btn-ghost btn-sm" onclick="closeTaskDrawer(${projectId})">取消</button>
|
||||
<button type="submit" class="btn btn-primary btn-sm" id="task-submit-btn-${projectId}">确认新增</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
if (window.lucide) window.lucide.createIcons();
|
||||
}
|
||||
|
||||
function showTaskModal(projectId) {
|
||||
const project = state.data.operations.find((x) => x.id === projectId);
|
||||
const tasks = (state.data.tasks || []).filter((t) => t.project_id === projectId);
|
||||
const phases = ["商务洽谈", "系统上线", "团队分工", "项目交付", "上线推广", "结项验收"];
|
||||
document.querySelector("#taskModal").innerHTML = `<div class="task-overlay" onclick="closeTaskModal()"><div class="task-panel" onclick="event.stopPropagation()"><div class="task-header"><h2 class="task-title">${project.project_name} · 任务清单</h2><div class="flex items-center gap-3"><button class="btn btn-primary btn-sm" onclick="event.stopPropagation(); openTaskForm(${projectId}, null)"><i data-lucide="plus"></i>新增任务</button><button class="task-close" onclick="closeTaskModal()"><i data-lucide="x"></i></button></div></div><div class="task-body-wrap">
|
||||
<div class="task-body">
|
||||
${phases.map((phase) => {
|
||||
const pt = tasks.filter((t) => t.phase === phase);
|
||||
if (!pt.length) return "";
|
||||
return `<div class="task-group"><div class="task-group-hd"><span class="task-group-icon"><i data-lucide="layers"></i></span><span class="task-group-label">${phase}</span><span class="task-group-n">${pt.length}</span></div><div class="task-group-list">${pt.map((t) => `<div class="task-row" data-id="${t.id}" onclick="event.stopPropagation(); openTaskForm(${projectId}, ${t.id})"><span class="task-dot"><i data-lucide="${t.status === 'done' ? 'check-circle' : 'circle'}"></i></span><div class="task-main"><span class="task-name">${t.task}</span>${t.notes ? `<span class="task-desc">${t.notes}</span>` : ""}${t.blockers ? `<span class="task-blocker">⚠ ${t.blockers}</span>` : ""}</div><span class="task-col">${t.owner || ""}</span><span class="task-col-badge">${t.due_date || ""}</span></div>`).join("")}</div></div>`;
|
||||
}).join("")}
|
||||
</div>
|
||||
<div id="task-drawer-${projectId}" class="task-drawer">
|
||||
<div class="task-drawer-hd"><span class="task-drawer-title">编辑任务</span><button class="task-close" onclick="closeTaskDrawer(${projectId})"><i data-lucide="x"></i></button></div>
|
||||
<form class="task-drawer-form" onsubmit="submitTaskForm(event, ${projectId})">
|
||||
<input type="hidden" name="task_id" id="task-id-${projectId}" value="">
|
||||
<label class="task-field"><span>任务名称</span><input name="task" required id="task-name-${projectId}"></label>
|
||||
<label class="task-field"><span>任务阶段</span><select name="phase" id="task-phase-${projectId}">${phases.map((p) => `<option>${p}</option>`).join("")}</select></label>
|
||||
<label class="task-field"><span>负责人</span><input name="owner" id="task-owner-${projectId}"></label>
|
||||
<label class="task-field"><span>截止时间</span><input name="due_date" type="date" id="task-due-${projectId}"></label>
|
||||
<label class="task-field"><span>任务说明</span><textarea name="notes" rows="3" id="task-notes-${projectId}"></textarea></label>
|
||||
<label class="task-field"><span>卡点&备注</span><textarea name="blockers" rows="2" id="task-blockers-${projectId}" placeholder="风险卡点、依赖项等"></textarea></label>
|
||||
<div class="flex justify-end gap-2 mt-4 pt-3 border-t border-slate-100">
|
||||
<button type="button" class="btn btn-ghost btn-sm" onclick="closeTaskDrawer(${projectId})">取消</button>
|
||||
<button type="submit" class="btn btn-primary btn-sm" id="task-submit-btn-${projectId}">确认新增</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div></div></div>`;
|
||||
document.querySelector("#taskModal").classList.add("active");
|
||||
if (window.lucide) window.lucide.createIcons();
|
||||
}
|
||||
window.closeTaskModal = () => {
|
||||
document.querySelector("#taskModal").classList.remove("active");
|
||||
document.querySelector("#taskModal").innerHTML = "";
|
||||
};
|
||||
|
||||
function renderProposals() {
|
||||
const categories = ["方案", "成本", "SOP", "财务流程"];
|
||||
const proposalRows = state.data.proposals.map((p) => [p.customer_or_project_name, p.version, badge(p.status), p.files.length + " 个"]);
|
||||
const proposalClicks = state.data.proposals.map((p) => ({ resource: "proposals", id: p.id }));
|
||||
document.querySelector("#proposals").innerHTML = `<div class="grid gap-4">
|
||||
@@ -214,54 +419,115 @@ window.uploadFile = async (event, module, ownerId, version, category) => {
|
||||
await load();
|
||||
};
|
||||
|
||||
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) => [`<strong>${x.project_name}</strong><p class="text-xs text-slate-500">${x.project_version}</p>`, 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 opClicks = items.map((x) => ({ resource: "operations", id: x.id }));
|
||||
document.querySelector("#operations").innerHTML = `<div class="grid gap-4">
|
||||
${card(formHtml([
|
||||
{ label: "项目名称", input: `<input name="project_name" required>` },
|
||||
{ label: "项目版本", input: `<input name="project_version" value="v1.0">` },
|
||||
{ label: "项目类型", input: `<select name="project_type"><option value="opportunity">业务机会项目</option><option value="execution">已签约执行项目</option></select>` },
|
||||
{ label: "状态", input: `<input name="project_status" value="线索发现">` },
|
||||
], { handler: "createOperation", text: "新增项目" }), "p-4")}
|
||||
<div class="flex gap-2">${[["all","全部项目"],["opportunity","业务机会项目"],["execution","已签约执行项目"]].map(([k,v]) => `<button class="btn ${state.opFilter === k ? "btn-primary" : "btn-ghost"}" onclick="state.opFilter='${k}'; renderOperations()">${v}</button>`).join("")}</div>
|
||||
${renderTable(["项目名称", "类型", "状态", "当前阶段", "交付文件", "最新跟进"], opRows, opClicks)}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function renderProducts() {
|
||||
const items = state.productPlatform === "all" ? state.data.products : state.data.products.filter((x) => (x.platform || "") === state.productPlatform);
|
||||
document.querySelector("#products").innerHTML = `<div class="grid gap-4">
|
||||
${card(formHtml([
|
||||
{ label: "产品名称", input: `<input name="product_name" required>` },
|
||||
{ label: "版本号", input: `<input name="version" required>` },
|
||||
{ label: "平台", input: `<select name="platform"><option value="">—</option><option>真研平台</option><option>科普平台</option><option>关爱平台</option></select>` },
|
||||
{ label: "上线日期", input: `<input name="launch_date" placeholder="2026-Q3">` },
|
||||
{ label: "状态", input: `<select name="status"><option>规划中</option><option>设计中</option><option>开发中</option><option>测试中</option><option>已上线</option><option>已延期</option><option>已取消</option></select>` },
|
||||
], { 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 })))}
|
||||
<div class="flex gap-2">${[["all","全部"],["真研平台","真研"],["科普平台","科普"],["关爱平台","关爱"]].map(([k,v]) => `<button class="btn ${state.productPlatform === k ? "btn-primary" : "btn-ghost"}" onclick="state.productPlatform='${k}'; renderProducts()">${v}</button>`).join("")}</div>
|
||||
${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 })))}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function renderFinance() {
|
||||
const rows = state.data.finance.map((x) => [x.month, badge(x.record_type === "revenue" ? "收入" : "成本/费用"), x.category, money(x.amount), x.occurred_date, text(x.notes)]);
|
||||
const pfs = state.data.projectFinances || [];
|
||||
const ops = state.data.operations || [];
|
||||
const months = ["2026-06","2026-07","2026-08","2026-09"];
|
||||
const monthLabels = ["6月","7月","8月","9月"];
|
||||
|
||||
// Aggregates
|
||||
const signed = pfs.filter(x => x.status === "已签单");
|
||||
const pending = pfs.filter(x => x.status !== "已签单");
|
||||
const sumSign = signed.reduce((s,x) => s + (x.sign_amount||0), 0);
|
||||
const sumPending = pending.reduce((s,x) => s + (x.sign_amount||0), 0);
|
||||
const monthRev = months.map(m => pfs.reduce((s,x) => s + (x["rev_"+m.replace("-","_")]||0), 0));
|
||||
const monthGross = months.map(m => pfs.reduce((s,x) => s + (x["gross_"+m.replace("-","_")]||0), 0));
|
||||
|
||||
const renderPfRow = (pf) => {
|
||||
const mCols = months.map(m => {
|
||||
const rev = pf["rev_"+m.replace("-","_")] || 0;
|
||||
const gross = pf["gross_"+m.replace("-","_")] || 0;
|
||||
return `<td class="p-2 text-right whitespace-nowrap"><span class="${rev ? 'text-blue-700 font-medium' : 'text-slate-300'}">${rev ? money(rev) : '—'}</span><br><span class="text-xs ${gross ? 'text-green-600' : 'text-slate-300'}">${gross ? money(gross) : '—'}</span></td>`;
|
||||
}).join("");
|
||||
return `<tr class="border-b border-slate-100 hover:bg-slate-50 cursor-pointer" onclick="openPfEditModal(${pf.id})"><td class="p-2 text-sm font-medium">${pf.customer_name}</td><td class="p-2 text-sm">${pf.business_type}</td><td class="p-2 text-sm">${pf.status === "已签单" ? badge("已签") : badge(pf.status,"amber")}</td><td class="p-2 text-right text-sm">${money(pf.sign_amount)}</td>${mCols}<td class="p-2 text-sm text-slate-500">${pf.sales_person || ""}</td></tr>`;
|
||||
};
|
||||
|
||||
document.querySelector("#finance").innerHTML = `<div class="grid gap-4">
|
||||
${card(`<h2 class="mb-4 text-lg font-bold">收入、毛利、成本/费用、净利月度曲线</h2><canvas id="financeChart2" height="105"></canvas>`, "p-5")}
|
||||
${card(formHtml([
|
||||
{ label: "月份", input: `<input name="month" required placeholder="YYYY-MM" pattern="\\d{4}-\\d{2}">` },
|
||||
{ label: "类型", input: `<select name="record_type"><option value="revenue">收入</option><option value="cost_expense">成本/费用</option></select>` },
|
||||
{ label: "分类", input: `<input name="category" required>` },
|
||||
{ label: "金额/万", input: `<input name="amount" type="number" step="0.01" required>` },
|
||||
{ label: "发生日期", input: `<input name="occurred_date" type="date">` },
|
||||
], { handler: "createFinance", text: "新增明细" }), "p-4")}
|
||||
${renderTable(["月份", "类型", "分类", "金额", "发生日期", "备注"], rows)}
|
||||
<div class="grid grid-cols-6 gap-3">
|
||||
${[["已签项目","" + signed.length],["签约金额",money(sumSign)],["待签项目","" + pending.length],["待签金额",money(sumPending)],["本月确收",money(monthRev[0])],["本月毛利",money(monthGross[0])]].map(([l,v]) => `<div class="bg-white rounded-lg border border-slate-200 p-3 text-center"><p class="text-xs text-slate-500">${l}</p><p class="text-xl font-bold text-slate-800">${v}</p></div>`).join("")}
|
||||
</div>
|
||||
${card(`<div class="flex items-center justify-between cursor-pointer" onclick="toggleFinanceChart()"><h2 class="text-lg font-bold text-slate-700">月度趋势</h2><i data-lucide="chevron-down" class="transition-transform rotate-90" id="financeChartIcon"></i></div><div id="financeChartWrap" class="hidden mt-4"><div style="position:relative;height:300px"><canvas id="financeChart2"></canvas></div></div>`, "p-5")}
|
||||
|
||||
<div class="flex justify-end"><button class="btn btn-primary btn-sm" onclick="openFinanceModal()"><i data-lucide="plus"></i>新增财务项目</button></div>
|
||||
<div id="financeModal" class="hidden fixed inset-0 z-50 flex items-center justify-center bg-black/30" onclick="closeFinanceModal()"><div class="bg-white rounded-xl shadow-xl w-full max-w-3xl mx-4 max-h-[90vh] overflow-y-auto" onclick="event.stopPropagation()"><div class="sticky top-0 bg-white border-b px-6 py-4 flex items-center justify-between"><h3 class="font-bold text-lg" id="financeModalTitle">新增项目财务</h3><button class="btn btn-ghost btn-sm" onclick="closeFinanceModal()"><i data-lucide="x"></i></button></div><form onsubmit="createFinance(event)" class="p-6 grid gap-3"><input type="hidden" name="pf_id" id="pf-id-input" value=""><div class="grid grid-cols-3 gap-3"><label class="text-xs">项目<select name="project_id" class="rounded border px-2 py-1.5 text-sm w-full">${ops.map(o => `<option value="${o.id}">${o.project_name}</option>`).join("")}</select></label><label class="text-xs">业务类型<select name="business_type" class="rounded border px-2 py-1.5 text-sm w-full">${["患者管理","创新支付","电商","MCN","科普视频","科普运营","医患运营","真实世界研究","其他"].map(t => `<option>${t}</option>`).join("")}</select></label><label class="text-xs">客户名称<input name="customer_name" class="rounded border px-2 py-1.5 text-sm w-full"></label><label class="text-xs">签约金额/万<input name="sign_amount" type="number" step="0.01" class="rounded border px-2 py-1.5 text-sm w-full"></label><label class="text-xs">签约月份<input name="sign_month" class="rounded border px-2 py-1.5 text-sm w-full"></label><label class="text-xs">状态<select name="status" class="rounded border px-2 py-1.5 text-sm w-full"><option>已签单</option><option>待签</option></select></label></div><div class="grid grid-cols-4 gap-2">${["06","07","08","09"].map(m => `<div class="border rounded p-2"><p class="text-xs text-slate-400 mb-1">${m}月</p><label class="text-xs text-slate-500">确收<br><input name="rev_2026_${m}" type="number" step="0.01" class="w-full rounded border px-1 py-1 text-sm" placeholder="万"></label><label class="text-xs text-slate-500 mt-1">毛利<br><input name="gross_2026_${m}" type="number" step="0.01" class="w-full rounded border px-1 py-1 text-sm" placeholder="万"></label></div>`).join("")}</div><div class="flex justify-end gap-2 pt-3 border-t"><button type="button" class="btn btn-ghost btn-sm" onclick="closeFinanceModal()">取消</button><button type="submit" class="btn btn-primary btn-sm">确认新增</button></div></form></div></div>
|
||||
|
||||
${card(`<h3 class="font-bold text-slate-700 mb-3">项目明细 <span class="text-slate-400 font-normal">(${pfs.length})</span></h3><div class="flex gap-2 mb-3">${[["已签单","已签"],["待签","待签"]].map(([k,v]) => `<button class="btn btn-sm ${state.finFilter === k ? 'btn-primary' : 'btn-ghost'}" onclick="state.finFilter='${k}';renderFinance()">${v} (${pfs.filter(x=>x.status===k).length})</button>`).join("")}</div><div class="overflow-x-auto"><table class="w-full text-sm"><thead><tr class="bg-slate-50 border-b border-slate-200"><th class="p-2 text-left font-semibold">客户</th><th class="p-2 text-left font-semibold">类型</th><th class="p-2 text-left font-semibold">状态</th><th class="p-2 text-right font-semibold">签约金额</th>${monthLabels.map(l => `<th class="p-2 text-center font-semibold">${l}<br><span class="text-xs text-slate-400">确收/毛利</span></th>`).join("")}<th class="p-2 text-left font-semibold">销售</th></tr></thead><tbody>${pfs.filter(x => x.status === state.finFilter).map(renderPfRow).join("")}</tbody></table></div>`, "p-4")}
|
||||
</div>`;
|
||||
renderChartOn("financeChart2", state.data.financeMonthly);
|
||||
if (window.lucide) window.lucide.createIcons();
|
||||
}
|
||||
|
||||
window.openFinanceModal = () => {
|
||||
const modal = document.querySelector("#financeModal");
|
||||
modal.classList.remove("hidden");
|
||||
};
|
||||
window.closeFinanceModal = () => {
|
||||
const modal = document.querySelector("#financeModal");
|
||||
modal.classList.add("hidden");
|
||||
};
|
||||
window.openPfEditModal = (pfId) => {
|
||||
const pf = (state.data.projectFinances || []).find(x => x.id === pfId);
|
||||
if (!pf) return;
|
||||
document.querySelector("#pf-id-input").value = pf.id;
|
||||
document.querySelector("#financeModalTitle").textContent = "编辑项目财务";
|
||||
const form = document.querySelector("#financeModal form");
|
||||
form.querySelector('[name="project_id"]').value = pf.project_id || "";
|
||||
form.querySelector('[name="business_type"]').value = pf.business_type || "";
|
||||
form.querySelector('[name="customer_name"]').value = pf.customer_name || "";
|
||||
form.querySelector('[name="sign_amount"]').value = pf.sign_amount || "";
|
||||
form.querySelector('[name="sign_month"]').value = pf.sign_month || "";
|
||||
form.querySelector('[name="status"]').value = pf.status || "已签单";
|
||||
for (const m of ["06","07","08","09"]) {
|
||||
form.querySelector('[name="rev_2026_' + m + '"]').value = pf["rev_2026_" + m] || "";
|
||||
form.querySelector('[name="gross_2026_' + m + '"]').value = pf["gross_2026_" + m] || "";
|
||||
}
|
||||
openFinanceModal();
|
||||
};
|
||||
window.toggleFinanceChart = () => {
|
||||
const wrap = document.querySelector("#financeChartWrap");
|
||||
const icon = document.querySelector("#financeChartIcon");
|
||||
if (!wrap) return;
|
||||
wrap.classList.toggle("hidden");
|
||||
icon.classList.toggle("rotate-90");
|
||||
if (!wrap.classList.contains("hidden") && !state.chart2) renderFinanceChart();
|
||||
};
|
||||
function renderFinanceChart() {
|
||||
const { financeMonthly } = state.data;
|
||||
const canvas = document.querySelector("#financeChart2");
|
||||
if (!canvas || !window.Chart) return;
|
||||
if (state.chart2) state.chart2.destroy();
|
||||
state.chart2 = new Chart(canvas, {
|
||||
type: "line",
|
||||
data: {
|
||||
labels: financeMonthly.map((x) => x.month),
|
||||
datasets: [
|
||||
{ label: "月度确收", data: financeMonthly.map((x) => x.revenue), borderColor: "#2563eb", tension: 0.3 },
|
||||
{ label: "月度毛利", data: financeMonthly.map((x) => x.net_profit), borderColor: "#059669", tension: 0.3 },
|
||||
],
|
||||
},
|
||||
options: { responsive: true, maintainAspectRatio: false, plugins: { legend: { position: "bottom", labels: { boxWidth: 12, font: { size: 11 } } } }, scales: { x: { ticks: { font: { size: 11 } }, grid: { display: false } }, y: { ticks: { font: { size: 11 }, callback: (v) => v + "万" } } } },
|
||||
});
|
||||
}
|
||||
|
||||
function renderChartOn(id, data) {
|
||||
const canvas = document.querySelector(`#${id}`);
|
||||
if (!canvas || !window.Chart) return;
|
||||
new Chart(canvas, {
|
||||
if (state.chart2) state.chart2.destroy();
|
||||
state.chart2 = new Chart(canvas, {
|
||||
type: "line",
|
||||
data: {
|
||||
labels: data.map((x) => x.month),
|
||||
@@ -276,11 +542,13 @@ function renderChartOn(id, data) {
|
||||
});
|
||||
}
|
||||
|
||||
function drawerField(icon, label, name, value, multiline = false) {
|
||||
function drawerField(icon, label, name, value, multiline = false, customControl = null) {
|
||||
const initialValue = text(value);
|
||||
const control = multiline
|
||||
? `<textarea name="${name}" rows="2" class="drawer-value drawer-textarea" data-original="${initialValue}">${initialValue}</textarea>`
|
||||
: `<input name="${name}" value="${initialValue}" class="drawer-value" data-original="${initialValue}">`;
|
||||
const control = customControl
|
||||
? customControl
|
||||
: multiline
|
||||
? `<textarea name="${name}" rows="2" class="drawer-value drawer-textarea" data-original="${initialValue}">${initialValue}</textarea>`
|
||||
: `<input name="${name}" value="${initialValue}" class="drawer-value" data-original="${initialValue}">`;
|
||||
return `<div class="drawer-field">
|
||||
<div class="drawer-field-label"><i data-lucide="${icon}"></i><span>${label}</span></div>
|
||||
<div class="drawer-field-control">${control}</div>
|
||||
@@ -292,28 +560,31 @@ function openDrawer(resource, id) {
|
||||
const item = list.find((x) => x.id === id);
|
||||
const drawer = document.querySelector("#drawer");
|
||||
const fields = resource === "sales"
|
||||
? [["target_customer","目标客户"],["priority","优先级"],["status","状态"]]
|
||||
? [["target_customer","业务机会"],["priority","优先级"],["status","状态"]]
|
||||
: resource === "operations"
|
||||
? [["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","下一步动作"]]
|
||||
? [["project_name","项目名称"],["owner","负责人"],["expected_sign_date","截止时间"],["expected_contract_amount","金额"],["notes","项目说明"]]
|
||||
: 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",
|
||||
owner: "user", 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"];
|
||||
const followupTarget = resource === "sales" ? "sales" : resource === "proposals" ? "proposal" : resource === "operations" ? "operation" : resource === "products" ? "product" : "";
|
||||
const title = item.target_customer || item.project_name || item.customer_or_project_name || item.product_name;
|
||||
drawer.innerHTML = `<div class="drawer-panel"><div class="sticky top-0 z-10 flex items-center justify-between border-b border-slate-200 bg-white/95 px-5 py-3 backdrop-blur"><div><p class="text-[10px] font-semibold uppercase tracking-[0.18em] text-slate-400">Detail Drawer</p><div class="flex items-center gap-2"><h2 class="drawer-title text-[17px] font-semibold leading-6 text-slate-900">${title}</h2><span id="drawerSaveStatus" class="save-status"></span></div></div><button class="btn btn-ghost btn-sm" onclick="closeDrawer()">关闭</button></div><div class="grid gap-5 p-5">
|
||||
drawer.innerHTML = `<div class="drawer-panel"><div class="sticky top-0 z-10 flex items-center justify-between border-b border-slate-200 bg-white/95 px-5 py-3 backdrop-blur"><div><p class="text-[10px] font-semibold uppercase tracking-[0.18em] text-slate-400">Detail Drawer</p><div class="flex items-center gap-2"><h2 class="drawer-title text-[17px] font-semibold leading-6 text-slate-900">${title}</h2><span id="drawerSaveStatus" class="save-status"></span></div></div><div class="flex items-center gap-2"><button class="btn btn-ghost btn-sm text-red-600 hover:bg-red-50" onclick="deleteDrawerItem('${resource}', ${id})"><i data-lucide="trash-2"></i>删除</button><button class="btn btn-ghost btn-sm" onclick="closeDrawer()">关闭</button></div></div><div class="grid gap-5 p-5">
|
||||
<section>
|
||||
<h3 class="drawer-section-title">属性</h3>
|
||||
<form id="drawerForm" class="drawer-fields">${fields.map(([key,label]) => drawerField(fieldIcons[key] || "circle", label, key, item[key], multilineFields.includes(key))).join("")}</form>
|
||||
<form id="drawerForm" class="drawer-fields">
|
||||
${drawerField("map-pin", "当前阶段", "current_stage", "", false, `<select name="current_stage" class="drawer-value" onchange="saveDrawerField(this,'${resource}',${id})">${["商务洽谈","系统上线","团队分工","项目交付","上线推广","结项验收"].map((s) => `<option ${s === item.current_stage ? "selected" : ""}>${s}</option>`).join("")}</select>`)}
|
||||
${fields.map(([key,label]) => drawerField(fieldIcons[key] || "circle", label, key, item[key], multilineFields.includes(key))).join("")}
|
||||
</form>
|
||||
</section>
|
||||
${resource === "proposals" ? `<section><h3 class="drawer-section-title">方案文件</h3><div class="grid gap-2">${["方案","成本","SOP","财务流程"].map((cat) => fileGroup("proposal", item.id, item.version, cat, item.files.filter((f) => f.file_category === cat))).join("")}</div></section>` : ""}
|
||||
${followupTarget ? `<section>
|
||||
@@ -380,7 +651,7 @@ function bindDrawerAutosave(resource, id, item) {
|
||||
field.addEventListener("keydown", (event) => {
|
||||
if (event.key === "Enter" && field.tagName !== "TEXTAREA") field.blur();
|
||||
});
|
||||
field.addEventListener("blur", async () => {
|
||||
const doSave = async () => {
|
||||
const value = field.value;
|
||||
if (value === field.dataset.original) return;
|
||||
const previous = field.dataset.original;
|
||||
@@ -400,13 +671,88 @@ function bindDrawerAutosave(resource, id, item) {
|
||||
setDrawerSaveStatus("保存失败", "danger");
|
||||
alert(`自动保存失败:${error.message}`);
|
||||
}
|
||||
});
|
||||
};
|
||||
field.addEventListener("blur", doSave);
|
||||
if (field.tagName === "SELECT") field.addEventListener("change", doSave);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
window.openDrawer = openDrawer;
|
||||
window.deleteDrawerItem = async (resource, id) => {
|
||||
if (!confirm("确认删除?此操作不可撤销。")) return;
|
||||
try {
|
||||
await api(`/api/${resource}/${id}`, { method: "DELETE" });
|
||||
closeDrawer();
|
||||
await load();
|
||||
} catch (error) {
|
||||
alert("删除失败:" + error.message);
|
||||
}
|
||||
};
|
||||
window.toggleTaskDone = async (taskId, projectId) => {
|
||||
const task = (state.data.tasks || []).find((t) => t.id === taskId);
|
||||
if (!task) return;
|
||||
const newStatus = task.status === "done" ? "" : "done";
|
||||
try {
|
||||
await api(`/api/tasks/${taskId}`, { method: "PUT", body: JSON.stringify({ data: { status: newStatus } }) });
|
||||
await load();
|
||||
} catch (error) {
|
||||
alert("更新失败:" + error.message);
|
||||
}
|
||||
};
|
||||
window.deleteTask = async (projectId) => {
|
||||
const taskId = document.querySelector(`#task-id-${projectId}`).value;
|
||||
if (!taskId) return;
|
||||
if (!confirm("确认删除该任务?此操作不可撤销。")) return;
|
||||
try {
|
||||
await api(`/api/tasks/${taskId}`, { method: "DELETE" });
|
||||
closeTaskDrawer(projectId);
|
||||
await load();
|
||||
} catch (error) {
|
||||
alert("删除失败:" + error.message);
|
||||
}
|
||||
};
|
||||
let dragTaskId = null;
|
||||
window.handleTaskDragStart = (event, taskId) => {
|
||||
dragTaskId = taskId;
|
||||
event.currentTarget.classList.add("dragging");
|
||||
event.dataTransfer.effectAllowed = "move";
|
||||
};
|
||||
window.handleTaskDrop = async (event, projectId, phase) => {
|
||||
event.preventDefault();
|
||||
event.currentTarget.classList.remove("drag-over");
|
||||
const target = event.currentTarget;
|
||||
if (!dragTaskId) return;
|
||||
// Find the dragged element and insert after the nearest task
|
||||
const dragged = document.querySelector(`.task-row[data-id="${dragTaskId}"]`);
|
||||
if (!dragged) return;
|
||||
const afterElement = getDragAfterElement(target, event.clientY);
|
||||
if (afterElement) {
|
||||
target.insertBefore(dragged, afterElement);
|
||||
} else {
|
||||
target.appendChild(dragged);
|
||||
}
|
||||
dragged.classList.remove("dragging");
|
||||
// Update sort_order in DB
|
||||
const rows = [...target.querySelectorAll(".task-row")];
|
||||
const updates = rows.map((row, i) => ({ id: parseInt(row.dataset.id), sort_order: i }));
|
||||
try {
|
||||
await api(`/api/tasks/batch-sort`, { method: "POST", body: JSON.stringify({ items: updates }) });
|
||||
} catch (e) { /* non-critical */ }
|
||||
dragTaskId = null;
|
||||
};
|
||||
function getDragAfterElement(container, y) {
|
||||
const elements = [...container.querySelectorAll(".task-row:not(.dragging)")];
|
||||
return elements.reduce((closest, child) => {
|
||||
const box = child.getBoundingClientRect();
|
||||
const offset = y - box.top - box.height / 2;
|
||||
if (offset < 0 && offset > closest.offset) {
|
||||
return { offset, element: child };
|
||||
}
|
||||
return closest;
|
||||
}, { offset: Number.NEGATIVE_INFINITY }).element;
|
||||
}
|
||||
window.closeDrawer = () => document.querySelector("#drawer").classList.remove("open");
|
||||
window.squireInstances = {};
|
||||
window.squireCmd = (cmd) => {
|
||||
|
||||
@@ -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; }
|
||||
|
||||
20
static/vendor/chart.js
vendored
Normal file
20
static/vendor/chart.js
vendored
Normal file
File diff suppressed because one or more lines are too long
12
static/vendor/lucide.js
vendored
Normal file
12
static/vendor/lucide.js
vendored
Normal file
File diff suppressed because one or more lines are too long
5015
static/vendor/squire.js
vendored
Normal file
5015
static/vendor/squire.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
83
static/vendor/tailwind.js
vendored
Normal file
83
static/vendor/tailwind.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -4,10 +4,7 @@
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>科普(慰心斋)OPC 工作台</title>
|
||||
<link rel="preconnect" href="https://cdn.tailwindcss.com" crossorigin>
|
||||
<link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin>
|
||||
<link rel="preconnect" href="https://unpkg.com" crossorigin>
|
||||
<script src="https://cdn.tailwindcss.com"></script>
|
||||
<script src="{{ url_for('static', filename='vendor/tailwind.js') }}"></script>
|
||||
<script>
|
||||
tailwind.config = {
|
||||
theme: {
|
||||
@@ -24,38 +21,46 @@
|
||||
}
|
||||
</script>
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}">
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.8/dist/chart.umd.min.js" defer></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/squire-rte@1/build/squire-raw.js" defer></script>
|
||||
<script src="https://unpkg.com/lucide@latest" defer></script>
|
||||
<script src="{{ url_for('static', filename='vendor/chart.js') }}" defer></script>
|
||||
<script src="{{ url_for('static', filename='vendor/squire.js') }}" defer></script>
|
||||
<script src="{{ url_for('static', filename='vendor/lucide.js') }}" defer></script>
|
||||
</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>
|
||||
|
||||
Reference in New Issue
Block a user