arms-app 1.0.81 → 1.0.83
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.
- package/package.json +1 -1
- package/public/1.d +23 -37
package/package.json
CHANGED
package/public/1.d
CHANGED
|
@@ -1,43 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
/**
|
|
2
|
+
* 原地修改树:把 id 命中的节点 disabled 设置为指定值
|
|
3
|
+
* @param {Array} tree
|
|
4
|
+
* @param {Array<string|number>} ids
|
|
5
|
+
* @param {boolean} disabledValue
|
|
6
|
+
* @param {string} idKey
|
|
7
|
+
* @param {string} childrenKey
|
|
8
|
+
* @returns {Array} tree(同一个引用)
|
|
9
|
+
*/
|
|
10
|
+
function setDisabledInTreeMutate(tree, ids, disabledValue = true, idKey = 'id', childrenKey = 'children') {
|
|
11
|
+
const idSet = new Set(ids);
|
|
12
|
+
|
|
13
|
+
const stack = Array.isArray(tree) ? [...tree] : [];
|
|
14
|
+
while (stack.length) {
|
|
15
|
+
const node = stack.pop();
|
|
16
|
+
if (!node || typeof node !== 'object') continue;
|
|
17
|
+
|
|
18
|
+
if (idSet.has(node[idKey])) {
|
|
19
|
+
node.disabled = disabledValue;
|
|
20
20
|
}
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
return tree;
|
|
24
|
-
}
|
|
25
|
-
function treeToList(tree) {
|
|
26
|
-
const result = [];
|
|
27
|
-
|
|
28
|
-
function traverse(node, parentId = null) {
|
|
29
|
-
const { children, ...rest } = node;
|
|
30
21
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
if (children && children.length) {
|
|
37
|
-
children.forEach(child => traverse(child, node.id));
|
|
22
|
+
const children = node[childrenKey];
|
|
23
|
+
if (Array.isArray(children)) {
|
|
24
|
+
for (let i = 0; i < children.length; i++) stack.push(children[i]);
|
|
38
25
|
}
|
|
39
26
|
}
|
|
40
27
|
|
|
41
|
-
tree
|
|
42
|
-
return result;
|
|
28
|
+
return tree;
|
|
43
29
|
}
|