@weitutech/by-components 1.0.27 → 1.0.30
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/CHANGELOG.md +38 -38
- package/README.md +469 -469
- package/docs/extension.md +15 -0
- package/docs/form.md +26 -0
- package/docs/table.md +26 -0
- package/lib/by-components.common.js +29353 -29328
- package/lib/by-components.umd.js +28985 -28960
- package/lib/by-components.umd.min.js +142 -142
- package/package.json +30 -30
- package/postcss.config.js +6 -6
- package/src/components/custom-column/index.vue +369 -369
- package/src/components/fold-search/index.vue +29 -29
- package/src/components/form/comps/custom-date-picker.vue +109 -109
- package/src/components/form/comps/date-picker-range.vue +78 -78
- package/src/components/form/comps/pair-number-input.vue +67 -67
- package/src/components/form/comps/select.vue +127 -127
- package/src/components/form/form.vue +351 -351
- package/src/components/page-search/page-search.vue +114 -114
- package/src/components/pager/index.vue +81 -81
- package/src/components/table/index.vue +240 -219
- package/src/index.js +30 -30
- package/src/plugin/vxeTable.js +300 -300
- package/src/plugin/vxeTable.scss +14 -14
- package/src/style/custom-column.scss +194 -194
- package/src/style/fold-search.scss +21 -21
- package/src/style/form.scss +342 -342
- package/src/style/index.scss +6 -6
- package/src/style/page-search.scss +26 -26
- package/src/style/pager.scss +40 -40
- package/src/style/table.scss +39 -39
- package/src/utils/index.js +31 -31
|
@@ -1,352 +1,352 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="b-form">
|
|
3
|
-
<div class="header">
|
|
4
|
-
<slot name="header" />
|
|
5
|
-
</div>
|
|
6
|
-
<el-form
|
|
7
|
-
ref="formRef"
|
|
8
|
-
class="myForm"
|
|
9
|
-
:label-position="labelPosition"
|
|
10
|
-
:rules="rules"
|
|
11
|
-
:label-width="labelWidth"
|
|
12
|
-
:inline="inline"
|
|
13
|
-
:model="value"
|
|
14
|
-
label-suffix=":"
|
|
15
|
-
>
|
|
16
|
-
<el-row>
|
|
17
|
-
<template v-for="item in formItems">
|
|
18
|
-
<el-col
|
|
19
|
-
v-if="!item.isHidden"
|
|
20
|
-
v-show="showFold(item)"
|
|
21
|
-
:key="item.label"
|
|
22
|
-
v-bind="item.colLayout || colLayout"
|
|
23
|
-
>
|
|
24
|
-
<el-form-item
|
|
25
|
-
:label="item.label || ''"
|
|
26
|
-
:rules="item.rules"
|
|
27
|
-
:style="item.itemStyle || itemStyle"
|
|
28
|
-
:prop="item.field"
|
|
29
|
-
:label-width="item.labelWidth || labelWidth"
|
|
30
|
-
>
|
|
31
|
-
<!-- 输入框 -->
|
|
32
|
-
<template v-if="item.type === 'input' || item.type === 'password'">
|
|
33
|
-
<el-input
|
|
34
|
-
:placeholder="item.placeholder"
|
|
35
|
-
clearable
|
|
36
|
-
v-bind="item.otherOptions"
|
|
37
|
-
style="width: 100%"
|
|
38
|
-
:show-password="item.type === 'password'"
|
|
39
|
-
:value="value[`${item.field}`]"
|
|
40
|
-
:size="elSize"
|
|
41
|
-
@input="handleValueChange($event, item)"
|
|
42
|
-
>
|
|
43
|
-
<slot v-if="item.otherOptions && item.otherOptions.isPrefix" name="prefix">
|
|
44
|
-
<el-select
|
|
45
|
-
v-if="item.otherOptions.prefixType === 'select'"
|
|
46
|
-
slot="prepend"
|
|
47
|
-
:value="value[`${item.otherOptions.prefixField}`]"
|
|
48
|
-
placeholder="请选择"
|
|
49
|
-
:style="{
|
|
50
|
-
width: '100px'
|
|
51
|
-
}"
|
|
52
|
-
@input="handleValueChange($event, item.otherOptions)"
|
|
53
|
-
>
|
|
54
|
-
<el-option v-for="p in item.otherOptions.prefixOption" :key="p.value" :label="p.label" :value="p.value" />
|
|
55
|
-
</el-select>
|
|
56
|
-
</slot>
|
|
57
|
-
<slot name="suffix" />
|
|
58
|
-
<slot name="prepend" />
|
|
59
|
-
<slot name="append" />
|
|
60
|
-
</el-input>
|
|
61
|
-
</template>
|
|
62
|
-
<!-- 选择器 -->
|
|
63
|
-
<template v-else-if="item.type === 'select'">
|
|
64
|
-
<by-select
|
|
65
|
-
:value="value[`${item.field}`]"
|
|
66
|
-
:config="item"
|
|
67
|
-
v-bind="item.otherOptions"
|
|
68
|
-
style="width: 100%"
|
|
69
|
-
clearable
|
|
70
|
-
filterable
|
|
71
|
-
:size="elSize"
|
|
72
|
-
:options="item.options"
|
|
73
|
-
@input="handleValueChange($event, item)"
|
|
74
|
-
/>
|
|
75
|
-
<slot :name="item.field" />
|
|
76
|
-
</template>
|
|
77
|
-
<!-- 日期选择器 -->
|
|
78
|
-
<template v-else-if="item.type === 'datepicker'">
|
|
79
|
-
<el-date-picker
|
|
80
|
-
style="width: 100%"
|
|
81
|
-
v-bind="item.otherOptions"
|
|
82
|
-
:placeholder="item.placeholder"
|
|
83
|
-
:value="value[`${item.field}`]"
|
|
84
|
-
:size="elSize"
|
|
85
|
-
@input="handleValueChange($event, item)"
|
|
86
|
-
/>
|
|
87
|
-
</template>
|
|
88
|
-
<!-- 级联 -->
|
|
89
|
-
<template v-else-if="item.type === 'cascader'">
|
|
90
|
-
<el-cascader
|
|
91
|
-
style="width: 100%"
|
|
92
|
-
v-bind="item.otherOptions"
|
|
93
|
-
:placeholder="item.placeholder"
|
|
94
|
-
:options="item.options"
|
|
95
|
-
clearable
|
|
96
|
-
filterable
|
|
97
|
-
:value="value[`${item.field}`]"
|
|
98
|
-
:size="elSize"
|
|
99
|
-
@input="handleValueChange($event, item)"
|
|
100
|
-
/>
|
|
101
|
-
</template>
|
|
102
|
-
<!-- 开关 -->
|
|
103
|
-
<template v-else-if="item.type === 'switch'">
|
|
104
|
-
<el-switch
|
|
105
|
-
v-bind="item.otherOptions"
|
|
106
|
-
:value="value[`${item.field}`]"
|
|
107
|
-
:size="elSize"
|
|
108
|
-
@input="handleValueChange($event, item)"
|
|
109
|
-
/>
|
|
110
|
-
</template>
|
|
111
|
-
<!-- 单选框 -->
|
|
112
|
-
<template v-else-if="item.type === 'radioGroup'">
|
|
113
|
-
<el-radio-group
|
|
114
|
-
v-if="item.cGOptions.type === 'button'"
|
|
115
|
-
v-bind="item.otherOptions"
|
|
116
|
-
:value="value[`${item.field}`]"
|
|
117
|
-
:size="elSize"
|
|
118
|
-
@input="handleValueChange($event, item)"
|
|
119
|
-
>
|
|
120
|
-
<el-radio-button
|
|
121
|
-
v-for="cgb in item.cGOptions.options"
|
|
122
|
-
:key="cgb.value"
|
|
123
|
-
:label="cgb.value"
|
|
124
|
-
:disabled="!!cgb.disabled"
|
|
125
|
-
>
|
|
126
|
-
{{ cgb.label }}
|
|
127
|
-
</el-radio-button>
|
|
128
|
-
</el-radio-group>
|
|
129
|
-
<el-radio-group
|
|
130
|
-
v-if="item.cGOptions.type === 'checkbox'"
|
|
131
|
-
v-bind="item.otherOptions"
|
|
132
|
-
:value="value[`${item.field}`]"
|
|
133
|
-
:size="elSize"
|
|
134
|
-
@input="handleValueChange($event, item)"
|
|
135
|
-
>
|
|
136
|
-
<el-radio v-for="cg in item.cGOptions.options" :key="cg.value" :label="cg.value" :disabled="!!cg.disabled">
|
|
137
|
-
{{ cg.label }}
|
|
138
|
-
</el-radio>
|
|
139
|
-
</el-radio-group>
|
|
140
|
-
</template>
|
|
141
|
-
<!-- 多选框 -->
|
|
142
|
-
<template v-else-if="item.type === 'checkboxGroup'">
|
|
143
|
-
<el-checkbox-group
|
|
144
|
-
v-if="item.cGOptions.type === 'button'"
|
|
145
|
-
v-bind="item.otherOptions"
|
|
146
|
-
:value="value[`${item.field}`]"
|
|
147
|
-
:size="elSize"
|
|
148
|
-
@input="handleValueChange($event, item)"
|
|
149
|
-
>
|
|
150
|
-
<el-checkbox-button
|
|
151
|
-
v-for="cgb in item.cGOptions.options"
|
|
152
|
-
:key="cgb.value"
|
|
153
|
-
:label="cgb.value"
|
|
154
|
-
>
|
|
155
|
-
{{ cgb.label }}
|
|
156
|
-
</el-checkbox-button>
|
|
157
|
-
</el-checkbox-group>
|
|
158
|
-
<el-checkbox-group
|
|
159
|
-
v-if="item.cGOptions.type === 'checkbox'"
|
|
160
|
-
v-bind="item.otherOptions"
|
|
161
|
-
:value="value[`${item.field}`]"
|
|
162
|
-
:size="elSize"
|
|
163
|
-
@input="handleValueChange($event, item)"
|
|
164
|
-
>
|
|
165
|
-
<el-checkbox
|
|
166
|
-
v-for="cg in item.cGOptions.options"
|
|
167
|
-
:key="cg.value"
|
|
168
|
-
:label="cg.value"
|
|
169
|
-
>
|
|
170
|
-
{{ cg.label }}
|
|
171
|
-
</el-checkbox>
|
|
172
|
-
</el-checkbox-group>
|
|
173
|
-
</template>
|
|
174
|
-
<!-- 文本类型 -->
|
|
175
|
-
<template v-else-if="item.type === 'text'">
|
|
176
|
-
<slot :name="item.slotName">
|
|
177
|
-
<div>{{ `${item.defaultValue}` }}</div>
|
|
178
|
-
</slot>
|
|
179
|
-
</template>
|
|
180
|
-
<!-- 双数字输入框 -->
|
|
181
|
-
<template v-else-if="item.type === 'pairNumberInput'">
|
|
182
|
-
<PairNumberInput
|
|
183
|
-
:value="value[`${item.field}`]"
|
|
184
|
-
:earliest-placeholder="item.earliestPlaceholder"
|
|
185
|
-
:latest-placeholder="item.latestPlaceholder"
|
|
186
|
-
@input="handleValueChange($event, item)"
|
|
187
|
-
/>
|
|
188
|
-
</template>
|
|
189
|
-
<!-- 时间范围自定义选择器 -->
|
|
190
|
-
<template v-else-if="item.type === 'customDatePicker'">
|
|
191
|
-
<CustomDatePicker
|
|
192
|
-
:value="value[`${item.field}`]"
|
|
193
|
-
v-bind="item"
|
|
194
|
-
@input="handleValueChange($event, item)"
|
|
195
|
-
/>
|
|
196
|
-
</template>
|
|
197
|
-
<!-- 自定义 -->
|
|
198
|
-
<template v-else-if="item.type === 'custom'">
|
|
199
|
-
<slot :name="item.field" :row="item" />
|
|
200
|
-
</template>
|
|
201
|
-
<!-- 搜索按钮 -->
|
|
202
|
-
<template v-else-if="item.type === 'search'">
|
|
203
|
-
<el-button :size="elSize || 'mini'" type="primary" icon="el-icon-search" v-bind="item.otherOptions" @click="handleQueryClick">{{ (item.otherOptions || {}).text || "搜索" }}</el-button>
|
|
204
|
-
</template>
|
|
205
|
-
</el-form-item>
|
|
206
|
-
</el-col>
|
|
207
|
-
</template>
|
|
208
|
-
<slot name="btn" :formData="formData" />
|
|
209
|
-
</el-row>
|
|
210
|
-
</el-form>
|
|
211
|
-
<div class="footer">
|
|
212
|
-
<slot name="footer" />
|
|
213
|
-
</div>
|
|
214
|
-
</div>
|
|
215
|
-
</template>
|
|
216
|
-
|
|
217
|
-
<script>
|
|
218
|
-
import PairNumberInput from "./comps/pair-number-input.vue"
|
|
219
|
-
import CustomDatePicker from "./comps/custom-date-picker.vue"
|
|
220
|
-
|
|
221
|
-
export default {
|
|
222
|
-
name: "ByForm",
|
|
223
|
-
components: {
|
|
224
|
-
PairNumberInput,
|
|
225
|
-
CustomDatePicker,
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
props: {
|
|
229
|
-
value: {
|
|
230
|
-
type: Object,
|
|
231
|
-
required: true
|
|
232
|
-
},
|
|
233
|
-
labelPosition: {
|
|
234
|
-
type: String,
|
|
235
|
-
default: "right"
|
|
236
|
-
},
|
|
237
|
-
formItems: {
|
|
238
|
-
type: Array,
|
|
239
|
-
default: () => []
|
|
240
|
-
},
|
|
241
|
-
flexible: {
|
|
242
|
-
type: Object,
|
|
243
|
-
default: () => {
|
|
244
|
-
return {
|
|
245
|
-
foldField: "none", // 需要折叠字段
|
|
246
|
-
unfold: false // 默认展开?
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
},
|
|
250
|
-
labelWidth: {
|
|
251
|
-
type: String,
|
|
252
|
-
default: "100px"
|
|
253
|
-
},
|
|
254
|
-
itemStyle: {
|
|
255
|
-
type: Object,
|
|
256
|
-
default: () => ({ padding: "10px 40px" })
|
|
257
|
-
},
|
|
258
|
-
colLayout: {
|
|
259
|
-
type: Object,
|
|
260
|
-
default: () => ({
|
|
261
|
-
xl: 4, // >1920px 4个
|
|
262
|
-
lg: 6,
|
|
263
|
-
md: 6,
|
|
264
|
-
sm: 8,
|
|
265
|
-
xs: 12
|
|
266
|
-
})
|
|
267
|
-
},
|
|
268
|
-
// 是否收起
|
|
269
|
-
isFlexible: {
|
|
270
|
-
type: Boolean,
|
|
271
|
-
default: true
|
|
272
|
-
},
|
|
273
|
-
inline: {
|
|
274
|
-
type: Boolean,
|
|
275
|
-
default: false
|
|
276
|
-
},
|
|
277
|
-
rules: {
|
|
278
|
-
type: Object,
|
|
279
|
-
default: () => {}
|
|
280
|
-
},
|
|
281
|
-
elSize: {
|
|
282
|
-
type: String,
|
|
283
|
-
default: "mini"
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
|
|
287
|
-
data() {
|
|
288
|
-
return {
|
|
289
|
-
formData: this.value,
|
|
290
|
-
// 数据替换
|
|
291
|
-
replacementData: undefined
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
|
|
295
|
-
computed: {
|
|
296
|
-
showFold() {
|
|
297
|
-
return (item) => {
|
|
298
|
-
if (this.isFlexible) {
|
|
299
|
-
return true
|
|
300
|
-
} else {
|
|
301
|
-
if (this.flexible && this.flexible.foldField.length) {
|
|
302
|
-
if (this.flexible.foldField.includes(item.id) || this.flexible.foldField.includes(item.field)) {
|
|
303
|
-
return false
|
|
304
|
-
} else {
|
|
305
|
-
return true
|
|
306
|
-
}
|
|
307
|
-
} else {
|
|
308
|
-
return true
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
},
|
|
314
|
-
|
|
315
|
-
watch: {
|
|
316
|
-
value: {
|
|
317
|
-
handler(newValue, oldValue) {
|
|
318
|
-
this.formData = newValue
|
|
319
|
-
this.replacementData = {
|
|
320
|
-
...(this.replacementData ? this.replacementData : {}),
|
|
321
|
-
...newValue
|
|
322
|
-
}
|
|
323
|
-
},
|
|
324
|
-
deep: true,
|
|
325
|
-
immediate: true
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
|
|
329
|
-
methods: {
|
|
330
|
-
validate(cb = () => {}) {
|
|
331
|
-
this.$refs.formRef.validate((valid, obj) => {
|
|
332
|
-
cb(valid, obj)
|
|
333
|
-
})
|
|
334
|
-
},
|
|
335
|
-
clearValidate() {
|
|
336
|
-
this.$refs.formRef.clearValidate()
|
|
337
|
-
},
|
|
338
|
-
handleValueChange(value, item) {
|
|
339
|
-
if (this.replacementData) {
|
|
340
|
-
this.replacementData[item.field] = value
|
|
341
|
-
} else {
|
|
342
|
-
this.replacementData = { ...this.value, [item.field]: value }
|
|
343
|
-
}
|
|
344
|
-
this.$emit("change", { ...item, value })
|
|
345
|
-
this.$emit("input", this.replacementData)
|
|
346
|
-
},
|
|
347
|
-
handleQueryClick() {
|
|
348
|
-
this.$emit("queryBtnClick")
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<div class="b-form">
|
|
3
|
+
<div class="header">
|
|
4
|
+
<slot name="header" />
|
|
5
|
+
</div>
|
|
6
|
+
<el-form
|
|
7
|
+
ref="formRef"
|
|
8
|
+
class="myForm"
|
|
9
|
+
:label-position="labelPosition"
|
|
10
|
+
:rules="rules"
|
|
11
|
+
:label-width="labelWidth"
|
|
12
|
+
:inline="inline"
|
|
13
|
+
:model="value"
|
|
14
|
+
label-suffix=":"
|
|
15
|
+
>
|
|
16
|
+
<el-row>
|
|
17
|
+
<template v-for="item in formItems">
|
|
18
|
+
<el-col
|
|
19
|
+
v-if="!item.isHidden"
|
|
20
|
+
v-show="showFold(item)"
|
|
21
|
+
:key="item.label"
|
|
22
|
+
v-bind="item.colLayout || colLayout"
|
|
23
|
+
>
|
|
24
|
+
<el-form-item
|
|
25
|
+
:label="item.label || ''"
|
|
26
|
+
:rules="item.rules"
|
|
27
|
+
:style="item.itemStyle || itemStyle"
|
|
28
|
+
:prop="item.field"
|
|
29
|
+
:label-width="item.labelWidth || labelWidth"
|
|
30
|
+
>
|
|
31
|
+
<!-- 输入框 -->
|
|
32
|
+
<template v-if="item.type === 'input' || item.type === 'password'">
|
|
33
|
+
<el-input
|
|
34
|
+
:placeholder="item.placeholder"
|
|
35
|
+
clearable
|
|
36
|
+
v-bind="item.otherOptions"
|
|
37
|
+
style="width: 100%"
|
|
38
|
+
:show-password="item.type === 'password'"
|
|
39
|
+
:value="value[`${item.field}`]"
|
|
40
|
+
:size="elSize"
|
|
41
|
+
@input="handleValueChange($event, item)"
|
|
42
|
+
>
|
|
43
|
+
<slot v-if="item.otherOptions && item.otherOptions.isPrefix" name="prefix">
|
|
44
|
+
<el-select
|
|
45
|
+
v-if="item.otherOptions.prefixType === 'select'"
|
|
46
|
+
slot="prepend"
|
|
47
|
+
:value="value[`${item.otherOptions.prefixField}`]"
|
|
48
|
+
placeholder="请选择"
|
|
49
|
+
:style="{
|
|
50
|
+
width: '100px'
|
|
51
|
+
}"
|
|
52
|
+
@input="handleValueChange($event, item.otherOptions)"
|
|
53
|
+
>
|
|
54
|
+
<el-option v-for="p in item.otherOptions.prefixOption" :key="p.value" :label="p.label" :value="p.value" />
|
|
55
|
+
</el-select>
|
|
56
|
+
</slot>
|
|
57
|
+
<slot name="suffix" />
|
|
58
|
+
<slot name="prepend" />
|
|
59
|
+
<slot name="append" />
|
|
60
|
+
</el-input>
|
|
61
|
+
</template>
|
|
62
|
+
<!-- 选择器 -->
|
|
63
|
+
<template v-else-if="item.type === 'select'">
|
|
64
|
+
<by-select
|
|
65
|
+
:value="value[`${item.field}`]"
|
|
66
|
+
:config="item"
|
|
67
|
+
v-bind="item.otherOptions"
|
|
68
|
+
style="width: 100%"
|
|
69
|
+
clearable
|
|
70
|
+
filterable
|
|
71
|
+
:size="elSize"
|
|
72
|
+
:options="item.options"
|
|
73
|
+
@input="handleValueChange($event, item)"
|
|
74
|
+
/>
|
|
75
|
+
<slot :name="item.field" />
|
|
76
|
+
</template>
|
|
77
|
+
<!-- 日期选择器 -->
|
|
78
|
+
<template v-else-if="item.type === 'datepicker'">
|
|
79
|
+
<el-date-picker
|
|
80
|
+
style="width: 100%"
|
|
81
|
+
v-bind="item.otherOptions"
|
|
82
|
+
:placeholder="item.placeholder"
|
|
83
|
+
:value="value[`${item.field}`]"
|
|
84
|
+
:size="elSize"
|
|
85
|
+
@input="handleValueChange($event, item)"
|
|
86
|
+
/>
|
|
87
|
+
</template>
|
|
88
|
+
<!-- 级联 -->
|
|
89
|
+
<template v-else-if="item.type === 'cascader'">
|
|
90
|
+
<el-cascader
|
|
91
|
+
style="width: 100%"
|
|
92
|
+
v-bind="item.otherOptions"
|
|
93
|
+
:placeholder="item.placeholder"
|
|
94
|
+
:options="item.options"
|
|
95
|
+
clearable
|
|
96
|
+
filterable
|
|
97
|
+
:value="value[`${item.field}`]"
|
|
98
|
+
:size="elSize"
|
|
99
|
+
@input="handleValueChange($event, item)"
|
|
100
|
+
/>
|
|
101
|
+
</template>
|
|
102
|
+
<!-- 开关 -->
|
|
103
|
+
<template v-else-if="item.type === 'switch'">
|
|
104
|
+
<el-switch
|
|
105
|
+
v-bind="item.otherOptions"
|
|
106
|
+
:value="value[`${item.field}`]"
|
|
107
|
+
:size="elSize"
|
|
108
|
+
@input="handleValueChange($event, item)"
|
|
109
|
+
/>
|
|
110
|
+
</template>
|
|
111
|
+
<!-- 单选框 -->
|
|
112
|
+
<template v-else-if="item.type === 'radioGroup'">
|
|
113
|
+
<el-radio-group
|
|
114
|
+
v-if="item.cGOptions.type === 'button'"
|
|
115
|
+
v-bind="item.otherOptions"
|
|
116
|
+
:value="value[`${item.field}`]"
|
|
117
|
+
:size="elSize"
|
|
118
|
+
@input="handleValueChange($event, item)"
|
|
119
|
+
>
|
|
120
|
+
<el-radio-button
|
|
121
|
+
v-for="cgb in item.cGOptions.options"
|
|
122
|
+
:key="cgb.value"
|
|
123
|
+
:label="cgb.value"
|
|
124
|
+
:disabled="!!cgb.disabled"
|
|
125
|
+
>
|
|
126
|
+
{{ cgb.label }}
|
|
127
|
+
</el-radio-button>
|
|
128
|
+
</el-radio-group>
|
|
129
|
+
<el-radio-group
|
|
130
|
+
v-if="item.cGOptions.type === 'checkbox'"
|
|
131
|
+
v-bind="item.otherOptions"
|
|
132
|
+
:value="value[`${item.field}`]"
|
|
133
|
+
:size="elSize"
|
|
134
|
+
@input="handleValueChange($event, item)"
|
|
135
|
+
>
|
|
136
|
+
<el-radio v-for="cg in item.cGOptions.options" :key="cg.value" :label="cg.value" :disabled="!!cg.disabled">
|
|
137
|
+
{{ cg.label }}
|
|
138
|
+
</el-radio>
|
|
139
|
+
</el-radio-group>
|
|
140
|
+
</template>
|
|
141
|
+
<!-- 多选框 -->
|
|
142
|
+
<template v-else-if="item.type === 'checkboxGroup'">
|
|
143
|
+
<el-checkbox-group
|
|
144
|
+
v-if="item.cGOptions.type === 'button'"
|
|
145
|
+
v-bind="item.otherOptions"
|
|
146
|
+
:value="value[`${item.field}`]"
|
|
147
|
+
:size="elSize"
|
|
148
|
+
@input="handleValueChange($event, item)"
|
|
149
|
+
>
|
|
150
|
+
<el-checkbox-button
|
|
151
|
+
v-for="cgb in item.cGOptions.options"
|
|
152
|
+
:key="cgb.value"
|
|
153
|
+
:label="cgb.value"
|
|
154
|
+
>
|
|
155
|
+
{{ cgb.label }}
|
|
156
|
+
</el-checkbox-button>
|
|
157
|
+
</el-checkbox-group>
|
|
158
|
+
<el-checkbox-group
|
|
159
|
+
v-if="item.cGOptions.type === 'checkbox'"
|
|
160
|
+
v-bind="item.otherOptions"
|
|
161
|
+
:value="value[`${item.field}`]"
|
|
162
|
+
:size="elSize"
|
|
163
|
+
@input="handleValueChange($event, item)"
|
|
164
|
+
>
|
|
165
|
+
<el-checkbox
|
|
166
|
+
v-for="cg in item.cGOptions.options"
|
|
167
|
+
:key="cg.value"
|
|
168
|
+
:label="cg.value"
|
|
169
|
+
>
|
|
170
|
+
{{ cg.label }}
|
|
171
|
+
</el-checkbox>
|
|
172
|
+
</el-checkbox-group>
|
|
173
|
+
</template>
|
|
174
|
+
<!-- 文本类型 -->
|
|
175
|
+
<template v-else-if="item.type === 'text'">
|
|
176
|
+
<slot :name="item.slotName">
|
|
177
|
+
<div>{{ `${item.defaultValue}` }}</div>
|
|
178
|
+
</slot>
|
|
179
|
+
</template>
|
|
180
|
+
<!-- 双数字输入框 -->
|
|
181
|
+
<template v-else-if="item.type === 'pairNumberInput'">
|
|
182
|
+
<PairNumberInput
|
|
183
|
+
:value="value[`${item.field}`]"
|
|
184
|
+
:earliest-placeholder="item.earliestPlaceholder"
|
|
185
|
+
:latest-placeholder="item.latestPlaceholder"
|
|
186
|
+
@input="handleValueChange($event, item)"
|
|
187
|
+
/>
|
|
188
|
+
</template>
|
|
189
|
+
<!-- 时间范围自定义选择器 -->
|
|
190
|
+
<template v-else-if="item.type === 'customDatePicker'">
|
|
191
|
+
<CustomDatePicker
|
|
192
|
+
:value="value[`${item.field}`]"
|
|
193
|
+
v-bind="item"
|
|
194
|
+
@input="handleValueChange($event, item)"
|
|
195
|
+
/>
|
|
196
|
+
</template>
|
|
197
|
+
<!-- 自定义 -->
|
|
198
|
+
<template v-else-if="item.type === 'custom'">
|
|
199
|
+
<slot :name="item.field" :row="item" />
|
|
200
|
+
</template>
|
|
201
|
+
<!-- 搜索按钮 -->
|
|
202
|
+
<template v-else-if="item.type === 'search'">
|
|
203
|
+
<el-button :size="elSize || 'mini'" type="primary" icon="el-icon-search" v-bind="item.otherOptions" @click="handleQueryClick">{{ (item.otherOptions || {}).text || "搜索" }}</el-button>
|
|
204
|
+
</template>
|
|
205
|
+
</el-form-item>
|
|
206
|
+
</el-col>
|
|
207
|
+
</template>
|
|
208
|
+
<slot name="btn" :formData="formData" />
|
|
209
|
+
</el-row>
|
|
210
|
+
</el-form>
|
|
211
|
+
<div class="footer">
|
|
212
|
+
<slot name="footer" />
|
|
213
|
+
</div>
|
|
214
|
+
</div>
|
|
215
|
+
</template>
|
|
216
|
+
|
|
217
|
+
<script>
|
|
218
|
+
import PairNumberInput from "./comps/pair-number-input.vue"
|
|
219
|
+
import CustomDatePicker from "./comps/custom-date-picker.vue"
|
|
220
|
+
|
|
221
|
+
export default {
|
|
222
|
+
name: "ByForm",
|
|
223
|
+
components: {
|
|
224
|
+
PairNumberInput,
|
|
225
|
+
CustomDatePicker,
|
|
226
|
+
},
|
|
227
|
+
|
|
228
|
+
props: {
|
|
229
|
+
value: {
|
|
230
|
+
type: Object,
|
|
231
|
+
required: true
|
|
232
|
+
},
|
|
233
|
+
labelPosition: {
|
|
234
|
+
type: String,
|
|
235
|
+
default: "right"
|
|
236
|
+
},
|
|
237
|
+
formItems: {
|
|
238
|
+
type: Array,
|
|
239
|
+
default: () => []
|
|
240
|
+
},
|
|
241
|
+
flexible: {
|
|
242
|
+
type: Object,
|
|
243
|
+
default: () => {
|
|
244
|
+
return {
|
|
245
|
+
foldField: "none", // 需要折叠字段
|
|
246
|
+
unfold: false // 默认展开?
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
labelWidth: {
|
|
251
|
+
type: String,
|
|
252
|
+
default: "100px"
|
|
253
|
+
},
|
|
254
|
+
itemStyle: {
|
|
255
|
+
type: Object,
|
|
256
|
+
default: () => ({ padding: "10px 40px" })
|
|
257
|
+
},
|
|
258
|
+
colLayout: {
|
|
259
|
+
type: Object,
|
|
260
|
+
default: () => ({
|
|
261
|
+
xl: 4, // >1920px 4个
|
|
262
|
+
lg: 6,
|
|
263
|
+
md: 6,
|
|
264
|
+
sm: 8,
|
|
265
|
+
xs: 12
|
|
266
|
+
})
|
|
267
|
+
},
|
|
268
|
+
// 是否收起
|
|
269
|
+
isFlexible: {
|
|
270
|
+
type: Boolean,
|
|
271
|
+
default: true
|
|
272
|
+
},
|
|
273
|
+
inline: {
|
|
274
|
+
type: Boolean,
|
|
275
|
+
default: false
|
|
276
|
+
},
|
|
277
|
+
rules: {
|
|
278
|
+
type: Object,
|
|
279
|
+
default: () => {}
|
|
280
|
+
},
|
|
281
|
+
elSize: {
|
|
282
|
+
type: String,
|
|
283
|
+
default: "mini"
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
|
|
287
|
+
data() {
|
|
288
|
+
return {
|
|
289
|
+
formData: this.value,
|
|
290
|
+
// 数据替换
|
|
291
|
+
replacementData: undefined
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
computed: {
|
|
296
|
+
showFold() {
|
|
297
|
+
return (item) => {
|
|
298
|
+
if (this.isFlexible) {
|
|
299
|
+
return true
|
|
300
|
+
} else {
|
|
301
|
+
if (this.flexible && this.flexible.foldField.length) {
|
|
302
|
+
if (this.flexible.foldField.includes(item.id) || this.flexible.foldField.includes(item.field)) {
|
|
303
|
+
return false
|
|
304
|
+
} else {
|
|
305
|
+
return true
|
|
306
|
+
}
|
|
307
|
+
} else {
|
|
308
|
+
return true
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
|
|
315
|
+
watch: {
|
|
316
|
+
value: {
|
|
317
|
+
handler(newValue, oldValue) {
|
|
318
|
+
this.formData = newValue
|
|
319
|
+
this.replacementData = {
|
|
320
|
+
...(this.replacementData ? this.replacementData : {}),
|
|
321
|
+
...newValue
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
deep: true,
|
|
325
|
+
immediate: true
|
|
326
|
+
}
|
|
327
|
+
},
|
|
328
|
+
|
|
329
|
+
methods: {
|
|
330
|
+
validate(cb = () => {}) {
|
|
331
|
+
this.$refs.formRef.validate((valid, obj) => {
|
|
332
|
+
cb(valid, obj)
|
|
333
|
+
})
|
|
334
|
+
},
|
|
335
|
+
clearValidate() {
|
|
336
|
+
this.$refs.formRef.clearValidate()
|
|
337
|
+
},
|
|
338
|
+
handleValueChange(value, item) {
|
|
339
|
+
if (this.replacementData) {
|
|
340
|
+
this.replacementData[item.field] = value
|
|
341
|
+
} else {
|
|
342
|
+
this.replacementData = { ...this.value, [item.field]: value }
|
|
343
|
+
}
|
|
344
|
+
this.$emit("change", { ...item, value })
|
|
345
|
+
this.$emit("input", this.replacementData)
|
|
346
|
+
},
|
|
347
|
+
handleQueryClick() {
|
|
348
|
+
this.$emit("queryBtnClick")
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
352
|
</script>
|