gm-printer 10.14.2-alpha.5 → 10.14.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.14.2-alpha.5",
3
+ "version": "10.14.2",
4
4
  "description": "diy printer",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -13,8 +13,7 @@ import {
13
13
  ColumnWidth,
14
14
  Textarea,
15
15
  Title,
16
- TipInfo,
17
- Text
16
+ TipInfo
18
17
  } from '../common/component'
19
18
  import { get, toJS } from 'mobx'
20
19
  import PropTypes from 'prop-types'
@@ -74,11 +73,6 @@ class EditorField extends React.Component {
74
73
  editStore.setSubtotalStyle(value)
75
74
  }
76
75
 
77
- handleOverallOrderStyleChange = value => {
78
- const { editStore } = this.props
79
- editStore.setOverallOrderStyle(value)
80
- }
81
-
82
76
  renderBlocks() {
83
77
  const { editStore, showNewDate } = this.props
84
78
  const { type, text, style, link } = editStore.computedSelectedInfo
@@ -184,15 +178,10 @@ class EditorField extends React.Component {
184
178
  }
185
179
 
186
180
  renderTable() {
187
- const { tableDataKeyList, editStore, isSomeSubtotalTr } = this.props
181
+ const { tableDataKeyList, editStore } = this.props
188
182
  const { head, headStyle, text, style } = editStore.computedSelectedInfo
189
183
 
190
- const {
191
- specialConfig,
192
- subtotal,
193
- overallOrder
194
- } = editStore.computedTableSpecialConfig
195
-
184
+ const { specialConfig, subtotal } = editStore.computedTableSpecialConfig
196
185
  // 小计样式,specialConfig可能是undefined
197
186
  const specialStyle =
198
187
  toJS(editStore.computedTableSpecialConfig)?.specialConfig?.style || {}
@@ -206,45 +195,16 @@ class EditorField extends React.Component {
206
195
  (editStore.computedTableSpecialConfig.subtotal &&
207
196
  get(subtotal, 'needUpperCase')) ||
208
197
  false
209
- // 每页合计大写的金额是否在前
198
+ // 大写的金额是否在前
210
199
  const subtotalUpperCaseBefore =
211
200
  (editStore.computedTableSpecialConfig.subtotal &&
212
201
  get(subtotal, 'isUpperCaseBefore')) ||
213
202
  false
214
- // 每页合计大写和小写的金额是否分开
203
+ // 大写和小写的金额是否分开
215
204
  const subtotalUpperLowerCaseSeparate =
216
205
  (editStore.computedTableSpecialConfig.subtotal &&
217
206
  get(subtotal, 'isUpperLowerCaseSeparate')) ||
218
207
  false
219
- // 每页合计样式
220
- const overallOrderStyle =
221
- (overallOrder && overallOrder?.fields[0].style) || {}
222
- // 每页合计自定义单元格
223
- const subtotalUpperCustomCell =
224
- (editStore.computedTableSpecialConfig?.subtotal &&
225
- get(subtotal, 'isCustomCells')) ||
226
- false
227
- // 整单合计是否大写
228
- const overallOrderNeedUpperCase =
229
- (editStore.computedTableSpecialConfig?.overallOrder &&
230
- get(overallOrder, 'needUpperCase')) ||
231
- false
232
- // 整单合计大写的金额是否在前
233
- const overallOrderCaseBefore =
234
- (editStore.computedTableSpecialConfig?.overallOrder &&
235
- get(overallOrder, 'isUpperCaseBefore')) ||
236
- false
237
- // 整单合计大写和小写的金额是否分开
238
- const overallOrderUpperLowerCaseSeparate =
239
- (editStore.computedTableSpecialConfig?.overallOrder &&
240
- get(overallOrder, 'isUpperLowerCaseSeparate')) ||
241
- false
242
- // 整单合计自定义单元格
243
- const overallOrderUpperCustomCell =
244
- (editStore.computedTableSpecialConfig?.overallOrder &&
245
- get(overallOrder, 'isCustomCells')) ||
246
- false
247
-
248
208
  return (
249
209
  <div>
250
210
  <Title title={i18next.t('编辑字段')} />
@@ -416,85 +376,18 @@ class EditorField extends React.Component {
416
376
  subtotalCheckOnChange={editStore.setSubtotalUpperCase}
417
377
  subtotalCheckText='显示大写金额'
418
378
  />
419
- {/* 结款单不需要这些配置 */}
420
- {!isSomeSubtotalTr && (
421
- <>
422
- <EditorSubtotalCheck
423
- subtotalCheckDisabled={subtotalNeedUpperCase}
424
- subtotalChecked={subtotalUpperCaseBefore}
425
- subtotalCheckOnChange={editStore.setSubtotalUpperCaseBefore}
426
- subtotalCheckText='大写金额在前'
427
- />
428
- <EditorSubtotalCheck
429
- subtotalCheckDisabled={subtotalNeedUpperCase}
430
- subtotalChecked={subtotalUpperLowerCaseSeparate}
431
- subtotalCheckOnChange={
432
- editStore.setSubtotalUpperLowerCaseSeparate
433
- }
434
- subtotalCheckText='大、小写金额分左右两边展示'
435
- />
436
- <EditorSubtotalCheck
437
- subtotalCheckDisabled
438
- subtotalChecked={subtotalUpperCustomCell}
439
- subtotalCheckOnChange={editStore.setSubtotalCustomCells}
440
- subtotalCheckText='开启自定义单元格'
441
- />
442
- <Text
443
- value={
444
- subtotal && subtotal?.fields?.[1] ? subtotal.fields[1].name : ''
445
- }
446
- onChange={editStore.setSubtotalFields}
447
- style={{ width: '65px', margin: '5px 0 5px 80px' }}
448
- />
449
- </>
450
- )}
451
- <Flex>
452
- <Flex>{i18next.t('整单合计')}:</Flex>
453
- <Fonter
454
- style={overallOrderStyle}
455
- onChange={this.handleOverallOrderStyleChange}
456
- />
457
- <Separator />
458
- <TextAlign
459
- style={overallOrderStyle}
460
- onChange={this.handleOverallOrderStyleChange}
461
- />
462
- </Flex>
463
- <EditorSubtotalCheck
464
- subtotalCheckDisabled
465
- subtotalChecked={overallOrderNeedUpperCase}
466
- subtotalCheckOnChange={editStore.setOverallOrderUpperCase}
467
- subtotalCheckText='显示大写金额'
468
- />
469
379
  <EditorSubtotalCheck
470
- subtotalCheckDisabled={overallOrderNeedUpperCase}
471
- subtotalChecked={overallOrderCaseBefore}
472
- subtotalCheckOnChange={editStore.setOverallOrderUpperCaseBefore}
380
+ subtotalCheckDisabled={subtotalNeedUpperCase}
381
+ subtotalChecked={subtotalUpperCaseBefore}
382
+ subtotalCheckOnChange={editStore.setSubtotalUpperCaseBefore}
473
383
  subtotalCheckText='大写金额在前'
474
384
  />
475
385
  <EditorSubtotalCheck
476
- subtotalCheckDisabled={overallOrderNeedUpperCase}
477
- subtotalChecked={overallOrderUpperLowerCaseSeparate}
478
- subtotalCheckOnChange={
479
- editStore.setOverallOrderUpperLowerCaseSeparate
480
- }
386
+ subtotalCheckDisabled={subtotalNeedUpperCase}
387
+ subtotalChecked={subtotalUpperLowerCaseSeparate}
388
+ subtotalCheckOnChange={editStore.setSubtotalUpperLowerCaseSeparate}
481
389
  subtotalCheckText='大、小写金额分左右两边展示'
482
390
  />
483
- <EditorSubtotalCheck
484
- subtotalCheckDisabled
485
- subtotalChecked={overallOrderUpperCustomCell}
486
- subtotalCheckOnChange={editStore.setOverallOrderCustomCells}
487
- subtotalCheckText='开启自定义单元格'
488
- />
489
- <Text
490
- value={
491
- overallOrder && overallOrder?.fields?.[1]
492
- ? overallOrder.fields[1].name
493
- : ''
494
- }
495
- onChange={editStore.setOverallOrderFields}
496
- style={{ width: '65px', margin: '5px 0 5px 80px' }}
497
- />
498
391
  </div>
499
392
  )
500
393
  }
@@ -515,8 +408,7 @@ class EditorField extends React.Component {
515
408
  EditorField.propTypes = {
516
409
  editStore: PropTypes.object,
517
410
  tableDataKeyList: PropTypes.array,
518
- showNewDate: PropTypes.bool,
519
- isSomeSubtotalTr: PropTypes.bool
411
+ showNewDate: PropTypes.bool
520
412
  }
521
413
  EditorField.defaultProps = {
522
414
  showNewDate: false
@@ -2,7 +2,7 @@ import i18next from '../../locales'
2
2
  import { action, computed, observable, set, toJS } from 'mobx'
3
3
  import { pageTypeMap } from '../config'
4
4
  import _ from 'lodash'
5
- import { dispatchMsg, getBlockName, exchange, getColSpanLength } from '../util'
5
+ import { dispatchMsg, getBlockName, exchange } from '../util'
6
6
  import React from 'react'
7
7
 
8
8
  class EditorStore {
@@ -61,28 +61,6 @@ class EditorStore {
61
61
  this.isAutoFilling = bol
62
62
  }
63
63
 
64
- @observable
65
- overallOrderShow = false
66
-
67
- // 整单合计自定义合并单元格
68
- @observable
69
- overallOrderConfigFields = {
70
- name: '',
71
- valueField: '',
72
- colSpan: 3, // 产品说3个
73
- style: {
74
- fontWeight: 'bold'
75
- }
76
- }
77
-
78
- // 每页合计自定义合并单元格
79
- @observable
80
- subtotalConfigFields = {
81
- name: '',
82
- valueField: '',
83
- colSpan: 3 // 产品说3个,开启自定义单元格
84
- }
85
-
86
64
  @computed
87
65
  get computedPrinterKey() {
88
66
  return _.map(this.config, (v, k) => {
@@ -533,64 +511,11 @@ class EditorStore {
533
511
  setSubtotalShow(name) {
534
512
  const arr = name.split('.')
535
513
  const table = this.config.contents[arr[2]]
536
- this.overallOrderShow = !this.overallOrderShow
514
+
537
515
  // 切换的时候,要把对应table的多余空数据清掉
538
516
  this.clearExtraTableData(table.dataKey)
539
-
517
+ table.subtotal.show = !table.subtotal.show
540
518
  this.setAutoFillingConfig(!this.isAutoFilling)
541
- // 获取td的colSpan
542
- const colSpanLength = getColSpanLength(table)
543
- set(table.subtotal, {
544
- show: !table.subtotal.show
545
- })
546
- // 兼容存在后端的模板,subtotal配置没有fields
547
- if (!table.subtotal?.fields) {
548
- set(table.subtotal, {
549
- fields: [
550
- {
551
- name: '每页合计:',
552
- valueField: 'real_item_price',
553
- colSpan: colSpanLength
554
- }
555
- ]
556
- })
557
- } else {
558
- table.subtotal.fields[0].colSpan =
559
- colSpanLength - (table.subtotal.fields?.[1]?.colSpan ?? 0)
560
- }
561
- }
562
-
563
- @action
564
- setOverallOrderShow(name) {
565
- const arr = name.split('.')
566
- const table = this.config.contents[arr[2]]
567
- this.overallOrderShow = !this.overallOrderShow
568
- const colSpanLength = getColSpanLength(table)
569
- if (table.overallOrder) {
570
- set(table.overallOrder, {
571
- show: !table.overallOrder.show
572
- })
573
- table.overallOrder.fields[0].colSpan =
574
- colSpanLength - (table.overallOrder.fields?.[1]?.colSpan ?? 0)
575
- } else {
576
- // 兼容已经存在的配送单据,他们的配置存在后端的,没有overallOrder这个配置,给加上
577
- set(table, {
578
- overallOrder: {
579
- show: true,
580
- fields: [
581
- {
582
- name: '整单合计:',
583
- valueField: '出库金额',
584
- style: {
585
- fontWeight: 'bold'
586
- },
587
- colSpan: colSpanLength
588
- }
589
- ]
590
- }
591
- })
592
- }
593
- this.config = toJS(this.config)
594
519
  }
595
520
 
596
521
  @action
@@ -605,7 +530,7 @@ class EditorStore {
605
530
  @action
606
531
  changeTableDataKey(name, key) {
607
532
  const arr = name.split('.')
608
- const { dataKey, overallOrder, subtotal } = this.config.contents[arr[2]]
533
+ const { dataKey } = this.config.contents[arr[2]]
609
534
  const keyArr = dataKey.split('_')
610
535
  let newDataKey
611
536
  // 当前有这个key则去掉
@@ -629,10 +554,6 @@ class EditorStore {
629
554
  ])
630
555
 
631
556
  this.config.contents[arr[2]].dataKey = newDataKey.join('_')
632
- // 整单合计不显示
633
- if (overallOrder?.show) overallOrder.show = false
634
- // 每页合计不显示
635
- if (subtotal?.show) subtotal.show = false
636
557
  }
637
558
 
638
559
  @action
@@ -1003,7 +924,6 @@ class EditorStore {
1003
924
  @action.bound
1004
925
  setSubtotalStyle(value) {
1005
926
  if (this.selectedRegion) {
1006
- this.overallOrderShow = !this.overallOrderShow
1007
927
  const arr = this.selectedRegion.split('.')
1008
928
  const subtotalConfig = this.config.contents[arr[2]].subtotal
1009
929
 
@@ -1017,11 +937,10 @@ class EditorStore {
1017
937
  }
1018
938
  }
1019
939
 
1020
- // 每页合计设置大写金额
940
+ // 设置大写金额
1021
941
  @action.bound
1022
942
  setSubtotalUpperCase() {
1023
943
  if (this.selectedRegion) {
1024
- this.overallOrderShow = !this.overallOrderShow
1025
944
  const arr = this.selectedRegion.split('.')
1026
945
  const subtotalConfig = this.config.contents[arr[2]].subtotal
1027
946
 
@@ -1037,11 +956,10 @@ class EditorStore {
1037
956
  }
1038
957
  }
1039
958
 
1040
- // 每页合计设置大写金额在前
959
+ // 设置大写金额在前
1041
960
  @action.bound
1042
961
  setSubtotalUpperCaseBefore() {
1043
962
  if (this.selectedRegion) {
1044
- this.overallOrderShow = !this.overallOrderShow
1045
963
  const arr = this.selectedRegion.split('.')
1046
964
  const subtotalConfig = this.config.contents[arr[2]].subtotal
1047
965
 
@@ -1050,11 +968,10 @@ class EditorStore {
1050
968
  }
1051
969
  }
1052
970
 
1053
- // 每页合计设置大小写金额分开
971
+ // 设置大小写金额分开
1054
972
  @action.bound
1055
973
  setSubtotalUpperLowerCaseSeparate() {
1056
974
  if (this.selectedRegion) {
1057
- this.overallOrderShow = !this.overallOrderShow
1058
975
  const arr = this.selectedRegion.split('.')
1059
976
  const subtotalConfig = this.config.contents[arr[2]].subtotal
1060
977
 
@@ -1065,210 +982,7 @@ class EditorStore {
1065
982
  }
1066
983
  }
1067
984
 
1068
- // 每页合计开启自定义单元格
1069
- @action.bound
1070
- setSubtotalCustomCells() {
1071
- if (this.selectedRegion) {
1072
- // 作用:触发组件的更新
1073
- this.overallOrderShow = !this.overallOrderShow
1074
- const arr = this.selectedRegion.split('.')
1075
- const table = this.config.contents[arr[2]]
1076
- const subtotalConfig = table?.subtotal
1077
- // 没有显示每页合计的时候不可以设置自定义单元格
1078
- if (!subtotalConfig?.show) return
1079
- // 多栏表格情况,计算colSpan
1080
- const colSpanLength = getColSpanLength(table)
1081
- const oldCustomCells = subtotalConfig?.isCustomCells
1082
-
1083
- set(subtotalConfig, {
1084
- isCustomCells: !oldCustomCells
1085
- })
1086
- // 兼容已经存在后端的模板,每页合计直接是显示的,导致每页合计配置没有fields,isCustomCells,手动添加上
1087
- if (oldCustomCells === undefined && !subtotalConfig.fields) {
1088
- set(subtotalConfig, {
1089
- fields: [
1090
- {
1091
- name: '每页合计:',
1092
- valueField: 'real_item_price',
1093
- colSpan: colSpanLength
1094
- }
1095
- ]
1096
- })
1097
- }
1098
- // 开启自定义单元格
1099
- if (subtotalConfig?.isCustomCells) {
1100
- // fields添加自定义单元格
1101
- subtotalConfig.fields = [
1102
- subtotalConfig.fields[0],
1103
- {
1104
- ...this.subtotalConfigFields
1105
- }
1106
- ]
1107
- // 重新计算合并单元格的个数
1108
- subtotalConfig.fields[0].colSpan =
1109
- colSpanLength - subtotalConfig.fields[1].colSpan
1110
- } else {
1111
- // 关闭自定义单元格,fields只有一个
1112
- subtotalConfig.fields = [subtotalConfig.fields[0]]
1113
- // 重新计算合并单元格的个数
1114
- subtotalConfig.fields[0].colSpan = colSpanLength
1115
- }
1116
- }
1117
- }
1118
-
1119
- // 每页合计自定义单元格文本输入
1120
- @action.bound
1121
- setSubtotalFields(value) {
1122
- if (this.selectedRegion) {
1123
- const arr = this.selectedRegion.split('.')
1124
- const table = this.config.contents[arr[2]]
1125
- const subtotalConfig = table?.subtotal
1126
-
1127
- if (subtotalConfig.isCustomCells) {
1128
- const subtotalConfig = table?.subtotal.fields
1129
- subtotalConfig[1].name = value
1130
- }
1131
- }
1132
- }
1133
-
1134
- // 整单合计设置大写金额
1135
- @action.bound
1136
- setOverallOrderUpperCase() {
1137
- if (this.selectedRegion) {
1138
- this.overallOrderShow = !this.overallOrderShow
1139
- const arr = this.selectedRegion.split('.')
1140
- const overallOrderConfig = this.config.contents[arr[2]]?.overallOrder
1141
-
1142
- const oldNeedUpperCase = overallOrderConfig?.needUpperCase
1143
- this.config.contents[arr[2]]?.overallOrder &&
1144
- set(overallOrderConfig, { needUpperCase: !oldNeedUpperCase })
1145
- // 没有大写金额时,将大写在前和大小写分开的多选框设置为false
1146
- if (
1147
- this.config.contents[arr[2]]?.overallOrder &&
1148
- overallOrderConfig.needUpperCase === false
1149
- ) {
1150
- overallOrderConfig.isUpperCaseBefore &&
1151
- set(overallOrderConfig, { isUpperCaseBefore: false })
1152
- overallOrderConfig.isUpperLowerCaseSeparate &&
1153
- set(overallOrderConfig, { isUpperLowerCaseSeparate: false })
1154
- }
1155
- }
1156
- }
1157
-
1158
- // 整单合计设置大写金额在前
1159
- @action.bound
1160
- setOverallOrderUpperCaseBefore() {
1161
- if (this.selectedRegion) {
1162
- this.overallOrderShow = !this.overallOrderShow
1163
- const arr = this.selectedRegion.split('.')
1164
- const overallOrderConfig = this.config.contents[arr[2]]?.overallOrder
1165
-
1166
- const oldUpperCaseBefore = overallOrderConfig?.isUpperCaseBefore
1167
- this.config.contents[arr[2]]?.overallOrder &&
1168
- set(overallOrderConfig, { isUpperCaseBefore: !oldUpperCaseBefore })
1169
- }
1170
- }
1171
-
1172
- // 整单合计设置大小写金额分开
1173
- @action.bound
1174
- setOverallOrderUpperLowerCaseSeparate() {
1175
- if (this.selectedRegion) {
1176
- this.overallOrderShow = !this.overallOrderShow
1177
- const arr = this.selectedRegion.split('.')
1178
- const overallOrderConfig = this.config.contents[arr[2]]?.overallOrder
1179
-
1180
- const oldUpperLowerCaseSeparate =
1181
- overallOrderConfig.isUpperLowerCaseSeparate
1182
- set(overallOrderConfig, {
1183
- isUpperLowerCaseSeparate: !oldUpperLowerCaseSeparate
1184
- })
1185
- }
1186
- }
1187
-
1188
- // 整单合计开启自定义单元格
1189
- @action.bound
1190
- setOverallOrderCustomCells() {
1191
- if (this.selectedRegion) {
1192
- // 作用:触发tableoverallordertr组件的更新
1193
- this.overallOrderShow = !this.overallOrderShow
1194
- const arr = this.selectedRegion.split('.')
1195
- const table = this.config.contents[arr[2]]
1196
- const overallOrderConfig = table?.overallOrder
1197
- if (!overallOrderConfig || !overallOrderConfig?.show) return
1198
- // 多栏表格情况
1199
- const colSpanLength = getColSpanLength(table)
1200
- const oldCustomCells = overallOrderConfig?.isCustomCells
1201
-
1202
- set(overallOrderConfig, {
1203
- isCustomCells: !oldCustomCells
1204
- })
1205
-
1206
- if (overallOrderConfig?.isCustomCells) {
1207
- // fields添加自定义单元格
1208
- overallOrderConfig.fields = [
1209
- overallOrderConfig.fields[0],
1210
- {
1211
- ...this.overallOrderConfigFields,
1212
- // 和之前保持一样的样式
1213
- style: { ...overallOrderConfig.fields[0].style }
1214
- }
1215
- ]
1216
- // 重新计算合并单元格的个数
1217
- overallOrderConfig.fields[0].colSpan =
1218
- colSpanLength - overallOrderConfig.fields[1].colSpan
1219
- } else {
1220
- // 关闭自定义单元格
1221
- overallOrderConfig.fields = [overallOrderConfig.fields[0]]
1222
- // 重新计算合并单元格的个数
1223
- overallOrderConfig.fields[0].colSpan = colSpanLength
1224
- }
1225
-
1226
- this.config = toJS(this.config)
1227
- }
1228
- }
1229
-
1230
- // 整单合计自定义单元格文本输入
1231
- @action.bound
1232
- setOverallOrderFields(value) {
1233
- if (this.selectedRegion) {
1234
- const arr = this.selectedRegion.split('.')
1235
- const table = this.config.contents[arr[2]]
1236
- const overallOrderConfig = table?.overallOrder
1237
-
1238
- if (overallOrderConfig.isCustomCells) {
1239
- const overallOrderConfigFields = table?.overallOrder.fields
1240
- overallOrderConfigFields[1].name = value
1241
- }
1242
- }
1243
- }
1244
-
1245
- // 整单合计样式设置
1246
- @action.bound
1247
- setOverallOrderStyle(value) {
1248
- if (this.selectedRegion) {
1249
- const flexStyle = {
1250
- left: 'flex-start',
1251
- center: 'center',
1252
- right: 'flex-end'
1253
- }
1254
- const arr = this.selectedRegion.split('.')
1255
- const overallOrderConfigFields = this.config.contents[arr[2]]
1256
- ?.overallOrder.fields
1257
- _.forEach(overallOrderConfigFields, item => {
1258
- const oldStyle = item.style || {}
1259
- set(item, {
1260
- style: {
1261
- ...oldStyle,
1262
- ...value,
1263
- // 整单合计里使用的flex布局,textAlign不生效
1264
- 'justify-content': flexStyle[value.textAlign]
1265
- }
1266
- })
1267
- })
1268
- }
1269
- }
1270
-
1271
- // 合计和每页合计设置交换位置
985
+ // 设置交换位置
1272
986
  @action.bound
1273
987
  setSubtotalCommutationPlace() {
1274
988
  if (this.selectedRegion) {