gm-printer 10.42.0 → 10.42.2-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.42.0",
3
+ "version": "10.42.2-beta.0",
4
4
  "description": "diy printer",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -19,14 +19,33 @@ export function buildDataKey(prefix, suffix) {
19
19
  return `${prefix}${suffix}`
20
20
  }
21
21
 
22
- /** 下拉选中「按明细单行」时的 value(detail_one_row) */
22
+ /** 下拉选中「按明细单行」时的 value(detail_one_row),可带 category/multi 等后缀 */
23
23
  export function isDetailOneRowSelectKey(dataKey) {
24
- return getDataKeySuffix(dataKey) === 'detail_one_row'
24
+ const suffix = getDataKeySuffix(dataKey)
25
+ return suffix === 'detail_one_row' || suffix.startsWith('detail_one_row_')
25
26
  }
26
27
 
28
+ /** 独立滚动明细单行(sku/address),可带 category/multi 等后缀 */
27
29
  export function isIndependentRolDataKey(dataKey) {
28
30
  const suffix = getDataKeySuffix(dataKey)
29
- return suffix === 'independent_rol_sku' || suffix === 'independent_rol_address'
31
+ return (
32
+ suffix === 'independent_rol_sku' ||
33
+ suffix === 'independent_rol_address' ||
34
+ suffix.startsWith('independent_rol_sku_') ||
35
+ suffix.startsWith('independent_rol_address_')
36
+ )
37
+ }
38
+
39
+ /**
40
+ * 从现有 dataKey 抽出可叠加修饰后缀(category / multi)
41
+ * 用于切换 goods/merchant 排序时保留右键「商品分类」「双栏」状态
42
+ */
43
+ export function getDataKeyModifierSuffix(dataKey) {
44
+ const parts = getDataKeySuffix(dataKey).split('_').filter(Boolean)
45
+ const modifiers = []
46
+ if (parts.includes('category')) modifiers.push('category')
47
+ if (parts.includes('multi')) modifiers.push('multi')
48
+ return modifiers.length ? `_${modifiers.join('_')}` : ''
30
49
  }
31
50
 
