重新构建一遍okr-tree

This commit is contained in:
aixianling
2022-08-23 10:37:38 +08:00
parent 59542c73b3
commit e445063afc
9 changed files with 1591 additions and 41 deletions

View File

@@ -0,0 +1,27 @@
export const NODE_KEY = "$treeNodeId";
export const markNodeData = function(node, data) {
if (!data || data[NODE_KEY]) return;
Object.defineProperty(data, NODE_KEY, {
value: node.id,
enumerable: false,
configurable: false,
writable: false
});
};
export const getNodeKey = function(key, data) {
if (!key) return data[NODE_KEY];
return data[key];
};
export const findNearestComponent = (element, componentName) => {
let target = element;
while (target && target.tagName !== "BODY") {
if (target.__vue__ && target.__vue__.$options.name === componentName) {
return target.__vue__;
}
target = target.parentNode;
}
return null;
};