|
|
@@ -176,13 +176,16 @@ $(document).ready(() => {
|
|
|
contract: '合同管理',
|
|
|
construction: '施工日志',
|
|
|
quality: '质量管理',
|
|
|
- inspection: '质量巡检',
|
|
|
- safe_payment: '安全计量',
|
|
|
- safe_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', 'safe_inspection', 'safe_payment'];
|
|
|
- const tenderPermissionKeys = ['quality', 'inspection', 'safe_inspection', 'safe_payment'];
|
|
|
-
|
|
|
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);
|
|
|
@@ -221,6 +224,9 @@ $(document).ready(() => {
|
|
|
for (const tpkey of tenderPermissionKeys) {
|
|
|
setTenderPermissionHtml(result[tpkey + 'AuditList'], tpkey);
|
|
|
}
|
|
|
+ for (const tpk in tPsKeys) {
|
|
|
+ setTenderPermissionsHtml(result[tpk + 'AuditList'], tpk, tPsKeys[tpk]);
|
|
|
+ }
|
|
|
resetAddUserHtml();
|
|
|
});
|
|
|
});
|
|
|
@@ -247,6 +253,8 @@ $(document).ready(() => {
|
|
|
$('#add_user_dropdownMenuButton').attr('data-type', 'construction');
|
|
|
} 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));
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -350,6 +358,40 @@ $(document).ready(() => {
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
+ 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) {
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
for (const key of tabTypeKeys) {
|
|
|
$('body').on('click', `#${key}-users .remove-${key}-user`, function () {
|
|
|
@@ -381,6 +423,11 @@ $(document).ready(() => {
|
|
|
$('#'+ type + '-users').find('tr[data-uid="'+ id +'"]').remove();
|
|
|
$('#remove-user').modal('hide');
|
|
|
});
|
|
|
+ } 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,
|
|
|
@@ -606,6 +653,25 @@ $(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]);
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
@@ -755,25 +821,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 (_.includes(tenderPermissionKeys, userType)) {
|
|
|
- userData.member = [1];
|
|
|
+ userData.member = {};
|
|
|
+ userData.member[userType] = [1];
|
|
|
$('#'+ userType +'-users tr').eq(i).find('input[type="checkbox"]').each(function () {
|
|
|
if ($(this).is(':checked')) {
|
|
|
- userData.member.push(parseInt($(this).attr('data-block')));
|
|
|
+ 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')));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
- // 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 (userType === 'safe_inspection') {
|
|
|
- // userData.member = [1];
|
|
|
- // if ($('#safe_inspection-users tr').eq(i).find('input[data-block="add"]').eq(0).is(':checked')) userData.member.push(2);
|
|
|
- // if ($('#safe_inspection-users tr').eq(i).find('input[data-block="view_all"]').eq(0).is(':checked')) userData.member.push(3);
|
|
|
- // }
|
|
|
saIdList.push(userData);
|
|
|
}
|
|
|
data.auditList = saIdList;
|
|
|
@@ -1110,6 +1175,31 @@ function setConstructionHtml(constructionAuditList) {
|
|
|
$('#construction-users').html(html);
|
|
|
}
|
|
|
|
|
|
+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) {
|