|
@@ -18,7 +18,7 @@ const findTenderTreeNode = function(sortId, tree) {
|
|
|
findTenderTreeNode(sortId, item.children);
|
|
|
}
|
|
|
});
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
function removeValueToCate(cate) {
|
|
|
const changeCate = JSON.parse(JSON.stringify(cate));
|
|
@@ -29,6 +29,40 @@ function removeValueToCate(cate) {
|
|
|
}
|
|
|
return newCate;
|
|
|
}
|
|
|
+
|
|
|
+function recursiveExpand(nodes, parent, checkFun) {
|
|
|
+ for (const node of nodes) {
|
|
|
+ const expanded = checkFun(node);
|
|
|
+ if (!expanded && node.sort_id) hideList.push({sort_id: node.sort_id});
|
|
|
+ if (node.expanded !== expanded) {
|
|
|
+ node.expanded = expanded;
|
|
|
+ if (node.sort_id) {
|
|
|
+ if (node.expanded) {
|
|
|
+ $('.c-body tr td span[cid="' + node.sort_id + '"]').children('i').removeClass('fa-plus-square-o').addClass('fa-minus-square-o');
|
|
|
+ $('.c-body tr td span[cid="' + node.sort_id + '"]').attr('title', '收起');
|
|
|
+ } else {
|
|
|
+ $('.c-body tr td span[cid="' + node.sort_id + '"]').children('i').removeClass('fa-minus-square-o').addClass('fa-plus-square-o');
|
|
|
+ $('.c-body tr td span[cid="' + node.sort_id + '"]').attr('title', '展开');
|
|
|
+ }
|
|
|
+ doTrStatus(node, node.expanded ? 'show' : 'hide');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ node.visible = parent ? (parent.expanded && parent.visible) : true;
|
|
|
+ if (node.children) recursiveExpand(node.children, node, checkFun);
|
|
|
+ }
|
|
|
+}
|
|
|
+function expandByCustom(checkFun) {
|
|
|
+ hideList = [];
|
|
|
+ recursiveExpand(tenderTree, null, checkFun);
|
|
|
+}
|
|
|
+
|
|
|
+function expandByLevel(level) {
|
|
|
+ expandByCustom(function (n) {
|
|
|
+ return n.level < level;
|
|
|
+ });
|
|
|
+ setLocalCache(uphlname, JSON.stringify(hideList));
|
|
|
+}
|
|
|
+
|
|
|
// 根据标段类别设置排序
|
|
|
function sortTenderTree(teTree = tenderTree) {
|
|
|
for (const tender of teTree) {
|
|
@@ -120,6 +154,8 @@ function doTrStatus(node, status, all = '') {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+let tenderTreeShowLevel;
|
|
|
+
|
|
|
$(document).ready(() => {
|
|
|
// 展开和收起
|
|
|
$('body').on('click', '.fold-switch', function () {
|
|
@@ -169,7 +205,44 @@ $(document).ready(() => {
|
|
|
}
|
|
|
}
|
|
|
setTopTr();
|
|
|
- })
|
|
|
+ });
|
|
|
+
|
|
|
+ tenderTreeShowLevel = $.cs_showLevel({
|
|
|
+ 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;
|
|
|
+ };
|
|
|
+ return tenderTree.map(getChildrenLevel).reduce((x, y) => { return Math.max(x, y); }, 0) - 1;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ { type: 'last', title: '最底层' },
|
|
|
+ ],
|
|
|
+ showLevel: function (tag) {
|
|
|
+
|
|
|
+ switch (tag) {
|
|
|
+ case "1":
|
|
|
+ case "2":
|
|
|
+ case "3":
|
|
|
+ case "4":
|
|
|
+ case "5":
|
|
|
+ expandByLevel(parseInt(tag));
|
|
|
+ break;
|
|
|
+ case "last":
|
|
|
+ expandByLevel(20);
|
|
|
+ break;
|
|
|
+ default: return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
|