gm-printer 10.14.2-alpha.3 → 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.3",
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,61 +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
- }
558
- }
559
-
560
- @action
561
- setOverallOrderShow(name) {
562
- const arr = name.split('.')
563
- const table = this.config.contents[arr[2]]
564
- this.overallOrderShow = !this.overallOrderShow
565
- const colSpanLength = getColSpanLength(table)
566
- if (table.overallOrder) {
567
- set(table.overallOrder, {
568
- show: !table.overallOrder.show
569
- })
570
- table.overallOrder.fields[0].colSpan =
571
- colSpanLength - (table.overallOrder.fields?.[1]?.colSpan ?? 0)
572
- } else {
573
- // 兼容已经存在的配送单据,他们的配置存在后端的,没有overallOrder这个配置,给加上
574
- set(table, {
575
- overallOrder: {
576
- show: true,
577
- fields: [
578
- {
579
- name: '整单合计:',
580
- valueField: '出库金额',
581
- style: {
582
- fontWeight: 'bold'
583
- },
584
- colSpan: colSpanLength
585
- }
586
- ]
587
- }
588
- })
589
- }
590
- this.config = toJS(this.config)
591
519
  }
592
520
 
593
521
  @action
@@ -602,7 +530,7 @@ class EditorStore {
602
530
  @action
603
531
  changeTableDataKey(name, key) {
604
532
  const arr = name.split('.')
605
- const { dataKey, overallOrder, subtotal } = this.config.contents[arr[2]]
533
+ const { dataKey } = this.config.contents[arr[2]]
606
534
  const keyArr = dataKey.split('_')
607
535
  let newDataKey
608
536
  // 当前有这个key则去掉
@@ -626,10 +554,6 @@ class EditorStore {
626
554
  ])
627
555
 
628
556
  this.config.contents[arr[2]].dataKey = newDataKey.join('_')
629
- // 整单合计不显示
630
- if (overallOrder?.show) overallOrder.show = false
631
- // 每页合计不显示
632
- if (subtotal?.show) subtotal.show = false
633
557
  }
634
558
 
635
559
  @action
@@ -1013,11 +937,10 @@ class EditorStore {
1013
937
  }
1014
938
  }
1015
939
 
1016
- // 每页合计设置大写金额
940
+ // 设置大写金额
1017
941
  @action.bound
