Merge pull request #3838 from dataease/pr@dev@feat_filter_select_grid_custom_sort

feat(过滤器): 文本下拉列表增加自定义排序
This commit is contained in:
xuwei-fit2cloud 2022-11-23 15:02:12 +08:00 committed by GitHub
commit 754c8c8673
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View File

@ -71,7 +71,7 @@
import { linkMultFieldValues, multFieldValues } from '@/api/dataset/dataset' import { linkMultFieldValues, multFieldValues } from '@/api/dataset/dataset'
import { getLinkToken, getToken } from '@/utils/auth' import { getLinkToken, getToken } from '@/utils/auth'
import bus from '@/utils/bus' import bus from '@/utils/bus'
import { isSameVueObj } from '@/utils' import { isSameVueObj, mergeCustomSortOption } from '@/utils'
import { attrsMap, styleAttrs, textSelectGridWidget } from '@/components/widget/deWidget/serviceNameFn.js' import { attrsMap, styleAttrs, textSelectGridWidget } from '@/components/widget/deWidget/serviceNameFn.js'
export default { export default {
@ -142,6 +142,9 @@ export default {
cssArr() { cssArr() {
const { brColor, wordColor, innerBgColor } = this.element.style const { brColor, wordColor, innerBgColor } = this.element.style
return { brColor, wordColor, innerBgColor } return { brColor, wordColor, innerBgColor }
},
isCustomSortWidget() {
return this.element.serviceName === 'textSelectGridWidget'
} }
}, },
watch: { watch: {
@ -354,7 +357,11 @@ export default {
}, },
optionData(data) { optionData(data) {
if (!data) return null if (!data) return null
return data.filter(item => !!item).map(item => { let tempData = data.filter(item => !!item)
if (this.isCustomSortWidget && this.element.options.attrs?.sort?.sort === 'custom') {
tempData = mergeCustomSortOption(this.element.options.attrs.sort.list, tempData)
}
return tempData.map(item => {
return { return {
id: item, id: item,
text: item text: item

View File

@ -96,6 +96,9 @@ class TextSelectGridServiceImpl extends WidgetService {
isSortWidget() { isSortWidget() {
return true return true
} }
isCustomSortWidget() {
return true
}
fillValueDerfault(element) { fillValueDerfault(element) {
const defaultV = element.options.value === null ? '' : element.options.value.toString() const defaultV = element.options.value === null ? '' : element.options.value.toString()
if (element.options.attrs.multiple) { if (element.options.attrs.multiple) {