gm-printer 10.28.0-beta.3 → 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 ADDED
@@ -0,0 +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"},{"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.3",
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, longPrintTableClassNameList, 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'
@@ -234,8 +238,8 @@ class CommonContextMenu extends React.Component {
234
238
  </div>
235
239
  ))}{' '}
236
240
  <Hr />
237
- </>)
238
- }
241
+ </>
242
+ )}
239
243
 
240
244
  <div onClick={this.handleAddContent.bind(this, 0, '')}>
241
245
  {i18next.t('向上插入区域块')}
@@ -564,7 +564,7 @@ class EditorField extends React.Component {
564
564
  value={
565
565
  subtotal && subtotal?.fields?.length > 1
566
566
  ? _.find(subtotal?.fields, item => !item.valueField)?.name ??
567
- ''
567
+ ''
568
568
  : ''
569
569
  }
570
570
  onChange={editStore.setSubtotalFields}
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}
@@ -175,7 +175,7 @@ class Printer extends React.Component {
175
175
  // eslint-disable-next-line no-case-declarations
176
176
  const list = printerStore.data._table[content.dataKey]
177
177
  // console.log(content, "content");
178
- if (content.className === "specialTable") {
178
+ if (content.className === 'specialTable') {
179
179
  return (
180
180
  <LongPrintTable
181
181
  key={`contents.table.${index}`}
@@ -187,18 +187,20 @@ class Printer extends React.Component {
187
187
  />
188
188
  )
189
189
  } else {
190
- return <Table
191
- key={`contents.table.${index}`}
192
- name={`contents.table.${index}`}
193
- config={content}
194
- range={{
195
- begin: 0,
196
- end: list?.length || 0
197
- }}
198
- placeholder={`${i18next.t('区域')} ${index}`}
199
- pageIndex={0}
200
- isSomeSubtotalTr={isSomeSubtotalTr}
201
- />
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
+ )
202
204
  }
203
205
  default:
204
206
  return (
@@ -239,10 +241,10 @@ class Printer extends React.Component {
239
241
 
240
242
  const end = isAutofillConfig
241
243
  ? panel.end +
242
- Math.floor(
243
- remainPageHeight /
244
- printerStore.computedTableCustomerRowHeight
245
- )
244
+ Math.floor(
245
+ remainPageHeight /
246
+ printerStore.computedTableCustomerRowHeight
247
+ )
246
248
  : panel.end
247
249
  switch (panel.type) {
248
250
  case 'table':