From 956b40b752769de90d7d27b1ae5f8b48d9677e08 Mon Sep 17 00:00:00 2001 From: chenjinsong <523037378@qq.com> Date: Sun, 25 Jul 2021 18:45:08 +0800 Subject: [PATCH] =?UTF-8?q?CN-64=20perf:=20entity=E5=B7=A6=E4=BE=A7?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E6=A1=86=E4=BA=A4=E4=BA=92=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/entities/LeftFilter.vue | 27 ++++++++++++++++++++++++-- src/views/entities/EntityExplorer.vue | 8 +++++++- 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/components/entities/LeftFilter.vue b/src/components/entities/LeftFilter.vue index 363b8107..693ac796 100644 --- a/src/components/entities/LeftFilter.vue +++ b/src/components/entities/LeftFilter.vue @@ -16,6 +16,7 @@ :props="{ isLeaf: 'leaf' }" :expand-on-click-node="false" :lazy="i === 0" + :ref="`tree-${i}`" highlight-current @node-click="(data, node, component) => nodeClick(data, node, component, i)" > @@ -41,12 +42,22 @@ export default { }, data () { return { - active: ['0', '1'] + active: ['0', '1'], + currentDataTop: null, + currentDataBottom: null } }, methods: { nodeClick (data, node, component, index) { - // if ((data.country && !data.region) || ()) + const currentData = index === 0 ? this.currentDataTop : this.currentDataBottom + if (this.dataEqual(currentData, data)) { + node.isCurrent = false + } + if (index === 0) { + this.currentDataTop = this.$_.cloneDeep(data) + } else { + this.currentDataBottom = this.$_.cloneDeep(data) + } this.$emit('select', data, node, index) }, showMore (key, hasnotMore) { @@ -56,6 +67,18 @@ export default { }, loadFilter (node, resolve, f) { this.$emit('loadFilter', node, resolve, f.filterType, f.childrenKey, f.key) + }, + dataEqual (obj1, obj2) { + if (!obj1 || !obj2) { + return false + } + let equal = true + this.$_.forIn(obj1, (value, key) => { + if (value !== obj2[key]) { + equal = false + } + }) + return equal } }, watch: { diff --git a/src/views/entities/EntityExplorer.vue b/src/views/entities/EntityExplorer.vue index fb06cd07..c4d637c6 100644 --- a/src/views/entities/EntityExplorer.vue +++ b/src/views/entities/EntityExplorer.vue @@ -179,7 +179,13 @@ export default { }) }, async select (data, node, index) { - this.pageObjRight = { ...this.pageObjRight, ...data } + const pageObjRight = { ...this.pageObjRight, ...data } + this.$_.forIn(data, (value, key) => { + if (value === this.pageObjRight[key]) { + delete pageObjRight[key] + } + }) + this.pageObjRight = JSON.parse(JSON.stringify(pageObjRight)) const res = await loadList(node, this.filterType, this.pageObjRight) this.listData = res.data.result },