@weitutech/by-components 1.0.31 → 1.1.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/.babelrc +7 -0
- package/.editorconfig +19 -0
- package/.eslintignore +9 -0
- package/.eslintrc.cjs +65 -0
- package/.prettierignore +9 -0
- package/.prettierrc +22 -0
- package/.vscode/extensions.json +7 -0
- package/.vscode/settings.json +27 -0
- package/CHANGELOG.md +14 -0
- package/README.md +30 -3
- package/docs/form.md +42 -1
- package/docs/table.md +25 -8
- package/lib/by-components.common.js +7831 -58668
- package/lib/by-components.umd.js +7631 -58451
- package/lib/by-components.umd.min.js +2 -301
- package/package.json +18 -4
- package/src/components/custom-column/index.vue +83 -58
- package/src/components/fold-search/index.vue +15 -5
- package/src/components/form/comps/custom-date-picker.vue +75 -39
- package/src/components/form/comps/date-picker-range.vue +47 -13
- package/src/components/form/comps/pair-number-input.vue +27 -15
- package/src/components/form/comps/select.vue +11 -8
- package/src/components/form/form.vue +89 -41
- package/src/components/page-search/page-search.vue +17 -9
- package/src/components/pager/index.vue +16 -10
- package/src/components/table/index.vue +190 -59
- package/src/index.js +2 -2
- package/src/plugin/vxeTable.js +3 -3
- package/src/style/custom-column.scss +6 -8
- package/src/style/index.scss +13 -6
- package/src/utils/index.js +3 -3
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
:end-placeholder="config.endPlaceholder || '结束时间'"
|
|
8
8
|
:range-separator="config.rangeSeparator || '-'"
|
|
9
9
|
:size="config.size || 'mini'"
|
|
10
|
-
type=
|
|
10
|
+
type="daterange"
|
|
11
11
|
@input="handleChange"
|
|
12
12
|
/>
|
|
13
13
|
<div class="btn">
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
</template>
|
|
26
26
|
|
|
27
27
|
<script>
|
|
28
|
-
import moment from
|
|
28
|
+
import moment from 'moment'
|
|
29
29
|
export default {
|
|
30
30
|
name: 'ByDatePickerRange',
|
|
31
31
|
props: {
|
|
32
|
-
|
|
32
|
+
//绑定的表单数据
|
|
33
33
|
value: {
|
|
34
34
|
type: Object,
|
|
35
35
|
default: null
|
|
@@ -43,13 +43,44 @@ export default {
|
|
|
43
43
|
data() {
|
|
44
44
|
return {
|
|
45
45
|
shortcuts: [
|
|
46
|
-
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
{
|
|
47
|
+
label: '上月',
|
|
48
|
+
start_time: moment()
|
|
49
|
+
.subtract(1, 'months')
|
|
50
|
+
.startOf('month')
|
|
51
|
+
.format('YYYY-MM-DD'),
|
|
52
|
+
end_time: moment()
|
|
53
|
+
.subtract(1, 'months')
|
|
54
|
+
.endOf('month')
|
|
55
|
+
.format('YYYY-MM-DD'),
|
|
56
|
+
key: 'last_month'
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
label: '昨天',
|
|
60
|
+
start_time: moment().subtract(1, 'days').format('YYYY-MM-DD'),
|
|
61
|
+
end_time: moment().subtract(1, 'days').format('YYYY-MM-DD'),
|
|
62
|
+
key: 'yesterday'
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: '今天',
|
|
66
|
+
start_time: moment().startOf('day').format('YYYY-MM-DD'),
|
|
67
|
+
end_time: moment().startOf('day').format('YYYY-MM-DD'),
|
|
68
|
+
key: 'today'
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
label: '本周',
|
|
72
|
+
start_time: moment().startOf('week').format('YYYY-MM-DD'),
|
|
73
|
+
end_time: moment().endOf('week').format('YYYY-MM-DD'),
|
|
74
|
+
key: 'week'
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
label: '本月',
|
|
78
|
+
start_time: moment().startOf('month').format('YYYY-MM-DD'),
|
|
79
|
+
end_time: moment().endOf('month').format('YYYY-MM-DD'),
|
|
80
|
+
key: 'month'
|
|
81
|
+
}
|
|
51
82
|
],
|
|
52
|
-
active:
|
|
83
|
+
active: ''
|
|
53
84
|
}
|
|
54
85
|
},
|
|
55
86
|
mounted() {
|
|
@@ -62,16 +93,19 @@ export default {
|
|
|
62
93
|
methods: {
|
|
63
94
|
handleChange(e) {
|
|
64
95
|
if (!e) {
|
|
65
|
-
this.$emit(
|
|
96
|
+
this.$emit('input', [])
|
|
66
97
|
} else {
|
|
67
|
-
this.$emit(
|
|
98
|
+
this.$emit(
|
|
99
|
+
'input',
|
|
100
|
+
e.map(item => moment(item).format('YYYY-MM-DD'))
|
|
101
|
+
)
|
|
68
102
|
}
|
|
69
|
-
this.active =
|
|
103
|
+
this.active = ''
|
|
70
104
|
},
|
|
71
105
|
handleClick(item) {
|
|
72
106
|
this.active = item.key
|
|
73
107
|
this.value[this.config.field] = [item.start_time, item.end_time]
|
|
74
|
-
this.$emit(
|
|
108
|
+
this.$emit('input', [item.start_time, item.end_time])
|
|
75
109
|
}
|
|
76
110
|
}
|
|
77
111
|
}
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="w-full flex">
|
|
3
|
-
<el-input
|
|
3
|
+
<el-input
|
|
4
|
+
class="w-1/2"
|
|
5
|
+
:value="value[0]"
|
|
6
|
+
:placeholder="earliestPlaceholder"
|
|
7
|
+
@input="value => handleInput(value, 'min')"
|
|
8
|
+
@blur="e => handleBlur(+e.target.value, 'min')"
|
|
9
|
+
/>
|
|
4
10
|
<span>~</span>
|
|
5
|
-
<el-input
|
|
11
|
+
<el-input
|
|
12
|
+
class="w-1/2"
|
|
13
|
+
:value="value[1]"
|
|
14
|
+
:placeholder="latestPlaceholder"
|
|
15
|
+
@input="value => handleInput(value, 'max')"
|
|
16
|
+
@blur="e => handleBlur(+e.target.value, 'max')"
|
|
17
|
+
/>
|
|
6
18
|
</div>
|
|
7
19
|
</template>
|
|
8
20
|
|
|
@@ -12,15 +24,15 @@ export default {
|
|
|
12
24
|
value: {
|
|
13
25
|
type: Array,
|
|
14
26
|
required: true,
|
|
15
|
-
default: () => [
|
|
27
|
+
default: () => ['', 0]
|
|
16
28
|
},
|
|
17
29
|
earliestPlaceholder: {
|
|
18
30
|
type: String,
|
|
19
|
-
default:
|
|
31
|
+
default: ''
|
|
20
32
|
},
|
|
21
33
|
latestPlaceholder: {
|
|
22
34
|
type: String,
|
|
23
|
-
default:
|
|
35
|
+
default: ''
|
|
24
36
|
}
|
|
25
37
|
},
|
|
26
38
|
|
|
@@ -31,14 +43,14 @@ export default {
|
|
|
31
43
|
* @param { string } type 输入框的类型 min | max
|
|
32
44
|
*/
|
|
33
45
|
handleInput(val, type) {
|
|
34
|
-
if (type ===
|
|
35
|
-
const values = [val.replace(/\D+/,
|
|
46
|
+
if (type === 'min') {
|
|
47
|
+
const values = [val.replace(/\D+/, ''), this.value[1]]
|
|
36
48
|
|
|
37
|
-
this.$emit(
|
|
38
|
-
} else if (type ===
|
|
39
|
-
const values = [this.value[0], val.replace(/\D+/,
|
|
49
|
+
this.$emit('input', values)
|
|
50
|
+
} else if (type === 'max') {
|
|
51
|
+
const values = [this.value[0], val.replace(/\D+/, '')]
|
|
40
52
|
|
|
41
|
-
this.$emit(
|
|
53
|
+
this.$emit('input', values)
|
|
42
54
|
}
|
|
43
55
|
},
|
|
44
56
|
|
|
@@ -48,17 +60,17 @@ export default {
|
|
|
48
60
|
* @param { string } type 输入框的类型 min | max
|
|
49
61
|
*/
|
|
50
62
|
handleBlur(val, type) {
|
|
51
|
-
if (type ===
|
|
63
|
+
if (type === 'min') {
|
|
52
64
|
if (val > this.value[1]) {
|
|
53
65
|
const values = [this.value[1], this.value[1]]
|
|
54
66
|
|
|
55
|
-
this.$emit(
|
|
67
|
+
this.$emit('input', values)
|
|
56
68
|
}
|
|
57
|
-
} else if (type ===
|
|
69
|
+
} else if (type === 'max') {
|
|
58
70
|
if (val < this.value[0]) {
|
|
59
71
|
const values = [this.value[0], this.value[0]]
|
|
60
72
|
|
|
61
|
-
this.$emit(
|
|
73
|
+
this.$emit('input', values)
|
|
62
74
|
}
|
|
63
75
|
}
|
|
64
76
|
}
|
|
@@ -27,12 +27,16 @@
|
|
|
27
27
|
</template>
|
|
28
28
|
<template v-else>
|
|
29
29
|
<el-option
|
|
30
|
-
v-for="
|
|
31
|
-
:key="
|
|
30
|
+
v-for="item in filterData"
|
|
31
|
+
:key="
|
|
32
|
+
item[config.optionValue || 'value'] +
|
|
33
|
+
'-' +
|
|
34
|
+
item[config.optionLabel || 'label']
|
|
35
|
+
"
|
|
32
36
|
:label="item[config.optionLabel || 'label']"
|
|
33
37
|
:value="item[config.optionValue || 'value']"
|
|
34
38
|
/>
|
|
35
|
-
|
|
39
|
+
</template>
|
|
36
40
|
</el-select>
|
|
37
41
|
</template>
|
|
38
42
|
<script>
|
|
@@ -42,7 +46,7 @@ export default {
|
|
|
42
46
|
props: {
|
|
43
47
|
...Select.props,
|
|
44
48
|
value: {
|
|
45
|
-
type: [String, Number, Array]
|
|
49
|
+
type: [String, Number, Array]
|
|
46
50
|
},
|
|
47
51
|
// 下拉框数据
|
|
48
52
|
placeholder: {
|
|
@@ -80,11 +84,11 @@ export default {
|
|
|
80
84
|
methods: {
|
|
81
85
|
change(e) {
|
|
82
86
|
this.$emit('change', arguments.length === 1 ? e : arguments)
|
|
83
|
-
this.$emit(
|
|
87
|
+
this.$emit('input', e)
|
|
84
88
|
},
|
|
85
89
|
input(e) {
|
|
86
90
|
this.$emit('change', arguments.length === 1 ? e : arguments)
|
|
87
|
-
this.$emit(
|
|
91
|
+
this.$emit('input', e)
|
|
88
92
|
},
|
|
89
93
|
visibleChange(e) {
|
|
90
94
|
this.$emit('visible-change', arguments.length === 1 ? e : arguments)
|
|
@@ -117,11 +121,10 @@ export default {
|
|
|
117
121
|
this.filterData = this.options
|
|
118
122
|
this.searchVal = this.$refs.selection.$refs.input.value
|
|
119
123
|
this.filterData = this.options.filter(
|
|
120
|
-
|
|
124
|
+
item => item[this.config.optionLabel].indexOf(this.searchVal) !== -1
|
|
121
125
|
)
|
|
122
126
|
}
|
|
123
127
|
}
|
|
124
128
|
}
|
|
125
129
|
}
|
|
126
130
|
</script>
|
|
127
|
-
|
|
@@ -12,15 +12,12 @@
|
|
|
12
12
|
:inline="inline"
|
|
13
13
|
:model="value"
|
|
14
14
|
label-suffix=":"
|
|
15
|
+
@submit.native.prevent="submit"
|
|
16
|
+
@reset.native.prevent="reset"
|
|
15
17
|
>
|
|
16
18
|
<el-row>
|
|
17
19
|
<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
|
-
>
|
|
20
|
+
<el-col v-if="!item.isHidden" v-show="showFold(item)" :key="item.label" v-bind="item.colLayout || colLayout">
|
|
24
21
|
<el-form-item
|
|
25
22
|
:label="item.label || ''"
|
|
26
23
|
:rules="item.rules"
|
|
@@ -51,7 +48,12 @@
|
|
|
51
48
|
}"
|
|
52
49
|
@input="handleValueChange($event, item.otherOptions)"
|
|
53
50
|
>
|
|
54
|
-
<el-option
|
|
51
|
+
<el-option
|
|
52
|
+
v-for="p in item.otherOptions.prefixOption"
|
|
53
|
+
:key="p.value"
|
|
54
|
+
:label="p.label"
|
|
55
|
+
:value="p.value"
|
|
56
|
+
/>
|
|
55
57
|
</el-select>
|
|
56
58
|
</slot>
|
|
57
59
|
<slot name="suffix" />
|
|
@@ -133,7 +135,12 @@
|
|
|
133
135
|
:size="elSize"
|
|
134
136
|
@input="handleValueChange($event, item)"
|
|
135
137
|
>
|
|
136
|
-
<el-radio
|
|
138
|
+
<el-radio
|
|
139
|
+
v-for="cg in item.cGOptions.options"
|
|
140
|
+
:key="cg.value"
|
|
141
|
+
:label="cg.value"
|
|
142
|
+
:disabled="!!cg.disabled"
|
|
143
|
+
>
|
|
137
144
|
{{ cg.label }}
|
|
138
145
|
</el-radio>
|
|
139
146
|
</el-radio-group>
|
|
@@ -147,11 +154,7 @@
|
|
|
147
154
|
:size="elSize"
|
|
148
155
|
@input="handleValueChange($event, item)"
|
|
149
156
|
>
|
|
150
|
-
<el-checkbox-button
|
|
151
|
-
v-for="cgb in item.cGOptions.options"
|
|
152
|
-
:key="cgb.value"
|
|
153
|
-
:label="cgb.value"
|
|
154
|
-
>
|
|
157
|
+
<el-checkbox-button v-for="cgb in item.cGOptions.options" :key="cgb.value" :label="cgb.value">
|
|
155
158
|
{{ cgb.label }}
|
|
156
159
|
</el-checkbox-button>
|
|
157
160
|
</el-checkbox-group>
|
|
@@ -162,11 +165,7 @@
|
|
|
162
165
|
:size="elSize"
|
|
163
166
|
@input="handleValueChange($event, item)"
|
|
164
167
|
>
|
|
165
|
-
<el-checkbox
|
|
166
|
-
v-for="cg in item.cGOptions.options"
|
|
167
|
-
:key="cg.value"
|
|
168
|
-
:label="cg.value"
|
|
169
|
-
>
|
|
168
|
+
<el-checkbox v-for="cg in item.cGOptions.options" :key="cg.value" :label="cg.value">
|
|
170
169
|
{{ cg.label }}
|
|
171
170
|
</el-checkbox>
|
|
172
171
|
</el-checkbox-group>
|
|
@@ -201,7 +200,36 @@
|
|
|
201
200
|
</template>
|
|
202
201
|
<!-- 搜索按钮 -->
|
|
203
202
|
<template v-else-if="item.type === 'search'">
|
|
204
|
-
<el-button
|
|
203
|
+
<el-button
|
|
204
|
+
:size="elSize || 'mini'"
|
|
205
|
+
type="primary"
|
|
206
|
+
icon="el-icon-search"
|
|
207
|
+
v-bind="item.otherOptions ?? {}"
|
|
208
|
+
@click="handleQueryClick"
|
|
209
|
+
>
|
|
210
|
+
{{ (item.otherOptions || {}).text || '搜索' }}
|
|
211
|
+
</el-button>
|
|
212
|
+
</template>
|
|
213
|
+
<!-- 重置、搜索 按钮 -->
|
|
214
|
+
<template v-else-if="item.type === 'formButtons'">
|
|
215
|
+
<el-button
|
|
216
|
+
v-if="!item.otherOptions || item.otherOptions.reset !== false"
|
|
217
|
+
native-type="reset"
|
|
218
|
+
:size="elSize || 'mini'"
|
|
219
|
+
v-bind="item.otherOptions ?? {}"
|
|
220
|
+
>
|
|
221
|
+
{{ (item.otherOptions || {}).resetText || '重置' }}
|
|
222
|
+
</el-button>
|
|
223
|
+
<el-button
|
|
224
|
+
v-if="!item.otherOptions || item.otherOptions.submit !== false"
|
|
225
|
+
native-type="submit"
|
|
226
|
+
:size="elSize || 'mini'"
|
|
227
|
+
type="primary"
|
|
228
|
+
:icon="!item.otherOptions || item.otherOptions.showSubmitIcon !== false ? 'el-icon-search' : ''"
|
|
229
|
+
v-bind="item.otherOptions ?? {}"
|
|
230
|
+
>
|
|
231
|
+
{{ (item.otherOptions || {}).submitText || '搜索' }}
|
|
232
|
+
</el-button>
|
|
205
233
|
</template>
|
|
206
234
|
</el-form-item>
|
|
207
235
|
</el-col>
|
|
@@ -216,14 +244,14 @@
|
|
|
216
244
|
</template>
|
|
217
245
|
|
|
218
246
|
<script>
|
|
219
|
-
import PairNumberInput from
|
|
220
|
-
import CustomDatePicker from
|
|
247
|
+
import PairNumberInput from './comps/pair-number-input.vue'
|
|
248
|
+
import CustomDatePicker from './comps/custom-date-picker.vue'
|
|
221
249
|
|
|
222
250
|
export default {
|
|
223
|
-
name:
|
|
251
|
+
name: 'ByForm',
|
|
224
252
|
components: {
|
|
225
253
|
PairNumberInput,
|
|
226
|
-
CustomDatePicker
|
|
254
|
+
CustomDatePicker
|
|
227
255
|
},
|
|
228
256
|
|
|
229
257
|
props: {
|
|
@@ -233,7 +261,7 @@ export default {
|
|
|
233
261
|
},
|
|
234
262
|
labelPosition: {
|
|
235
263
|
type: String,
|
|
236
|
-
default:
|
|
264
|
+
default: 'right'
|
|
237
265
|
},
|
|
238
266
|
formItems: {
|
|
239
267
|
type: Array,
|
|
@@ -243,18 +271,18 @@ export default {
|
|
|
243
271
|
type: Object,
|
|
244
272
|
default: () => {
|
|
245
273
|
return {
|
|
246
|
-
foldField:
|
|
274
|
+
foldField: 'none', // 需要折叠字段
|
|
247
275
|
unfold: false // 默认展开?
|
|
248
276
|
}
|
|
249
277
|
}
|
|
250
278
|
},
|
|
251
279
|
labelWidth: {
|
|
252
280
|
type: String,
|
|
253
|
-
default:
|
|
281
|
+
default: '100px'
|
|
254
282
|
},
|
|
255
283
|
itemStyle: {
|
|
256
284
|
type: Object,
|
|
257
|
-
default: () => ({ padding:
|
|
285
|
+
default: () => ({ padding: '10px 40px' })
|
|
258
286
|
},
|
|
259
287
|
colLayout: {
|
|
260
288
|
type: Object,
|
|
@@ -281,7 +309,7 @@ export default {
|
|
|
281
309
|
},
|
|
282
310
|
elSize: {
|
|
283
311
|
type: String,
|
|
284
|
-
default:
|
|
312
|
+
default: 'mini'
|
|
285
313
|
}
|
|
286
314
|
},
|
|
287
315
|
|
|
@@ -289,13 +317,15 @@ export default {
|
|
|
289
317
|
return {
|
|
290
318
|
formData: this.value,
|
|
291
319
|
// 数据替换
|
|
292
|
-
replacementData: undefined
|
|
320
|
+
replacementData: undefined,
|
|
321
|
+
// 存储初始值
|
|
322
|
+
initialValues: { ...this.value }
|
|
293
323
|
}
|
|
294
324
|
},
|
|
295
325
|
|
|
296
326
|
computed: {
|
|
297
327
|
showFold() {
|
|
298
|
-
return
|
|
328
|
+
return item => {
|
|
299
329
|
if (this.isFlexible) {
|
|
300
330
|
return true
|
|
301
331
|
} else {
|
|
@@ -342,28 +372,46 @@ export default {
|
|
|
342
372
|
} else {
|
|
343
373
|
this.replacementData = { ...this.value, [item.field]: value }
|
|
344
374
|
}
|
|
345
|
-
this.$emit(
|
|
346
|
-
this.$emit(
|
|
375
|
+
this.$emit('change', { ...item, value })
|
|
376
|
+
this.$emit('input', this.replacementData)
|
|
347
377
|
},
|
|
348
378
|
handleRangeChange({ startTime, endTime }, item) {
|
|
349
379
|
if (!item.startTimeField || !item.endTimeField) return
|
|
350
|
-
|
|
380
|
+
|
|
351
381
|
if (this.replacementData) {
|
|
352
382
|
this.replacementData[item.startTimeField] = startTime
|
|
353
383
|
this.replacementData[item.endTimeField] = endTime
|
|
354
384
|
} else {
|
|
355
|
-
this.replacementData = {
|
|
356
|
-
...this.value,
|
|
357
|
-
[item.startTimeField]: startTime,
|
|
358
|
-
[item.endTimeField]: endTime
|
|
385
|
+
this.replacementData = {
|
|
386
|
+
...this.value,
|
|
387
|
+
[item.startTimeField]: startTime,
|
|
388
|
+
[item.endTimeField]: endTime
|
|
359
389
|
}
|
|
360
390
|
}
|
|
361
|
-
|
|
362
|
-
this.$emit(
|
|
391
|
+
|
|
392
|
+
this.$emit('input', this.replacementData)
|
|
363
393
|
},
|
|
364
394
|
handleQueryClick() {
|
|
365
|
-
this.$emit(
|
|
395
|
+
this.$emit('queryBtnClick')
|
|
396
|
+
},
|
|
397
|
+
|
|
398
|
+
// 表单提交
|
|
399
|
+
submit() {
|
|
400
|
+
this.$refs.formRef.validate(valid => {
|
|
401
|
+
if (valid) {
|
|
402
|
+
this.$emit('submit', this.formData)
|
|
403
|
+
} else {
|
|
404
|
+
return false
|
|
405
|
+
}
|
|
406
|
+
})
|
|
407
|
+
},
|
|
408
|
+
// 重置
|
|
409
|
+
reset() {
|
|
410
|
+
// 重置为初始值
|
|
411
|
+
this.$refs.formRef.resetFields()
|
|
412
|
+
this.$emit('input', { ...this.initialValues })
|
|
413
|
+
this.$emit('reset')
|
|
366
414
|
}
|
|
367
415
|
}
|
|
368
416
|
}
|
|
369
|
-
</script>
|
|
417
|
+
</script>
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
@input="handleInput"
|
|
8
8
|
@change="handleChange"
|
|
9
9
|
@queryBtnClick="handleQueryClick"
|
|
10
|
+
@submit="submit"
|
|
11
|
+
@reset="reset"
|
|
10
12
|
>
|
|
11
13
|
<template #header>
|
|
12
|
-
<slot name="header"
|
|
14
|
+
<slot name="header"></slot>
|
|
13
15
|
</template>
|
|
14
16
|
<template #footer>
|
|
15
17
|
<div v-if="isShowUnfoldBtn" class="fold">
|
|
@@ -17,14 +19,13 @@
|
|
|
17
19
|
</div>
|
|
18
20
|
</template>
|
|
19
21
|
<template v-for="item in getCustomItem" #[item]>
|
|
20
|
-
<slot :name="item"
|
|
22
|
+
<slot :name="item"></slot>
|
|
21
23
|
</template>
|
|
22
24
|
</by-form>
|
|
23
25
|
</div>
|
|
24
26
|
</template>
|
|
25
27
|
|
|
26
28
|
<script>
|
|
27
|
-
|
|
28
29
|
export default {
|
|
29
30
|
props: {
|
|
30
31
|
searchFormConfig: {
|
|
@@ -64,7 +65,7 @@ export default {
|
|
|
64
65
|
},
|
|
65
66
|
// 所有需要自定义的插槽
|
|
66
67
|
getCustomItem() {
|
|
67
|
-
return this.formItems.filter(f => f.type ===
|
|
68
|
+
return this.formItems.filter(f => f.type === 'custom').map(item => item.field)
|
|
68
69
|
}
|
|
69
70
|
},
|
|
70
71
|
|
|
@@ -89,13 +90,13 @@ export default {
|
|
|
89
90
|
// 2.优化二: 当用户点击重置
|
|
90
91
|
handleResetClick() {
|
|
91
92
|
this.formData = { ...this.formOriginData }
|
|
92
|
-
this.$emit(
|
|
93
|
-
this.$emit(
|
|
93
|
+
this.$emit('input', { ...this.formOriginData })
|
|
94
|
+
this.$emit('resetBtnClick')
|
|
94
95
|
},
|
|
95
96
|
|
|
96
97
|
// 3.优化三: 当用户点击搜索
|
|
97
98
|
handleQueryClick() {
|
|
98
|
-
this.$emit(
|
|
99
|
+
this.$emit('queryBtnClick')
|
|
99
100
|
},
|
|
100
101
|
|
|
101
102
|
// 4.优化四: 当用户点击展开
|
|
@@ -104,10 +105,17 @@ export default {
|
|
|
104
105
|
},
|
|
105
106
|
handleInput(value) {
|
|
106
107
|
this.formData = value
|
|
107
|
-
this.$emit(
|
|
108
|
+
this.$emit('input', { ...this.formData })
|
|
108
109
|
},
|
|
109
110
|
handleChange(event) {
|
|
110
|
-
this.$emit(
|
|
111
|
+
this.$emit('change', event)
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
submit() {
|
|
115
|
+
this.$emit('submit', this.formData)
|
|
116
|
+
},
|
|
117
|
+
reset() {
|
|
118
|
+
this.$emit('reset')
|
|
111
119
|
}
|
|
112
120
|
}
|
|
113
121
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div
|
|
3
|
+
id="pager"
|
|
4
|
+
class="pager fixed bottom-0 right-0 w-full flex justify-center items-center z-50"
|
|
5
|
+
>
|
|
3
6
|
<el-pagination
|
|
4
7
|
:current-page="pager['page']"
|
|
5
8
|
:page-size="pager['limit']"
|
|
@@ -7,8 +10,8 @@
|
|
|
7
10
|
background
|
|
8
11
|
layout="total, prev, pager, next,sizes, jumper"
|
|
9
12
|
:total="totalCount"
|
|
10
|
-
@size-change="
|
|
11
|
-
@current-change="
|
|
13
|
+
@size-change="value => handleValueChange(value, 'limit')"
|
|
14
|
+
@current-change="value => handleValueChange(value, 'page')"
|
|
12
15
|
/>
|
|
13
16
|
</div>
|
|
14
17
|
</template>
|
|
@@ -47,13 +50,13 @@ export default {
|
|
|
47
50
|
|
|
48
51
|
watch: {
|
|
49
52
|
page: {
|
|
50
|
-
handler: function(val, oldVal) {
|
|
53
|
+
handler: function (val, oldVal) {
|
|
51
54
|
this.pager.page = val
|
|
52
55
|
},
|
|
53
56
|
immediate: true
|
|
54
57
|
},
|
|
55
58
|
limit: {
|
|
56
|
-
handler: function(val, oldVal) {
|
|
59
|
+
handler: function (val, oldVal) {
|
|
57
60
|
this.pager.limit = val
|
|
58
61
|
},
|
|
59
62
|
immediate: true
|
|
@@ -61,8 +64,12 @@ export default {
|
|
|
61
64
|
},
|
|
62
65
|
mounted() {
|
|
63
66
|
// 修改分页文案
|
|
64
|
-
document.getElementsByClassName(
|
|
65
|
-
|
|
67
|
+
document.getElementsByClassName(
|
|
68
|
+
'el-pagination__jump'
|
|
69
|
+
)[0].childNodes[0].nodeValue = '跳至'
|
|
70
|
+
document.getElementsByClassName(
|
|
71
|
+
'el-pagination__jump'
|
|
72
|
+
)[0].childNodes[2].nodeValue = ''
|
|
66
73
|
},
|
|
67
74
|
|
|
68
75
|
methods: {
|
|
@@ -71,11 +78,10 @@ export default {
|
|
|
71
78
|
const values = {
|
|
72
79
|
...this.pager,
|
|
73
80
|
[field]: value,
|
|
74
|
-
page: field ===
|
|
81
|
+
page: field === 'limit' ? 1 : value
|
|
75
82
|
}
|
|
76
|
-
this.$emit(
|
|
83
|
+
this.$emit('onChange', values)
|
|
77
84
|
}
|
|
78
85
|
}
|
|
79
86
|
}
|
|
80
87
|
</script>
|
|
81
|
-
|