From 9223f5c85713d4e7c0e0ebdc321102b11e4f8318 Mon Sep 17 00:00:00 2001 From: Jo <479214531@qq.com> Date: Fri, 12 Nov 2021 00:07:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=88=86=E7=B1=BB=E9=BB=98?= =?UTF-8?q?=E8=AE=A4=E6=98=BE=E7=A4=BA=E6=9C=80=E9=87=8C=E5=B1=82=E7=9A=84?= =?UTF-8?q?=E7=AC=AC=E4=B8=80=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/data/list/index.vue | 16 ++++++++++++++-- src/pages/stat/list/index.vue | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/pages/data/list/index.vue b/src/pages/data/list/index.vue index d0e6b69..b4fb0a6 100644 --- a/src/pages/data/list/index.vue +++ b/src/pages/data/list/index.vue @@ -341,19 +341,31 @@ export default { }, // 分类展开及点击回调 selectType(index, indexPath) { - console.log(index, indexPath) let introduce = '' let dataSource = '' this.keyword = '' let list = this.typeList let select = '' + // 获取最里层的第一个子级id + function getDeepest(data) { + if (data[0].children && data[0].children.length) { + getDeepest(data[0].children) + } else { + select = data[0].id + } + } function handleData(data) { data.map((n, i) => { // 匹配到点击的分类,默认展开子级第一个分类 if (n.id == index) { if (n.introduce) introduce = n.introduce if (n.dataSource) dataSource = n.dataSource - if (!select) select = n.children.length ? (n.children[0].children.length ? n.children[0].children[0].id : n.children[0].id) : n.id + // 如果有子级,则递归取到最下面的第一级子级id,如果没有子级,则取当前id + if (n.children.length) { + getDeepest(n.children) + } else { + select = index + } } else { handleData(n.children) } diff --git a/src/pages/stat/list/index.vue b/src/pages/stat/list/index.vue index 9345d8a..47d62f3 100644 --- a/src/pages/stat/list/index.vue +++ b/src/pages/stat/list/index.vue @@ -70,7 +70,7 @@ -
+
展开更多