gm-printer 10.28.0-beta.1 → 10.28.0-beta.2
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/package.json +1 -1
- package/src/common/common_context_menu.js +17 -12
- package/src/common/editor_edit_field.js +18 -14
- package/src/common/editor_select.js +38 -29
- package/src/config.js +8 -5
- package/src/editor/context_menu.js +10 -7
- package/src/printer/long_print_table/index.js +96 -87
- package/src/printer/page.js +7 -2
- package/src/printer/printer.js +40 -37
package/.eslintcache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"/Users/joke/Desktop/gm-printer/src/printer/printer.js":"1","/Users/joke/Desktop/gm-printer/src/printer/page.js":"2","/Users/joke/Desktop/gm-printer/src/printer/long_print_table/index.js":"3","/Users/joke/Desktop/gm-printer/src/editor/context_menu.js":"4","/Users/joke/Desktop/gm-printer/src/config.js":"5","/Users/joke/Desktop/gm-printer/src/common/editor_select.js":"6","/Users/joke/Desktop/gm-printer/src/common/editor_edit_field.js":"7","/Users/joke/Desktop/gm-printer/src/common/common_context_menu.js":"8"},{"size":12305,"mtime":1728981026281},{"size":1899,"mtime":1728981006613},{"size":11905,"mtime":1728980840768,"results":"9","hashOfConfig":"10"},{"size":6329,"mtime":1728980977665},{"size":3185,"mtime":1728980903446},{"size":6042,"mtime":1728980953458,"results":"11","hashOfConfig":"10"},{"size":24316,"mtime":1728980939561},{"size":9821,"mtime":1728980917598,"results":"12","hashOfConfig":"10"},{"filePath":"13","messages":"14","errorCount":4,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},"1ho4xzn",{"filePath":"15","messages":"16","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"17","messages":"18","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/Users/joke/Desktop/gm-printer/src/printer/long_print_table/index.js",["19","20","21","22"],"/Users/joke/Desktop/gm-printer/src/common/editor_select.js",[],"/Users/joke/Desktop/gm-printer/src/common/common_context_menu.js",[],{"ruleId":"23","severity":2,"message":"24","line":100,"column":26,"nodeType":"25","endLine":100,"endColumn":33},{"ruleId":"26","severity":2,"message":"27","line":240,"column":5,"nodeType":"28","endLine":339,"endColumn":6},{"ruleId":"29","severity":2,"message":"30","line":257,"column":22,"nodeType":"25","messageId":"31","endLine":257,"endColumn":32},{"ruleId":"29","severity":2,"message":"30","line":297,"column":30,"nodeType":"25","messageId":"31","endLine":297,"endColumn":40},"no-unused-vars","'dataKey' is assigned a value but never used.","Identifier","no-unreachable","Unreachable code.","ReturnStatement","no-undef","'getTdStyle' is not defined.","undef"]
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import i18next from '../../locales'
|
|
2
2
|
import React, { useEffect } from 'react'
|
|
3
3
|
import PropTypes from 'prop-types'
|
|
4
|
-
import { tableClassNameList } from '../config'
|
|
4
|
+
import { tableClassNameList, LONG_PRINT } from '../config'
|
|
5
5
|
import _ from 'lodash'
|
|
6
6
|
import { Hr, ImageUploader } from '../common/component'
|
|
7
7
|
import { observer, inject } from 'mobx-react'
|
|
@@ -192,7 +192,7 @@ class CommonContextMenu extends React.Component {
|
|
|
192
192
|
const { className } = editStore.config.contents[arr[2]]
|
|
193
193
|
const isActive = c => className === c
|
|
194
194
|
const { config } = editStore
|
|
195
|
-
const isLongPrint = config?.page?.type ===
|
|
195
|
+
const isLongPrint = config?.page?.type === LONG_PRINT
|
|
196
196
|
return (
|
|
197
197
|
<>
|
|
198
198
|
{renderTableAction && (
|
|
@@ -205,16 +205,21 @@ class CommonContextMenu extends React.Component {
|
|
|
205
205
|
<div onClick={this.handleRemove}>{i18next.t('移除列')}</div>
|
|
206
206
|
<Hr />
|
|
207
207
|
|
|
208
|
-
{!isLongPrint &&
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
208
|
+
{!isLongPrint && (
|
|
209
|
+
<>
|
|
210
|
+
{' '}
|
|
211
|
+
{_.map(tableClassNameList, o => (
|
|
212
|
+
<div
|
|
213
|
+
onClick={this.handleSetTableConfig.bind(this, o.value)}
|
|
214
|
+
key={o.value}
|
|
215
|
+
className={isActive(o.value) ? 'active' : ''}
|
|
216
|
+
>
|
|
217
|
+
{o.text}
|
|
218
|
+
</div>
|
|
219
|
+
))}{' '}
|
|
220
|
+
<Hr />
|
|
221
|
+
</>
|
|
222
|
+
)}
|
|
218
223
|
|
|
219
224
|
<div onClick={this.handleAddContent.bind(this, 0, '')}>
|
|
220
225
|
{i18next.t('向上插入区域块')}
|
|
@@ -20,6 +20,7 @@ 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'
|
|
23
24
|
import _ from 'lodash'
|
|
24
25
|
|
|
25
26
|
@inject('editStore')
|
|
@@ -199,7 +200,8 @@ class EditorField extends React.Component {
|
|
|
199
200
|
renderTable() {
|
|
200
201
|
const { tableDataKeyList, editStore, isSomeSubtotalTr } = this.props
|
|
201
202
|
const { head, headStyle, text, style } = editStore.computedSelectedInfo
|
|
202
|
-
|
|
203
|
+
const { config } = editStore
|
|
204
|
+
const isLongPrint = config?.page?.type === LONG_PRINT
|
|
203
205
|
const {
|
|
204
206
|
specialConfig,
|
|
205
207
|
subtotal,
|
|
@@ -362,19 +364,21 @@ class EditorField extends React.Component {
|
|
|
362
364
|
|
|
363
365
|
<Gap height='5px' />
|
|
364
366
|
|
|
365
|
-
|
|
366
|
-
<Flex alignCenter>
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
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
|
+
)}
|
|
378
382
|
|
|
379
383
|
<Gap height='5px' />
|
|
380
384
|
|
|
@@ -2,12 +2,9 @@ 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
|
+
import { RadioGroup, Radio } from '@gmfe/react'
|
|
9
6
|
import { InputWithUnit } from '../common/component'
|
|
10
|
-
import { pageTypeMap, printDirectionList } from '../config'
|
|
7
|
+
import { pageTypeMap, printDirectionList, LONG_PRINT } from '../config'
|
|
11
8
|
import _ from 'lodash'
|
|
12
9
|
import { dispatchMsg } from '../util'
|
|
13
10
|
import PropTypes from 'prop-types'
|
|
@@ -19,7 +16,7 @@ class EditorSelector extends React.Component {
|
|
|
19
16
|
this.props.editStore.setConfigName(e.target.value)
|
|
20
17
|
}
|
|
21
18
|
|
|
22
|
-
handleConfigIsFixLastFooter =
|
|
19
|
+
handleConfigIsFixLastFooter = _val => {
|
|
23
20
|
this.props.editStore.setConfigIsFixLastFooter(_val)
|
|
24
21
|
}
|
|
25
22
|
|
|
@@ -45,13 +42,19 @@ class EditorSelector extends React.Component {
|
|
|
45
42
|
|
|
46
43
|
render() {
|
|
47
44
|
const {
|
|
48
|
-
config: {
|
|
45
|
+
config: {
|
|
46
|
+
name,
|
|
47
|
+
page,
|
|
48
|
+
batchPrintConfig,
|
|
49
|
+
isFixLastFooter,
|
|
50
|
+
showDiyOverAllOrder
|
|
51
|
+
},
|
|
49
52
|
computedRegionList,
|
|
50
53
|
computedSelectedRegionTip,
|
|
51
54
|
selectedRegion
|
|
52
55
|
} = this.props.editStore
|
|
53
56
|
const isDIY = page.type === 'DIY'
|
|
54
|
-
const isLongPrint = page.type ===
|
|
57
|
+
const isLongPrint = page.type === LONG_PRINT
|
|
55
58
|
return (
|
|
56
59
|
<div>
|
|
57
60
|
<Flex alignCenter>
|
|
@@ -102,20 +105,22 @@ class EditorSelector extends React.Component {
|
|
|
102
105
|
/>
|
|
103
106
|
</Flex>
|
|
104
107
|
)}
|
|
105
|
-
{!isLongPrint &&
|
|
106
|
-
<
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
{v.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
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
|
+
)}
|
|
119
124
|
|
|
120
125
|
<Flex alignCenter className='gm-padding-top-5'>
|
|
121
126
|
<div>{i18next.t('选择区域')}:</div>
|
|
@@ -156,21 +161,25 @@ class EditorSelector extends React.Component {
|
|
|
156
161
|
</>
|
|
157
162
|
)}
|
|
158
163
|
|
|
159
|
-
{
|
|
160
|
-
|
|
161
|
-
<label htmlFor={1}
|
|
164
|
+
{showDiyOverAllOrder !== undefined && (
|
|
165
|
+
<Flex alignCenter className='gm-padding-top-5'>
|
|
166
|
+
<label htmlFor={1}>是否固定末页签名和页脚区域:</label>
|
|
162
167
|
<RadioGroup
|
|
163
168
|
name='isFixFooter'
|
|
164
169
|
value={isFixLastFooter}
|
|
165
170
|
inline
|
|
166
171
|
onChange={this.handleConfigIsFixLastFooter}
|
|
167
|
-
className=
|
|
172
|
+
className='gm-flex'
|
|
168
173
|
>
|
|
169
|
-
<Radio value
|
|
170
|
-
|
|
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>
|
|
171
180
|
</RadioGroup>
|
|
172
181
|
</Flex>
|
|
173
|
-
}
|
|
182
|
+
)}
|
|
174
183
|
|
|
175
184
|
<Flex className='gm-padding-top-5 gm-text-red' column>
|
|
176
185
|
{computedSelectedRegionTip}
|
package/src/config.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import i18next from '../locales'
|
|
2
|
+
|
|
3
|
+
export const LONG_PRINT = 'longPrint'
|
|
4
|
+
|
|
2
5
|
export const pageTypeMap = {
|
|
3
6
|
A4: {
|
|
4
7
|
name: 'A4',
|
|
@@ -79,7 +82,7 @@ export const pageTypeMap = {
|
|
|
79
82
|
}
|
|
80
83
|
},
|
|
81
84
|
// 新增长条打印配置选项
|
|
82
|
-
|
|
85
|
+
[LONG_PRINT]: {
|
|
83
86
|
name: i18next.t('长条打印'),
|
|
84
87
|
size: {
|
|
85
88
|
width: '80mm',
|
|
@@ -87,10 +90,10 @@ export const pageTypeMap = {
|
|
|
87
90
|
},
|
|
88
91
|
printDirection: 'vertical',
|
|
89
92
|
gap: {
|
|
90
|
-
paddingTop: '
|
|
91
|
-
paddingRight: '
|
|
92
|
-
paddingBottom: '
|
|
93
|
-
paddingLeft: '
|
|
93
|
+
paddingTop: '2mm',
|
|
94
|
+
paddingRight: '2mm',
|
|
95
|
+
paddingBottom: '2mm',
|
|
96
|
+
paddingLeft: '2mm'
|
|
94
97
|
}
|
|
95
98
|
},
|
|
96
99
|
DIY: {
|
|
@@ -6,6 +6,7 @@ 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'
|
|
9
10
|
|
|
10
11
|
const blockTypeList = [
|
|
11
12
|
{ value: '', text: i18next.t('插入文本') },
|
|
@@ -123,16 +124,18 @@ class ContextMenu extends React.Component {
|
|
|
123
124
|
const isOverallOrder = overallOrder?.show
|
|
124
125
|
const isDiyOverallOrder = diyOverallOrder?.show
|
|
125
126
|
// 长条打印
|
|
126
|
-
const isLongPrint = type ===
|
|
127
|
+
const isLongPrint = type === LONG_PRINT
|
|
127
128
|
|
|
128
129
|
return (
|
|
129
130
|
<>
|
|
130
|
-
{!isLongPrint &&
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
131
|
+
{!isLongPrint && (
|
|
132
|
+
<div
|
|
133
|
+
onClick={this.handleChangeTableDataKey.bind(this, 'multi', name)}
|
|
134
|
+
className={isMultiActive ? 'active' : ''}
|
|
135
|
+
>
|
|
136
|
+
{i18next.t('双栏商品')}
|
|
137
|
+
</div>
|
|
138
|
+
)}
|
|
136
139
|
{/* 三分纸高度太小,做不了三栏,会死循环 */}
|
|
137
140
|
{type !== 'A4/3' && !isLongPrint && (
|
|
138
141
|
<div
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
getDataKey,
|
|
7
7
|
getHeight,
|
|
8
8
|
getTableColumnName,
|
|
9
|
-
getWidth
|
|
9
|
+
getWidth
|
|
10
10
|
} from '../../util'
|
|
11
11
|
import { inject, observer } from 'mobx-react'
|
|
12
12
|
import classNames from 'classnames'
|
|
@@ -82,7 +82,7 @@ class Table extends React.Component {
|
|
|
82
82
|
|
|
83
83
|
handleDrop = e => {
|
|
84
84
|
const { index } = e.target.dataset
|
|
85
|
-
console.log(this.state.index, index)
|
|
85
|
+
console.log(this.state.index, index)
|
|
86
86
|
if (this.state.index !== index) {
|
|
87
87
|
dispatchMsg('gm-printer-table-drag', {
|
|
88
88
|
source: this.state.index,
|
|
@@ -148,85 +148,94 @@ class Table extends React.Component {
|
|
|
148
148
|
)
|
|
149
149
|
}
|
|
150
150
|
|
|
151
|
-
return (
|
|
152
|
-
{
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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
|
+
)
|
|
230
239
|
|
|
231
240
|
return (
|
|
232
241
|
<table
|
|
@@ -296,13 +305,13 @@ class Table extends React.Component {
|
|
|
296
305
|
dangerouslySetInnerHTML={{
|
|
297
306
|
__html: col.isSpecialColumn
|
|
298
307
|
? printerStore.templateSpecialDetails(
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
308
|
+
col,
|
|
309
|
+
dataKey,
|
|
310
|
+
i
|
|
311
|
+
)
|
|
303
312
|
: printerStore
|
|
304
|
-
|
|
305
|
-
|
|
313
|
+
.templateTable(col.text, dataKey, i, pageIndex)
|
|
314
|
+
.replace(/\(\)/g, '')
|
|
306
315
|
}}
|
|
307
316
|
/>
|
|
308
317
|
)
|
package/src/printer/page.js
CHANGED
|
@@ -3,6 +3,7 @@ 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'
|
|
6
7
|
|
|
7
8
|
@inject('printerStore')
|
|
8
9
|
@observer
|
|
@@ -44,7 +45,9 @@ class Page extends React.Component {
|
|
|
44
45
|
...pageStyle,
|
|
45
46
|
boxSizing: 'content-box',
|
|
46
47
|
width: `calc(${width} - ${paddingLeft} - ${paddingRight})`,
|
|
47
|
-
[type
|
|
48
|
+
[type === LONG_PRINT
|
|
49
|
+
? 'minHeight'
|
|
50
|
+
: 'height']: `calc(${height} - ${paddingTop} - ${paddingBottom} ${x})`,
|
|
48
51
|
padding: `${paddingTop} ${paddingRight} ${paddingBottom} ${paddingLeft}`
|
|
49
52
|
}}
|
|
50
53
|
>
|
|
@@ -52,7 +55,9 @@ class Page extends React.Component {
|
|
|
52
55
|
className='gm-printer-page-inner'
|
|
53
56
|
style={{
|
|
54
57
|
width: `calc(${width} - ${paddingLeft} - ${paddingRight})`,
|
|
55
|
-
[type
|
|
58
|
+
[type === LONG_PRINT
|
|
59
|
+
? 'minHeight'
|
|
60
|
+
: 'height']: `calc(${height} - ${paddingTop} - ${paddingBottom} ${x})`
|
|
56
61
|
}}
|
|
57
62
|
>
|
|
58
63
|
{children}
|
package/src/printer/printer.js
CHANGED
|
@@ -8,8 +8,9 @@ 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
|
|
11
|
+
import LongPrintTable from './long_print_table'
|
|
12
12
|
import MergePage from './merge_page'
|
|
13
|
+
import { LONG_PRINT } from '../config'
|
|
13
14
|
|
|
14
15
|
// Header Sign Footer 相对特殊,要单独处理
|
|
15
16
|
const Header = props => (
|
|
@@ -165,37 +166,39 @@ class Printer extends React.Component {
|
|
|
165
166
|
renderLongPage() {
|
|
166
167
|
const { printerStore } = this.props
|
|
167
168
|
const { config } = printerStore
|
|
168
|
-
return
|
|
169
|
-
<
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
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
|
+
return (
|
|
178
|
+
<LongPrintTable
|
|
179
|
+
key={`contents.table.${index}`}
|
|
180
|
+
name={`contents.table.${index}`}
|
|
181
|
+
config={content}
|
|
182
|
+
range={{ begin: 0, end: list?.length || 0 }}
|
|
183
|
+
pageIndex={0}
|
|
184
|
+
placeholder={`${i18next.t('区域')} ${index}`}
|
|
185
|
+
/>
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
default:
|
|
189
|
+
return (
|
|
190
|
+
<Panel
|
|
191
|
+
key={`contents.panel.${index}`}
|
|
192
|
+
name={`contents.panel.${index}`}
|
|
193
|
+
config={content}
|
|
194
|
+
pageIndex={0}
|
|
195
|
+
placeholder={`${i18next.t('区域')} ${index}`}
|
|
196
|
+
/>
|
|
197
|
+
)
|
|
198
|
+
}
|
|
199
|
+
})}
|
|
200
|
+
</Page>
|
|
201
|
+
)
|
|
199
202
|
}
|
|
200
203
|
|
|
201
204
|
renderPage() {
|
|
@@ -221,10 +224,10 @@ class Printer extends React.Component {
|
|
|
221
224
|
|
|
222
225
|
const end = isAutofillConfig
|
|
223
226
|
? panel.end +
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
227
|
+
Math.floor(
|
|
228
|
+
remainPageHeight /
|
|
229
|
+
printerStore.computedTableCustomerRowHeight
|
|
230
|
+
)
|
|
228
231
|
: panel.end
|
|
229
232
|
switch (panel.type) {
|
|
230
233
|
case 'table':
|
|
@@ -320,7 +323,7 @@ class Printer extends React.Component {
|
|
|
320
323
|
const { printerStore, config } = this.props
|
|
321
324
|
// batchPrintConfig: 1 不连续打印(纸张会间断)2 连续打印(纸张连续打,不间断)
|
|
322
325
|
const batchPrintConfig = config.batchPrintConfig
|
|
323
|
-
if (config.page.type ===
|
|
326
|
+
if (config.page.type === LONG_PRINT) {
|
|
324
327
|
return !printerStore.ready ? this.renderBefore() : this.renderLongPage()
|
|
325
328
|
}
|
|
326
329
|
if (batchPrintConfig === 2) {
|