gm-printer 10.37.1 → 10.37.3-beta.0

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.
@@ -0,0 +1,85 @@
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import _ from 'lodash'
4
+ import { Flex } from '../components'
5
+ import { Gap, Title } from '../common/component'
6
+ import editStore from './store'
7
+ import { observer, inject } from 'mobx-react'
8
+ import EditorTitle from '../common/editor_title'
9
+ import EditorSelect from '../common/editor_select'
10
+ import EditorField from '../common/editor_edit_field'
11
+ import EditorAddField from '../common/editor_add_field'
12
+ import ContextMenu from './context_menu'
13
+ import i18next from '../../locales'
14
+ import withStore from '../common/hoc_with_store'
15
+
16
+ const tableDataKeyList = [
17
+ {
18
+ value: 'examiningDetail',
19
+ text: i18next.t('检测明细'),
20
+ hasSubtotalBtn: true
21
+ }
22
+ ]
23
+
24
+ @withStore(editStore)
25
+ @inject('editStore')
26
+ @observer
27
+ class Editor extends React.Component {
28
+ render() {
29
+ const { onSave, showEditor, addFields, menuConfig } = this.props
30
+
31
+ return (
32
+ <div className='gm-printer-edit'>
33
+ <Flex className='gm-printer-edit-title-fixed'>
34
+ <Title
35
+ title={i18next.t('模板预览')}
36
+ text={
37
+ <span className='gm-text-desc gm-padding-left-5'>
38
+ {i18next.t(
39
+ '说明:选中内容进行编辑,可拖动字段移动位置,右键使用更多功能'
40
+ )}
41
+ </span>
42
+ }
43
+ />
44
+ </Flex>
45
+
46
+ {showEditor && (
47
+ <div className='gm-printer-edit-zone'>
48
+ <EditorTitle onSave={onSave} />
49
+ <Gap height='10px' />
50
+ <EditorSelect />
51
+ <Gap height='5px' />
52
+ <EditorField tableDataKeyList={tableDataKeyList} />
53
+ <Gap height='5px' />
54
+ <EditorAddField addFields={addFields} />
55
+
56
+ <div id='gm-printer-tip' />
57
+ <div id='gm-printer-modal' />
58
+ </div>
59
+ )}
60
+
61
+ <div className='gm-printer-edit-wrap'>
62
+ <ContextMenu menuConfig={menuConfig} />
63
+ </div>
64
+ </div>
65
+ )
66
+ }
67
+ }
68
+
69
+ Editor.propTypes = {
70
+ config: PropTypes.object.isRequired,
71
+ onSave: PropTypes.func,
72
+ showEditor: PropTypes.bool,
73
+ mockData: PropTypes.object.isRequired,
74
+ addFields: PropTypes.object.isRequired,
75
+ menuConfig: PropTypes.oneOfType([
76
+ PropTypes.arrayOf(PropTypes.string),
77
+ PropTypes.object
78
+ ])
79
+ }
80
+
81
+ Editor.defaultProps = {
82
+ onSave: _.noop
83
+ }
84
+
85
+ export default Editor
@@ -0,0 +1,4 @@
1
+ import withShadowDom from '../common/hoc_with_shadow_dom'
2
+ import Editor from './editor'
3
+
4
+ export default withShadowDom(Editor)
@@ -0,0 +1,74 @@
1
+ import EditorStore from '../common/editor_store'
2
+ import { action, toJS } from 'mobx'
3
+ import i18next from '../../locales'
4
+
5
+ const DEFAULT_TABLE_COLUMNS = [
6
+ {
7
+ head: i18next.t('序号'),
8
+ text: i18next.t('{{列.序号}}'),
9
+ style: { textAlign: 'center' },
10
+ headStyle: { textAlign: 'center' }
11
+ },
12
+ {
13
+ head: i18next.t('样品名称'),
14
+ text: i18next.t('{{列.样品名称}}'),
15
+ style: { textAlign: 'center' },
16
+ headStyle: { textAlign: 'center' }
17
+ },
18
+ {
19
+ head: i18next.t('样品编码'),
20
+ text: i18next.t('{{列.样品编码}}'),
21
+ style: { textAlign: 'center' },
22
+ headStyle: { textAlign: 'center' }
23
+ },
24
+ {
25
+ head: i18next.t('检测结果'),
26
+ text: i18next.t('{{列.检测结果}}'),
27
+ style: { textAlign: 'center' },
28
+ headStyle: { textAlign: 'center' }
29
+ }
30
+ ]
31
+
32
+ class Store extends EditorStore {
33
+ constructor({ defaultTableDataKey }) {
34
+ super()
35
+ this.defaultTableDataKey = defaultTableDataKey
36
+ }
37
+
38
+ getDefaultTableConfig() {
39
+ return {
40
+ dataKey: this.defaultTableDataKey,
41
+ subtotal: { show: false },
42
+ columns: DEFAULT_TABLE_COLUMNS
43
+ }
44
+ }
45
+
46
+ @action
47
+ init(config, data) {
48
+ super.init(config, data)
49
+ this.defaultTableDataKey = 'examiningDetail'
50
+ }
51
+
52
+ @action.bound
53
+ addContent(name, index, type, tableConfig = null) {
54
+ if (type === 'table' && !tableConfig) {
55
+ tableConfig = this.getDefaultTableConfig()
56
+ }
57
+ super.addContent(name, index, type, tableConfig)
58
+ this.config = toJS(this.config)
59
+ }
60
+
61
+ @action
62
+ changeTableDataKey(name, key, options = {}) {
63
+ super.changeTableDataKey(name, key, options)
64
+ this.config = toJS(this.config)
65
+ }
66
+
67
+ @action
68
+ removeContent(name) {
69
+ super.removeContent(name)
70
+ this.config = toJS(this.config)
71
+ }
72
+ }
73
+
74
+ export default new Store({ defaultTableDataKey: 'examiningDetail' })
package/src/index.js CHANGED
@@ -1,7 +1,9 @@
1
1
  // ‼️优先初始化语言设置(必须先初始化语言)
2
2
  import '../locales'
3
- import Editor from './editor'
3
+ import Editor, { Editor2 } from './editor'
4
+
4
5
  import EditorPurchase from './editor_purchase'
6
+ import examiningReportEditor from './examining_report_editor'
5
7
  import EditorStockIn from './editor_stockin'
6
8
  import EditorStockOut from './editor_stockout'
7
9
  import EditorSettle from './editor_settle'
@@ -27,9 +29,11 @@ export { setLocale } from '../locales'
27
29
 
28
30
  export {
29
31
  Editor,
32
+ Editor2,
30
33
  EditorStockIn,
31
34
  EditorStockOut,
32
35
  EditorPurchase,
36
+ examiningReportEditor,
33
37
  EditorSettle,
34
38
  EditorStatement,
35
39
  EditorAccoutStatement,
@@ -103,10 +103,10 @@ class Printer extends React.Component {
103
103
  componentDidMount() {
104
104
  const { printerStore, config, getremainpageHeight } = this.props
105
105
  const batchPrintConfig = config.batchPrintConfig
106
- // 连续打印不需要计算
106
+ // didMount 代表第一次渲染完成
107
+ printerStore.setReady(true)
108
+ // 连续打印不需要分页计算
107
109
  if (batchPrintConfig !== 2) {
108
- // didMount 代表第一次渲染完成
109
- printerStore.setReady(true)
110
110
  printerStore.computedPages()
111
111
  if (config.autoFillConfig?.checked) {
112
112
  this.props.printerStore.setAutofillConfig(