gm-printer 10.37.2 → 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.
- package/build/demo.js +9 -9
- package/package.json +1 -1
- package/src/common/editor_store.js +37 -2
- package/src/editor/{editor2.js → editor_menu_config.js} +1 -2
- package/src/editor/index.js +2 -2
- package/src/examining_report_editor/context_menu.js +94 -0
- package/src/examining_report_editor/editor.js +85 -0
- package/src/examining_report_editor/index.js +4 -0
- package/src/examining_report_editor/store.js +74 -0
- package/src/index.js +2 -0
- package/src/printer/printer.js +3 -3
- /package/src/editor/{context_menu2.js → context_menu_config.js} +0 -0
package/package.json
CHANGED
|
@@ -94,13 +94,45 @@ class EditorStore {
|
|
|
94
94
|
|
|
95
95
|
@action
|
|
96
96
|
setSubtotalFieldsCol(arr) {
|
|
97
|
-
// this.overallOrderShow = !this.overallOrderShow
|
|
98
|
-
// 重新计算每页合计的单元格
|
|
99
97
|
const table = this.config.contents[arr[2]]
|
|
98
|
+
if (!table?.subtotal?.show) return
|
|
99
|
+
|
|
100
|
+
const colSpanLength = getColSpanLength(table)
|
|
101
|
+
if (!table.subtotal.fields?.length) {
|
|
102
|
+
set(table.subtotal, {
|
|
103
|
+
fields: [
|
|
104
|
+
{
|
|
105
|
+
name: '每页合计:',
|
|
106
|
+
valueField: 'real_item_price',
|
|
107
|
+
colSpan: colSpanLength
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
})
|
|
111
|
+
return
|
|
112
|
+
}
|
|
113
|
+
|
|
100
114
|
const subtotalLength = table.subtotal.fields.length
|
|
101
115
|
table.subtotal.fields[subtotalLength - 1].colSpan += 1
|
|
102
116
|
}
|
|
103
117
|
|
|
118
|
+
@action
|
|
119
|
+
updateSelectedRegionAfterContentInsert(insertIndex) {
|
|
120
|
+
const updateNameIndex = name => {
|
|
121
|
+
if (!name) return name
|
|
122
|
+
const parts = name.split('.')
|
|
123
|
+
if (parts[0] !== 'contents') return name
|
|
124
|
+
const regionIndex = ~~parts[2]
|
|
125
|
+
if (regionIndex >= insertIndex) {
|
|
126
|
+
parts[2] = String(regionIndex + 1)
|
|
127
|
+
return parts.join('.')
|
|
128
|
+
}
|
|
129
|
+
return name
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
this.selectedRegion = updateNameIndex(this.selectedRegion)
|
|
133
|
+
this.selected = updateNameIndex(this.selected)
|
|
134
|
+
}
|
|
135
|
+
|
|
104
136
|
@action
|
|
105
137
|
setMultiDigitDecimal(bool) {
|
|
106
138
|
this.isMultiDigitDecimal = bool
|
|
@@ -266,6 +298,7 @@ class EditorStore {
|
|
|
266
298
|
{ batchPrintConfig: 1, isFixLastFooter: true },
|
|
267
299
|
config
|
|
268
300
|
)
|
|
301
|
+
this.defaultTableDataKey = config.defaultTableDataKey || 'orders'
|
|
269
302
|
this.originConfig = config
|
|
270
303
|
this.selected = null
|
|
271
304
|
this.selectedRegion = null
|
|
@@ -1205,6 +1238,8 @@ class EditorStore {
|
|
|
1205
1238
|
}
|
|
1206
1239
|
})
|
|
1207
1240
|
}
|
|
1241
|
+
this.updateSelectedRegionAfterContentInsert(index)
|
|
1242
|
+
this.config = toJS(this.config)
|
|
1208
1243
|
}
|
|
1209
1244
|
}
|
|
1210
1245
|
}
|
|
@@ -13,7 +13,7 @@ import EditorField from '../common/editor_edit_field'
|
|
|
13
13
|
import EditorAddField from '../common/editor_add_field'
|
|
14
14
|
import EditorPageSummary from '../common/editor_page_summary'
|
|
15
15
|
import EditorCutomizedConfig from '../common/editor_customize_config'
|
|
16
|
-
import ContextMenu from './
|
|
16
|
+
import ContextMenu from './context_menu_config'
|
|
17
17
|
import i18next from '../../locales'
|
|
18
18
|
import withStore from '../common/hoc_with_store'
|
|
19
19
|
|
|
@@ -51,7 +51,6 @@ class Editor extends React.Component {
|
|
|
51
51
|
customTableConfigs,
|
|
52
52
|
menuConfig
|
|
53
53
|
} = this.props
|
|
54
|
-
console.log('menuConfig', menuConfig)
|
|
55
54
|
return (
|
|
56
55
|
<div className='gm-printer-edit'>
|
|
57
56
|
<Flex className='gm-printer-edit-title-fixed'>
|
package/src/editor/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import withShadowDom from '../common/hoc_with_shadow_dom'
|
|
2
2
|
import Editor from './editor'
|
|
3
|
-
import
|
|
3
|
+
import EditorMenuConfig from './editor_menu_config'
|
|
4
4
|
|
|
5
5
|
export default withShadowDom(Editor)
|
|
6
|
-
export const Editor2 = withShadowDom(
|
|
6
|
+
export const Editor2 = withShadowDom(EditorMenuConfig)
|
|
@@ -0,0 +1,94 @@
|
|
|
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
|
|
@@ -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,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
|
@@ -3,6 +3,7 @@ import '../locales'
|
|
|
3
3
|
import Editor, { Editor2 } from './editor'
|
|
4
4
|
|
|
5
5
|
import EditorPurchase from './editor_purchase'
|
|
6
|
+
import examiningReportEditor from './examining_report_editor'
|
|
6
7
|
import EditorStockIn from './editor_stockin'
|
|
7
8
|
import EditorStockOut from './editor_stockout'
|
|
8
9
|
import EditorSettle from './editor_settle'
|
|
@@ -32,6 +33,7 @@ export {
|
|
|
32
33
|
EditorStockIn,
|
|
33
34
|
EditorStockOut,
|
|
34
35
|
EditorPurchase,
|
|
36
|
+
examiningReportEditor,
|
|
35
37
|
EditorSettle,
|
|
36
38
|
EditorStatement,
|
|
37
39
|
EditorAccoutStatement,
|
package/src/printer/printer.js
CHANGED
|
@@ -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(
|
|
File without changes
|