'use strict';
/**
*
*
* @author Mai
* @date 2025/7/18
* @version
*/
const MemberPermission = function() {
let setting;
// 搜索&展开收起
let timer = null;
let oldSearchVal = null;
$('#member-search').bind('input propertychange', function(e) {
oldSearchVal = e.target.value;
timer && clearTimeout(timer);
timer = setTimeout(() => {
const newVal = $('#member-search').val();
let html = '';
if (newVal && newVal === oldSearchVal) {
accountList
.filter(item => item && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1)))
.forEach(item => {
html += `
`;
group.groupList.forEach(item => {
html += `
${item.name}${item.mobile || ''}
${item.role || ''}
`
});
html += '
';
});
$('.book-list').empty();
$('.book-list').append(html);
}
}
}, 400);
});
$('.book-list').on('click', 'dt', function () {
const idx = $(this).find('.acc-btn').attr('data-groupid')
const type = $(this).find('.acc-btn').attr('data-type')
if (type === 'hide') {
$(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
$(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o')
$(this).find('.acc-btn').attr('data-type', 'show')
})
} else {
$(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
$(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square')
$(this).find('.acc-btn').attr('data-type', 'hide')
})
}
return false
});
// 添加
$('dl').on('click', 'dd', function () {
const auditorId = parseInt($(this).data('id'));
const user = accountList.find(x => { return x.id === auditorId; });
const check = $(`tr[uid=${auditorId}]`, '#member-list');
if (check.length > 0) {
toastr.error('请勿重复添加成员');
return;
}
$('#member-list').append(getUserPermissionHtml({ uid: user.id, name: user.name, role: user.role }));
});
const getUserPermissionHtml = function(user) {
const html = [];
html.push(`