diff --git a/frontend/src/components/dragItem/index.vue b/frontend/src/components/dragItem/index.vue index ec326d9737..ef45d7fca3 100644 --- a/frontend/src/components/dragItem/index.vue +++ b/frontend/src/components/dragItem/index.vue @@ -1,115 +1,13 @@ @@ -124,103 +22,34 @@ export default { index: { type: Number, required: true - }, - allFields: { - type: Array, - default: () => [] - }, - sort: { - type: Object, - default: () => null - }, - isSortWidget: { - type: Boolean, - default: false } + }, data() { return { - radio: 0, - ascFieldsShow: false, - descFieldsShow: false, - defaultSortProp: { - sort: 'none' - }, - sortNode: null } }, computed: { - disabledSort() { - return this.index > 0 - } + }, watch: { - index(val, old) { + /* index(val, old) { if (val !== old) { this.sortChange('none') } - } + } */ }, mounted() { }, created() { - if (!this.sortNode) { - this.sortNode = this.sort && this.sort.id ? JSON.parse(JSON.stringify(this.sort)) : JSON.parse(JSON.stringify(this.defaultSortProp)) - } + }, methods: { - clickItem(param) { - if (!param) { - return - } - switch (param.type) { - case 'none': - this.sortChange('none') - break - case 'asc': - this.sortChange('asc') - break - case 'desc': - this.sortChange('desc') - break - case 'remove': - this.removeItem() - break - default: - break - } - }, - beforeClickItem(type) { - return { - type: type - } - }, removeItem() { this.item.index = this.index this.$emit('closeItem', this.item) - }, - - saveAscField({ id, name }) { - this.ascFieldsShow = false - const sort = 'asc' - this.sortNode = { id, name, sort } - this.$emit('sort-change', this.sortNode) - }, - - saveDescField({ id, name }) { - this.descFieldsShow = false - const sort = 'desc' - this.sortNode = { id, name, sort } - this.$emit('sort-change', this.sortNode) - }, - sortChange(type) { - this.sortNode.sort = type - if (type === 'none') { - this.sortNode = { sort: 'none' } - } - this.$emit('sort-change', this.sortNode) } } @@ -249,51 +78,4 @@ span { font-size: 12px; } -.de-ul li { - margin: 5px 2px; - cursor: pointer; - - &:hover { - color: #409EFF; - border-color: rgb(198, 226, 255); - background-color: rgb(236, 245, 255); - } - - &:before { - content: ""; - width: 6px; - height: 6px; - display: inline-block; - border-radius: 50%; - vertical-align: middle; - margin-right: 5px; - } -} - -.de-active-li { - &:before { - background: #409EFF; - } -} - -.de-sort-menu::before { - content: ""; - width: 6px; - height: 6px; - display: inline-block; - border-radius: 50%; - vertical-align: middle; - margin-right: 5px; -} - -.de-delete-field { - margin-left: 4px; -} - -.de-sort-field-span { - display: inline-flexbox; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; -} diff --git a/frontend/src/components/widget/deWidget/DeSelect.vue b/frontend/src/components/widget/deWidget/DeSelect.vue index 30cf432457..d8761e0e28 100644 --- a/frontend/src/components/widget/deWidget/DeSelect.vue +++ b/frontend/src/components/widget/deWidget/DeSelect.vue @@ -43,11 +43,10 @@ import ElVisualSelect from '@/components/elVisualSelect' import { linkMultFieldValues, multFieldValues } from '@/api/dataset/dataset' import bus from '@/utils/bus' -import { isSameVueObj } from '@/utils' +import { isSameVueObj, mergeCustomSortOption } from '@/utils' import { getLinkToken, getToken } from '@/utils/auth' import customInput from '@/components/widget/deWidget/customInput' import { textSelectWidget } from '@/components/widget/deWidget/serviceNameFn.js' - export default { components: { ElVisualSelect }, mixins: [customInput], @@ -123,6 +122,9 @@ export default { const i18nKey = this.element.options.attrs.multiple ? 'panel.multiple_choice' : 'panel.single_choice' const i18nValue = this.$t(i18nKey) return '(' + i18nValue + ')' + }, + isCustomSortWidget() { + return this.element.serviceName === 'textSelectWidget' } }, @@ -347,7 +349,11 @@ export default { }, optionData(data) { 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 { id: item, text: item diff --git a/frontend/src/components/widget/serviceImpl/TextSelectServiceImpl.js b/frontend/src/components/widget/serviceImpl/TextSelectServiceImpl.js index ab8cd690df..4b5b79d85a 100644 --- a/frontend/src/components/widget/serviceImpl/TextSelectServiceImpl.js +++ b/frontend/src/components/widget/serviceImpl/TextSelectServiceImpl.js @@ -99,6 +99,9 @@ class TextSelectServiceImpl extends WidgetService { isSortWidget() { return true } + isCustomSortWidget() { + return true + } fillValueDerfault(element) { const defaultV = element.options.value === null ? '' : element.options.value.toString() diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index e81de74ae2..3fbe39e6f6 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -325,3 +325,12 @@ export const changeFavicon = link => { document.head.appendChild($favicon) } } + +export const mergeCustomSortOption = (customSortList, sourceList) => { + if (!customSortList?.length) return sourceList?.length ? sourceList : [] + + if (!sourceList?.length) return customSortList?.length ? customSortList : [] + + const result = [...customSortList, ...sourceList] + return [...new Set(result)] +} diff --git a/frontend/src/views/panel/filter/FilterDialog.vue b/frontend/src/views/panel/filter/FilterDialog.vue index bf6c0b64ef..23b444b139 100644 --- a/frontend/src/views/panel/filter/FilterDialog.vue +++ b/frontend/src/views/panel/filter/FilterDialog.vue @@ -267,7 +267,6 @@
+ + + + + +
@@ -197,9 +210,10 @@ + + diff --git a/frontend/src/views/panel/filter/filterMain/FilterHead.vue b/frontend/src/views/panel/filter/filterMain/FilterHead.vue index 1f9367ab76..3f2431b546 100644 --- a/frontend/src/views/panel/filter/filterMain/FilterHead.vue +++ b/frontend/src/views/panel/filter/filterMain/FilterHead.vue @@ -23,13 +23,10 @@ > @@ -46,7 +43,6 @@ + +