form-group-repeater.wxml
5.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<view class="group-repeater">
<view class="group-repeater__section">
<view class="group-repeater__header">
<view class="group-repeater__title {{ disabled ? 'is-disabled' : '' }}">{{ group.label }}</view>
<view
wx:if="{{ canAdd }}"
class="group-repeater__add-btn"
bindtap="onAdd"
>
<view class="group-repeater__add-icon"></view>
<text class="group-repeater__add-text">新增</text>
</view>
</view>
<view wx:if="{{ rowTotal > 0 }}" class="group-repeater__nav">
<view
class="group-repeater__nav-btn {{ rowTotal <= 1 || activeIndex <= 0 ? 'is-disabled' : '' }}"
data-direction="-1"
bindtap="onNav"
>
<image class="group-repeater__nav-icon" src="{{ navIconLeft }}" mode="aspectFit" />
</view>
<view class="group-repeater__nav-text">{{ rowTotal ? activeIndex + 1 : 0 }}/{{ rowTotal }}</view>
<view
class="group-repeater__nav-btn {{ !rowTotal || activeIndex + 1 >= rowTotal ? 'is-disabled' : '' }}"
data-direction="1"
bindtap="onNav"
>
<image class="group-repeater__nav-icon" src="{{ navIconRight }}" mode="aspectFit" />
</view>
</view>
<view wx:if="{{ rowTotal > 0 }}" class="group-repeater__card">
<view class="group-repeater__card-hd">
<text class="group-repeater__row-label">第{{ rowTotal ? activeIndex + 1 : 0 }}行</text>
<view wx:if="{{ !disabled }}" class="group-repeater__delete" bindtap="onRemove">
<image
class="group-repeater__delete-icon"
src="{{ IMG_URL }}images/delete.png"
mode="aspectFit"
/>
</view>
</view>
<view class="group-repeater__fields">
<block
wx:for="{{ visibleRowFields }}"
wx:key="_wxRowKey"
wx:for-item="child"
>
<form-field-radio
wx:if="{{ child.type === 'radio' }}"
id="{{ child._wxRowKey }}"
field="{{ child }}"
value="{{ child.value }}"
disabled="{{ disabled || child.disabled }}"
error="{{ errors[group.key + '__' + activeIndex + '__' + child.key] || '' }}"
group-key="{{ group.key }}"
row-index="{{ activeIndex }}"
bind:change="onFieldChange"
/>
<form-field-select
wx:elif="{{ child.type === 'select' }}"
id="{{ child._wxRowKey }}"
field="{{ child }}"
value="{{ child.value }}"
disabled="{{ disabled || child.disabled }}"
error="{{ errors[group.key + '__' + activeIndex + '__' + child.key] || '' }}"
request-context="{{ requestContext }}"
row-values="{{ rowValues }}"
group-brand-ids="{{ group.brandId }}"
group-key="{{ group.key }}"
row-index="{{ activeIndex }}"
bind:change="onFieldChange"
/>
<form-field-input
wx:elif="{{ child.type === 'input' }}"
id="{{ child._wxRowKey }}"
field="{{ child }}"
value="{{ child.value }}"
disabled="{{ disabled || child.disabled }}"
error="{{ errors[group.key + '__' + activeIndex + '__' + child.key] || '' }}"
group-key="{{ group.key }}"
row-index="{{ activeIndex }}"
bind:change="onFieldChange"
bind:blur="onFieldBlur"
/>
<form-field-phone
wx:elif="{{ child.type === 'phoneInput' }}"
id="{{ child._wxRowKey }}"
field="{{ child }}"
value="{{ child.value }}"
disabled="{{ disabled || child.disabled }}"
error="{{ errors[group.key + '__' + activeIndex + '__' + child.key] || '' }}"
group-key="{{ group.key }}"
row-index="{{ activeIndex }}"
bind:change="onFieldChange"
bind:blur="onFieldBlur"
/>
<form-field-datetime
wx:elif="{{ child.type === 'datetime' || child.type === 'date' }}"
id="{{ child._wxRowKey }}"
field="{{ child }}"
value="{{ child.value }}"
disabled="{{ disabled || child.disabled }}"
error="{{ errors[group.key + '__' + activeIndex + '__' + child.key] || '' }}"
group-key="{{ group.key }}"
row-index="{{ activeIndex }}"
bind:change="onFieldChange"
/>
<form-field-carBrand
wx:elif="{{ child.type === 'carBrandSelect' }}"
id="{{ child._wxRowKey }}"
field="{{ child }}"
value="{{ child.value }}"
disabled="{{ disabled || child.disabled }}"
error="{{ errors[group.key + '__' + activeIndex + '__' + child.key] || '' }}"
group-key="{{ group.key }}"
row-index="{{ activeIndex }}"
/>
<form-field-multipleSelect
wx:elif="{{ child.type === 'multipleSelect' }}"
id="{{ child._wxRowKey }}"
field="{{ child }}"
value="{{ child.value }}"
disabled="{{ disabled || child.disabled }}"
error="{{ errors[group.key + '__' + activeIndex + '__' + child.key] || '' }}"
request-context="{{ requestContext }}"
group-key="{{ group.key }}"
row-index="{{ activeIndex }}"
bind:change="onFieldChange"
/>
<form-field-number
wx:elif="{{ child.type === 'numberInput' }}"
id="{{ child._wxRowKey }}"
field="{{ child }}"
value="{{ child.value }}"
disabled="{{ disabled || child.disabled }}"
error="{{ errors[group.key + '__' + activeIndex + '__' + child.key] || '' }}"
group-key="{{ group.key }}"
row-index="{{ activeIndex }}"
bind:change="onFieldChange"
bind:blur="onFieldBlur"
/>
<form-field-textarea
wx:elif="{{ child.type === 'textarea' }}"
id="{{ child._wxRowKey }}"
field="{{ child }}"
value="{{ child.value == null ? '' : child.value }}"
disabled="{{ disabled || child.disabled }}"
error="{{ errors[group.key + '__' + activeIndex + '__' + child.key] || '' }}"
group-key="{{ group.key }}"
row-index="{{ activeIndex }}"
bind:change="onFieldChange"
/>
</block>
</view>
</view>
</view>
<view wx:if="{{ errors[group.key] }}" class="group-repeater__group-error">{{ errors[group.key] }}</view>
</view>