From 50b03eef6aefb0bd92ab00d5ba213214a375654f Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Tue, 28 Nov 2023 16:01:00 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E8=BF=87=E6=BB=A4=E5=99=A8=E5=9C=A8?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2=E8=A7=A6=E5=8F=91=E4=B8=A4?= =?UTF-8?q?=E6=AC=A1=E8=AF=B7=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/frontend/src/components/canvas/DeCanvas.vue | 2 +- core/frontend/src/components/widget/deWidget/DeDate.vue | 6 ++++-- .../src/components/widget/deWidget/DeInputSearch.vue | 6 ++++-- .../src/components/widget/deWidget/DeNumberRange.vue | 6 ++++-- core/frontend/src/components/widget/deWidget/DeSelect.vue | 6 ++++-- .../src/components/widget/deWidget/DeSelectGrid.vue | 6 ++++-- .../src/components/widget/deWidget/DeSelectTree.vue | 6 ++++-- core/frontend/src/views/panel/edit/index.vue | 2 +- 8 files changed, 26 insertions(+), 14 deletions(-) diff --git a/core/frontend/src/components/canvas/DeCanvas.vue b/core/frontend/src/components/canvas/DeCanvas.vue index 3ea8fbaa34..d97346a6d1 100644 --- a/core/frontend/src/components/canvas/DeCanvas.vue +++ b/core/frontend/src/components/canvas/DeCanvas.vue @@ -509,7 +509,7 @@ export default { this.$store.commit('setComponentWithId', this.currentFilterCom) this.$store.commit('recordSnapshot', 'sureFilter') this.$store.commit('setCurComponent', { component: this.currentFilterCom, index: this.curComponentIndex }) - bus.$emit('reset-default-value', this.currentFilterCom.id) + bus.$emit('reset-default-value', this.currentFilterCom) this.closeFilter() }, reFreshComponent(component) { diff --git a/core/frontend/src/components/widget/deWidget/DeDate.vue b/core/frontend/src/components/widget/deWidget/DeDate.vue index ff355563cc..36b42c5827 100644 --- a/core/frontend/src/components/widget/deWidget/DeDate.vue +++ b/core/frontend/src/components/widget/deWidget/DeDate.vue @@ -418,8 +418,10 @@ export default { this.$refs.dateRef.hidePicker() } }, - resetDefaultValue(id) { - if (this.inDraw && this.manualModify && this.element.id === id) { + resetDefaultValue(ele) { + const id = ele.id + const eleVal = ele.options.value.toString() + if (this.inDraw && this.manualModify && this.element.id === id && this.values.toString() !== eleVal && this.defaultValueStr === eleVal) { if (!this.element.options.attrs.default.isDynamic) { this.values = this.fillValueDerfault() this.dateChange(this.values) diff --git a/core/frontend/src/components/widget/deWidget/DeInputSearch.vue b/core/frontend/src/components/widget/deWidget/DeInputSearch.vue index f2becf0ad6..cd63f8d1bc 100644 --- a/core/frontend/src/components/widget/deWidget/DeInputSearch.vue +++ b/core/frontend/src/components/widget/deWidget/DeInputSearch.vue @@ -99,8 +99,10 @@ export default { clearHandler() { this.value = null }, - resetDefaultValue(id) { - if (this.inDraw && this.manualModify && this.element.id === id) { + resetDefaultValue(ele) { + const id = ele.id + const eleVal = ele.options.value.toString() + if (this.inDraw && this.manualModify && this.element.id === id && this.value.toString() !== eleVal && this.defaultValueStr === eleVal) { this.value = this.fillValueDerfault() this.search() } diff --git a/core/frontend/src/components/widget/deWidget/DeNumberRange.vue b/core/frontend/src/components/widget/deWidget/DeNumberRange.vue index beb9410fdf..bc20b38d30 100644 --- a/core/frontend/src/components/widget/deWidget/DeNumberRange.vue +++ b/core/frontend/src/components/widget/deWidget/DeNumberRange.vue @@ -160,8 +160,10 @@ export default { this.form.min = null this.form.max = null }, - resetDefaultValue(id) { - if (this.inDraw && this.manualModify && this.element.id === id) { + resetDefaultValue(ele) { + const id = ele.id + const eleVal = ele.options.value.toString() + if (this.inDraw && this.manualModify && this.element.id === id && this.defaultValueStr === eleVal) { if (!this.element.options.value) { this.form.min = null this.form.max = null diff --git a/core/frontend/src/components/widget/deWidget/DeSelect.vue b/core/frontend/src/components/widget/deWidget/DeSelect.vue index 970ec23773..599e192c0e 100644 --- a/core/frontend/src/components/widget/deWidget/DeSelect.vue +++ b/core/frontend/src/components/widget/deWidget/DeSelect.vue @@ -345,8 +345,10 @@ export default { this.$refs.deSelect.$refs.visualSelect.blur() } }, - resetDefaultValue(id) { - if (this.inDraw && this.manualModify && this.element.id === id) { + resetDefaultValue(ele) { + const id = ele.id + const eleVal = ele.options.value.toString() + if (this.inDraw && this.manualModify && this.element.id === id && this.value.toString() !== eleVal && this.defaultValueStr === eleVal) { if (this.selectFirst) { this.fillFirstValue() this.firstChange(this.value) diff --git a/core/frontend/src/components/widget/deWidget/DeSelectGrid.vue b/core/frontend/src/components/widget/deWidget/DeSelectGrid.vue index 892719dfee..5c0e9188e2 100644 --- a/core/frontend/src/components/widget/deWidget/DeSelectGrid.vue +++ b/core/frontend/src/components/widget/deWidget/DeSelectGrid.vue @@ -282,8 +282,10 @@ export default { this.checkAll = false this.isIndeterminate = false }, - resetDefaultValue(id) { - if (this.inDraw && this.manualModify && this.element.id === id) { + resetDefaultValue(ele) { + const id = ele.id + const eleVal = ele.options.value.toString() + if (this.inDraw && this.manualModify && this.element.id === id && this.value.toString() !== eleVal && this.defaultValueStr === eleVal) { this.value = this.fillValueDerfault() this.changeValue(this.value) diff --git a/core/frontend/src/components/widget/deWidget/DeSelectTree.vue b/core/frontend/src/components/widget/deWidget/DeSelectTree.vue index 86c2c4a678..834d9a9607 100644 --- a/core/frontend/src/components/widget/deWidget/DeSelectTree.vue +++ b/core/frontend/src/components/widget/deWidget/DeSelectTree.vue @@ -234,8 +234,10 @@ export default { this.value = this.element.options.attrs.multiple ? [] : null this.$refs.deSelectTree && this.$refs.deSelectTree.resetSelectAll && this.$refs.deSelectTree.resetSelectAll() }, - resetDefaultValue(id) { - if (this.inDraw && this.manualModify && this.element.id === id) { + resetDefaultValue(ele) { + const id = ele.id + const eleVal = ele.options.value.toString() + if (this.inDraw && this.manualModify && this.element.id === id && this.value.toString() !== eleVal && this.defaultValueStr === eleVal) { this.value = this.fillValueDerfault() this.changeValue(this.value) } diff --git a/core/frontend/src/views/panel/edit/index.vue b/core/frontend/src/views/panel/edit/index.vue index e1b623485b..99447afee8 100644 --- a/core/frontend/src/views/panel/edit/index.vue +++ b/core/frontend/src/views/panel/edit/index.vue @@ -1269,7 +1269,7 @@ export default { this.$store.commit('recordSnapshot', 'sureFilter') this.$store.commit('setCurComponent', { component: this.currentFilterCom, index: this.curComponentIndex }) this.$store.commit('setComponentFromList', this.currentFilterCom) - bus.$emit('reset-default-value', this.currentFilterCom.id) + bus.$emit('reset-default-value', this.currentFilterCom) this.closeFilter() }, reFreshComponent(component) {