feat(#2): 章程模板填充 - 生成项目章程和干系人登记册Markdown

This commit is contained in:
2026-04-11 18:36:41 +08:00
parent 9728dffdd9
commit 17297a231e
2 changed files with 148 additions and 5 deletions

143
src/lib/charter.ts Normal file
View File

@@ -0,0 +1,143 @@
/**
* 章程模板填充模块
* 根据向导页收集的项目数据生成符合PMBOK标准的项目章程Markdown
*/
export interface ProjectData {
name: string;
goal: string;
scopeIn: string;
scopeOut: string;
constraints: string;
assumptions: string;
stakeholders: Array<{
name: string;
role: string;
power: string;
interest: string;
strategy: string;
}>;
milestones: Array<{
name: string;
targetDate: string;
deliverable: string;
}>;
}
/**
* 生成项目章程 Markdown
*/
export function generateCharter(data: ProjectData): string {
const now = new Date().toISOString().split('T')[0];
return `# 项目章程
### 基本信息
- **项目名称:** ${data.name || '(待填写)'}
- **项目经理:** (待指定)
- **发起人/产品负责人:** (待指定)
- **开始日期:** ${now}
- **目标结束日期:** (待确定)
### 项目目标
${data.goal || '(待填写)'}
### 范围边界
**包含:**
${data.scopeIn ? data.scopeIn.split('\n').map((l) => `- ${l}`).join('\n') : '- (待填写)'}
**不包含:**
${data.scopeOut ? data.scopeOut.split('\n').map((l) => `- ${l}`).join('\n') : '- (待填写)'}
### 关键里程碑
| 里程碑 | 目标日期 | 交付物 |
|--------|---------|--------|
${data.milestones.length > 0
? data.milestones.map((m) => `| ${m.name} | ${m.targetDate} | ${m.deliverable} |`).join('\n')
: '| (待添加) | | |'}
### 主要干系人
| 角色 | 姓名 | 权力 | 利益/关注度 | 参与策略 |
|------|------|------|-----------|---------|
${data.stakeholders.length > 0
? data.stakeholders.map((s) => `| ${s.role} | ${s.name} | ${s.power} | ${s.interest} | ${s.strategy} |`).join('\n')
: '| (待添加) | | | | |'}
### 初步资源
- 开发:(待确认)人
- 设计:(待确认)人
- 测试:(待确认)人
- 基础设施预算:(待确认)
### 约束和假设
**约束:**
${data.constraints ? `- ${data.constraints}` : '- (待填写)'}
**假设:**
${data.assumptions ? `- ${data.assumptions}` : '- (待填写)'}
---
*本文档由 FlowPilot 自动生成于 ${now}*
`;
}
/**
* 生成干系人登记册 Markdown
*/
export function generateStakeholderRegister(data: ProjectData): string {
const now = new Date().toISOString().split('T')[0];
return `# 干系人登记册
> 项目:${data.name || '(待填写)'}
> 日期:${now}
## 干系人列表
| 干系人 | 角色 | 权力 | 利益/关注度 | 态度 | 参与策略 |
|--------|------|------|-----------|------|---------|
${data.stakeholders.length > 0
? data.stakeholders.map((s) => `| ${s.name} | ${s.role} | ${s.power} | ${s.interest} | 待评估 | ${s.strategy} |`).join('\n')
: '| (待添加) | | | | | |'}
## 权力-利益矩阵
\`\`\`
高利益
|
重点管理 | 保持满意
(高权力高利益) | (低权力高利益)
————————————+————————————
随时告知 | 监督
(高权力低利益) | (低权力低利益)
|
低利益
低权力 高权力
\`\`\`
${data.stakeholders
.filter((s) => s.power === '高' && s.interest === '高')
.map((s) => `- **重点管理**${s.name}${s.role})→ ${s.strategy}`)
.join('\n')}
${data.stakeholders
.filter((s) => s.power === '低' && s.interest === '高')
.map((s) => `- **保持满意**${s.name}${s.role})→ ${s.strategy}`)
.join('\n')}
${data.stakeholders
.filter((s) => s.power === '高' && s.interest === '低')
.map((s) => `- **随时告知**${s.name}${s.role})→ ${s.strategy}`)
.join('\n')}
${data.stakeholders
.filter((s) => s.power === '低' && s.interest === '低')
.map((s) => `- **监督**${s.name}${s.role})→ ${s.strategy}`)
.join('\n')}
---
*本文档由 FlowPilot 自动生成于 ${now}*
`;
}