@handaotech-design/bom 0.0.45 → 0.0.47
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -56,6 +56,7 @@ const displayTreeData = computed(() => {
|
|
|
56
56
|
})
|
|
57
57
|
const isPreservingTreeState = ref<boolean>(false)
|
|
58
58
|
const isAutoLoadingRoots = ref(false)
|
|
59
|
+
let isProgrammaticScroll = false
|
|
59
60
|
const searchMatches = ref<string[]>([])
|
|
60
61
|
const currentMatchIndex = ref(0)
|
|
61
62
|
const initTreeState = () => {
|
|
@@ -102,6 +103,7 @@ async function locateNodeByKey(targetKey: string) {
|
|
|
102
103
|
if (!targetKey) {
|
|
103
104
|
return
|
|
104
105
|
}
|
|
106
|
+
isProgrammaticScroll = true
|
|
105
107
|
ensureRootVisibleByKey(targetKey)
|
|
106
108
|
const parentKeys = getParentKeys(targetKey) || []
|
|
107
109
|
expandedKeys.value = Array.from(new Set([
|
|
@@ -115,6 +117,9 @@ async function locateNodeByKey(targetKey: string) {
|
|
|
115
117
|
align: 'top',
|
|
116
118
|
})
|
|
117
119
|
focusNode(targetKey)
|
|
120
|
+
requestAnimationFrame(() => {
|
|
121
|
+
isProgrammaticScroll = false
|
|
122
|
+
})
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
const scrollToMatch = async (index: number) => {
|
|
@@ -309,7 +314,7 @@ const loadMoreRoot = () => {
|
|
|
309
314
|
}
|
|
310
315
|
|
|
311
316
|
const maybeAutoLoadMoreRoot = () => {
|
|
312
|
-
if (isAutoLoadingRoots.value || !canLoadMoreRoot.value) {
|
|
317
|
+
if (isAutoLoadingRoots.value || !canLoadMoreRoot.value || isProgrammaticScroll) {
|
|
313
318
|
return
|
|
314
319
|
}
|
|
315
320
|
const container = treeContainerRef.value
|
|
@@ -357,6 +362,10 @@ async function _loadData(node: EventDataNode) {
|
|
|
357
362
|
}
|
|
358
363
|
|
|
359
364
|
function focusNode(key: string) {
|
|
365
|
+
// 先清理页面上已有的焦点动画
|
|
366
|
+
document.querySelectorAll<HTMLElement>('.tree-node-tittle.focus-flash').forEach(el => {
|
|
367
|
+
el.classList.remove('focus-flash')
|
|
368
|
+
})
|
|
360
369
|
// 1. 用 antd Tree 自带滚动
|
|
361
370
|
treeRef.value?.scrollTo({ key, align: 'center' })
|
|
362
371
|
|
package/dist/es/utils/bom.js
CHANGED
|
@@ -46,6 +46,7 @@ export function convertBomDataToTree(treeData, nodeConfigRule) {
|
|
|
46
46
|
firstSelectableNodeKey = node.key;
|
|
47
47
|
}
|
|
48
48
|
const isLeafObj = {
|
|
49
|
+
PROCESS_PLAN: false,
|
|
49
50
|
OPERATION: true
|
|
50
51
|
};
|
|
51
52
|
Object.assign(node, {
|
|
@@ -53,7 +54,8 @@ export function convertBomDataToTree(treeData, nodeConfigRule) {
|
|
|
53
54
|
title: finalTitle,
|
|
54
55
|
selectable: boolSelectable,
|
|
55
56
|
icon,
|
|
56
|
-
|
|
57
|
+
// TODO 优化逻辑,从配置中读取
|
|
58
|
+
isLeaf: typeof isLeafObj[node.businessType] !== "undefined" ? isLeafObj[node.businessType] : !node.children?.length,
|
|
57
59
|
...rest
|
|
58
60
|
});
|
|
59
61
|
const { children, ...restProps } = node;
|
|
@@ -56,6 +56,7 @@ const displayTreeData = computed(() => {
|
|
|
56
56
|
})
|
|
57
57
|
const isPreservingTreeState = ref<boolean>(false)
|
|
58
58
|
const isAutoLoadingRoots = ref(false)
|
|
59
|
+
let isProgrammaticScroll = false
|
|
59
60
|
const searchMatches = ref<string[]>([])
|
|
60
61
|
const currentMatchIndex = ref(0)
|
|
61
62
|
const initTreeState = () => {
|
|
@@ -102,6 +103,7 @@ async function locateNodeByKey(targetKey: string) {
|
|
|
102
103
|
if (!targetKey) {
|
|
103
104
|
return
|
|
104
105
|
}
|
|
106
|
+
isProgrammaticScroll = true
|
|
105
107
|
ensureRootVisibleByKey(targetKey)
|
|
106
108
|
const parentKeys = getParentKeys(targetKey) || []
|
|
107
109
|
expandedKeys.value = Array.from(new Set([
|
|
@@ -115,6 +117,9 @@ async function locateNodeByKey(targetKey: string) {
|
|
|
115
117
|
align: 'top',
|
|
116
118
|
})
|
|
117
119
|
focusNode(targetKey)
|
|
120
|
+
requestAnimationFrame(() => {
|
|
121
|
+
isProgrammaticScroll = false
|
|
122
|
+
})
|
|
118
123
|
}
|
|
119
124
|
|
|
120
125
|
const scrollToMatch = async (index: number) => {
|
|
@@ -309,7 +314,7 @@ const loadMoreRoot = () => {
|
|
|
309
314
|
}
|
|
310
315
|
|
|
311
316
|
const maybeAutoLoadMoreRoot = () => {
|
|
312
|
-
if (isAutoLoadingRoots.value || !canLoadMoreRoot.value) {
|
|
317
|
+
if (isAutoLoadingRoots.value || !canLoadMoreRoot.value || isProgrammaticScroll) {
|
|
313
318
|
return
|
|
314
319
|
}
|
|
315
320
|
const container = treeContainerRef.value
|
|
@@ -357,6 +362,10 @@ async function _loadData(node: EventDataNode) {
|
|
|
357
362
|
}
|
|
358
363
|
|
|
359
364
|
function focusNode(key: string) {
|
|
365
|
+
// 先清理页面上已有的焦点动画
|
|
366
|
+
document.querySelectorAll<HTMLElement>('.tree-node-tittle.focus-flash').forEach(el => {
|
|
367
|
+
el.classList.remove('focus-flash')
|
|
368
|
+
})
|
|
360
369
|
// 1. 用 antd Tree 自带滚动
|
|
361
370
|
treeRef.value?.scrollTo({ key, align: 'center' })
|
|
362
371
|
|
package/dist/lib/utils/bom.js
CHANGED
|
@@ -55,6 +55,7 @@ function convertBomDataToTree(treeData, nodeConfigRule) {
|
|
|
55
55
|
firstSelectableNodeKey = node.key;
|
|
56
56
|
}
|
|
57
57
|
const isLeafObj = {
|
|
58
|
+
PROCESS_PLAN: false,
|
|
58
59
|
OPERATION: true
|
|
59
60
|
};
|
|
60
61
|
Object.assign(node, {
|
|
@@ -62,7 +63,8 @@ function convertBomDataToTree(treeData, nodeConfigRule) {
|
|
|
62
63
|
title: finalTitle,
|
|
63
64
|
selectable: boolSelectable,
|
|
64
65
|
icon,
|
|
65
|
-
|
|
66
|
+
// TODO 优化逻辑,从配置中读取
|
|
67
|
+
isLeaf: typeof isLeafObj[node.businessType] !== "undefined" ? isLeafObj[node.businessType] : !node.children?.length,
|
|
66
68
|
...rest
|
|
67
69
|
});
|
|
68
70
|
const {
|