|
|
@@ -163,6 +163,7 @@ function getFilterTenderTreeHtml() {
|
|
|
}
|
|
|
|
|
|
$(document).ready(() => {
|
|
|
+
|
|
|
autoFlashHeight();
|
|
|
function getObjHeight(select) {
|
|
|
return select.length > 0 ? select.height() : 0;
|
|
|
@@ -176,10 +177,16 @@ $(document).ready(() => {
|
|
|
contract: '合同管理',
|
|
|
construction: '施工日志',
|
|
|
quality: '质量管理',
|
|
|
- inspection: '质量巡检',
|
|
|
+ safe: '安全管理',
|
|
|
+ };
|
|
|
+ const tabTypeKeys = ['tourist', 'schedule', 'contract', 'construction', 'quality', 'safe'];
|
|
|
+ // 单个tenderPermission字段用这个
|
|
|
+ const tenderPermissionKeys = [];
|
|
|
+ // 多个tenderPermission字段融合处理用这个
|
|
|
+ const tPsKeys = {
|
|
|
+ quality: ['quality', 'inspection'],
|
|
|
+ safe: ['safe_inspection', 'safe_payment'],
|
|
|
};
|
|
|
- const tabTypeKeys = ['tourist', 'schedule', 'contract', 'construction', 'quality', 'inspection'];
|
|
|
-
|
|
|
const $filterTenderDone = $('body #filter-tender-done')
|
|
|
if (window.location.search && window.location.search.split('done=')[1]) {
|
|
|
$filterTenderDone.prop('checked', window.location.search.split('done=')[1] === '1' ? true : false);
|
|
|
@@ -215,8 +222,12 @@ $(document).ready(() => {
|
|
|
setScheduleHtml(result.scheduleAuditList);
|
|
|
setContractHtml(result.contractAuditList);
|
|
|
setConstructionHtml(result.constructionAuditList);
|
|
|
- setTenderPermissionHtml(result.qualityAuditList, 'quality');
|
|
|
- setTenderPermissionHtml(result.inspectionAuditList, 'inspection');
|
|
|
+ for (const tpkey of tenderPermissionKeys) {
|
|
|
+ setTenderPermissionHtml(result[tpkey + 'AuditList'], tpkey);
|
|
|
+ }
|
|
|
+ for (const tpk in tPsKeys) {
|
|
|
+ setTenderPermissionsHtml(result[tpk + 'AuditList'], tpk, tPsKeys[tpk]);
|
|
|
+ }
|
|
|
resetAddUserHtml();
|
|
|
});
|
|
|
});
|
|
|
@@ -232,21 +243,33 @@ $(document).ready(() => {
|
|
|
$('#user-set').hide();
|
|
|
} else {
|
|
|
$('#user-set').show();
|
|
|
- if ($(this).attr('href') === '#guest') {
|
|
|
+ const href = $(this).attr('href');
|
|
|
+ if (href === '#guest') {
|
|
|
$('#add_user_dropdownMenuButton').attr('data-type', 'tourist');
|
|
|
- } else if ($(this).attr('href') === '#tzpro') {
|
|
|
+ } else if (href === '#tzpro') {
|
|
|
$('#add_user_dropdownMenuButton').attr('data-type', 'schedule');
|
|
|
- } else if ($(this).attr('href') === '#htgl') {
|
|
|
+ } else if (href === '#htgl') {
|
|
|
$('#add_user_dropdownMenuButton').attr('data-type', 'contract');
|
|
|
$('#contract-tip').show();
|
|
|
- } else if ($(this).attr('href') === '#sgrz') {
|
|
|
+ } else if (href === '#sgrz') {
|
|
|
$('#add_user_dropdownMenuButton').attr('data-type', 'construction');
|
|
|
- } else if ($(this).attr('href') === '#zlgl') {
|
|
|
- $('#add_user_dropdownMenuButton').attr('data-type', 'quality');
|
|
|
- } else if ($(this).attr('href') === '#zlxj') {
|
|
|
- $('#add_user_dropdownMenuButton').attr('data-type', 'inspection');
|
|
|
+ } else if (_.includes(tenderPermissionKeys, $(this).attr('href').substring(1))) {
|
|
|
+ $('#add_user_dropdownMenuButton').attr('data-type', $(this).attr('href').substring(1));
|
|
|
+ } else if (_.includes(Object.keys(tPsKeys), $(this).attr('href').substring(1))) {
|
|
|
+ $('#add_user_dropdownMenuButton').attr('data-type', $(this).attr('href').substring(1));
|
|
|
+ }
|
|
|
+ let currentNavType = null;
|
|
|
+ if (href === '#guest') currentNavType = 'tourist';
|
|
|
+ else if (href === '#tzpro') currentNavType = 'schedule';
|
|
|
+ else if (href === '#htgl') currentNavType = 'contract';
|
|
|
+ else if (href === '#sgrz') currentNavType = 'construction';
|
|
|
+ else if (href === '#zlgl') currentNavType = 'quality';
|
|
|
+ else if (href === '#zlxj') currentNavType = 'inspection';
|
|
|
+ if(currentNavType) {
|
|
|
+ setTimeout(() => updateSelectedMarks(currentNavType), 0);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
});
|
|
|
|
|
|
$('body').on('click', '.c-body a', function (e) {
|
|
|
@@ -325,57 +348,69 @@ $(document).ready(() => {
|
|
|
postData('/sp/' + spid + '/construction/' + cur_tenderid + '/audit/save', prop, function (data) {
|
|
|
});
|
|
|
});
|
|
|
-
|
|
|
- // 权限更改
|
|
|
- $('body').on('click', '#quality-users input[type="checkbox"]', function () {
|
|
|
- const uid = parseInt($(this).parents('tr').data('uid'));
|
|
|
- const member = {
|
|
|
- uid,
|
|
|
- quality: [1],
|
|
|
- };
|
|
|
- $(this).parents('tr').find('input[type="checkbox"]').each(function () {
|
|
|
- if ($(this).is(':checked')) {
|
|
|
- member.quality.push($(this).data('value'));
|
|
|
- }
|
|
|
- });
|
|
|
- const prop = {
|
|
|
- type: 'save-permission',
|
|
|
- uid,
|
|
|
- members: [member],
|
|
|
- key: 'quality',
|
|
|
- };
|
|
|
- const _self = $(this);
|
|
|
- postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', prop, function (data) {
|
|
|
+ for (const tpKey of tenderPermissionKeys) {
|
|
|
+ $('body').on('click', `#${tpKey}-users input[type="checkbox"]`, function () {
|
|
|
+ const uid = parseInt($(this).parents('tr').data('uid'));
|
|
|
+ const member = {
|
|
|
+ uid,
|
|
|
+ };
|
|
|
+ member[tpKey] = [1];
|
|
|
+ $(this).parents('tr').find('input[type="checkbox"]').each(function () {
|
|
|
+ if ($(this).is(':checked')) {
|
|
|
+ member[tpKey].push($(this).data('value'));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const prop = {
|
|
|
+ type: 'save-permission',
|
|
|
+ uid,
|
|
|
+ members: [member],
|
|
|
+ key: tpKey,
|
|
|
+ };
|
|
|
+ const _self = $(this);
|
|
|
+ postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', prop, function (data) {
|
|
|
+ });
|
|
|
});
|
|
|
- });
|
|
|
-
|
|
|
- // 权限更改
|
|
|
- $('body').on('click', '#inspection-users input[type="checkbox"]', function () {
|
|
|
- const uid = parseInt($(this).parents('tr').data('uid'));
|
|
|
- const member = {
|
|
|
- uid,
|
|
|
- inspection: [1],
|
|
|
- };
|
|
|
- $(this).parents('tr').find('input[type="checkbox"]').each(function () {
|
|
|
- if ($(this).is(':checked')) {
|
|
|
- member.inspection.push($(this).data('value'));
|
|
|
+ }
|
|
|
+ for (const tPsKey in tPsKeys) {
|
|
|
+ $('body').on('click', `#${tPsKey}-users input[type="checkbox"]`, function () {
|
|
|
+ const uid = parseInt($(this).parents('tr').data('uid'));
|
|
|
+ const member = {
|
|
|
+ uid,
|
|
|
+ };
|
|
|
+ const key = $(this).data('key');
|
|
|
+ member[key] = [];
|
|
|
+ if ($(this).data('block') === 'view' && !$(this).is(':checked')) {
|
|
|
+ $(this).parents('tr').find(`input[data-key="${key}"]`).prop('checked', false);
|
|
|
+ } else {
|
|
|
+ let viewFlag = false;
|
|
|
+ $(this).parents('tr').find(`input[data-key="${key}"]`).each(function () {
|
|
|
+ if ($(this).is(':checked')) {
|
|
|
+ if ($(this).data('block') !== 'view') {
|
|
|
+ member[key].push(1);
|
|
|
+ $(this).parents('tr').find(`input[data-key="${key}"][data-block="view"]`).prop('checked', true);
|
|
|
+ viewFlag = true;
|
|
|
+ }
|
|
|
+ member[key].push($(this).data('value'));
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
+ const prop = {
|
|
|
+ type: 'save-permission',
|
|
|
+ uid,
|
|
|
+ members: [member],
|
|
|
+ key,
|
|
|
+ };
|
|
|
+ const _self = $(this);
|
|
|
+ postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', prop, function (data) {
|
|
|
+ });
|
|
|
});
|
|
|
- const prop = {
|
|
|
- type: 'save-permission',
|
|
|
- uid,
|
|
|
- members: [member],
|
|
|
- key: 'inspection',
|
|
|
- };
|
|
|
- const _self = $(this);
|
|
|
- postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', prop, function (data) {
|
|
|
- });
|
|
|
- });
|
|
|
+ }
|
|
|
|
|
|
for (const key of tabTypeKeys) {
|
|
|
$('body').on('click', `#${key}-users .remove-${key}-user`, function () {
|
|
|
$('#remove_user_type').val(key);
|
|
|
$('#remove_user_id').val($(this).data('id'));
|
|
|
+ $('#show_id').val($(this).data('show-id'));
|
|
|
});
|
|
|
}
|
|
|
|
|
|
@@ -387,22 +422,46 @@ $(document).ready(() => {
|
|
|
return;
|
|
|
}
|
|
|
const id = parseInt($('#remove_user_id').val());
|
|
|
+ const showId = parseInt($('#show_id').val());
|
|
|
if (type === 'contract') {
|
|
|
postData('/sp/' + spid + '/contract/tender/' + cur_tenderid + '/audit/save', { type: 'del-audit', id }, function (data) {
|
|
|
- $('#'+ type + '-users').find('tr[data-id="'+ id +'"]').remove();
|
|
|
+ $('#'+ type + '-users').find('tr[data-uid="'+ id +'"]').remove();
|
|
|
$('#remove-user').modal('hide');
|
|
|
+ selectedUserIdsByType[type] = selectedUserIdsByType[type].filter(function(userId) {
|
|
|
+ return userId !== showId;
|
|
|
+ });
|
|
|
+ updateSelectedMarks();
|
|
|
});
|
|
|
} else if (type === 'construction') {
|
|
|
postData('/sp/' + spid + '/' + type + '/' + cur_tenderid + '/audit/save', { type: 'del-audit', id }, function (data) {
|
|
|
$('#'+ type + '-users').find('tr[data-id="'+ id +'"]').remove();
|
|
|
$('#remove-user').modal('hide');
|
|
|
});
|
|
|
- } else if (type === 'quality' || type === 'inspection') {
|
|
|
+ } else if (_.includes(tenderPermissionKeys, type)) {
|
|
|
postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', { type: 'del-audit', id, key: type }, function (data) {
|
|
|
$('#'+ type + '-users').find('tr[data-uid="'+ id +'"]').remove();
|
|
|
$('#remove-user').modal('hide');
|
|
|
+ selectedUserIdsByType[type] = selectedUserIdsByType[type].filter(function(userId) {
|
|
|
+ return userId !== showId;
|
|
|
+ });
|
|
|
+ updateSelectedMarks();
|
|
|
+ });
|
|
|
+ } else if (_.includes(Object.keys(tPsKeys), type)) {
|
|
|
+ postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', { type: 'del-audit', id, key: type, together: 1 }, function (data) {
|
|
|
+ $('#'+ type + '-users').find('tr[data-uid="'+ id +'"]').remove();
|
|
|
+ $('#remove-user').modal('hide');
|
|
|
+ selectedUserIdsByType[type] = selectedUserIdsByType[type].filter(function(userId) {
|
|
|
+ return userId !== showId;
|
|
|
+ });
|
|
|
+ updateSelectedMarks();
|
|
|
+ });
|
|
|
+ } else if (_.includes(Object.keys(tPsKeys), type)) {
|
|
|
+ postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', { type: 'del-audit', id, key: type, together: 1 }, function (data) {
|
|
|
+ $('#'+ type + '-users').find('tr[data-uid="'+ id +'"]').remove();
|
|
|
+ $('#remove-user').modal('hide');
|
|
|
});
|
|
|
} else {
|
|
|
+
|
|
|
const prop = {
|
|
|
id: id,
|
|
|
type: 'del',
|
|
|
@@ -410,7 +469,12 @@ $(document).ready(() => {
|
|
|
postData('/tender/' + cur_tenderid + '/' + type + '/audit/save', prop, function (data) {
|
|
|
$('#'+ type + '-users').find('tr[data-id="'+ id +'"]').remove();
|
|
|
$('#remove-user').modal('hide');
|
|
|
+ selectedUserIdsByType[type] = selectedUserIdsByType[type].filter(function(userId) {
|
|
|
+ return userId !== showId;
|
|
|
+ });
|
|
|
+ updateSelectedMarks();
|
|
|
});
|
|
|
+
|
|
|
}
|
|
|
|
|
|
});
|
|
|
@@ -419,6 +483,13 @@ $(document).ready(() => {
|
|
|
let timerAddUser = null;
|
|
|
let oldSearchValAddUser = null;
|
|
|
$('body').on('input propertychange', '#add_user_dropdownMenu2 .gr-search', function (e) {
|
|
|
+
|
|
|
+ const currentDropdownType = $('#add_user_dropdownMenuButton').attr('data-type');
|
|
|
+ let currentSelectedIdsForType = [];
|
|
|
+ if (currentDropdownType && selectedUserIdsByType.hasOwnProperty(currentDropdownType)) {
|
|
|
+ currentSelectedIdsForType = selectedUserIdsByType[currentDropdownType]; // 获取对应类型的ID数组
|
|
|
+ }
|
|
|
+
|
|
|
oldSearchValAddUser = e.target.value;
|
|
|
timerAddUser && clearTimeout(timerAddUser);
|
|
|
timerAddUser = setTimeout(() => {
|
|
|
@@ -426,9 +497,14 @@ $(document).ready(() => {
|
|
|
if (newVal && newVal === oldSearchValAddUser) {
|
|
|
let html = '';
|
|
|
accountList.filter(item => item && item.id !== cur_uid && (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}" >
|
|
|
+ const itemIdInt = parseInt(item.id, 10);
|
|
|
+ const isSelected = currentSelectedIdsForType.includes(itemIdInt);
|
|
|
+ const selectedMarkStyle = isSelected ? '' : ' style="display:none;"';
|
|
|
+ html += `<dd class="border-bottom p-2 mb-0 user-item" 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>
|
|
|
+ class="ml-auto">${item.mobile || ''}</span>
|
|
|
+ <span class="selected-mark text-success ml-2"${selectedMarkStyle}><i class="fa fa-check"></i></span>
|
|
|
+ </p>
|
|
|
<span class="text-muted">${item.role || ''}</span>
|
|
|
</dd>`
|
|
|
});
|
|
|
@@ -443,6 +519,11 @@ $(document).ready(() => {
|
|
|
});
|
|
|
|
|
|
function resetAddUserHtml() {
|
|
|
+ const currentDropdownType = $('#add_user_dropdownMenuButton').attr('data-type');
|
|
|
+ let currentSelectedIdsForType = [];
|
|
|
+ if (currentDropdownType && selectedUserIdsByType.hasOwnProperty(currentDropdownType)) {
|
|
|
+ currentSelectedIdsForType = selectedUserIdsByType[currentDropdownType];
|
|
|
+ }
|
|
|
let html = '';
|
|
|
accountGroup.forEach((group, idx) => {
|
|
|
if (!group) return;
|
|
|
@@ -451,9 +532,14 @@ $(document).ready(() => {
|
|
|
<div class="dd-content" data-toggleid="${idx}">`;
|
|
|
group.groupList.forEach(item => {
|
|
|
if (item.id !== cur_uid) {
|
|
|
- html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
|
|
|
+ const itemIdInt = parseInt(item.id, 10);
|
|
|
+ const isSelected = currentSelectedIdsForType.includes(itemIdInt);
|
|
|
+ const selectedMarkStyle = isSelected ? '' : ' style="display:none;"';
|
|
|
+ html += `<dd class="border-bottom p-2 mb-0 user-item" 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>
|
|
|
+ class="ml-auto">${item.mobile || ''}</span>
|
|
|
+ <span class="selected-mark text-success ml-2"${selectedMarkStyle}><i class="fa fa-check"></i></span>
|
|
|
+ </p>
|
|
|
<span class="text-muted">${item.role || ''}</span>
|
|
|
</dd>`;
|
|
|
}
|
|
|
@@ -484,7 +570,7 @@ $(document).ready(() => {
|
|
|
});
|
|
|
|
|
|
// 选中用户
|
|
|
- $('body').on('click', '#add_user_dropdownMenu2 dl dd', function () {
|
|
|
+ $('body').on('click', '#add_user_dropdownMenu2 dl dd', function (e) {
|
|
|
const id = parseInt($(this).data('id'));
|
|
|
if (id) {
|
|
|
const user = _.find(accountList, function (item) {
|
|
|
@@ -498,6 +584,7 @@ $(document).ready(() => {
|
|
|
}
|
|
|
if (_.includes(saIdList, id)) {
|
|
|
toastr.error('该用户已存在列表中,无需重复添加');
|
|
|
+ e.stopPropagation();
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
@@ -506,6 +593,7 @@ $(document).ready(() => {
|
|
|
type: 'add',
|
|
|
};
|
|
|
postData('/tender/' + cur_tenderid + '/tourist/audit/save', prop, function (data) {
|
|
|
+ selectedUserIdsByType.tourist.push(id);
|
|
|
const html = `<tr data-uid="${user.id}" data-id="${data.id}">
|
|
|
<td>${user.name}</td>
|
|
|
<td>${user.role}</td>
|
|
|
@@ -522,10 +610,11 @@ $(document).ready(() => {
|
|
|
</div>
|
|
|
</td>
|
|
|
<td class="text-center">
|
|
|
- <a href="#remove-user1" data-id="${data.id}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-tourist-user">移除</a>
|
|
|
+ <a href="#remove-user1" data-id="${data.id}" data-show-id="${user.id}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-tourist-user">移除</a>
|
|
|
</td>
|
|
|
</tr>`;
|
|
|
$('#tourist-users').append(html);
|
|
|
+ updateSelectedMarks();
|
|
|
});
|
|
|
} else if (type === 'schedule') {
|
|
|
const user = _.find(accountList, function (item) {
|
|
|
@@ -545,6 +634,7 @@ $(document).ready(() => {
|
|
|
type: 'add',
|
|
|
};
|
|
|
postData('/tender/' + cur_tenderid + '/schedule/audit/save', prop, function (data) {
|
|
|
+ selectedUserIdsByType.schedule.push(user.id);
|
|
|
const html = `<tr data-uid="${user.id}" data-id="${data.id}">
|
|
|
<td>${user.name}</td>
|
|
|
<td>${user.role}</td>
|
|
|
@@ -561,10 +651,11 @@ $(document).ready(() => {
|
|
|
</div>
|
|
|
</td>
|
|
|
<td class="text-center">
|
|
|
- <a href="#remove-user1" data-id="${data.id}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-schedule-user">移除</a>
|
|
|
+ <a href="#remove-user1" data-id="${data.id}" data-show-id="${user.id}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-schedule-user">移除</a>
|
|
|
</td>
|
|
|
</tr>`;
|
|
|
$('#schedule-users').append(html);
|
|
|
+ updateSelectedMarks();
|
|
|
});
|
|
|
} else if (type === 'contract') {
|
|
|
const user = _.find(accountList, function (item) {
|
|
|
@@ -606,7 +697,7 @@ $(document).ready(() => {
|
|
|
postData('/sp/' + spid + '/construction/' + cur_tenderid + '/audit/save', prop, function (datas) {
|
|
|
setConstructionHtml(datas);
|
|
|
});
|
|
|
- } else if (type === 'quality' || type === 'inspection') {
|
|
|
+ } else if (_.includes(tenderPermissionKeys, type)) {
|
|
|
const user = _.find(accountList, function (item) {
|
|
|
return item.id === id;
|
|
|
});
|
|
|
@@ -627,8 +718,28 @@ $(document).ready(() => {
|
|
|
postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', prop, function (datas) {
|
|
|
setTenderPermissionHtml(datas, type);
|
|
|
});
|
|
|
+ } else if (_.includes(Object.keys(tPsKeys), type)) {
|
|
|
+ const saIdList = [];
|
|
|
+ for (let i = 0; i < $('#' + type + '-users tr').length; i++) {
|
|
|
+ saIdList.push(parseInt($('#' + type + '-users tr').eq(i).data('uid')));
|
|
|
+ }
|
|
|
+ if (_.includes(saIdList, id)) {
|
|
|
+ toastr.error('该用户已存在列表中,无需重复添加');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const prop = {
|
|
|
+ id: id,
|
|
|
+ type: 'add-audit',
|
|
|
+ key: type,
|
|
|
+ together: 1,
|
|
|
+ };
|
|
|
+ postData('/sp/' + spid + '/quality/' + cur_tenderid + '/audit/save', prop, function (datas) {
|
|
|
+ setTenderPermissionsHtml(datas, type, tPsKeys[type]);
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
+ e.stopPropagation();
|
|
|
});
|
|
|
sortCategory4User();
|
|
|
initTenderTree4User();
|
|
|
@@ -775,13 +886,24 @@ $(document).ready(() => {
|
|
|
}
|
|
|
} else if (userType === 'construction') {
|
|
|
userData.is_report = $('#construction-users tr').eq(i).find('input[type="checkbox"]').eq(0).is(':checked') ? 1 : 0;
|
|
|
- } else if (userType === 'quality') {
|
|
|
- userData.member = [1];
|
|
|
- if ($('#quality-users tr').eq(i).find('input[data-block="upload"]').eq(0).is(':checked')) userData.member.push(2);
|
|
|
- if ($('#quality-users tr').eq(i).find('input[data-block="add"]').eq(0).is(':checked')) userData.member.push(3);
|
|
|
- } else if (userType === 'inspection') {
|
|
|
- userData.member = [1];
|
|
|
- if ($('#inspection-users tr').eq(i).find('input[data-block="add"]').eq(0).is(':checked')) userData.member.push(2);
|
|
|
+ } else if (_.includes(tenderPermissionKeys, userType)) {
|
|
|
+ userData.member = {};
|
|
|
+ userData.member[userType] = [1];
|
|
|
+ $('#'+ userType +'-users tr').eq(i).find('input[type="checkbox"]').each(function () {
|
|
|
+ if ($(this).is(':checked')) {
|
|
|
+ userData.member[userType].push(parseInt($(this).attr('data-value')));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else if (_.includes(Object.keys(tPsKeys), userType)) {
|
|
|
+ userData.member = {};
|
|
|
+ for (const key of tPsKeys[userType]) {
|
|
|
+ userData.member[key] = [];
|
|
|
+ $('#'+ userType +'-users tr').eq(i).find('input[data-key="' + key + '"]').each(function () {
|
|
|
+ if ($(this).is(':checked')) {
|
|
|
+ userData.member[key].push(parseInt($(this).attr('data-value')));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
saIdList.push(userData);
|
|
|
}
|
|
|
@@ -950,6 +1072,55 @@ const tenderListSpec = (function(){
|
|
|
return { getTenderNodeHtml, getTenderTreeHeaderHtml }
|
|
|
})();
|
|
|
|
|
|
+function updateSelectedMarks(forcedType = null) {
|
|
|
+ let currentUserListSelector = '';
|
|
|
+ let selectedIdsArray = [];
|
|
|
+ let currentType = forcedType;
|
|
|
+ if (!currentType) {
|
|
|
+ const $activeTabPane = $('.tab-pane.active');
|
|
|
+ const activeTabId = $activeTabPane.attr('id');
|
|
|
+ switch(activeTabId) {
|
|
|
+ case 'guest': currentType = 'tourist'; break;
|
|
|
+ case 'tzpro': currentType = 'schedule'; break;
|
|
|
+ case 'htgl': currentType = 'contract'; break;
|
|
|
+ case 'sgrz': currentType = 'construction'; break;
|
|
|
+ case 'zlgl': currentType = 'quality'; break;
|
|
|
+ case 'zlxj': currentType = 'inspection'; break;
|
|
|
+ default: currentType = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (currentType && selectedUserIdsByType.hasOwnProperty(currentType)) {
|
|
|
+ switch(currentType) {
|
|
|
+ case 'tourist': currentUserListSelector = '#tourist-users'; break;
|
|
|
+ case 'schedule': currentUserListSelector = '#schedule-users'; break;
|
|
|
+ case 'contract': currentUserListSelector = '#contract-users'; break;
|
|
|
+ case 'construction': currentUserListSelector = '#construction-users'; break;
|
|
|
+ case 'quality': currentUserListSelector = '#quality-users'; break;
|
|
|
+ case 'inspection': currentUserListSelector = '#inspection-users'; break;
|
|
|
+ }
|
|
|
+ selectedIdsArray = selectedUserIdsByType[currentType];
|
|
|
+ } else {
|
|
|
+ $('.user-item').find('.selected-mark').hide();
|
|
|
+ $('.user-item').removeClass('bg-light');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if ($('#add_user_dropdownMenu2 .book-list').length > 0) {
|
|
|
+ $('.user-item').each(function() {
|
|
|
+ const userIdStr = $(this).data('id');
|
|
|
+ const userId = parseInt(userIdStr, 10);
|
|
|
+ const $mark = $(this).find('.selected-mark');
|
|
|
+ if (!isNaN(userId) && selectedIdsArray.includes(userId)) {
|
|
|
+ $mark.show();
|
|
|
+ $(this).addClass('bg-light');
|
|
|
+ } else {
|
|
|
+ $mark.hide();
|
|
|
+ $(this).removeClass('bg-light');
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
function setShenpiHtml(shenpi, tender, revising) {
|
|
|
let html = '';
|
|
|
if (shenpi.sp_lc.length > 0) {
|
|
|
@@ -1008,6 +1179,14 @@ function setShenpiHtml(shenpi, tender, revising) {
|
|
|
$('#splc').html(html);
|
|
|
}
|
|
|
|
|
|
+let selectedUserIdsByType = {
|
|
|
+ tourist: [],
|
|
|
+ schedule: [],
|
|
|
+ contract: [],
|
|
|
+ construction: [],
|
|
|
+ quality: [],
|
|
|
+ inspection: []
|
|
|
+};
|
|
|
function setTouristHtml(tourists) {
|
|
|
let html = '';
|
|
|
if (tourists.length > 0) {
|
|
|
@@ -1028,12 +1207,21 @@ function setTouristHtml(tourists) {
|
|
|
</div>
|
|
|
</td>
|
|
|
<td class="text-center">
|
|
|
- <a href="#remove-user1" data-id="${t.id}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-tourist-user">移除</a>
|
|
|
+ <a href="#remove-user1" data-id="${t.id}" data-show-id="${t.user_id}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-tourist-user">移除</a>
|
|
|
</td>
|
|
|
</tr>`;
|
|
|
}
|
|
|
+ selectedUserIdsByType.tourist = [];
|
|
|
+ if (Array.isArray(tourists)) {
|
|
|
+ tourists.forEach(function(tourist) {
|
|
|
+ if (tourist.user_id !== undefined && tourist.user_id !== null) {
|
|
|
+ selectedUserIdsByType.tourist.push(parseInt(tourist.user_id, 10));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
$('#tourist-users').html(html);
|
|
|
+ updateSelectedMarks();
|
|
|
}
|
|
|
|
|
|
function setScheduleHtml(scheduleAuditList) {
|
|
|
@@ -1057,12 +1245,20 @@ function setScheduleHtml(scheduleAuditList) {
|
|
|
</div>
|
|
|
</td>
|
|
|
<td class="text-center">
|
|
|
- <a href="#remove-user1" data-id="${sa.id}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-schedule-user">移除</a>
|
|
|
+ <a href="#remove-user1" data-id="${sa.id}" data-show-id="${sa.user_id}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-schedule-user">移除</a>
|
|
|
</td>
|
|
|
</tr>`;
|
|
|
}
|
|
|
+ if (Array.isArray(scheduleAuditList)) {
|
|
|
+ scheduleAuditList.forEach(function(sa) {
|
|
|
+ if (sa.audit_id !== undefined && sa.audit_id !== null) {
|
|
|
+ selectedUserIdsByType.schedule.push(parseInt(sa.audit_id, 10));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
$('#schedule-users').html(html);
|
|
|
+ updateSelectedMarks();
|
|
|
}
|
|
|
|
|
|
function setContractHtml(datas) {
|
|
|
@@ -1090,11 +1286,19 @@ function setContractHtml(datas) {
|
|
|
<input type="checkbox" class="permission-checkbox" data-type="permission_show_node" value="${ca.uid}" ${ca.permission_show_node ? 'checked' : ''}>
|
|
|
</td>
|
|
|
<td class="text-center">
|
|
|
- <a href="#remove-user1" data-toggle="modal" data-target="#remove-user" class="btn btn-outline-danger btn-sm ml-1 remove-contract-user" data-id="${ca.uid}">移除</a>
|
|
|
+ <a href="#remove-user1" data-show-id="${ca.uid}" data-toggle="modal" data-target="#remove-user" class="btn btn-outline-danger btn-sm ml-1 remove-contract-user" data-id="${ca.uid}">移除</a>
|
|
|
</td>
|
|
|
</tr>`;
|
|
|
}
|
|
|
+ if (Array.isArray(datas)) {
|
|
|
+ datas.forEach(function(ca) {
|
|
|
+ if (ca.uid !== undefined && ca.uid !== null) {
|
|
|
+ selectedUserIdsByType.contract.push(parseInt(ca.uid, 10));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
$('#contract-users').html(list);
|
|
|
+ updateSelectedMarks();
|
|
|
}
|
|
|
|
|
|
function setConstructionHtml(constructionAuditList) {
|
|
|
@@ -1111,20 +1315,61 @@ function setConstructionHtml(constructionAuditList) {
|
|
|
</div>
|
|
|
</td>
|
|
|
<td class="text-center">
|
|
|
- <a href="#remove-user1" data-id="${sa.id}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-construction-user">移除</a>
|
|
|
+ <a href="#remove-user1" data-show-id="${sa.uid}" data-id="${sa.id}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-construction-user">移除</a>
|
|
|
</td>
|
|
|
</tr>`;
|
|
|
}
|
|
|
+ if (Array.isArray(constructionAuditList)) {
|
|
|
+ constructionAuditList.forEach(function(sa) {
|
|
|
+ if (sa.uid !== undefined && sa.uid !== null) {
|
|
|
+ selectedUserIdsByType.construction.push(parseInt(sa.uid, 10));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
$('#construction-users').html(html);
|
|
|
+ updateSelectedMarks();
|
|
|
+}
|
|
|
+
|
|
|
+function setTenderPermissionsHtml(auditList, key, keys) {
|
|
|
+ const html = [];
|
|
|
+ for (const m of auditList) {
|
|
|
+ html.push(getUserPermissionsHtml(m, key, keys));
|
|
|
+ }
|
|
|
+ $('#' + key + '-users').html(html.join(''));
|
|
|
}
|
|
|
|
|
|
+const getUserPermissionsHtml = function(user, key, keys) {
|
|
|
+ const html = [];
|
|
|
+ html.push(`<tr data-uid="${user.uid}" data-id="${user.id}">`);
|
|
|
+ html.push(`<td>${user.name}</td>`, `<td>${user.role}</td>`);
|
|
|
+ const block = _.find(permissionBlock, { key: key });
|
|
|
+ for (const block of permissionBlock) {
|
|
|
+ if (keys.indexOf(block.key) < 0) continue;
|
|
|
+ for (const p of block.permission) {
|
|
|
+ const checked = user[block.key] ? (user[block.key].indexOf(p.value) >= 0 ? 'checked' : '') : '';
|
|
|
+ html.push(`<td class="text-center"><input type="checkbox" data-key="${block.key}" data-block="${p.key}" data-value="${p.value}" ${checked}></td>`);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ html.push(`<td class="text-center"><a href="#remove-user1" data-id="${user.uid}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-${key}-user">移除</a></td>`);
|
|
|
+ html.push('</tr>');
|
|
|
+ return html.join('');
|
|
|
+};
|
|
|
+
|
|
|
function setTenderPermissionHtml(auditList, key) {
|
|
|
const html = [];
|
|
|
for (const m of auditList) {
|
|
|
html.push(getUserPermissionHtml(m, key));
|
|
|
}
|
|
|
+ if (Array.isArray(auditList)) {
|
|
|
+ auditList.forEach(function(sa) {
|
|
|
+ if (sa.uid !== undefined && sa.uid !== null) {
|
|
|
+ selectedUserIdsByType[key].push(parseInt(sa.uid, 10));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
$('#' + key + '-users').html(html.join(''));
|
|
|
+ updateSelectedMarks();
|
|
|
}
|
|
|
|
|
|
const getUserPermissionHtml = function(user, key) {
|
|
|
@@ -1137,7 +1382,7 @@ const getUserPermissionHtml = function(user, key) {
|
|
|
const checked = user[block.key] ? (user[block.key].indexOf(p.value) >= 0 ? 'checked' : '') : '';
|
|
|
html.push(`<td class="text-center"><input type="checkbox" data-block="${p.key}" data-value="${p.value}" ${checked}></td>`);
|
|
|
}
|
|
|
- html.push(`<td class="text-center"><a href="#remove-user1" data-id="${user.uid}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-${key}-user">移除</a></td>`);
|
|
|
+ html.push(`<td class="text-center"><a href="#remove-user1" data-show-id="${user.uid}" data-id="${user.uid}" data-toggle="modal" data-target="#remove-user" class="btn btn-sm btn-outline-danger remove-${key}-user">移除</a></td>`);
|
|
|
html.push('</tr>');
|
|
|
return html.join('');
|
|
|
};
|