32
51
  export function isLastColDataKey(dataKey) {
@@ -14,6 +14,7 @@ import {
14
14
  import { accountRadioList } from './util'
15
15
  import {
16
16
  buildDataKey,
17
+ getDataKeyModifierSuffix,
17
18
  getDataKeyPrefix,
18
19
  isDetailOneRowSelectKey,
19
20
  isIndependentRolDataKey
@@ -1573,13 +1574,16 @@ class EditorStore {
1573
1574
  const arr = this.selectedRegion.split('.')
1574
1575
  const table = this.config.contents[arr[2]]
1575
1576
  const prefix = getDataKeyPrefix(table.dataKey)
1577
+ // 切换「按商品/按商户排序」时保留已开启的商品分类、双栏后缀,避免点完分类再切排序把 category 冲掉
1578
+ const baseSuffix = dataKey === 'goods' ? 'independent_rol_sku' : 'independent_rol_address'
1579
+ const nextDataKey = buildDataKey(
1580
+ prefix,
1581
+ `${baseSuffix}${getDataKeyModifierSuffix(table.dataKey)}`
1582
+ )
1576
1583
 
1577
1584
  set(table, {
1578
1585
  purchaseSettingKey: dataKey,
1579
- dataKey:
1580
- dataKey === 'goods'
1581
- ? buildDataKey(prefix, 'independent_rol_sku')
1582
- : buildDataKey(prefix, 'independent_rol_address'),
1586
+ dataKey: nextDataKey,
1583
1587
  detail_sort_type: 0
1584
1588
  })
1585
1589
  }
@@ -1601,7 +1605,8 @@ class EditorStore {
1601
1605
  const table = this.config.contents[arr[2]]
1602
1606
 
1603
1607
  const { dataKey } = table
1604
- if (isIndependentRolDataKey(dataKey)) {
1608
+ // independent_rol_* / detail_one_row_*(含 category、multi 后缀)在下拉里都映射回「按采购明细单行」
1609
+ if (isIndependentRolDataKey(dataKey) || isDetailOneRowSelectKey(dataKey)) {
1605
1610
  return buildDataKey(getDataKeyPrefix(dataKey), 'detail_one_row')
1606
1611
  }
1607
1612
  return dataKey
@@ -16,7 +16,9 @@ import _ from 'lodash'
16
16
  import { inject, observer } from 'mobx-react'
17
17
  import {
18
18
  buildDataKey,
19
+ getDataKeyModifierSuffix,
19
20
  getDataKeyPrefix,
21
+ getDataKeySuffix,
20
22
  isDetailOneRowSelectKey,
21
23
  } from '../common/data_key_util'
22
24
 
@@ -90,19 +92,23 @@ class TableDetailEditor extends React.Component {
90
92
  .replace(/{{([^.\s}]+)}}/g, '{{列.$1}}')
91
93
  }
92
94
  const prefix = getDataKeyPrefix(config.dataKey)
93
- const rolSkuKey = buildDataKey(prefix, 'independent_rol_sku')
94
- const rolAddressKey = buildDataKey(prefix, 'independent_rol_address')
95
+ const curSuffix = getDataKeySuffix(config.dataKey)
96
+ const modifier = getDataKeyModifierSuffix(config.dataKey)
97
+ // 已是对应 independent_rol_*(含 category/multi)则不再重设,避免冲掉商品分类
95
98
  if (
96
99
  config.purchaseSettingKey === 'goods' &&
97
- config.dataKey !== rolSkuKey
100
+ !curSuffix.startsWith('independent_rol_sku')
98
101
  ) {
99
- editStore.setPurchaseTableKey(rolSkuKey, addFields.specialTableConfig)
102
+ editStore.setPurchaseTableKey(
103
+ buildDataKey(prefix, `independent_rol_sku${modifier}`),
104
+ addFields.specialTableConfig
105
+ )
100
106
  } else if (
101
107
  config.purchaseSettingKey === 'merchant' &&
102
- config.dataKey !== rolAddressKey
108
+ !curSuffix.startsWith('independent_rol_address')
103
109
  ) {
104
110
  editStore.setPurchaseTableKey(
105
- rolAddressKey,
111
+ buildDataKey(prefix, `independent_rol_address${modifier}`),
106
112
  addFields.specialTableConfig
107
113
  )
108
114
  }
@@ -49,10 +49,15 @@ class Panel extends React.Component {
49
49
  diffY = -diffY
50
50
  }
51
51
 
52
+ // 高度不允许拖成负数:负 height 是非法 CSS,浏览器按 0 渲染,
53
+ // 但分页的配置兜底会取到负值,导致末页预留为负、内容溢出与固定页脚重叠
54
+ const height =
55
+ Math.max(0, parseInt(pxAdd(config.style.height, diffY), 10)) + 'px'
56
+
52
57
  dispatchMsg('gm-printer-panel-style-set', {
53
58
  name,
54
59
  style: {
55
- height: pxAdd(config.style.height, diffY)
60
+ height
56
61
  }
57
62
  })
58
63
  }
@@ -9,7 +9,10 @@ import {
9
9
  getArrayMid,
10
10
  getOverallOrderTrHeight
11
11
  } from '../util'
12
- import { isIndependentRolDataKey } from '../common/data_key_util'
12
+ import {
13
+ isDetailOneRowSelectKey,
14
+ isIndependentRolDataKey
15
+ } from '../common/data_key_util'
13
16
  import _ from 'lodash'
14
17
  import Big from 'big.js'
15
18
  import { Tip } from '../components'
@@ -245,7 +248,9 @@ class PrinterStore {
245
248
  const raw = this.config?.sign?.style?.height
246
249
  if (raw == null || raw === '') return 0
247
250
  const parsed = parseFloat(raw)
248
- return Number.isFinite(parsed) ? parsed : 0
251
+ // 负高度(编辑器历史版本可拖出如 -161px)会让末页签名预留为负,
252
+ // 单页虚增可容纳高度,固定页脚时表格溢出与页脚重叠;非正值一律按 0
253
+ return parsed > 0 ? parsed : 0
249
254
  }
250
255
 
251
256
  /** 处理采购单的明细
@@ -741,13 +746,12 @@ class PrinterStore {
741
746
  */
742
747
  templateTableRowSpan(text, dataKey, index, begin) {
743
748
  try {
744
- // 采购 / 分拣「按明细单行」展开后才做合并单元格(后缀 independent_rol_*)
749
+ // 采购 / 分拣「按明细单行」展开后才做合并单元格(后缀 independent_rol_* / detail_one_row_*,含 category)
745
750
  const canMerge =
746
751
  isIndependentRolDataKey(dataKey) ||
752
+ isDetailOneRowSelectKey(dataKey) ||
747
753
  dataKey === 'taxRateSales' ||
748
- dataKey === 'ordinary' ||
749
- dataKey === 'purchase_detail_one_row' ||
750
- dataKey === 'sorting_detail_detail_one_row'
754
+ dataKey === 'ordinary'
751
755
  if (!canMerge) {
752
756
  return null
753
757
  }