|
@@ -155,6 +155,15 @@ function doTrStatus(node, status, all = '') {
|
|
|
}
|
|
|
|
|
|
let tenderTreeShowLevel;
|
|
|
+const getChildrenLevel = function (node) {
|
|
|
+ let iLevel = node.level;
|
|
|
+ if (node.children && node.children.length > 0) {
|
|
|
+ for (const c of node.children) {
|
|
|
+ iLevel = Math.max(iLevel, getChildrenLevel(c));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return iLevel;
|
|
|
+};
|
|
|
|
|
|
$(document).ready(() => {
|
|
|
// 展开和收起
|
|
@@ -211,20 +220,16 @@ $(document).ready(() => {
|
|
|
selector: '#show-level',
|
|
|
levels: [
|
|
|
{
|
|
|
- type: 'sort', count: function () {
|
|
|
- const getChildrenLevel = function (node) {
|
|
|
- let iLevel = node.level;
|
|
|
- if (node.children && node.children.length > 0) {
|
|
|
- for (const c of node.children) {
|
|
|
- iLevel = Math.max(iLevel, getChildrenLevel(c));
|
|
|
- }
|
|
|
- }
|
|
|
- return iLevel;
|
|
|
- };
|
|
|
+ type: 'sort', count: 5, visible_count: function () {
|
|
|
return tenderTree.map(getChildrenLevel).reduce((x, y) => { return Math.max(x, y); }, 0) - 1;
|
|
|
}
|
|
|
},
|
|
|
- { type: 'last', title: '最底层' },
|
|
|
+ {
|
|
|
+ type: 'last', title: '最底层', visible: function () {
|
|
|
+ const count = tenderTree.map(getChildrenLevel).reduce((x, y) => { return Math.max(x, y); }, 0) - 1;
|
|
|
+ return count > 0;
|
|
|
+ }
|
|
|
+ },
|
|
|
],
|
|
|
showLevel: function (tag) {
|
|
|
|