fast-crud-ui3 1.5.16 → 1.5.17
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 +9978 -5939
- 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 +510 -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 +89 -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 +66 -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 +761 -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,170 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 使用 el-select 以便更好的支持搜索以及多选(可借助el-select的远程搜索模式实现——避免下拉) -->
|
|
3
|
+
<el-select v-model="value"
|
|
4
|
+
:clearable="clearable"
|
|
5
|
+
:placeholder="placeholder"
|
|
6
|
+
:size="size"
|
|
7
|
+
:disabled="disabled"
|
|
8
|
+
:multiple="multiple"
|
|
9
|
+
remote :suffix-icon="null"
|
|
10
|
+
@clear="handleClear"
|
|
11
|
+
@blur="(event) => $emit('blur', event)"
|
|
12
|
+
@change="(val) => $emit('change', val)"
|
|
13
|
+
@click="handleClick"
|
|
14
|
+
@focus="handleFocus">
|
|
15
|
+
<el-option v-for="item in options" :key="item.value" :value="item.value" :label="item.label"/>
|
|
16
|
+
</el-select>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
import {pick} from "../../../util/pick"
|
|
21
|
+
import {defaultIfEmpty, isArray, isEmpty, isObject} from "../../../util/util"
|
|
22
|
+
import FastTableOption from "../../../model/fastTableOption.js"
|
|
23
|
+
|
|
24
|
+
export default {
|
|
25
|
+
name: "FastObjectPicker",
|
|
26
|
+
emits: ['update:modelValue', 'blur', 'change', 'clear', 'click', 'focus'],
|
|
27
|
+
props: {
|
|
28
|
+
modelValue: {
|
|
29
|
+
required: true
|
|
30
|
+
},
|
|
31
|
+
tableOption: {
|
|
32
|
+
type: FastTableOption,
|
|
33
|
+
required: true
|
|
34
|
+
},
|
|
35
|
+
showField: String, // 回显到控件上的字段 @deprecated 1.6 使用valKey替代
|
|
36
|
+
valKey: String, // 替代showField, 指定"值"key
|
|
37
|
+
labelKey: String, // 当控件需要"值显"不一致时, 指定"显"key
|
|
38
|
+
pickObject: Object, // 单选时, pick选择后回填到的目标object上
|
|
39
|
+
pickMap: Object, // 单选时, pick选择后回填到目标object上时,指导字段对应关系: key为pick的数据的字段名, value为pickObject中的字段名
|
|
40
|
+
valueCovert: { // 针对showField取值的值转换, 对于多选时, 会讲showField的多个值用英文逗号分隔后返回,作为组件v-model值
|
|
41
|
+
type: Function,
|
|
42
|
+
default: (pickData, field) => {
|
|
43
|
+
if (isArray(pickData)) {
|
|
44
|
+
return pickData.map(row => row[field])
|
|
45
|
+
} else {
|
|
46
|
+
return pickData[field]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
beforeOpen: {
|
|
51
|
+
type: Function,
|
|
52
|
+
default: () => Promise.resolve()
|
|
53
|
+
},
|
|
54
|
+
title: String,
|
|
55
|
+
multiple: {
|
|
56
|
+
type: Boolean,
|
|
57
|
+
default: () => false
|
|
58
|
+
},
|
|
59
|
+
placeholder: {
|
|
60
|
+
type: String,
|
|
61
|
+
default: () => "请点选..."
|
|
62
|
+
},
|
|
63
|
+
appendToBody: {
|
|
64
|
+
type: Boolean,
|
|
65
|
+
default: () => true
|
|
66
|
+
},
|
|
67
|
+
disabled: {
|
|
68
|
+
type: Boolean,
|
|
69
|
+
default: () => false
|
|
70
|
+
},
|
|
71
|
+
clearable: {
|
|
72
|
+
type: Boolean,
|
|
73
|
+
default: () => true
|
|
74
|
+
},
|
|
75
|
+
size: String,
|
|
76
|
+
// pick弹窗的宽度
|
|
77
|
+
dialogWidth: {
|
|
78
|
+
type: String,
|
|
79
|
+
default: () => '70%'
|
|
80
|
+
},
|
|
81
|
+
// 用以内置el-select回显
|
|
82
|
+
options: {
|
|
83
|
+
type: Array,
|
|
84
|
+
default: () => []
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
mounted() {
|
|
88
|
+
if (isEmpty(this.options) && !isEmpty(this.modelValue)) { // 有初始值, 先构造一个选项以便正常显示
|
|
89
|
+
// this.options = [{label: this.modelValue, value: this.modelValue}]
|
|
90
|
+
this.options.length = 0
|
|
91
|
+
this.options.push([{label: this.modelValue, value: this.modelValue}])
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
computed: {
|
|
95
|
+
value: {
|
|
96
|
+
get() {
|
|
97
|
+
return this.modelValue
|
|
98
|
+
},
|
|
99
|
+
set(val) {
|
|
100
|
+
this.$emit('update:modelValue', val)
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
methods: {
|
|
105
|
+
handleClear(event) {
|
|
106
|
+
this.$emit('clear', event)
|
|
107
|
+
// 清除pickMap的其它属性
|
|
108
|
+
if (!isEmpty(this.pickMap) && !isEmpty(this.pickObject)) {
|
|
109
|
+
Object.entries(this.pickMap).forEach(([pickFieldName, formFieldName]) => {
|
|
110
|
+
this.pickObject[formFieldName] = null
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
handleClick(event) {
|
|
115
|
+
// 检查点击事件的目标是否为清除按钮, 清除按钮的话不上抛点击事件
|
|
116
|
+
if (event.target.classList.contains('el-input__clear')) {
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
this.$emit('click', event)
|
|
120
|
+
this.openPick()
|
|
121
|
+
},
|
|
122
|
+
handleFocus(event) {
|
|
123
|
+
this.$emit('focus', event)
|
|
124
|
+
// this.openPick() // ESC退出后焦点又回到input,会导致ESC关不掉
|
|
125
|
+
},
|
|
126
|
+
openPick() {
|
|
127
|
+
const {beforeOpen, tableOption} = this
|
|
128
|
+
beforeOpen().then(() => {
|
|
129
|
+
pick({
|
|
130
|
+
option: tableOption,
|
|
131
|
+
multiple: this.multiple,
|
|
132
|
+
dialog: {
|
|
133
|
+
title: this.title,
|
|
134
|
+
width: this.dialogWidth,
|
|
135
|
+
appendToBody: this.appendToBody
|
|
136
|
+
}
|
|
137
|
+
}).then((fatData) => {
|
|
138
|
+
const data = isArray(fatData) ? fatData.map((item) => item.row) : fatData.row
|
|
139
|
+
const valKey = defaultIfEmpty(this.valKey, this.showField)
|
|
140
|
+
const labelKey = defaultIfEmpty(this.labelKey, valKey)
|
|
141
|
+
// 赋值options
|
|
142
|
+
const options = (isArray(data) ? data : [data]).map(item => {
|
|
143
|
+
return {value: item[valKey], label: item[labelKey]}
|
|
144
|
+
})
|
|
145
|
+
this.options.length = 0
|
|
146
|
+
this.options.push(...options)
|
|
147
|
+
// 赋值value
|
|
148
|
+
const newVal = this.valueCovert(data, valKey)
|
|
149
|
+
this.value = newVal
|
|
150
|
+
this.$emit('change', newVal)
|
|
151
|
+
if (this.multiple !== true && isObject(data)) {
|
|
152
|
+
// 赋值pickObject
|
|
153
|
+
Object.entries(this.pickMap).forEach(([pickFieldName, formFieldName]) => {
|
|
154
|
+
this.pickObject[formFieldName] = data[pickFieldName]
|
|
155
|
+
})
|
|
156
|
+
}
|
|
157
|
+
}).catch((err = '你取消了pic弹窗') => {
|
|
158
|
+
console.debug(err)
|
|
159
|
+
})
|
|
160
|
+
}).catch((err = '你取消了打开pick') => {
|
|
161
|
+
console.debug(err)
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
</script>
|
|
167
|
+
|
|
168
|
+
<style scoped lang="scss">
|
|
169
|
+
|
|
170
|
+
</style>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-select v-model="value" v-bind="$attrs" :size="size" :multiple="multiple"
|
|
3
|
+
@change="(val) => $emit('change', val)"
|
|
4
|
+
@clear="() => $emit('clear')"
|
|
5
|
+
@focus="(event) => $emit('focus', event)"
|
|
6
|
+
@blur="(event) => $emit('blur', event)"
|
|
7
|
+
@visible-change="(visible) => $emit('visibleChange', visible)"
|
|
8
|
+
@remove-tag="(tagVal) => $emit('removeTag', tagVal)">
|
|
9
|
+
<el-option v-for="item in nativeOptions" :key="item.value" :label="item[labelKey]" :value="item[valKey]"
|
|
10
|
+
:disabled="disableVal.indexOf(item[valKey]) > -1"></el-option>
|
|
11
|
+
</el-select>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
import FastTableOption from '../../../model/fastTableOption.js'
|
|
16
|
+
import Query from '../../../model/query.js'
|
|
17
|
+
import * as util from '../../../util/util.js'
|
|
18
|
+
|
|
19
|
+
export default {
|
|
20
|
+
name: "fast-select",
|
|
21
|
+
emits: ['update:modelValue', 'change', 'clear', 'focus', 'blur', 'visibleChange', 'removeTag'],
|
|
22
|
+
props: {
|
|
23
|
+
modelValue: {
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
options: {
|
|
27
|
+
type: [Array, FastTableOption],
|
|
28
|
+
default: () => []
|
|
29
|
+
},
|
|
30
|
+
labelKey: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: () => "label"
|
|
33
|
+
},
|
|
34
|
+
valKey: {
|
|
35
|
+
type: String,
|
|
36
|
+
default: () => "value"
|
|
37
|
+
},
|
|
38
|
+
multiple: { // 多值时, value为数组
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: () => false
|
|
41
|
+
},
|
|
42
|
+
disableVal: {
|
|
43
|
+
type: Array,
|
|
44
|
+
default: () => []
|
|
45
|
+
},
|
|
46
|
+
size: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: 'default'
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
data() {
|
|
52
|
+
return {
|
|
53
|
+
nativeOptions: util.isArray(this.options) ? this.options : []
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
async mounted() {
|
|
57
|
+
if (this.options instanceof FastTableOption) {
|
|
58
|
+
await this.buildSelectOptions()
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
computed: {
|
|
62
|
+
value: {
|
|
63
|
+
get() {
|
|
64
|
+
return this.modelValue
|
|
65
|
+
},
|
|
66
|
+
set(val) {
|
|
67
|
+
this.$emit('update:modelValue', val)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
methods: {
|
|
72
|
+
buildSelectOptions() {
|
|
73
|
+
if (!(this.options instanceof FastTableOption)) {
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
const query = new Query().setDistinct().setCols([this.valKey, this.labelKey]);
|
|
77
|
+
this.options._buildSelectOptions(query, this.valKey, this.labelKey).then(options => {
|
|
78
|
+
this.nativeOptions = options
|
|
79
|
+
}).catch(err => {
|
|
80
|
+
console.error(err)
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
</script>
|
|
86
|
+
|
|
87
|
+
<style scoped>
|
|
88
|
+
|
|
89
|
+
</style>
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<fast-table class="fc-fast-table"
|
|
3
|
+
:data="rows"
|
|
4
|
+
:is-static="true"
|
|
5
|
+
:option="tableOption"
|
|
6
|
+
@selection-change="handleSelectionChange">
|
|
7
|
+
<template v-for="column in columnProps">
|
|
8
|
+
<component :is="column.componentName"
|
|
9
|
+
v-bind="column.props"
|
|
10
|
+
v-if="column.hidden === false"/>
|
|
11
|
+
</template>
|
|
12
|
+
<template #button>
|
|
13
|
+
<el-button type="danger" plain :disabled="checkedRows.length === 0" @click="handleRemove"
|
|
14
|
+
v-if="action === 'delete' && rows.length > 1">从删除清单里移出</el-button>
|
|
15
|
+
</template>
|
|
16
|
+
</fast-table>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script>
|
|
20
|
+
import FastTableOption from "../../../model/fastTableOption.js"
|
|
21
|
+
|
|
22
|
+
export default {
|
|
23
|
+
name: 'RowConfirm',
|
|
24
|
+
props: {
|
|
25
|
+
rows: {
|
|
26
|
+
type: Array,
|
|
27
|
+
default: () => []
|
|
28
|
+
},
|
|
29
|
+
columnConfigs: Object,
|
|
30
|
+
action: {
|
|
31
|
+
type: String,
|
|
32
|
+
default: () => 'view',
|
|
33
|
+
validator: (value) => ['view', 'delete'].indexOf(value) > -1
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
data() {
|
|
37
|
+
return {
|
|
38
|
+
tableOption: new FastTableOption({
|
|
39
|
+
queryable: false,
|
|
40
|
+
insertable: false,
|
|
41
|
+
updatable: false,
|
|
42
|
+
deletable: false,
|
|
43
|
+
exportable: false,
|
|
44
|
+
enableMulti: this.rows.length > 1
|
|
45
|
+
}),
|
|
46
|
+
checkedRows: []
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
computed: {
|
|
50
|
+
columnProps() {
|
|
51
|
+
return this.columnConfigs.map(({tableColumnComponentName, customConfig}) => {
|
|
52
|
+
const {hidden, showLength, col, label, props} = customConfig
|
|
53
|
+
return {
|
|
54
|
+
componentName: tableColumnComponentName,
|
|
55
|
+
hidden: hidden,
|
|
56
|
+
props: {
|
|
57
|
+
...props,
|
|
58
|
+
filter: false,
|
|
59
|
+
prop: col,
|
|
60
|
+
label: label,
|
|
61
|
+
showOverflowToolTip: true,
|
|
62
|
+
showLength: showLength
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
methods: {
|
|
69
|
+
handleSelectionChange({fatRows}) {
|
|
70
|
+
this.checkedRows = fatRows
|
|
71
|
+
},
|
|
72
|
+
handleRemove() {
|
|
73
|
+
for (let i = this.rows.length - 1; i >= 0; i--) {
|
|
74
|
+
if (this.checkedRows.some(r => r === this.rows[i])) {
|
|
75
|
+
this.rows.splice(i, 1)
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
getRows() {
|
|
80
|
+
return this.rows
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
<style scoped lang="scss">
|
|
87
|
+
</style>
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="fc-dynamic-filter-form">
|
|
3
|
+
<div class="fc-dynamic-filter-sort-btn">
|
|
4
|
+
<el-radio v-model="asc" label="" border :size="size">不排序</el-radio>
|
|
5
|
+
<el-radio v-model="asc" :label="true" border :size="size">升序</el-radio>
|
|
6
|
+
<el-radio v-model="asc" :label="false" border :size="size">降序</el-radio>
|
|
7
|
+
</div>
|
|
8
|
+
<div class="fc-dynamic-filter-component-wrapper">
|
|
9
|
+
<div class="title">输入过滤:</div>
|
|
10
|
+
<div class="fc-dynamic-filter-component">
|
|
11
|
+
<component :is="localFilter.component" v-model="localFilter.val" v-bind="localFilter.props"/>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="fc-dynamic-filter-distinct-wrapper">
|
|
15
|
+
<div class="title">
|
|
16
|
+
<div>
|
|
17
|
+
<span>去重筛选:</span>
|
|
18
|
+
<el-checkbox size="small" type="info" v-model="reuseCond" @change="distinctLoad">复用已生效的条件
|
|
19
|
+
</el-checkbox>
|
|
20
|
+
</div>
|
|
21
|
+
<el-button link
|
|
22
|
+
:style="{'color': distinctOptionAsc === '' ? 'gray': '#409EFF', 'padding': 0}"
|
|
23
|
+
:icon="distinctOptionsAscIcon"
|
|
24
|
+
@click="() => distinctOptionAsc = !distinctOptionAsc"
|
|
25
|
+
v-if="distinctLoaded"></el-button>
|
|
26
|
+
</div>
|
|
27
|
+
<!-- 由于distinct查询可能比较慢, 因此由用户点击触发展示 -->
|
|
28
|
+
<div class="fc-dynamic-filter-distinct" v-loading="distinctLoading">
|
|
29
|
+
<!-- distinct 勾选项 -->
|
|
30
|
+
<el-input size="small" v-model="distinctOptionFilterKeyword" :clearable="true" placeholder="输入过滤.."
|
|
31
|
+
v-if="distinctLoaded"></el-input>
|
|
32
|
+
<fast-checkbox-group :options="distinctFilteredOptions" :show-chose-all="false"
|
|
33
|
+
class="fc-dynamic-filter-distinct-options"
|
|
34
|
+
v-model="distinctCheckedValue"
|
|
35
|
+
v-if="distinctLoaded"></fast-checkbox-group>
|
|
36
|
+
<div style="display: flex; justify-content: center;" v-if="!distinctLoaded">
|
|
37
|
+
<el-button link style="color: gray;" @click="distinctLoad">请点击加载</el-button>
|
|
38
|
+
</div>
|
|
39
|
+
<el-empty v-if="distinctLoaded && distinctOptions.length === 0">
|
|
40
|
+
<template #image><span></span></template>
|
|
41
|
+
</el-empty>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
<div class="fc-dynamic-filter-form-btn">
|
|
45
|
+
<el-button :size="size" @click="getEmpty">查空值</el-button>
|
|
46
|
+
<el-button :size="size" @click="getNotEmpty">查非空值</el-button>
|
|
47
|
+
<span style="flex: 1;"></span>
|
|
48
|
+
<el-button type="primary" :size="size" @click="ok">确认</el-button>
|
|
49
|
+
<el-button :size="size" @click="close">关闭</el-button>
|
|
50
|
+
</div>
|
|
51
|
+
</div>
|
|
52
|
+
</template>
|
|
53
|
+
|
|
54
|
+
<script>
|
|
55
|
+
import FastTableOption from '../../../model/fastTableOption.js'
|
|
56
|
+
import FilterComponentConfig from '../../../model/filterComponentConfig.js'
|
|
57
|
+
import Query from '../../../model/query.js'
|
|
58
|
+
import Opt from '../../../model/opt.js'
|
|
59
|
+
import {escapeValToLabel} from "../../../util/escape.js"
|
|
60
|
+
import {isEmpty, isObject, toStr} from "../../../util/util"
|
|
61
|
+
import FastCheckboxGroup from "../../checkbox-group/src/fast-checkbox-group.vue"
|
|
62
|
+
import {Sort, SortUp, SortDown} from "@element-plus/icons-vue"
|
|
63
|
+
|
|
64
|
+
export default {
|
|
65
|
+
name: "dynamic-filter-form",
|
|
66
|
+
components: {FastCheckboxGroup},
|
|
67
|
+
emits: ['ok', 'cancel'],
|
|
68
|
+
props: {
|
|
69
|
+
option: FastTableOption,
|
|
70
|
+
filter: FilterComponentConfig,
|
|
71
|
+
order: [String],
|
|
72
|
+
conds: {
|
|
73
|
+
type: Array,
|
|
74
|
+
default: () => []
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
mounted() {
|
|
78
|
+
console.log(this.localFilter)
|
|
79
|
+
},
|
|
80
|
+
computed: {
|
|
81
|
+
size() {
|
|
82
|
+
return this.option.style.size
|
|
83
|
+
},
|
|
84
|
+
distinctOptionsAscIcon() {
|
|
85
|
+
return this.distinctOptionAsc === '' ? Sort : (this.distinctOptionAsc === true ? SortUp : SortDown)
|
|
86
|
+
},
|
|
87
|
+
distinctFilteredOptions() {
|
|
88
|
+
const {distinctOptionFilterKeyword, distinctOptionAsc} = this
|
|
89
|
+
return this.distinctOptions.filter(item => isEmpty(distinctOptionFilterKeyword) || toStr(item.label).indexOf(distinctOptionFilterKeyword) !== -1)
|
|
90
|
+
.sort((a, b) => {
|
|
91
|
+
const label1 = toStr(a.label), label2 = toStr(b.label);
|
|
92
|
+
return distinctOptionAsc ? label1.localeCompare(label2) : label2.localeCompare(label1)
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
data() {
|
|
97
|
+
const localFilter = new FilterComponentConfig({...this.filter})
|
|
98
|
+
return {
|
|
99
|
+
localFilter: localFilter,
|
|
100
|
+
asc: this.order === 'asc' ? true : (this.order === 'desc' ? false : ''),
|
|
101
|
+
reuseCond: true, // 复用已生效的条件
|
|
102
|
+
distinctLoaded: false, // 是否distinct query loaded
|
|
103
|
+
distinctLoading: false, // 是否distinct query loading中
|
|
104
|
+
distinctOptions: [], // 检索出的distinct选项
|
|
105
|
+
distinctOptionAsc: '', // distinct选项排序, 默认不排序
|
|
106
|
+
distinctOptionFilterKeyword: null, // distinct选项过滤关键词
|
|
107
|
+
distinctCheckedValue: [], // 勾选的distinct值
|
|
108
|
+
distinctAbortCtrl: null // distinct请求终止控制器
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
methods: {
|
|
112
|
+
distinctLoad() {
|
|
113
|
+
this.distinctLoading = true;
|
|
114
|
+
this.distinctAbortCtrl = new AbortController();
|
|
115
|
+
const {col, component, props} = this.localFilter;
|
|
116
|
+
|
|
117
|
+
const distinctQuery = new Query().setDistinct().setCols([col]);
|
|
118
|
+
if (this.reuseCond) {
|
|
119
|
+
distinctQuery.setConds(this.conds);
|
|
120
|
+
}
|
|
121
|
+
this.option._list(distinctQuery, {signal: this.distinctAbortCtrl.signal}).then((res) => {
|
|
122
|
+
if (res.length > 1000) { // 为防止页面卡死, 最多显示1000个
|
|
123
|
+
res.splice(1001);
|
|
124
|
+
}
|
|
125
|
+
const distinctValues = res.filter(item => isObject(item) && item.hasOwnProperty(col)).map(item => item[col])
|
|
126
|
+
this.distinctOptions.length = 0 // 清空
|
|
127
|
+
distinctValues.map((v) => {
|
|
128
|
+
escapeValToLabel(component, v, props).then(label => {
|
|
129
|
+
this.distinctOptions.push({
|
|
130
|
+
value: v,
|
|
131
|
+
label: label
|
|
132
|
+
})
|
|
133
|
+
}).catch(err => {
|
|
134
|
+
console.error(err)
|
|
135
|
+
this.distinctOptions.push({
|
|
136
|
+
value: v,
|
|
137
|
+
label: v
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
})
|
|
141
|
+
this.distinctLoaded = true;
|
|
142
|
+
}).catch(err => {
|
|
143
|
+
console.error(err)
|
|
144
|
+
}).finally(() => {
|
|
145
|
+
this.distinctLoading = false;
|
|
146
|
+
})
|
|
147
|
+
},
|
|
148
|
+
getEmpty() {
|
|
149
|
+
this.$emit('ok', {
|
|
150
|
+
filter: new FilterComponentConfig({...this.localFilter, opt: Opt.EMPTY}),
|
|
151
|
+
order: {
|
|
152
|
+
col: this.localFilter.col,
|
|
153
|
+
asc: this.asc
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
},
|
|
157
|
+
getNotEmpty() {
|
|
158
|
+
this.$emit('ok', {
|
|
159
|
+
filter: new FilterComponentConfig({...this.localFilter, opt: Opt.NEMPTY}),
|
|
160
|
+
order: {
|
|
161
|
+
col: this.localFilter.col,
|
|
162
|
+
asc: this.asc
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
},
|
|
166
|
+
ok() {
|
|
167
|
+
let filterConfig;
|
|
168
|
+
if (this.distinctCheckedValue.length > 0) {
|
|
169
|
+
filterConfig = {
|
|
170
|
+
component: 'fast-checkbox-group',
|
|
171
|
+
col: this.localFilter.col,
|
|
172
|
+
label: this.localFilter.label,
|
|
173
|
+
opt: 'in',
|
|
174
|
+
val: this.distinctCheckedValue,
|
|
175
|
+
disabled: false,
|
|
176
|
+
props: {
|
|
177
|
+
options: this.distinctOptions,
|
|
178
|
+
labelKey: 'label',
|
|
179
|
+
valKey: 'value',
|
|
180
|
+
showChoseAll: true
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
} else {
|
|
184
|
+
filterConfig = {...this.localFilter};
|
|
185
|
+
}
|
|
186
|
+
this.$emit('ok', {
|
|
187
|
+
filter: new FilterComponentConfig(filterConfig),
|
|
188
|
+
order: {
|
|
189
|
+
col: this.localFilter.col,
|
|
190
|
+
asc: this.asc
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
},
|
|
194
|
+
close() {
|
|
195
|
+
this.$emit('cancel')
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
beforeUnmount() {
|
|
199
|
+
if (this.distinctAbortCtrl) {
|
|
200
|
+
this.distinctAbortCtrl.abort()
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
</script>
|
|
205
|
+
|
|
206
|
+
<style scoped lang="scss">
|
|
207
|
+
.fc-dynamic-filter-form {
|
|
208
|
+
& > * {
|
|
209
|
+
margin-bottom: 10px;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
& .title {
|
|
213
|
+
margin-bottom: 5px;
|
|
214
|
+
font-size: 13px;
|
|
215
|
+
display: flex;
|
|
216
|
+
align-items: center;
|
|
217
|
+
justify-content: space-between;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.fc-dynamic-filter-sort-btn, .fc-dynamic-filter-component {
|
|
221
|
+
display: flex;
|
|
222
|
+
justify-content: space-between;
|
|
223
|
+
|
|
224
|
+
& > * {
|
|
225
|
+
flex: 1;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.fc-dynamic-filter-component-wrapper {
|
|
230
|
+
margin: 20px 0;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.fc-dynamic-filter-distinct {
|
|
234
|
+
border: 1px solid #e1e1e1;
|
|
235
|
+
padding: 10px;
|
|
236
|
+
overflow: auto;
|
|
237
|
+
max-height: 300px;
|
|
238
|
+
|
|
239
|
+
.fc-dynamic-filter-distinct-options {
|
|
240
|
+
margin-top: 10px;
|
|
241
|
+
|
|
242
|
+
:deep(.el-checkbox) {
|
|
243
|
+
display: block;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.fc-dynamic-filter-form-btn {
|
|
249
|
+
display: flex;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
</style>
|