$(function () {
autoFlashHeight();
//编辑input及textarea
$('.edit-input').on('change', function () {
const newVal = _.trim($(this).val());
const id = $(this).data('id');
if (newVal.length > 1000) {
toastr.error('内容字符长度不能超过1000');
return false;
}
updateJsonData(newVal, id);
});
$('.edit-textarea').on('change', function () {
const newVal = $(this).val();
const id = $(this).data('id');
if (newVal.length > 10000) {
toastr.error('内容字符长度不能超过10000');
return false;
}
updateJsonData(newVal, id);
});
function updateJsonData(newVal, id) {
postData('/construction/' + tender_id + '/log/' + log_id + '/save', { type: 'update_json', updateData: { key: id, value: newVal } }, function (result) {
});
}
// 审签人选择
let timer = null
let oldSearchVal = null
$('#gr-search').bind('input propertychange', function(e) {
oldSearchVal = e.target.value
timer && clearTimeout(timer)
timer = setTimeout(() => {
const newVal = $('#gr-search').val()
let html = ''
if (newVal && newVal === oldSearchVal) {
accountList.filter(item => item && cur_uid !== item.id && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
html += `
`
group.groupList.forEach(item => {
if (item.id !== cur_uid) {
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 id = parseInt($(this).data('id'));
if (id) {
postData('/construction/' + tender_id + '/log/' + log_id + '/save', { type: 'set_shenpi', uid: id }, function (result) {
$('#show-shenpi-btn').hide();
$('#show-shenpi span').text(result.shenpi_username);
$('#show-shenpi').show();
});
}
});
$('.remove-shenpi-btn').on('click', function () {
postData('/construction/' + tender_id + '/log/' + log_id + '/save', { type: 'remove_shenpi' }, function (result) {
$('#show-shenpi-btn').show();
$('#show-shenpi span').text('');
$('#show-shenpi').hide();
});
});
$('body').on('click', '#start-btn', function () {
// 判断是否已选择审签人,有则提交
const username = $('#show-shenpi span').text() || $('#show-shenpi-input').val();
if (username == '') {
toastr.error('请选择审签人再提交');
return false;
}
postData('/construction/' + tender_id + '/log/' + log_id + '/save', { type: 'start' }, function (result) {
window.location.reload();
});
});
$('#edit-start').click(function () {
// $('#edit-end').show();
$('#edit-start').hide();
$('.edit-input').removeAttr('readonly');
$('.edit-textarea').removeAttr('readonly');
$(this).siblings('span').hide();
$(this).parents('.title-main').append('
${index+1} |
${att.filename}${att.fileext} |
${moment(att.upload_time).format("YYYY-MM-DD HH:mm:ss")} |
`
html += (att.uid === accountId && (logStatus === constructionStatusConst.checked ? Boolean(att.extra_upload) : true)) ?
`` : '';
html += ` | `;
}
$('#attList').html(html);
$('#attList').on('click', 'tr', function() {
$('#attList tr').removeClass('bg-light');
$(this).addClass('bg-light');
});
}
});