fast-crud-ui3 1.5.16 → 1.5.18-beta
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/lib/assets/fonts/iconfont.d.ts +0 -0
- package/lib/components/checkbox-group/index.d.ts +2 -0
- package/lib/components/checkbox-group/src/fast-checkbox-group.d.ts +72 -0
- package/lib/components/content-dialog/index.d.ts +2 -0
- package/lib/components/content-dialog/src/fast-cell-content.d.ts +83 -0
- package/lib/components/json-viewer/index.d.ts +2 -0
- package/lib/components/json-viewer/src/fast-json-viewer.d.ts +48 -0
- package/lib/components/mapping.d.ts +5 -0
- package/lib/components/object-picker/index.d.ts +2 -0
- package/lib/components/object-picker/src/fast-object-picker.d.ts +132 -0
- package/lib/components/select/index.d.ts +2 -0
- package/lib/components/select/src/fast-select.d.ts +83 -0
- package/lib/components/table/index.d.ts +2 -0
- package/lib/components/table/src/RowConfirm.d.ts +39 -0
- package/lib/components/table/src/dynamic-filter-form.d.ts +118 -0
- package/lib/components/table/src/dynamic-filter-list.d.ts +57 -0
- package/lib/components/table/src/easy-filter.d.ts +118 -0
- package/lib/components/table/src/export-confirm.d.ts +12 -0
- package/lib/components/table/src/quick-filter-form.d.ts +42 -0
- package/lib/components/table/src/row-form.d.ts +33 -0
- package/lib/components/table/src/stored-filter-manager.d.ts +55 -0
- package/lib/components/table/src/stored-filter.d.ts +37 -0
- package/lib/components/table/src/table-head-cell.d.ts +9 -0
- package/lib/components/table/src/table.d.ts +507 -0
- package/lib/components/table/src/util.d.ts +77 -0
- package/lib/components/table-column/config.d.ts +5 -0
- package/lib/components/table-column/index.d.ts +2 -0
- package/lib/components/table-column/src/table-column.d.ts +256 -0
- package/lib/components/table-column-date-picker/config.d.ts +5 -0
- package/lib/components/table-column-date-picker/index.d.ts +2 -0
- package/lib/components/table-column-date-picker/src/table-column-date-picker.d.ts +173 -0
- package/lib/components/table-column-file/config.d.ts +5 -0
- package/lib/components/table-column-file/index.d.ts +2 -0
- package/lib/components/table-column-file/src/table-column-file.d.ts +285 -0
- package/lib/components/table-column-img/config.d.ts +5 -0
- package/lib/components/table-column-img/index.d.ts +2 -0
- package/lib/components/table-column-img/src/table-column-img.d.ts +285 -0
- package/lib/components/table-column-input/config.d.ts +5 -0
- package/lib/components/table-column-input/index.d.ts +2 -0
- package/lib/components/table-column-input/src/table-column-input.d.ts +173 -0
- package/lib/components/table-column-number/config.d.ts +5 -0
- package/lib/components/table-column-number/index.d.ts +2 -0
- package/lib/components/table-column-number/src/table-column-number.d.ts +173 -0
- package/lib/components/table-column-object/config.d.ts +5 -0
- package/lib/components/table-column-object/index.d.ts +2 -0
- package/lib/components/table-column-object/src/table-column-object.d.ts +315 -0
- package/lib/components/table-column-select/config.d.ts +5 -0
- package/lib/components/table-column-select/index.d.ts +2 -0
- package/lib/components/table-column-select/src/table-column-select.d.ts +276 -0
- package/lib/components/table-column-switch/config.d.ts +5 -0
- package/lib/components/table-column-switch/index.d.ts +2 -0
- package/lib/components/table-column-switch/src/table-column-switch.d.ts +175 -0
- package/lib/components/table-column-textarea/config.d.ts +5 -0
- package/lib/components/table-column-textarea/index.d.ts +2 -0
- package/lib/components/table-column-textarea/src/table-column-textarea.d.ts +173 -0
- package/lib/components/table-column-time-picker/config.d.ts +5 -0
- package/lib/components/table-column-time-picker/index.d.ts +2 -0
- package/lib/components/table-column-time-picker/src/table-column-time-picker.d.ts +173 -0
- package/lib/components/upload/index.d.ts +2 -0
- package/lib/components/upload/src/fast-upload.d.ts +120 -0
- package/lib/fast-crud-ui3.cjs.js +44 -17
- package/lib/fast-crud-ui3.es.js +9991 -5946
- package/lib/fast-crud-ui3.umd.js +44 -17
- package/lib/global.d.ts +42 -0
- package/lib/index.d.ts +56 -0
- package/lib/mixins/table-column.d.ts +104 -0
- package/lib/mixins/upload.d.ts +15 -0
- package/lib/model/cond.d.ts +48 -0
- package/lib/model/editComponentConfig.d.ts +25 -0
- package/lib/model/fastTableOption.d.ts +513 -0
- package/lib/model/filterComponentConfig.d.ts +55 -0
- package/lib/model/opt.d.ts +20 -0
- package/lib/model/order.d.ts +28 -0
- package/lib/model/pageQuery.d.ts +43 -0
- package/lib/model/query.d.ts +101 -0
- package/lib/model/rel.d.ts +5 -0
- package/lib/style.css +1 -1
- package/lib/util/cache.d.ts +17 -0
- package/lib/util/dialog.d.ts +49 -0
- package/lib/util/escape.d.ts +7 -0
- package/lib/util/http.d.ts +8 -0
- package/lib/util/pick.d.ts +9 -0
- package/lib/util/util.d.ts +311 -0
- package/package.json +19 -5
- package/packages/assets/fonts/iconfont.css +163 -0
- package/packages/assets/fonts/iconfont.js +1 -0
- package/packages/assets/fonts/iconfont.ttf +0 -0
- package/packages/assets/fonts/iconfont.woff +0 -0
- package/packages/assets/fonts/iconfont.woff2 +0 -0
- package/packages/components/checkbox-group/index.js +7 -0
- package/packages/components/checkbox-group/src/fast-checkbox-group.vue +83 -0
- package/packages/components/content-dialog/index.js +7 -0
- package/packages/components/content-dialog/src/fast-cell-content.vue +115 -0
- package/packages/components/json-viewer/index.js +7 -0
- package/packages/components/json-viewer/src/fast-json-viewer.vue +54 -0
- package/packages/components/mapping.js +95 -0
- package/packages/components/object-picker/index.js +7 -0
- package/packages/components/object-picker/src/fast-object-picker.vue +170 -0
- package/packages/components/select/index.js +7 -0
- package/packages/components/select/src/fast-select.vue +90 -0
- package/packages/components/table/index.js +7 -0
- package/packages/components/table/src/RowConfirm.vue +87 -0
- package/packages/components/table/src/dynamic-filter-form.vue +253 -0
- package/packages/components/table/src/dynamic-filter-list.vue +172 -0
- package/packages/components/table/src/easy-filter.vue +129 -0
- package/packages/components/table/src/export-confirm.vue +55 -0
- package/packages/components/table/src/quick-filter-form.vue +140 -0
- package/packages/components/table/src/row-form.vue +137 -0
- package/packages/components/table/src/stored-filter-manager.vue +240 -0
- package/packages/components/table/src/stored-filter.vue +180 -0
- package/packages/components/table/src/table-head-cell.vue +41 -0
- package/packages/components/table/src/table.vue +1309 -0
- package/packages/components/table/src/util.js +496 -0
- package/packages/components/table-column/config.js +64 -0
- package/packages/components/table-column/index.js +7 -0
- package/packages/components/table-column/src/table-column.vue +44 -0
- package/packages/components/table-column-date-picker/config.js +139 -0
- package/packages/components/table-column-date-picker/index.js +7 -0
- package/packages/components/table-column-date-picker/src/table-column-date-picker.vue +54 -0
- package/packages/components/table-column-file/config.js +83 -0
- package/packages/components/table-column-file/index.js +7 -0
- package/packages/components/table-column-file/src/table-column-file.vue +79 -0
- package/packages/components/table-column-img/config.js +83 -0
- package/packages/components/table-column-img/index.js +7 -0
- package/packages/components/table-column-img/src/table-column-img.vue +82 -0
- package/packages/components/table-column-input/config.js +77 -0
- package/packages/components/table-column-input/index.js +7 -0
- package/packages/components/table-column-input/src/table-column-input.vue +60 -0
- package/packages/components/table-column-number/config.js +89 -0
- package/packages/components/table-column-number/index.js +7 -0
- package/packages/components/table-column-number/src/table-column-number.vue +54 -0
- package/packages/components/table-column-object/config.js +66 -0
- package/packages/components/table-column-object/index.js +7 -0
- package/packages/components/table-column-object/src/table-column-object.vue +75 -0
- package/packages/components/table-column-select/config.js +67 -0
- package/packages/components/table-column-select/index.js +7 -0
- package/packages/components/table-column-select/src/table-column-select.vue +101 -0
- package/packages/components/table-column-switch/config.js +55 -0
- package/packages/components/table-column-switch/index.js +7 -0
- package/packages/components/table-column-switch/src/table-column-switch.vue +82 -0
- package/packages/components/table-column-textarea/config.js +77 -0
- package/packages/components/table-column-textarea/index.js +7 -0
- package/packages/components/table-column-textarea/src/table-column-textarea.vue +56 -0
- package/packages/components/table-column-time-picker/config.js +62 -0
- package/packages/components/table-column-time-picker/index.js +7 -0
- package/packages/components/table-column-time-picker/src/table-column-time-picker.vue +53 -0
- package/packages/components/upload/index.js +7 -0
- package/packages/components/upload/src/fast-upload.vue +272 -0
- package/packages/global.d.ts +42 -0
- package/packages/index.js +145 -0
- package/packages/mixins/table-column.js +133 -0
- package/packages/mixins/upload.js +14 -0
- package/packages/model/cond.js +74 -0
- package/packages/model/editComponentConfig.js +72 -0
- package/packages/model/fastTableOption.js +769 -0
- package/packages/model/filterComponentConfig.js +191 -0
- package/packages/model/opt.js +21 -0
- package/packages/model/order.js +37 -0
- package/packages/model/pageQuery.js +52 -0
- package/packages/model/query.js +161 -0
- package/packages/model/rel.js +5 -0
- package/packages/style.scss +5 -0
- package/packages/util/cache.js +92 -0
- package/packages/util/dialog.js +133 -0
- package/packages/util/escape.js +34 -0
- package/packages/util/http.js +18 -0
- package/packages/util/pick.js +92 -0
- package/packages/util/util.js +892 -0
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="fc-stored-filter-manager">
|
|
3
|
+
<div class="fc-stored-filter-manager-btns">
|
|
4
|
+
<el-button :icon="Plus" type="primary" plain @click="addStoreGroup">添加</el-button>
|
|
5
|
+
<el-button type="success" plain @click="saveStoreGroup">保存</el-button>
|
|
6
|
+
</div>
|
|
7
|
+
<template v-for="g in groups">
|
|
8
|
+
<el-card class="fc-stored-filter-item" shadow="hover" v-if="hiddenBuildIn === false || g.buildIn === false">
|
|
9
|
+
<template #header>
|
|
10
|
+
<div class="fc-stored-filter-item-header">
|
|
11
|
+
<div style="display: flex">
|
|
12
|
+
<el-input class="fc-stored-filter-item-label" placeholder="请输入组合名" v-model="g.label"
|
|
13
|
+
:disabled="g.buildIn"/>
|
|
14
|
+
<el-alert type="warning" :closable="false" show-icon v-if="!g.compatible">此筛选组不兼容, 请修改
|
|
15
|
+
</el-alert>
|
|
16
|
+
</div>
|
|
17
|
+
<el-button type="danger" link @click="delStoreGroup(g)" v-if="!g.buildIn">删除</el-button>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
<div class="fc-dynamic-filter-list">
|
|
21
|
+
<el-popover class="fc-stored-filter-item-cond" popper-style="max-width: none; width: auto; z-index: 3000"
|
|
22
|
+
v-for="(f, index) in g.filters" :key="f.col + '.' + index" :disabled="g.buildIn">
|
|
23
|
+
<template v-slot:reference>
|
|
24
|
+
<div class="fc-dynamic-filter-btns">
|
|
25
|
+
<el-button link class="fc-dynamic-filter-open-btn">
|
|
26
|
+
{{ f.condMsg }}
|
|
27
|
+
</el-button>
|
|
28
|
+
<el-button link class="fc-dynamic-filter-del-btn" :icon="Close" v-if="!g.buildIn"
|
|
29
|
+
@click.stop="delConfig(index, g.filters)"></el-button>
|
|
30
|
+
|
|
31
|
+
<span style="margin-right: 10px; color: #909090;">且</span>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
<component class="component" :is="f.component" v-model="f.val" v-bind="f.props" :teleported="false" @change="onChange(f)"
|
|
35
|
+
v-if="f.opt !== Opt.NULL && f.opt !== Opt.NNULL && f.opt !== Opt.EMPTY && f.opt !== Opt.NEMPTY"/>
|
|
36
|
+
</el-popover>
|
|
37
|
+
|
|
38
|
+
<el-dropdown max-height="200px" @command="(col) => handleAddCond(col, g)" v-if="!g.buildIn">
|
|
39
|
+
<el-link :icon="Plus"></el-link>
|
|
40
|
+
<template #dropdown>
|
|
41
|
+
<el-dropdown-menu>
|
|
42
|
+
<el-dropdown-item v-for="col in colsOption" :command="col.value">{{ col.label }}</el-dropdown-item>
|
|
43
|
+
</el-dropdown-menu>
|
|
44
|
+
</template>
|
|
45
|
+
</el-dropdown>
|
|
46
|
+
</div>
|
|
47
|
+
</el-card>
|
|
48
|
+
</template>
|
|
49
|
+
<el-button style="text-decoration: underline;" link @click="() => hiddenBuildIn = !hiddenBuildIn">
|
|
50
|
+
{{ hiddenBuildIn ? '显示' : '隐藏' }}内置的组合筛选项
|
|
51
|
+
</el-button>
|
|
52
|
+
</div>
|
|
53
|
+
</template>
|
|
54
|
+
|
|
55
|
+
<script>
|
|
56
|
+
import {Close, Plus} from "@element-plus/icons-vue";
|
|
57
|
+
import FastTableOption from '../../../model/fastTableOption.js'
|
|
58
|
+
import Opt from '../../../model/opt.js'
|
|
59
|
+
import {buildStoredFilterComponent, setCustomFilterGroups} from "./util.js";
|
|
60
|
+
import * as util from "../../../util/util.js";
|
|
61
|
+
import {ElMessage} from "element-plus";
|
|
62
|
+
|
|
63
|
+
export default {
|
|
64
|
+
name: "stored-filter-manager",
|
|
65
|
+
emits: ['ok'],
|
|
66
|
+
props: {
|
|
67
|
+
tableOption: FastTableOption,
|
|
68
|
+
columnConfig: Object,
|
|
69
|
+
storeGroups: Array
|
|
70
|
+
},
|
|
71
|
+
data() {
|
|
72
|
+
const groups = util.deepClone(this.storeGroups) // 避免修改外部
|
|
73
|
+
groups.forEach(g => {
|
|
74
|
+
if (util.isFunction(g.filters)) { // 瞬化某些filter
|
|
75
|
+
g.filters = g.filters()
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
return {
|
|
79
|
+
hiddenBuildIn: true,
|
|
80
|
+
groups: groups.sort((a, b) => a.buildIn - b.buildIn)
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
computed: {
|
|
84
|
+
Plus() {
|
|
85
|
+
return Plus
|
|
86
|
+
},
|
|
87
|
+
Close() {
|
|
88
|
+
return Close
|
|
89
|
+
},
|
|
90
|
+
Opt() {
|
|
91
|
+
return Opt
|
|
92
|
+
},
|
|
93
|
+
colsOption() {
|
|
94
|
+
return Object.entries(this.columnConfig).map(([col, config]) => {
|
|
95
|
+
const {customConfig: {label}} = config
|
|
96
|
+
return {value: col, label: label}
|
|
97
|
+
})
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
async created() {
|
|
101
|
+
// 刷新条件显示
|
|
102
|
+
for (let i = 0; i < this.groups.length; i++) {
|
|
103
|
+
for (let j = 0; j < this.groups[i].filters.length; j++) {
|
|
104
|
+
await this.groups[i].filters[j].updateCondMsg()
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
methods: {
|
|
109
|
+
onChange(filter) {
|
|
110
|
+
filter.updateCondMsg()
|
|
111
|
+
},
|
|
112
|
+
async handleAddCond(col, storeGroup) {
|
|
113
|
+
const filter = buildStoredFilterComponent(col, this.columnConfig, this.tableOption)
|
|
114
|
+
if (!util.isEmpty(filter)) {
|
|
115
|
+
await filter.updateCondMsg()
|
|
116
|
+
storeGroup.filters.push(filter)
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
delConfig(index, filters) {
|
|
120
|
+
filters.splice(index, 1)
|
|
121
|
+
},
|
|
122
|
+
addStoreGroup() {
|
|
123
|
+
this.groups.unshift({
|
|
124
|
+
label: '',
|
|
125
|
+
filters: [],
|
|
126
|
+
buildIn: false,
|
|
127
|
+
compatible: true
|
|
128
|
+
})
|
|
129
|
+
},
|
|
130
|
+
/**
|
|
131
|
+
* 删除存筛: 只能删除自定义
|
|
132
|
+
*/
|
|
133
|
+
delStoreGroup(group) {
|
|
134
|
+
this.groups = this.groups.filter(g => g !== group)
|
|
135
|
+
},
|
|
136
|
+
/**
|
|
137
|
+
* 保存自定义存筛到localStorage中,注意: 只保存自定义的
|
|
138
|
+
*/
|
|
139
|
+
saveStoreGroup() {
|
|
140
|
+
const toBeSavedGroups = this.groups.filter(g => g.buildIn === false)
|
|
141
|
+
const labels = this.groups.map(g => g.label)
|
|
142
|
+
const duplicateLabel = labels.filter((l, i) => labels.indexOf(l) !== i)
|
|
143
|
+
// check
|
|
144
|
+
util.assertTip(util.isEmpty(duplicateLabel), '组合名重复,请修改:' + [...new Set(duplicateLabel)])
|
|
145
|
+
for (let i = 0; i < toBeSavedGroups.length; i++) {
|
|
146
|
+
const {label, filters} = toBeSavedGroups[i]
|
|
147
|
+
util.assertTip(!util.isEmpty(label), '请填写组合名')
|
|
148
|
+
util.assertTip(label.length <= 10, `组合名长度不得超过10:${label}`)
|
|
149
|
+
util.assertTip(!util.isEmpty(filters), `请为“${label}”配置筛选项`)
|
|
150
|
+
util.assertTip(filters.every(f => f.isEffective()), `“${label}”存在无效筛选项`)
|
|
151
|
+
}
|
|
152
|
+
setCustomFilterGroups(this.tableOption, toBeSavedGroups)
|
|
153
|
+
ElMessage.success('保存成功')
|
|
154
|
+
this.$emit('ok')
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
</script>
|
|
159
|
+
|
|
160
|
+
<style scoped lang="scss">
|
|
161
|
+
.fc-stored-filter-manager {
|
|
162
|
+
.fc-stored-filter-manager-btns {
|
|
163
|
+
margin-bottom: 20px;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
.fc-stored-filter-item {
|
|
167
|
+
margin: 10px 0;
|
|
168
|
+
|
|
169
|
+
:deep(.fc-stored-filter-item-header) {
|
|
170
|
+
display: flex;
|
|
171
|
+
justify-content: space-between;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
.fc-stored-filter-item-label {
|
|
175
|
+
width: 200px;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
.fc-dynamic-filter-list {
|
|
180
|
+
display: flex;
|
|
181
|
+
flex-wrap: wrap;
|
|
182
|
+
column-gap: 5px;
|
|
183
|
+
align-items: center;
|
|
184
|
+
|
|
185
|
+
.fc-dynamic-filter-btns {
|
|
186
|
+
display: flex;
|
|
187
|
+
align-items: center;
|
|
188
|
+
|
|
189
|
+
&:hover {
|
|
190
|
+
.fc-dynamic-filter-open-btn {
|
|
191
|
+
text-decoration: underline;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
.fc-dynamic-filter-del-btn {
|
|
195
|
+
//display: inline-block;
|
|
196
|
+
visibility: visible;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.fc-dynamic-filter-open-btn {
|
|
202
|
+
color: gray;
|
|
203
|
+
padding: 3px 5px;
|
|
204
|
+
border: 1px solid #cacaca;
|
|
205
|
+
border-radius: 3px;
|
|
206
|
+
font-size: 15px !important;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.fc-dynamic-filter-del-btn {
|
|
210
|
+
visibility: hidden;
|
|
211
|
+
margin-left: 5px;
|
|
212
|
+
padding: 5px 0;
|
|
213
|
+
color: #8d4343;
|
|
214
|
+
font-size: 13px !important;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
.fc-dynamic-filter-clear-btn {
|
|
218
|
+
font-size: 13px !important;
|
|
219
|
+
margin-left: 3px;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.component {
|
|
224
|
+
margin: 10px 0;
|
|
225
|
+
max-width: 420px;
|
|
226
|
+
max-height: 300px;
|
|
227
|
+
overflow: auto;
|
|
228
|
+
|
|
229
|
+
:deep(.fc-checkbox-group) {
|
|
230
|
+
display: block;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
:deep(.fc-checkbox-group .el-checkbox) {
|
|
234
|
+
display: block;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
</style>
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="fc-stored-btn">
|
|
3
|
+
<el-dropdown :size="size">
|
|
4
|
+
<el-button type="primary" :size="size">
|
|
5
|
+
<span v-if="showLabel">{{ showLabel }}</span>
|
|
6
|
+
<el-icon v-else>
|
|
7
|
+
<Star/>
|
|
8
|
+
</el-icon>
|
|
9
|
+
<el-icon>
|
|
10
|
+
<arrow-down/>
|
|
11
|
+
</el-icon>
|
|
12
|
+
</el-button>
|
|
13
|
+
<template #dropdown>
|
|
14
|
+
<el-dropdown-menu>
|
|
15
|
+
<!-- <el-dropdown-item @click="clear">清空</el-dropdown-item>-->
|
|
16
|
+
<el-dropdown-item v-for="item in storeGroups" :key="item.label"
|
|
17
|
+
:style="{color: (groupLabels.indexOf(item.label) > -1) ? '#3f99f5 !important' : ''}"
|
|
18
|
+
:disabled="!item.compatible"
|
|
19
|
+
@click="handleClick(item, $event)">
|
|
20
|
+
<el-icon v-show="groupLabels.indexOf(item.label) > -1">
|
|
21
|
+
<Select/>
|
|
22
|
+
</el-icon>
|
|
23
|
+
<span>{{ item.label }}</span>
|
|
24
|
+
</el-dropdown-item>
|
|
25
|
+
<el-dropdown-item divided @click="toCustom">自定义</el-dropdown-item>
|
|
26
|
+
</el-dropdown-menu>
|
|
27
|
+
</template>
|
|
28
|
+
</el-dropdown>
|
|
29
|
+
</div>
|
|
30
|
+
</template>
|
|
31
|
+
<script>
|
|
32
|
+
import {nextTick} from "vue"
|
|
33
|
+
import {dayjs} from "element-plus"
|
|
34
|
+
import {ArrowDown, Star, Select} from "@element-plus/icons-vue"
|
|
35
|
+
import * as util from "../../../util/util.js"
|
|
36
|
+
import FastTableOption from "../../../model/fastTableOption.js"
|
|
37
|
+
import {openDialog} from "../../../util/dialog.js";
|
|
38
|
+
import StoredFilterManager from "./stored-filter-manager.vue";
|
|
39
|
+
import {buildFilterGroups, buildStoredFilterComponent, getCustomFilterGroups} from "./util.js"
|
|
40
|
+
|
|
41
|
+
export default {
|
|
42
|
+
name: "stored-filter",
|
|
43
|
+
components: {ArrowDown, Star, Select},
|
|
44
|
+
emits: ['change', 'update:modelValue'],
|
|
45
|
+
props: {
|
|
46
|
+
// 存筛label名组成的数组, 表示勾选项
|
|
47
|
+
groupLabels: Array,
|
|
48
|
+
size: String,
|
|
49
|
+
tableOption: FastTableOption,
|
|
50
|
+
columnConfig: Object
|
|
51
|
+
},
|
|
52
|
+
data() {
|
|
53
|
+
return {
|
|
54
|
+
storeGroups: [], // 存筛分组列表。元素格式: {label: '存筛名', filters: [{..}], buildIn: false, compatible: true}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
computed: {
|
|
58
|
+
showLabel() {
|
|
59
|
+
if (util.isEmpty(this.groupLabels)) {
|
|
60
|
+
return ''
|
|
61
|
+
}
|
|
62
|
+
const firstLabel = this.groupLabels[0]
|
|
63
|
+
return firstLabel + (this.groupLabels.length > 1 ? `+${this.groupLabels.length - 1}` : '')
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
mounted() {
|
|
67
|
+
nextTick(() => this.init())
|
|
68
|
+
},
|
|
69
|
+
methods: {
|
|
70
|
+
init() {
|
|
71
|
+
this.storeGroups.length = 0
|
|
72
|
+
this.initCreateTimeFilter() // 基于创建时间构造内置存筛
|
|
73
|
+
this.initDevCustomFilter() // 构造开发者预定义存筛
|
|
74
|
+
this.initUserCustomFilter() // 构造用户自定义存筛
|
|
75
|
+
this.storeGroups.sort((a, b) => b.compatible - a.compatible)
|
|
76
|
+
},
|
|
77
|
+
initCreateTimeFilter() {
|
|
78
|
+
const {createTimeField} = this.tableOption
|
|
79
|
+
if (util.isEmpty(createTimeField)) {
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
const getFilters = (type) => {
|
|
83
|
+
const createTimeFilter = buildStoredFilterComponent(createTimeField, this.columnConfig, this.tableOption)
|
|
84
|
+
if (util.isNull(createTimeFilter)) {
|
|
85
|
+
return []
|
|
86
|
+
}
|
|
87
|
+
const {props: {valueFormat}} = createTimeFilter
|
|
88
|
+
const end = new Date()
|
|
89
|
+
let start
|
|
90
|
+
if (type === 'day') {
|
|
91
|
+
start = util.getBeginOfDate(end)
|
|
92
|
+
} else if (type === 'week') {
|
|
93
|
+
start = util.getBeginOfWeek(end)
|
|
94
|
+
} else if (type === 'month') {
|
|
95
|
+
start = util.getBeginOfMonth(end)
|
|
96
|
+
}
|
|
97
|
+
createTimeFilter.val = [dayjs(start).format(valueFormat), dayjs(end).format(valueFormat)]
|
|
98
|
+
return [createTimeFilter]
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
this.storeGroups.push({
|
|
102
|
+
label: '当天新建', buildIn: true, compatible: true, filters: () => {
|
|
103
|
+
return getFilters('day')
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
this.storeGroups.push({
|
|
107
|
+
label: '当周新建', buildIn: true, compatible: true, filters: () => {
|
|
108
|
+
return getFilters('week')
|
|
109
|
+
}
|
|
110
|
+
})
|
|
111
|
+
this.storeGroups.push({
|
|
112
|
+
label: '当月新建', buildIn: true, compatible: true, filters: () => {
|
|
113
|
+
return getFilters('month')
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
},
|
|
117
|
+
initDevCustomFilter() {
|
|
118
|
+
const {condGroups = []} = this.tableOption
|
|
119
|
+
const filterGroups = buildFilterGroups(this.tableOption, this.columnConfig, condGroups, true)
|
|
120
|
+
this.storeGroups.push(...filterGroups)
|
|
121
|
+
},
|
|
122
|
+
initUserCustomFilter() {
|
|
123
|
+
const filterGroups = getCustomFilterGroups(this.tableOption, this.columnConfig)
|
|
124
|
+
this.storeGroups.push(...filterGroups)
|
|
125
|
+
},
|
|
126
|
+
handleClick(group, e) {
|
|
127
|
+
const idx = this.groupLabels.indexOf(group.label)
|
|
128
|
+
if (idx > -1) { // 取消
|
|
129
|
+
this.groupLabels.splice(idx, 1)
|
|
130
|
+
} else {
|
|
131
|
+
if (!(e.ctrlKey || e.metaKey)) { // 支持按住ctrl/command点击可以选多个
|
|
132
|
+
this.groupLabels.length = 0
|
|
133
|
+
}
|
|
134
|
+
this.groupLabels.push(group.label)
|
|
135
|
+
}
|
|
136
|
+
this.$emit('change')
|
|
137
|
+
},
|
|
138
|
+
toCustom() {
|
|
139
|
+
openDialog({
|
|
140
|
+
component: StoredFilterManager,
|
|
141
|
+
props: {
|
|
142
|
+
tableOption: this.tableOption,
|
|
143
|
+
columnConfig: this.columnConfig,
|
|
144
|
+
storeGroups: this.storeGroups
|
|
145
|
+
},
|
|
146
|
+
dialogProps: {
|
|
147
|
+
title: '自定义组合筛选',
|
|
148
|
+
width: '60%'
|
|
149
|
+
}
|
|
150
|
+
}).then(() => {
|
|
151
|
+
this.init()
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
},
|
|
155
|
+
clear() {
|
|
156
|
+
this.groupLabels.length = 0
|
|
157
|
+
this.$emit('change')
|
|
158
|
+
},
|
|
159
|
+
/**
|
|
160
|
+
* 获取生效的筛选项, 通过勾选的存筛组(groupLabels),从storeGroups中解析出生效的filters并返回
|
|
161
|
+
* @return {*[]}
|
|
162
|
+
*/
|
|
163
|
+
getStoreFilters() {
|
|
164
|
+
const effectFilters = []
|
|
165
|
+
if (util.isEmpty(this.storeGroups)) {
|
|
166
|
+
this.init()
|
|
167
|
+
}
|
|
168
|
+
for (const g of this.storeGroups) {
|
|
169
|
+
if (this.groupLabels.indexOf(g.label) === -1) {
|
|
170
|
+
continue
|
|
171
|
+
}
|
|
172
|
+
const filters = util.isFunction(g.filters) ? g.filters.call(this.tableOption.context) : g.filters
|
|
173
|
+
util.assert(util.isArray(filters), `the filters prop of group(${g.label}) is wrong type, it should be a array, or a function that return a array`)
|
|
174
|
+
effectFilters.push(...filters)
|
|
175
|
+
}
|
|
176
|
+
return effectFilters
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
</script>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="fc-table-column-head-cell" :class="{'filter': column.filter !== false && column.dynamicFilter !== false}">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
<el-icon v-if="column.order === 'asc' || column.order === 'desc'" class="sort-icon">
|
|
5
|
+
<SortUp v-if="column.order === 'asc'"/>
|
|
6
|
+
<SortDown v-else/>
|
|
7
|
+
</el-icon>
|
|
8
|
+
</div>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script>
|
|
12
|
+
import {SortDown, SortUp} from "@element-plus/icons-vue"
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
name: "fast-table-head-cell",
|
|
16
|
+
components: {SortDown, SortUp},
|
|
17
|
+
props: {
|
|
18
|
+
column: Object
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<style scoped lang="scss">
|
|
24
|
+
.fc-table-column-head-cell {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
white-space: nowrap;
|
|
29
|
+
height: 38px;
|
|
30
|
+
line-height: 38px;
|
|
31
|
+
margin: 0 10px;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.fc-table-column-head-cell.filter {
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.sort-icon {
|
|
39
|
+
color: #409eff;
|
|
40
|
+
}
|
|
41
|
+
</style>
|