forked from github/dataease
perf(过滤器): 文本下拉框自定义排序
This commit is contained in:
parent
fc2469c45d
commit
33cbc06498
@ -314,6 +314,16 @@ export const isSameVueObj = (source, target) => {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const isSameArr = (source, target) => {
|
||||||
|
if (!source && !target) return true
|
||||||
|
if (source?.length && target?.length && source.length === target.length) {
|
||||||
|
const sortSource = source.sort()
|
||||||
|
const sortTarget = target.sort()
|
||||||
|
return JSON.stringify(sortSource) === JSON.stringify(sortTarget)
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
export const changeFavicon = link => {
|
export const changeFavicon = link => {
|
||||||
let $favicon = document.querySelector('link[rel="icon"]')
|
let $favicon = document.querySelector('link[rel="icon"]')
|
||||||
if ($favicon !== null) {
|
if ($favicon !== null) {
|
||||||
|
@ -412,10 +412,6 @@ export default {
|
|||||||
this.myAttrs.fieldId = null
|
this.myAttrs.fieldId = null
|
||||||
this.myAttrs.activeName = null
|
this.myAttrs.activeName = null
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.myAttrs.sort?.sort === 'custom') {
|
|
||||||
this.myAttrs.sort.list = []
|
|
||||||
}
|
|
||||||
this.enableSureButton()
|
this.enableSureButton()
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span
|
<span
|
||||||
v-if="widget.isCustomSortWidget && widget.isCustomSortWidget()"
|
v-if="widget.isSortWidget && widget.isSortWidget()"
|
||||||
style="padding-left: 10px;"
|
style="padding-left: 10px;"
|
||||||
>
|
>
|
||||||
|
|
||||||
|
@ -95,6 +95,7 @@
|
|||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
|
|
||||||
<el-dropdown-item
|
<el-dropdown-item
|
||||||
|
v-if="isCustomSortWidget"
|
||||||
:command="beforeClickItem('custom')"
|
:command="beforeClickItem('custom')"
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
@ -146,6 +147,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { fieldListWithPermission } from '@/api/dataset/dataset'
|
import { fieldListWithPermission } from '@/api/dataset/dataset'
|
||||||
import FilterCustomSort from './FilterCustomSort'
|
import FilterCustomSort from './FilterCustomSort'
|
||||||
|
import { isSameArr } from '@/utils'
|
||||||
export default {
|
export default {
|
||||||
name: 'FilterSort',
|
name: 'FilterSort',
|
||||||
components: { FilterCustomSort },
|
components: { FilterCustomSort },
|
||||||
@ -175,7 +177,7 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
fieldIds() {
|
fieldIds() {
|
||||||
return this.element.options.attrs.fieldId || []
|
return this.element.options.attrs.fieldId
|
||||||
},
|
},
|
||||||
isSortWidget() {
|
isSortWidget() {
|
||||||
return this.widget && this.widget.isSortWidget && this.widget.isSortWidget()
|
return this.widget && this.widget.isSortWidget && this.widget.isSortWidget()
|
||||||
@ -195,8 +197,24 @@ export default {
|
|||||||
watch: {
|
watch: {
|
||||||
firstTableId(val, old) {
|
firstTableId(val, old) {
|
||||||
if (val !== old) {
|
if (val !== old) {
|
||||||
|
if (this.isSortWidget && (this.sortNode?.sort === 'asc' || this.sortNode?.sort === 'desc')) {
|
||||||
|
this.sortNode = { sort: 'none' }
|
||||||
|
this.$emit('sort-change', this.sortNode)
|
||||||
|
}
|
||||||
this.loadFields()
|
this.loadFields()
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
fieldIds(val, old) {
|
||||||
|
if (val !== old) {
|
||||||
|
if (this.isCustomSortWidget && this.sortNode.sort === 'custom') {
|
||||||
|
const valArr = val?.length ? val.split(',') : null
|
||||||
|
const oldArr = old?.length ? old.split(',') : null
|
||||||
|
if (!isSameArr(valArr, oldArr)) {
|
||||||
|
this.sortNode = { sort: 'none' }
|
||||||
|
this.$emit('sort-change', this.sortNode)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -210,12 +228,12 @@ export default {
|
|||||||
this.customSortList = JSON.parse(JSON.stringify(this.sortNode.list))
|
this.customSortList = JSON.parse(JSON.stringify(this.sortNode.list))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.sortNode) {
|
|
||||||
this.sortNode = JSON.parse(JSON.stringify(this.defaultSortProp))
|
|
||||||
}
|
|
||||||
|
|
||||||
this.loadFields()
|
this.loadFields()
|
||||||
}
|
}
|
||||||
|
if (!this.sortNode) {
|
||||||
|
this.sortNode = JSON.parse(JSON.stringify(this.defaultSortProp))
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
customSortChange(list) {
|
customSortChange(list) {
|
||||||
|
Loading…
Reference in New Issue
Block a user