gm-printer 10.28.0-beta.2 → 10.28.0-beta.4

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/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"]
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"},{"size":12947,"mtime":1730112542854},{"size":3569,"mtime":1730112081043,"results":"5","hashOfConfig":"6"},{"size":25058,"mtime":1730112453858},{"size":10273,"mtime":1730112252986},{"filePath":"7","messages":"8","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1ho4xzn","/Users/joke/Desktop/gm-printer/src/config.js",[]]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-printer",
3
- "version": "10.28.0-beta.2",
3
+ "version": "10.28.0-beta.4",
4
4
  "description": "diy printer",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -1,7 +1,11 @@
1
1
  import i18next from '../../locales'
2
2
  import React, { useEffect } from 'react'
3
3
  import PropTypes from 'prop-types'
4
- import { tableClassNameList, LONG_PRINT } from '../config'
4
+ import {
5
+ tableClassNameList,
6
+ longPrintTableClassNameList,
7
+ LONG_PRINT
8
+ } from '../config'
5
9
  import _ from 'lodash'
6
10
  import { Hr, ImageUploader } from '../common/component'
7
11
  import { observer, inject } from 'mobx-react'
@@ -221,6 +225,22 @@ class CommonContextMenu extends React.Component {
221
225
  </>
222
226
  )}
223
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
+ )}
243
+
224
244
  <div onClick={this.handleAddContent.bind(this, 0, '')}>
225
245
  {i18next.t('向上插入区域块')}
226
246
  </div>
@@ -380,6 +380,23 @@ class EditorField extends React.Component {
380
380
  </Flex>
381
381
  )}
382
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
+ )}
399
+
383
400
  <Gap height='5px' />
384
401
 
385
402
  <Flex>
package/src/config.js CHANGED
@@ -125,7 +125,16 @@ export const borderStyleList = [
125
125
  export const tableClassNameList = [
126
126
  { value: '', text: i18next.t('默认样式') },
127
127
  { value: 'className0', text: i18next.t('浅实线样式') },
128
- { value: 'className1', 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('样式四') }
129
138
  ]
130
139
 
131
140
  export const tableDataKeyList = [
package/src/index.js CHANGED
@@ -17,7 +17,8 @@ import {
17
17
  Printer,
18
18
  getCSS,
19
19
  getPrintContainerHTML,
20
- doBatchFinancePrint
20
+ doBatchFinancePrint,
21
+ setPrintStyle
21
22
  } from './printer'
22
23
  import { MULTI_SUFFIX, MULTI_SUFFIX3 } from './config'
23
24
 
@@ -43,5 +44,6 @@ export {
43
44
  MULTI_SUFFIX,
44
45
  MULTI_SUFFIX3,
45
46
  getPrintContainerHTML,
46
- doBatchFinancePrint
47
+ doBatchFinancePrint,
48
+ setPrintStyle
47
49
  }
@@ -77,14 +77,16 @@ function toDoPrint({ data, config }, isSomeSubtotalTr) {
77
77
  function toDoPrintBatch(list, isPrint = true) {
78
78
  return new window.Promise(resolve => {
79
79
  const $app = $printer.contentWindow.document.getElementById('appContainer')
80
-
80
+ // 获取模版类型
81
+ const templateType = list?.[0]?.config?.page?.type
82
+ // 初始化
81
83
  ReactDOM.unmountComponentAtNode($app)
82
84
  ReactDOM.render(
83
85
  <BatchPrinter
84
86
  list={list}
85
87
  onReady={() => {
86
88
  afterImgAndSvgLoaded(() => {
87
- isPrint && $printer.contentWindow.print()
89
+ isPrint && templateType !== "longPrint" && $printer.contentWindow.print()
88
90
  resolve()
89
91
  }, $app)
90
92
  }}
@@ -145,4 +147,11 @@ function getPrintContainerHTML() {
145
147
  return $printer.contentWindow.document.getElementsByTagName('html')[0]
146
148
  .innerHTML
147
149
  }
148
- export { doPrint, doBatchPrint, getPrintContainerHTML, doBatchFinancePrint }
150
+
151
+ function setPrintStyle() {
152
+ const doc = document
153
+ const style = doc.createElement('style')
154
+ style.appendChild(doc.createTextNode(getCSS()))
155
+ doc.head.appendChild(style)
156
+ }
157
+ export { doPrint, doBatchPrint, getPrintContainerHTML, doBatchFinancePrint, setPrintStyle }
@@ -4,7 +4,8 @@ import {
4
4
  doPrint,
5
5
  doBatchPrint,
6
6
  getPrintContainerHTML,
7
- doBatchFinancePrint
7
+ doBatchFinancePrint,
8
+ setPrintStyle
8
9
  } from './do_print'
9
10
  import getCSS from './get_css'
10
11
 
@@ -15,5 +16,6 @@ export {
15
16
  BatchPrinter,
16
17
  getCSS,
17
18
  getPrintContainerHTML,
18
- doBatchFinancePrint
19
+ doBatchFinancePrint,
20
+ setPrintStyle
19
21
  }
@@ -44,20 +44,16 @@ class Page extends React.Component {
44
44
  style={{
45
45
  ...pageStyle,
46
46
  boxSizing: 'content-box',
47
- width: `calc(${width} - ${paddingLeft} - ${paddingRight})`,
48
- [type === LONG_PRINT
49
- ? 'minHeight'
50
- : 'height']: `calc(${height} - ${paddingTop} - ${paddingBottom} ${x})`,
51
- padding: `${paddingTop} ${paddingRight} ${paddingBottom} ${paddingLeft}`
47
+ width: type === LONG_PRINT ? `${width}` : `calc(${width} - ${paddingLeft} - ${paddingRight})`,
48
+ padding: `${paddingTop} ${paddingRight} ${paddingBottom} ${paddingLeft}`,
49
+ height: type === LONG_PRINT ? `` : `calc(${height} - ${paddingTop} - ${paddingBottom} ${x})`,
52
50
  }}
53
51
  >
54
52
  <div
55
53
  className='gm-printer-page-inner'
56
54
  style={{
57
- width: `calc(${width} - ${paddingLeft} - ${paddingRight})`,
58
- [type === LONG_PRINT
59
- ? 'minHeight'
60
- : 'height']: `calc(${height} - ${paddingTop} - ${paddingBottom} ${x})`
55
+ width: type === LONG_PRINT ? `${width}` : `calc(${width} - ${paddingLeft} - ${paddingRight})`,
56
+ height: type === LONG_PRINT ? `` : `calc(${height} - ${paddingTop} - ${paddingBottom} ${x})`
61
57
  }}
62
58
  >
63
59
  {children}
@@ -164,7 +164,7 @@ class Printer extends React.Component {
164
164
  }
165
165
 
166
166
  renderLongPage() {
167
- const { printerStore } = this.props
167
+ const { printerStore, isSomeSubtotalTr } = this.props
168
168
  const { config } = printerStore
169
169
  return (
170
170
  <Page>
@@ -174,17 +174,34 @@ class Printer extends React.Component {
174
174
  case 'table':
175
175
  // eslint-disable-next-line no-case-declarations
176
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
-
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
+ }
188
205
  default:
189
206
  return (
190
207
  <Panel