mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
@@ -48,6 +48,9 @@ function useStore<T>() {
|
||||
// 没有使用 computed,而是手动更新部分数据 https://github.com/vuejs/vue/issues/6660#issuecomment-331417140
|
||||
instance.store.updateCurrentRowData()
|
||||
instance.store.updateExpandRows()
|
||||
instance.store.updateTreeData(
|
||||
instance.store.states.defaultExpandAll.value
|
||||
)
|
||||
if (unref(states.reserveSelection)) {
|
||||
instance.store.assertRowKey()
|
||||
instance.store.updateSelectionByRowKey()
|
||||
|
||||
@@ -66,18 +66,19 @@ function useTree<T>(watcherData: WatcherPropsData<T>) {
|
||||
return res
|
||||
}
|
||||
|
||||
const updateTreeData = () => {
|
||||
const updateTreeData = (
|
||||
ifExpandAll = instance.store?.states.defaultExpandAll.value
|
||||
) => {
|
||||
const nested = normalizedData.value
|
||||
const normalizedLazyNode_ = normalizedLazyNode.value
|
||||
const keys = Object.keys(nested)
|
||||
const newTreeData = {}
|
||||
if (keys.length) {
|
||||
const oldTreeData = unref(treeData)
|
||||
const defaultExpandAll = instance.store?.states.defaultExpandAll.value
|
||||
const rootLazyRowKeys = []
|
||||
const getExpanded = (oldValue, key) => {
|
||||
const included =
|
||||
defaultExpandAll ||
|
||||
ifExpandAll ||
|
||||
(expandRowKeys.value && expandRowKeys.value.indexOf(key) !== -1)
|
||||
return !!((oldValue && oldValue.expanded) || included)
|
||||
}
|
||||
@@ -124,8 +125,18 @@ function useTree<T>(watcherData: WatcherPropsData<T>) {
|
||||
instance.store?.updateTableScrollY()
|
||||
}
|
||||
|
||||
watch(() => normalizedData.value, updateTreeData)
|
||||
watch(() => normalizedLazyNode.value, updateTreeData)
|
||||
watch(
|
||||
() => normalizedData.value,
|
||||
() => {
|
||||
updateTreeData()
|
||||
}
|
||||
)
|
||||
watch(
|
||||
() => normalizedLazyNode.value,
|
||||
() => {
|
||||
updateTreeData()
|
||||
}
|
||||
)
|
||||
|
||||
const updateTreeExpandKeys = (value: string[]) => {
|
||||
expandRowKeys.value = value
|
||||
|
||||
@@ -430,6 +430,7 @@ function useWatcher<T>() {
|
||||
const {
|
||||
updateTreeExpandKeys,
|
||||
toggleTreeExpansion,
|
||||
updateTreeData,
|
||||
loadOrToggle,
|
||||
states: treeStates,
|
||||
} = useTree({
|
||||
@@ -490,6 +491,7 @@ function useWatcher<T>() {
|
||||
updateExpandRows,
|
||||
updateCurrentRowData,
|
||||
loadOrToggle,
|
||||
updateTreeData,
|
||||
states: {
|
||||
rowKey,
|
||||
data,
|
||||
|
||||
Reference in New Issue
Block a user