gm-printer 10.42.0 → 10.42.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gm-printer",
3
- "version": "10.42.0",
3
+ "version": "10.42.1",
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
  }
@@ -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'
@@ -741,13 +744,12 @@ class PrinterStore {
741
744
  */
742
745
  templateTableRowSpan(text, dataKey, index, begin) {
743
746
  try {
744
- // 采购 / 分拣「按明细单行」展开后才做合并单元格(后缀 independent_rol_*)
747
+ // 采购 / 分拣「按明细单行」展开后才做合并单元格(后缀 independent_rol_* / detail_one_row_*,含 category)
745
748
  const canMerge =
746
749
  isIndependentRolDataKey(dataKey) ||
750
+ isDetailOneRowSelectKey(dataKey) ||
747
751
  dataKey === 'taxRateSales' ||
748
- dataKey === 'ordinary' ||
749
- dataKey === 'purchase_detail_one_row' ||
750
- dataKey === 'sorting_detail_detail_one_row'
752
+ dataKey === 'ordinary'
751
753
  if (!canMerge) {
752
754
  return null
753
755
  }