1018
942
  setSubtotalUpperCase() {
1019
943
  if (this.selectedRegion) {
1020
- this.overallOrderShow = !this.overallOrderShow
1021
944
  const arr = this.selectedRegion.split('.')
1022
945
  const subtotalConfig = this.config.contents[arr[2]].subtotal
1023
946
 
@@ -1033,11 +956,10 @@ class EditorStore {
1033
956
  }
1034
957
  }
1035
958
 
1036
- // 每页合计设置大写金额在前
959
+ // 设置大写金额在前
1037
960
  @action.bound
1038
961
  setSubtotalUpperCaseBefore() {
1039
962
  if (this.selectedRegion) {
1040
- this.overallOrderShow = !this.overallOrderShow
1041
963
  const arr = this.selectedRegion.split('.')
1042
964
  const subtotalConfig = this.config.contents[arr[2]].subtotal
1043
965
 
@@ -1046,11 +968,10 @@ class EditorStore {
1046
968
  }
1047
969
  }
1048
970
 
1049
- // 每页合计设置大小写金额分开
971
+ // 设置大小写金额分开
1050
972
  @action.bound
1051
973
  setSubtotalUpperLowerCaseSeparate() {
1052
974
  if (this.selectedRegion) {
1053
- this.overallOrderShow = !this.overallOrderShow
1054
975
  const arr = this.selectedRegion.split('.')
1055
976
  const subtotalConfig = this.config.contents[arr[2]].subtotal
1056
977
 
@@ -1061,210 +982,7 @@ class EditorStore {
1061
982
  }
1062
983
  }
1063
984
 
1064
- // 每页合计开启自定义单元格
1065
- @action.bound
1066
- setSubtotalCustomCells() {
1067
- if (this.selectedRegion) {
1068
- // 作用:触发组件的更新
1069
- this.overallOrderShow = !this.overallOrderShow
1070
- const arr = this.selectedRegion.split('.')
1071
- const table = this.config.contents[arr[2]]
1072
- const subtotalConfig = table?.subtotal
1073
- // 没有显示每页合计的时候不可以设置自定义单元格
1074
- if (!subtotalConfig?.show) return
1075
- // 多栏表格情况,计算colSpan
1076
- const colSpanLength = getColSpanLength(table)
1077
- const oldCustomCells = subtotalConfig?.isCustomCells
1078
-
1079
- set(subtotalConfig, {
1080
- isCustomCells: !oldCustomCells
1081
- })
1082
- // 兼容已经存在后端的模板,每页合计直接是显示的,导致每页合计配置没有fields,isCustomCells,手动添加上
1083
- if (oldCustomCells === undefined && !subtotalConfig.fields) {
1084
- set(subtotalConfig, {
1085
- fields: [
1086
- {
1087
- name: '每页合计:',
1088
- valueField: 'real_item_price',
1089
- colSpan: colSpanLength
1090
- }
1091
- ]
1092
- })
1093
- }
1094
- // 开启自定义单元格
1095
- if (subtotalConfig?.isCustomCells) {
1096
- // fields添加自定义单元格
1097
- subtotalConfig.fields = [
1098
- subtotalConfig.fields[0],
1099
- {
1100
- ...this.subtotalConfigFields
1101
- }
1102
- ]
1103
- // 重新计算合并单元格的个数
1104
- subtotalConfig.fields[0].colSpan =
1105
- colSpanLength - subtotalConfig.fields[1].colSpan
1106
- } else {
1107
- // 关闭自定义单元格,fields只有一个
1108
- subtotalConfig.fields = [subtotalConfig.fields[0]]
1109
- // 重新计算合并单元格的个数
1110
- subtotalConfig.fields[0].colSpan = colSpanLength
1111
- }
1112
- }
1113
- }
1114
-
1115
- // 每页合计自定义单元格文本输入
1116
- @action.bound
1117
- setSubtotalFields(value) {
1118
- if (this.selectedRegion) {
1119
- const arr = this.selectedRegion.split('.')
1120
- const table = this.config.contents[arr[2]]
1121
- const subtotalConfig = table?.subtotal
1122
-
1123
- if (subtotalConfig.isCustomCells) {
1124
- const subtotalConfig = table?.subtotal.fields
1125
- subtotalConfig[1].name = value
1126
- }
1127
- }
1128
- }
1129
-
1130
- // 整单合计设置大写金额
1131
- @action.bound
1132
- setOverallOrderUpperCase() {
1133
- if (this.selectedRegion) {
1134
- this.overallOrderShow = !this.overallOrderShow
1135
- const arr = this.selectedRegion.split('.')
1136
- const overallOrderConfig = this.config.contents[arr[2]]?.overallOrder
1137
-
1138
- const oldNeedUpperCase = overallOrderConfig?.needUpperCase
1139
- this.config.contents[arr[2]]?.overallOrder &&
1140
- set(overallOrderConfig, { needUpperCase: !oldNeedUpperCase })
1141
- // 没有大写金额时,将大写在前和大小写分开的多选框设置为false
1142
- if (
1143
- this.config.contents[arr[2]]?.overallOrder &&
1144
- overallOrderConfig.needUpperCase === false
1145
- ) {
1146
- overallOrderConfig.isUpperCaseBefore &&
1147
- set(overallOrderConfig, { isUpperCaseBefore: false })
1148
- overallOrderConfig.isUpperLowerCaseSeparate &&
1149
- set(overallOrderConfig, { isUpperLowerCaseSeparate: false })
1150
- }
1151
- }
1152
- }
1153
-
1154
- // 整单合计设置大写金额在前
1155
- @action.bound
1156
- setOverallOrderUpperCaseBefore() {
1157
- if (this.selectedRegion) {
1158
- this.overallOrderShow = !this.overallOrderShow
1159
- const arr = this.selectedRegion.split('.')
1160
- const overallOrderConfig = this.config.contents[arr[2]]?.overallOrder
1161
-
1162
- const oldUpperCaseBefore = overallOrderConfig?.isUpperCaseBefore
1163
- this.config.contents[arr[2]]?.overallOrder &&
1164
- set(overallOrderConfig, { isUpperCaseBefore: !oldUpperCaseBefore })
1165
- }
1166
- }
1167
-
1168
- // 整单合计设置大小写金额分开
1169
- @action.bound
1170
- setOverallOrderUpperLowerCaseSeparate() {
1171
- if (this.selectedRegion) {
1172
- this.overallOrderShow = !this.overallOrderShow
1173
- const arr = this.selectedRegion.split('.')
1174
- const overallOrderConfig = this.config.contents[arr[2]]?.overallOrder
1175
-
1176
- const oldUpperLowerCaseSeparate =
1177
- overallOrderConfig.isUpperLowerCaseSeparate
1178
- set(overallOrderConfig, {
1179
- isUpperLowerCaseSeparate: !oldUpperLowerCaseSeparate
1180
- })
1181
- }
1182
- }
1183
-
1184
- // 整单合计开启自定义单元格
1185
- @action.bound
1186
- setOverallOrderCustomCells() {
1187
- if (this.selectedRegion) {
1188
- // 作用:触发tableoverallordertr组件的更新
1189
- this.overallOrderShow = !this.overallOrderShow
1190
- const arr = this.selectedRegion.split('.')
1191
- const table = this.config.contents[arr[2]]
1192
- const overallOrderConfig = table?.overallOrder
1193
- if (!overallOrderConfig || !overallOrderConfig?.show) return
1194
- // 多栏表格情况
1195
- const colSpanLength = getColSpanLength(table)
1196
- const oldCustomCells = overallOrderConfig?.isCustomCells
1197
-
1198
- set(overallOrderConfig, {
1199
- isCustomCells: !oldCustomCells
1200
- })
1201
-
1202
- if (overallOrderConfig?.isCustomCells) {
1203
- // fields添加自定义单元格
1204
- overallOrderConfig.fields = [
1205
- overallOrderConfig.fields[0],
1206
- {
1207
- ...this.overallOrderConfigFields,
1208
- // 和之前保持一样的样式
1209
- style: { ...overallOrderConfig.fields[0].style }
1210
- }
1211
- ]
1212
- // 重新计算合并单元格的个数
1213
- overallOrderConfig.fields[0].colSpan =
1214
- colSpanLength - overallOrderConfig.fields[1].colSpan
1215
- } else {
1216
- // 关闭自定义单元格
1217
- overallOrderConfig.fields = [overallOrderConfig.fields[0]]
1218
- // 重新计算合并单元格的个数
1219
- overallOrderConfig.fields[0].colSpan = colSpanLength
1220
- }
1221
-
1222
- this.config = toJS(this.config)
1223
- }
1224
- }
1225
-
1226
- // 整单合计自定义单元格文本输入
1227
- @action.bound
1228
- setOverallOrderFields(value) {
1229
- if (this.selectedRegion) {
1230
- const arr = this.selectedRegion.split('.')
1231
- const table = this.config.contents[arr[2]]
1232
- const overallOrderConfig = table?.overallOrder
1233
-
1234
- if (overallOrderConfig.isCustomCells) {
1235
- const overallOrderConfigFields = table?.overallOrder.fields
1236
- overallOrderConfigFields[1].name = value
1237
- }
1238
- }
1239
- }
1240
-
1241
- // 整单合计样式设置
1242
- @action.bound
1243
- setOverallOrderStyle(value) {
1244
- if (this.selectedRegion) {
1245
- const flexStyle = {
1246
- left: 'flex-start',
1247
- center: 'center',
1248
- right: 'flex-end'
1249
- }
1250
- const arr = this.selectedRegion.split('.')
1251
- const overallOrderConfigFields = this.config.contents[arr[2]]
1252
- ?.overallOrder.fields
1253
- _.forEach(overallOrderConfigFields, item => {
1254
- const oldStyle = item.style || {}
1255
- set(item, {
1256
- style: {
1257
- ...oldStyle,
1258
- ...value,
1259
- // 整单合计里使用的flex布局,textAlign不生效
1260
- 'justify-content': flexStyle[value.textAlign]
1261
- }
1262
- })
1263
- })
1264
- }
1265
- }
1266
-
1267
- // 合计和每页合计设置交换位置
985
+ // 设置交换位置
1268
986
  @action.bound
1269
987
  setSubtotalCommutationPlace() {
1270
988
  if (this.selectedRegion) {