'use strict'; /** * * * @author Mai * @date * @version */ $.cs_showLevel = function (setting) { const sortTitle = ['第一层', '第二层', '第三层','第四层', '第五层']; if (!setting.selector) throw '未指定模块'; if (!setting.levels) { setting.levels = [ { type: 'sort', count: 5, }, { type: 'last', title: '最底层' }, // { type: 'leafXmj', title: '只显示项目节' }, // { type: 'curMeasure', title: '只显示本期计量' }, ]; } const initShowLevel = function () { const obj = $(setting.selector); const html = []; html.push(''); html.push('
'); obj.html(html.join('')); $('a[name=showLevel]').click(function () { setTimeout(() => { const tag = $(this).attr('tag'); showWaitingView(); setting.showLevel(tag); closeWaitingView(); }); }); refreshMenuVisible(); }; const refreshMenuVisible = function () { const showMenu = function (tag, visible) { if (visible) $(`[tag=${tag}]`).show(); if (!visible) $(`[tag=${tag}]`).hide(); }; for (const l of setting.levels) { if (l.type === 'sort') { let visibleCount = typeof l.visible_count === 'function' ? l.visible_count() : l.visible_count; for (let i = 1; i <= l.count; ++i) { showMenu(i, i <= visibleCount); } } else { const visible = typeof l.visible === 'function' ? l.visible() : l.visible; showMenu(l.type, visible); } } }; return { initShowLevel, refreshMenuVisible } ; };