gm-printer 10.28.0-beta.6 → 10.28.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 CHANGED
@@ -1 +1 @@
1
- [{"/Users/joke/Desktop/gm-printer/src/printer/printer.js":"1","/Users/joke/Desktop/gm-printer/src/config.js":"2","/Users/joke/Desktop/gm-printer/src/common/editor_edit_field.js":"3","/Users/joke/Desktop/gm-printer/src/common/common_context_menu.js":"4","/Users/joke/Desktop/gm-printer/src/printer/page.js":"5","/Users/joke/Desktop/gm-printer/src/printer/index.js":"6","/Users/joke/Desktop/gm-printer/src/printer/do_print.js":"7","/Users/joke/Desktop/gm-printer/src/index.js":"8"},{"size":12947,"mtime":1730112542854},{"size":3569,"mtime":1730112081043,"results":"9","hashOfConfig":"10"},{"size":25058,"mtime":1730112453858},{"size":10273,"mtime":1730112252986},{"size":2063,"mtime":1730179887329,"results":"11","hashOfConfig":"10"},{"size":366,"mtime":1730177042822,"results":"12","hashOfConfig":"10"},{"size":4420,"mtime":1730179896410,"results":"13","hashOfConfig":"10"},{"size":1173,"mtime":1730177052800,"results":"14","hashOfConfig":"10"},{"filePath":"15","messages":"16","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1ho4xzn",{"filePath":"17","messages":"18","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"19","messages":"20","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"21","messages":"22","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"23","messages":"24","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/joke/Desktop/gm-printer/src/config.js",[],"/Users/joke/Desktop/gm-printer/src/printer/page.js",[],"/Users/joke/Desktop/gm-printer/src/printer/index.js",[],"/Users/joke/Desktop/gm-printer/src/printer/do_print.js",[],"/Users/joke/Desktop/gm-printer/src/index.js",[]]
1
+ [{"/Users/joke/Desktop/gm-printer/src/printer/printer.js":"1","/Users/joke/Desktop/gm-printer/src/config.js":"2","/Users/joke/Desktop/gm-printer/src/common/editor_edit_field.js":"3","/Users/joke/Desktop/gm-printer/src/common/common_context_menu.js":"4","/Users/joke/Desktop/gm-printer/src/printer/page.js":"5","/Users/joke/Desktop/gm-printer/src/printer/index.js":"6","/Users/joke/Desktop/gm-printer/src/printer/do_print.js":"7","/Users/joke/Desktop/gm-printer/src/index.js":"8"},{"size":12947,"mtime":1730112542854},{"size":3569,"mtime":1730112081043,"results":"9","hashOfConfig":"10"},{"size":25058,"mtime":1730112453858},{"size":10273,"mtime":1730112252986},{"size":1907,"mtime":1730181054714,"results":"11","hashOfConfig":"10"},{"size":366,"mtime":1730177042822,"results":"12","hashOfConfig":"10"},{"size":4420,"mtime":1730179896410,"results":"13","hashOfConfig":"10"},{"size":1173,"mtime":1730177052800,"results":"14","hashOfConfig":"10"},{"filePath":"15","messages":"16","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1ho4xzn",{"filePath":"17","messages":"18","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"19","messages":"20","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"21","messages":"22","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"23","messages":"24","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/joke/Desktop/gm-printer/src/config.js",[],"/Users/joke/Desktop/gm-printer/src/printer/page.js",[],"/Users/joke/Desktop/gm-printer/src/printer/index.js",[],"/Users/joke/Desktop/gm-printer/src/printer/do_print.js",[],"/Users/joke/Desktop/gm-printer/src/index.js",[]]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-printer",
3
- "version": "10.28.0-beta.6",
3
+ "version": "10.28.1",
4
4
  "description": "diy printer",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -114,4 +114,4 @@
114
114
  "dependencies": {
115
115
  "qrcode.react": "^0.9.2"
116
116
  }
117
- }
117
+ }
@@ -1,11 +1,7 @@
1
1
  import i18next from '../../locales'
2
2
  import React, { useEffect } from 'react'
3
3
  import PropTypes from 'prop-types'
4
- import {
5
- tableClassNameList,
6
- longPrintTableClassNameList,
7
- LONG_PRINT
8
- } from '../config'
4
+ import { tableClassNameList } from '../config'
9
5
  import _ from 'lodash'
10
6
  import { Hr, ImageUploader } from '../common/component'
11
7
  import { observer, inject } from 'mobx-react'
@@ -195,8 +191,7 @@ class CommonContextMenu extends React.Component {
195
191
  const arr = name.split('.')
196
192
  const { className } = editStore.config.contents[arr[2]]
197
193
  const isActive = c => className === c
198
- const { config } = editStore
199
- const isLongPrint = config?.page?.type === LONG_PRINT
194
+
200
195
  return (
201
196
  <>
202
197
  {renderTableAction && (
@@ -209,38 +204,17 @@ class CommonContextMenu extends React.Component {
209
204
  <div onClick={this.handleRemove}>{i18next.t('移除列')}</div>
210
205
  <Hr />
211
206
 
212
- {!isLongPrint && (
213
- <>
214
- {' '}
215
- {_.map(tableClassNameList, o => (
216
- <div
217
- onClick={this.handleSetTableConfig.bind(this, o.value)}
218
- key={o.value}
219
- className={isActive(o.value) ? 'active' : ''}
220
- >
221
- {o.text}
222
- </div>
223
- ))}{' '}
224
- <Hr />
225
- </>
226
- )}
227
-
228
- {isLongPrint && (
229
- <>
230
- {' '}
231
- {_.map(longPrintTableClassNameList, o => (
232
- <div
233
- onClick={this.handleSetTableConfig.bind(this, o.value)}
234
- key={o.value}
235
- className={isActive(o.value) ? 'active' : ''}
236
- >
237
- {o.text}
238
- </div>
239
- ))}{' '}
240
- <Hr />
241
- </>
242
- )}
207
+ {_.map(tableClassNameList, o => (
208
+ <div
209
+ onClick={this.handleSetTableConfig.bind(this, o.value)}
210
+ key={o.value}
211
+ className={isActive(o.value) ? 'active' : ''}
212
+ >
213
+ {o.text}
214
+ </div>
215
+ ))}
243
216
 
217
+ <Hr />
244
218
  <div onClick={this.handleAddContent.bind(this, 0, '')}>
245
219
  {i18next.t('向上插入区域块')}
246
220
  </div>
@@ -20,7 +20,6 @@ import {
20
20
  import { get, toJS } from 'mobx'
21
21
  import PropTypes from 'prop-types'
22
22
  import { subtotalRadioList } from './util'
23
- import { LONG_PRINT } from '../config'
24
23
  import _ from 'lodash'
25
24
 
26
25
  @inject('editStore')
@@ -200,8 +199,7 @@ class EditorField extends React.Component {
200
199
  renderTable() {
201
200
  const { tableDataKeyList, editStore, isSomeSubtotalTr } = this.props
202
201
  const { head, headStyle, text, style } = editStore.computedSelectedInfo
203
- const { config } = editStore
204
- const isLongPrint = config?.page?.type === LONG_PRINT
202
+
205
203
  const {
206
204
  specialConfig,
207
205
  subtotal,
@@ -364,38 +362,19 @@ class EditorField extends React.Component {
364
362
 
365
363
  <Gap height='5px' />
366
364
 
367
- {!isLongPrint && (
368
- <Flex alignCenter>
369
- <Flex alignCenter>{i18next.t('表格样式')}:</Flex>
370
- <Select
371
- className='gm-printer-edit-select'
372
- value={editStore.tableCustomStyle}
373
- onChange={editStore.changeTableCustomStyle}
374
- >
375
- <Option value='default'>{i18next.t('默认样式')}</Option>
376
- <Option value='className0'>{i18next.t('样式一')}</Option>
377
- <Option value='className1'>{i18next.t('样式二')}</Option>
378
- <Option value='className2'>{i18next.t('样式三')}</Option>
379
- </Select>
380
- </Flex>
381
- )}
382
-
383
- {isLongPrint && (
384
- <Flex alignCenter>
385
- <Flex alignCenter>{i18next.t('表格样式')}:</Flex>
386
- <Select
387
- className='gm-printer-edit-select'
388
- value={editStore.tableCustomStyle}
389
- onChange={editStore.changeTableCustomStyle}
390
- >
391
- <Option value='default'>{i18next.t('默认样式')}</Option>
392
- <Option value='className0'>{i18next.t('样式一')}</Option>
393
- <Option value='className1'>{i18next.t('样式二')}</Option>
394
- <Option value='className2'>{i18next.t('样式三')}</Option>
395
- <Option value='specialTable'>{i18next.t('样式四')}</Option>
396
- </Select>
397
- </Flex>
398
- )}
365
+ <Flex alignCenter>
366
+ <Flex alignCenter>{i18next.t('表格样式')}:</Flex>
367
+ <Select
368
+ className='gm-printer-edit-select'
369
+ value={editStore.tableCustomStyle}
370
+ onChange={editStore.changeTableCustomStyle}
371
+ >
372
+ <Option value='default'>{i18next.t('默认样式')}</Option>
373
+ <Option value='className0'>{i18next.t('样式一')}</Option>
374
+ <Option value='className1'>{i18next.t('样式二')}</Option>
375
+ <Option value='className2'>{i18next.t('样式三')}</Option>
376
+ </Select>
377
+ </Flex>
399
378
 
400
379
  <Gap height='5px' />
401
380
 
@@ -2,9 +2,12 @@ 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 { RadioGroup, Radio } from '@gmfe/react'
5
+ import {
6
+ RadioGroup,
7
+ Radio,
8
+ } from '@gmfe/react'
6
9
  import { InputWithUnit } from '../common/component'
7
- import { pageTypeMap, printDirectionList, LONG_PRINT } from '../config'
10
+ import { pageTypeMap, printDirectionList } from '../config'
8
11
  import _ from 'lodash'
9
12
  import { dispatchMsg } from '../util'
10
13
  import PropTypes from 'prop-types'
@@ -16,7 +19,7 @@ class EditorSelector extends React.Component {
16
19
  this.props.editStore.setConfigName(e.target.value)
17
20
  }
18
21
 
19
- handleConfigIsFixLastFooter = _val => {
22
+ handleConfigIsFixLastFooter = (_val) => {
20
23
  this.props.editStore.setConfigIsFixLastFooter(_val)
21
24
  }
22
25
 
@@ -42,19 +45,13 @@ class EditorSelector extends React.Component {
42
45
 
43
46
  render() {
44
47
  const {
45
- config: {
46
- name,
47
- page,
48
- batchPrintConfig,
49
- isFixLastFooter,
50
- showDiyOverAllOrder
51
- },
48
+ config: { name, page, batchPrintConfig, isFixLastFooter, showDiyOverAllOrder },
52
49
  computedRegionList,
53
50
  computedSelectedRegionTip,
54
51
  selectedRegion
55
52
  } = this.props.editStore
56
53
  const isDIY = page.type === 'DIY'
57
- const isLongPrint = page.type === LONG_PRINT
54
+
58
55
  return (
59
56
  <div>
60
57
  <Flex alignCenter>
@@ -82,7 +79,7 @@ class EditorSelector extends React.Component {
82
79
  </Select>
83
80
  </Flex>
84
81
 
85
- {(isDIY || isLongPrint) && (
82
+ {isDIY && (
86
83
  <Flex alignCenter className='gm-padding-top-5'>
87
84
  <div>{i18next.t('纸张宽度')}:</div>
88
85
  <InputWithUnit
@@ -105,22 +102,21 @@ class EditorSelector extends React.Component {
105
102
  />
106
103
  </Flex>
107
104
  )}
108
- {!isLongPrint && (
109
- <Flex alignCenter className='gm-padding-top-5'>
110
- <div>{i18next.t('打印布局')}:</div>
111
- <Select
112
- className='gm-printer-edit-select'
113
- value={page.printDirection}
114
- onChange={this.handlePrintDirection}
115
- >
116
- {_.map(printDirectionList, v => (
117
- <Option key={v.value} value={v.value}>
118
- {v.text}
119
- </Option>
120
- ))}
121
- </Select>
122
- </Flex>
123
- )}
105
+
106
+ <Flex alignCenter className='gm-padding-top-5'>
107
+ <div>{i18next.t('打印布局')}:</div>
108
+ <Select
109
+ className='gm-printer-edit-select'
110
+ value={page.printDirection}
111
+ onChange={this.handlePrintDirection}
112
+ >
113
+ {_.map(printDirectionList, v => (
114
+ <Option key={v.value} value={v.value}>
115
+ {v.text}
116
+ </Option>
117
+ ))}
118
+ </Select>
119
+ </Flex>
124
120
 
125
121
  <Flex alignCenter className='gm-padding-top-5'>
126
122
  <div>{i18next.t('选择区域')}:</div>
@@ -161,25 +157,21 @@ class EditorSelector extends React.Component {
161
157
  </>
162
158
  )}
163
159
 
164
- {showDiyOverAllOrder !== undefined && (
165
- <Flex alignCenter className='gm-padding-top-5'>
166
- <label htmlFor={1}>是否固定末页签名和页脚区域:</label>
167
- <RadioGroup
168
- name='isFixFooter'
169
- value={isFixLastFooter}
170
- inline
171
- onChange={this.handleConfigIsFixLastFooter}
172
- className='gm-flex'
173
- >
174
- <Radio value style={{ display: 'flex', marginRight: 10 }}>
175
- <span style={{ marginLeft: 5 }}>是</span>
176
- </Radio>
177
- <Radio value={false} style={{ display: 'flex' }}>
178
- <span style={{ marginLeft: 5 }}>否</span>
179
- </Radio>
180
- </RadioGroup>
181
- </Flex>
182
- )}
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
+ }
183
175
 
184
176
  <Flex className='gm-padding-top-5 gm-text-red' column>
185
177
  {computedSelectedRegionTip}
@@ -25,7 +25,7 @@
25
25
  background: whitesmoke;
26
26
  font-size: 12px;
27
27
  margin: 0;
28
- // line-height: 1.5; /* 1 */
28
+ line-height: 1.5; /* 1 */
29
29
  -webkit-text-size-adjust: 100%; /* 2 */
30
30
  position: relative;
31
31
  overflow: hidden;
@@ -263,13 +263,6 @@
263
263
  top: calc(50% - 0.5em);
264
264
  }
265
265
 
266
- .long_print_table_row{
267
- cursor: move;
268
- &.active{
269
- outline: 1px solid rgb(82, 146, 247);
270
- }
271
- }
272
-
273
266
  table {
274
267
  // 不被 before 遮挡
275
268
  position: relative;
package/src/config.js CHANGED
@@ -1,7 +1,4 @@
1
1
  import i18next from '../locales'
2
-
3
- export const LONG_PRINT = 'longPrint'
4
-
5
2
  export const pageTypeMap = {
6
3
  A4: {
7
4
  name: 'A4',
@@ -81,21 +78,6 @@ export const pageTypeMap = {
81
78
  paddingLeft: '16mm'
82
79
  }
83
80
  },
84
- // 新增长条打印配置选项
85
- [LONG_PRINT]: {
86
- name: i18next.t('长条打印'),
87
- size: {
88
- width: '80mm',
89
- height: '100mm'
90
- },
91
- printDirection: 'vertical',
92
- gap: {
93
- paddingTop: '2mm',
94
- paddingRight: '2mm',
95
- paddingBottom: '2mm',
96
- paddingLeft: '2mm'
97
- }
98
- },
99
81
  DIY: {
100
82
  name: i18next.t('自定义纸张'),
101
83
  size: {
@@ -125,16 +107,7 @@ export const borderStyleList = [
125
107
  export const tableClassNameList = [
126
108
  { value: '', text: i18next.t('默认样式') },
127
109
  { value: 'className0', text: i18next.t('浅实线样式') },
128
- { value: 'className1', text: i18next.t('无实线样式') },
129
- { value: 'className2', text: i18next.t('样式三') }
130
- ]
131
-
132
- export const longPrintTableClassNameList = [
133
- { value: '', text: i18next.t('默认样式') },
134
- { value: 'className0', text: i18next.t('样式一') },
135
- { value: 'className1', text: i18next.t('样式二') },
136
- { value: 'className2', text: i18next.t('样式三') },
137
- { value: 'specialTable', text: i18next.t('样式四') }
110
+ { value: 'className1', text: i18next.t('无实线样式') }
138
111
  ]
139
112
 
140
113
  export const tableDataKeyList = [
@@ -6,7 +6,6 @@ import { inject, observer } from 'mobx-react'
6
6
  import _ from 'lodash'
7
7
  import { Printer } from '../printer'
8
8
  import { isMultiTable } from '../util'
9
- import { LONG_PRINT } from '../config'
10
9
 
11
10
  const blockTypeList = [
12
11
  { value: '', text: i18next.t('插入文本') },
@@ -123,21 +122,17 @@ class ContextMenu extends React.Component {
123
122
  const isSubtotalActive = subtotal.show
124
123
  const isOverallOrder = overallOrder?.show
125
124
  const isDiyOverallOrder = diyOverallOrder?.show
126
- // 长条打印
127
- const isLongPrint = type === LONG_PRINT
128
125
 
129
126
  return (
130
127
  <>
131
- {!isLongPrint && (
132
- <div
133
- onClick={this.handleChangeTableDataKey.bind(this, 'multi', name)}
134
- className={isMultiActive ? 'active' : ''}
135
- >
136
- {i18next.t('双栏商品')}
137
- </div>
138
- )}
128
+ <div
129
+ onClick={this.handleChangeTableDataKey.bind(this, 'multi', name)}
130
+ className={isMultiActive ? 'active' : ''}
131
+ >
132
+ {i18next.t('双栏商品')}
133
+ </div>
139
134
  {/* 三分纸高度太小,做不了三栏,会死循环 */}
140
- {type !== 'A4/3' && !isLongPrint && (
135
+ {type !== 'A4/3' && (
141
136
  <div
142
137
  onClick={this.handleChangeTableDataKey.bind(this, 'multi3', name)}
143
138
  className={isThreeActive ? 'active' : ''}
package/src/index.js CHANGED
@@ -17,8 +17,7 @@ import {
17
17
  Printer,
18
18
  getCSS,
19
19
  getPrintContainerHTML,
20
- doBatchFinancePrint,
21
- setPrintStyle
20
+ doBatchFinancePrint
22
21
  } from './printer'
23
22
  import { MULTI_SUFFIX, MULTI_SUFFIX3 } from './config'
24
23
 
@@ -44,6 +43,5 @@ export {
44
43
  MULTI_SUFFIX,
45
44
  MULTI_SUFFIX3,
46
45
  getPrintContainerHTML,
47
- doBatchFinancePrint,
48
- setPrintStyle
46
+ doBatchFinancePrint
49
47
  }
@@ -4,6 +4,7 @@ import Printer from './printer'
4
4
  import getCSS from './get_css'
5
5
  import BatchPrinter from './batch_printer'
6
6
  import BatchFinancePrinter from '../finance_voucher/components/finance_batch_printer'
7
+ import { isZoom } from 'gm-util'
7
8
  import { afterImgAndSvgLoaded } from '../util'
8
9
 
9
10
  const printerId = '_gm-printer_' + Math.random()
@@ -76,18 +77,14 @@ function toDoPrint({ data, config }, isSomeSubtotalTr) {
76
77
  function toDoPrintBatch(list, isPrint = true) {
77
78
  return new window.Promise(resolve => {
78
79
  const $app = $printer.contentWindow.document.getElementById('appContainer')
79
- // 获取模版类型
80
- const templateType = list?.[0]?.config?.page?.type
81
- // 初始化
80
+
82
81
  ReactDOM.unmountComponentAtNode($app)
83
82
  ReactDOM.render(
84
83
  <BatchPrinter
85
84
  list={list}
86
85
  onReady={() => {
87
86
  afterImgAndSvgLoaded(() => {
88
- isPrint &&
89
- templateType !== 'longPrint' &&
90
- $printer.contentWindow.print()
87
+ isPrint && $printer.contentWindow.print()
91
88
  resolve()
92
89
  }, $app)
93
90
  }}
@@ -148,17 +145,4 @@ function getPrintContainerHTML() {
148
145
  return $printer.contentWindow.document.getElementsByTagName('html')[0]
149
146
  .innerHTML
150
147
  }
151
-
152
- function setPrintStyle() {
153
- const doc = document
154
- const style = doc.createElement('style')
155
- style.appendChild(doc.createTextNode(getCSS()))
156
- doc.head.appendChild(style)
157
- }
158
- export {
159
- doPrint,
160
- doBatchPrint,
161
- getPrintContainerHTML,
162
- doBatchFinancePrint,
163
- setPrintStyle
164
- }
148
+ export { doPrint, doBatchPrint, getPrintContainerHTML, doBatchFinancePrint }
@@ -4,8 +4,7 @@ import {
4
4
  doPrint,
5
5
  doBatchPrint,
6
6
  getPrintContainerHTML,
7
- doBatchFinancePrint,
8
- setPrintStyle
7
+ doBatchFinancePrint
9
8
  } from './do_print'
10
9
  import getCSS from './get_css'
11
10
 
@@ -16,6 +15,5 @@ export {
16
15
  BatchPrinter,
17
16
  getCSS,
18
17
  getPrintContainerHTML,
19
- doBatchFinancePrint,
20
- setPrintStyle
18
+ doBatchFinancePrint
21
19
  }
@@ -3,7 +3,6 @@ import PropTypes from 'prop-types'
3
3
  import { inject, observer } from 'mobx-react'
4
4
  import { getHeight } from '../util'
5
5
  import classNames from 'classnames'
6
- import { LONG_PRINT } from '../config'
7
6
 
8
7
  @inject('printerStore')
9
8
  @observer
@@ -30,9 +29,9 @@ class Page extends React.Component {
30
29
 
31
30
  const {
32
31
  size: { width, height },
33
- pageStyle,
34
- type
32
+ pageStyle
35
33
  } = printerStore.config.page
34
+
36
35
  // 统一减2毫米,防止计算误差溢出
37
36
  const x = '- 2mm'
38
37
  return (
@@ -45,21 +44,15 @@ class Page extends React.Component {
45
44
  ...pageStyle,
46
45
  boxSizing: 'content-box',
47
46
  width: `calc(${width} - ${paddingLeft} - ${paddingRight})`,
48
- padding: `${paddingTop} ${paddingRight} ${paddingBottom} ${paddingLeft}`,
49
- height:
50
- type === LONG_PRINT
51
- ? ``
52
- : `calc(${height} - ${paddingTop} - ${paddingBottom} ${x})`
47
+ height: `calc(${height} - ${paddingTop} - ${paddingBottom} ${x})`,
48
+ padding: `${paddingTop} ${paddingRight} ${paddingBottom} ${paddingLeft}`
53
49
  }}
54
50
  >
55
51
  <div
56
52
  className='gm-printer-page-inner'
57
53
  style={{
58
54
  width: `calc(${width} - ${paddingLeft} - ${paddingRight})`,
59
- height:
60
- type === LONG_PRINT
61
- ? ``
62
- : `calc(${height} - ${paddingTop} - ${paddingBottom} ${x})`
55
+ height: `calc(${height} - ${paddingTop} - ${paddingBottom} ${x})`
63
56
  }}
64
57
  >
65
58
  {children}
@@ -3,14 +3,12 @@ import React from 'react'
3
3
  import classNames from 'classnames'
4
4
  import { inject, observer, Provider } from 'mobx-react'
5
5
  import PropTypes from 'prop-types'
6
- import PrinterStore from './store'
6
+ import PrinterStore, { TR_BASE_HEIGHT } from './store'
7
7
  import Page from './page'
8
8
  import _ from 'lodash'
9
9
  import Panel from './panel'
10
10
  import Table from './table'
11
- import LongPrintTable from './long_print_table'
12
11
  import MergePage from './merge_page'
13
- import { LONG_PRINT } from '../config'
14
12
 
15
13
  // Header Sign Footer 相对特殊,要单独处理
16
14
  const Header = props => (
@@ -163,61 +161,6 @@ class Printer extends React.Component {
163
161
  )
164
162
  }
165
163
 
166
- renderLongPage() {
167
- const { printerStore, isSomeSubtotalTr } = this.props
168
- const { config } = printerStore
169
- return (
170
- <Page>
171
- <Header config={config.header} pageIndex={0} />
172
- {_.map(config.contents, (content, index) => {
173
- switch (content.type) {
174
- case 'table':
175
- // eslint-disable-next-line no-case-declarations
176
- const list = printerStore.data._table[content.dataKey]
177
- // console.log(content, "content");
178
- if (content.className === 'specialTable') {
179
- return (
180
- <LongPrintTable
181
- key={`contents.table.${index}`}
182
- name={`contents.table.${index}`}
183
- config={content}
184
- range={{ begin: 0, end: list?.length || 0 }}
185
- pageIndex={0}
186
- placeholder={`${i18next.t('区域')} ${index}`}
187
- />
188
- )
189
- } else {
190
- return (
191
- <Table
192
- key={`contents.table.${index}`}
193
- name={`contents.table.${index}`}
194
- config={content}
195
- range={{
196
- begin: 0,
197
- end: list?.length || 0
198
- }}
199
- placeholder={`${i18next.t('区域')} ${index}`}
200
- pageIndex={0}
201
- isSomeSubtotalTr={isSomeSubtotalTr}
202
- />
203
- )
204
- }
205
- default:
206
- return (
207
- <Panel
208
- key={`contents.panel.${index}`}
209
- name={`contents.panel.${index}`}
210
- config={content}
211
- pageIndex={0}
212
- placeholder={`${i18next.t('区域')} ${index}`}
213
- />
214
- )
215
- }
216
- })}
217
- </Page>
218
- )
219
- }
220
-
221
164
  renderPage() {
222
165
  const { printerStore, isSomeSubtotalTr } = this.props
223
166
  const { config, remainPageHeight, isAutoFilling } = printerStore
@@ -340,9 +283,6 @@ class Printer extends React.Component {
340
283
  const { printerStore, config } = this.props
341
284
  // batchPrintConfig: 1 不连续打印(纸张会间断)2 连续打印(纸张连续打,不间断)
342
285
  const batchPrintConfig = config.batchPrintConfig
343
- if (config.page.type === LONG_PRINT) {
344
- return !printerStore.ready ? this.renderBefore() : this.renderLongPage()
345
- }
346
286
  if (batchPrintConfig === 2) {
347
287
  return this.renderMerge()
348
288
  } else {
@@ -7,7 +7,7 @@
7
7
  font-weight: 400;
8
8
  -webkit-font-smoothing: antialiased;
9
9
  -webkit-overflow-scrolling: touch;
10
- // line-height: 2.5;
10
+ line-height: 1.5;
11
11
 
12
12
  background: white;
13
13
  page-break-after: always;
@@ -1,391 +0,0 @@
1
- import React from 'react'
2
- import PropTypes from 'prop-types'
3
- import _ from 'lodash'
4
- import {
5
- dispatchMsg,
6
- getDataKey,
7
- getHeight,
8
- getTableColumnName,
9
- getWidth
10
- } from '../../util'
11
- import { inject, observer } from 'mobx-react'
12
- import classNames from 'classnames'
13
- import SpecialTr from '../table_special_tr'
14
- import CategoryTr from '../table_category_tr'
15
- import SubtotalTr from '../table_subtotal_tr'
16
- import PageSummary from '../page_summary'
17
- import OverallOrder from '../table_overallOrder_tr'
18
- import DiyOverallOrder from '../table_diy_overallOrder_tr'
19
-
20
- @inject('printerStore')
21
- @observer
22
- class Table extends React.Component {
23
- constructor(props) {
24
- super(props)
25
- this.ref = React.createRef()
26
- this.state = {
27
- index: null
28
- }
29
- }
30
-
31
- componentDidMount() {
32
- const { name, printerStore } = this.props
33
-
34
- if (!printerStore.ready) {
35
- const $table = this.ref.current.querySelector('table')
36
- const tHead = $table.querySelector('thead')
37
- const ths = tHead.querySelectorAll('th') || []
38
- const trs = $table.querySelectorAll('tbody tr') || []
39
- const detailsDiv = $table.querySelectorAll('tr td .b-table-details')
40
-
41
- printerStore.setHeight(name, getHeight($table))
42
-
43
- printerStore.setTable(name, {
44
- head: {
45
- height: getHeight(tHead),
46
- widths: _.map(ths, th => getWidth(th))
47
- },
48
- body: {
49
- heights: _.map(trs, tr => getHeight(tr)),
50
- children: _.map(detailsDiv, div => getHeight(div))
51
- }
52
- })
53
- }
54
- }
55
-
56
- handleClick = e => {
57
- const { name } = this.props
58
- const { index } = e.target.dataset
59
- dispatchMsg('gm-printer-select', {
60
- selected: getTableColumnName(name, index)
61
- })
62
- }
63
-
64
- handleDragStart = e => {
65
- const { name } = this.props
66
- const { index } = e.target.dataset
67
-
68
- this.setState({
69
- index
70
- })
71
-
72
- dispatchMsg('gm-printer-select', {
73
- selected: getTableColumnName(name, index)
74
- })
75
- }
76
-
77
- handleSelectedRegion = () => {
78
- const { name } = this.props
79
-
80
- dispatchMsg('gm-printer-select-region', { selected: name })
81
- }
82
-
83
- handleDrop = e => {
84
- const { index } = e.target.dataset
85
- console.log(this.state.index, index)
86
- if (this.state.index !== index) {
87
- dispatchMsg('gm-printer-table-drag', {
88
- source: this.state.index,
89
- target: index
90
- })
91
- }
92
- }
93
-
94
- handleDragOver = e => {
95
- e.preventDefault()
96
- }
97
-
98
- getColumns = () => {
99
- const {
100
- config: { columns, dataKey }
101
- } = this.props
102
- const columns1 = columns.map((val, index) => ({ ...val, index }))
103
- return columns1
104
- }
105
-
106
- renderDefault() {
107
- let {
108
- config,
109
- config: { dataKey, arrange, customerRowHeight = 23 },
110
- name,
111
- range,
112
- pageIndex,
113
- printerStore,
114
- isSomeSubtotalTr
115
- } = this.props
116
- // 数据
117
- dataKey = getDataKey(dataKey, arrange)
118
- const tableData = printerStore.data._table[dataKey] || []
119
-
120
- // 列
121
- const columns = this.getColumns()
122
- // 每页合计在前
123
- const subtotalTrPageSummary = () => {
124
- return (
125
- <>
126
- <SubtotalTr
127
- range={range}
128
- config={config}
129
- printerStore={printerStore}
130
- isSomeSubtotalTr={isSomeSubtotalTr}
131
- />
132
- <PageSummary {...this.props} />
133
- </>
134
- )
135
- }
136
- // 合计在前
137
- const PageSummarySubtotalTr = () => {
138
- return (
139
- <>
140
- <PageSummary {...this.props} />
141
- <SubtotalTr
142
- range={range}
143
- config={config}
144
- printerStore={printerStore}
145
- isSomeSubtotalTr={isSomeSubtotalTr}
146
- />
147
- </>
148
- )
149
- }
150
-
151
- return (
152
- <div style={{ tableLayout: 'inherit', wordBreak: 'break-all' }}>
153
- {_.map(_.range(range.begin, range.end), i => {
154
- const _special = tableData[i] && tableData[i]._special
155
- const _specialText = tableData[i] && tableData[i]._specialText
156
- if (_specialText)
157
- return <CategoryTr key={i} config={config} data={_specialText} />
158
- if (_special)
159
- return <SpecialTr key={i} config={config} data={_special} />
160
- // 如果项为空对象展现一个占满一行的td
161
- const isItemNone = !_.keys(tableData[i]).length
162
- console.log(columns, 'columns')
163
- return (
164
- <div key={i} style={{ borderTop: '1px dashed black' }}>
165
- {isItemNone
166
- ? null
167
- : _.map(columns, (col, j) => {
168
- return (
169
- <div
170
- key={j}
171
- data-name={getTableColumnName(name, col.index)}
172
- data-index={col.index}
173
- onClick={this.handleClick}
174
- draggable
175
- onDragStart={this.handleDragStart}
176
- onDrop={this.handleDrop}
177
- onDragOver={this.handleDragOver}
178
- style={{ padding: '2px 0' }}
179
- className={classNames('long_print_table_row', {
180
- active:
181
- getTableColumnName(name, col.index) ===
182
- printerStore.selected
183
- })}
184
- >
185
- <span
186
- data-name={getTableColumnName(name, col.index)}
187
- data-index={col.index}
188
- onClick={this.handleClick}
189
- style={{ ...col.headStyle }}
190
- >
191
- {col.head}:
192
- </span>
193
- <span
194
- style={{
195
- ...col.style
196
- }}
197
- data-name={getTableColumnName(name, col.index)}
198
- data-index={col.index}
199
- onClick={this.handleClick}
200
- dangerouslySetInnerHTML={{
201
- __html: col.isSpecialColumn
202
- ? printerStore.templateSpecialDetails(
203
- col,
204
- dataKey,
205
- i
206
- )
207
- : printerStore
208
- .templateTable(
209
- col.text,
210
- dataKey,
211
- i,
212
- pageIndex
213
- )
214
- .replace(/\(\)/g, '')
215
- }}
216
- />
217
- </div>
218
- )
219
- })}
220
- </div>
221
- )
222
- })}
223
- {this.props.config.subtotal.isCommutationPlace
224
- ? PageSummarySubtotalTr()
225
- : subtotalTrPageSummary()}
226
- <OverallOrder
227
- range={range}
228
- config={config}
229
- printerStore={printerStore}
230
- />
231
- <DiyOverallOrder
232
- range={range}
233
- config={config}
234
- printerStore={printerStore}
235
- pageIndex={pageIndex}
236
- />
237
- </div>
238
- )
239
-
240
- return (
241
- <table
242
- style={{
243
- // td会撑开table的宽度
244
- tableLayout: 'inherit',
245
- wordBreak: 'break-all'
246
- }}
247
- >
248
- <thead>
249
- <tr style={{ height: `${customerRowHeight}px` }}>
250
- {_.map(columns, (col, i) => (
251
- <th
252
- key={i}
253
- data-index={col.index}
254
- data-name={getTableColumnName(name, col.index)}
255
- draggable
256
- style={{
257
- ...getTdStyle(i, col.headStyle),
258
- ...col.headStyle
259
- }}
260
- className={classNames({
261
- active:
262
- getTableColumnName(name, col.index) ===
263
- printerStore.selected
264
- })}
265
- onClick={this.handleClick}
266
- onDragStart={this.handleDragStart}
267
- onDrop={this.handleDrop}
268
- onDragOver={this.handleDragOver}
269
- >
270
- {col.head}
271
- </th>
272
- ))}
273
- </tr>
274
- </thead>
275
- <tbody>
276
- {_.map(_.range(range.begin, range.end), i => {
277
- const _special = tableData[i] && tableData[i]._special
278
- const _specialText = tableData[i] && tableData[i]._specialText
279
- if (_specialText)
280
- return <CategoryTr key={i} config={config} data={_specialText} />
281
- if (_special)
282
- return <SpecialTr key={i} config={config} data={_special} />
283
- // 如果项为空对象展现一个占满一行的td
284
- const isItemNone = !_.keys(tableData[i]).length
285
-
286
- return (
287
- <tr style={{ height: `${customerRowHeight}px` }} key={i}>
288
- {isItemNone ? (
289
- <td colSpan='99' />
290
- ) : (
291
- _.map(columns, (col, j) => {
292
- return (
293
- <td
294
- key={j}
295
- data-name={getTableColumnName(name, col.index)}
296
- style={{
297
- ...getTdStyle(j, col.style),
298
- ...col.style
299
- }}
300
- className={classNames({
301
- active:
302
- getTableColumnName(name, col.index) ===
303
- printerStore.selected
304
- })}
305
- dangerouslySetInnerHTML={{
306
- __html: col.isSpecialColumn
307
- ? printerStore.templateSpecialDetails(
308
- col,
309
- dataKey,
310
- i
311
- )
312
- : printerStore
313
- .templateTable(col.text, dataKey, i, pageIndex)
314
- .replace(/\(\)/g, '')
315
- }}
316
- />
317
- )
318
- })
319
- )}
320
- </tr>
321
- )
322
- })}
323
- {this.props.config.subtotal.isCommutationPlace
324
- ? PageSummarySubtotalTr()
325
- : subtotalTrPageSummary()}
326
- <OverallOrder
327
- range={range}
328
- config={config}
329
- printerStore={printerStore}
330
- />
331
- <DiyOverallOrder
332
- range={range}
333
- config={config}
334
- printerStore={printerStore}
335
- pageIndex={pageIndex}
336
- />
337
- </tbody>
338
- </table>
339
- )
340
- }
341
-
342
- renderEmptyTable() {
343
- return (
344
- <table>
345
- <thead />
346
- <tbody>
347
- <tr />
348
- </tbody>
349
- </table>
350
- )
351
- }
352
-
353
- render() {
354
- let {
355
- config: { className, dataKey, arrange },
356
- name,
357
- placeholder,
358
- printerStore
359
- } = this.props
360
- dataKey = getDataKey(dataKey, arrange)
361
- const tableData = printerStore.data._table[dataKey] || []
362
- const active = printerStore.selectedRegion === name
363
- return (
364
- <div
365
- ref={this.ref}
366
- className={classNames(
367
- 'gm-printer-table',
368
- 'gm-printer-table-classname-' + (className || 'default'),
369
- { active }
370
- )}
371
- data-name={name}
372
- data-placeholder={placeholder}
373
- onClick={this.handleSelectedRegion}
374
- >
375
- {tableData.length ? this.renderDefault() : this.renderEmptyTable()}
376
- </div>
377
- )
378
- }
379
- }
380
-
381
- Table.propTypes = {
382
- config: PropTypes.object.isRequired,
383
- name: PropTypes.string.isRequired,
384
- range: PropTypes.object.isRequired,
385
- pageIndex: PropTypes.number.isRequired,
386
- placeholder: PropTypes.string,
387
- printerStore: PropTypes.object,
388
- isSomeSubtotalTr: PropTypes.bool
389
- }
390
-
391
- export default Table