ознакомление
This commit is contained in:
105
public/tasks.js
105
public/tasks.js
@@ -628,6 +628,106 @@ function canUserAddFilesToTask(task) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ==================== ФУНКЦИИ ДЛЯ ОЗНАКОМЛЕНИЯ ====================
|
||||
|
||||
async function openAcquaintanceModal(taskId) {
|
||||
try {
|
||||
const response = await fetch(`/api/tasks/${taskId}`);
|
||||
if (!response.ok) throw new Error('Ошибка загрузки задачи');
|
||||
const task = await response.json();
|
||||
|
||||
// Заполняем модальное окно
|
||||
document.getElementById('acquaintance-original-task-id').value = task.id;
|
||||
document.getElementById('acquaintance-original-title').innerHTML = `
|
||||
<strong>№${task.id}</strong> ${task.title}<br>
|
||||
<small>Автор: ${task.creator_name}</small>
|
||||
`;
|
||||
|
||||
// Устанавливаем дату выполнения по умолчанию (завтра)
|
||||
const tomorrow = new Date();
|
||||
tomorrow.setDate(tomorrow.getDate() + 1);
|
||||
document.getElementById('acquaintance-due-date').value = tomorrow.toISOString().split('T')[0];
|
||||
document.getElementById('acquaintance-due-time').value = '19:00';
|
||||
|
||||
// Загружаем пользователей для выбора автора
|
||||
await loadUsers(); // гарантируем, что users загружены
|
||||
renderAcquaintanceAuthorsChecklist(users);
|
||||
|
||||
// Информация об исполнителе (текущий пользователь)
|
||||
const executorInfo = document.getElementById('acquaintance-executor-info');
|
||||
if (executorInfo) {
|
||||
executorInfo.innerHTML = `Исполнитель: ${currentUser.name} (${currentUser.login})`;
|
||||
}
|
||||
|
||||
// Отображаем модальное окно
|
||||
document.getElementById('acquaintance-task-modal').style.display = 'block';
|
||||
} catch (error) {
|
||||
console.error('Ошибка открытия модального окна ознакомления:', error);
|
||||
alert('Не удалось загрузить задачу');
|
||||
}
|
||||
}
|
||||
|
||||
function closeAcquaintanceModal() {
|
||||
const modal = document.getElementById('acquaintance-task-modal');
|
||||
if (modal) modal.style.display = 'none';
|
||||
|
||||
const authorSearch = document.getElementById('acquaintance-author-search');
|
||||
if (authorSearch) authorSearch.value = '';
|
||||
|
||||
const userSearch = document.getElementById('acquaintance-user-search');
|
||||
if (userSearch) userSearch.value = '';
|
||||
|
||||
acquaintanceSelectedUsers = [];
|
||||
acquaintanceSelectedAuthor = null;
|
||||
}
|
||||
|
||||
async function createAcquaintanceTask(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const originalTaskId = document.getElementById('acquaintance-original-task-id').value;
|
||||
const dueDate = document.getElementById('acquaintance-due-date').value;
|
||||
const dueTime = document.getElementById('acquaintance-due-time').value;
|
||||
const fullDueDateTime = `${dueDate}T${dueTime}:00`;
|
||||
const comment = document.getElementById('acquaintance-comment').value.trim();
|
||||
const assignedUserIds = [currentUser.id]; // исполнитель – текущий пользователь
|
||||
const creatorId = document.querySelector('input[name="acquaintance-author"]:checked')?.value;
|
||||
|
||||
if (!creatorId) {
|
||||
alert('Выберите автора задачи');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('/api/tasks/acquaintance', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
originalTaskId,
|
||||
dueDate: fullDueDateTime,
|
||||
assignedUserIds,
|
||||
creatorId,
|
||||
comment
|
||||
})
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
alert('Задача ознакомления успешно создана!');
|
||||
closeAcquaintanceModal();
|
||||
loadTasks();
|
||||
loadActivityLogs();
|
||||
} else {
|
||||
alert(`Ошибка: ${result.error || 'Неизвестная ошибка'}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Ошибка создания задачи ознакомления:', error);
|
||||
alert('Сетевая ошибка');
|
||||
}
|
||||
}
|
||||
|
||||
// Добавляем отладочную функцию
|
||||
function debugDocumentFields() {
|
||||
console.log('=== ОТЛАДКА ПОЛЕЙ ДОКУМЕНТОВ ===');
|
||||
@@ -647,4 +747,7 @@ function debugDocumentFields() {
|
||||
window.debugDocumentFields = debugDocumentFields;
|
||||
window.loadTasks = loadTasks;
|
||||
window.updateAssignment = updateAssignment;
|
||||
window.renderTasksForActiveSection = renderTasksForActiveSection;
|
||||
window.renderTasksForActiveSection = renderTasksForActiveSection;
|
||||
window.openAcquaintanceModal = openAcquaintanceModal;
|
||||
window.closeAcquaintanceModal = closeAcquaintanceModal;
|
||||
window.createAcquaintanceTask = createAcquaintanceTask;
|
||||
Reference in New Issue
Block a user