gm-printer 10.26.0 → 10.27.0-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-printer",
3
- "version": "10.26.0",
3
+ "version": "10.27.0-beta.0",
4
4
  "description": "diy printer",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -72,6 +72,11 @@ class EditorField extends React.Component {
72
72
  editStore.setSpecialStyle(value)
73
73
  }
74
74
 
75
+ handleCategoryStyleChange = value => {
76
+ const { editStore } = this.props
77
+ editStore.setCategoryStyle(value)
78
+ }
79
+
75
80
  handleSubtotalStyleChange = value => {
76
81
  const { editStore } = this.props
77
82
  editStore.setSubtotalStyle(value)
@@ -202,6 +207,9 @@ class EditorField extends React.Component {
202
207
  diyOverallOrder
203
208
  } = editStore.computedTableSpecialConfig
204
209
 
210
+ // 新分类
211
+ const categoryStyle =
212
+ toJS(editStore.computedTableSpecialConfig)?.categoryConfig?.style || {}
205
213
  // 小计样式,specialConfig可能是undefined
206
214
  const specialStyle =
207
215
  toJS(editStore.computedTableSpecialConfig)?.specialConfig?.style || {}
@@ -417,6 +425,19 @@ class EditorField extends React.Component {
417
425
  />
418
426
  <Gap />
419
427
 
428
+ <Flex>
429
+ <Flex>{i18next.t('分类设置')}:</Flex>
430
+ <Fonter
431
+ style={categoryStyle}
432
+ onChange={this.handleCategoryStyleChange}
433
+ />
434
+ <Separator />
435
+ <TextAlign
436
+ style={categoryStyle}
437
+ onChange={this.handleCategoryStyleChange}
438
+ />
439
+ </Flex>
440
+
420
441
  <Flex>
421
442
  <Flex>{i18next.t('小计设置')}:</Flex>
422
443
  <Fonter
@@ -602,6 +602,26 @@ class EditorStore {
602
602
  }
603
603
  }
604
604
 
605
+ @action
606
+ setCategoryConfigShow(name) {
607
+ const arr = name.split('.')
608
+ const table = this.config.contents[arr[2]]
609
+ this.overallOrderShow = !this.overallOrderShow
610
+ // 切换的时候,要把对应table的多余空数据清掉
611
+ this.clearExtraTableData(table.dataKey)
612
+
613
+ // 兼容存在后端的模板
614
+ if (!table?.categoryConfig) {
615
+ set(table, {
616
+ categoryConfig: {
617
+ show: true,
618
+ style: { fontWeight: 'bold' },
619
+ type: 'categoryConfig'
620
+ }
621
+ })
622
+ }
623
+ }
624
+
605
625
  @action
606
626
  subtotalRadioCheck(fields) {
607
627
  if (this.selectedRegion) {
@@ -740,6 +760,7 @@ class EditorStore {
740
760
  newDataKey = _.sortBy(newDataKey, [
741
761
  o => o === 'multi3',
742
762
  o => o === 'multi',
763
+ o => o === 'newCategory',
743
764
  o => o === 'category',
744
765
  o => o === 'orders'
745
766
  ])
@@ -1119,6 +1140,27 @@ class EditorStore {
1119
1140
  }
1120
1141
  }
1121
1142
 
1143
+ // 设置新模版样式
1144
+ @action.bound
1145
+ setCategoryStyle(value) {
1146
+ if (this.selectedRegion) {
1147
+ this.overallOrderShow = !this.overallOrderShow
1148
+ const arr = this.selectedRegion.split('.')
1149
+ const tableConfig = this.config.contents[arr[2]]
1150
+
1151
+ const oldStyle = tableConfig?.categoryConfig
1152
+ ? tableConfig.categoryConfig.style
1153
+ : {}
1154
+ set(tableConfig?.categoryConfig, {
1155
+ ...(tableConfig?.categoryConfig ?? {}),
1156
+ style: {
1157
+ ...oldStyle,
1158
+ ...value
1159
+ }
1160
+ })
1161
+ }
1162
+ }
1163
+
1122
1164
  @action.bound
1123
1165
  setSpecialUpperCase() {
1124
1166
  if (this.selectedRegion) {
@@ -70,6 +70,13 @@ class ContextMenu extends React.Component {
70
70
  editStore.setSubtotalShow(name)
71
71
  }
72
72
 
73
+ handleCategoryConfig = (key, name) => {
74
+ const { editStore } = this.props
75
+ editStore.changeTableDataKey(name, key)
76
+
77
+ editStore.setCategoryConfigShow(name)
78
+ }
79
+
73
80
  handleChangeTableData = isAutoFilling => {
74
81
  const { editStore } = this.props
75
82
  editStore.handleChangeTableData(isAutoFilling)
@@ -111,6 +118,7 @@ class ContextMenu extends React.Component {
111
118
  const isMultiActive = keyArr.includes('multi')
112
119
  const isThreeActive = keyArr.includes('multi3')
113
120
  const isCategoryActive = keyArr.includes('category')
121
+ const isNewCategoryActive = keyArr.includes('newCategory')
114
122
  const isSubtotalActive = subtotal.show
115
123
  const isOverallOrder = overallOrder?.show
116
124
  const isDiyOverallOrder = diyOverallOrder?.show
@@ -135,6 +143,12 @@ class ContextMenu extends React.Component {
135
143
  <div
136
144
  onClick={this.handleChangeTableDataKey.bind(this, 'category', name)}
137
145
  className={isCategoryActive ? 'active' : ''}
146
+ >
147
+ {i18next.t('分类小计')}
148
+ </div>
149
+ <div
150
+ onClick={this.handleCategoryConfig.bind(this, 'newCategory', name)}
151
+ className={isNewCategoryActive ? 'active' : ''}
138
152
  >
139
153
  {i18next.t('商品分类')}
140
154
  </div>
@@ -14,6 +14,7 @@ import { inject, observer } from 'mobx-react'
14
14
  import classNames from 'classnames'
15
15
  import { MULTI_SUFFIX } from '../config'
16
16
  import SpecialTr from './table_special_tr'
17
+ import CategoryTr from './table_category_tr'
17
18
  import SubtotalTr from './table_subtotal_tr'
18
19
  import PageSummary from './page_summary'
19
20
  import OverallOrder from './table_overallOrder_tr'
@@ -114,11 +115,10 @@ class Table extends React.Component {
114
115
  const data = {
115
116
  ...val,
116
117
  index,
117
- // 先匹配 {{ }}模版中的
118
118
  text: val.text.replace(/{{(.*?)}}/g, s => {
119
119
  // 再匹配 列.xxx 相关的
120
120
  s = s.replace(
121
- /(列.[\u4e00-\u9fa5]*[0-9A-Za-z_]?[\u4e00-\u9fa5]*[A-Za-z_]*[\u4e00-\u9fa5]*)/g,
121
+ /(列.[\u4e00-\u9fa5]*[0-9A-Za-z_]*[\u4e00-\u9fa5]*[A-Za-z_]*[\u4e00-\u9fa5]*)/g,
122
122
  m => m + `${MULTI_SUFFIX}${colNum}`
123
123
  )
124
124
  return s
@@ -264,6 +264,9 @@ class Table extends React.Component {
264
264
  <tbody>
265
265
  {_.map(_.range(range.begin, range.end), i => {
266
266
  const _special = tableData[i] && tableData[i]._special
267
+ const _specialText = tableData[i] && tableData[i]._specialText
268
+ if (_specialText)
269
+ return <CategoryTr key={i} config={config} data={_specialText} />
267
270
  if (_special)
268
271
  return <SpecialTr key={i} config={config} data={_special} />
269
272
  // 如果项为空对象展现一个占满一行的td
@@ -291,13 +294,13 @@ class Table extends React.Component {
291
294
  dangerouslySetInnerHTML={{
292
295
  __html: col.isSpecialColumn
293
296
  ? printerStore.templateSpecialDetails(
294
- col,
295
- dataKey,
296
- i
297
- )
297
+ col,
298
+ dataKey,
299
+ i
300
+ )
298
301
  : printerStore
299
- .templateTable(col.text, dataKey, i, pageIndex)
300
- .replace(/\(\)/g, '')
302
+ .templateTable(col.text, dataKey, i, pageIndex)
303
+ .replace(/\(\)/g, '')
301
304
  }}
302
305
  />
303
306
  )
@@ -0,0 +1,23 @@
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import { observer } from 'mobx-react'
4
+
5
+ const CategoryTr = props => {
6
+ const {
7
+ config: { categoryConfig },
8
+ data
9
+ } = props
10
+ return (
11
+ <tr>
12
+ <td colSpan='99'>
13
+ <div style={{ ...categoryConfig?.style }}>{data?.text ?? '11'}</div>
14
+ </td>
15
+ </tr>
16
+ )
17
+ }
18
+ CategoryTr.propTypes = {
19
+ config: PropTypes.object.isRequired,
20
+ data: PropTypes.object
21
+ }
22
+
23
+ export default observer(CategoryTr)