From c5f6f47b926e937a55a2723c4177e8ec1e86f3ed Mon Sep 17 00:00:00 2001 From: toesbieya <1647775459@qq.com> Date: Sun, 26 Jul 2020 00:45:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=95=86=E5=93=81=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E9=80=89=E6=8B=A9=E6=9C=89=E8=AF=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../order/components/CategorySelector.vue | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/vue/src/views/purchase/order/components/CategorySelector.vue b/vue/src/views/purchase/order/components/CategorySelector.vue index 5be34e4..c2acdab 100644 --- a/vue/src/views/purchase/order/components/CategorySelector.vue +++ b/vue/src/views/purchase/order/components/CategorySelector.vue @@ -40,7 +40,9 @@ computed: { tree() { - return this.$store.state.dataCache.categoryTree + const arr = this.$store.state.dataCache.categoryTree + this.addDisabledAttr(arr) + return arr }, selectableCategories() { return this.$store.state.dataCache.categories.filter(i => i.type === 1) @@ -50,14 +52,17 @@ methods: { init() { if (this.tree.length === 0) { - getAll() - .then(data => { - data.forEach(i => i._disabled = i.type === 0) - this.$store.commit('dataCache/categories', data) - }) + getAll().then(data => this.$store.commit('dataCache/categories', data)) } }, + addDisabledAttr(arr) { + arr.forEach(i => { + i._disabled = i.type !== 1 + i.children && this.addDisabledAttr(i.children) + }) + }, + change(v) { if (isEmpty(v) || this.selected.length <= 0) return if (this.selected.includes(v)) {