// 游客及投资管理用户添加到其他标段
const tenderTree4User = [];
let parentId4User = 0;
// 分类数据排序
function sortCategory4User() {
category.sort(function (a, b) {
return a.level ? (b.level ? a.level - b.level : -1) : a.id - b.id;
});
}
// 初始化TenderTree数据
function initTenderTree4User () {
const levelCategory = category.filter(function (c) {
return c.level && c.level > 0;
});
function findCategoryNode4User(cid, value, array) {
for (const a of array) {
if (a.cid === cid && a.vid === value) {
return a;
}
}
}
function getCategoryNode4User(category, value, parent, i = null) {
const array = parent ? parent.children : tenderTree4User;
let cate = findCategoryNode4User(category.id, value, array);
if (!cate) {
const cateValue = findNode2('id', value, category.value);
if (!cateValue) return null;
cate = {
cid: category.id,
vid: value,
name: cateValue.value,
children: [],
level: i ? i : category.level,
sort_id: ++parentId4User,
sort: cateValue.sort,
};
array.push(cate);
}
return cate;
}
function loadTenderCategory4User (tender) {
let tenderCategory = null;
for (const [index,lc] of levelCategory.entries()) {
const tenderCate = findNode2('cid', lc.id, tender.category);
if (tenderCate) {
tenderCategory = getCategoryNode4User(lc, tenderCate.value, tenderCategory);
} else {
if (index === 0 && tender.category) {
for (const [i,c] of tender.category.entries()) {
const cate = findNode2('id', c.cid, category);
if (cate) tenderCategory = getCategoryNode4User(cate, c.value, tenderCategory, i+1);
}
}
return tenderCategory;
}
}
return tenderCategory;
}
tenderTree4User.splice(0, tenderTree4User.length);
for (const t of tenders) {
t.valid = true;
delete t.level;
if (t.category && levelCategory.length > 0) {
const parent = loadTenderCategory4User(t);
if (parent) {
t.level = parent.level + 1;
parent.children.push(t);
} else {
tenderTree4User.push(t);
}
} else {
tenderTree4User.push(t);
}
}
sortTenderTree(tenderTree4User);
}
function recursiveGetTenderNodeHtml4User (node, arr, pid) {
const html = [];
html.push('
');
// 名称
html.push('');
if (node.cid) {
html.push(' ', node.name);
} else {
html.push('');
html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
html.push(' ');
//html.push('', node[c.field], ' ');
html.push('', node.name, ' ');
}
html.push(' ');
html.push('');
if (!node.cid) {
html.push(' ');
}
html.push(' ');
html.push(' ');
if (node.children) {
for (const c of node.children) {
html.push(recursiveGetTenderNodeHtml4User(c, node.children, node.sort_id));
}
}
return html.join('');
}
// 根据TenderTree数据获取Html代码
function getTenderTreeHtml4User () {
if (tenderTree4User.length > 0) {
const html = [];
html.push('');
html.push('', '');
html.push('名称 ');
html.push('选择 ');
html.push(' ', ' ');
parentId4User = 0;
for (const t of tenderTree4User) {
html.push(recursiveGetTenderNodeHtml4User(t, tenderTree4User, ''));
}
html.push('
');
return html.join('');
} else {
return EmptyTenderHtml.join('');
}
}
function recursiveGetFilterTenderNodeHtml (node, arr) {
const html = [];
html.push(``);
// 名称
html.push('');
if (node.cid) {
html.push(' ', node.name);
} else {
html.push('');
html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
html.push(' ', node.name);
}
html.push(' ');
html.push('');
if (!node.cid) {
html.push(` `);
}
html.push(' ');
html.push('');
if (!node.cid) {
html.push(` `);
}
html.push(' ');
html.push(' ');
if (node.children) {
for (const c of node.children) {
html.push(recursiveGetFilterTenderNodeHtml(c, node.children));
}
}
return html.join('');
}
function getFilterTenderTreeHtml() {
const html = [];
for (const t of tenderTree4User) {
html.push(recursiveGetFilterTenderNodeHtml(t, tenderTree4User));
}
$('#filter-tender-list').html(html.join(''));
}
$(document).ready(() => {
autoFlashHeight();
function getObjHeight(select) {
return select.length > 0 ? select.height() : 0;
}
const cHeader = getObjHeight($(".c-header"));
$('.tab-content').height($(window).height()-cHeader-90+53-46);
const tabTypes = {
tourist: '游客',
schedule: '投资进度',
contract: '合同管理',
construction: '施工日志',
};
const tabTypeKeys = ['tourist', 'schedule', 'contract', 'construction'];
$('body').on('click', '.c-body .tender-info', function () {
$('.c-body .tender-info').removeClass('table-warning');
$(this).addClass('table-warning');
const tid = parseInt($(this).attr('data-id'));
if (!tid) {
toastr.warning('不存在标段无法设置');
return;
}
// 请求获取右侧列表信息
postData(`/sp/${spid}/setting/manage/tender/save`, { type: 'msg', tid: parseInt($(this).attr('data-id'))}, function (result) {
sp_lc = result.shenpi.sp_lc;
sp_type = result.shenpi.sp_type;
sp_status = result.shenpi.sp_status;
sp_status_list = result.shenpi.sp_status_list;
cur_tenderid = result.tender.id;
cur_uid = result.tender.user_id;
setShenpiHtml(result.shenpi, result.tender, result.revising);
setTouristHtml(result.tourists);
setScheduleHtml(result.scheduleAuditList);
setContractHtml(result.contractAuditList);
setConstructionHtml(result.constructionAuditList);
resetAddUserHtml();
});
});
setTimeout(function () {
$('.c-body .tender-info').eq(0).click();// 需要延时加载
}, 500);
$('body').on('click', '.nav .nav-link', function () {
$('#contract-tip').hide();
if ($(this).attr('href') === '#splc') {
$('#user-set').hide();
} else {
$('#user-set').show();
if ($(this).attr('href') === '#guest') {
$('#add_user_dropdownMenuButton').attr('data-type', 'tourist');
} else if ($(this).attr('href') === '#tzpro') {
$('#add_user_dropdownMenuButton').attr('data-type', 'schedule');
} else if ($(this).attr('href') === '#htgl') {
$('#add_user_dropdownMenuButton').attr('data-type', 'contract');
$('#contract-tip').show();
} else if ($(this).attr('href') === '#sgrz') {
$('#add_user_dropdownMenuButton').attr('data-type', 'construction');
}
}
});
$('body').on('click', '.c-body a', function (e) {
e.stopPropagation();
});
// 权限设置
$('body').on('click', '#tourist-users .set-tourist-permission', function () {
const id = parseInt($(this).data('id'));
const permission = {
file: ($(this).attr('name') === 'file' ? $(this).is(':checked') : $('#' + id + '_file').is(':checked')) ? 1 : 0,
tag: ($(this).attr('name') === 'tag' ? $(this).is(':checked') : $('#' + id + '_tag').is(':checked')) ? 1 : 0,
}
const prop = {
id,
type: 'permission',
permission,
}
console.log(prop);
postData('/tender/' + cur_tenderid + '/tourist/audit/save', prop, function (data) {
});
});
// 权限更改
$('body').on('click', '#schedule-users input[type="checkbox"]', function () {
let permission = scPermission.no;
const value = parseInt($(this).data('zhi'));
if ($(this).is(':checked')) {
if (value === scPermission.edit) {
permission = scPermission.edit;
$(this).parents('td').siblings().find('input').prop('checked', true);
} else if (value === scPermission.show) {
permission = scPermission.show;
}
} else {
if (value === scPermission.edit) {
permission = scPermission.show;
} else if (value === scPermission.show) {
permission = scPermission.no;
$(this).parents('td').siblings().find('input').prop('checked', false);
}
}
const id = parseInt($(this).data('id'));
const prop = {
id,
permission,
type: 'edit',
};
const _self = $(this);
postData('/tender/' + cur_tenderid + '/schedule/audit/save', prop, function (data) {
});
});
// 权限更改
$('body').on('click', '#contract-users input[type="checkbox"]', function () {
const type = $(this).attr('data-type');
const value = $(this).is(':checked') ? 1 : 0;
const id = parseInt($(this).val());
const updateInfo = { uid: id };
updateInfo[type] = value;
postData(`/sp/${spid}/contract/tender/${cur_tenderid}/audit/save`, { type: 'save-permission', updateData: updateInfo }, function (result) {
})
});
// 权限更改
$('body').on('click', '#construction-users input[type="checkbox"]', function () {
const id = parseInt($(this).data('id'));
const prop = {
type: 'save-report',
updateData: {
id,
is_report: $(this).is(':checked') ? 1 : 0,
}
};
const _self = $(this);
postData('/sp/' + spid + '/construction/' + 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'));
});
}
// 移除用户确定
$('#remove_user_btn').click(function () {
const type = $('#remove_user_type').val();
if (tabTypeKeys.indexOf(type) === -1) {
toastr.error('参数有误');
return;
}
const id = parseInt($('#remove_user_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();
$('#remove-user').modal('hide');
});
} else if (type === 'construction') {
postData('/sp/' + spid + '/construction/' + cur_tenderid + '/audit/save', { type: 'del-audit', id }, function (data) {
$('#'+ type + '-users').find('tr[data-id="'+ id +'"]').remove();
$('#remove-user').modal('hide');
});
} else {
const prop = {
id: id,
type: 'del',
};
postData('/tender/' + cur_tenderid + '/' + type + '/audit/save', prop, function (data) {
$('#'+ type + '-users').find('tr[data-id="'+ id +'"]').remove();
$('#remove-user').modal('hide');
});
}
});
// 投资进度
let timerAddUser = null;
let oldSearchValAddUser = null;
$('body').on('input propertychange', '#add_user_dropdownMenu2 .gr-search', function (e) {
oldSearchValAddUser = e.target.value;
timerAddUser && clearTimeout(timerAddUser);
timerAddUser = setTimeout(() => {
const newVal = $(this).val();
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 += `
${item.name} ${item.mobile || ''}
${item.role || ''}
`
});
$('#add_user_dropdownMenu2 .book-list').empty();
$('#add_user_dropdownMenu2 .book-list').append(html);
} else {
if (!$('#add_user_dropdownMenu2 .acc-btn').length) {
resetAddUserHtml();
}
}
}, 400);
});
function resetAddUserHtml() {
let html = '';
accountGroup.forEach((group, idx) => {
if (!group) return;
html += `
${group.groupName}
`;
group.groupList.forEach(item => {
if (item.id !== cur_uid) {
html += `
${item.name} ${item.mobile || ''}
${item.role || ''}
`;
}
});
html += '
';
});
$('#add_user_dropdownMenu2 .book-list').empty();
$('#add_user_dropdownMenu2 .book-list').append(html);
}
// 添加审批流程按钮逻辑
$('body').on('click', '#add_user_dropdownMenu2 .book-list 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;
});
// 选中用户
$('body').on('click', '#add_user_dropdownMenu2 dl dd', function () {
const id = parseInt($(this).data('id'));
if (id) {
const user = _.find(accountList, function (item) {
return item.id === id;
});
const type = $('#add_user_dropdownMenuButton').attr('data-type');
if (type === 'tourist') {
const saIdList = [];
for (let i = 0; i < $('#tourist-users tr').length; i++) {
saIdList.push(parseInt($('#tourist-users tr').eq(i).data('uid')));
}
if (_.includes(saIdList, id)) {
toastr.error('该用户已存在列表中,无需重复添加');
return;
}
const prop = {
user_id: id,
type: 'add',
};
postData('/tender/' + cur_tenderid + '/tourist/audit/save', prop, function (data) {
const html = `
${user.name}
${user.role}
移除
`;
$('#tourist-users').append(html);
});
} else if (type === 'schedule') {
const user = _.find(accountList, function (item) {
return item.id === id;
});
const saIdList = [];
for (let i = 0; i < $('#schedule-users tr').length; i++) {
saIdList.push(parseInt($('#schedule-users tr').eq(i).data('uid')));
}
if (_.includes(saIdList, id)) {
toastr.error('该用户已存在列表中,无需重复添加');
return;
}
const prop = {
audit_id: id,
type: 'add',
};
postData('/tender/' + cur_tenderid + '/schedule/audit/save', prop, function (data) {
const html = `
${user.name}
${user.role}
移除
`;
$('#schedule-users').append(html);
});
} else if (type === 'contract') {
const user = _.find(accountList, function (item) {
return item.id === id;
});
const saIdList = [];
for (let i = 0; i < $('#contract-users tr').length; i++) {
saIdList.push(parseInt($('#contract-users tr').eq(i).data('uid')));
}
if (_.includes(saIdList, id)) {
toastr.error('该用户已存在列表中,无需重复添加');
return;
}
const prop = {
id: id,
type: 'add-audit',
};
postData('/sp/' + spid + '/contract/tender/' + cur_tenderid + '/audit/save', prop, function (datas) {
setContractHtml(datas);
});
} else if (type === 'construction') {
const user = _.find(accountList, function (item) {
return item.id === id;
});
const saIdList = [];
for (let i = 0; i < $('#construction-users tr').length; i++) {
saIdList.push(parseInt($('#construction-users tr').eq(i).data('uid')));
}
if (_.includes(saIdList, id)) {
toastr.error('该用户已存在列表中,无需重复添加');
return;
}
const prop = {
id: id,
type: 'add-audit',
};
postData('/sp/' + spid + '/construction/' + cur_tenderid + '/audit/save', prop, function (datas) {
setConstructionHtml(datas);
});
}
}
});
sortCategory4User();
initTenderTree4User();
getFilterTenderTreeHtml();
$('#set-other-tender-user-a').click(function () {
if(!cur_tenderid) {
toastr.warning('未选中标段无法设置');
return;
}
const userType = $('#add_user_dropdownMenuButton').attr('data-type');
const saIdList = [];
for (let i = 0; i < $('#'+ userType +'-users tr').length; i++) {
saIdList.push(parseInt($('#'+ userType +'-users tr').eq(i).data('uid')));
}
if (saIdList.length > 0) {
$('#bdcopy').modal('show');
} else {
toastr.warning('未存在'+ tabTypes[userType] +'用户账号,无法应用至其他标段');
return;
}
});
$('#bdcopy').on('show.bs.modal', function () {
const html = getTenderTreeHtml4User();
$('#tender-list-4user').html(html);
$('#search-tender').val('');
$('#search-tender-result').text('0/0');
$('#up-tender-search').attr('disabled', true);
$('#down-tender-search').attr('disabled', true);
setTimeout(function () { $('#tender-list-4user').scrollTop(0); },500);
});
let timer4SearchTender = null;
let oldSearchVal4SearchTender = null;
$('body').on('input propertychange', '#bdcopy input[name="tender-name"]', function(e) {
oldSearchVal4SearchTender = e.target.value;
timer4SearchTender && clearTimeout(timer4SearchTender);
timer4SearchTender = setTimeout(() => {
const newVal = $(this).val();
const resultLength = $('#tender-list-4user').find('.result').length;
if (resultLength > 0) {
let content = $('#tender-list-4user').html();
const replaceStr = $('#tender-list-4user').find('.result').eq(0).html();
const regExp2 = new RegExp('' + replaceStr + ' ', 'g');
content = content.replace(regExp2, replaceStr);
const regExp3 = new RegExp('' + replaceStr + ' ', 'g');
content = content.replace(regExp3, replaceStr);
$('#tender-list-4user').html(content);
}
$('#search-tender-result').text('0/0');
$('#up-tender-search').attr('disabled', true);
$('#down-tender-search').attr('disabled', true);
if (newVal && newVal === oldSearchVal4SearchTender) {
const regExp = new RegExp(newVal, 'g');
for (let i = 0; i < $('#tender-list-4user tr').length; i++) {
if (_.includes($('#tender-list-4user tr').eq(i).children('td').eq(0).children('a').html(), newVal)) {
$('#tender-list-4user tr').eq(i).children('td').eq(0).children('a').html($('#tender-list-4user tr').eq(i).children('td').eq(0).children('a').html().replace(regExp, '' + newVal + ' '))
}
}
const resultLength2 = $('#tender-list-4user').find('.result').length;
if (resultLength2 > 0) {
$('#tender-list-4user').find('.result').eq(0).css('background', 'orange');
$('#search-tender-result').text('1/' + resultLength2);
$('#up-tender-search').attr('disabled', false);
$('#down-tender-search').attr('disabled', false);
}
}
if($('#tender-list-4user').find('.result').length > 0) {
const X = $('#tender-list-4user').find('.result').eq(0).offset().top;
$('#tender-list-4user').scrollTop(X - $('#tender-list-4user').offset().top + $('#tender-list-4user').scrollTop() - 30);
}
}, 400);
});
$('#up-tender-search').on('click', function () {
const cur = parseInt($('#search-tender-result').text().split('/')[0]);
const total = parseInt($('#search-tender-result').text().split('/')[1]);
const now = cur - 1 !== 0 ? cur - 1: total;
$('#tender-list-4user').find('.result').eq(cur-1).css('background', 'yellow');
$('#tender-list-4user').find('.result').eq(now-1).css('background', 'orange');
// $('#tender-list tr').eq(searchUser[cur-1]).children('td').eq(2).html($('#tender-list tr').eq(searchUser[cur-1]).children('td').eq(2).html().replace('', ''))
// $('#tender-list tr').eq(searchUser[now-1]).children('td').eq(2).html($('#tender-list tr').eq(searchUser[now-1]).children('td').eq(2).html().replace('', ''))
$('#search-tender-result').text(now + '/' + total);
const X = $('#tender-list-4user').find('.result').eq(now-1).offset().top;
$('#tender-list-4user').scrollTop(X - $('#tender-list-4user').offset().top + $('#tender-list-4user').scrollTop() - 30);
});
$('#down-tender-search').on('click', function () {
const cur = parseInt($('#search-tender-result').text().split('/')[0]);
const total = parseInt($('#search-tender-result').text().split('/')[1]);
const now = cur + 1 > total ? 1: cur + 1;
$('#tender-list-4user').find('.result').eq(cur-1).css('background', 'yellow');
$('#tender-list-4user').find('.result').eq(now-1).css('background', 'orange');
// $('#tender-list tr').eq(searchUser[cur-1]).children('td').eq(2).html($('#tender-list tr').eq(searchUser[cur-1]).children('td').eq(2).html().replace('', ''))
// $('#tender-list tr').eq(searchUser[now-1]).children('td').eq(2).html($('#tender-list tr').eq(searchUser[now-1]).children('td').eq(2).html().replace('', ''))
$('#search-tender-result').text(now + '/' + total);
const X = $('#tender-list-4user').find('.result').eq(now-1).offset().top;
$('#tender-list-4user').scrollTop(X - $('#tender-list-4user').offset().top + $('#tender-list-4user').scrollTop() -30);
});
$('#save-other-tender-user').click(function () {
$(this).attr('disabled', true);
const num = $('#tender-list-4user input:checked').length;
if (num < 2) {
toastr.warning('请选择需要应用同步的标段');
$(this).attr('disabled', false);
return;
}
const userType = $('#add_user_dropdownMenuButton').attr('data-type');
const data = {
type: 'copy2otu',
tid: cur_tenderid,
userType,
};
const saIdList = [];
for (let i = 0; i < $('#'+ userType +'-users tr').length; i++) {
const userData = {
uid: parseInt($('#'+ userType +'-users tr').eq(i).data('uid')),
}
if (userType === 'tourist') {
userData.permission = {
file: $('#tourist-users tr').eq(i).find('input[type="checkbox"]').eq(0).is(':checked') ? 1 : 0,
tag: $('#tourist-users tr').eq(i).find('input[type="checkbox"]').eq(1).is(':checked') ? 1 : 0,
};
} else if (userType === 'schedule') {
let permission = scPermission.no;
const _this = $('#schedule-users tr').eq(i).find('input[type="checkbox"]').eq(0);
const _other = $('#schedule-users tr').eq(i).find('input[type="checkbox"]').eq(1);
if (_this.is(':checked') && _other.is(':checked')) {
permission = scPermission.edit;
} else if (_this.is(':checked') && !_other.is(':checked')) {
permission = scPermission.show;
}
userData.permission = permission;
} else if (userType === 'contract') {
userData.permission = {
add: $('#contract-users tr').eq(i).find('input[data-type="permission_add"]').eq(0).is(':checked') ? 1 : 0,
edit: $('#contract-users tr').eq(i).find('input[data-type="permission_edit"]').eq(0).is(':checked') ? 1 : 0,
showUnit: $('#contract-users tr').eq(i).find('input[data-type="permission_show_unit"]').eq(0).is(':checked') ? 1 : 0,
showNode: $('#contract-users tr').eq(i).find('input[data-type="permission_show_node"]').eq(0).is(':checked') ? 1 : 0,
}
} else if (userType === 'construction') {
userData.is_report = $('#construction-users tr').eq(i).find('input[type="checkbox"]').eq(0).is(':checked') ? 1 : 0;
}
saIdList.push(userData);
}
data.auditList = saIdList;
// 获取已选中的标段
const tenderList = [];
for (let i = 0; i < num; i++) {
const tid = parseInt($('#tender-list-4user input:checked').eq(i).data('tid'));
if (tid !== cur_tenderid) {
tenderList.push(tid);
}
}
data.tidList = tenderList.join(',');
// 请求获取右侧列表信息
const _self = $(this);
postData(`/sp/${spid}/setting/manage/tender/save`, data, function (result) {
toastr.success('应用至其他标段成功');
_self.attr('disabled', false);
$('#bdcopy').modal('hide');
}, function () {
_self.attr('disabled', false);
});
});
// 关联标段
$('#select-tender').on('show.bs.modal', function () {
$('#select-all-tender').prop('checked', false);
postData(`/sp/${spid}/setting/manage/tender/save`, { type: 'noSp-tenders' }, function (result) {
const html = [];
for (const t of result) {
html.push('');
html.push('', t.name, ' ');
html.push('', t.user_name, ' ');
html.push('', moment(t.create_time).format('YYYY-MM-DD'), ' ');
html.push('', ' ', ' ');
html.push(' ');
}
$('#no-project-tenders').html(html.join(''));
});
});
$('#bind-sp-btn').click(function () {
const num = $('#no-project-tenders input:checked').length;
if (num < 1) {
toastr.warning('请选择需要关联的标段');
return;
}
const tidList = [];
for (let i = 0; i < num; i++) {
tidList.push($('#no-project-tenders input:checked').eq(i).data('tid'));
}
postData(`/sp/${spid}/setting/manage/tender/save`, { type: 'bind-sp', spid, tidList: tidList.join(',') }, function (result) {
toastr.success('关联标段成功');
$('#select-tender').modal('hide');
setTimeout(function () {
window.location.reload();
}, 500);
});
});
$('#select-all-tender').click(function () {
const checked = $(this).is(':checked');
$('#no-project-tenders input').prop('checked', checked);
});
// $('#change-sp').change(function () {
// const spid = $(this).val();
// console.log(spid);
// postData(`/sp/${spid}/setting/manage/tender/save`, { type: 'get-category', spid }, function (result) {
// $('#cate-list', '#edit-bd').html(getCategoryHtml(result));
// const tender = _.find(tenders, { id: cur_tenderid });
// if (tender && tender.spid === spid) {
// for (const c of tender.category) {
// // $('input[value=' + c.value + ']', '#edit-bd').prop('checked', 'checked');
// $('option[value=' + c.value + ']', '#edit-bd').prop('selected', true);
// }
// }
// });
// })
$('#filter-tender-ok').click(function() {
const updateData = [];
const tr = $('tr[tid]', '#filter-tender');
for (const t of tr) {
const data = { id: t.getAttribute('tid')};
const checkes = $('input', t);
for (const c of checkes) {
data[c.getAttribute('data-type')] = c.checked ? 1 : 0;
}
updateData.push(data);
}
postData(`/sp/${spid}/list/batchUpdate`, updateData, function() {
window.location.reload();
});
});
$('#edit-bd').on('show.bs.modal', function () {
const tree = new TreeSelect({
element: '#tree-container',
data: subProjects,
selected: spid,
onSelect: (id, label) => {
const newSpid = id;
console.log(newSpid);
$('#change-sp').val(newSpid);
postData(`/sp/${newSpid}/setting/manage/tender/save`, { type: 'get-category', spid: newSpid }, function (result) {
$('#cate-list', '#edit-bd').html(getCategoryHtml(result));
const tender = _.find(tenders, { id: cur_tenderid });
if (tender && tender.spid === newSpid) {
for (const c of tender.category) {
// $('input[value=' + c.value + ']', '#edit-bd').prop('checked', 'checked');
$('option[value=' + c.value + ']', '#edit-bd').prop('selected', true);
}
}
});
// console.log('选中了:', id, label);
}
});
});
});
const tenderListSpec = (function(){
function getTenderTreeHeaderHtml() {
const html = [];
html.push('');
html.push('', '');
html.push('', '标段名称', ' ');
html.push('', '创建人', ' ');
html.push(' ', ' ');
return html.join('');
}
function getTenderNodeHtml(node, arr, pid) {
const html = [];
html.push('');
// 名称
html.push('');
if (node.cid) {
html.push(' ');
html.push((node.level === 1 ? '' : ''), node.name, (node.level === 1 ? ' ' : ''));
} else {
html.push('');
html.push('
');
html.push('
');
html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
html.push(' ');
//html.push('
', node[c.field], ' ');
html.push('
', node.name, ' ');
html.push('
');
html.push('
');
html.push('
');
const hasStage = node.progress ? (node.stage_count > 0 ? true : node.stage_status !== 0) : !!node.lastStage;
if (!hasStage) {
html.push('
');
} else {
html.push('
');
}
html.push('
');
}
html.push(' ');
// 创建人
html.push('', node.user_name ? node.user_name : '', ' ');
html.push(' ');
return html.join('');
}
return { getTenderNodeHtml, getTenderTreeHeaderHtml }
})();
function setShenpiHtml(shenpi, tender, revising) {
let html = '';
if (shenpi.sp_lc.length > 0) {
for (const sp of shenpi.sp_lc) {
html += `
设置其他标段
设置其他流程 `;
if (sp.code === 'stage' && !revising && tender.ledger_status === auditConst.ledger.status.checked) {
html += `
多人协同 `;
}
html += `
${sp.name}
${shenpi.sp_status_list[sp.status].name}:${shenpi.sp_status_list[sp.status].msg}
`;
if (sp.status === sp_status.sqspr) {
html += ``;
} else if (sp.status === sp_status.gdspl) {
const flow = sp_lc.find(x => { return x.code === sp.code; });
flow.auditGroupList = sp.auditGroupList;
html += auditUtils.getGroupHtml(flow, sp.code);
let addhtml = '
\n';
addhtml += auditUtils.getgdsplHtml(flow, sp.code);
addhtml += ' \n';
html += addhtml;
} else if (sp.status === sp_status.gdzs) {
let addhtml = '
\n' +
' \n' +
' 授权审批人 \n' +
' \n' +
' \n' +
' \n' +
' \n';
addhtml += sp.audit ? makeAudit(sp.audit) : makeSelectAudit(sp.code);
addhtml += ' \n';
html += addhtml;
}
html += `
`;
}
}
$('#splc').html(html);
}
function setTouristHtml(tourists) {
let html = '';
if (tourists.length > 0) {
for (const t of tourists) {
html += `
${t.user_name}
${t.user_role}
移除
`;
}
}
$('#tourist-users').html(html);
}
function setScheduleHtml(scheduleAuditList) {
let html = '';
if (scheduleAuditList.length > 0) {
for (const sa of scheduleAuditList) {
const audit = _.find(accountList, { id: sa.audit_id });
html += `
${audit ? audit.name : ''}
${audit ? audit.role : ''}
移除
`;
}
}
$('#schedule-users').html(html);
}
function setContractHtml(datas) {
let list = '';
for (const ca of datas) {
list += `
${ca.name}
${ca.role}
移除
`;
}
$('#contract-users').html(list);
}
function setConstructionHtml(constructionAuditList) {
let html = '';
if (constructionAuditList.length > 0) {
for (const sa of constructionAuditList) {
html += `
${sa.name}
${sa.role}
移除
`;
}
}
$('#construction-users').html(html);
}