gm-printer 10.27.2 → 10.27.3-beta.1
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/.eslintcache +1 -0
- package/README.md +77 -56
- package/assets/image-20230509125111428.png +0 -0
- package/assets/image-20230509125629476.png +0 -0
- package/assets/image-20230509125812166.png +0 -0
- package/assets/image-20230509125922115.png +0 -0
- package/assets/image-20230509130332523.png +0 -0
- package/package.json +1 -1
- package/src/common/editor_select.js +26 -2
- package/src/common/editor_store.js +6 -1
- package/src/printer/printer.js +4 -3
- package/build/demo.js +0 -54
- package/build/index.html +0 -1
package/.eslintcache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"/Users/joke/work_code/gm-printer/src/printer/table.js":"1","/Users/joke/work_code/gm-printer/src/printer/store.js":"2","/Users/joke/work_code/gm-printer/src/printer/table_subtotal_tr.js":"3","/Users/joke/work_code/gm-printer/src/common/util.js":"4","/Users/joke/work_code/gm-printer/src/common/editor_store.js":"5","/Users/joke/work_code/gm-printer/src/common/editor_edit_field.js":"6"},{"size":10861,"mtime":1722841015622},{"size":18403,"mtime":1709723362583,"results":"7","hashOfConfig":"8"},{"size":6329,"mtime":1722840447954,"results":"9","hashOfConfig":"10"},{"size":648,"mtime":1722840447954,"results":"11","hashOfConfig":"10"},{"size":49196,"mtime":1722840447953,"results":"12","hashOfConfig":"10"},{"size":23532,"mtime":1722840447952,"results":"13","hashOfConfig":"10"},{"filePath":"14","messages":"15","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1akqze6",{"filePath":"16","messages":"17","errorCount":1,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"12qfxi0",{"filePath":"18","messages":"19","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"20","messages":"21","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"22","messages":"23","errorCount":1,"warningCount":5,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"/Users/joke/work_code/gm-printer/src/printer/store.js",[],"/Users/joke/work_code/gm-printer/src/printer/table_subtotal_tr.js",["24"],"/Users/joke/work_code/gm-printer/src/common/util.js",[],"/Users/joke/work_code/gm-printer/src/common/editor_store.js",[],"/Users/joke/work_code/gm-printer/src/common/editor_edit_field.js",["25","26","27","28","29","30"],{"ruleId":"31","severity":2,"message":"32","line":49,"column":9,"nodeType":"33","endLine":49,"endColumn":16},{"ruleId":"34","severity":1,"message":"35","line":344,"column":13,"nodeType":"36","endLine":344,"endColumn":49},{"ruleId":"34","severity":1,"message":"35","line":362,"column":13,"nodeType":"36","endLine":362,"endColumn":56},{"ruleId":"34","severity":1,"message":"35","line":528,"column":15,"nodeType":"36","endLine":528,"endColumn":53},{"ruleId":"34","severity":1,"message":"35","line":595,"column":11,"nodeType":"36","endLine":595,"endColumn":53},{"ruleId":"34","severity":1,"message":"35","line":645,"column":19,"nodeType":"36","endLine":645,"endColumn":64},{"ruleId":"37","severity":2,"message":"38","line":712,"column":22,"nodeType":"39","messageId":"40","endLine":712,"endColumn":31},"no-unused-vars","'sumData' is assigned a value but never used.","Identifier","react/jsx-handler-names","Handler function for onChange prop key must begin with 'handle'","JSXAttribute","gmfe/i18n-check","t函数的key只能为字符串常量(Literal),请使用单引号或双引号包裹","MemberExpression","isVariable"]
|
package/README.md
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
# gm-printer
|
|
2
|
-
|
|
3
|
-
gm-printer是一个实现开发者自定义网页打印的人类高质量开源库,你可以根据业务需要自定义打印字段配置(<a href='#template_config'>配置详情</a>),完成高质量网页打印功能。
|
|
4
|
-
|
|
1
|
+
# gm-printer
|
|
2
|
+
|
|
3
|
+
gm-printer 是一个实现开发者自定义网页打印的人类高质量开源库,你可以根据业务需要自定义打印字段配置(<a href='#template_config'>配置详情</a>),完成高质量网页打印功能。
|
|
5
4
|
|
|
6
5
|
## <div id='development'>开发指南</div>
|
|
6
|
+
|
|
7
7
|
以下操作将帮助你在本地机器上安装和运行该项目,进行开发
|
|
8
|
+
|
|
8
9
|
```bash
|
|
9
10
|
# 先安装依赖
|
|
10
11
|
yarn
|
|
11
12
|
# 项目启动
|
|
12
13
|
yarn start
|
|
13
14
|
# 项目构建(基本不怎么使用)
|
|
14
|
-
yarn build
|
|
15
|
+
yarn build
|
|
15
16
|
```
|
|
17
|
+
|
|
16
18
|
## <div id='usage'>安装使用指南</div>
|
|
19
|
+
|
|
17
20
|
```bash
|
|
18
21
|
# npm
|
|
19
22
|
npm i gm-printer
|
|
@@ -22,9 +25,10 @@ yarn add gm-printer
|
|
|
22
25
|
```
|
|
23
26
|
|
|
24
27
|
## <div id='simple_categroy'>配置目录简述</div>
|
|
28
|
+
|
|
25
29
|
```bash
|
|
26
30
|
├── src
|
|
27
|
-
│ ├── index.js
|
|
31
|
+
│ ├── index.js
|
|
28
32
|
│ ├── add_fields # 右侧对应的字段配置
|
|
29
33
|
│ ├── data_to_key # 原始数据转换成打印数据
|
|
30
34
|
│ ├── mock_data # 模拟数据
|
|
@@ -35,55 +39,60 @@ yarn add gm-printer
|
|
|
35
39
|
```
|
|
36
40
|
|
|
37
41
|
## 版本管理
|
|
38
|
-
所有的版本都有 3 个数字:x.y.z。
|
|
39
|
-
* 第一个数字是主版本。
|
|
40
|
-
* 第二个数字是次版本。
|
|
41
|
-
* 第三个数字是补丁版本。
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
所有的版本都有 3 个数字:x.y.z。
|
|
44
|
+
|
|
45
|
+
- 第一个数字是主版本。
|
|
46
|
+
- 第二个数字是次版本。
|
|
47
|
+
- 第三个数字是补丁版本。
|
|
48
|
+
|
|
49
|
+
当发布新的版本时,不仅仅是随心所欲地增加数字,还要遵循以下规则:
|
|
50
|
+
|
|
51
|
+
- 当进行不兼容的 API 更改时,则升级主版本。
|
|
52
|
+
- 当以向后兼容的方式添加功能时,则升级次版本。
|
|
53
|
+
- 当进行向后兼容的缺陷修复时,则升级补丁版本。
|
|
47
54
|
|
|
48
55
|
该约定在所有编程语言中均被采用,每个 npm 软件包都必须遵守该约定,这一点非常重要,因为整个系统都依赖于此。
|
|
49
56
|
|
|
50
|
-
## 版本发布
|
|
51
|
-
一般版本发布分为如下几个版:
|
|
52
|
-
* 内测版本(alpha)
|
|
53
|
-
* 公测版本(beta)
|
|
54
|
-
* 正式版本的候选版本(rc: release candiate)
|
|
55
|
-
* 正式版本
|
|
57
|
+
## 版本发布
|
|
56
58
|
|
|
57
|
-
|
|
59
|
+
gm-printer 是一个单独的打印库,使用 github action 发布版本
|
|
58
60
|
|
|
59
|
-
|
|
60
|
-
* 发布重大版本或版本改动较大时,先发布alpha、beta、rc等先行版本。
|
|
61
|
-
* 将`pageage.json`中的`version`修改为`X.X.X-beta.0`,或者运行 `npm version X.X.X-beta.0`来更新`package.json`,同时创建一个 git 标签[参考](https://docs.npmjs.com/cli/version)。
|
|
62
|
-
```bash
|
|
63
|
-
npm login # 输入用户名和密码
|
|
61
|
+
1. beta 版本包的版本发布(在自己的 feature|fix 分支),执行 yarn release 后选择 beta 版本
|
|
64
62
|
|
|
65
|
-
|
|
66
|
-
npm publish --tag (alpha | beta)
|
|
63
|
+

|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
2. 正式版本的发布
|
|
66
|
+
|
|
67
|
+
1. 提 pr 到 master
|
|
68
|
+
2. 切换到 master,之后执行 yarn release 选择正式版本(注意 minor 和 patch 的区别)
|
|
69
|
+
|
|
70
|
+
3. 选择后版本后再输入 y,会自动生成 tag 和 push,触发 github action 的 release.yml,且生成 changelog
|
|
71
71
|
|
|
72
|
+

|
|
73
|
+
|
|
74
|
+

|
|
75
|
+
|
|
76
|
+
自此自动发包完成!
|
|
72
77
|
上述操作在自己的分支上进行发布版本即可,发完后,将分支合并到 master 上!!!
|
|
73
78
|
|
|
74
79
|
## <div id='template_config'>模板文件(template_config)</div>
|
|
75
|
-
|
|
80
|
+
|
|
81
|
+
config 主要是有下面 6 大部分组成
|
|
82
|
+
|
|
76
83
|
```js
|
|
77
84
|
export default {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
85
|
+
name: '模板名称', // 模板名称
|
|
86
|
+
page: {}, // 模板整体的配置信息
|
|
87
|
+
header: {}, // 页眉(每页都会渲染)
|
|
88
|
+
contents: {}, // 主要内容(contents只渲染一次!第一页放不下,会顺延到次页继续渲染,直至全部渲染)
|
|
89
|
+
sign: {}, // 签名(只在最后一页渲染)
|
|
90
|
+
footer: {} // 页脚(每页都会渲染)
|
|
84
91
|
}
|
|
85
92
|
```
|
|
93
|
+
|
|
86
94
|
一个简单模板配置如下
|
|
95
|
+
|
|
87
96
|
```js
|
|
88
97
|
export default {
|
|
89
98
|
name: '模板名称',
|
|
@@ -95,18 +104,22 @@ export default {
|
|
|
95
104
|
height: '297mm' // 纸张高度
|
|
96
105
|
},
|
|
97
106
|
printDirection: 'vertical', // 打印布局方向(两种: vertical, horizontal)
|
|
98
|
-
gap: {
|
|
107
|
+
gap: {
|
|
108
|
+
// 纸张内边距
|
|
99
109
|
paddingRight: '5mm',
|
|
100
110
|
paddingLeft: '5mm',
|
|
101
111
|
paddingBottom: '5mm',
|
|
102
112
|
paddingTop: '5mm'
|
|
103
113
|
}
|
|
104
114
|
},
|
|
105
|
-
header: {
|
|
106
|
-
|
|
115
|
+
header: {
|
|
116
|
+
// 页眉
|
|
117
|
+
blocks: [
|
|
118
|
+
// blocks数组,里面元素
|
|
107
119
|
{
|
|
108
120
|
text: '收货人: {{收货人}}', // 文本块
|
|
109
|
-
style: {
|
|
121
|
+
style: {
|
|
122
|
+
// 文本块样式
|
|
110
123
|
right: '',
|
|
111
124
|
left: '450px',
|
|
112
125
|
position: 'absolute',
|
|
@@ -114,15 +127,17 @@ export default {
|
|
|
114
127
|
}
|
|
115
128
|
}
|
|
116
129
|
],
|
|
117
|
-
style: {
|
|
130
|
+
style: {
|
|
131
|
+
// header 的样式
|
|
118
132
|
height: '97px'
|
|
119
133
|
}
|
|
120
134
|
},
|
|
121
|
-
contents: [
|
|
135
|
+
contents: [
|
|
136
|
+
// contents数组,元素是object.
|
|
122
137
|
{
|
|
123
138
|
blocks: [
|
|
124
139
|
{
|
|
125
|
-
text: '收货人: {{收货人}}',
|
|
140
|
+
text: '收货人: {{收货人}}', // 模板字符串用{{}}表示
|
|
126
141
|
style: {
|
|
127
142
|
right: '',
|
|
128
143
|
left: '450px',
|
|
@@ -136,27 +151,32 @@ export default {
|
|
|
136
151
|
}
|
|
137
152
|
},
|
|
138
153
|
{
|
|
139
|
-
className: '',
|
|
140
|
-
type: 'table',
|
|
141
|
-
dataKey: 'orders_category',
|
|
142
|
-
subtotal: {
|
|
154
|
+
className: '',
|
|
155
|
+
type: 'table', // type 表明是table
|
|
156
|
+
dataKey: 'orders_category', // table的接受哪些数据. dataKey详细看下文
|
|
157
|
+
subtotal: {
|
|
158
|
+
// 是否显示table每页合计
|
|
143
159
|
show: false
|
|
144
160
|
},
|
|
145
|
-
columns: [
|
|
161
|
+
columns: [
|
|
162
|
+
// 表单列配置
|
|
146
163
|
{
|
|
147
164
|
head: '序号',
|
|
148
|
-
headStyle: {
|
|
165
|
+
headStyle: {
|
|
166
|
+
// 表头样式
|
|
149
167
|
textAlign: 'center'
|
|
150
168
|
},
|
|
151
|
-
style: {
|
|
169
|
+
style: {
|
|
170
|
+
// 表格样式
|
|
152
171
|
textAlign: 'center'
|
|
153
172
|
},
|
|
154
|
-
text: '{{列.序号}}'
|
|
173
|
+
text: '{{列.序号}}' // 表格内容
|
|
155
174
|
}
|
|
156
175
|
]
|
|
157
176
|
}
|
|
158
177
|
],
|
|
159
|
-
sign: {
|
|
178
|
+
sign: {
|
|
179
|
+
// 签名(只在最后一页打印)
|
|
160
180
|
blocks: [
|
|
161
181
|
{
|
|
162
182
|
text: '签收人:',
|
|
@@ -171,7 +191,8 @@ export default {
|
|
|
171
191
|
height: '46px'
|
|
172
192
|
}
|
|
173
193
|
},
|
|
174
|
-
footer: {
|
|
194
|
+
footer: {
|
|
195
|
+
// 页脚
|
|
175
196
|
blocks: [
|
|
176
197
|
{
|
|
177
198
|
text: '页码: {{当前页码}} / {{页码总数}}',
|
|
@@ -201,6 +222,7 @@ export default {
|
|
|
201
222
|
```
|
|
202
223
|
|
|
203
224
|
## data 数据
|
|
225
|
+
|
|
204
226
|
```json
|
|
205
227
|
{
|
|
206
228
|
common: object, // 非表格数据
|
|
@@ -228,4 +250,3 @@ contents.panel.0.block.0 //区域块的每一个块
|
|
|
228
250
|
contents.table.0 //区域表格
|
|
229
251
|
contents.table.0.column.0 // 区域表格的每一个表格
|
|
230
252
|
```
|
|
231
|
-
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -2,6 +2,10 @@ import i18next from '../../locales'
|
|
|
2
2
|
import React from 'react'
|
|
3
3
|
import { observer, inject } from 'mobx-react'
|
|
4
4
|
import { Flex, Option, Select } from '../components'
|
|
5
|
+
import {
|
|
6
|
+
RadioGroup,
|
|
7
|
+
Radio,
|
|
8
|
+
} from '@gmfe/react'
|
|
5
9
|
import { InputWithUnit } from '../common/component'
|
|
6
10
|
import { pageTypeMap, printDirectionList } from '../config'
|
|
7
11
|
import _ from 'lodash'
|
|
@@ -15,6 +19,10 @@ class EditorSelector extends React.Component {
|
|
|
15
19
|
this.props.editStore.setConfigName(e.target.value)
|
|
16
20
|
}
|
|
17
21
|
|
|
22
|
+
handleConfigIsFixLastFooter = (_val) => {
|
|
23
|
+
this.props.editStore.setConfigIsFixLastFooter(_val)
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
handlePageType = value => {
|
|
19
27
|
this.props.editStore.setSizePageType(value)
|
|
20
28
|
}
|
|
@@ -37,13 +45,13 @@ class EditorSelector extends React.Component {
|
|
|
37
45
|
|
|
38
46
|
render() {
|
|
39
47
|
const {
|
|
40
|
-
config: { name, page, batchPrintConfig },
|
|
48
|
+
config: { name, page, batchPrintConfig, isFixLastFooter, showDiyOverAllOrder },
|
|
41
49
|
computedRegionList,
|
|
42
50
|
computedSelectedRegionTip,
|
|
43
51
|
selectedRegion
|
|
44
52
|
} = this.props.editStore
|
|
45
53
|
const isDIY = page.type === 'DIY'
|
|
46
|
-
|
|
54
|
+
|
|
47
55
|
return (
|
|
48
56
|
<div>
|
|
49
57
|
<Flex alignCenter>
|
|
@@ -149,6 +157,22 @@ class EditorSelector extends React.Component {
|
|
|
149
157
|
</>
|
|
150
158
|
)}
|
|
151
159
|
|
|
160
|
+
{
|
|
161
|
+
showDiyOverAllOrder !== undefined && <Flex alignCenter className='gm-padding-top-5'>
|
|
162
|
+
<label htmlFor={1}>{'是否固定末页签名和页脚区域:'}</label>
|
|
163
|
+
<RadioGroup
|
|
164
|
+
name='isFixFooter'
|
|
165
|
+
value={isFixLastFooter}
|
|
166
|
+
inline
|
|
167
|
+
onChange={this.handleConfigIsFixLastFooter}
|
|
168
|
+
className="gm-flex"
|
|
169
|
+
>
|
|
170
|
+
<Radio value={true} style={{ display: 'flex', marginRight: 10}}><span style={{ marginLeft: 5}}>是</span></Radio>
|
|
171
|
+
<Radio value={false} style={{ display: 'flex'}}><span style={{ marginLeft: 5}}>否</span></Radio>
|
|
172
|
+
</RadioGroup>
|
|
173
|
+
</Flex>
|
|
174
|
+
}
|
|
175
|
+
|
|
152
176
|
<Flex className='gm-padding-top-5 gm-text-red' column>
|
|
153
177
|
{computedSelectedRegionTip}
|
|
154
178
|
</Flex>
|
|
@@ -217,7 +217,7 @@ class EditorStore {
|
|
|
217
217
|
@action
|
|
218
218
|
init(config, data) {
|
|
219
219
|
// batchPrintConfig: 1 不连续打印(一张采购单不出现多供应商)2 连续打印(一张采购单可能出现多个供应商)
|
|
220
|
-
this.config = Object.assign({ batchPrintConfig: 1 }, config)
|
|
220
|
+
this.config = Object.assign({ batchPrintConfig: 1, isFixLastFooter: false }, config)
|
|
221
221
|
this.originConfig = config
|
|
222
222
|
this.selected = null
|
|
223
223
|
this.selectedRegion = null
|
|
@@ -247,6 +247,11 @@ class EditorStore {
|
|
|
247
247
|
this.config.name = name
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
@action
|
|
251
|
+
setConfigIsFixLastFooter(_value) {
|
|
252
|
+
this.config.isFixLastFooter = _value
|
|
253
|
+
}
|
|
254
|
+
|
|
250
255
|
@action.bound
|
|
251
256
|
setPageSize(field, value) {
|
|
252
257
|
this.config.page.size[field] = value
|
package/src/printer/printer.js
CHANGED
|
@@ -20,7 +20,7 @@ const Sign = props => (
|
|
|
20
20
|
{...props}
|
|
21
21
|
style={{
|
|
22
22
|
...props.style,
|
|
23
|
-
position: 'absolute',
|
|
23
|
+
position: props?.flag ? 'relative' : 'absolute',
|
|
24
24
|
left: 0,
|
|
25
25
|
right: 0
|
|
26
26
|
}}
|
|
@@ -38,7 +38,7 @@ const Footer = props => (
|
|
|
38
38
|
{...props}
|
|
39
39
|
style={{
|
|
40
40
|
...props.style,
|
|
41
|
-
position: 'absolute',
|
|
41
|
+
position: props?.flag ? 'relative' : 'absolute',
|
|
42
42
|
bottom: 0,
|
|
43
43
|
left: 0,
|
|
44
44
|
right: 0
|
|
@@ -223,9 +223,10 @@ class Printer extends React.Component {
|
|
|
223
223
|
config={config.sign}
|
|
224
224
|
pageIndex={i}
|
|
225
225
|
style={{ bottom: config.footer.style.height }}
|
|
226
|
+
flag={isLastPage && config?.isFixLastFooter}
|
|
226
227
|
/>
|
|
227
228
|
)}
|
|
228
|
-
<Footer config={config.footer} pageIndex={i} />
|
|
229
|
+
<Footer config={config.footer} pageIndex={i} flag={isLastPage && config?.isFixLastFooter} />
|
|
229
230
|
</Page>
|
|
230
231
|
)
|
|
231
232
|
})}
|