diff --git a/frontend/src/components/ElVisualSelect/index.vue b/frontend/src/components/ElVisualSelect/index.vue index 3799166a96..e97ac20409 100644 --- a/frontend/src/components/ElVisualSelect/index.vue +++ b/frontend/src/components/ElVisualSelect/index.vue @@ -69,12 +69,16 @@ export default { }, list() { this.resetList() - this.init() + this.$nextTick(() => { + this.init() + }) } }, mounted() { this.resetList() - this.init() + this.$nextTick(() => { + this.init() + }) }, methods: { addScrollDiv(selectDom) { @@ -101,13 +105,13 @@ export default { if (this.defaultFirst && this.list.length > 0) { this.selectValue = this.list[0].value } + if (!this.list || !this.list.length) return const selectDom = document.querySelector( `.${this.classId} .el-select-dropdown .el-select-dropdown__wrap` ) this.scrollbar = document.querySelector(`.${this.classId} .el-select-dropdown .el-scrollbar`) this.slectBoxDom = document.querySelector(`.${this.classId} .el-select-dropdown__wrap`) - if (!this.slectBoxDom || !this.slectBoxDom.style) return this.slectBoxDom.style.display = 'flex' this.slectBoxDom.style.flexDirection = 'row' this.domList = selectDom.querySelector( diff --git a/frontend/src/components/widget/DeWidget/DeSelect.vue b/frontend/src/components/widget/DeWidget/DeSelect.vue index 1cbdf5a8da..fb655c29b1 100644 --- a/frontend/src/components/widget/DeWidget/DeSelect.vue +++ b/frontend/src/components/widget/DeWidget/DeSelect.vue @@ -36,6 +36,7 @@ import ElVisualSelect from '@/components/ElVisualSelect' import { multFieldValues, linkMultFieldValues } from '@/api/dataset/dataset' import bus from '@/utils/bus' +import { isSameVueObj } from '@/utils' import { getLinkToken, getToken } from '@/utils/auth' import customInput from '@/components/widget/DeWidget/customInput' import { textSelectWidget } from '@/components/widget/DeWidget/serviceNameFn.js' @@ -143,7 +144,9 @@ export default { }) }, 'element.options.attrs.sort': function(value, old) { - if (value === null || typeof value === 'undefined' || value === old) return + if (value === null || typeof value === 'undefined' || value === old || isSameVueObj(value, old)) return + this.show = false + this.datas = [] let method = multFieldValues @@ -160,6 +163,10 @@ export default { this.element.options.attrs.fieldId.length > 0 && method(param).then(res => { this.datas = this.optionDatas(res.data) + this.$nextTick(() => { + this.show = true + this.handleCoustomStyle() + }) }) || (this.element.options.value = '') } diff --git a/frontend/src/utils/index.js b/frontend/src/utils/index.js index 7c4a9510f1..e6db4df3c2 100644 --- a/frontend/src/utils/index.js +++ b/frontend/src/utils/index.js @@ -278,3 +278,11 @@ export function isMobile() { const flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i) return flag } + +export const isSameVueObj = (source, target) => { + if (!source && !target) return true + if (!!source && !!target) { + return JSON.stringify(source) === JSON.stringify(target) + } + return false +}