const { Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
        Header, Footer, AlignmentType, HeadingLevel, BorderStyle, WidthType, 
        ShadingType, VerticalAlign, PageNumber, PageBreak, LevelFormat } = require('docx');
const fs = require('fs');

const border = { style: BorderStyle.SINGLE, size: 1, color: "CCCCCC" };
const borders = { top: border, bottom: border, left: border, right: border };
const headerBorder = { style: BorderStyle.SINGLE, size: 1, color: "FFFFFF" };
const headerBorders = { top: headerBorder, bottom: headerBorder, left: headerBorder, right: headerBorder };

const cellMargins = { top: 80, bottom: 80, left: 120, right: 120 };

// 颜色定义
const colors = {
    primary: "667EEA",    // 主色 - 蓝紫渐变
    secondary: "764BA2",  // 副色
    accent: "F093FB",     // 强调色
    lightBg: "F8F9FC",    // 浅灰背景
    headerBg: "667EEA",   // 表头背景
    text: "2D3748",        // 正文文字
    gray: "718096",       // 灰色文字
};

// 创建文档
const doc = new Document({
    styles: {
        default: { 
            document: { 
                run: { font: "Arial", size: 24 } // 12pt = 24 half-points
            } 
        },
        paragraphStyles: [
            { 
                id: "Heading1", name: "Heading 1", basedOn: "Normal", next: "Normal", quickFormat: true,
                run: { size: 48, bold: true, font: "Arial", color: colors.primary },
                paragraph: { spacing: { before: 400, after: 200 }, outlineLevel: 0 }
            },
            { 
                id: "Heading2", name: "Heading 2", basedOn: "Normal", next: "Normal", quickFormat: true,
                run: { size: 36, bold: true, font: "Arial", color: colors.secondary },
                paragraph: { spacing: { before: 300, after: 150 }, outlineLevel: 1 }
            },
            { 
                id: "Heading3", name: "Heading 3", basedOn: "Normal", next: "Normal", quickFormat: true,
                run: { size: 28, bold: true, font: "Arial", color: colors.text },
                paragraph: { spacing: { before: 200, after: 100 }, outlineLevel: 2 }
            },
        ]
    },
    numbering: {
        config: [
            {
                reference: "bullets",
                levels: [{
                    level: 0, format: LevelFormat.BULLET, text: "\u2022", alignment: AlignmentType.LEFT,
                    style: { paragraph: { indent: { left: 720, hanging: 360 } } }
                }, {
                    level: 1, format: LevelFormat.BULLET, text: "\u25E6", alignment: AlignmentType.LEFT,
                    style: { paragraph: { indent: { left: 1080, hanging: 360 } } }
                }]
            },
            {
                reference: "numbers",
                levels: [{
                    level: 0, format: LevelFormat.DECIMAL, text: "%1.", alignment: AlignmentType.LEFT,
                    style: { paragraph: { indent: { left: 720, hanging: 360 } } }
                }]
            }
        ]
    },
    sections: [{
        properties: {
            page: {
                size: { width: 12240, height: 15840 },  // A4
                margin: { top: 1440, right: 1440, bottom: 1440, left: 1440 }
            }
        },
        headers: {
            default: new Header({
                children: [
                    new Paragraph({
                        children: [
                            new TextRun({ text: "天天系统 ERP", bold: true, color: colors.primary, size: 24 }),
                            new TextRun({ text: "    功能需求规划文档", color: colors.gray, size: 20 })
                        ],
                        border: { bottom: { style: BorderStyle.SINGLE, size: 6, color: colors.primary } }
                    })
                ]
            })
        },
        footers: {
            default: new Footer({
                children: [
                    new Paragraph({
                        children: [
                            new TextRun({ text: "第 ", color: colors.gray, size: 20 }),
                            new TextRun({ children: [PageNumber.CURRENT], color: colors.gray, size: 20 }),
                            new TextRun({ text: " 页", color: colors.gray, size: 20 }),
                            new TextRun({ text: "    天天系统 ERP - 机密文件", color: colors.gray, size: 20 })
                        ],
                        alignment: AlignmentType.CENTER,
                        border: { top: { style: BorderStyle.SINGLE, size: 6, color: colors.primary } }
                    })
                ]
            })
        },
        children: [
            // 封面
            new Paragraph({ spacing: { before: 2400 } }),
            new Paragraph({
                children: [new TextRun({ text: "天天系统 ERP", bold: true, size: 72, color: colors.primary })],
                alignment: AlignmentType.CENTER
            }),
            new Paragraph({
                children: [new TextRun({ text: "功能需求规划文档", size: 48, color: colors.text })],
                alignment: AlignmentType.CENTER,
                spacing: { before: 400 }
            }),
            new Paragraph({ spacing: { before: 1200 } }),
            new Table({
                width: { size: 5000, type: WidthType.DXA },
                columnWidths: [5000],
                alignment: AlignmentType.CENTER,
                rows: [
                    new TableRow({
                        children: [
                            new TableCell({
                                borders,
                                shading: { fill: colors.lightBg, type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [
                                    new Paragraph({ 
                                        children: [new TextRun({ text: "版本号：V1.0", size: 24, color: colors.text })],
                                        alignment: AlignmentType.CENTER,
                                        spacing: { before: 100, after: 100 }
                                    }),
                                    new Paragraph({ 
                                        children: [new TextRun({ text: "编制日期：2026年4月8日", size: 24, color: colors.text })],
                                        alignment: AlignmentType.CENTER,
                                        spacing: { before: 100, after: 100 }
                                    }),
                                    new Paragraph({ 
                                        children: [new TextRun({ text: "编制人：管理员", size: 24, color: colors.text })],
                                        alignment: AlignmentType.CENTER,
                                        spacing: { before: 100, after: 100 }
                                    }),
                                    new Paragraph({ 
                                        children: [new TextRun({ text: "状态：草稿", size: 24, color: colors.gray })],
                                        alignment: AlignmentType.CENTER,
                                        spacing: { before: 100, after: 100 }
                                    })
                                ]
                            })
                        ]
                    })
                ]
            }),
            
            // 分页
            new Paragraph({ children: [new PageBreak()] }),
            
            // 目录
            new Paragraph({ heading: HeadingLevel.HEADING_1, children: [new TextRun("目录")] }),
            new Paragraph({ spacing: { before: 200 }, children: [new TextRun("1. 项目概述")]}),
            new Paragraph({ spacing: { before: 100 }, children: [new TextRun("2. 功能模块总览")]}),
            new Paragraph({ spacing: { before: 100 }, children: [new TextRun("3. 设备管理系统")]}),
            new Paragraph({ spacing: { before: 100 }, children: [new TextRun("4. 采购管理系统")]}),
            new Paragraph({ spacing: { before: 100 }, children: [new TextRun("5. 仓储物流系统")]}),
            new Paragraph({ spacing: { before: 100 }, children: [new TextRun("6. 财务管理系统")]}),
            new Paragraph({ spacing: { before: 100 }, children: [new TextRun("7. 人力资源系统")]}),
            new Paragraph({ spacing: { before: 100 }, children: [new TextRun("8. 协同办公系统")]}),
            new Paragraph({ spacing: { before: 100 }, children: [new TextRun("9. 应用主页设计")]}),
            new Paragraph({ spacing: { before: 100 }, children: [new TextRun("10. 附录")]}),
            
            // 分页
            new Paragraph({ children: [new PageBreak()] }),
            
            // 1. 项目概述
            new Paragraph({ heading: HeadingLevel.HEADING_1, children: [new TextRun("1. 项目概述")] }),
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("1.1 项目背景")] }),
            new Paragraph({ 
                spacing: { after: 200 },
                children: [new TextRun("天天系统是一套面向中小型企业的综合管理信息系统，涵盖设备管理、采购管理、仓储物流、财务管理、人力资源和协同办公六大核心模块，旨在帮助企业实现数字化转型，提升运营效率。")]
            }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("1.2 项目目标")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("实现企业资源的一体化管理")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("优化业务流程，减少人工操作")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("提供实时数据支持决策分析")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("提升跨部门协作效率")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("降低运营成本，提高客户满意度")] }),
            
            // 分页
            new Paragraph({ children: [new PageBreak()] }),
            
            // 2. 功能模块总览
            new Paragraph({ heading: HeadingLevel.HEADING_1, children: [new TextRun("2. 功能模块总览")] }),
            new Paragraph({ spacing: { after: 200 }, children: [new TextRun("天天系统包含以下六大核心模块：")] }),
            
            // 模块总览表格
            new Table({
                width: { size: 9360, type: WidthType.DXA },
                columnWidths: [2000, 2000, 5360],
                rows: [
                    new TableRow({
                        children: [
                            new TableCell({
                                borders: headerBorders,
                                shading: { fill: colors.headerBg, type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [new Paragraph({ children: [new TextRun({ text: "模块名称", bold: true, color: "FFFFFF" })], alignment: AlignmentType.CENTER })]
                            }),
                            new TableCell({
                                borders: headerBorders,
                                shading: { fill: colors.headerBg, type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [new Paragraph({ children: [new TextRun({ text: "核心功能", bold: true, color: "FFFFFF" })], alignment: AlignmentType.CENTER })]
                            }),
                            new TableCell({
                                borders: headerBorders,
                                shading: { fill: colors.headerBg, type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [new Paragraph({ children: [new TextRun({ text: "功能描述", bold: true, color: "FFFFFF" })], alignment: AlignmentType.CENTER })]
                            })
                        ]
                    }),
                    new TableRow({
                        children: [
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun({ text: "设备管理", bold: true, color: colors.primary })] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("台账/巡检/维护")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("对生产设备进行全面管理，包括设备台账、巡检计划、维护保养等")] })] })
                        ]
                    }),
                    new TableRow({
                        children: [
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun({ text: "采购管理", bold: true, color: colors.primary })] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("需求/订单/供应商")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("管理采购全流程，从需求申请到订单执行、供应商管理")] })] })
                        ]
                    }),
                    new TableRow({
                        children: [
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun({ text: "仓储物流", bold: true, color: colors.primary })] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("入库/出库/库存")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("管理物料和成品的出入库流程，实时监控库存状态")] })] })
                        ]
                    }),
                    new TableRow({
                        children: [
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun({ text: "财务管理", bold: true, color: colors.primary })] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("总账/应收应付/报表")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("提供完整的财务核算功能，支持多种财务报表")] })] })
                        ]
                    }),
                    new TableRow({
                        children: [
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun({ text: "人力资源", bold: true, color: colors.primary })] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("组织/员工/薪酬")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("管理企业组织架构、员工档案、考勤薪酬等")] })] })
                        ]
                    }),
                    new TableRow({
                        children: [
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun({ text: "协同办公", bold: true, color: colors.primary })] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("审批/门户/知识")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("提供审批流程、企业门户、知识管理等协同功能")] })] })
                        ]
                    })
                ]
            }),
            
            // 分页
            new Paragraph({ children: [new PageBreak()] }),
            
            // 3. 设备管理系统
            new Paragraph({ heading: HeadingLevel.HEADING_1, children: [new TextRun("3. 设备管理系统")] }),
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("3.1 设备台账")] }),
            new Table({
                width: { size: 9360, type: WidthType.DXA },
                columnWidths: [3120, 6240],
                rows: [
                    new TableRow({
                        children: [
                            new TableCell({
                                borders: headerBorders,
                                shading: { fill: colors.headerBg, type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [new Paragraph({ children: [new TextRun({ text: "功能点", bold: true, color: "FFFFFF" })], alignment: AlignmentType.CENTER })]
                            }),
                            new TableCell({
                                borders: headerBorders,
                                shading: { fill: colors.headerBg, type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [new Paragraph({ children: [new TextRun({ text: "功能描述", bold: true, color: "FFFFFF" })], alignment: AlignmentType.CENTER })]
                            })
                        ]
                    }),
                    new TableRow({
                        children: [
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("设备列表")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("展示所有设备的基本信息，支持筛选、搜索、导出")] })] })
                        ]
                    }),
                    new TableRow({
                        children: [
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("设备分类")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("按类型、状态、位置等维度对设备进行分类管理")] })] })
                        ]
                    }),
                    new TableRow({
                        children: [
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("设备档案")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("记录设备的详细信息，包括技术参数、使用说明、维保记录等")] })] })
                        ]
                    })
                ]
            }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("3.2 巡检管理")] }),
            new Table({
                width: { size: 9360, type: WidthType.DXA },
                columnWidths: [3120, 6240],
                rows: [
                    new TableRow({
                        children: [
                            new TableCell({
                                borders: headerBorders,
                                shading: { fill: colors.headerBg, type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [new Paragraph({ children: [new TextRun({ text: "功能点", bold: true, color: "FFFFFF" })], alignment: AlignmentType.CENTER })]
                            }),
                            new TableCell({
                                borders: headerBorders,
                                shading: { fill: colors.headerBg, type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [new Paragraph({ children: [new TextRun({ text: "功能描述", bold: true, color: "FFFFFF" })], alignment: AlignmentType.CENTER })]
                            })
                        ]
                    }),
                    new TableRow({
                        children: [
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("巡检计划")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("制定周期性巡检计划，自动生成巡检任务")] })] })
                        ]
                    }),
                    new TableRow({
                        children: [
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("巡检任务")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("执行巡检任务，记录巡检结果和问题")] })] })
                        ]
                    }),
                    new TableRow({
                        children: [
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("巡检记录")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("查询历史巡检记录，支持追溯分析")] })] })
                        ]
                    })
                ]
            }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("3.3 维护保养")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("保养计划：制定设备保养周期和内容")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("保养任务：执行和跟踪保养工作")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("维修记录：记录设备维修历史和费用")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("3.4 统计分析")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("设备完好率统计")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("故障分析报表")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("维保成本分析")] }),
            
            // 分页
            new Paragraph({ children: [new PageBreak()] }),
            
            // 4. 采购管理系统
            new Paragraph({ heading: HeadingLevel.HEADING_1, children: [new TextRun("4. 采购管理系统")] }),
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("4.1 采购需求")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("需求申请：员工提交采购申请，包含物料、数量、用途等")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("需求审批：按流程审批采购申请")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("需求池：汇总待采购的需求，进行批量处理")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("4.2 采购订单")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("订单创建：基于审批通过的需求生成采购订单")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("订单跟踪：实时跟踪订单的执行状态")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("订单结算：与供应商进行货款结算")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("4.3 供应商管理")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("供应商档案：管理供应商的基本信息和资质")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("供应商评估：定期评估供应商的表现")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("供应商分类：按类型、等级对供应商分组管理")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("4.4 库存查询")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("实时库存：查看当前各物料的库存数量")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("库存预警：设置库存上下限，自动提醒")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("库存流水：查看物料的进出库明细")] }),
            
            // 分页
            new Paragraph({ children: [new PageBreak()] }),
            
            // 5. 仓储物流系统
            new Paragraph({ heading: HeadingLevel.HEADING_1, children: [new TextRun("5. 仓储物流系统")] }),
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("5.1 入库管理")] }),
            new Table({
                width: { size: 9360, type: WidthType.DXA },
                columnWidths: [3120, 6240],
                rows: [
                    new TableRow({
                        children: [
                            new TableCell({
                                borders: headerBorders,
                                shading: { fill: colors.headerBg, type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [new Paragraph({ children: [new TextRun({ text: "入库类型", bold: true, color: "FFFFFF" })], alignment: AlignmentType.CENTER })]
                            }),
                            new TableCell({
                                borders: headerBorders,
                                shading: { fill: colors.headerBg, type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [new Paragraph({ children: [new TextRun({ text: "说明", bold: true, color: "FFFFFF" })], alignment: AlignmentType.CENTER })]
                            })
                        ]
                    }),
                    new TableRow({
                        children: [
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("采购入库")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("采购订单到货后入库")] })] })
                        ]
                    }),
                    new TableRow({
                        children: [
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("生产入库")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("生产完工的产品入库")] })] })
                        ]
                    }),
                    new TableRow({
                        children: [
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("退货入库")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("销售退货或其他原因退货入库")] })] })
                        ]
                    })
                ]
            }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("5.2 出库管理")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("领料出库：生产部门领用物料")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("销售出库：销售订单发货出库")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("调拨出库：仓库之间调拨")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("5.3 库存管理")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("库存盘点：定期或不定期进行库存盘点")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("库存调拨：库房间物料调拨")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("库存预警：低库存提醒")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("5.4 报表统计")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("出入库明细报表")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("库存周转率分析")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("ABC分类分析")] }),
            
            // 分页
            new Paragraph({ children: [new PageBreak()] }),
            
            // 6. 财务管理系统
            new Paragraph({ heading: HeadingLevel.HEADING_1, children: [new TextRun("6. 财务管理系统")] }),
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("6.1 总账管理")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("科目设置：设置会计科目体系")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("凭证管理：录入、审核记账凭证")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("账簿查询：查询总账、明细账")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("6.2 应收应付")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("应收账款：管理客户欠款")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("应付账款：管理供应商欠款")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("收付款管理：记录收款和付款")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("6.3 报表中心")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("资产负债表")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("利润表")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("现金流量表")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("6.4 资产管理")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("固定资产：管理企业固定资产")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("资产折旧：自动计算资产折旧")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("资产盘点：定期盘点固定资产")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("6.5 出纳管理")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("银行对账：与银行流水核对")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("现金日记账：记录现金收支")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("资金计划：制定资金使用计划")] }),
            
            // 分页
            new Paragraph({ children: [new PageBreak()] }),
            
            // 7. 人力资源系统
            new Paragraph({ heading: HeadingLevel.HEADING_1, children: [new TextRun("7. 人力资源系统")] }),
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("7.1 组织管理")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("组织架构：设置公司部门结构")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("岗位管理：设置岗位和职责")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("编制管理：管理各部门编制人数")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("7.2 员工管理")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("员工档案：管理员工基本信息")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("入职离职：办理入职和离职手续")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("合同管理：管理劳动合同")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("7.3 假期管理")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("假期类型：设置假期种类")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("假期余额：管理员工假期余额")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("请假审批：处理请假申请")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("7.4 薪酬核算")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("薪资结构：设置薪资组成")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("薪资计算：根据考勤、绩效等计算薪资")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("薪资发放：生成工资条")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("7.5 工作流配置")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("审批流程：配置审批流程")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("表单设计：设计审批表单")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("流程监控：监控流程执行状态")] }),
            
            // 分页
            new Paragraph({ children: [new PageBreak()] }),
            
            // 8. 协同办公系统
            new Paragraph({ heading: HeadingLevel.HEADING_1, children: [new TextRun("8. 协同办公系统")] }),
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("8.1 企业门户")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("门户配置：配置企业门户样式和内容")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("快捷入口：设置常用功能快捷入口")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("消息中心：统一消息通知")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("8.2 知识管理")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("文档中心：集中管理企业文档")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("知识库：建立知识库体系")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("文件共享：团队文件共享")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("8.3 审批中心")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("待办事项：待处理的审批")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("已办事项：已处理完成的审批")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("我发起的：发起过的审批")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("审批设置：配置审批规则")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("8.4 费用报销")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("报销申请：提交费用报销")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("借款管理：管理员工借款")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("费用标准：设置报销标准")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("8.5 通知公告")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("公告发布：发布企业公告")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("公告管理：管理已发布的公告")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("阅读统计：统计公告阅读情况")] }),
            
            // 分页
            new Paragraph({ children: [new PageBreak()] }),
            
            // 9. 应用主页设计
            new Paragraph({ heading: HeadingLevel.HEADING_1, children: [new TextRun("9. 应用主页设计")] }),
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("9.1 工作台设计")] }),
            new Paragraph({ spacing: { after: 200 }, children: [new TextRun("应用主页（工作台）是用户登录后的第一个页面，需要展示以下内容：")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_3, children: [new TextRun("数据概览")] }),
            new Table({
                width: { size: 9360, type: WidthType.DXA },
                columnWidths: [2340, 2340, 2340, 2340],
                rows: [
                    new TableRow({
                        children: [
                            new TableCell({
                                borders: headerBorders,
                                shading: { fill: colors.primary, type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [new Paragraph({ children: [new TextRun({ text: "设备总数", bold: true, color: "FFFFFF" })], alignment: AlignmentType.CENTER })]
                            }),
                            new TableCell({
                                borders: headerBorders,
                                shading: { fill: "11998E", type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [new Paragraph({ children: [new TextRun({ text: "库存物料", bold: true, color: "FFFFFF" })], alignment: AlignmentType.CENTER })]
                            }),
                            new TableCell({
                                borders: headerBorders,
                                shading: { fill: "F5576C", type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [new Paragraph({ children: [new TextRun({ text: "待审批", bold: true, color: "FFFFFF" })], alignment: AlignmentType.CENTER })]
                            }),
                            new TableCell({
                                borders: headerBorders,
                                shading: { fill: colors.secondary, type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [new Paragraph({ children: [new TextRun({ text: "本月支出", bold: true, color: "FFFFFF" })], alignment: AlignmentType.CENTER })]
                            })
                        ]
                    })
                ]
            }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_3, children: [new TextRun("快捷入口")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("设备巡检")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("采购申请")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("入库登记")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("请假申请")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("费用报销")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("库存查询")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_3, children: [new TextRun("待办事项")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("审批类：待处理的审批单")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("任务类：待执行的巡检、保养任务")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("提醒类：库存预警、合同到期等")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_3, children: [new TextRun("应用模块")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("六大模块入口图标")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("显示各模块的关键数据")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("支持自定义模块排序")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_3, children: [new TextRun("经营概览")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("数据图表展示")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("支持切换周/月/季视图")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_3, children: [new TextRun("最新公告")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("展示最新发布的公告")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("区分公告类型（重要/普通）")] }),
            
            // 分页
            new Paragraph({ children: [new PageBreak()] }),
            
            // 10. 附录
            new Paragraph({ heading: HeadingLevel.HEADING_1, children: [new TextRun("10. 附录")] }),
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("10.1 版本历史")] }),
            new Table({
                width: { size: 9360, type: WidthType.DXA },
                columnWidths: [1500, 2000, 5860],
                rows: [
                    new TableRow({
                        children: [
                            new TableCell({
                                borders: headerBorders,
                                shading: { fill: colors.headerBg, type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [new Paragraph({ children: [new TextRun({ text: "版本", bold: true, color: "FFFFFF" })], alignment: AlignmentType.CENTER })]
                            }),
                            new TableCell({
                                borders: headerBorders,
                                shading: { fill: colors.headerBg, type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [new Paragraph({ children: [new TextRun({ text: "日期", bold: true, color: "FFFFFF" })], alignment: AlignmentType.CENTER })]
                            }),
                            new TableCell({
                                borders: headerBorders,
                                shading: { fill: colors.headerBg, type: ShadingType.CLEAR },
                                margins: cellMargins,
                                children: [new Paragraph({ children: [new TextRun({ text: "说明", bold: true, color: "FFFFFF" })], alignment: AlignmentType.CENTER })]
                            })
                        ]
                    }),
                    new TableRow({
                        children: [
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("V1.0")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("2026-04-08")] })] }),
                            new TableCell({ borders, margins: cellMargins, children: [new Paragraph({ children: [new TextRun("初始版本")] })] })
                        ]
                    })
                ]
            }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("10.2 参考资料")] }),
            new Paragraph({ numbering: { reference: "numbers", level: 0 }, children: [new TextRun("《企业资源规划（ERP）系统设计规范》")] }),
            new Paragraph({ numbering: { reference: "numbers", level: 0 }, children: [new TextRun("《天天系统技术架构文档》")] }),
            new Paragraph({ numbering: { reference: "numbers", level: 0 }, children: [new TextRun("《UI/UX设计规范》")] }),
            
            new Paragraph({ heading: HeadingLevel.HEADING_2, children: [new TextRun("10.3 联系方式")] }),
            new Paragraph({ spacing: { after: 100 }, children: [new TextRun("如有疑问，请联系系统开发团队：")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("邮箱：support@tiantian.com")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("电话：400-888-8888")] }),
            new Paragraph({ numbering: { reference: "bullets", level: 0 }, children: [new TextRun("地址：XX市XX区XX路XX号")] }),
        ]
    }]
});

// 生成文件
Packer.toBuffer(doc).then(buffer => {
    fs.writeFileSync('/Users/gxwebsoft/VUE/tiantian-system/docs/规划文档/天天系统功能需求规划.docx', buffer);
    console.log('文档生成成功！');
}).catch(err => {
    console.error('生成失败：', err);
});
