gm-printer 10.41.0 → 10.41.2

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.41.0",
3
+ "version": "10.41.2",
4
4
  "description": "diy printer",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -0,0 +1,35 @@
1
+ /**
2
+ * 模板 table.dataKey 前缀工具。
3
+ * 采购模板:purchase_*;分拣明细模板:sorting_detail_*(后缀与采购一致)。
4
+ */
5
+ export const SORTING_DETAIL_PREFIX = 'sorting_detail_'
6
+ export const PURCHASE_PREFIX = 'purchase_'
7
+
8
+ export function getDataKeyPrefix(dataKey) {
9
+ if (dataKey?.startsWith(SORTING_DETAIL_PREFIX)) return SORTING_DETAIL_PREFIX
10
+ return PURCHASE_PREFIX
11
+ }
12
+
13
+ export function getDataKeySuffix(dataKey) {
14
+ if (!dataKey || typeof dataKey !== 'string') return ''
15
+ return dataKey.replace(/^(sorting_detail_|purchase_)/, '')
16
+ }
17
+
18
+ export function buildDataKey(prefix, suffix) {
19
+ return `${prefix}${suffix}`
20
+ }
21
+
22
+ /** 下拉选中「按明细单行」时的 value(detail_one_row) */
23
+ export function isDetailOneRowSelectKey(dataKey) {
24
+ return getDataKeySuffix(dataKey) === 'detail_one_row'
25
+ }
26
+
27
+ export function isIndependentRolDataKey(dataKey) {
28
+ const suffix = getDataKeySuffix(dataKey)
29
+ return suffix === 'independent_rol_sku' || suffix === 'independent_rol_address'
30
+ }
31
+
32
+ export function isLastColDataKey(dataKey) {
33
+ const suffix = getDataKeySuffix(dataKey)
34
+ return suffix === 'last_col' || suffix === 'last_col_noLineBreak'
35
+ }
@@ -207,8 +207,15 @@ class EditorField extends React.Component {
207
207
  tableDataKeyList,
208
208
  editStore,
209
209
  isSomeSubtotalTr,
210
- mergeClassificationAndLabel
210
+ mergeClassificationAndLabel,
211
+ editFieldConfig = {}
211
212
  } = this.props
213
+ // 业务侧可通过 editFieldConfig 隐藏配送单专属配置;未传则默认全部展示(兼容旧逻辑)
214
+ const showCategory = editFieldConfig.category !== false
215
+ const showCategorySubtotal = editFieldConfig.categorySubtotal !== false
216
+ const showPageSubtotal = editFieldConfig.pageSubtotal !== false
217
+ const showDiyPageSubtotal = editFieldConfig.diyPageSubtotal !== false
218
+ const showOverallOrder = editFieldConfig.overallOrder !== false
212
219
  const { head, headStyle, text, style } = editStore.computedSelectedInfo
213
220
  const { config } = editStore
214
221
  const isLongPrint = config?.page?.type === LONG_PRINT
@@ -216,9 +223,16 @@ class EditorField extends React.Component {
216
223
  specialConfig,
217
224
  subtotal,
218
225
  overallOrder,
219
- diyOverallOrder
226
+ diyOverallOrder,
227
+ diySubtotal
220
228
  } = editStore.computedTableSpecialConfig
221
229
 
230
+ // 与预览区右键开关联动:未开启时不展示对应编辑配置(避免「点不动却占位」)
231
+ const pageSubtotalEnabled = !!subtotal?.show
232
+ const diyPageSubtotalEnabled = !!diySubtotal?.show
233
+ const overallOrderEnabled = !!overallOrder?.show
234
+ const diyOverallOrderEnabled = !!diyOverallOrder?.show
235
+
222
236
  // 新分类
223
237
  const categoryStyle =
224
238
  toJS(editStore.computedTableSpecialConfig)?.categoryConfig?.style || {}
