123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- '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('<button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' +
- '<i class="fa fa-list-ol"></i> 显示层级</button>');
- html.push('<div class="dropdown-menu" aria-labelledby="dropdownMenuButton" id="showLevelList">');
- for (const l of setting.levels) {
- if (l.type === 'sort') {
- let count = typeof l.count === 'function' ? l.count() : l.count;
- count = Math.min(count, 5);
- for (let i = 1; i <= count; ++i) {
- html.push(`<a class="dropdown-item" name="showLevel" tag="${i}" href="javascript: void(0);">${sortTitle[i-1]}</a>`);
- }
- } else {
- html.push(`<a class="dropdown-item" name="showLevel" tag="${l.type}" href="javascript: void(0);">${l.title}</a>`);
- }
- }
- html.push('</div>');
- obj.html(html.join(''));
- $('a[name=showLevel]').click(function () {
- setTimeout(() => {
- const tag = $(this).attr('tag');
- showWaitingView();
- setting.showLevel(tag);
- closeWaitingView();
- });
- });
- };
- return { initShowLevel } ;
- };
|