n20-common-lib 1.3.35 → 1.3.36
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/assets/css/el-button.scss +2 -1
- package/src/directives/VClickOutside/index.js +3 -3
- package/src/directives/VRules/index.js +10 -0
- package/src/utils/repairElementUI.js +51 -1
- package/src/utils/tableheaderFilterpanel.vue +249 -0
- package/style/index.css +3 -3
- package/style/index.css.map +1 -1
- package/theme/blue.css +3 -3
- package/theme/green.css +3 -3
- package/theme/lightBlue.css +3 -3
- package/theme/orange.css +3 -3
- package/theme/purple.css +3 -3
- package/theme/red.css +3 -3
- package/theme/yellow.css +3 -3
package/package.json
CHANGED
|
@@ -8,10 +8,10 @@ directive.install = (Vue) => {
|
|
|
8
8
|
node.context[binding.expression](event)
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
document.body.addEventListener('click', el.clickOutsideEvent)
|
|
11
|
+
document.body.addEventListener('click', el.clickOutsideEvent, binding.arg === 'capture')
|
|
12
12
|
},
|
|
13
|
-
unbind: function (el) {
|
|
14
|
-
document.body.removeEventListener('click', el.clickOutsideEvent)
|
|
13
|
+
unbind: function (el, binding) {
|
|
14
|
+
document.body.removeEventListener('click', el.clickOutsideEvent, binding.arg === 'capture')
|
|
15
15
|
}
|
|
16
16
|
})
|
|
17
17
|
}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
/* 对ElementUI硬优化 */
|
|
2
2
|
import Popper from 'element-ui/lib/utils/popper.js'
|
|
3
3
|
|
|
4
|
+
import Vue from 'vue'
|
|
5
|
+
import FilterPanel from './tableheaderFilterpanel.vue'
|
|
6
|
+
|
|
7
|
+
function hasClass(el, cls) {
|
|
8
|
+
if (!el || !cls) return false
|
|
9
|
+
if (cls.indexOf(' ') !== -1) throw new Error('className should not contain space.')
|
|
10
|
+
if (el.classList) {
|
|
11
|
+
return el.classList.contains(cls)
|
|
12
|
+
} else {
|
|
13
|
+
return (' ' + el.className + ' ').indexOf(' ' + cls + ' ') > -1
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
4
17
|
function setPropsDefault(component, props) {
|
|
5
18
|
let c_props = component.props
|
|
6
19
|
Object.keys(props).forEach((key) => {
|
|
@@ -69,7 +82,7 @@ export default function (ElementUI) {
|
|
|
69
82
|
default: true
|
|
70
83
|
}
|
|
71
84
|
})
|
|
72
|
-
|
|
85
|
+
// 设置表头最小宽度,保证表头不换行
|
|
73
86
|
setMethodsDefault(ElementUI.TableColumn, {
|
|
74
87
|
setColumnWidth(column) {
|
|
75
88
|
if (this.realWidth) {
|
|
@@ -92,4 +105,41 @@ export default function (ElementUI) {
|
|
|
92
105
|
return column
|
|
93
106
|
}
|
|
94
107
|
})
|
|
108
|
+
|
|
109
|
+
// 美化表头搜索
|
|
110
|
+
if (ElementUI.Table.components.TableHeader) {
|
|
111
|
+
setMethodsDefault(ElementUI.Table.components.TableHeader, {
|
|
112
|
+
handleFilterClick(event, column) {
|
|
113
|
+
event.stopPropagation()
|
|
114
|
+
const target = event.target
|
|
115
|
+
let cell = target.tagName === 'TH' ? target : target.parentNode
|
|
116
|
+
if (hasClass(cell, 'noclick')) return
|
|
117
|
+
cell = cell.querySelector('.el-table__column-filter-trigger') || cell
|
|
118
|
+
const table = this.$parent
|
|
119
|
+
|
|
120
|
+
let filterPanel = this.filterPanels[column.id]
|
|
121
|
+
|
|
122
|
+
if (filterPanel && column.filterOpened) {
|
|
123
|
+
filterPanel.showPopper = false
|
|
124
|
+
return
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (!filterPanel) {
|
|
128
|
+
filterPanel = new Vue(FilterPanel)
|
|
129
|
+
this.filterPanels[column.id] = filterPanel
|
|
130
|
+
if (column.filterPlacement) {
|
|
131
|
+
filterPanel.placement = column.filterPlacement
|
|
132
|
+
}
|
|
133
|
+
filterPanel.table = table
|
|
134
|
+
filterPanel.cell = cell
|
|
135
|
+
filterPanel.column = column
|
|
136
|
+
!this.$isServer && filterPanel.$mount(document.createElement('div'))
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
setTimeout(() => {
|
|
140
|
+
filterPanel.showPopper = true
|
|
141
|
+
}, 16)
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
}
|
|
95
145
|
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<transition name="el-zoom-in-top">
|
|
3
|
+
<div
|
|
4
|
+
v-if="multiple"
|
|
5
|
+
v-show="showPopper"
|
|
6
|
+
v-click-outside:capture="handleOutsideClick"
|
|
7
|
+
class="el-table-filter p-a m-t"
|
|
8
|
+
>
|
|
9
|
+
<el-input
|
|
10
|
+
v-model="searchVal"
|
|
11
|
+
class="input-w m-b"
|
|
12
|
+
placeholder="请输入"
|
|
13
|
+
clearable
|
|
14
|
+
suffix-icon="el-icon-search"
|
|
15
|
+
/>
|
|
16
|
+
<div>
|
|
17
|
+
<el-scrollbar>
|
|
18
|
+
<el-checkbox
|
|
19
|
+
v-model="allCheck"
|
|
20
|
+
:label="true"
|
|
21
|
+
:indeterminate="filteredValue.length > 0"
|
|
22
|
+
@change="allChange"
|
|
23
|
+
>{{ filters | alltextF }}</el-checkbox
|
|
24
|
+
>
|
|
25
|
+
<el-checkbox-group v-model="filteredValue" class="flex-column">
|
|
26
|
+
<template v-for="filter in filters">
|
|
27
|
+
<el-checkbox
|
|
28
|
+
v-if="filter.text.includes(searchVal)"
|
|
29
|
+
:key="filter.value"
|
|
30
|
+
class="m-t-s"
|
|
31
|
+
:label="filter.value"
|
|
32
|
+
>{{ filter | textF }}</el-checkbox
|
|
33
|
+
>
|
|
34
|
+
</template>
|
|
35
|
+
</el-checkbox-group>
|
|
36
|
+
</el-scrollbar>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="flex-box flex-c m-t-m">
|
|
39
|
+
<el-button
|
|
40
|
+
type="primary"
|
|
41
|
+
size="mini"
|
|
42
|
+
@click="
|
|
43
|
+
() => {
|
|
44
|
+
filteredValue.length ? handleConfirm() : handleReset()
|
|
45
|
+
}
|
|
46
|
+
"
|
|
47
|
+
>
|
|
48
|
+
确认
|
|
49
|
+
</el-button>
|
|
50
|
+
<el-button plain size="mini" @click="handleReset">清空</el-button>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
<div
|
|
54
|
+
v-else
|
|
55
|
+
v-show="showPopper"
|
|
56
|
+
v-click-outside:capture="handleOutsideClick"
|
|
57
|
+
class="el-table-filter p-a m-t"
|
|
58
|
+
>
|
|
59
|
+
<el-input
|
|
60
|
+
v-model="searchVal"
|
|
61
|
+
class="input-w m-b-ss"
|
|
62
|
+
placeholder="请输入"
|
|
63
|
+
clearable
|
|
64
|
+
suffix-icon="el-icon-search"
|
|
65
|
+
/>
|
|
66
|
+
<ul class="el-table-filter__list">
|
|
67
|
+
<li
|
|
68
|
+
class="el-table-filter__list-item"
|
|
69
|
+
:class="{
|
|
70
|
+
'is-active': filterValue === undefined || filterValue === null
|
|
71
|
+
}"
|
|
72
|
+
@click="handleSelect(null)"
|
|
73
|
+
>
|
|
74
|
+
{{ filters | alltextF }}
|
|
75
|
+
</li>
|
|
76
|
+
<template v-for="filter in filters">
|
|
77
|
+
<li
|
|
78
|
+
v-if="filter.text.includes(searchVal)"
|
|
79
|
+
:key="filter.value"
|
|
80
|
+
class="el-table-filter__list-item"
|
|
81
|
+
:label="filter.value"
|
|
82
|
+
:class="{ 'is-active': isActive(filter) }"
|
|
83
|
+
@click="handleSelect(filter.value)"
|
|
84
|
+
>
|
|
85
|
+
{{ filter | textF }}
|
|
86
|
+
</li>
|
|
87
|
+
</template>
|
|
88
|
+
</ul>
|
|
89
|
+
</div>
|
|
90
|
+
</transition>
|
|
91
|
+
</template>
|
|
92
|
+
|
|
93
|
+
<script>
|
|
94
|
+
import Popper from 'element-ui/lib/utils/vue-popper.js'
|
|
95
|
+
export default {
|
|
96
|
+
name: 'ElTableFilterPanelPor',
|
|
97
|
+
filters: {
|
|
98
|
+
textF(item) {
|
|
99
|
+
if (item.count === undefined) {
|
|
100
|
+
return item.text
|
|
101
|
+
} else {
|
|
102
|
+
return item.text + ' (' + item.count + ')'
|
|
103
|
+
}
|
|
104
|
+
},
|
|
105
|
+
alltextF(list = []) {
|
|
106
|
+
if (list.some((c) => c.count !== undefined)) {
|
|
107
|
+
let total = 0
|
|
108
|
+
list.forEach((c) => {
|
|
109
|
+
if (!isNaN(c.count)) {
|
|
110
|
+
total = total + Number(c.count)
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
return '全部 (' + total + ')'
|
|
114
|
+
} else {
|
|
115
|
+
return '全部'
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
mixins: [Popper],
|
|
120
|
+
props: {
|
|
121
|
+
placement: {
|
|
122
|
+
type: String,
|
|
123
|
+
default: 'bottom-end'
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
|
|
127
|
+
data() {
|
|
128
|
+
return {
|
|
129
|
+
table: null,
|
|
130
|
+
cell: null,
|
|
131
|
+
column: null,
|
|
132
|
+
searchVal: '',
|
|
133
|
+
allCheck: false
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
computed: {
|
|
138
|
+
filters() {
|
|
139
|
+
return this.column && this.column.filters
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
filterValue: {
|
|
143
|
+
get() {
|
|
144
|
+
return (this.column.filteredValue || [])[0]
|
|
145
|
+
},
|
|
146
|
+
set(value) {
|
|
147
|
+
if (this.filteredValue) {
|
|
148
|
+
console.log(this.filteredValue, 567)
|
|
149
|
+
if (typeof value !== 'undefined' && value !== null) {
|
|
150
|
+
this.filteredValue.splice(0, 1, value)
|
|
151
|
+
} else {
|
|
152
|
+
this.filteredValue.splice(0, 1)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
filteredValue: {
|
|
159
|
+
get() {
|
|
160
|
+
if (this.column) {
|
|
161
|
+
return this.column.filteredValue || []
|
|
162
|
+
}
|
|
163
|
+
return []
|
|
164
|
+
},
|
|
165
|
+
set(value) {
|
|
166
|
+
if (this.column) {
|
|
167
|
+
this.column.filteredValue = value
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
|
|
172
|
+
multiple() {
|
|
173
|
+
if (this.column) {
|
|
174
|
+
return this.column.filterMultiple
|
|
175
|
+
}
|
|
176
|
+
return true
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
mounted() {
|
|
181
|
+
this.popperElm = this.$el
|
|
182
|
+
this.referenceElm = this.cell
|
|
183
|
+
this.table.bodyWrapper.addEventListener('scroll', () => {
|
|
184
|
+
this.updatePopper()
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
this.$watch('showPopper', (value) => {
|
|
188
|
+
if (this.column) this.column.filterOpened = value
|
|
189
|
+
if (value) this.searchVal = ''
|
|
190
|
+
// if (value) {
|
|
191
|
+
// Dropdown.open(this)
|
|
192
|
+
// } else {
|
|
193
|
+
// Dropdown.close(this)
|
|
194
|
+
// }
|
|
195
|
+
})
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
methods: {
|
|
199
|
+
isActive(filter) {
|
|
200
|
+
return filter.value === this.filterValue
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
handleOutsideClick() {
|
|
204
|
+
setTimeout(() => {
|
|
205
|
+
this.showPopper = false
|
|
206
|
+
}, 16)
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
handleConfirm() {
|
|
210
|
+
this.confirmFilter(this.filteredValue)
|
|
211
|
+
this.handleOutsideClick()
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
handleReset() {
|
|
215
|
+
this.filteredValue = []
|
|
216
|
+
this.confirmFilter(this.filteredValue)
|
|
217
|
+
this.handleOutsideClick()
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
handleSelect(filterValue) {
|
|
221
|
+
this.filterValue = filterValue
|
|
222
|
+
|
|
223
|
+
if (typeof filterValue !== 'undefined' && filterValue !== null) {
|
|
224
|
+
this.confirmFilter(this.filteredValue)
|
|
225
|
+
} else {
|
|
226
|
+
this.confirmFilter([])
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
this.handleOutsideClick()
|
|
230
|
+
},
|
|
231
|
+
|
|
232
|
+
confirmFilter(filteredValue) {
|
|
233
|
+
this.table.store.commit('filterChange', {
|
|
234
|
+
column: this.column,
|
|
235
|
+
values: filteredValue
|
|
236
|
+
})
|
|
237
|
+
this.table.store.updateAllSelected()
|
|
238
|
+
},
|
|
239
|
+
|
|
240
|
+
allChange(val) {
|
|
241
|
+
if (val) {
|
|
242
|
+
this.filteredValue = this.filters.map((f) => f.value)
|
|
243
|
+
} else {
|
|
244
|
+
this.filteredValue = []
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
</script>
|