|
@@ -136,6 +136,10 @@ const props = defineProps({
|
|
|
type: String,
|
|
|
default: '',
|
|
|
},
|
|
|
+ treeAutoExpandKeys: {
|
|
|
+ type: Array,
|
|
|
+ default: () => [],
|
|
|
+ },
|
|
|
})
|
|
|
|
|
|
// 事件
|
|
@@ -144,18 +148,20 @@ const contractId = ref(props.contractId)
|
|
|
const classType = ref(props.classType)
|
|
|
const authBtnTabKey = ref(props.authBtnTabKey)
|
|
|
const primaryKeyId = ref(props.primaryKeyId)
|
|
|
-const TreeAutoExpandKeys = ref(getStoreValue('wbsTreeExpandKeys') || [])
|
|
|
+const TreeAutoExpandKeys = ref(props.treeAutoExpandKeys)
|
|
|
// 监听
|
|
|
watch(() => [
|
|
|
props.contractId,
|
|
|
props.classType,
|
|
|
props.authBtnTabKey,
|
|
|
props.primaryKeyId,
|
|
|
-], ([cid, clas, tab, pkid]) => {
|
|
|
+ props.treeAutoExpandKeys,
|
|
|
+], ([cid, clas, tab, pkid, keys]) => {
|
|
|
contractId.value = cid
|
|
|
classType.value = clas
|
|
|
authBtnTabKey.value = tab
|
|
|
primaryKeyId.value = pkid
|
|
|
+ TreeAutoExpandKeys.value = keys
|
|
|
|
|
|
})
|
|
|
|
|
@@ -311,9 +317,11 @@ const getSameLevelsTreeData = async () => {
|
|
|
nextTick(() => {
|
|
|
// 方案1: 使用 store 方法
|
|
|
// 方案2: 备用方案 - 使用 setTimeout 确保DOM已渲染
|
|
|
- setTimeout(() => {
|
|
|
- expandNodesManually(TreeAutoExpandKeys.value)
|
|
|
- }, 300)
|
|
|
+ console.log(TreeAutoExpandKeys.value, 'TreeAutoExpandKeys.value')
|
|
|
+ expandNodesManually(TreeAutoExpandKeys.value)
|
|
|
+ // setTimeout(() => {
|
|
|
+ // expandNodesManually(TreeAutoExpandKeys.value)
|
|
|
+ // }, 3000)
|
|
|
})
|
|
|
|
|
|
|
|
@@ -330,7 +338,7 @@ const expandNodesManually = (keys) => {
|
|
|
|
|
|
keys.forEach(key => {
|
|
|
const node = treeRef.value.getNode(key)
|
|
|
- console.log(node, 'node')
|
|
|
+
|
|
|
if (node && !node.expanded) {
|
|
|
|
|
|
|