@@ -477,217 +491,235 @@ class EditorField extends React.Component {
477
491
  />
478
492
  <Gap />
479
493
 
480
- {!mergeClassificationAndLabel && (
494
+ {!mergeClassificationAndLabel && (showCategory || showCategorySubtotal) && (
495
+ <>
496
+ {showCategory && (
497
+ <Flex>
498
+ <Flex>{i18next.t('分类设置')}:</Flex>
499
+ <Fonter
500
+ style={categoryStyle}
501
+ onChange={this.handleCategoryStyleChange}
502
+ />
503
+ <Separator />
504
+ <TextAlign
505
+ style={categoryStyle}
506
+ onChange={this.handleCategoryStyleChange}
507
+ />
508
+ </Flex>
509
+ )}
510
+
511
+ {showCategorySubtotal && (
512
+ <>
513
+ <Flex>
514
+ <Flex>{i18next.t('小计设置')}:</Flex>
515
+ <Fonter
516
+ style={specialStyle}
517
+ onChange={this.handleSpecialStyleChange}
518
+ />
519
+ <Separator />
520
+ <TextAlign
521
+ style={specialStyle}
522
+ onChange={this.handleSpecialStyleChange}
523
+ />
524
+ </Flex>
525
+ <EditorSubtotalCheck
526
+ subtotalCheckDisabled
527
+ subtotalChecked={specialTrNeedUpperCase}
528
+ subtotalCheckOnChange={editStore.setSpecialUpperCase}
529
+ subtotalCheckText='显示大写金额'
530
+ />
531
+ </>
532
+ )}
533
+ </>
534
+ )}
535
+
536
+ {showPageSubtotal && pageSubtotalEnabled && (
481
537
  <>
482
538
  <Flex>
483
- <Flex>{i18next.t('分类设置')}:</Flex>
539
+ <Flex>{i18next.t('每页合计设置')}:</Flex>
484
540
  <Fonter
485
- style={categoryStyle}
486
- onChange={this.handleCategoryStyleChange}
541
+ style={subtotalStyle}
542
+ onChange={this.handleSubtotalStyleChange}
487
543
  />
488
544
  <Separator />
489
545
  <TextAlign
490
- style={categoryStyle}
491
- onChange={this.handleCategoryStyleChange}
546
+ style={subtotalStyle}
547
+ onChange={this.handleSubtotalStyleChange}
492
548
  />
493
549
  </Flex>
550
+ <Gap />
551
+ {!isSomeSubtotalTr && (
552
+ <div>
553
+ <Flex>{i18next.t('合计栏打印金额')}:</Flex>
554
+ <Flex style={{ marginLeft: 57 }} wrap>
555
+ {subtotalRadioList.map(fields => {
556
+ // 兼容
557
+ let subtotalFields = subtotal?.fields?.[0].valueField
558
+ if (subtotalFields === 'total_item_price')
559
+ subtotalFields = '下单金额'
560
+ if (
561
+ subtotalFields === 'real_item_price' ||
562
+ !subtotal?.fields?.[0].valueField
563
+ )
564
+ subtotalFields = '出库金额'
565
+ return (
566
+ <Radio
567
+ style={{ marginLeft: 5 }}
568
+ id={fields.id}
569
+ value={fields.value}
570
+ key={fields.id}
571
+ inputName='subtotalRadio'
572
+ checked={subtotalFields === fields.id}
573
+ radioChecked={() => editStore.subtotalRadioCheck(fields)}
574
+ />
575
+ )
576
+ })}
577
+ </Flex>
578
+ </div>
579
+ )}
580
+ {/* 结款单不需要这个配置 */}
581
+ {!isSomeSubtotalTr && (
582
+ <EditorSubtotalCheck
583
+ subtotalCheckDisabled
584
+ subtotalChecked={printAccount}
585
+ subtotalCheckOnChange={editStore.setPrintAccount}
586
+ subtotalCheckText='打印账户总计金额'
587
+ />
588
+ )}
589
+ <EditorSubtotalCheck
590
+ subtotalCheckDisabled
591
+ subtotalChecked={subtotalNeedUpperCase}
592
+ subtotalCheckOnChange={editStore.setSubtotalUpperCase}
593
+ subtotalCheckText='显示大写金额'
594
+ />
595
+ {/* 结款单不需要这些配置 */}
596
+ {!isSomeSubtotalTr && (
597
+ <>
598
+ <EditorSubtotalCheck
599
+ subtotalCheckDisabled={subtotalNeedUpperCase}
600
+ subtotalChecked={subtotalUpperCaseBefore}
601
+ subtotalCheckOnChange={editStore.setSubtotalUpperCaseBefore}
602
+ subtotalCheckText='大写金额在前'
603
+ />
604
+ <EditorSubtotalCheck
605
+ subtotalCheckDisabled={subtotalNeedUpperCase}
606
+ subtotalChecked={subtotalUpperLowerCaseSeparate}
607
+ subtotalCheckOnChange={
608
+ editStore.setSubtotalUpperLowerCaseSeparate
609
+ }
610
+ subtotalCheckText='大、小写金额分左右两边展示'
611
+ />
612
+ <EditorSubtotalCheck
613
+ subtotalCheckDisabled
614
+ subtotalChecked={subtotalUpperCustomCell}
615
+ subtotalCheckOnChange={editStore.setSubtotalCustomCells}
616
+ subtotalCheckText='开启自定义单元格'
617
+ />
618
+ <Text
619
+ // 只有自定义单元格的valueField值是空的,以后自每页合计,记得加type,之前没加,都无法区分
620
+ value={
621
+ subtotal && subtotal?.fields?.length > 1
622
+ ? _.find(subtotal?.fields, item => !item.valueField)
623
+ ?.name ?? ''
624
+ : ''
625
+ }
626
+ onChange={editStore.setSubtotalFields}
627
+ style={{ width: '65px', margin: '5px 0 5px 80px' }}
628
+ />
629
+ </>
630
+ )}
631
+ </>
632
+ )}
633
+
634
+ {showDiyPageSubtotal &&
635
+ diyPageSubtotalEnabled &&
636
+ this.renderDiySummaryEditor({
637
+ label: '自定义每页合计',
638
+ placeholder: '请输入要每页合计字段',
639
+ showConfigKey: 'showDiySubtotal',
640
+ configKey: 'diySubtotal',
641
+ editStore
642
+ })}
494
643
 
644
+ {showOverallOrder && overallOrderEnabled && (
645
+ <>
495
646
  <Flex>
496
- <Flex>{i18next.t('小计设置')}:</Flex>
647
+ <Flex>{i18next.t('整单合计')}:</Flex>
497
648
  <Fonter
498
- style={specialStyle}
499
- onChange={this.handleSpecialStyleChange}
649
+ style={overallOrderStyle}
650
+ onChange={this.handleOverallOrderStyleChange}
500
651
  />
501
652
  <Separator />
502
653
  <TextAlign
503
- style={specialStyle}
504
- onChange={this.handleSpecialStyleChange}
654
+ style={overallOrderStyle}
655
+ onChange={this.handleOverallOrderStyleChange}
505
656
  />
506
657
  </Flex>
507
658
  <EditorSubtotalCheck
508
659
  subtotalCheckDisabled
509
- subtotalChecked={specialTrNeedUpperCase}
510
- subtotalCheckOnChange={editStore.setSpecialUpperCase}
511
- subtotalCheckText='显示大写金额'
660
+ subtotalChecked={overallOrder?.showEachPage !== false}
661
+ subtotalCheckOnChange={editStore.setOverallOrderShowEachPage}
662
+ subtotalCheckText='每页展示'
512
663
  />
513
- </>
514
- )}
515
-
516
- <Flex>
517
- <Flex>{i18next.t('每页合计设置')}:</Flex>
518
- <Fonter
519
- style={subtotalStyle}
520
- onChange={this.handleSubtotalStyleChange}
521
- />
522
- <Separator />
523
- <TextAlign
524
- style={subtotalStyle}
525
- onChange={this.handleSubtotalStyleChange}
526
- />
527
- </Flex>
528
- <Gap />
529
- {!isSomeSubtotalTr && (
530
- <div>
531
- <Flex>{i18next.t('合计栏打印金额')}:</Flex>
532
664
  <Flex style={{ marginLeft: 57 }} wrap>
533
- {subtotalRadioList.map(fields => {
534
- // 兼容
535
- let subtotalFields = subtotal?.fields?.[0].valueField
536
- if (subtotalFields === 'total_item_price')
537
- subtotalFields = '下单金额'
538
- if (
539
- subtotalFields === 'real_item_price' ||
540
- !subtotal?.fields?.[0].valueField
541
- )
542
- subtotalFields = '出库金额'
665
+ {overallOrderRadioList.map((fields, i) => {
543
666
  return (
544
667
  <Radio
545
668
  style={{ marginLeft: 5 }}
546
- id={fields.id}
669
+ id={`${fields.id}${i}`}
547
670
  value={fields.value}
548
671
  key={fields.id}
549
- inputName='subtotalRadio'
550
- checked={subtotalFields === fields.id}
551
- radioChecked={() => editStore.subtotalRadioCheck(fields)}
672
+ inputName='overallOrderRadio'
673
+ checked={
674
+ (overallOrder?.fields?.[0]?.valueField ?? '出库金额') ===
675
+ fields.id
676
+ }
677
+ radioChecked={() =>
678
+ editStore.setOverallOrderValueField(fields)
679
+ }
552
680
  />
553
681
  )
554
682
  })}
555
683
  </Flex>
556
- </div>
557
- )}
558
- {/* 结款单不需要这个配置 */}
559
- {!isSomeSubtotalTr && (
560
- <EditorSubtotalCheck
561
- subtotalCheckDisabled
562
- subtotalChecked={printAccount}
563
- subtotalCheckOnChange={editStore.setPrintAccount}
564
- subtotalCheckText='打印账户总计金额'
565
- />
566
- )}
567
- <EditorSubtotalCheck
568
- subtotalCheckDisabled
569
- subtotalChecked={subtotalNeedUpperCase}
570
- subtotalCheckOnChange={editStore.setSubtotalUpperCase}
571
- subtotalCheckText='显示大写金额'
572
- />
573
- {/* 结款单不需要这些配置 */}
574
- {!isSomeSubtotalTr && (
575
- <>
576
684
  <EditorSubtotalCheck
577
- subtotalCheckDisabled={subtotalNeedUpperCase}
578
- subtotalChecked={subtotalUpperCaseBefore}
579
- subtotalCheckOnChange={editStore.setSubtotalUpperCaseBefore}
685
+ subtotalCheckDisabled
686
+ subtotalChecked={overallOrderNeedUpperCase}
687
+ subtotalCheckOnChange={editStore.setOverallOrderUpperCase}
688
+ subtotalCheckText='显示大写金额'
689
+ />
690
+ <EditorSubtotalCheck
691
+ subtotalCheckDisabled={overallOrderNeedUpperCase}
692
+ subtotalChecked={overallOrderCaseBefore}
693
+ subtotalCheckOnChange={editStore.setOverallOrderUpperCaseBefore}
580
694
  subtotalCheckText='大写金额在前'
581
695
  />
582
696
  <EditorSubtotalCheck
583
- subtotalCheckDisabled={subtotalNeedUpperCase}
584
- subtotalChecked={subtotalUpperLowerCaseSeparate}
697
+ subtotalCheckDisabled={overallOrderNeedUpperCase}
698
+ subtotalChecked={overallOrderUpperLowerCaseSeparate}
585
699
  subtotalCheckOnChange={
586
- editStore.setSubtotalUpperLowerCaseSeparate
700
+ editStore.setOverallOrderUpperLowerCaseSeparate
587
701
  }
588
702
  subtotalCheckText='大、小写金额分左右两边展示'
589
703
  />
590
704
  <EditorSubtotalCheck
591
705
  subtotalCheckDisabled
592
- subtotalChecked={subtotalUpperCustomCell}
593
- subtotalCheckOnChange={editStore.setSubtotalCustomCells}
706
+ subtotalChecked={overallOrderUpperCustomCell}
707
+ subtotalCheckOnChange={editStore.setOverallOrderCustomCells}
594
708
  subtotalCheckText='开启自定义单元格'
595
709
  />
596
710
  <Text
597
- // 只有自定义单元格的valueField值是空的,以后自每页合计,记得加type,之前没加,都无法区分
598
711
  value={
599
- subtotal && subtotal?.fields?.length > 1
600
- ? _.find(subtotal?.fields, item => !item.valueField)?.name ??
601
- ''
712
+ overallOrder && overallOrder?.fields?.[1]
713
+ ? overallOrder.fields[1].name
602
714
  : ''
603
715
  }
604
- onChange={editStore.setSubtotalFields}
716
+ onChange={editStore.setOverallOrderFields}
605
717
  style={{ width: '65px', margin: '5px 0 5px 80px' }}
606
718
  />
607
719
  </>
608
720
  )}
609
-
610
- {this.renderDiySummaryEditor({
611
- label: '自定义每页合计',
612
- placeholder: '请输入要每页合计字段',
613
- showConfigKey: 'showDiySubtotal',
614
- configKey: 'diySubtotal',
615
- editStore
616
- })}
617
-
618
- <Flex>
619
- <Flex>{i18next.t('整单合计')}:</Flex>
620
- <Fonter
621
- style={overallOrderStyle}
622
- onChange={this.handleOverallOrderStyleChange}
623
- />
624
- <Separator />
625
- <TextAlign
626
- style={overallOrderStyle}
627
- onChange={this.handleOverallOrderStyleChange}
628
- />
629
- </Flex>
630
- <EditorSubtotalCheck
631
- subtotalCheckDisabled
632
- subtotalChecked={overallOrder?.showEachPage !== false}
633
- subtotalCheckOnChange={editStore.setOverallOrderShowEachPage}
634
- subtotalCheckText='每页展示'
635
- />
636
- <Flex style={{ marginLeft: 57 }} wrap>
637
- {overallOrderRadioList.map((fields, i) => {
638
- return (
639
- <Radio
640
- style={{ marginLeft: 5 }}
641
- id={`${fields.id}${i}`}
642
- value={fields.value}
643
- key={fields.id}
644
- inputName='overallOrderRadio'
645
- checked={
646
- (overallOrder?.fields?.[0]?.valueField ?? '出库金额') ===
647
- fields.id
648
- }
649
- radioChecked={() => editStore.setOverallOrderValueField(fields)}
650
- />
651
- )
652
- })}
653
- </Flex>
654
- <EditorSubtotalCheck
655
- subtotalCheckDisabled
656
- subtotalChecked={overallOrderNeedUpperCase}
657
- subtotalCheckOnChange={editStore.setOverallOrderUpperCase}
658
- subtotalCheckText='显示大写金额'
659
- />
660
- <EditorSubtotalCheck
661
- subtotalCheckDisabled={overallOrderNeedUpperCase}
662
- subtotalChecked={overallOrderCaseBefore}
663
- subtotalCheckOnChange={editStore.setOverallOrderUpperCaseBefore}
664
- subtotalCheckText='大写金额在前'
665
- />
666
- <EditorSubtotalCheck
667
- subtotalCheckDisabled={overallOrderNeedUpperCase}
668
- subtotalChecked={overallOrderUpperLowerCaseSeparate}
669
- subtotalCheckOnChange={
670
- editStore.setOverallOrderUpperLowerCaseSeparate
671
- }
672
- subtotalCheckText='大、小写金额分左右两边展示'
673
- />
674
- <EditorSubtotalCheck
675
- subtotalCheckDisabled
676
- subtotalChecked={overallOrderUpperCustomCell}
677
- subtotalCheckOnChange={editStore.setOverallOrderCustomCells}
678
- subtotalCheckText='开启自定义单元格'
679
- />
680
- <Text
681
- value={
682
- overallOrder && overallOrder?.fields?.[1]
683
- ? overallOrder.fields[1].name
684
- : ''
685
- }
686
- onChange={editStore.setOverallOrderFields}
687
- style={{ width: '65px', margin: '5px 0 5px 80px' }}
688
- />
689
- {/* 自定义整单合计 */}
690
- {editStore.config.showDiyOverAllOrder && (
721
+ {/* 自定义整单合计:能力开关 showDiyOverAllOrder + 预览区已开启 */}
722
+ {editStore.config.showDiyOverAllOrder && diyOverallOrderEnabled && (
691
723
  <Flex>
692
724
  <Flex>{i18next.t('自定义整单合计')}:</Flex>
693
725
  <div>
@@ -786,11 +818,11 @@ class EditorField extends React.Component {
786
818
  style={specialStyle}
787
819
  onChange={this.handleClassificationAndLabelTally}
788
820
  />
789
- <Flex style={{ marginLeft: 0 }}>
821
+ <Flex style={{ marginLeft: 0 }} wrap>
790
822
  {subtotalRadioList.map((fields, i) => {
791
823
  return (
792
824
  <Radio
793
- style={{ marginLeft: 5 }}
825
+ style={{ marginLeft: 5, marginBottom: 4 }}
794
826
  id={`${fields.id}_${i}`}
795
827
  value={fields.value}
796
828
  key={fields.id}
@@ -991,10 +1023,16 @@ EditorField.propTypes = {
991
1023
  tableDataKeyList: PropTypes.array,
992
1024
  showNewDate: PropTypes.bool,
993
1025
  isSomeSubtotalTr: PropTypes.bool,
994
- mergeClassificationAndLabel: PropTypes.bool
1026
+ mergeClassificationAndLabel: PropTypes.bool,
1027
+ /**
1028
+ * 控制「编辑字段」区各配置块显隐。未传 / 某项不为 false 时保持展示(默认兼容配送单)。
1029
+ * 可选 key:category / categorySubtotal / pageSubtotal / diyPageSubtotal / overallOrder
1030
+ */
1031
+ editFieldConfig: PropTypes.object
995
1032
  }
996
1033
  EditorField.defaultProps = {
997
- showNewDate: false
1034
+ showNewDate: false,
1035
+ editFieldConfig: {}
998
1036
  }
999
1037
 
1000
1038
  class EditorSubtotalCheck extends React.Component {
@@ -4,6 +4,12 @@ import { pageTypeMap } from '../config'
4
4
  import _ from 'lodash'
5
5
  import { dispatchMsg, getBlockName, exchange, getColSpanLength } from '../util'
6
6
  import { accountRadioList } from './util'
7
+ import {
8
+ buildDataKey,
9
+ getDataKeyPrefix,
10
+ isDetailOneRowSelectKey,
11
+ isIndependentRolDataKey,
12
+ } from './data_key_util'
7
13
  import React from 'react'
8
14
  import { createDiySummaryStoreMethods } from './diy_summary_helper'
9
15
 
@@ -1269,16 +1275,17 @@ class EditorStore {
1269
1275
  const table = this.config.contents[arr[2]]
1270
1276
 
1271
1277
  const getDataKey = () => {
1272
- if (dataKey === 'purchase_detail_one_row') {
1278
+ if (isDetailOneRowSelectKey(dataKey)) {
1273
1279
  if (!table.purchaseSettingKey) {
1274
1280
  this.setPurchasePrintSettingKey()
1275
1281
  return dataKey
1276
1282
  }
1283
+ const prefix = getDataKeyPrefix(dataKey)
1277
1284
  if (table.purchaseSettingKey === 'goods') {
1278
- return 'purchase_independent_rol_sku'
1285
+ return buildDataKey(prefix, 'independent_rol_sku')
1279
1286
  }
1280
1287
  if (table.purchaseSettingKey === 'merchant') {
1281
- return 'purchase_independent_rol_address'
1288
+ return buildDataKey(prefix, 'independent_rol_address')
1282
1289
  }
1283
1290
  }
1284
1291
  return dataKey
@@ -1298,15 +1305,15 @@ class EditorStore {
1298
1305
  @action.bound setPurchasePrintSettingKey(dataKey = 'goods') {
1299
1306
  const arr = this.selectedRegion.split('.')
1300
1307
  const table = this.config.contents[arr[2]]
1308
+ const prefix = getDataKeyPrefix(table.dataKey)
1301
1309
 
1302
1310
  set(table, {
1303
1311
  purchaseSettingKey: dataKey,
1304
1312
  dataKey:
1305
1313
  dataKey === 'goods'
1306
- ? 'purchase_independent_rol_sku'
1307
- : 'purchase_independent_rol_address',
1308
- // 切换打印设置时,重置明细行排序为默认值(候选值列表会变化)
1309
- detail_sort_type: 0
1314
+ ? buildDataKey(prefix, 'independent_rol_sku')
1315
+ : buildDataKey(prefix, 'independent_rol_address'),
1316
+ detail_sort_type: 0,
1310
1317
  })
1311
1318
  }
1312
1319
 
@@ -1327,11 +1334,8 @@ class EditorStore {
1327
1334
  const table = this.config.contents[arr[2]]
1328
1335
 
1329
1336
  const { dataKey } = table
1330
- if (
1331
- dataKey === 'purchase_independent_rol_sku' ||
1332
- dataKey === 'purchase_independent_rol_address'
1333
- ) {
1334
- return 'purchase_detail_one_row'
1337
+ if (isIndependentRolDataKey(dataKey)) {
1338
+ return buildDataKey(getDataKeyPrefix(dataKey), 'detail_one_row')
1335
1339
  }
1336
1340
  return dataKey
1337
1341
  }
@@ -21,6 +21,7 @@ import withStore from '../common/hoc_with_store'
21
21
  class Editor extends React.Component {
22
22
  render() {
23
23
  const { onSave, showEditor, addFields, isPurchase } = this.props
24
+ const editFieldConfig = addFields?.editFieldConfig
24
25
 
25
26
  return (
26
27
  <div className='gm-printer-edit'>
@@ -43,7 +44,7 @@ class Editor extends React.Component {
43
44
  <Gap height='10px' />
44
45
  <EditorSelect isPurchase={isPurchase} />
45
46
  <Gap height='5px' />
46
- <EditorField />
47
+ <EditorField editFieldConfig={editFieldConfig} />
47
48
  <Gap height='5px' />
48
49
  <EditorAddField addFields={addFields} />
49
50
  <Gap height='5px' />
@@ -14,6 +14,11 @@ import {
14
14
  } from '../common/component'
15
15
  import _ from 'lodash'
16
16
  import { inject, observer } from 'mobx-react'
17
+ import {
18
+ buildDataKey,
19
+ getDataKeyPrefix,
20
+ isDetailOneRowSelectKey,
21
+ } from '../common/data_key_util'
17
22
 
18
23
  const dataKeyList = [
19
24
  { value: 'purchase_no_detail', text: i18next.t('不打印明细') },
@@ -78,33 +83,31 @@ class TableDetailEditor extends React.Component {
78
83
 
79
84
  handleDetailAddField = ({ key, value }) => {
80
85
  const { editStore, config, addFields } = this.props
81
- if (editStore.computedDataKey === 'purchase_detail_one_row') {
82
- // 序号 {{列.序号}}
86
+ if (isDetailOneRowSelectKey(editStore.computedDataKey)) {
83
87
  const transform = str => {
84
88
  return str
85
- .replace(/{{\s*([^}]+)\s*}}/g, '{{$1}}') // 先标准化(去掉多余空格)
89
+ .replace(/{{\s*([^}]+)\s*}}/g, '{{$1}}')
86
90
  .replace(/{{([^.\s}]+)}}/g, '{{列.$1}}')
87
91
  }
92
+ const prefix = getDataKeyPrefix(config.dataKey)
93
+ const rolSkuKey = buildDataKey(prefix, 'independent_rol_sku')
94
+ const rolAddressKey = buildDataKey(prefix, 'independent_rol_address')
88
95
  if (
89
96
  config.purchaseSettingKey === 'goods' &&
90
- config.dataKey !== 'purchase_independent_rol_sku'
97
+ config.dataKey !== rolSkuKey
91
98
  ) {
92
- editStore.setPurchaseTableKey(
93
- 'purchase_independent_rol_sku',
94
- addFields.specialTableConfig
95
- )
99
+ editStore.setPurchaseTableKey(rolSkuKey, addFields.specialTableConfig)
96
100
  } else if (
97
101
  config.purchaseSettingKey === 'merchant' &&
98
- config.dataKey !== 'purchase_independent_rol_address'
102
+ config.dataKey !== rolAddressKey
99
103
  ) {
100
104
  editStore.setPurchaseTableKey(
101
- 'purchase_independent_rol_address',
105
+ rolAddressKey,
102
106
  addFields.specialTableConfig
103
107
  )
104
108
  }
105
109
 
106
110
  editStore.addFieldToTable({ key, value: transform(value) })
107
-
108
111
  return
109
112
  }
110
113
  editStore.specialTextAddField('*' + value)
@@ -161,7 +164,7 @@ class TableDetailEditor extends React.Component {
161
164
  </Select>
162
165
  </Flex>
163
166
 
164
- {editStore.computedDataKey === 'purchase_detail_one_row' && (
167
+ {isDetailOneRowSelectKey(editStore.computedDataKey) && (
165
168
  <>
166
169
  <Flex alignCenter className='gm-padding-top-5'>
167
170
  <div>{i18next.t('打印设置')}:</div>
@@ -229,7 +232,7 @@ class TableDetailEditor extends React.Component {
229
232
  </Flex>
230
233
  </div>
231
234
 
232
- {editStore.computedDataKey !== 'purchase_detail_one_row' && (
235
+ {!isDetailOneRowSelectKey(editStore.computedDataKey) && (
233
236
  <>
234
237
  <div className='gm-padding-top-5'>
235
238
  <div>{i18next.t('字段设置')}:</div>