|
@@ -62,7 +62,6 @@ $(document).ready(function() {
|
|
|
html.push('<button class="btn btn-outline-primary btn-sm ml-1" name="up"><i class="fa fa-arrow-up"></i></button>');
|
|
|
html.push('<button class="btn btn-outline-primary btn-sm ml-1" name="down"><i class="fa fa-arrow-down"></i></button>');
|
|
|
html.push('<button class="btn btn-outline-primary btn-sm ml-1" name="top">顶层</button>');
|
|
|
- if (!node.is_folder) html.push('<button class="btn btn-outline-primary btn-sm ml-1" name="member">成员管理</button>');
|
|
|
}
|
|
|
html.push('</td>');
|
|
|
return html.join('');
|
|
@@ -404,215 +403,4 @@ $(document).ready(function() {
|
|
|
$('#sm-management').attr('tree_id', '');
|
|
|
});
|
|
|
});
|
|
|
-
|
|
|
- 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 += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
|
|
|
- <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
|
|
|
- class="ml-auto">${item.mobile || ''}</span></p>
|
|
|
- <span class="text-muted">${item.role || ''}</span></dd>`
|
|
|
- });
|
|
|
- $('.book-list').empty();
|
|
|
- $('.book-list').append(html);
|
|
|
- } else {
|
|
|
- if (!$('.acc-btn').length) {
|
|
|
- accountGroup.forEach((group, idx) => {
|
|
|
- if (!group) return;
|
|
|
- html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
|
|
|
- </a> ${group.groupName}</dt>
|
|
|
- <div class="dd-content" data-toggleid="${idx}">`;
|
|
|
- group.groupList.forEach(item => {
|
|
|
- html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
|
|
|
- <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
|
|
|
- class="ml-auto">${item.mobile || ''}</span></p>
|
|
|
- <span class="text-muted">${item.role || ''}</span>
|
|
|
- </dd>`
|
|
|
- });
|
|
|
- html += '</div>';
|
|
|
- });
|
|
|
- $('.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
|
|
|
- });
|
|
|
- let orgMembers, newMembers;
|
|
|
- const generateMemberHtml = function () {
|
|
|
- const html = [];
|
|
|
- for (const mem of newMembers) {
|
|
|
- html.push(`<tr uid="${mem.uid}">`);
|
|
|
- html.push(`<td>${mem.name}</td>`);
|
|
|
- html.push(`<td>${mem.role}</td>`);
|
|
|
- // 动态投资
|
|
|
- const viewBudget = mem.budget_permission.indexOf(permissionConst.budget.view.value) >= 0;
|
|
|
- html.push(`<td><div class="custom-control custom-checkbox mb-2">
|
|
|
- <input type="checkbox" ptype="budget" sptype="view" uid="${mem.uid}" id="budgetview${mem.uid}" class="custom-control-input" ${(viewBudget ? 'checked' : '')}>
|
|
|
- <label class="custom-control-label" for="budgetview${mem.uid}"></label></div></td>`);
|
|
|
- const editBudget = mem.budget_permission.indexOf(permissionConst.budget.edit.value) >= 0;
|
|
|
- html.push(`<td><div class="custom-control custom-checkbox mb-2">
|
|
|
- <input type="checkbox" ptype="budget" sptype="edit" id="budgetedit${mem.uid}" uid="${mem.uid}" class="custom-control-input" ${(editBudget ? 'checked' : '')}>
|
|
|
- <label class="custom-control-label" for="budgetedit${mem.uid}"></label></div></td>`);
|
|
|
- // 电子文档
|
|
|
-
|
|
|
- const fileView = mem.file_permission.indexOf(permissionConst.file.view.value) >= 0;
|
|
|
- html.push(`<td><div class="custom-control custom-checkbox mb-2">
|
|
|
- <input type="checkbox" ptype="file" sptype="view" uid="${mem.uid}" id="fileview${mem.uid}" class="custom-control-input" ${(fileView ? 'checked' : '')}>
|
|
|
- <label class="custom-control-label" for="fileview${mem.uid}"></label></div></td>`);
|
|
|
- const fileUpload = mem.file_permission.indexOf(permissionConst.file.upload.value) >= 0;
|
|
|
- html.push(`<td><div class="custom-control custom-checkbox mb-2">
|
|
|
- <input type="checkbox" ptype="file" sptype="upload" id="fileupload${mem.uid}" uid="${mem.uid}" class="custom-control-input" ${(fileUpload ? 'checked' : '')}>
|
|
|
- <label class="custom-control-label" for="fileupload${mem.uid}"></label></div></td>`);
|
|
|
- const fileDelete = mem.file_permission.indexOf(permissionConst.file.delete.value) >= 0;
|
|
|
- html.push(`<td><div class="custom-control custom-checkbox mb-2">
|
|
|
- <input type="checkbox" ptype="file" sptype="delete" id="filedelete${mem.uid}" uid="${mem.uid}" class="custom-control-input" ${(fileDelete ? 'checked' : '')}>
|
|
|
- <label class="custom-control-label" for="filedelete${mem.uid}"></label></div></td>`);
|
|
|
- const fileEdit = mem.file_permission.indexOf(permissionConst.file.filing.value) >= 0;
|
|
|
- html.push(`<td><div class="custom-control custom-checkbox mb-2">
|
|
|
- <input type="checkbox" ptype="file" sptype="filing" uid="${mem.uid}" id="fileedit${mem.uid}" class="custom-control-input" ${(fileEdit ? 'checked' : '')}>
|
|
|
- <label class="custom-control-label" for="fileedit${mem.uid}"></label></div></td>`);
|
|
|
- // 关联标段
|
|
|
- const rela = mem.manage_permission.indexOf(permissionConst.manage.rela.value) >= 0;
|
|
|
- html.push(`<td><div class="custom-control custom-checkbox mb-2">
|
|
|
- <input type="checkbox" ptype="manage" sptype="rela" id="rela${mem.uid}" uid="${mem.uid}" class="custom-control-input" ${(rela ? 'checked' : '')}>
|
|
|
- <label class="custom-control-label" for="rela${mem.uid}"></label></div></td>`);
|
|
|
- html.push(`<td><a href="javascript: void(0);" class="btn btn-outline-danger btn-sm ml-1" name="del-member" uid="${mem.uid}">移除</a></td>`);
|
|
|
- html.push('</tr>');
|
|
|
- }
|
|
|
- $('#member-list').html(html.join(''));
|
|
|
- };
|
|
|
- $('[data-target="#member"]').click(function(){
|
|
|
- const tr = this.parentNode.parentNode;
|
|
|
- curBudget.id = tr.getAttribute('tree_id');
|
|
|
- curBudget.bid = tr.getAttribute('bid');
|
|
|
- curBudget.name = tr.getAttribute('bname');
|
|
|
- curBudget.rela_tender = tr.getAttribute('rela-tender');
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
- $('body').on('click', 'button[name=member]', function(e) {
|
|
|
- const treeId = $(this).parent().parent().attr('tree_id');
|
|
|
- const node = projectTreeObj.ProjectTree.getItems(treeId);
|
|
|
- if (node.is_folder) return;
|
|
|
- $('#member-ok').attr('tree_id', treeId);
|
|
|
- postData('/subproj/member', { id: treeId }, function (result) {
|
|
|
- orgMembers = result;
|
|
|
- newMembers = result;
|
|
|
- generateMemberHtml();
|
|
|
- $('#member').modal('show');
|
|
|
- });
|
|
|
- });
|
|
|
- $('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;
|
|
|
- }
|
|
|
- newMembers.push({
|
|
|
- uid: user.id,
|
|
|
- name: user.name,
|
|
|
- role: user.role,
|
|
|
- budget_permission: [],
|
|
|
- file_permission: [],
|
|
|
- manage_permission: [],
|
|
|
- });
|
|
|
- generateMemberHtml();
|
|
|
- });
|
|
|
- $('#member').on('click', 'a[name="del-member"]', function () {
|
|
|
- const id = parseInt(this.getAttribute('uid'));
|
|
|
- newMembers.splice(newMembers.findIndex(x => { return x.uid === id}), 1);
|
|
|
- generateMemberHtml();
|
|
|
- });
|
|
|
- $('#member-list').on('click', 'input', function () {
|
|
|
- const id = parseInt(this.getAttribute('uid'));
|
|
|
- const mem = newMembers.find(x => { return x.uid === id});
|
|
|
- const pType = this.getAttribute('ptype'), spType = this.getAttribute('sptype');
|
|
|
- if (this.checked) {
|
|
|
- if (pType === 'budget' && spType === 'view') {
|
|
|
- mem.budget_permission.push(parseInt(permissionConst.budget.view.value));
|
|
|
- } else if (pType === 'budget' && spType === 'edit') {
|
|
|
- mem.budget_permission.push(parseInt(permissionConst.budget.edit.value));
|
|
|
- if (mem.budget_permission.indexOf(permissionConst.budget.view.value) < 0) {
|
|
|
- mem.budget_permission.push(parseInt(permissionConst.budget.view.value));
|
|
|
- $(`#budgetview${id}`)[0].checked = true;
|
|
|
- }
|
|
|
- } else if (pType === 'file' && spType === 'view') {
|
|
|
- mem.file_permission.push(parseInt(permissionConst.file.view.value));
|
|
|
- } else if (pType === 'file' && spType === 'upload') {
|
|
|
- mem.file_permission.push(parseInt(permissionConst.file.upload.value));
|
|
|
- if (mem.file_permission.indexOf(permissionConst.file.view.value) < 0) {
|
|
|
- mem.file_permission.push(parseInt(permissionConst.file.view.value));
|
|
|
- $(`#fileview${id}`)[0].checked = true;
|
|
|
- }
|
|
|
- } else if (pType === 'file' && spType === 'delete') {
|
|
|
- mem.file_permission.push(parseInt(permissionConst.file.delete.value));
|
|
|
- if (mem.file_permission.indexOf(permissionConst.file.view.value) < 0) {
|
|
|
- mem.file_permission.push(parseInt(permissionConst.file.view.value));
|
|
|
- $(`#fileview${id}`)[0].checked = true;
|
|
|
- }
|
|
|
- } else if (pType === 'file' && spType === 'filing') {
|
|
|
- mem.file_permission.push(parseInt(permissionConst.file.filing.value));
|
|
|
- if (mem.file_permission.indexOf(permissionConst.file.view.value) < 0) {
|
|
|
- mem.file_permission.push(parseInt(permissionConst.file.view.value));
|
|
|
- $(`#fileview${id}`)[0].checked = true;
|
|
|
- }
|
|
|
- } else if (pType === 'manage' && spType === 'rela') {
|
|
|
- mem.manage_permission.push(parseInt(permissionConst.manage.rela.value));
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (pType === 'budget' && spType === 'view') {
|
|
|
- mem.budget_permission = [];
|
|
|
- $(`#budgetedit${id}`)[0].checked = false;
|
|
|
- } else if (pType === 'budget' && spType === 'edit') {
|
|
|
- mem.budget_permission.splice(mem.budget_permission.indexOf(permissionConst.budget.edit.value), 1);
|
|
|
- } else if (pType === 'file' && spType === 'view') {
|
|
|
- mem.file_permission = [];
|
|
|
- $(`#fileupload${id}`)[0].checked = false;
|
|
|
- $(`#fileedit${id}`)[0].checked = false;
|
|
|
- $(`#filedelete${id}`)[0].checked = false;
|
|
|
- } else if (pType === 'file' && spType === 'upload') {
|
|
|
- mem.file_permission.splice(mem.file_permission.indexOf(permissionConst.file.upload.value), 1);
|
|
|
- } else if (pType === 'file' && spType === 'delete') {
|
|
|
- mem.file_permission.splice(mem.file_permission.indexOf(permissionConst.file.delete.value), 1);
|
|
|
- } else if (pType === 'file' && spType === 'filing') {
|
|
|
- mem.file_permission.splice(mem.file_permission.indexOf(permissionConst.file.filing.value), 1);
|
|
|
- } else if (pType === 'manage' && spType === 'rela') {
|
|
|
- mem.manage_permission = [];
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- $('#member-ok').click(function(){
|
|
|
- const id = this.getAttribute('tree_id');
|
|
|
- postData('/subproj/memberSave', {id, member: newMembers}, function () {
|
|
|
- $('#member').modal('hide');
|
|
|
- })
|
|
|
- });
|
|
|
});
|