gm-printer 10.31.0 → 10.31.1-beta.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 +1 -1
- package/src/common/component.js +37 -1
- package/src/common/editor_special_other_field.js +45 -0
- package/src/common/editor_store.js +23 -0
- package/src/editor/editor.js +2 -0
- package/src/printer/table_special_tr.js +16 -5
- package/build/demo.js +0 -54
- package/build/index.html +0 -1
package/package.json
CHANGED
package/src/common/component.js
CHANGED
|
@@ -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,45 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import PropTypes from 'prop-types'
|
|
3
|
+
import { Gap, Checkbox } from './component'
|
|
4
|
+
import { observer, inject } from 'mobx-react'
|
|
5
|
+
|
|
6
|
+
@inject('editStore')
|
|
7
|
+
@observer
|
|
8
|
+
class SpecialOtherField extends React.Component {
|
|
9
|
+
render() {
|
|
10
|
+
const { addFields, mockData, editStore } = this.props
|
|
11
|
+
const specialOtherFields = addFields.specialOtherFields
|
|
12
|
+
const tableData = mockData?._table
|
|
13
|
+
const checked = editStore?.config?.specialOtherConfig || []
|
|
14
|
+
const specialConfig = editStore?.config?.specialConfig
|
|
15
|
+
return (
|
|
16
|
+
<div>
|
|
17
|
+
{specialOtherFields &&
|
|
18
|
+
specialOtherFields.map(fields => (
|
|
19
|
+
<Checkbox
|
|
20
|
+
id={fields.id}
|
|
21
|
+
value={fields.value}
|
|
22
|
+
key={fields.id}
|
|
23
|
+
checked={checked.includes(fields.id)}
|
|
24
|
+
radioChecked={() =>
|
|
25
|
+
editStore.multipleRadioChecked(fields, tableData)
|
|
26
|
+
}
|
|
27
|
+
disabled={specialConfig === 'noSpecail'}
|
|
28
|
+
/>
|
|
29
|
+
))}
|
|
30
|
+
|
|
31
|
+
<Gap />
|
|
32
|
+
</div>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
SpecialOtherField.propTypes = {
|
|
38
|
+
fields: PropTypes.object,
|
|
39
|
+
handleAddField: PropTypes.func,
|
|
40
|
+
addFields: PropTypes.object.isRequired,
|
|
41
|
+
editStore: PropTypes.object,
|
|
42
|
+
mockData: PropTypes.object.isRequired
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export default SpecialOtherField
|
|
@@ -968,9 +968,32 @@ class EditorStore {
|
|
|
968
968
|
|
|
969
969
|
@action.bound
|
|
970
970
|
radioChecked(fields) {
|
|
971
|
+
if (fields.id === 'noSpecail') {
|
|
972
|
+
this.config.specialOtherConfig = []
|
|
973
|
+
}
|
|
971
974
|
this.config.specialConfig = fields.id
|
|
972
975
|
}
|
|
973
976
|
|
|
977
|
+
@action.bound
|
|
978
|
+
multipleRadioChecked(fields) {
|
|
979
|
+
if (this.config.specialConfig === 'noSpecail') {
|
|
980
|
+
this.config.specialOtherConfig = []
|
|
981
|
+
return
|
|
982
|
+
}
|
|
983
|
+
const arr = this.config?.specialOtherConfig
|
|
984
|
+
? [...this.config.specialOtherConfig]
|
|
985
|
+
: []
|
|
986
|
+
if (arr.includes(fields.id)) {
|
|
987
|
+
// 如果已选中,则取消选中
|
|
988
|
+
const index = arr.indexOf(fields.id)
|
|
989
|
+
arr.splice(index, 1)
|
|
990
|
+
} else {
|
|
991
|
+
// 如果未选中,则添加
|
|
992
|
+
arr.push(fields.id)
|
|
993
|
+
}
|
|
994
|
+
this.config.specialOtherConfig = arr
|
|
995
|
+
}
|
|
996
|
+
|
|
974
997
|
@action
|
|
975
998
|
removeField() {
|
|
976
999
|
if (!this.selected) {
|
package/src/editor/editor.js
CHANGED
|
@@ -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
|
|
@@ -32,6 +32,13 @@ const SpecialTr = ({ data, config }) => {
|
|
|
32
32
|
compiled = () => template_text
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
const defaultFields = [
|
|
36
|
+
{
|
|
37
|
+
valueField: '下单金额'
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
const newFields = fields || defaultFields
|
|
41
|
+
|
|
35
42
|
switch (type) {
|
|
36
43
|
case 'flex':
|
|
37
44
|
// eslint-disable-next-line no-case-declarations
|
|
@@ -95,9 +102,13 @@ const SpecialTr = ({ data, config }) => {
|
|
|
95
102
|
throw Error('_special缺少text,请检查data_to_key处理table数据代码!')
|
|
96
103
|
|
|
97
104
|
if (isUpperLowerCaseSeparate) {
|
|
105
|
+
const UpperCaseBefore =
|
|
106
|
+
data[newFields[0].valueField]
|
|
107
|
+
?.upperLowerCaseSeparateAndUpperCaseBefore
|
|
108
|
+
|
|
98
109
|
const htmlStr = isUpperCaseBefore
|
|
99
|
-
?
|
|
100
|
-
: data[
|
|
110
|
+
? UpperCaseBefore
|
|
111
|
+
: data[newFields[0].valueField]?.upperLowerCaseSeparate
|
|
101
112
|
return (
|
|
102
113
|
<tr>
|
|
103
114
|
<td
|
|
@@ -119,12 +130,12 @@ const SpecialTr = ({ data, config }) => {
|
|
|
119
130
|
// eslint-disable-next-line no-case-declarations
|
|
120
131
|
const getHtml = () => {
|
|
121
132
|
if (isUpperCaseBefore) {
|
|
122
|
-
return data[
|
|
133
|
+
return data[newFields[0].valueField]?.upperCaseBefore
|
|
123
134
|
}
|
|
124
135
|
if (needUpperCase) {
|
|
125
|
-
return data[
|
|
136
|
+
return data[newFields[0].valueField]?.upperCaseText
|
|
126
137
|
}
|
|
127
|
-
return data[
|
|
138
|
+
return data[newFields[0]?.valueField]?.text || data.text
|
|
128
139
|
}
|
|
129
140
|
|
|
130
141
|
return (
|