gm-printer 10.30.1 → 10.30.2-beta.6

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.30.1",
3
+ "version": "10.30.2-beta.6",
4
4
  "description": "diy printer",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -78,6 +78,11 @@ class EditorField extends React.Component {
78
78
  editStore.setCategoryStyle(value)
79
79
  }
80
80
 
81
+ handleClassificationAndLabelTally = style => {
82
+ const { editStore } = this.props
83
+ editStore.setClassificationAndLabelTally('style', style)
84
+ }
85
+
81
86
  handleSubtotalStyleChange = value => {
82
87
  const { editStore } = this.props
83
88
  editStore.setSubtotalStyle(value)
@@ -198,7 +203,12 @@ class EditorField extends React.Component {
198
203
  }
199
204
 
200
205
  renderTable() {
201
- const { tableDataKeyList, editStore, isSomeSubtotalTr } = this.props
206
+ const {
207
+ tableDataKeyList,
208
+ editStore,
209
+ isSomeSubtotalTr,
210
+ mergeClassificationAndLabel
211
+ } = this.props
202
212
  const { head, headStyle, text, style } = editStore.computedSelectedInfo
203
213
  const { config } = editStore
204
214
  const isLongPrint = config?.page?.type === LONG_PRINT
@@ -294,6 +304,22 @@ class EditorField extends React.Component {
294
304
  const diyOverallOrderValueField =
295
305
  editStore.computedTableSpecialConfig?.diyOverallOrder?.fields?.[0]
296
306
  .valueField
307
+
308
+ // 分类/标签小计 是否需要大写
309
+ const classificationAndLabelTallyNeedUpperCase =
310
+ (editStore.computedTableSpecialConfig?.specialConfig &&
311
+ get(specialConfig, 'needUpperCase')) ||
312
+ false
313
+ const classificationAndLabelTallyUpperCaseBefore =
314
+ (editStore.computedTableSpecialConfig?.specialConfig &&
315
+ get(specialConfig, 'isUpperCaseBefore')) ||
316
+ false
317
+ // 自定义整单合计大写和小写的金额是否分开
318
+ const classificationAndLabelTallyLowerCaseSeparate =
319
+ (editStore.computedTableSpecialConfig?.specialConfig &&
320
+ get(specialConfig, 'isUpperLowerCaseSeparate')) ||
321
+ false
322
+
297
323
  return (
298
324
  <div>
299
325
  <Title title={i18next.t('编辑字段')} />
@@ -446,38 +472,41 @@ class EditorField extends React.Component {
446
472
  />
447
473
  <Gap />
448
474
 
449
- <Flex>
450
- <Flex>{i18next.t('分类设置')}:</Flex>
451
- <Fonter
452
- style={categoryStyle}
453
- onChange={this.handleCategoryStyleChange}
454
- />
455
- <Separator />
456
- <TextAlign
457
- style={categoryStyle}
458
- onChange={this.handleCategoryStyleChange}
459
- />
460
- </Flex>
461
-
462
- <Flex>
463
- <Flex>{i18next.t('小计设置')}:</Flex>
464
- <Fonter
465
- style={specialStyle}
466
- onChange={this.handleSpecialStyleChange}
467
- />
468
- <Separator />
469
- <TextAlign
470
- style={specialStyle}
471
- onChange={this.handleSpecialStyleChange}
472
- />
473
- </Flex>
475
+ {!mergeClassificationAndLabel && (
476
+ <>
477
+ <Flex>
478
+ <Flex>{i18next.t('分类设置')}:</Flex>
479
+ <Fonter
480
+ style={categoryStyle}
481
+ onChange={this.handleCategoryStyleChange}
482
+ />
483
+ <Separator />
484
+ <TextAlign
485
+ style={categoryStyle}
486
+ onChange={this.handleCategoryStyleChange}
487
+ />
488
+ </Flex>
474
489
 
475
- <EditorSubtotalCheck
476
- subtotalCheckDisabled
477
- subtotalChecked={specialTrNeedUpperCase}
478
- subtotalCheckOnChange={editStore.setSpecialUpperCase}
479
- subtotalCheckText='显示大写金额'
480
- />
490
+ <Flex>
491
+ <Flex>{i18next.t('小计设置')}:</Flex>
492
+ <Fonter
493
+ style={specialStyle}
494
+ onChange={this.handleSpecialStyleChange}
495
+ />
496
+ <Separator />
497
+ <TextAlign
498
+ style={specialStyle}
499
+ onChange={this.handleSpecialStyleChange}
500
+ />
501
+ </Flex>
502
+ <EditorSubtotalCheck
503
+ subtotalCheckDisabled
504
+ subtotalChecked={specialTrNeedUpperCase}
505
+ subtotalCheckOnChange={editStore.setSpecialUpperCase}
506
+ subtotalCheckText='显示大写金额'
507
+ />
508
+ </>
509
+ )}
481
510
 
482
511
  <Flex>
483
512
  <Flex>{i18next.t('每页合计设置')}:</Flex>
@@ -685,7 +714,10 @@ class EditorField extends React.Component {
685
714
  : ''
686
715
  }
687
716
  onChange={editStore.setDiyOverallOrderFields}
688
- style={{ width: '100px', margin: '5px 0 5px 0px' }}
717
+ style={{
718
+ width: '100px',
719
+ margin: '5px 0 5px 0px'
720
+ }}
689
721
  />
690
722
  </Flex>
691
723
  <Textarea
@@ -699,6 +731,79 @@ class EditorField extends React.Component {
699
731
  </div>
700
732
  </Flex>
701
733
  )}
734
+ {mergeClassificationAndLabel && (
735
+ <>
736
+ <Flex>{i18next.t('分类/标签小计')}:</Flex>
737
+ <Flex style={{ marginLeft: 57 }}>
738
+ <div>
739
+ <Fonter
740
+ style={specialStyle}
741
+ onChange={this.handleClassificationAndLabelTally}
742
+ />
743
+ <Separator />
744
+ <TextAlign
745
+ style={specialStyle}
746
+ onChange={this.handleClassificationAndLabelTally}
747
+ />
748
+ <Flex style={{ marginLeft: 0 }}>
749
+ {subtotalRadioList.map((fields, i) => {
750
+ return (
751
+ <Radio
752
+ style={{ marginLeft: 5 }}
753
+ id={`${fields.id}${i}`}
754
+ value={fields.value}
755
+ key={fields.id}
756
+ inputName='classificationAndLabelTallyRadio'
757
+ checked={
758
+ (specialConfig?.fields?.[0]?.valueField ??
759
+ '出库金额') === fields.id
760
+ }
761
+ radioChecked={() =>
762
+ editStore.setClassificationAndLabelTallyField(fields)
763
+ }
764
+ />
765
+ )
766
+ })}
767
+ </Flex>
768
+ <EditorSubtotalCheck
769
+ subtotalCheckDisabled
770
+ subtotalChecked={classificationAndLabelTallyNeedUpperCase}
771
+ subtotalCheckOnChange={() =>
772
+ editStore.setClassificationAndLabelTally('needUpperCase')
773
+ }
774
+ subtotalCheckText='显示大写金额'
775
+ marginLeft
776
+ />
777
+ <EditorSubtotalCheck
778
+ subtotalCheckDisabled={
779
+ classificationAndLabelTallyNeedUpperCase
780
+ }
781
+ subtotalChecked={classificationAndLabelTallyUpperCaseBefore}
782
+ subtotalCheckOnChange={() =>
783
+ editStore.setClassificationAndLabelTally(
784
+ 'isUpperCaseBefore'
785
+ )
786
+ }
787
+ subtotalCheckText='大写金额在前'
788
+ marginLeft
789
+ />
790
+ <EditorSubtotalCheck
791
+ subtotalCheckDisabled={
792
+ classificationAndLabelTallyNeedUpperCase
793
+ }
794
+ subtotalChecked={classificationAndLabelTallyLowerCaseSeparate}
795
+ subtotalCheckOnChange={() =>
796
+ editStore.setClassificationAndLabelTally(
797
+ 'isUpperLowerCaseSeparate'
798
+ )
799
+ }
800
+ subtotalCheckText='大、小写金额分左右两边展示'
801
+ marginLeft
802
+ />
803
+ </div>
804
+ </Flex>
805
+ </>
806
+ )}
702
807
  </div>
703
808
  )
704
809
  }
@@ -720,7 +825,8 @@ EditorField.propTypes = {
720
825
  editStore: PropTypes.object,
721
826
  tableDataKeyList: PropTypes.array,
722
827
  showNewDate: PropTypes.bool,
723
- isSomeSubtotalTr: PropTypes.bool
828
+ isSomeSubtotalTr: PropTypes.bool,
829
+ mergeClassificationAndLabel: PropTypes.bool
724
830
  }
725
831
  EditorField.defaultProps = {
726
832
  showNewDate: false
@@ -1271,6 +1271,69 @@ class EditorStore {
1271
1271
  }
1272
1272
  }
1273
1273
 
1274
+ // 分类/标签 小计
1275
+ @action.bound setClassificationAndLabelTally(key, value = null) {
1276
+ if (this.selectedRegion) {
1277
+ const arr = this.selectedRegion.split('.')
1278
+ const tableConfig = this.config.contents[arr[2]]
1279
+
1280
+ const initValue = {
1281
+ style: {},
1282
+ needUpperCase: false,
1283
+ isUpperCaseBefore: false,
1284
+ isUpperLowerCaseSeparate: false
1285
+ }
1286
+
1287
+ const oldValue = tableConfig.specialConfig
1288
+ ? tableConfig.specialConfig[key] || initValue[key]
1289
+ : initValue[key]
1290
+
1291
+ let newValue = null
1292
+ if (typeof oldValue === 'boolean' && !value) {
1293
+ newValue = !oldValue
1294
+ } else if (typeof value === 'object' && value !== null) {
1295
+ newValue = {
1296
+ ...oldValue,
1297
+ ...value
1298
+ }
1299
+ }
1300
+
1301
+ set(tableConfig, {
1302
+ specialConfig: {
1303
+ ...tableConfig.specialConfig,
1304
+ [key]: newValue
1305
+ }
1306
+ })
1307
+
1308
+ // 没有大写金额时,将大写在前和大小写分开的多选框设置为false
1309
+ if (tableConfig?.specialConfig?.needUpperCase === false) {
1310
+ tableConfig.specialConfig.isUpperCaseBefore &&
1311
+ set(tableConfig.specialConfig, { isUpperCaseBefore: false })
1312
+ tableConfig.specialConfig.isUpperLowerCaseSeparate &&
1313
+ set(tableConfig.specialConfig, { isUpperLowerCaseSeparate: false })
1314
+ }
1315
+ }
1316
+ }
1317
+
1318
+ // 分类/标签 小计设置金额字段
1319
+ @action.bound setClassificationAndLabelTallyField(fields) {
1320
+ if (this.selectedRegion) {
1321
+ const arr = this.selectedRegion.split('.')
1322
+ const tableConfig = this.config.contents[arr[2]]
1323
+
1324
+ set(tableConfig, {
1325
+ specialConfig: {
1326
+ ...tableConfig.specialConfig,
1327
+ fields: [
1328
+ {
1329
+ valueField: fields.id
1330
+ }
1331
+ ]
1332
+ }
1333
+ })
1334
+ }
1335
+ }
1336
+
1274
1337
  @action.bound
1275
1338
  setSpecialUpperCase() {
1276
1339
  if (this.selectedRegion) {
@@ -40,7 +40,14 @@ export const noSubtotalBtnTableDataKeySet = new Set(
40
40
  @observer
41
41
  class Editor extends React.Component {
42
42
  render() {
43
- const { onSave, showEditor, addFields, showNewDate, mockData } = this.props
43
+ const {
44
+ onSave,
45
+ showEditor,
46
+ addFields,
47
+ showNewDate,
48
+ mockData,
49
+ mergeClassificationAndLabel
50
+ } = this.props
44
51
 
45
52
  return (
46
53
  <div className='gm-printer-edit'>
@@ -83,6 +90,7 @@ class Editor extends React.Component {
83
90
  <EditorField
84
91
  tableDataKeyList={tableDataKeyList}
85
92
  showNewDate={showNewDate}
93
+ mergeClassificationAndLabel={mergeClassificationAndLabel}
86
94
  />
87
95
  <Gap height='5px' />
88
96
  <EditorAddField addFields={addFields} />
@@ -109,7 +117,8 @@ Editor.propTypes = {
109
117
  showEditor: PropTypes.bool,
110
118
  mockData: PropTypes.object.isRequired,
111
119
  addFields: PropTypes.object.isRequired,
112
- showNewDate: PropTypes.bool
120
+ showNewDate: PropTypes.bool,
121
+ mergeClassificationAndLabel: PropTypes.bool
113
122
  }
114
123
 
115
124
  Editor.defaultProps = {
@@ -3,6 +3,7 @@ import _ from 'lodash'
3
3
  import PropTypes from 'prop-types'
4
4
  import { observer } from 'mobx-react'
5
5
  import { has, get } from 'mobx'
6
+ import { Flex } from '../components'
6
7
 
7
8
  /**
8
9
  * 分类小计组件
@@ -13,7 +14,15 @@ import { has, get } from 'mobx'
13
14
  const SpecialTr = ({ data, config }) => {
14
15
  const specialConfig =
15
16
  has(config, 'specialConfig') && get(config, 'specialConfig')
16
- const { style, template_text, separator, needUpperCase } = specialConfig
17
+ const {
18
+ style,
19
+ template_text,
20
+ separator,
21
+ needUpperCase,
22
+ isUpperCaseBefore,
23
+ isUpperLowerCaseSeparate,
24
+ fields
25
+ } = specialConfig
17
26
  const { list, type, fixedSize } = data
18
27
 
19
28
  let compiled
@@ -85,16 +94,44 @@ const SpecialTr = ({ data, config }) => {
85
94
  if (!data.text)
86
95
  throw Error('_special缺少text,请检查data_to_key处理table数据代码!')
87
96
 
97
+ if (isUpperLowerCaseSeparate) {
98
+ return (
99
+ <tr>
100
+ <td
101
+ colSpan={99}
102
+ style={Object.assign({ fontWeight: 'bold' }, style)}
103
+ >
104
+ <Flex
105
+ className='gm-flex-justify-between'
106
+ dangerouslySetInnerHTML={{
107
+ __html:
108
+ data[fields[0].valueField]?.upperLowerCaseSeparate ||
109
+ data.text
110
+ }}
111
+ />
112
+ </td>
113
+ </tr>
114
+ )
115
+ }
116
+
117
+ // eslint-disable-next-line no-case-declarations
118
+ const getHtml = () => {
119
+ if (isUpperCaseBefore) {
120
+ return data[fields[0].valueField]?.upperCaseBefore
121
+ }
122
+ if (needUpperCase) {
123
+ return data[fields[0].valueField]?.upperCaseText
124
+ }
125
+ return data[fields?.[0]?.valueField]?.text || data.text
126
+ }
127
+
88
128
  return (
89
129
  <tr>
90
130
  <td
91
131
  colSpan={99}
92
132
  style={Object.assign({ fontWeight: 'bold' }, style)}
93
133
  dangerouslySetInnerHTML={{
94
- __html:
95
- needUpperCase && data.upperCaseText
96
- ? data.upperCaseText
97
- : data.text
134
+ __html: getHtml() || data.text
98
135
  }}
99
136
  />
100
137
  </tr>