@silly_yi/easyprint-designer 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -0
- package/dist/chunk-LOROXNH3.mjs +41 -0
- package/dist/chunk-LOROXNH3.mjs.map +1 -0
- package/dist/chunk-SL6FLXZG.mjs +14 -0
- package/dist/chunk-SL6FLXZG.mjs.map +1 -0
- package/dist/html2canvas-MYFAOOCT.mjs +7813 -0
- package/dist/html2canvas-MYFAOOCT.mjs.map +1 -0
- package/dist/index.d.mts +386 -0
- package/dist/index.d.ts +386 -0
- package/dist/index.es-3SSZWNCG.mjs +10515 -0
- package/dist/index.es-3SSZWNCG.mjs.map +1 -0
- package/dist/index.global.js +47014 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +47006 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +27569 -0
- package/dist/index.mjs.map +1 -0
- package/dist/purify.es-AJQYKX7Y.mjs +1038 -0
- package/dist/purify.es-AJQYKX7Y.mjs.map +1 -0
- package/package.json +39 -0
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# EasyPrint Designer
|
|
2
|
+
|
|
3
|
+
EasyPrint Designer 是一个轻量级、高性能的 Web 端报表设计器与打印生成器。它基于 HTML5 Canvas 和 jQuery 构建,不依赖任何重型框架,可以轻松集成到任何 Web 项目中(如 React, Vue, Angular 或原生 JS)。
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
## 功能特性
|
|
9
|
+
|
|
10
|
+
- 🎨 **可视化设计器**:直观的拖拽式界面,所见即所得的设计体验。
|
|
11
|
+
- 📄 **丰富组件**:支持文本、矩形、直线、图片、条形码、二维码等基础组件。
|
|
12
|
+
- 📊 **高级表格**:
|
|
13
|
+
- 支持动态数据行绑定。
|
|
14
|
+
- **自动分页**:表格内容超出页面高度时,自动切割并延伸至下一页。
|
|
15
|
+
- **自动合计**:可配置指定列自动计算总和,并在底部追加合计行。
|
|
16
|
+
- 跨页表头自动重复。
|
|
17
|
+
- 🔢 **页面管理**:支持自定义纸张尺寸(A4, A3 等)、页边距设置以及自动页码生成。
|
|
18
|
+
- 🔌 **数据绑定**:强大的 JavaScript 动态渲染函数支持(类似 `{{ data.field }}` 的逻辑,但更灵活)。
|
|
19
|
+
- 🖨️ **高质量导出**:
|
|
20
|
+
- **PDF**:原生支持生成多页 PDF 文档。
|
|
21
|
+
- **图片**:支持导出高清(Retina 适配)JPG/PNG 图片(多页报表自动打包为 ZIP)。
|
|
22
|
+
- 📦 **零重依赖**:体积小巧,无框架运行时依赖。
|
|
23
|
+
|
|
24
|
+
## 安装
|
|
25
|
+
|
|
26
|
+
### 使用 NPM
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install @silly_yi/easyprint-designer
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## 使用指南
|
|
34
|
+
|
|
35
|
+
### 1. 引入设计器 (Designer)
|
|
36
|
+
|
|
37
|
+
集成设计器,允许用户进行模板编辑。
|
|
38
|
+
|
|
39
|
+
```html
|
|
40
|
+
<div id="designer-container" style="height: 100vh;"></div>
|
|
41
|
+
|
|
42
|
+
<script type="module">
|
|
43
|
+
import { create } from 'easyprint-designer';
|
|
44
|
+
// 样式会自动注入,无需手动引入 CSS!
|
|
45
|
+
|
|
46
|
+
const designer = create(document.getElementById('designer-container'), {
|
|
47
|
+
// 可选的初始化参数
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// 加载已有配置
|
|
51
|
+
designer.setConfig({
|
|
52
|
+
page: { widthMm: 210, heightMm: 297, paper: "A4" },
|
|
53
|
+
elements: []
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// 获取当前配置用于保存
|
|
57
|
+
const config = designer.getConfig();
|
|
58
|
+
console.log(config);
|
|
59
|
+
</script>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
如果使用全局脚本(script 标签):
|
|
63
|
+
|
|
64
|
+
```html
|
|
65
|
+
<script>
|
|
66
|
+
const designer = EasyPrintDesigner.create(document.getElementById('designer-container'));
|
|
67
|
+
</script>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 2. 引入预览器 (Previewer)
|
|
71
|
+
|
|
72
|
+
使用真实数据渲染报表。
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<div id="preview-container"></div>
|
|
76
|
+
|
|
77
|
+
<script type="module">
|
|
78
|
+
import { preview } from 'easyprint-designer';
|
|
79
|
+
|
|
80
|
+
const templateConfig = { ... }; // 从数据库加载的模板配置
|
|
81
|
+
const reportData = {
|
|
82
|
+
orderNo: "ORD-123",
|
|
83
|
+
items: [{ name: "商品 A", price: 100 }, { name: "商品 B", price: 200 }]
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const previewer = preview(document.getElementById('preview-container'), templateConfig, {
|
|
87
|
+
data: reportData
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// 导出操作
|
|
91
|
+
// previewer.exportPDF("report.pdf");
|
|
92
|
+
// previewer.exportJPG("report.jpg"); // 如果有多页,会自动下载 ZIP 包
|
|
93
|
+
</script>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## 数据绑定说明
|
|
97
|
+
|
|
98
|
+
所有组件都支持通过 `renderFn` 属性进行动态渲染。这是一个字符串形式的 JavaScript 函数体。
|
|
99
|
+
|
|
100
|
+
**可用变量:**
|
|
101
|
+
- `data`: 传递给预览器的完整数据对象。
|
|
102
|
+
- `rowIndex`: (仅表格) 当前行的索引。
|
|
103
|
+
- `rowItem`: (仅表格) 当前行的数据对象。
|
|
104
|
+
|
|
105
|
+
**示例:**
|
|
106
|
+
|
|
107
|
+
* **文本组件**:
|
|
108
|
+
```javascript
|
|
109
|
+
return "订单号: " + data.orderNo;
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
* **表格单元格**:
|
|
113
|
+
```javascript
|
|
114
|
+
return rowItem.price.toFixed(2);
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
* **条形码/二维码**:
|
|
118
|
+
```javascript
|
|
119
|
+
return data.trackingCode;
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## 开发
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# 安装依赖
|
|
126
|
+
npm install
|
|
127
|
+
|
|
128
|
+
# 启动开发服务器
|
|
129
|
+
npm run dev
|
|
130
|
+
|
|
131
|
+
# 构建生产版本
|
|
132
|
+
npm run build
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## 开源协议
|
|
136
|
+
|
|
137
|
+
MIT
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
9
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
10
|
+
}) : x)(function(x) {
|
|
11
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
12
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
+
});
|
|
14
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
33
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
__require,
|
|
37
|
+
__commonJS,
|
|
38
|
+
__toESM,
|
|
39
|
+
__publicField
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=chunk-LOROXNH3.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// node_modules/@babel/runtime/helpers/esm/typeof.js
|
|
2
|
+
function _typeof(o) {
|
|
3
|
+
"@babel/helpers - typeof";
|
|
4
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
|
|
5
|
+
return typeof o2;
|
|
6
|
+
} : function(o2) {
|
|
7
|
+
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
|
|
8
|
+
}, _typeof(o);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
_typeof
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=chunk-SL6FLXZG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../node_modules/@babel/runtime/helpers/esm/typeof.js"],"sourcesContent":["function _typeof(o) {\n \"@babel/helpers - typeof\";\n\n return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) {\n return typeof o;\n } : function (o) {\n return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o;\n }, _typeof(o);\n}\nexport { _typeof as default };"],"mappings":";AAAA,SAAS,QAAQ,GAAG;AAClB;AAEA,SAAO,UAAU,cAAc,OAAO,UAAU,YAAY,OAAO,OAAO,WAAW,SAAUA,IAAG;AAChG,WAAO,OAAOA;AAAA,EAChB,IAAI,SAAUA,IAAG;AACf,WAAOA,MAAK,cAAc,OAAO,UAAUA,GAAE,gBAAgB,UAAUA,OAAM,OAAO,YAAY,WAAW,OAAOA;AAAA,EACpH,GAAG,QAAQ,CAAC;AACd;","names":["o"]}
|