gm-printer 10.26.0-beta.1 → 10.26.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-beta.1",
3
+ "version": "10.26.0",
4
4
  "description": "diy printer",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -455,6 +455,15 @@ class EditorField extends React.Component {
455
455
  <Flex>{i18next.t('合计栏打印金额')}:</Flex>
456
456
  <Flex style={{ marginLeft: 57 }}>
457
457
  {subtotalRadioList.map(fields => {
458
+ // 兼容
459
+ let subtotalFields = subtotal?.fields?.[0].valueField
460
+ if (subtotalFields === 'total_item_price')
461
+ subtotalFields = '下单金额'
462
+ if (
463
+ subtotalFields === 'real_item_price' ||
464
+ !subtotal?.fields?.[0].valueField
465
+ )
466
+ subtotalFields = '出库金额'
458
467
  return (
459
468
  <Radio
460
469
  style={{ marginLeft: 5 }}
@@ -462,7 +471,7 @@ class EditorField extends React.Component {
462
471
  value={fields.value}
463
472
  key={fields.id}
464
473
  inputName='subtotalRadio'
465
- checked={subtotal?.fields?.[0].valueField === fields.id}
474
+ checked={subtotalFields === fields.id}
466
475
  radioChecked={() => editStore.subtotalRadioCheck(fields)}
467
476
  />
468
477
  )
@@ -533,6 +542,24 @@ class EditorField extends React.Component {
533
542
  onChange={this.handleOverallOrderStyleChange}
534
543
  />
535
544
  </Flex>
545
+ <Flex style={{ marginLeft: 57 }}>
546
+ {subtotalRadioList.map((fields, i) => {
547
+ return (
548
+ <Radio
549
+ style={{ marginLeft: 5 }}
550
+ id={`${fields.id}${i}`}
551
+ value={fields.value}
552
+ key={fields.id}
553
+ inputName='overallOrderRadio'
554
+ checked={
555
+ (overallOrder?.fields?.[0]?.valueField ?? '出库金额') ===
556
+ fields.id
557
+ }
558
+ radioChecked={() => editStore.setOverallOrderValueField(fields)}
559
+ />
560
+ )
561
+ })}
562
+ </Flex>
536
563
  <EditorSubtotalCheck
537
564
  subtotalCheckDisabled
538
565
  subtotalChecked={overallOrderNeedUpperCase}
@@ -607,6 +607,26 @@ class EditorStore {
607
607
  if (this.selectedRegion) {
608
608
  this.overallOrderShow = !this.overallOrderShow
609
609
  const arr = this.selectedRegion.split('.')
610
+ const table = this.config.contents[arr[2]]
611
+ const colSpanLength = getColSpanLength(table)
612
+ if (!this.config.contents[arr[2]].subtotal.fields?.[0]) {
613
+ // 兼容已经存在的配送单据,他们的配置存在后端的,没有subtotal这个配置,给加上
614
+ set(table, {
615
+ subtotal: {
616
+ show: true,
617
+ fields: [
618
+ {
619
+ name: '每页合计:',
620
+ valueField: '下单金额',
621
+ style: {
622
+ fontWeight: 'bold'
623
+ },
624
+ colSpan: colSpanLength
625
+ }
626
+ ]
627
+ }
628
+ })
629
+ }
610
630
  this.config.contents[arr[2]].subtotal.fields[0].valueField = fields.id
611
631
 
612
632
  const fieldList = this.config.contents[arr[2]].subtotal.fields
@@ -672,7 +692,7 @@ class EditorStore {
672
692
  fields: [
673
693
  {
674
694
  name: '自定义整单合计:',
675
- valueField: '{{出库金额}}',
695
+ valueField: '{{列.出库金额}}',
676
696
  style: {
677
697
  fontWeight: 'bold'
678
698
  }
@@ -1208,7 +1228,7 @@ class EditorStore {
1208
1228
  fields: [
1209
1229
  {
1210
1230
  name: '每页合计:',
1211
- valueField: 'real_item_price',
1231
+ valueField: '出库金额',
1212
1232
  colSpan: colSpanLength
1213
1233
  }
1214
1234
  ]
@@ -1357,6 +1377,39 @@ class EditorStore {
1357
1377
  }
1358
1378
  }
1359
1379
 
1380
+ // 整单合计金额单选设置
1381
+ @action.bound
1382
+ setOverallOrderValueField({ id }) {
1383
+ if (this.selectedRegion) {
1384
+ this.overallOrderShow = !this.overallOrderShow
1385
+ const arr = this.selectedRegion.split('.')
1386
+ const table = this.config.contents[arr[2]]
1387
+ const colSpanLength = getColSpanLength(table)
1388
+ if (!this.config.contents[arr[2]].overallOrder.fields?.[0]) {
1389
+ // 兼容已经存在的配送单据,他们的配置存在后端的,没有overallOrder这个配置,给加上
1390
+ set(table, {
1391
+ overallOrder: {
1392
+ show: true,
1393
+ fields: [
1394
+ {
1395
+ name: '整单合计:',
1396
+ valueField: '下单金额',
1397
+ style: {
1398
+ fontWeight: 'bold'
1399
+ },
1400
+ colSpan: colSpanLength
1401
+ }
1402
+ ]
1403
+ }
1404
+ })
1405
+ }
1406
+ const overallOrderConfig = this.config.contents[arr[2]]?.overallOrder
1407
+ const oldValueField = overallOrderConfig.fields?.[0]
1408
+ this.config.contents[arr[2]]?.overallOrder &&
1409
+ set(oldValueField, { valueField: id })
1410
+ }
1411
+ }
1412
+
1360
1413
  // 整单合计设置大写金额
1361
1414
  @action.bound
1362
1415
  setOverallOrderUpperCase() {
@@ -3,22 +3,27 @@ import i18next from '../../locales'
3
3
  /**
4
4
  * 每页合计设置单选按钮
5
5
  * id的值是用来计算每页的金额总数,不要轻易随便改
6
- * id值暂时使用_origin的值,可优化改为{{列.xxxx}}的值,改起来有代价,先不改
7
6
  */
7
+ // 整单合计和每页合计栏都使用的这个
8
8
  const subtotalRadioList = [
9
9
  {
10
10
  value: i18next.t('下单金额'),
11
- id: 'total_item_price'
11
+ id: '下单金额'
12
12
  },
13
13
  {
14
14
  value: i18next.t('出库金额'),
15
- id: 'real_item_price'
15
+ id: '出库金额'
16
+ },
17
+ {
18
+ value: i18next.t('实际金额'),
19
+ id: '实际金额'
16
20
  }
17
21
  ]
18
22
 
19
23
  const accountRadioList = {
20
- total_item_price: i18next.t('下单金额'),
21
- real_item_price: i18next.t('出库金额')
24
+ 下单金额: i18next.t('下单金额'),
25
+ 出库金额: i18next.t('出库金额'),
26
+ 实际金额: i18next.t('实际金额')
22
27
  }
23
28
 
24
29
  export { subtotalRadioList, accountRadioList }
@@ -30,10 +30,11 @@ const SubtotalTr = props => {
30
30
  isUpperCaseBefore, // 决定小写金额是否在前
31
31
  isUpperLowerCaseSeparate, // 决定大小写金额是否分开在两端
32
32
  style,
33
+
33
34
  fields = [
34
35
  {
35
36
  name: i18next.t('每页合计:'),
36
- valueField: 'real_item_price'
37
+ valueField: '出库金额'
37
38
  }
38
39
  ],
39
40
  displayName = false // 是否展示字段名
@@ -68,6 +69,30 @@ const SubtotalTr = props => {
68
69
  ).toFixed(2)
69
70
  }
70
71
 
72
+ // 计算合计
73
+ const sumData2 = (list, field) => {
74
+ // 兼容之前
75
+ if (field === 'total_item_price') field = '下单金额'
76
+ if (field === 'real_item_price') field = '出库金额'
77
+ if (field === 'settle_money2') field = '结算金额'
78
+ if (field === 'total_money2') field = '金额'
79
+ return _.reduce(
80
+ list,
81
+ (a, b) => {
82
+ let result = a
83
+ result = a.plus(b[field] || 0)
84
+ if (b?.[field + MULTI_SUFFIX]) {
85
+ result = result.plus(b?.[field + MULTI_SUFFIX])
86
+ }
87
+ if (b?.[field + MULTI_SUFFIX3]) {
88
+ result = result.plus(b?.[field + MULTI_SUFFIX3])
89
+ }
90
+ return result
91
+ },
92
+ Big(0)
93
+ ).toFixed(2)
94
+ }
95
+
71
96
  const getData = field => {
72
97
  const data = printerStore.data.common
73
98
  return data?.[field] ?? ''
@@ -82,7 +107,7 @@ const SubtotalTr = props => {
82
107
  const sum = {}
83
108
 
84
109
  _.each(fields, v => {
85
- sum[v.name] = sumData(list, v.valueField)
110
+ sum[v.name] = sumData2(list, v.valueField)
86
111
  })
87
112
  let subtotalStr = ''
88
113
  for (const name in sum) {
@@ -140,7 +165,7 @@ const SubtotalTr = props => {
140
165
  {item.type === 'useSummarize'
141
166
  ? getData(item.valueField)
142
167
  : index === 0
143
- ? sumData(list, item.valueField)
168
+ ? sumData2(list, item.valueField)
144
169
  : ''}
145
170
  {/* {index === 0 ? sumData(list, item.valueField) : ''} */}
146
171
  </span>
@@ -151,7 +176,9 @@ const SubtotalTr = props => {
151
176
  coverDigit2Uppercase(getData(item.valueField))
152
177
  : index === 0
153
178
  ? '大写:' +
154
- coverDigit2Uppercase(sumData(list, item.valueField))
179
+ coverDigit2Uppercase(
180
+ sumData2(list, item.valueField)
181
+ )
155
182
  : ''}
156
183
  </span>
157
184
  )}