gm-printer 11.0.2-beta.2 → 11.1.0-beta.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.
@@ -1,140 +0,0 @@
1
- import React from 'react'
2
- import PropTypes from 'prop-types'
3
- import _ from 'lodash'
4
- import { Flex, ToolTip } 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 SpecialField from '../common/editor_special_field'
11
- import SpecialOtherField from '../common/editor_special_other_field'
12
- import EditorField from '../common/editor_edit_field'
13
- import EditorAddField from '../common/editor_add_field'
14
- import EditorPageSummary from '../common/editor_page_summary'
15
- import EditorCutomizedConfig from '../common/editor_customize_config'
16
- import ContextMenu from './context_menu_config'
17
- import i18next from '../../locales'
18
- import withStore from '../common/hoc_with_store'
19
-
20
- // ‼️‼️🚸🚸 注意: value的命名不要用下划线! 原因是 computedTableDataKeyOfSelectedRegion 会split('_')下划线做一些事情‼️
21
- // 📚hasSubtotalBtn 这种表格是否支持 双栏,分类,合计 功能
22
- const tableDataKeyList = [
23
- { value: 'orders', text: i18next.t('全部商品'), hasSubtotalBtn: true },
24
- { value: 'abnormal', text: i18next.t('异常商品'), hasSubtotalBtn: false },
25
- {
26
- value: 'abnormalDetails',
27
- text: i18next.t('异常商品(明细)'),
28
- hasSubtotalBtn: false
29
- },
30
- { value: 'reward', text: i18next.t('积分表格'), hasSubtotalBtn: false },
31
- { value: 'combination', text: i18next.t('组合商品'), hasSubtotalBtn: false },
32
- { value: 'turnover', text: i18next.t('周转物表格'), hasSubtotalBtn: false }
33
- ]
34
-
35
- export const noSubtotalBtnTableDataKeySet = new Set(
36
- tableDataKeyList.filter(v => !v.hasSubtotalBtn).map(o => o.value)
37
- )
38
-
39
- @withStore(editStore)
40
- @inject('editStore')
41
- @observer
42
- class Editor extends React.Component {
43
- render() {
44
- const {
45
- onSave,
46
- showEditor,
47
- addFields,
48
- showNewDate,
49
- mockData,
50
- mergeClassificationAndLabel,
51
- customTableConfigs,
52
- menuConfig
53
- } = this.props
54
- return (
55
- <div className='gm-printer-edit'>
56
- <Flex className='gm-printer-edit-title-fixed'>
57
- <Title
58
- title={i18next.t('模板预览')}
59
- text={
60
- <span className='gm-text-desc gm-padding-left-5'>
61
- {i18next.t(
62
- '说明:选中内容进行编辑,可拖动字段移动位置,右键使用更多功能'
63
- )}
64
- {/* <a
65
- href='https://v.qq.com/x/page/t08044292dd.html'
66
- target='_blank'
67
- className='btn-link'
68
- rel='noopener noreferrer'
69
- >
70
- {i18next.t('查看视频教程')}
71
- </a> */}
72
- </span>
73
- }
74
- />
75
- </Flex>
76
-
77
- {showEditor && (
78
- <div className='gm-printer-edit-zone'>
79
- <EditorTitle onSave={onSave} />
80
- <Gap height='10px' />
81
- <>
82
- <>{i18next.t('模版类型')}</>
83
- <ToolTip text='表示该模板是针对单一商户的配送单模板(商户配送单),或是账户合并打印配送单(账户配送单)的模板。' />
84
- <span>{':' + i18next.t('商户配送单')}</span>
85
- </>
86
- <Gap height='10px' />
87
- <EditorSelect />
88
- <Gap height='5px' />
89
- <SpecialField addFields={addFields} mockData={mockData} />
90
- <SpecialOtherField addFields={addFields} mockData={mockData} />
91
- <EditorCutomizedConfig />
92
- <Gap height='5px' />
93
- <EditorField
94
- tableDataKeyList={tableDataKeyList}
95
- showNewDate={showNewDate}
96
- mergeClassificationAndLabel={mergeClassificationAndLabel}
97
- />
98
- <Gap height='5px' />
99
- <EditorAddField addFields={addFields} />
100
- <Gap height='5px' />
101
- <EditorPageSummary summaryFields={addFields.summaryFields} />
102
-
103
- <div id='gm-printer-tip' />
104
-
105
- <div id='gm-printer-modal' />
106
- </div>
107
- )}
108
-
109
- <div className='gm-printer-edit-wrap'>
110
- <ContextMenu
111
- customTableConfigs={customTableConfigs}
112
- menuConfig={menuConfig}
113
- />
114
- </div>
115
- </div>
116
- )
117
- }
118
- }
119
-
120
- Editor.propTypes = {
121
- config: PropTypes.object.isRequired,
122
- onSave: PropTypes.func,
123
- showEditor: PropTypes.bool,
124
- mockData: PropTypes.object.isRequired,
125
- addFields: PropTypes.object.isRequired,
126
- showNewDate: PropTypes.bool,
127
- mergeClassificationAndLabel: PropTypes.bool,
128
- customTableConfigs: PropTypes.array,
129
- menuConfig: PropTypes.oneOfType([
130
- PropTypes.arrayOf(PropTypes.string),
131
- PropTypes.object
132
- ])
133
- }
134
-
135
- Editor.defaultProps = {
136
- onSave: _.noop,
137
- showNewDate: false
138
- }
139
-
140
- export default Editor
@@ -1,94 +0,0 @@
1
- import i18next from '../../locales'
2
- import React from 'react'
3
- import PropTypes from 'prop-types'
4
- import CommonContextMenu from '../common/common_context_menu'
5
- import { inject, observer } from 'mobx-react'
6
- import _ from 'lodash'
7
- import { Printer } from '../printer'
8
-
9
- const blockTypeList = [
10
- { value: '', text: i18next.t('插入文本') },
11
- { value: 'line', text: i18next.t('插入线条') },
12
- { value: 'image', text: i18next.t('插入图片') }
13
- ]
14
-
15
- @inject(stores => ({
16
- editStore: stores.editStore,
17
- mockData: stores.mockData
18
- }))
19
- @observer
20
- class ContextMenu extends React.Component {
21
- isMenuItemEnabled = key => {
22
- const { menuConfig } = this.props
23
- if (!menuConfig) return true
24
- if (Array.isArray(menuConfig)) return menuConfig.includes(key)
25
- if (typeof menuConfig === 'object') return !!menuConfig[key]
26
- return true
27
- }
28
-
29
- hasSubtotalBtn = name => {
30
- if (!name) return false
31
- const arr = name.split('.')
32
- if (!_.includes(arr, 'table')) return false
33
- const dataKey = this.props.editStore.config.contents[arr[2]].dataKey
34
- return dataKey === 'examiningDetail' || dataKey.startsWith('examiningDetail_')
35
- }
36
-
37
- handleChangeTableDataKey = (key, name) => {
38
- const { editStore } = this.props
39
- editStore.changeTableDataKey(name, key)
40
- }
41
-
42
- renderTableAction = name => {
43
- if (!this.hasSubtotalBtn(name)) {
44
- return null
45
- }
46
-
47
- const arr = name.split('.')
48
- const { dataKey } = this.props.editStore.config.contents[arr[2]]
49
- const keyArr = dataKey.split('_')
50
- const isMultiActive = keyArr.includes('multi')
51
-
52
- return (
53
- <>
54
- {this.isMenuItemEnabled('multi') && (
55
- <div
56
- onClick={this.handleChangeTableDataKey.bind(this, 'multi', name)}
57
- className={isMultiActive ? 'active' : ''}
58
- >
59
- {i18next.t('双栏商品')}
60
- </div>
61
- )}
62
- </>
63
- )
64
- }
65
-
66
- render() {
67
- const { editStore, mockData } = this.props
68
- return (
69
- <CommonContextMenu
70
- renderTableAction={this.renderTableAction}
71
- insertBlockList={blockTypeList}
72
- >
73
- <Printer
74
- key={editStore.computedPrinterKey}
75
- selected={editStore.selected}
76
- selectedRegion={editStore.selectedRegion}
77
- config={editStore.config}
78
- data={mockData}
79
- />
80
- </CommonContextMenu>
81
- )
82
- }
83
- }
84
-
85
- ContextMenu.propTypes = {
86
- editStore: PropTypes.object,
87
- mockData: PropTypes.object,
88
- menuConfig: PropTypes.oneOfType([
89
- PropTypes.arrayOf(PropTypes.string),
90
- PropTypes.object
91
- ])
92
- }
93
-
94
- export default ContextMenu
@@ -1,85 +0,0 @@
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
@@ -1,4 +0,0 @@
1
- import withShadowDom from '../common/hoc_with_shadow_dom'
2
- import Editor from './editor'
3
-
4
- export default withShadowDom(Editor)
@@ -1,78 +0,0 @@
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: [
43
- {
44
- head: i18next.t('表头'),
45
- text: i18next.t('{{列.表头}}'),
46
- style: { textAlign: 'center' },
47
- headStyle: { textAlign: 'center' }
48
- }
49
- ]
50
- }
51
- }
52
-
53
- @action
54
- init(config, data) {
55
- super.init(config, data)
56
- this.defaultTableDataKey = 'examiningDetail'
57
- }
58
-
59
- @action.bound
60
- addContent(name, index, type, tableConfig = null) {
61
- super.addContent(name, index, type, tableConfig)
62
- this.config = toJS(this.config)
63
- }
64
-
65
- @action
66
- changeTableDataKey(name, key, options = {}) {
67
- super.changeTableDataKey(name, key, options)
68
- this.config = toJS(this.config)
69
- }
70
-
71
- @action
72
- removeContent(name) {
73
- super.removeContent(name)
74
- this.config = toJS(this.config)
75
- }
76
- }
77
-
78
- export default new Store({ defaultTableDataKey: 'examiningDetail' })