源参数默认展开

This commit is contained in:
caozehui
2025-03-10 10:09:15 +08:00
parent 667ed3bcc0
commit 258d3d692f

View File

@@ -6,9 +6,9 @@
:pagination="false" :pagination="false"
:toolButton="false" :toolButton="false"
:data="tableData" :data="tableData"
row-key="id" :row-key="id"
:style="{ height: '250px',maxHeight: '400px',overflow:'hidden'}" :style="{ height: '250px',maxHeight: '400px',overflow:'hidden'}"
:expand-row-keys="['0']" :expand-row-keys="defaultExpandRowKeys"
> >
<!-- 表格 header 按钮 --> <!-- 表格 header 按钮 -->
<template #tableHeader='scope'> <template #tableHeader='scope'>
@@ -71,25 +71,26 @@ watch(() => props.parameterStr, (newData) => {
}) })
const defaultExpandRowKeys =computed(() => { const defaultExpandRowKeys =computed(() => {
return '548c00d2e4744c38aee938cb08e2ff3b' return getDefaultKeyArray(tableData.value)
}) })
const getDefaultKey = (data: any[]) => { const getDefaultKeyArray = (data: any[]) => {
if (!data || data.length === 0) { if (!data || data.length === 0) {
return []; return []
} }
const firstElement = data[0]; const firstElement = data[0]
let result: any[] = []
recursion(firstElement,result)
return findFirstLeafNode(firstElement); return result
} }
const findFirstLeafNode = (node: any): any => { const recursion = (node: any, result: any[]) => {
if (!node.children || node.children.length === 0) { if (node.children && node.children.length !== 0) {
return node.id; result.push(node.id)
recursion(node.children[0], result)
} }
return findFirstLeafNode(node.children[0]);
} }
const getTableList = () => { const getTableList = () => {