/* views/overview.js —— 工作台首页(v4:替换 v3 的"总览仪表盘") * * 30–40 人共用的组织资产系统,每人进来先知道自己该干什么。三种视角同时在场(分区,不藏进 tab): * ① 给我的 当前身份:交了哪些、进了几张卡、还差哪个阶段 * ② 全员的池子 池子规模、本周新增、最新进池 3 张(卡片形态)、评分最高 * ③ 现场看板 五阶段 × 人数矩阵、谁卡住了(直接列名)、各板块产出 * 外加一行「PPT 痛点 → 系统能力」对照:让客户一眼看出系统是照着他们的痛处做的。 */ (function () { "use strict"; const T = window.KF_TAXONOMY; const U = window.KF_UTIL; const UI = window.KF_UI; const OPP = window.KF_OPP; const esc = U.esc; /* 五种成果类型 → 所属阶段口径(用于"还差哪个阶段") */ const STAGE_PRODUCT = { S1: "品类市场分析", S2: "用户需求与痛点", S3: "机会点与机会卡", S4: "验证评分与结论", S5: "场景卖点与方案" }; function weekAgo() { return Date.now() - 7 * 86400000; } /* ---------------- ① 给我的 ---------------- */ function meOf(db) { const me = OPP.getMe(); return me ? db.memberByName[me] || { name: me, artifactIds: [], stageObj: null, msgCount: 0, done: false, isGuest: true } : null; } function mine(db) { const me = meOf(db); const names = OPP.meCandidates(db); const who = `
当前身份
`; if (!me) { return `

给我的

现场每人选一次自己,之后刷新保持
${who}

还没选身份。选完之后这里会显示:你交了几份成果、有几张卡进了池子、还差哪个阶段没交。

${names.slice(0, 12).map((n) => `${esc(n)}`).join("")}${names.length > 12 ? `…共 ${names.length} 人` : ""}
`; } const arts = me.artifactIds.map((id) => db.artifactById[id]).filter(Boolean); const myOpps = db.opportunities.filter((o) => o.upload.by === me.name); const myScores = db.opportunities.filter((o) => o.stats.byUser[me.name]); /* 每个阶段是否交过:按成果的 stage 字段;S3 另外看有没有机会卡进池 */ const stageRows = T.STAGES.map((s) => { const a = arts.filter((x) => x.stageObj && x.stageObj.no === s.no); const o = myOpps.filter((x) => x.stageObj && x.stageObj.no === s.no); const cur = me.stageObj && me.stageObj.no === s.no; const done = a.length > 0 || o.length > 0; const state = done ? "done" : cur ? "cur" : "todo"; return ` ${esc(s.label)}${esc(STAGE_PRODUCT[s.code])} ${done ? "已交" : cur ? "进行中 · 未交" : "未到 / 未交"} ${a.length} ${o.length} `; }).join(""); const missing = T.STAGES.filter((s) => !arts.some((x) => x.stageObj && x.stageObj.no === s.no) && !myOpps.some((x) => x.stageObj && x.stageObj.no === s.no)); const nextMissing = missing.find((s) => !me.stageObj || s.no >= me.stageObj.no) || missing[0]; const recent = arts.slice().sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt)).slice(0, 3); return `

给我的

${esc(me.name)}的贡献
${who}
${arts.length}份成果已归集
${myOpps.length}张机会卡进了池子
${myScores.length}张卡由我评过分
${missing.length}${missing.length ? `个阶段还没交${nextMissing ? `,下一个是 ${nextMissing.code}` : ""}` : "五个阶段都交过"}
${stageRows}
阶段状态我的成果我的机会卡

我最近交的

我的成员页
${recent.length ? recent.map((a) => ``).join("") : `

还没有成果。在分身上传后会出现在这里。

`}
`; } /* ---------------- ② 全员的池子 ---------------- */ function pool(db) { const all = db.opportunities; const fresh = all.filter((o) => o.upload.at && new Date(o.upload.at).getTime() >= weekAgo()); const latest = OPP.sortCards(all, "new").slice(0, 3); const best = all.filter((o) => o.stats.n).sort((a, b) => b.stats.avg - a.stats.avg)[0]; const byStatus = (k) => all.filter((o) => o.status === k).length; return `

全员的池子

组织视角 · 机会储备进入卡片池 →
${all.length}张机会卡 ${byStatus("candidate")} 候选 · ${byStatus("approved")} 立项 · ${byStatus("rejected")} 否决
${fresh.length}本周新增
${new Set(all.map((o) => o.upload.by).filter(Boolean)).size}进池的人
${new Set(all.map((o) => o.upload.agentName).filter(Boolean)).size}参与上传的 Agent
${best ? `评分最高${esc(best.title)}${best.stats.avg} 分 · ${best.stats.n} 人评` : ""}

最新进池的 3 张

按上传时间
${latest.length ? `` : `
池子还是空的:S3 阶段学员上传机会卡后会出现在这里。
`}
`; } /* ---------------- ③ 现场看板 ---------------- */ function board(db) { const members = db.members; const total = members.length; /* 矩阵:行=阶段,列=S1..S5 到达过 / 当前停留;格内是人数,点开该阶段 */ const reached = (s) => members.filter((m) => m.stageObj && m.stageObj.no >= s.no).length; const stay = (s) => members.filter((m) => m.stageObj && m.stageObj.no === s.no).length; const cellMax = Math.max(1, ...T.STAGES.map((s) => reached(s))); const matrix = `${T.STAGES.map((s) => ``).join("")} ${T.STAGES.map((s) => ` ${T.STAGES.map((t) => t.no <= s.no ? `` : ``).join("")} `).join("")}
阶段${s.code}到达进度
${esc(s.label)}停留 ${stay(s)} 人 · 产出 ${db.byStage[s.no - 1].artifacts.length} 条成果${db.byStage[s.no - 1].opportunities.length ? ` + ${db.byStage[s.no - 1].opportunities.length} 张卡` : ""}${stay(t)}·${reached(s)}/${total} 人
`; const stuck = members.filter((m) => m.stuck).sort((a, b) => b.stuckHours - a.stuckHours); const idle = members.filter((m) => !m.stuck && !m.done); const stuckHtml = stuck.length ? `
${stuck.map((m) => ` ${esc(m.name)} ${esc(m.stageObj ? m.stageObj.code : "—")} · ${m.stuckHours} 小时没交 ${m.msgCount} 条对话 · ${esc(m.groupId || "未分组")}`).join("")}
` : `
${UI.icons.info}现在没有卡住的人(在对话 ≥5 条、超过 ${db.stuckHours} 小时没新成果才算卡住)。
`; const idleLine = idle.length ? `

另有 ${idle.length} 人未提交但还在活跃:${idle.map((m) => esc(m.name)).join("、")}

` : ""; const done = members.filter((m) => m.done).length; return `

现场看板

讲师视角 · 30–40 人同场阶段详情 →
${total}在场成员
${done}已交成果
${members.length - done - stuck.length}在对话、未交
${stuck.length}卡住(>${db.stuckHours}h)
${matrix}

谁卡住了

按停留时长
${stuckHtml}${idleLine}
`; } /* ---------------- 分板块产出 ---------------- */ function boards(db) { const cards = db.byStage.map(({ stage, artifacts, opportunities }) => { const list = artifacts.slice().sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt)).slice(0, 3); const people = [...new Set(artifacts.map((a) => a.ownerName).filter(Boolean))]; const byAgent = U.countBy(artifacts, (a) => a.upload.agentName || "未记录 Agent"); return `
${stage.code}

${esc(stage.label)}

${artifacts.length}条成果${opportunities.length ? `${opportunities.length} 张卡` : ""}
产出:${esc(STAGE_PRODUCT[stage.code])}
    ${list.length ? list.map((a) => `
  1. ${esc(a.shortTitle)} ${esc(a.ownerName || "—")}${esc(a.upload.agentName ? OPP.agentName(a.upload.agentName) : "Agent 未记录")}${esc(U.fmtAgo(a.createdAt))}
  2. `).join("") : `
  3. 还没有成果入库
  4. `}
${people.length} 人产出${byAgent.size ? ` · ${[...byAgent.keys()].map((k) => esc(OPP.agentName(k))).join("、")}` : ""}
`; }).join(""); return `

分板块产出

五个阶段各自的沉淀 · 谁产的
${cards}
`; } /* ---------------- 痛点 → 系统能力 ---------------- */ const PAIN = [ ["① 信息收集繁琐分散", "原材料库 / 调研入池:资讯归集到一处,Agent 自动入库", "#/sources"], ["② 机会识别凭经验", "机会卡片池:可评分、可排序、可决策", "#/pool"], ["③ 卖点提炼缺抓手", "痛点 ↔ 卖点:报告里的交叉表,由结论追到原文", "#/reportIndex"], ["④ 概念验证无量化", "评分模型:五维加权,卡片上直接有分", "#/pool"], ["⑤ 琐事挤占思考", "上传自动化:Agent 上传、带来源元数据,人只做判断", "#/stages"] ]; function pains() { return `

痛点 → 系统能力

PPT 里的五句话,在这个系统里各自落在哪
    ${PAIN.map(([p, cap, href], i) => `
  1. 0${i + 1} ${esc(p)} ${esc(cap)}
  2. `).join("")}
`; } function render(db) { return `

工作台

${db.members.length} 人共用一套数字分身。这一屏先回答三件事:我要交什么、池子里有什么、现场谁卡住了。

${mine(db)} ${pool(db)} ${board(db)} ${boards(db)} ${pains()}
`; } window.KF_VIEW_OVERVIEW = { render }; })();