@lx-frontend/wrap-element-ui 1.0.1-beta.4 → 1.0.1-beta.6
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/README.md +45 -45
- package/package.json +14 -14
- package/src/components/AddMembers/index.vue +157 -157
- package/src/components/AuditSteps/index.vue +140 -140
- package/src/components/DemoComponent/index.vue +20 -20
- package/src/components/EditableTable/README.md +147 -147
- package/src/components/EditableTable/index.less +724 -724
- package/src/components/EditableTable/index.vue +885 -914
- package/src/components/EditableTable/types.ts +116 -116
- package/src/components/EditableTable/useCellHover.ts +71 -71
- package/src/components/EditableTable/useColumnHeaderOperation.ts +326 -325
- package/src/components/EditableTable/useDefaultOperation.ts +95 -95
- package/src/components/EditableTable/useDragSort.ts +290 -290
- package/src/components/EditableTable/usePagination.ts +30 -30
- package/src/components/EditableTable/useRowBgColor.ts +43 -50
- package/src/components/EditableTable/useViewSetting.ts +119 -119
- package/src/components/EditableTable/viewColorSelect.vue +65 -0
- package/src/components/Ellipsis/MultilineEllipsis.vue +141 -141
- package/src/components/Ellipsis/index.vue +119 -119
- package/src/components/LxTable/index.vue +296 -296
- package/src/components/PopoverForm/index.vue +66 -66
- package/src/components/SearchForm/index.vue +243 -243
- package/src/components/SearchSelect/index.vue +153 -153
- package/src/components/index.ts +24 -24
- package/src/components/singleMessage/index.ts +44 -44
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-popover :placement="placement" :disabled="isDisabled" :width="width || 300" v-model="show" trigger="click" :visible-arrow="true">
|
|
3
|
-
<div class="el-popover__header">
|
|
4
|
-
{{title}}
|
|
5
|
-
<slot name="title"></slot>
|
|
6
|
-
<el-button type="text" icon="el-icon-close" @click="handleClose"></el-button>
|
|
7
|
-
</div>
|
|
8
|
-
<slot name="form"></slot>
|
|
9
|
-
|
|
10
|
-
<div v-if="withSubmitBtn" class="el-popover__footer">
|
|
11
|
-
<slot name="footer"></slot>
|
|
12
|
-
<el-button type="primary" class="wp100" @click="handleSubmit">{{ okText }}</el-button>
|
|
13
|
-
</div>
|
|
14
|
-
<span slot='reference'>
|
|
15
|
-
<slot name='reference'></slot>
|
|
16
|
-
</span>
|
|
17
|
-
</el-popover>
|
|
18
|
-
</template>
|
|
19
|
-
<script>
|
|
20
|
-
export default {
|
|
21
|
-
name: 'PopoverForm',
|
|
22
|
-
props: {
|
|
23
|
-
title: String,
|
|
24
|
-
width: Number,
|
|
25
|
-
placement: {
|
|
26
|
-
type: String,
|
|
27
|
-
default: 'left',
|
|
28
|
-
},
|
|
29
|
-
withSubmitBtn: {
|
|
30
|
-
type: Boolean,
|
|
31
|
-
default: true,
|
|
32
|
-
},
|
|
33
|
-
isDisabled: {
|
|
34
|
-
type: Boolean,
|
|
35
|
-
default: false,
|
|
36
|
-
},
|
|
37
|
-
okText: {
|
|
38
|
-
type: String,
|
|
39
|
-
default: '确认',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
data() {
|
|
43
|
-
return {
|
|
44
|
-
show: false,
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
methods: {
|
|
48
|
-
handleClose() {
|
|
49
|
-
this.show = false;
|
|
50
|
-
},
|
|
51
|
-
handleSubmit() {
|
|
52
|
-
this.$emit('on-sure');
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
watch: {
|
|
56
|
-
show(val) {
|
|
57
|
-
this.$emit('on-change', val);
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
</script>
|
|
62
|
-
<style type="scss" scoped>
|
|
63
|
-
.wp100{
|
|
64
|
-
width: 100%;
|
|
65
|
-
}
|
|
66
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<el-popover :placement="placement" :disabled="isDisabled" :width="width || 300" v-model="show" trigger="click" :visible-arrow="true">
|
|
3
|
+
<div class="el-popover__header">
|
|
4
|
+
{{title}}
|
|
5
|
+
<slot name="title"></slot>
|
|
6
|
+
<el-button type="text" icon="el-icon-close" @click="handleClose"></el-button>
|
|
7
|
+
</div>
|
|
8
|
+
<slot name="form"></slot>
|
|
9
|
+
|
|
10
|
+
<div v-if="withSubmitBtn" class="el-popover__footer">
|
|
11
|
+
<slot name="footer"></slot>
|
|
12
|
+
<el-button type="primary" class="wp100" @click="handleSubmit">{{ okText }}</el-button>
|
|
13
|
+
</div>
|
|
14
|
+
<span slot='reference'>
|
|
15
|
+
<slot name='reference'></slot>
|
|
16
|
+
</span>
|
|
17
|
+
</el-popover>
|
|
18
|
+
</template>
|
|
19
|
+
<script>
|
|
20
|
+
export default {
|
|
21
|
+
name: 'PopoverForm',
|
|
22
|
+
props: {
|
|
23
|
+
title: String,
|
|
24
|
+
width: Number,
|
|
25
|
+
placement: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: 'left',
|
|
28
|
+
},
|
|
29
|
+
withSubmitBtn: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: true,
|
|
32
|
+
},
|
|
33
|
+
isDisabled: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: false,
|
|
36
|
+
},
|
|
37
|
+
okText: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: '确认',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
data() {
|
|
43
|
+
return {
|
|
44
|
+
show: false,
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
methods: {
|
|
48
|
+
handleClose() {
|
|
49
|
+
this.show = false;
|
|
50
|
+
},
|
|
51
|
+
handleSubmit() {
|
|
52
|
+
this.$emit('on-sure');
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
watch: {
|
|
56
|
+
show(val) {
|
|
57
|
+
this.$emit('on-change', val);
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
</script>
|
|
62
|
+
<style type="scss" scoped>
|
|
63
|
+
.wp100{
|
|
64
|
+
width: 100%;
|
|
65
|
+
}
|
|
66
|
+
</style>
|
|
@@ -1,244 +1,244 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-form
|
|
3
|
-
class="search-form"
|
|
4
|
-
:inline="isInline"
|
|
5
|
-
:label-width="width"
|
|
6
|
-
>
|
|
7
|
-
<el-form-item
|
|
8
|
-
v-for="({
|
|
9
|
-
isEmpty = true, key, type, prop, label, placeholder, candidate, filterable=false, withoutAll=false, collapseTags=false,
|
|
10
|
-
clearable=false, multiple=false, multipleLimit=0, changeCb, inputLimitCallback, slotName, dateType='date',
|
|
11
|
-
doubleIsInline = true,
|
|
12
|
-
}) in config"
|
|
13
|
-
:key="label"
|
|
14
|
-
:label="showLabel ? label : ''"
|
|
15
|
-
style="margin-right: 10px"
|
|
16
|
-
>
|
|
17
|
-
<el-input
|
|
18
|
-
v-if="type === 'input'"
|
|
19
|
-
:placeholder="placeholder ? placeholder : showLabel ? '请输入' : label"
|
|
20
|
-
:value="formData[prop]"
|
|
21
|
-
@input="val => handleInput(val, prop, inputLimitCallback)"
|
|
22
|
-
/>
|
|
23
|
-
<div
|
|
24
|
-
v-if="type === 'doubleInput'"
|
|
25
|
-
:class="doubleIsInline ? 'form-double-inline': ''"
|
|
26
|
-
>
|
|
27
|
-
<el-input
|
|
28
|
-
@input="val => handleInput(val, prop[0], inputLimitCallback)"
|
|
29
|
-
:value="formData[prop[0]]"
|
|
30
|
-
:placeholder="(placeholder || [])[0] || '请输入'"
|
|
31
|
-
/>
|
|
32
|
-
<el-input
|
|
33
|
-
:placeholder="(placeholder || [])[1] || '请输入'"
|
|
34
|
-
:value="formData[prop[1]]"
|
|
35
|
-
@input="val => handleInput(val, prop[1], inputLimitCallback)"
|
|
36
|
-
/>
|
|
37
|
-
</div>
|
|
38
|
-
<el-select
|
|
39
|
-
v-if="type === 'select'"
|
|
40
|
-
:value="formData[prop]"
|
|
41
|
-
:placeholder="placeholder ? placeholder : showLabel ? '请输入' : label"
|
|
42
|
-
:clearable="clearable"
|
|
43
|
-
@input="val => handleInput(val, prop)"
|
|
44
|
-
@change="(...args) => changeCb && changeCb(...args)"
|
|
45
|
-
:filterable="filterable"
|
|
46
|
-
:multiple="multiple"
|
|
47
|
-
:multiple-limit="multipleLimit"
|
|
48
|
-
:collapse-tags="collapseTags"
|
|
49
|
-
>
|
|
50
|
-
<el-option
|
|
51
|
-
v-if="!withoutAll"
|
|
52
|
-
value=""
|
|
53
|
-
:label="showLabel ? '全部' : label"
|
|
54
|
-
/>
|
|
55
|
-
<el-option
|
|
56
|
-
v-for="({name, value, code, id}) in candidate"
|
|
57
|
-
:key="id || name"
|
|
58
|
-
:value="value || code || id"
|
|
59
|
-
:label="name"
|
|
60
|
-
/>
|
|
61
|
-
</el-select>
|
|
62
|
-
<el-date-picker
|
|
63
|
-
v-if="type === 'datePicker'"
|
|
64
|
-
@input="val => handleInput(val, prop)"
|
|
65
|
-
@change="(...args) => changeCb && changeCb(...args)"
|
|
66
|
-
:value="formData[prop]"
|
|
67
|
-
format="yyyy-MM-dd"
|
|
68
|
-
:type="dateType"
|
|
69
|
-
range-separator="到"
|
|
70
|
-
:placeholder="dateType == 'date' ? placeholder || '选择日期' : '选择日期范围'"
|
|
71
|
-
start-placeholder="开始日期"
|
|
72
|
-
end-placeholder="结束日期"
|
|
73
|
-
/>
|
|
74
|
-
<div
|
|
75
|
-
v-if="type === 'doubleDatePicker'"
|
|
76
|
-
:class="doubleIsInline ? 'form-double-inline': ''"
|
|
77
|
-
>
|
|
78
|
-
<el-date-picker
|
|
79
|
-
@input="val => handleInput(val, prop[0], '', key)"
|
|
80
|
-
@change="(...args) => changeCb && changeCb(...args)"
|
|
81
|
-
:value="formData[prop[0]]"
|
|
82
|
-
value-format="yyyy-MM-dd"
|
|
83
|
-
format="yyyy-MM-dd"
|
|
84
|
-
type="date"
|
|
85
|
-
:placeholder="(placeholder || [])[0] || '开始日期'"
|
|
86
|
-
/>
|
|
87
|
-
<el-date-picker
|
|
88
|
-
@input="val => handleInput(val, prop[1], '', key)"
|
|
89
|
-
@change="(...args) => changeCb && changeCb(...args)"
|
|
90
|
-
:value="formData[prop[1]]"
|
|
91
|
-
value-format="yyyy-MM-dd"
|
|
92
|
-
format="yyyy-MM-dd"
|
|
93
|
-
type="date"
|
|
94
|
-
:placeholder="(placeholder || [])[1] || '结束日期'"
|
|
95
|
-
/>
|
|
96
|
-
<el-checkbox
|
|
97
|
-
:value="checkedIds[key]"
|
|
98
|
-
v-if="isEmpty"
|
|
99
|
-
@change="(value) => handelIsEmpty(prop, value, key)"
|
|
100
|
-
class="is-empty"
|
|
101
|
-
>
|
|
102
|
-
空白
|
|
103
|
-
</el-checkbox>
|
|
104
|
-
</div>
|
|
105
|
-
<slot
|
|
106
|
-
v-if="type === 'slot'"
|
|
107
|
-
:name="slotName"
|
|
108
|
-
/>
|
|
109
|
-
</el-form-item>
|
|
110
|
-
<span v-if="isShowSearchBtn">
|
|
111
|
-
<el-button
|
|
112
|
-
class="search"
|
|
113
|
-
@click="handleSearch"
|
|
114
|
-
type="primary"
|
|
115
|
-
>{{ searchText }}</el-button>
|
|
116
|
-
<el-button
|
|
117
|
-
v-if="showClear"
|
|
118
|
-
@click="handleClearParams"
|
|
119
|
-
>{{ clearText }}</el-button>
|
|
120
|
-
</span>
|
|
121
|
-
</el-form>
|
|
122
|
-
</template>
|
|
123
|
-
|
|
124
|
-
<script>
|
|
125
|
-
export default {
|
|
126
|
-
name: 'SearchForm',
|
|
127
|
-
props: {
|
|
128
|
-
isShowSearchBtn: {
|
|
129
|
-
default: true,
|
|
130
|
-
type: Boolean
|
|
131
|
-
},
|
|
132
|
-
isInline: {
|
|
133
|
-
default: false,
|
|
134
|
-
type: Boolean
|
|
135
|
-
},
|
|
136
|
-
config: {
|
|
137
|
-
required: true,
|
|
138
|
-
type: Array
|
|
139
|
-
},
|
|
140
|
-
width: {
|
|
141
|
-
default: '100px',
|
|
142
|
-
type: String
|
|
143
|
-
},
|
|
144
|
-
formData: {
|
|
145
|
-
required: true
|
|
146
|
-
},
|
|
147
|
-
showClear: {
|
|
148
|
-
default: true,
|
|
149
|
-
type: Boolean
|
|
150
|
-
},
|
|
151
|
-
showLabel: {
|
|
152
|
-
default: true,
|
|
153
|
-
type: Boolean
|
|
154
|
-
},
|
|
155
|
-
ownerClear: {
|
|
156
|
-
type: Function
|
|
157
|
-
},
|
|
158
|
-
resetCheckedIds: {
|
|
159
|
-
type: Boolean
|
|
160
|
-
},
|
|
161
|
-
searchText: {
|
|
162
|
-
default: '搜索',
|
|
163
|
-
type: String
|
|
164
|
-
},
|
|
165
|
-
clearText: {
|
|
166
|
-
default: '清除',
|
|
167
|
-
type: String
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
data () {
|
|
171
|
-
return {
|
|
172
|
-
visible: true,
|
|
173
|
-
initialData: {},
|
|
174
|
-
checkedIds: {}
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
watch: {
|
|
178
|
-
resetCheckedIds () {
|
|
179
|
-
this.config.filter(c => c.type === 'doubleDatePicker').map(t => t.key).forEach(k => {
|
|
180
|
-
this.$set(this.checkedIds, k, false)
|
|
181
|
-
})
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
mounted () {
|
|
185
|
-
this.initialData = Object.freeze({ ...this.formData })
|
|
186
|
-
},
|
|
187
|
-
methods: {
|
|
188
|
-
handleInput (val, prop, inputLimitCallback, key) {
|
|
189
|
-
if (inputLimitCallback && !inputLimitCallback(val)) return false
|
|
190
|
-
if (val) {
|
|
191
|
-
this.$set(this.checkedIds, key, false)
|
|
192
|
-
}
|
|
193
|
-
this.$emit('update:formData', { ...this.formData, [prop]: val })
|
|
194
|
-
this.$emit('isPickerEmpty', this.checkedIds)
|
|
195
|
-
},
|
|
196
|
-
|
|
197
|
-
handleSearch () {
|
|
198
|
-
this.$emit('search', this.formData)
|
|
199
|
-
},
|
|
200
|
-
|
|
201
|
-
handelIsEmpty (prop, value, key) {
|
|
202
|
-
if (value) {
|
|
203
|
-
// eslint-disable-next-line
|
|
204
|
-
this.formData[prop[0]] = '';
|
|
205
|
-
// eslint-disable-next-line
|
|
206
|
-
this.formData[prop[1]] = '';
|
|
207
|
-
}
|
|
208
|
-
this.$set(this.checkedIds, key, value)
|
|
209
|
-
this.$emit('isPickerEmpty', this.checkedIds)
|
|
210
|
-
},
|
|
211
|
-
|
|
212
|
-
handleClearParams () { // 父组件可以通过调用 `this.$refs[xx].handleClearParams()` 来清空表单数据
|
|
213
|
-
if (this.ownerClear && typeof this.ownerClear === 'function') {
|
|
214
|
-
this.ownerClear()
|
|
215
|
-
return
|
|
216
|
-
}
|
|
217
|
-
Object.keys(this.checkedIds).forEach((k) => {
|
|
218
|
-
this.checkedIds[k] = false
|
|
219
|
-
})
|
|
220
|
-
this.$emit('update:formData', { ...this.formData, ...this.initialData })
|
|
221
|
-
},
|
|
222
|
-
|
|
223
|
-
handleFormClose () {
|
|
224
|
-
this.visible = false;
|
|
225
|
-
},
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
</script>
|
|
229
|
-
<style scoped lang="less">
|
|
230
|
-
.form-double-inline {
|
|
231
|
-
display: flex;
|
|
232
|
-
& .el-input {
|
|
233
|
-
width: 100%;
|
|
234
|
-
&:not(:first-child) {
|
|
235
|
-
margin-left: 4px;
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
& .el-date-editor{
|
|
239
|
-
&:not(:first-child){
|
|
240
|
-
margin-left: 4px;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<el-form
|
|
3
|
+
class="search-form"
|
|
4
|
+
:inline="isInline"
|
|
5
|
+
:label-width="width"
|
|
6
|
+
>
|
|
7
|
+
<el-form-item
|
|
8
|
+
v-for="({
|
|
9
|
+
isEmpty = true, key, type, prop, label, placeholder, candidate, filterable=false, withoutAll=false, collapseTags=false,
|
|
10
|
+
clearable=false, multiple=false, multipleLimit=0, changeCb, inputLimitCallback, slotName, dateType='date',
|
|
11
|
+
doubleIsInline = true,
|
|
12
|
+
}) in config"
|
|
13
|
+
:key="label"
|
|
14
|
+
:label="showLabel ? label : ''"
|
|
15
|
+
style="margin-right: 10px"
|
|
16
|
+
>
|
|
17
|
+
<el-input
|
|
18
|
+
v-if="type === 'input'"
|
|
19
|
+
:placeholder="placeholder ? placeholder : showLabel ? '请输入' : label"
|
|
20
|
+
:value="formData[prop]"
|
|
21
|
+
@input="val => handleInput(val, prop, inputLimitCallback)"
|
|
22
|
+
/>
|
|
23
|
+
<div
|
|
24
|
+
v-if="type === 'doubleInput'"
|
|
25
|
+
:class="doubleIsInline ? 'form-double-inline': ''"
|
|
26
|
+
>
|
|
27
|
+
<el-input
|
|
28
|
+
@input="val => handleInput(val, prop[0], inputLimitCallback)"
|
|
29
|
+
:value="formData[prop[0]]"
|
|
30
|
+
:placeholder="(placeholder || [])[0] || '请输入'"
|
|
31
|
+
/>
|
|
32
|
+
<el-input
|
|
33
|
+
:placeholder="(placeholder || [])[1] || '请输入'"
|
|
34
|
+
:value="formData[prop[1]]"
|
|
35
|
+
@input="val => handleInput(val, prop[1], inputLimitCallback)"
|
|
36
|
+
/>
|
|
37
|
+
</div>
|
|
38
|
+
<el-select
|
|
39
|
+
v-if="type === 'select'"
|
|
40
|
+
:value="formData[prop]"
|
|
41
|
+
:placeholder="placeholder ? placeholder : showLabel ? '请输入' : label"
|
|
42
|
+
:clearable="clearable"
|
|
43
|
+
@input="val => handleInput(val, prop)"
|
|
44
|
+
@change="(...args) => changeCb && changeCb(...args)"
|
|
45
|
+
:filterable="filterable"
|
|
46
|
+
:multiple="multiple"
|
|
47
|
+
:multiple-limit="multipleLimit"
|
|
48
|
+
:collapse-tags="collapseTags"
|
|
49
|
+
>
|
|
50
|
+
<el-option
|
|
51
|
+
v-if="!withoutAll"
|
|
52
|
+
value=""
|
|
53
|
+
:label="showLabel ? '全部' : label"
|
|
54
|
+
/>
|
|
55
|
+
<el-option
|
|
56
|
+
v-for="({name, value, code, id}) in candidate"
|
|
57
|
+
:key="id || name"
|
|
58
|
+
:value="value || code || id"
|
|
59
|
+
:label="name"
|
|
60
|
+
/>
|
|
61
|
+
</el-select>
|
|
62
|
+
<el-date-picker
|
|
63
|
+
v-if="type === 'datePicker'"
|
|
64
|
+
@input="val => handleInput(val, prop)"
|
|
65
|
+
@change="(...args) => changeCb && changeCb(...args)"
|
|
66
|
+
:value="formData[prop]"
|
|
67
|
+
format="yyyy-MM-dd"
|
|
68
|
+
:type="dateType"
|
|
69
|
+
range-separator="到"
|
|
70
|
+
:placeholder="dateType == 'date' ? placeholder || '选择日期' : '选择日期范围'"
|
|
71
|
+
start-placeholder="开始日期"
|
|
72
|
+
end-placeholder="结束日期"
|
|
73
|
+
/>
|
|
74
|
+
<div
|
|
75
|
+
v-if="type === 'doubleDatePicker'"
|
|
76
|
+
:class="doubleIsInline ? 'form-double-inline': ''"
|
|
77
|
+
>
|
|
78
|
+
<el-date-picker
|
|
79
|
+
@input="val => handleInput(val, prop[0], '', key)"
|
|
80
|
+
@change="(...args) => changeCb && changeCb(...args)"
|
|
81
|
+
:value="formData[prop[0]]"
|
|
82
|
+
value-format="yyyy-MM-dd"
|
|
83
|
+
format="yyyy-MM-dd"
|
|
84
|
+
type="date"
|
|
85
|
+
:placeholder="(placeholder || [])[0] || '开始日期'"
|
|
86
|
+
/>
|
|
87
|
+
<el-date-picker
|
|
88
|
+
@input="val => handleInput(val, prop[1], '', key)"
|
|
89
|
+
@change="(...args) => changeCb && changeCb(...args)"
|
|
90
|
+
:value="formData[prop[1]]"
|
|
91
|
+
value-format="yyyy-MM-dd"
|
|
92
|
+
format="yyyy-MM-dd"
|
|
93
|
+
type="date"
|
|
94
|
+
:placeholder="(placeholder || [])[1] || '结束日期'"
|
|
95
|
+
/>
|
|
96
|
+
<el-checkbox
|
|
97
|
+
:value="checkedIds[key]"
|
|
98
|
+
v-if="isEmpty"
|
|
99
|
+
@change="(value) => handelIsEmpty(prop, value, key)"
|
|
100
|
+
class="is-empty"
|
|
101
|
+
>
|
|
102
|
+
空白
|
|
103
|
+
</el-checkbox>
|
|
104
|
+
</div>
|
|
105
|
+
<slot
|
|
106
|
+
v-if="type === 'slot'"
|
|
107
|
+
:name="slotName"
|
|
108
|
+
/>
|
|
109
|
+
</el-form-item>
|
|
110
|
+
<span v-if="isShowSearchBtn">
|
|
111
|
+
<el-button
|
|
112
|
+
class="search"
|
|
113
|
+
@click="handleSearch"
|
|
114
|
+
type="primary"
|
|
115
|
+
>{{ searchText }}</el-button>
|
|
116
|
+
<el-button
|
|
117
|
+
v-if="showClear"
|
|
118
|
+
@click="handleClearParams"
|
|
119
|
+
>{{ clearText }}</el-button>
|
|
120
|
+
</span>
|
|
121
|
+
</el-form>
|
|
122
|
+
</template>
|
|
123
|
+
|
|
124
|
+
<script>
|
|
125
|
+
export default {
|
|
126
|
+
name: 'SearchForm',
|
|
127
|
+
props: {
|
|
128
|
+
isShowSearchBtn: {
|
|
129
|
+
default: true,
|
|
130
|
+
type: Boolean
|
|
131
|
+
},
|
|
132
|
+
isInline: {
|
|
133
|
+
default: false,
|
|
134
|
+
type: Boolean
|
|
135
|
+
},
|
|
136
|
+
config: {
|
|
137
|
+
required: true,
|
|
138
|
+
type: Array
|
|
139
|
+
},
|
|
140
|
+
width: {
|
|
141
|
+
default: '100px',
|
|
142
|
+
type: String
|
|
143
|
+
},
|
|
144
|
+
formData: {
|
|
145
|
+
required: true
|
|
146
|
+
},
|
|
147
|
+
showClear: {
|
|
148
|
+
default: true,
|
|
149
|
+
type: Boolean
|
|
150
|
+
},
|
|
151
|
+
showLabel: {
|
|
152
|
+
default: true,
|
|
153
|
+
type: Boolean
|
|
154
|
+
},
|
|
155
|
+
ownerClear: {
|
|
156
|
+
type: Function
|
|
157
|
+
},
|
|
158
|
+
resetCheckedIds: {
|
|
159
|
+
type: Boolean
|
|
160
|
+
},
|
|
161
|
+
searchText: {
|
|
162
|
+
default: '搜索',
|
|
163
|
+
type: String
|
|
164
|
+
},
|
|
165
|
+
clearText: {
|
|
166
|
+
default: '清除',
|
|
167
|
+
type: String
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
data () {
|
|
171
|
+
return {
|
|
172
|
+
visible: true,
|
|
173
|
+
initialData: {},
|
|
174
|
+
checkedIds: {}
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
watch: {
|
|
178
|
+
resetCheckedIds () {
|
|
179
|
+
this.config.filter(c => c.type === 'doubleDatePicker').map(t => t.key).forEach(k => {
|
|
180
|
+
this.$set(this.checkedIds, k, false)
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
mounted () {
|
|
185
|
+
this.initialData = Object.freeze({ ...this.formData })
|
|
186
|
+
},
|
|
187
|
+
methods: {
|
|
188
|
+
handleInput (val, prop, inputLimitCallback, key) {
|
|
189
|
+
if (inputLimitCallback && !inputLimitCallback(val)) return false
|
|
190
|
+
if (val) {
|
|
191
|
+
this.$set(this.checkedIds, key, false)
|
|
192
|
+
}
|
|
193
|
+
this.$emit('update:formData', { ...this.formData, [prop]: val })
|
|
194
|
+
this.$emit('isPickerEmpty', this.checkedIds)
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
handleSearch () {
|
|
198
|
+
this.$emit('search', this.formData)
|
|
199
|
+
},
|
|
200
|
+
|
|
201
|
+
handelIsEmpty (prop, value, key) {
|
|
202
|
+
if (value) {
|
|
203
|
+
// eslint-disable-next-line
|
|
204
|
+
this.formData[prop[0]] = '';
|
|
205
|
+
// eslint-disable-next-line
|
|
206
|
+
this.formData[prop[1]] = '';
|
|
207
|
+
}
|
|
208
|
+
this.$set(this.checkedIds, key, value)
|
|
209
|
+
this.$emit('isPickerEmpty', this.checkedIds)
|
|
210
|
+
},
|
|
211
|
+
|
|
212
|
+
handleClearParams () { // 父组件可以通过调用 `this.$refs[xx].handleClearParams()` 来清空表单数据
|
|
213
|
+
if (this.ownerClear && typeof this.ownerClear === 'function') {
|
|
214
|
+
this.ownerClear()
|
|
215
|
+
return
|
|
216
|
+
}
|
|
217
|
+
Object.keys(this.checkedIds).forEach((k) => {
|
|
218
|
+
this.checkedIds[k] = false
|
|
219
|
+
})
|
|
220
|
+
this.$emit('update:formData', { ...this.formData, ...this.initialData })
|
|
221
|
+
},
|
|
222
|
+
|
|
223
|
+
handleFormClose () {
|
|
224
|
+
this.visible = false;
|
|
225
|
+
},
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
</script>
|
|
229
|
+
<style scoped lang="less">
|
|
230
|
+
.form-double-inline {
|
|
231
|
+
display: flex;
|
|
232
|
+
& .el-input {
|
|
233
|
+
width: 100%;
|
|
234
|
+
&:not(:first-child) {
|
|
235
|
+
margin-left: 4px;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
& .el-date-editor{
|
|
239
|
+
&:not(:first-child){
|
|
240
|
+
margin-left: 4px;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
244
|
</style>
|