'use strict';
(function () {
const aside = document.querySelector('.aside');
const tollbar = document.querySelector('.toolbar');
const menu = document.querySelector('.menu');
const main = document.querySelector('.main');
const hiddenClass = 'hidden';
const activeClass = 'actived';
tollbar.addEventListener('click', (event) => {
const currentShow = tollbar.children[0].classList.contains(hiddenClass);
if (!currentShow) {
tollbar.children[0].classList.add(hiddenClass);
tollbar.children[1].classList.remove(hiddenClass);
tollbar.setAttribute('title', '展开');
aside.style.cssText = 'width: 0 !important;';
aside.classList.remove('aside-show');
} else {
tollbar.children[0].classList.remove(hiddenClass);
tollbar.children[1].classList.add(hiddenClass);
tollbar.setAttribute('title', '隐藏');
aside.classList.add('aside-show');
aside.style.cssText = '';
}
barChartResize();
});
const len = menu.children.length;
for (let index = 0; index < len; index++) {
const el = menu.children[index];
el.addEventListener('click', (event) => {
main.children[index].classList.remove('hide');
el.classList.add(activeClass);
for (let i = 0; i < len; i++) {
if (i !== index) {
menu.children[i].classList.remove(activeClass);
main.children[i].classList.add('hide');
}
}
if (index === 0) {
setTimeout(() => {
barChartResize();
}, 10);
} else if (index === 1) {
setTimeout(() => {
const table = document.querySelector('.table');
const tbody = table.children[1];
tbody.style.cssText = `max-height: ${table.clientHeight - 32}px;`;
}, 10);
}
});
}
})();