# heiien/mes-print-plugin architecture

> Architecture diagram of the GitHub repository heiien/mes-print-plugin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/heiien/mes-print-plugin
- Repository: https://github.com/heiien/mes-print-plugin

## Overview

MES 排版打印是飞书多维表格侧边栏插件：用户选择计划单记录，插件读取主表及关联明细、日报，生成可配置的 A4 预览，再调用浏览器打印对话框导出或打印。运行逻辑集中在 src/main.js；演示数据来自 src/demo-data.js。README 说明了方向、字号和签名配置，但节选未展示其具体事件处理，故不推断其内部连线。

Main entry points: [`src/main.js`](https://github.com/heiien/mes-print-plugin/blob/main/src/main.js) (A4 预览生成), [`src/demo-data.js`](https://github.com/heiien/mes-print-plugin/blob/main/src/demo-data.js) (模拟数据集)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_selection["记录选择"]
  node_main["应用初始化<br/>[main.js]"]
  node_environment["环境检测<br/>[main.js]"]
  node_table_picker["表与记录选择<br/>[main.js]"]
end

subgraph group_records["数据读取"]
  node_table_service[("飞书多维表格")]
  node_demo_data[("模拟数据集<br/>[demo-data.js]")]
  node_record_reader["主记录读取<br/>[main.js]"]
  node_link_expander["关联记录展开<br/>[main.js]"]
end

subgraph group_preview["排版与打印"]
  node_preview_renderer["A4 预览生成<br/>[main.js]"]
  node_layout_options["版式配置<br/>[main.js]"]
  node_print_action["打印与 PDF<br/>[main.js]"]
end

node_user(("插件用户"))
node_browser_print["浏览器打印"]

node_user -->|"打开插件"| node_main
node_main -->|"检测环境"| node_environment
node_environment -->|"查询表元数据"| node_table_service
node_environment -.->|"使用模拟数据"| node_demo_data
node_main -->|"加载表与记录"| node_table_picker
node_table_picker -->|"读取字段记录"| node_table_service
node_table_picker -.->|"读取模拟记录"| node_demo_data
node_user -->|"选择记录"| node_table_picker
node_user -->|"请求预览"| node_preview_renderer
node_preview_renderer -->|"读取主记录"| node_record_reader
node_record_reader -->|"获取记录字段"| node_table_service
node_record_reader -.->|"读取模拟字段"| node_demo_data
node_preview_renderer -->|"展开关联字段"| node_link_expander
node_link_expander -->|"读取关联记录"| node_table_service
node_link_expander -.->|"读取模拟关联项"| node_demo_data
node_user -->|"调整版式"| node_layout_options
node_preview_renderer -->|"应用版式"| node_layout_options
node_user -->|"打印或导出"| node_print_action
node_print_action -->|"调用打印对话框"| node_browser_print

click node_main "https://github.com/heiien/mes-print-plugin/blob/main/src/main.js"
click node_environment "https://github.com/heiien/mes-print-plugin/blob/main/src/main.js"
click node_table_picker "https://github.com/heiien/mes-print-plugin/blob/main/src/main.js"
click node_demo_data "https://github.com/heiien/mes-print-plugin/blob/main/src/demo-data.js"
click node_record_reader "https://github.com/heiien/mes-print-plugin/blob/main/src/main.js"
click node_link_expander "https://github.com/heiien/mes-print-plugin/blob/main/src/main.js"
click node_preview_renderer "https://github.com/heiien/mes-print-plugin/blob/main/src/main.js"
click node_layout_options "https://github.com/heiien/mes-print-plugin/blob/main/src/main.js"
click node_print_action "https://github.com/heiien/mes-print-plugin/blob/main/src/main.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_environment,node_table_picker toneBlue
class node_table_service,node_demo_data,node_record_reader,node_link_expander toneAmber
class node_preview_renderer,node_layout_options,node_print_action toneMint
class node_user,node_browser_print toneIndigo
```

## Components

### 记录选择

- [应用初始化](https://github.com/heiien/mes-print-plugin/blob/main/src/main.js): `src/main.js`
- [环境检测](https://github.com/heiien/mes-print-plugin/blob/main/src/main.js): `src/main.js`
- [表与记录选择](https://github.com/heiien/mes-print-plugin/blob/main/src/main.js): `src/main.js`

### 数据读取

- **飞书多维表格**
- [模拟数据集](https://github.com/heiien/mes-print-plugin/blob/main/src/demo-data.js): `src/demo-data.js`
- [主记录读取](https://github.com/heiien/mes-print-plugin/blob/main/src/main.js): `src/main.js`
- [关联记录展开](https://github.com/heiien/mes-print-plugin/blob/main/src/main.js): `src/main.js`

### 排版与打印

- [A4 预览生成](https://github.com/heiien/mes-print-plugin/blob/main/src/main.js): `src/main.js`
- [版式配置](https://github.com/heiien/mes-print-plugin/blob/main/src/main.js): `src/main.js`
- [打印与 PDF](https://github.com/heiien/mes-print-plugin/blob/main/src/main.js): `src/main.js`

### Other components

- **插件用户**
- **浏览器打印**

## Connections

- 插件用户 → 应用初始化: 打开插件
- 应用初始化 → 环境检测: 检测环境
- 环境检测 → 飞书多维表格: 查询表元数据
- 环境检测 → 模拟数据集: 使用模拟数据
- 应用初始化 → 表与记录选择: 加载表与记录
- 表与记录选择 → 飞书多维表格: 读取字段记录
- 表与记录选择 → 模拟数据集: 读取模拟记录
- 插件用户 → 表与记录选择: 选择记录
- 插件用户 → A4 预览生成: 请求预览
- A4 预览生成 → 主记录读取: 读取主记录
- 主记录读取 → 飞书多维表格: 获取记录字段
- 主记录读取 → 模拟数据集: 读取模拟字段
- A4 预览生成 → 关联记录展开: 展开关联字段
- 关联记录展开 → 飞书多维表格: 读取关联记录
- 关联记录展开 → 模拟数据集: 读取模拟关联项
- 插件用户 → 版式配置: 调整版式
- A4 预览生成 → 版式配置: 应用版式
- 插件用户 → 打印与 PDF: 打印或导出
- 打印与 PDF → 浏览器打印: 调用打印对话框
