├── .gitignore
├── LICENSE
├── README.md
├── doc
├── apidoc.http
├── demo.png
├── init_print_template.sql
├── mock-data
│ ├── preview-component
│ │ ├── chuzongdan.json
│ │ ├── jiezhangdan.json
│ │ ├── kekandan.json
│ │ ├── tangkoudan.json
│ │ ├── xiaofeiqingdan.json
│ │ └── yujiedan.json
│ ├── request
│ │ ├── content.json
│ │ ├── preview-component.json
│ │ ├── queryType.json
│ │ ├── save.json
│ │ ├── system-component.json
│ │ └── update.json
│ └── system-component
│ │ ├── chuzongdan.json
│ │ ├── jiezhangdan.json
│ │ ├── kekandan.json
│ │ ├── tangkoudan.json
│ │ ├── xiaofeiqingdan.json
│ │ └── yujiedan.json
├── preview
│ ├── 厨总单.png
│ ├── 堂口单.png
│ ├── 客看单.png
│ ├── 消费清单.png
│ ├── 结账单.png
│ └── 预结单.png
└── table.sql
├── h5-demo
├── assets
│ ├── angular.js
│ └── template-web.js
├── css
│ ├── bootstrap.css
│ ├── main.css
│ └── main.less
├── index.html
└── js
│ ├── main.js
│ └── utils.js
├── pom.xml
└── src
├── main
├── java
│ └── com
│ │ └── zxcs
│ │ └── printtemplate
│ │ ├── PrintTemplateApplication.java
│ │ ├── constant
│ │ └── SystemComponentTypeEnum.java
│ │ ├── controller
│ │ ├── PrinterDeviceController.java
│ │ ├── PrinterKitchenController.java
│ │ └── PrinterTicketController.java
│ │ ├── dao
│ │ ├── PrinterCustomComponentMapper.java
│ │ ├── PrinterDeviceMapper.java
│ │ ├── PrinterDocumentTypeMapper.java
│ │ ├── PrinterKitchenDocumentTypeRulesMapper.java
│ │ ├── PrinterKitchenGoodsRulesMapper.java
│ │ ├── PrinterKitchenMapper.java
│ │ ├── PrinterKitchenTableRulesMapper.java
│ │ ├── PrinterSystemComponentMapper.java
│ │ ├── PrinterTemplateDocumentMapper.java
│ │ └── PrinterTemplateModuleMapper.java
│ │ ├── exception
│ │ ├── BaseException.java
│ │ ├── GlobalExceptionHandler.java
│ │ ├── common
│ │ │ ├── ParameterException.java
│ │ │ ├── ParameterIllegalException.java
│ │ │ ├── ParamterErrorException.java
│ │ │ └── PermissionRefusedException.java
│ │ └── print
│ │ │ ├── PrinterDeviceException.java
│ │ │ ├── PrinterKitchenException.java
│ │ │ └── PrinterTemplateDocumentException.java
│ │ ├── form
│ │ ├── BaseForm.java
│ │ ├── CustomTemplateDocumentForm.java
│ │ ├── DocumentTypeRule.java
│ │ ├── PrinterKitchenForm.java
│ │ ├── PrinterKitchenGoodsRule.java
│ │ ├── PrinterKitchenTableRule.java
│ │ ├── SavePrinterDeviceForm.java
│ │ ├── TemplateDocumentEnableForm.java
│ │ ├── UpdateCustomTemplateDocumentForm.java
│ │ └── UpdatePrinterDeviceForm.java
│ │ ├── helper
│ │ └── MapHelper.java
│ │ ├── model
│ │ ├── PrinterCustomComponentDO.java
│ │ ├── PrinterDeviceDO.java
│ │ ├── PrinterDocumentTypeDO.java
│ │ ├── PrinterKitchenDO.java
│ │ ├── PrinterKitchenDocumentTypeRulesDO.java
│ │ ├── PrinterKitchenGoodsRulesDO.java
│ │ ├── PrinterKitchenTableRulesDO.java
│ │ ├── PrinterSystemComponentDO.java
│ │ ├── PrinterTemplateDocumentDO.java
│ │ └── PrinterTemplateModuleDO.java
│ │ ├── service
│ │ ├── IPrinterCustomComponentService.java
│ │ ├── IPrinterDeviceService.java
│ │ ├── IPrinterDocumentTypeService.java
│ │ ├── IPrinterKitchenDocumentTypeRulesService.java
│ │ ├── IPrinterKitchenGoodsRulesService.java
│ │ ├── IPrinterKitchenService.java
│ │ ├── IPrinterKitchenTableRulesService.java
│ │ ├── IPrinterSystemComponentService.java
│ │ ├── IPrinterTemplateDocumentService.java
│ │ ├── IPrinterTemplateModuleService.java
│ │ └── impl
│ │ │ ├── PrinterCustomComponentImpl.java
│ │ │ ├── PrinterDeviceServiceImpl.java
│ │ │ ├── PrinterDocumentTypeServiceImpl.java
│ │ │ ├── PrinterKitchenDocumentTypeRulesServiceImpl.java
│ │ │ ├── PrinterKitchenGoodsRulesServiceImpl.java
│ │ │ ├── PrinterKitchenServiceImpl.java
│ │ │ ├── PrinterKitchenTableRulesServiceImpl.java
│ │ │ ├── PrinterSystemComponentServiceImpl.java
│ │ │ ├── PrinterTemplateDocumentServiceImpl.java
│ │ │ └── PrinterTemplateModuleServiceImpl.java
│ │ └── vo
│ │ ├── PrinterDeviceVO.java
│ │ ├── PrinterDocumentTypeVO.java
│ │ ├── PrinterKitchenIntegrationVO.java
│ │ ├── PrinterKitchenVO.java
│ │ ├── PrinterTemplateDocumentVO.java
│ │ └── Response.java
└── resources
│ ├── application.yml
│ ├── mapper
│ ├── PrinterCustomComponentMapper.xml
│ ├── PrinterDeviceMapper.xml
│ ├── PrinterDocumentTypeMapper.xml
│ ├── PrinterKitchenDocumentTypeRulesMapper.xml
│ ├── PrinterKitchenGoodsRulesMapper.xml
│ ├── PrinterKitchenMapper.xml
│ ├── PrinterKitchenTableRulesMapper.xml
│ ├── PrinterSystemComponentMapper.xml
│ ├── PrinterTemplateDocumentMapper.xml
│ └── PrinterTemplateModuleMapper.xml
│ └── mybatis-config.xml
└── test
└── java
└── com
└── zxcs
└── printtemplate
├── MainTest.java
└── api
├── IScOperationPrinterCustomComponentServiceTest.java
├── IScOperationPrinterDeviceServiceTest.java
├── IScOperationPrinterDocumentTypeServiceTest.java
├── IScOperationPrinterKitchenDocumentTypeRulesServiceTest.java
├── IScOperationPrinterKitchenGoodsRulesServiceTest.java
├── IScOperationPrinterKitchenServiceTest.java
├── IScOperationPrinterKitchenTableRulesServiceTest.java
├── IScOperationPrinterSystemComponentServiceTest.java
├── IScOperationPrinterTemplateDocumentServiceTest.java
└── IScOperationPrinterTemplateModuleServiceTest.java
/.gitignore:
--------------------------------------------------------------------------------
1 | *~
2 | .class
3 |
4 | # idea
5 | .idea/
6 | .gradle/
7 | build/
8 | *.iml
9 | *.ipr
10 | *.iws
11 |
12 | # Eclipse
13 | bin/
14 | gen/
15 | .settings/
16 | .project
17 | .classpath
18 |
19 | # maven
20 | target/
21 | *.war
22 | *.zip
23 | *.tar
24 | *.tar.gz
25 |
26 | # temp
27 | *.log
28 | *.cache
29 | *.diff
30 | *.patch
31 | *.tmp
32 | logs/
33 | .svn
34 |
35 | # system
36 | .DS_Store
37 | Thumbs.db
38 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## printtemplate
2 |
3 | `printtemplate`是一款设计完整,使用在80mm热敏小票打印机上的打印模板,模板包含的模块已经满足 餐饮店堂食、外卖小票的绝大部分场景。
4 | 开箱即用,开发者可以很快速的集成到内部应用中。
5 |
6 |
7 | ## Demo
8 |
9 | 
10 |
11 | ### [Demo演示视频](https://www.bilibili.com/video/BV1aK4y1k7tg/)
12 |
13 |
14 | ## Design
15 |
16 | - 1.打印模板-设计输出流程:
17 |
18 | 1)根据不同的模板类型,设计小票排版的`HTML`静态页面。
19 |
20 | 2)将订单数据渲染到`HTML`文件中。
21 |
22 | 3)将渲染好的`HTML`文件发送到小票打印机,完成打印出票。
23 |
24 | - 2.出票口设计思路
25 |
26 | 1)出票口 是一组打印规则,用于打印指定的菜品;比如配置:桌位的区域、餐饮菜品的种类、特定的商品。
27 |
28 | 2)出票口 可以配置 一品一纸、多品一纸等等。
29 |
30 | 3)出票口列表、新增出票口、删除出票口、修改出票口。
31 |
32 |
33 | ## Deployment
34 |
35 | 1.初始化数据,在MySQL中新建数据库`print_template`导`doc`目录下`init_print_template.sql`脚本。
36 |
37 | 2.服务端基于`Spring Boot`的web项目,打包成jar直接部署。(接口文档在`doc`目录下`apidoc.http`文件)
38 |
39 | 3.在项目的`h5-demo`目录中提供了一个demo,介绍了如何在浏览器中绘制一个打印模板。
40 |
41 |
42 | ## License
43 |
44 | The project is licensed under the Apache 2 license.
45 |
--------------------------------------------------------------------------------
/doc/apidoc.http:
--------------------------------------------------------------------------------
1 | ### 1.查询-票据类型
2 | GET 127.0.0.1:8080/printerTicket/types
3 |
4 | ### 2.查询店铺-模板列表(含默认模板)
5 | GET 127.0.0.1:8080/printerTicket/list?shopId=1&documentType=1
6 |
7 | ### 3.票据样式-获取系统组件
8 | GET 127.0.0.1:8080/printerTicket/systemComponents?templateId=1
9 |
10 | ### 4.票据样式-获取预览组件
11 | GET 127.0.0.1:81/printerTicket/previewComponents?templateId=1
12 |
13 | ### 5.店铺-新增模板
14 | POST 127.0.0.1:8080/printerTicket/save
15 | Content-Type: application/json
16 |
17 | {
18 | "documentType": 1,
19 | "modules": "...",
20 | "name": "模板二",
21 | "operatorId": 0,
22 | "shopId": "1",
23 | "url": ""
24 | }
25 |
26 | ### 6.店铺-更新模板
27 | POST 127.0.0.1:8080/printerTicket/update
28 | Content-Type: application/json
29 |
30 | {
31 | "templateId": 1,
32 | "modules": "",
33 | "name": "模板二",
34 | "operatorId": 0,
35 | "shopId": "1",
36 | "url": ""
37 | }
38 |
39 | ### 7.店铺-删除模板
40 | DELETE 127.0.0.1:81/printerTicket?id=1
41 |
42 | ### 8.店铺-启用模板
43 | PUT 127.0.0.1:81/printerTicket/enable
44 |
45 | ### 9.打印机列表
46 | GET 127.0.0.1:8080/printerDevice/list?shopId=1&page=1&rows=1
47 |
48 | ### 10.新增-打印机
49 | POST 127.0.0.1:8080/printerDevice/save
50 | Content-Type: application/json
51 |
52 | {
53 | "deviceName": "后厨打印机",
54 | "printerDeviceType": 2,
55 | "address": "192.168.1.13",
56 | "shopId": 1,
57 | "operatorId": 0
58 | }
59 |
60 | ### 11.更新-打印机
61 | POST 127.0.0.1:8080/printerDevice/edit
62 | Content-Type: application/json
63 |
64 | {
65 | "id": 2,
66 | "deviceName": "后厨打印机",
67 | "printerDeviceType": 2,
68 | "address": "192.168.1.13",
69 | "shopId": 1,
70 | "operatorId": 0
71 | }
72 |
73 | ### 12.删除-打印机
74 | DELETE 127.0.0.1:8080/printerDevice?id=1
75 |
76 | ### 13.出票口-列表
77 | GET 127.0.0.1:8080/printerKitchen/list?shopId=1&page=1&rows=1
78 |
79 | ### 14.新增-出票口
80 | POST 127.0.0.1:8080/printerKitchen/save
81 | Content-Type: application/json
82 |
83 | {
84 | "name": "出票口规则一",
85 | "printerDeviceId": 1,
86 | "shopId": 1,
87 | "operatorId": 1,
88 | "documentTypeRules": [
89 | {
90 | "documentTypeId": 1,
91 | "number": 1,
92 | "printerType": 1
93 | }
94 | ],
95 | "table": 1,
96 | "goods": 1,
97 | "tableRules": [
98 | {
99 | "tableId": 1
100 | }
101 | ],
102 | "goodsRules": [
103 | {
104 | "goodsId": 1,
105 | "stockId": 0
106 | }
107 | ]
108 | }
109 |
110 | ### 15.更新-出票口
111 | PUT 127.0.0.1:8080/printerKitchen/edit
112 | Content-Type: application/json
113 |
114 | {
115 | "id": 1,
116 | "name": "出票口规则一",
117 | "printerDeviceId": 1,
118 | "shopId": 1,
119 | "operatorId": 1,
120 | "documentTypeRules": [
121 | {
122 | "documentTypeId": 1,
123 | "number": 1,
124 | "printerType": 1
125 | }
126 | ],
127 | "table": 1,
128 | "goods": 1,
129 | "tableRules": [
130 | {
131 | "tableId": 1
132 | }
133 | ],
134 | "goodsRules": [
135 | {
136 | "goodsId": 2,
137 | "stockId": 0
138 | }
139 | ]
140 | }
141 |
142 | ### 16.查询-出票口
143 | GET 127.0.0.1:8080/printerKitchen?id=1
144 |
145 | ### 17.删除-出票口
146 | DELETE 127.0.0.1:8080/printerKitchen?id=2
147 |
--------------------------------------------------------------------------------
/doc/demo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smart-rabbit-china/printtemplate/a5ca32264f601cc7dc80a673cbb9a9d1231c5671/doc/demo.png
--------------------------------------------------------------------------------
/doc/mock-data/request/content.json:
--------------------------------------------------------------------------------
1 | {
2 | "content": {
3 | "rows": [
4 | {
5 | "cells": [
6 | {
7 | "percent": 100,
8 | "style": {
9 | "align": "center",
10 | "fontSize": 4
11 | },
12 | "text": "#{shopName}"
13 | }
14 | ],
15 | "type": "text"
16 | },
17 | {
18 | "cells": [
19 | {
20 | "percent": 100,
21 | "style": {
22 | "align": "center",
23 | "fontSize": 4
24 | },
25 | "text": "#{ticketType}"
26 | }
27 | ],
28 | "type": "text"
29 | },
30 | {
31 | "text": "-",
32 | "type": "line"
33 | },
34 | {
35 | "cells": [
36 | {
37 | "percent": 70,
38 | "style": {
39 | "align": "left",
40 | "fontSize": 1
41 | },
42 | "text": "桌台号:#{tableNum}"
43 | },
44 | {
45 | "percent": 30,
46 | "style": {
47 | "align": "right",
48 | "fontSize": 1
49 | },
50 | "text": "流水号:#{serialNum}"
51 | }
52 | ],
53 | "type": "text"
54 | },
55 | {
56 | "cells": [
57 | {
58 | "percent": 80,
59 | "style": {
60 | "align": "left",
61 | "fontSize": 1
62 | },
63 | "text": "订单号:#{orderNum}"
64 | },
65 | {
66 | "percent": 20,
67 | "style": {
68 | "align": "right",
69 | "fontSize": 1
70 | },
71 | "text": "人数:#{peopleNum}"
72 | }
73 | ],
74 | "type": "text"
75 | },
76 | {
77 | "cells": [
78 | {
79 | "percent": 100,
80 | "style": {
81 | "align": "left",
82 | "fontSize": 1
83 | },
84 | "text": "会员:#{memberNum}"
85 | }
86 | ],
87 | "type": "text"
88 | },
89 | {
90 | "cells": [
91 | {
92 | "percent": 100,
93 | "style": {
94 | "align": "left",
95 | "fontSize": 1
96 | },
97 | "text": "#{mealPeopleDetail}"
98 | }
99 | ],
100 | "type": "text"
101 | },
102 | {
103 | "text": "-",
104 | "type": "line"
105 | },
106 | {
107 | "cells": [
108 | {
109 | "percent": 40,
110 | "style": {
111 | "align": "left",
112 | "fontSize": 1
113 | },
114 | "text": "商品",
115 | "visible": "#{goodSourceSize}!=0"
116 | },
117 | {
118 | "percent": 20,
119 | "style": {
120 | "align": "right",
121 | "fontSize": 1
122 | },
123 | "text": "单价",
124 | "visible": "#{goodSourceSize}!=0"
125 | },
126 | {
127 | "percent": 20,
128 | "style": {
129 | "align": "right",
130 | "fontSize": 1
131 | },
132 | "text": "数量",
133 | "visible": "#{goodSourceSize}!=0"
134 | },
135 | {
136 | "percent": 20,
137 | "style": {
138 | "align": "right",
139 | "fontSize": 1
140 | },
141 | "text": "价格",
142 | "visible": "#{goodSourceSize}!=0"
143 | }
144 | ],
145 | "type": "text"
146 | },
147 | {
148 | "childRows": [
149 | {
150 | "style": {
151 | "align": "center",
152 | "fontSize": 1
153 | },
154 | "text": "-",
155 | "type": "line",
156 | "value": "#{goodMiddleCategoryName}"
157 | },
158 | {
159 | "childRows": [
160 | {
161 | "cells": [
162 | {
163 | "percent": 40,
164 | "style": {
165 | "align": "left",
166 | "fontSize": 1
167 | },
168 | "text": "#{good}"
169 | },
170 | {
171 | "percent": 20,
172 | "style": {
173 | "align": "right",
174 | "fontSize": 1
175 | },
176 | "text": "#{price}"
177 | },
178 | {
179 | "percent": 20,
180 | "style": {
181 | "align": "right",
182 | "fontSize": 1
183 | },
184 | "text": "#{number}"
185 | },
186 | {
187 | "percent": 20,
188 | "style": {
189 | "align": "right",
190 | "fontSize": 1
191 | },
192 | "text": "#{amount}"
193 | }
194 | ],
195 | "type": "text"
196 | },
197 | {
198 | "cells": [
199 | {
200 | "percent": 80,
201 | "style": {
202 | "align": "left",
203 | "fontSize": 1
204 | },
205 | "text": "#{practice}"
206 | },
207 | {
208 | "percent": 20,
209 | "style": {
210 | "align": "right",
211 | "fontSize": 1
212 | },
213 | "text": "#{practicePrice}"
214 | }
215 | ],
216 | "type": "text"
217 | },
218 | {
219 | "cells": [
220 | {
221 | "percent": 80,
222 | "style": {
223 | "align": "left",
224 | "fontSize": 1
225 | },
226 | "text": "#{burdening}"
227 | },
228 | {
229 | "percent": 20,
230 | "style": {
231 | "align": "right",
232 | "fontSize": 1
233 | },
234 | "text": "#{burdeningPrice}"
235 | }
236 | ],
237 | "type": "text"
238 | },
239 | {
240 | "cells": [
241 | {
242 | "percent": 100,
243 | "style": {
244 | "align": "left",
245 | "fontSize": 1
246 | },
247 | "text": "#{memo}"
248 | }
249 | ],
250 | "type": "text"
251 | },
252 | {
253 | "childRows": [
254 | {
255 | "style": {
256 | "align": "center",
257 | "fontSize": 1
258 | },
259 | "text": "-",
260 | "type": "line",
261 | "value": "#{setMealGroupCategoryNew}"
262 | },
263 | {
264 | "childRows": [
265 | {
266 | "cells": [
267 | {
268 | "percent": 40,
269 | "style": {
270 | "align": "left",
271 | "fontSize": 1
272 | },
273 | "text": "#{setMealGroupCategoryGood}"
274 | },
275 | {
276 | "percent": 20,
277 | "style": {
278 | "align": "right",
279 | "fontSize": 1
280 | },
281 | "text": "#{setMealGroupCategoryPrice}"
282 | },
283 | {
284 | "percent": 20,
285 | "style": {
286 | "align": "right",
287 | "fontSize": 1
288 | },
289 | "text": "#{setMealGroupCategoryNumber}"
290 | },
291 | {
292 | "percent": 20,
293 | "style": {
294 | "align": "right",
295 | "fontSize": 1
296 | },
297 | "text": "#{setMealGroupCategoryAmount}"
298 | }
299 | ],
300 | "type": "text"
301 | },
302 | {
303 | "cells": [
304 | {
305 | "percent": 80,
306 | "style": {
307 | "align": "left",
308 | "fontSize": 1
309 | },
310 | "text": "#{setMealGroupCategoryPractice}"
311 | },
312 | {
313 | "percent": 20,
314 | "style": {
315 | "align": "right",
316 | "fontSize": 1
317 | },
318 | "text": "#{setMealGroupCategoryPracticePrice}"
319 | }
320 | ],
321 | "type": "text"
322 | },
323 | {
324 | "cells": [
325 | {
326 | "percent": 80,
327 | "style": {
328 | "align": "left",
329 | "fontSize": 1
330 | },
331 | "text": "#{setMealGroupCategoryBurdening}"
332 | },
333 | {
334 | "percent": 20,
335 | "style": {
336 | "align": "right",
337 | "fontSize": 1
338 | },
339 | "text": "#{setMealGroupCategoryBurdeningPrice}"
340 | }
341 | ],
342 | "type": "text"
343 | },
344 | {
345 | "cells": [
346 | {
347 | "percent": 100,
348 | "style": {
349 | "align": "left",
350 | "fontSize": 1
351 | },
352 | "text": "#{setMealGroupCategoryMemo}"
353 | }
354 | ],
355 | "type": "text"
356 | }
357 | ],
358 | "source": "#{setMealGroupCategorySource}",
359 | "type": "list"
360 | }
361 | ],
362 | "source": "#{setMealGroupSource}",
363 | "type": "list"
364 | }
365 | ],
366 | "source": "#{goodMiddleCategorySource}",
367 | "type": "list"
368 | }
369 | ],
370 | "source": "#{goodSource}",
371 | "type": "list"
372 | },
373 | {
374 | "text": "-",
375 | "type": "line"
376 | },
377 | {
378 | "cells": [
379 | {
380 | "percent": 60,
381 | "style": {
382 | "align": "left",
383 | "fontSize": 1
384 | },
385 | "text": "合计"
386 | },
387 | {
388 | "percent": 20,
389 | "style": {
390 | "align": "right",
391 | "fontSize": 1
392 | },
393 | "text": "#{goodNumber}"
394 | },
395 | {
396 | "percent": 20,
397 | "style": {
398 | "align": "right",
399 | "fontSize": 1
400 | },
401 | "text": "#{goodPrice}"
402 | }
403 | ],
404 | "type": "text"
405 | },
406 | {
407 | "text": "-",
408 | "type": "line"
409 | },
410 | {
411 | "cells": [
412 | {
413 | "percent": 100,
414 | "style": {
415 | "align": "left",
416 | "fontSize": 1
417 | },
418 | "text": "整单备注:#{orderMemo}"
419 | }
420 | ],
421 | "type": "text"
422 | },
423 | {
424 | "text": "-",
425 | "type": "line"
426 | },
427 | {
428 | "cells": [
429 | {
430 | "percent": 50,
431 | "style": {
432 | "align": "left",
433 | "fontSize": 1
434 | },
435 | "text": "服务员:#{waiter}"
436 | },
437 | {
438 | "percent": 50,
439 | "style": {
440 | "align": "right",
441 | "fontSize": 1
442 | },
443 | "text": "操作员:#{cashier}"
444 | }
445 | ],
446 | "type": "text"
447 | },
448 | {
449 | "cells": [
450 | {
451 | "percent": 50,
452 | "style": {
453 | "align": "left",
454 | "fontSize": 1
455 | },
456 | "text": "开单:#{openBillingTime}"
457 | },
458 | {
459 | "percent": 50,
460 | "style": {
461 | "align": "right",
462 | "fontSize": 1
463 | },
464 | "text": "打印:#{printTime}"
465 | }
466 | ],
467 | "type": "text"
468 | },
469 | {
470 | "cells": [
471 | {
472 | "percent": 100,
473 | "style": {
474 | "align": "center",
475 | "fontSize": 1
476 | },
477 | "text": "#{shopAddress}"
478 | }
479 | ],
480 | "type": "text"
481 | },
482 | {
483 | "cells": [
484 | {
485 | "percent": 100,
486 | "style": {
487 | "align": "center",
488 | "fontSize": 1
489 | },
490 | "text": "#{shopPhone}"
491 | }
492 | ],
493 | "type": "text"
494 | },
495 | {
496 | "cells": [
497 | {
498 | "percent": 100,
499 | "style": {
500 | "align": "center",
501 | "fontSize": 1
502 | },
503 | "text": "欢迎下次光临"
504 | }
505 | ],
506 | "type": "text"
507 | }
508 | ]
509 | }
510 | }
--------------------------------------------------------------------------------
/doc/mock-data/request/queryType.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "name": "结账单",
4 | "id": 1
5 | },
6 | {
7 | "name": "客看单",
8 | "id": 2
9 | },
10 | {
11 | "name": "预结单",
12 | "id": 3
13 | },
14 | {
15 | "name": "消费清单",
16 | "id": 4
17 | },
18 | {
19 | "name": "厨总单",
20 | "id": 5
21 | },
22 | {
23 | "name": "堂口单",
24 | "id": 6
25 | }
26 | ]
--------------------------------------------------------------------------------
/doc/preview/厨总单.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smart-rabbit-china/printtemplate/a5ca32264f601cc7dc80a673cbb9a9d1231c5671/doc/preview/厨总单.png
--------------------------------------------------------------------------------
/doc/preview/堂口单.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smart-rabbit-china/printtemplate/a5ca32264f601cc7dc80a673cbb9a9d1231c5671/doc/preview/堂口单.png
--------------------------------------------------------------------------------
/doc/preview/客看单.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smart-rabbit-china/printtemplate/a5ca32264f601cc7dc80a673cbb9a9d1231c5671/doc/preview/客看单.png
--------------------------------------------------------------------------------
/doc/preview/消费清单.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smart-rabbit-china/printtemplate/a5ca32264f601cc7dc80a673cbb9a9d1231c5671/doc/preview/消费清单.png
--------------------------------------------------------------------------------
/doc/preview/结账单.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smart-rabbit-china/printtemplate/a5ca32264f601cc7dc80a673cbb9a9d1231c5671/doc/preview/结账单.png
--------------------------------------------------------------------------------
/doc/preview/预结单.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/smart-rabbit-china/printtemplate/a5ca32264f601cc7dc80a673cbb9a9d1231c5671/doc/preview/预结单.png
--------------------------------------------------------------------------------
/doc/table.sql:
--------------------------------------------------------------------------------
1 | CREATE DATABASE IF NOT EXISTS `print_template` CHARACTER SET = utf8mb4;
2 |
3 | -- 打印机表
4 | CREATE TABLE IF NOT EXISTS `printer_device` (
5 | `id` int(11) UNSIGNED AUTO_INCREMENT,
6 | `device_name` varchar(30) NOT NULL DEFAULT '' COMMENT '名称',
7 | `printer_device_type` tinyint NOT NULL DEFAULT 0 COMMENT '打印机类型:1-服务器 2-网络打印机',
8 | `address` varchar(20) NOT NULL DEFAULT '' COMMENT 'ip地址',
9 | `is_delete` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否状态:0-未删除 1-删除',
10 | `shop_id` int(11) NOT NULL DEFAULT 0 COMMENT '店铺id',
11 | `creator_id` int(11) DEFAULT 0 COMMENT '创建人',
12 | `creator_name` varchar(30) DEFAULT '' COMMENT '创建人姓名',
13 | `updator_id` int(11) DEFAULT 0 COMMENT '修改人',
14 | `updator_name` varchar(30) DEFAULT '' COMMENT '修改人姓名',
15 | `create_time` datetime DEFAULT NULL,
16 | `update_time` datetime DEFAULT NULL,
17 | PRIMARY KEY (`id`),
18 | KEY `idx_printer_device_shop_id`(`shop_id`)
19 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT '打印机表';
20 |
21 | -- 出票口表
22 | CREATE TABLE IF NOT EXISTS `printer_kitchen` (
23 | `id` int(11) UNSIGNED AUTO_INCREMENT,
24 | `name` varchar(30) NOT NULL DEFAULT '' COMMENT '出票口名称',
25 | `printer_device_id` int NOT NULL DEFAULT 0 COMMENT '打印机id',
26 | `is_table` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否配置桌台区域:0-未配置 1-配置',
27 | `is_goods` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否配置打印菜品:0-未配置 1-配置',
28 | `is_delete` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否删除:0-未删除 1-删除',
29 | `shop_id` int(11) NOT NULL DEFAULT 0 COMMENT '店铺id',
30 | `creator_id` int DEFAULT 0 COMMENT '创建人',
31 | `creator_name` varchar(30) DEFAULT '' COMMENT '创建人姓名',
32 | `updator_id` int DEFAULT 0 COMMENT '修改人',
33 | `updator_name` varchar(30) DEFAULT '' COMMENT '修改人姓名',
34 | `create_time` datetime DEFAULT NULL,
35 | `update_time` datetime DEFAULT NULL,
36 | PRIMARY KEY(`id`),
37 | KEY `idx_printer_kitchen_shop_id`(`shop_id`)
38 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT '出票口表';
39 |
40 | -- 出票口票据类型表
41 | CREATE TABLE IF NOT EXISTS `printer_kitchen_document_type_rules` (
42 | `id` int(11) UNSIGNED AUTO_INCREMENT,
43 | `printer_kitchen_id` int(11) NOT NULL DEFAULT 0 COMMENT '出票口id',
44 | `document_type_id` int NOT NULL DEFAULT 0 COMMENT '票据类型',
45 | `number` tinyint NOT NULL DEFAULT 1 COMMENT '打印份数',
46 | `printer_type` tinyint UNSIGNED NOT NULL DEFAULT 1 COMMENT '打印方式:1-一纸多菜 2-一纸一菜 3-各打一张',
47 | `is_delete` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否删除:0-未删除 1-删除',
48 | `create_time` datetime DEFAULT NULL,
49 | `update_time` datetime DEFAULT NULL,
50 | PRIMARY KEY(`id`),
51 | KEY `idx_kitchen_document_type_printer_kitchen_id`(`printer_kitchen_id`),
52 | KEY `idx_kitchen_document_type_document_type_id`(`document_type_id`)
53 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT '出票口票据类型表';
54 |
55 | -- 出票口配置桌台区域表
56 | CREATE TABLE IF NOT EXISTS `printer_kitchen_table_rules` (
57 | `id` int(11) UNSIGNED AUTO_INCREMENT,
58 | `printer_kitchen_id` int(11) NOT NULL DEFAULT 0 COMMENT '出票口id',
59 | `table_id` int(11) NOT NULL DEFAULT 0 COMMENT '桌台号',
60 | `is_delete` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否删除:0-未删除 1-删除',
61 | `create_time` datetime DEFAULT NULL,
62 | `update_time` datetime DEFAULT NULL,
63 | PRIMARY KEY(`id`),
64 | KEY `idx_kitchen_table_rules_printer_kitchen_id`(`printer_kitchen_id`),
65 | KEY `idx_kitchen_table_rules_table_id`(`table_id`)
66 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT '出票口配置桌台区域表';
67 |
68 | -- 出票口配置打印菜品表
69 | CREATE TABLE IF NOT EXISTS `printer_kitchen_goods_rules` (
70 | `id` int(11) UNSIGNED AUTO_INCREMENT,
71 | `printer_kitchen_id` int(11) NOT NULL DEFAULT 0 COMMENT '出票口id',
72 | `goods_id` int(11) NOT NULL DEFAULT 0 COMMENT '商品id',
73 | `stock_id` int(11) NOT NULL DEFAULT 0 COMMENT '规格id',
74 | `is_delete` tinyint UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否删除:0-未删除 1-删除',
75 | `create_time` datetime DEFAULT NULL,
76 | `update_time` datetime DEFAULT NULL,
77 | PRIMARY KEY(`id`),
78 | KEY `idx_kitchen_goods_rules_printer_kitchen_id`(`printer_kitchen_id`),
79 | KEY `idx_kitchen_goods_rules_goods_id`(`goods_id`),
80 | KEY `idx_kitchen_goods_rules_stock_id`(`stock_id`)
81 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT '出票口配置打印菜品表';
82 |
83 | -- 打印模板类型表
84 | CREATE TABLE IF NOT EXISTS `printer_document_type` (
85 | `id` INT UNSIGNED AUTO_INCREMENT,
86 | `name` VARCHAR(10) NOT NULL DEFAULT '' COMMENT '类型名称',
87 | `status` TINYINT NOT NULL DEFAULT 0 COMMENT '状态:0-禁用 1-启用',
88 | `create_time` datetime DEFAULT NULL COMMENT '添加时间',
89 | `update_time` datetime DEFAULT NULL COMMENT '更新时间',
90 | PRIMARY KEY(`id`),
91 | KEY `idx_name`(`name`)
92 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT '打印模板类型表';
93 |
94 | -- 打印模板模块表
95 | CREATE TABLE IF NOT EXISTS `printer_template_module` (
96 | `id` INT UNSIGNED AUTO_INCREMENT,
97 | `module_name` VARCHAR(10) NOT NULL COMMENT '模块名称',
98 | `module_describe` VARCHAR(30) NOT NULL COMMENT '模块描述',
99 | `document_type` INT NOT NULL COMMENT '模板类型',
100 | `sort` INT DEFAULT 0 COMMENT '排序',
101 | `create_time` datetime DEFAULT NULL COMMENT '添加时间',
102 | `update_time` datetime DEFAULT NULL COMMENT '更新时间',
103 | PRIMARY KEY(`id`)
104 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT '打印模板模块表';
105 |
106 | -- 打印模板系统组件表
107 | CREATE TABLE IF NOT EXISTS `printer_system_component`(
108 | `id` INTEGER UNSIGNED AUTO_INCREMENT,
109 | `module_id` INT NOT NULL DEFAULT 0 COMMENT '模块id',
110 | `parent_id` INT NOT NULL DEFAULT 0 COMMENT '父组件id',
111 | `ref_id` INT NOT NULL DEFAULT 0 COMMENT '引用id',
112 | `label` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '组件名称',
113 | `value` VARCHAR(30) NOT NULL DEFAULT '' COMMENT '组件值',
114 | `value_style` VARCHAR(150) NOT NULL DEFAULT '' COMMENT '组件值排版属性',
115 | `placeholder` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '占位符,例如:#{orderSource}',
116 | `type` VARCHAR(10) NOT NULL DEFAULT '' COMMENT '组件类型:hidden-隐藏(refId) text-文本 grid-网格 title-表格标题 category-分类 head-表格头',
117 | `row` INT NOT NULL DEFAULT 0 COMMENT '行号',
118 | `column` INT NOT NULL DEFAULT 0 COMMENT '列号',
119 | `width` INT NOT NULL DEFAULT 0 COMMENT '宽度,百分比',
120 | `sort` INT NOT NULL DEFAULT 0 COMMENT '序号',
121 | `is_enable` tinyint NOT NULL DEFAULT 1 COMMENT '启用状态:0 未启用 1已启用',
122 | `create_time` datetime DEFAULT NULL COMMENT '添加时间',
123 | `update_time` datetime DEFAULT NULL COMMENT '更新时间',
124 | PRIMARY KEY(`id`),
125 | UNIQUE KEY `idx_temponent_component_id`(`id`),
126 | KEY `idx_template_component_module_id`(`module_id`),
127 | KEY `idx_template_component_parent_id`(`parent_id`)
128 | ) ENGINE = InnoDB AUTO_INCREMENT = 1 DEFAULT CHARSET = utf8mb4 COMMENT '打印模板系统组件表';
129 |
130 | -- 应用-打印模板表
131 | CREATE TABLE IF NOT EXISTS `printer_template_document` (
132 | `id` INT UNSIGNED AUTO_INCREMENT,
133 | `name` VARCHAR(20) NOT NULL DEFAULT '' COMMENT '模板名称',
134 | `document_type` INT NOT NULL DEFAULT 0 COMMENT '文档类型',
135 | `url` VARCHAR(100) DEFAULT '' COMMENT '文档预览图',
136 | `status` INT NOT NULL DEFAULT 0 COMMENT '模板状态:0-删除 1-启用 2-禁用',
137 | `shop_id` INT NOT NULL DEFAULT 0 COMMENT '店铺id',
138 | `creator_id` INT NOT NULL DEFAULT 0 COMMENT '添加者id',
139 | `creator_name` VARCHAR(20) DEFAULT '' COMMENT '添加者名称',
140 | `create_time` datetime DEFAULT NULL,
141 | `update_time` datetime DEFAULT NULL,
142 | PRIMARY KEY(`id`),
143 | KEY `idx_template_document_shop_id`(`shop_id`)
144 | ) ENGINE = InnoDB AUTO_INCREMENT = 0 DEFAULT CHARSET = utf8mb4 COMMENT '应用-打印模板表';
145 |
146 | -- 自定义组件表
147 | CREATE TABLE `printer_custom_component` (
148 | `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
149 | `document_template_id` int(11) NOT NULL DEFAULT '0' COMMENT '模板id',
150 | `system_component_id` int(11) DEFAULT '0' COMMENT '系统组件id',
151 | `value_style` varchar(150) NOT NULL DEFAULT '' COMMENT '自定义组件属性',
152 | `is_delete` tinyint(4) NOT NULL DEFAULT '0' COMMENT '是否删除:0-未删除 1-删除',
153 | PRIMARY KEY (`id`),
154 | KEY `idx_systemComponentId` (`system_component_id`)
155 | ) ENGINE=InnoDB AUTO_INCREMENT=827 DEFAULT CHARSET=utf8mb4 COMMENT='自定义组件表';
--------------------------------------------------------------------------------
/h5-demo/css/main.css:
--------------------------------------------------------------------------------
1 | .component-box {
2 | border: 4px dotted dodgerblue;
3 | padding: 20px 30px;
4 | }
5 | .component-box .panel-module {
6 | margin: 10px 20px;
7 | border: 2px solid gray;
8 | }
9 | .component-box .panel-module .panel-module-title {
10 | padding: 0 10px;
11 | border-bottom: 2px solid gray;
12 | }
13 | .component-box .panel-module .panel-module-body {
14 | padding: 2%;
15 | /*启用状态*/
16 | }
17 | .component-box .panel-module .panel-module-body .panel-component {
18 | margin: 2%;
19 | width: 28%;
20 | background-color: gray;
21 | display: inline-block;
22 | border: 1px solid white;
23 | height: 45px;
24 | cursor: pointer;
25 | }
26 | .component-box .panel-module .panel-module-body .panel-component table {
27 | vertical-align: middle;
28 | height: 100%;
29 | width: 100%;
30 | }
31 | .component-box .panel-module .panel-module-body .panel-component table tbody {
32 | display: table-row-group;
33 | vertical-align: middle;
34 | border-color: inherit;
35 | }
36 | .component-box .panel-module .panel-module-body .panel-component table tbody tr {
37 | display: table-row;
38 | vertical-align: inherit;
39 | border-color: inherit;
40 | }
41 | .component-box .panel-module .panel-module-body .panel-component table tbody tr td {
42 | color: white;
43 | font-size: 14px;
44 | text-align: center;
45 | display: table-cell;
46 | vertical-align: inherit;
47 | }
48 | .component-box .panel-module .panel-module-body .panel-component:hover {
49 | border: 1px solid gray;
50 | }
51 | .component-box .panel-module .panel-module-body .switch-on {
52 | background-color: #2D93CA;
53 | color: #000;
54 | }
55 | .template-container {
56 | width: 70%;
57 | border: 4px dotted dodgerblue;
58 | padding: 30px 30px;
59 | background-color: #e4e4e4;
60 | }
61 | .template-container .template-module-list {
62 | background-color: white;
63 | margin: 0 20px;
64 | padding: 20px 15px;
65 | }
66 | .template-container .template-module-list .template-module {
67 | /*模块分隔线*/
68 | }
69 | .template-container .template-module-list .template-module .template-row {
70 | display: flex;
71 | justify-content: space-between;
72 | /*获取焦点*/
73 | /*店铺logo*/
74 | }
75 | .template-container .template-module-list .template-module .template-row .template-component {
76 | width: 100%;
77 | box-sizing: border-box;
78 | border: 1px solid white;
79 | }
80 | .template-container .template-module-list .template-module .template-row .template-component:hover {
81 | border: 1px solid orange;
82 | background-color: rgba(247, 248, 74, 0.67);
83 | cursor: pointer;
84 | }
85 | .template-container .template-module-list .template-module .template-row .template-component-focus {
86 | border: 1px solid orange;
87 | background-color: rgba(247, 248, 74, 0.67);
88 | }
89 | .template-container .template-module-list .template-module .template-row .template-component-individuation {
90 | width: 100%;
91 | }
92 | .template-container .template-module-list .template-module .template-row .template-component-individuation .template-component-table .template-component-thead .template-component-tr,
93 | .template-container .template-module-list .template-module .template-row .template-component-individuation .template-component-table .template-component-tbody .template-component-tr {
94 | display: flex;
95 | justify-content: space-between;
96 | }
97 | .template-container .template-module-list .template-module .template-row .shop-logo {
98 | width: 100%;
99 | color: #3194ff;
100 | padding: 10px;
101 | margin: 10px 0;
102 | text-align: center;
103 | box-sizing: border-box;
104 | border: 1px solid black;
105 | background-color: #e6e6e6;
106 | }
107 | .template-container .template-module-list .template-module .the-divider {
108 | margin: 5px 0;
109 | }
110 | .template-property-panel {
111 | position: fixed;
112 | bottom: 10%;
113 | right: 18%;
114 | width: 14%;
115 | }
116 |
--------------------------------------------------------------------------------
/h5-demo/css/main.less:
--------------------------------------------------------------------------------
1 | .component-box {
2 | border: 4px dotted dodgerblue;
3 | padding: 20px 30px;
4 | .panel-module {
5 | margin: 10px 20px;
6 | border: 2px solid gray;
7 | .panel-module-title {
8 | padding: 0 10px;
9 | border-bottom: 2px solid gray;
10 | }
11 | .panel-module-body {
12 | padding: 2%;
13 | .panel-component {
14 | margin: 2%;
15 | width: 28%;
16 | background-color: gray;
17 | display: inline-block;
18 | border: 1px solid white;
19 | height: 45px;
20 | cursor: pointer;
21 | table {
22 | vertical-align: middle;
23 | height: 100%;
24 | width: 100%;
25 | tbody {
26 | display: table-row-group;
27 | vertical-align: middle;
28 | border-color: inherit;
29 | tr {
30 | display: table-row;
31 | vertical-align: inherit;
32 | border-color: inherit;
33 | td {
34 | color: white;
35 | font-size: 14px;
36 | text-align: center;
37 | display: table-cell;
38 | vertical-align: inherit;
39 | }
40 | }
41 | }
42 | }
43 | }
44 | .panel-component:hover {
45 | border: 1px solid gray;
46 | }
47 | /*启用状态*/
48 | .switch-on {
49 | background-color: #2D93CA;
50 | color: #000;
51 | }
52 | }
53 | }
54 | }
55 |
56 | .template-container {
57 | width: 70%;
58 | border: 4px dotted dodgerblue;
59 | padding: 30px 30px;
60 | background-color: #e4e4e4;
61 | .template-module-list {
62 | background-color: white;
63 | margin: 0 20px;
64 | padding: 20px 15px;
65 | .template-module {
66 | .template-row {
67 | display: flex;
68 | justify-content: space-between;
69 | .template-component {
70 | width: 100%;
71 | box-sizing:border-box;
72 | border: 1px solid white;
73 | }
74 | .template-component:hover {
75 | border: 1px solid orange;
76 | background-color: rgba(247, 248, 74, 0.67);
77 | cursor: pointer;
78 | }
79 | /*获取焦点*/
80 | .template-component-focus {
81 | border: 1px solid orange;
82 | background-color: rgba(247, 248, 74, 0.67);
83 | }
84 | .template-component-individuation {
85 | width: 100%;
86 | .template-component-table {
87 | .template-component-thead,
88 | .template-component-tbody {
89 | .template-component-tr {
90 | display: flex;
91 | justify-content: space-between;
92 | .table-component-td {
93 |
94 | }
95 | }
96 | }
97 | }
98 | }
99 | /*店铺logo*/
100 | .shop-logo {
101 | width: 100%;
102 | color: #3194ff;
103 | padding: 10px;
104 | margin: 10px 0;
105 | text-align: center;
106 | box-sizing:border-box;
107 | border: 1px solid black;
108 | background-color: #e6e6e6;
109 | }
110 | }
111 | /*模块分隔线*/
112 | .the-divider {
113 | margin: 5px 0;
114 | }
115 | }
116 | }
117 | }
118 |
119 | .template-property-panel {
120 | position: fixed;
121 | bottom: 10%;
122 | right: 18%;
123 | width: 14%;
124 | }
125 |
--------------------------------------------------------------------------------
/h5-demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
7 |
8 |
9 |
10 |
11 | 打印模块
12 |
13 |
14 |
15 |
16 |
17 |
打印机-模板样式
18 |
19 |
20 |
32 |
33 |
34 |
35 |
36 |
37 |
{{panelModule.moduleName}} {{panelModule.moduleDescribe}}
38 |
39 |
40 |
43 |
44 |
45 |
46 | {{panelComponent.label}} |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
66 |
67 |
68 | {{templateComponent.value}}
69 |
70 |
74 |
75 | {{templateComponent.tableTitle.value}}
76 |
77 |
78 |
79 |
80 |
81 |
85 |
86 | {{tableHeadColumn.value}}
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 | {{templateComponent.category.value}}
96 |
97 |
98 |
99 |
103 |
104 | {{tableTbodyRowColumn.value}}
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
--------------------------------------------------------------------------------
/h5-demo/js/utils.js:
--------------------------------------------------------------------------------
1 | /**
2 | * AngularJS统一请求(Content-Type:application/json)
3 | * @param $http
4 | * @param param
5 | */
6 | function baseRequestForm ($http, param) {
7 | if (!param.method) {
8 | param.method = "GET";
9 | } else {
10 | param.data = JSON.stringify(param.data);
11 | }
12 | $http({
13 | url: param.url,
14 | method: param.method,
15 | data: param.data
16 | }).then(
17 | function (res) {
18 | param.sCallback && param.sCallback(res);
19 | },
20 | function (res) {
21 | console.log("error: ", res);
22 | }
23 | );
24 | }
25 |
26 | /**
27 | * 判断对象属性不为空
28 | * object = null false
29 | * object[property] = null false
30 | * object[property] = "" false
31 | * @param object 对象
32 | * @param property 属性
33 | * @return boolean
34 | */
35 | function isNotEmpty (object, property) {
36 | return object != null && object.hasOwnProperty(property) && object[property] != null && object[property] !== "";
37 | }
38 |
39 | /**
40 | * 横线连接转换驼峰
41 | * @param value 横线连接
42 | * @return {string}
43 | */
44 | function lineToHump(value) {
45 | return value.replace(/\-(\w)/g, function(all, letter){
46 | return letter.toUpperCase();
47 | });
48 | }
49 |
50 | /**
51 | * 驼峰转换横线连接
52 | * @param value 驼峰
53 | * @returns {string}
54 | */
55 | function humpToLine(value) {
56 | return value.replace(/([A-Z])/g,"-$1").toLowerCase();
57 | }
58 |
59 | /**
60 | * 根据参数名获取地址栏URL里的参数
61 | * @param name 参数名
62 | * @return {string}
63 | */
64 | function getUrlQueryString(name) {
65 | var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
66 | var r = window.location.search.substr(1).match(reg);
67 | return r !== null ? unescape(r[2]) : null;
68 | }
69 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 | org.springframework.boot
6 | spring-boot-starter-parent
7 | 2.2.5.RELEASE
8 |
9 |
10 | 4.0.0
11 | printtemplate
12 | 1.0.0
13 | print-template ${project.version}
14 | 小票打印机,自定义模板样式
15 |
16 |
17 | 1.1.10
18 | 1.3.2
19 | 5.1.48
20 | 3.3.2
21 | 1.2.61
22 | 28.0-jre
23 | 5.1.8
24 | 1.18.12
25 |
26 |
27 |
28 |
29 | org.springframework.boot
30 | spring-boot-starter-web
31 |
32 |
33 | com.alibaba
34 | druid-spring-boot-starter
35 | ${druid.version}
36 |
37 |
38 | org.mybatis.spring.boot
39 | mybatis-spring-boot-starter
40 | ${mybatis-spring-boot.version}
41 |
42 |
43 | org.springframework.boot
44 | spring-boot-starter-test
45 | test
46 |
47 |
48 | mysql
49 | mysql-connector-java
50 | ${mysql-connector-java.version}
51 |
52 |
53 | org.apache.commons
54 | commons-lang3
55 | ${commons-lang.version}
56 |
57 |
58 | com.alibaba
59 | fastjson
60 | ${fastjson.version}
61 |
62 |
63 | com.google.guava
64 | guava
65 | ${guava.version}
66 |
67 |
68 | com.github.pagehelper
69 | pagehelper
70 | ${pagehelper.version}
71 |
72 |
73 | org.projectlombok
74 | lombok
75 | ${lombok.version}
76 |
77 |
78 |
79 |
80 | print-template
81 |
82 |
83 | org.springframework.boot
84 | spring-boot-maven-plugin
85 |
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/src/main/java/com/zxcs/printtemplate/PrintTemplateApplication.java:
--------------------------------------------------------------------------------
1 | package com.zxcs.printtemplate;
2 |
3 | import org.springframework.boot.SpringApplication;
4 | import org.springframework.boot.autoconfigure.SpringBootApplication;
5 |
6 | /**
7 | * Created by zfh on 2018/12/10
8 | */
9 | @SpringBootApplication
10 | public class PrintTemplateApplication{
11 |
12 | public static void main(String[] args) {
13 | SpringApplication.run(PrintTemplateApplication.class, args);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/com/zxcs/printtemplate/constant/SystemComponentTypeEnum.java:
--------------------------------------------------------------------------------
1 | package com.zxcs.printtemplate.constant;
2 |
3 | /**
4 | * 打印模板-系统组件类型枚举
5 | * Created by zfh on 2018/12/27
6 | */
7 | public enum SystemComponentTypeEnum {
8 |
9 | HIDDEN("hidden", "隐藏-refId"),
10 | TEXT("text", "文本"),
11 | GRID("grid", "网格"),
12 | TITLE("title", "表格标题"),
13 | CATEGORY("category", "分类"),
14 | TABLE_HEAD("head", "表格头");
15 |
16 | private String name;
17 |
18 | private String desc;
19 |
20 | SystemComponentTypeEnum (String name, String desc) {
21 | this.name = name;
22 | this.desc = desc;
23 | }
24 |
25 | public String getName() {
26 | return name;
27 | }
28 |
29 | public String getDesc() {
30 | return desc;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/zxcs/printtemplate/controller/PrinterDeviceController.java:
--------------------------------------------------------------------------------
1 | package com.zxcs.printtemplate.controller;
2 |
3 | import com.github.pagehelper.PageInfo;
4 | import com.zxcs.printtemplate.exception.print.PrinterDeviceException;
5 | import com.zxcs.printtemplate.form.SavePrinterDeviceForm;
6 | import com.zxcs.printtemplate.form.UpdatePrinterDeviceForm;
7 | import com.zxcs.printtemplate.helper.MapHelper;
8 | import com.zxcs.printtemplate.model.PrinterDeviceDO;
9 | import com.zxcs.printtemplate.service.IPrinterDeviceService;
10 | import com.zxcs.printtemplate.vo.PrinterDeviceVO;
11 | import com.zxcs.printtemplate.vo.Response;
12 | import org.springframework.beans.BeanUtils;
13 | import org.springframework.beans.factory.annotation.Autowired;
14 | import org.springframework.web.bind.annotation.*;
15 |
16 | import java.util.ArrayList;
17 | import java.util.List;
18 |
19 | /**
20 | * 设备-打印机
21 | *
22 | * Created by zfh on 2019/01/09
23 | */
24 | @RequestMapping("printerDevice")
25 | @RestController
26 | public class PrinterDeviceController {
27 |
28 | @Autowired
29 | private IPrinterDeviceService printerDeviceService;
30 |
31 | /**
32 | * 新增-打印机
33 | *
34 | * @param form {@link SavePrinterDeviceForm}
35 | * @return {@link Response}
36 | */
37 | @PostMapping("save")
38 | public Response save(@RequestBody SavePrinterDeviceForm form) {
39 | form.validateParam();
40 |
41 | printerDeviceService.save(form.getPrinterDevice());
42 | return Response.newInstance();
43 | }
44 |
45 | /**
46 | * 打印机列表
47 | *
48 | * @return {@link Response}
49 | */
50 | @GetMapping("list")
51 | public Response queryList(@RequestParam(name = "shopId", defaultValue = "0") Integer shopId,
52 | @RequestParam(name = "page", defaultValue = "1") Integer page,
53 | @RequestParam(name = "rows", defaultValue = "10") Integer rows) {
54 | PageInfo pageInfo = printerDeviceService.listPrinterDeviceByShopId(shopId, page, rows);
55 | List voList = new ArrayList<>(10);
56 | for (PrinterDeviceDO printerDevice : pageInfo.getList()) {
57 | PrinterDeviceVO printerDeviceVO = new PrinterDeviceVO();
58 | BeanUtils.copyProperties(printerDevice, printerDeviceVO);
59 | voList.add(printerDeviceVO);
60 | }
61 | return Response.newInstance().setData(MapHelper.newInstance().put("total", pageInfo.getTotal()).put("list", voList).map());
62 | }
63 |
64 | /**
65 | * 查询-打印机
66 | *
67 | * @return {@link Response}
68 | */
69 | @GetMapping("")
70 | public Response doQuery(@RequestParam(name = "id", defaultValue = "0") Integer id) {
71 | PrinterDeviceDO printerDevice = printerDeviceService.getScShopPrinterDeviceByPrimaryKey(id);
72 | if (printerDevice == null || printerDevice.getDelete().equals(1)) {
73 | throw new PrinterDeviceException();
74 | }
75 | PrinterDeviceVO printerDeviceVO = new PrinterDeviceVO();
76 | BeanUtils.copyProperties(printerDevice, printerDeviceVO);
77 | return Response.newInstance().setData(printerDeviceVO);
78 | }
79 |
80 | /**
81 | * 更新-打印机
82 | *
83 | * @param form {@link UpdatePrinterDeviceForm}
84 | * @return {@link Response}
85 | */
86 | @PutMapping("edit")
87 | public Response doEdit(@RequestBody UpdatePrinterDeviceForm form) {
88 | form.validateParam();
89 |
90 | PrinterDeviceDO printerDevice = printerDeviceService.getScShopPrinterDeviceByPrimaryKey(form.getId());
91 | if (printerDevice == null || printerDevice.getDelete().equals(1)) {
92 | throw new PrinterDeviceException();
93 | }
94 | printerDeviceService.updateByPrimaryKeySelective(form.getScShopPrinterDevice());
95 | return Response.newInstance();
96 | }
97 |
98 | /**
99 | * 删除-打印机
100 | *
101 | * @return {@link Response}
102 | */
103 | @DeleteMapping("")
104 | public Response doDelete(@RequestParam(name = "id", defaultValue = "0") Integer id) {
105 | PrinterDeviceDO printerDevice = printerDeviceService.getScShopPrinterDeviceByPrimaryKey(id);
106 | if (printerDevice == null || printerDevice.getDelete().equals(1)) {
107 | throw new PrinterDeviceException();
108 | }
109 | PrinterDeviceDO params = new PrinterDeviceDO();
110 | params.setId(printerDevice.getId());
111 | printerDevice.setDelete(1);
112 | printerDeviceService.updateByPrimaryKeySelective(printerDevice);
113 | return Response.newInstance();
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/src/main/java/com/zxcs/printtemplate/controller/PrinterKitchenController.java:
--------------------------------------------------------------------------------
1 | package com.zxcs.printtemplate.controller;
2 |
3 | import com.github.pagehelper.PageInfo;
4 | import com.zxcs.printtemplate.exception.print.PrinterKitchenException;
5 | import com.zxcs.printtemplate.form.PrinterKitchenForm;
6 | import com.zxcs.printtemplate.helper.MapHelper;
7 | import com.zxcs.printtemplate.model.PrinterKitchenDO;
8 | import com.zxcs.printtemplate.model.PrinterKitchenDocumentTypeRulesDO;
9 | import com.zxcs.printtemplate.model.PrinterKitchenGoodsRulesDO;
10 | import com.zxcs.printtemplate.model.PrinterKitchenTableRulesDO;
11 | import com.zxcs.printtemplate.service.IPrinterKitchenDocumentTypeRulesService;
12 | import com.zxcs.printtemplate.service.IPrinterKitchenGoodsRulesService;
13 | import com.zxcs.printtemplate.service.IPrinterKitchenService;
14 | import com.zxcs.printtemplate.service.IPrinterKitchenTableRulesService;
15 | import com.zxcs.printtemplate.vo.PrinterKitchenIntegrationVO;
16 | import com.zxcs.printtemplate.vo.PrinterKitchenVO;
17 | import com.zxcs.printtemplate.vo.Response;
18 | import org.springframework.beans.BeanUtils;
19 | import org.springframework.beans.factory.annotation.Autowired;
20 | import org.springframework.web.bind.annotation.*;
21 |
22 | import java.util.ArrayList;
23 | import java.util.HashMap;
24 | import java.util.List;
25 | import java.util.Map;
26 |
27 | /**
28 | * 打印机-出票口Rest
29 | * Created by zfh on 2019/01/09
30 | */
31 | @RequestMapping("printerKitchen")
32 | @RestController
33 | public class PrinterKitchenController {
34 |
35 | @Autowired
36 | private IPrinterKitchenService printerKitchenService;
37 |
38 | @Autowired
39 | private IPrinterKitchenDocumentTypeRulesService printerKitchenDocumentTypeRulesService;
40 |
41 | @Autowired
42 | private IPrinterKitchenTableRulesService printerKitchenTableRulesService;
43 |
44 | @Autowired
45 | private IPrinterKitchenGoodsRulesService printerKitchenGoodsRulesService;
46 |
47 | /**
48 | * 新增-出票口
49 | * @param form {@link PrinterKitchenForm}
50 | * @return {@link Response}
51 | */
52 | @PostMapping("save")
53 | public Response save (@RequestBody PrinterKitchenForm form) {
54 | form.validateParam();
55 |
56 | Integer printerKitchenId = 0;
57 | try {
58 | printerKitchenId = printerKitchenService.save(form.getPrinterKitchen());
59 | printerKitchenDocumentTypeRulesService.saveMultipleRecord(form.getDocumentTypeRulesList(printerKitchenId));
60 | if (form.getTable() == 1) {
61 | printerKitchenTableRulesService.saveMultipleRecord(form.getTableRulesList(printerKitchenId));
62 | }
63 | if (form.getGoods() == 1) {
64 | printerKitchenGoodsRulesService.saveMultipleRecord(form.getGoodsRulesList(printerKitchenId));
65 | }
66 | } catch (Exception e) {
67 | // 回滚
68 | PrinterKitchenDO params = new PrinterKitchenDO();
69 | params.setId(printerKitchenId);
70 | params.setDelete(1);
71 | printerKitchenService.updateByPrimaryKeySelective(params);
72 | throw new PrinterKitchenException("新增出票口异常!");
73 | }
74 | return Response.newInstance().setData(MapHelper.newInstance().put("printerKitchenId", printerKitchenId).map());
75 | }
76 |
77 | /**
78 | * 出票口-列表
79 | * @return {@link Response}
80 | */
81 | @GetMapping("list")
82 | public Response queryList (@RequestParam(name = "shopId", defaultValue = "0") Integer shopId,
83 | @RequestParam(name = "page", defaultValue = "1") Integer page,
84 | @RequestParam(name = "rows", defaultValue = "10") Integer rows) {
85 | PageInfo pageInfo = printerKitchenService.listPrinterKitchenByShopId(shopId, page, rows);
86 |
87 | List voList = new ArrayList<>(10);
88 | for (PrinterKitchenDO printerKitchen : pageInfo.getList()) {
89 | PrinterKitchenVO printerKitchenVO = new PrinterKitchenVO();
90 | BeanUtils.copyProperties(printerKitchen, printerKitchenVO);
91 | voList.add(printerKitchenVO);
92 | }
93 | return Response.newInstance().setData(MapHelper.newInstance().put("total", pageInfo.getTotal()).put("list", voList).map());
94 | }
95 |
96 | /**
97 | * 查询-出票口
98 | * @return {@link Response}
99 | */
100 | @GetMapping("")
101 | public Response queryInfo (@RequestParam(name = "id", defaultValue = "0") Integer id) {
102 | PrinterKitchenDO printerKitchen = printerKitchenService.getByPrimaryKey(id);
103 | if (printerKitchen == null || printerKitchen.getDelete() == 1) {
104 | throw new PrinterKitchenException();
105 | }
106 | PrinterKitchenIntegrationVO printerKitchenIntegrationVO = new PrinterKitchenIntegrationVO();
107 | BeanUtils.copyProperties(printerKitchen, printerKitchenIntegrationVO);
108 | List documentTypeRulesList = printerKitchenDocumentTypeRulesService.listPrinterKitchenDocumentTypeRulesByPrinterKitchenId(id);
109 | List