gm-printer 10.31.1 → 10.32.1

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.31.1",
3
+ "version": "10.32.1",
4
4
  "description": "diy printer",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -676,6 +676,41 @@ TipInfo.propTypes = {
676
676
  color: PropTypes.string
677
677
  }
678
678
 
679
+ const Checkbox = ({
680
+ id,
681
+ value,
682
+ radioChecked,
683
+ checked,
684
+ style,
685
+ inputName,
686
+ disabled
687
+ }) => (
688
+ <div style={style}>
689
+ <input
690
+ type='checkbox'
691
+ value={value}
692
+ id={id}
693
+ name={inputName ?? 'radio'}
694
+ onChange={radioChecked}
695
+ checked={checked}
696
+ style={{ margin: '5px 5px 0 0' }}
697
+ disabled={disabled}
698
+ />
699
+ <label htmlFor={id}>{value}</label>
700
+ <Gap />
701
+ </div>
702
+ )
703
+
704
+ Checkbox.propTypes = {
705
+ id: PropTypes.string,
706
+ value: PropTypes.string,
707
+ style: PropTypes.string,
708
+ inputName: PropTypes.string,
709
+ radioChecked: PropTypes.func,
710
+ checked: PropTypes.bool,
711
+ disabled: PropTypes.bool
712
+ }
713
+
679
714
  export {
680
715
  Text,
681
716
  Textarea,
@@ -696,5 +731,6 @@ export {
696
731
  Gap,
697
732
  RadioGap,
698
733
  FieldBtn,
699
- TipInfo
734
+ TipInfo,
735
+ Checkbox
700
736
  }
@@ -0,0 +1,47 @@
1
+ import React from 'react'
2
+ import PropTypes from 'prop-types'
3
+ import { Gap, RadioGap, Title, Checkbox } from './component'
4
+ import { observer, inject } from 'mobx-react'
5
+ import i18next from '../../locales'
6
+
7
+ @inject('editStore')
8
+ @observer
9
+ class SpecialOtherField extends React.Component {
10
+ render() {
11
+ const { addFields, mockData, editStore } = this.props
12
+ const specialOtherFields = addFields.specialOtherFields
13
+ const tableData = mockData?._table
14
+ const checked = editStore?.config?.specialOtherConfig || []
15
+ const specialConfig = editStore?.config?.specialConfig
16
+ return (
17
+ <div>
18
+ <Title title={i18next.t('配送单数据过滤')} />
19
+ <RadioGap />
20
+ {specialOtherFields &&
21
+ specialOtherFields.map(fields => (
22
+ <Checkbox
23
+ id={fields.id}
24
+ value={fields.value}
25
+ key={fields.id}
26
+ checked={checked.includes(fields.id)}
27
+ radioChecked={() =>
28
+ editStore.multipleRadioChecked(fields, tableData)
29
+ }
30
+ />
31
+ ))}
32
+
33
+ <Gap />
34
+ </div>
35
+ )
36
+ }
37
+ }
38
+
39
+ SpecialOtherField.propTypes = {
40
+ fields: PropTypes.object,
41
+ handleAddField: PropTypes.func,
42
+ addFields: PropTypes.object.isRequired,
43
+ editStore: PropTypes.object,
44
+ mockData: PropTypes.object.isRequired
45
+ }
46
+
47
+ export default SpecialOtherField
@@ -971,6 +971,27 @@ class EditorStore {
971
971
  this.config.specialConfig = fields.id
972
972
  }
973
973
 
974
+ @action.bound
975
+ multipleRadioChecked(fields) {
976
+ const arr = this.config?.specialOtherConfig
977
+ ? [...this.config.specialOtherConfig]
978
+ : []
979
+ if (arr.includes(fields.id)) {
980
+ // 如果已选中,则取消选中
981
+ const index = arr.indexOf(fields.id)
982
+ arr.splice(index, 1)
983
+ } else {
984
+ // 如果未选中,则添加
985
+ arr.push(fields.id)
986
+ }
987
+ // this.config.specialOtherConfig = arr
988
+
989
+ this.config = {
990
+ ...this.config,
991
+ specialOtherConfig: arr
992
+ }
993
+ }
994
+
974
995
  @action
975
996
  removeField() {
976
997
  if (!this.selected) {
@@ -8,6 +8,7 @@ import { observer, inject } from 'mobx-react'
8
8
  import EditorTitle from '../common/editor_title'
9
9
  import EditorSelect from '../common/editor_select'
10
10
  import SpecialField from '../common/editor_special_field'
11
+ import SpecialOtherField from '../common/editor_special_other_field'
11
12
  import EditorField from '../common/editor_edit_field'
12
13
  import EditorAddField from '../common/editor_add_field'
13
14
  import EditorPageSummary from '../common/editor_page_summary'
@@ -85,6 +86,7 @@ class Editor extends React.Component {
85
86
  <EditorSelect />
86
87
  <Gap height='5px' />
87
88
  <SpecialField addFields={addFields} mockData={mockData} />
89
+ <SpecialOtherField addFields={addFields} mockData={mockData} />
88
90
  <EditorCutomizedConfig />
89
91
  <Gap height='5px' />
90
92
  <EditorField