действия

This commit is contained in:
2026-03-05 22:58:14 +05:00
parent 4e74132143
commit c958a7f913
4 changed files with 66 additions and 29 deletions

View File

@@ -70,7 +70,7 @@ class TaskChat {
></textarea> ></textarea>
<div class="chat-attachments" id="chat-attachments-${this.taskId}"></div> <div class="chat-attachments" id="chat-attachments-${this.taskId}"></div>
<div class="chat-actions"> <div class="chat-actions">
<button class="chat-send-btn" onclick="window.taskChats[${this.taskId}].sendMessage()">➤</button> <button class="chat-send-btn" onclick="window.taskChats[${this.taskId}].sendMessage()">➤ Отправить ➤</button>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -29,7 +29,7 @@ if (currentUser && !isDeleted && !isClosed) {
actions.push({ actions.push({
label: '▶️ Приступить', label: '▶️ Приступить',
handler: () => window.updateStatus(taskId, currentUser.id, 'in_progress'), handler: () => window.updateStatus(taskId, currentUser.id, 'in_progress'),
primary: true primary: true
}); });
} }
// Кнопка "Выполнено" (если статус 'in_progress', 'overdue' или 'rework') // Кнопка "Выполнено" (если статус 'in_progress', 'overdue' или 'rework')
@@ -41,11 +41,21 @@ if (currentUser && !isDeleted && !isClosed) {
actions.push({ actions.push({
label: '✅ Выполнено', label: '✅ Выполнено',
handler: handler, handler: handler,
primary: true primary: true
}); });
} }
} }
} }
// Копия доступна всем, у кого есть кнопка
if (typeof openCopyModal === 'function') {
actions.push({ label: '📋 Создать копию',
handler: () => openCopyModal(taskId),
primary: true
});
log('nav-task-actions assignRemove_openModal yes');
} else {
log('nav-task-actions assignRemove_openModal not');
}
// Действия для активных (не удалённых, не закрытых) задач // Действия для активных (не удалённых, не закрытых) задач
if (!isDeleted && !isClosed && currentUser.login === 'minicrm') { if (!isDeleted && !isClosed && currentUser.login === 'minicrm') {
if (typeof openTaskChat === 'function') { if (typeof openTaskChat === 'function') {
@@ -81,7 +91,7 @@ if (currentUser && !isDeleted && !isClosed) {
// ${currentUser && currentUser.role === 'tasks' && canEdit || currentUser.role === 'admin' // ${currentUser && currentUser.role === 'tasks' && canEdit || currentUser.role === 'admin'
// Администраторы и роль tasks // Администраторы и роль tasks
if (currentUser && (currentUser.role === 'admin' || (currentUser.role === 'tasks' && canEdit))) { if (currentUser && (currentUser.role === 'admin' || (currentUser.role === 'tasks' && canEdit))) {
if (typeof assignAdd_openModal === 'function') { if (typeof assignAdd_openModal === 'function') {
actions.push({ label: '🧑‍💼➕ Добавить исполнителя', actions.push({ label: '🧑‍💼➕ Добавить исполнителя',
@@ -102,35 +112,27 @@ if (currentUser && !isDeleted && !isClosed) {
log('nav-task-actions assignRemove_openModal not'); log('nav-task-actions assignRemove_openModal not');
} }
//} //}
// Копия доступна всем, у кого есть кнопка
if (typeof openCopyModal === 'function') {
actions.push({ label: '📋 Создать копию', handler: () => openCopyModal(taskId) });
log('nav-task-actions assignRemove_openModal yes');
} else {
log('nav-task-actions assignRemove_openModal not');
}
// Доработка для документа (исполнитель) // Доработка для документа (исполнитель)
//if (task.task_type === 'document' && userRole === 'Исполнитель') { if (currentUser && (currentUser.role === 'admin' && currentUser.login === 'minicrm')) {
if (typeof openReworkModal === 'function') { if (typeof openReworkModal === 'function') {
actions.push({ label: '🔄 Переделать документ', handler: () => openReworkModal(taskId) }); actions.push({ label: '🔄 Переделать документ', handler: () => openReworkModal(taskId) });
log('nav-task-actions assignRemove_openModal yes'); log('nav-task-actions assignRemove_openModal yes');
} else { } else {
log('nav-task-actions assignRemove_openModal not'); log('nav-task-actions assignRemove_openModal not');
} }
//} }
}
// Доработка и изменение срока для необычных задач (исполнитель) // Доработка и изменение срока для необычных задач (исполнитель)
//if (!isDeleted && !isClosed && task.task_type !== 'regular' &&task.assignments && task.assignments.some(a => parseInt(a.user_id) === window.currentUser?.id)) { if (!isDeleted && !isClosed && task.task_type !== 'regular' && task.assignments && task.assignments.some(a => parseInt(a.user_id) === currentUser?.id)) {
if (typeof openReworkModal === 'function') { actions.push({ label: '🔄 Доработка', handler: () => openReworkModal(taskId) }); if (typeof openReworkModal === 'function') { actions.push({ label: '🔄 Доработка', handler: () => openReworkModal(taskId),primary_task: true});
log('nav-task-actions openReworkModal yes'); log('nav-task-actions openReworkModal yes');
} else {log('nav-task-actions openReworkModal not');} } else {log('nav-task-actions openReworkModal not');}
if (typeof openChangeDeadlineModal === 'function') { actions.push({ label: '📅 Изменить срок', handler: () => openChangeDeadlineModal(taskId) }); if (typeof openChangeDeadlineModal === 'function') { actions.push({ label: '📅 Изменить срок', handler: () => openChangeDeadlineModal(taskId),primary_task: true });
log('nav-task-actions openChangeDeadlineModal yes'); log('nav-task-actions openChangeDeadlineModal yes');
} else {log('nav-task-actions openChangeDeadlineModal not');} } else {log('nav-task-actions openChangeDeadlineModal not');}
//} }
if (currentUser && currentUser.login === 'minicrm') {
// Закрытие (только minicrm) // Закрытие (только minicrm)
//if (window.currentUser && window.currentUser.login === 'minicrm') { //if (window.currentUser && window.currentUser.login === 'minicrm') {
if (typeof closeTask === 'function') actions.push({ label: '🔒 Закрыть задачу', handler: () => closeTask(taskId) }); if (typeof closeTask === 'function') actions.push({ label: '🔒 Закрыть задачу', handler: () => closeTask(taskId) });
@@ -200,7 +202,8 @@ log('nav-task-actions openChangeDeadlineModal yes');
// primary // primary
const primaryActions = actions.filter(a => a.primary); const primaryActions = actions.filter(a => a.primary);
const adminActions = actions.filter(a => a.admin && !a.primary); const adminActions = actions.filter(a => a.admin && !a.primary);
const userActions = actions.filter(a => !a.primary && !a.admin); const taskActions = actions.filter(a => a.primary_task && !a.primary && !a.primary);
const userActions = actions.filter(a => !a.primary && !a.admin && !a.primary_task);
// Создаём затемнение // Создаём затемнение
const overlay = document.createElement('div'); const overlay = document.createElement('div');
overlay.id = 'task-action-modal'; overlay.id = 'task-action-modal';
@@ -290,6 +293,37 @@ if (primaryActions.length > 0) {
}); });
modal.appendChild(primaryContainer); modal.appendChild(primaryContainer);
} }
// === Блок taskActions ===
if (taskActions.length > 0) {
const taskContainer = document.createElement('div');
taskContainer.style.marginBottom = '20px';
taskActions.forEach(a => {
const btn = document.createElement('button');
btn.textContent = a.label;
btn.style.cssText = `
width: 100%;
padding: 14px;
background-color: #dfc63cff; // цвет
color: white;
border: none;
border-radius: 8px;
font-size: 16px;
font-weight: 500;
cursor: pointer;
transition: background-color 0.2s;
margin-bottom: 10px;
`;
btn.onmouseover = () => btn.style.backgroundColor = '#dfc63cff';
btn.onmouseout = () => btn.style.backgroundColor = '#dfc63cff';
btn.onclick = (event) => {
event.stopPropagation();
a.handler();
removeModal();
};
taskContainer.appendChild(btn);
});
modal.appendChild(taskContainer);
}
// === Блок admin === // === Блок admin ===
if (adminActions.length > 0) { if (adminActions.length > 0) {
const adminContainer = document.createElement('div'); const adminContainer = document.createElement('div');
@@ -321,6 +355,7 @@ if (adminActions.length > 0) {
}); });
modal.appendChild(adminContainer); modal.appendChild(adminContainer);
} }
// === Блок остальных (user) === // === Блок остальных (user) ===
if (userActions.length > 0) { if (userActions.length > 0) {
const grid = document.createElement('div'); const grid = document.createElement('div');

View File

@@ -179,9 +179,9 @@ ${currentUser && currentUser.login === 'minicrm' ? `<button class="manage-assign
${currentUser && currentUser.login === 'minicrm' ? `<button class="rework-btn" onclick="openReworkModal(${task.id})" title="Вернуть на доработку">🔄</button>` : ''} ${currentUser && currentUser.login === 'minicrm' ? `<button class="rework-btn" onclick="openReworkModal(${task.id})" title="Вернуть на доработку">🔄</button>` : ''}
<!-- Кнопка переделки документа для исполнителей --> <!-- Кнопка переделки документа для исполнителей -->
${task.task_type === 'document' && userRole === 'Исполнитель' ? `<button class="rework-btn" onclick="openReworkModal(${task.id})" title="Переделать документ">🔄Переделать</button>` : ''} ${task.task_type === 'document' && userRole === 'Исполнитель' && currentUser.login === 'minicrm' ? `<button class="rework-btn" onclick="openReworkModal(${task.id})" title="Переделать документ">🔄Переделать</button>` : ''}
${!isDeleted && !isClosed && task.task_type !== 'regular' && task.assignments && task.assignments.some(a => parseInt(a.user_id) === currentUser.id) ? ` ${!isDeleted && !isClosed && task.task_type !== 'regular' && task.assignments && task.assignments.some(a => parseInt(a.user_id) === currentUser.id) && currentUser.login === 'minicrm' ? `
<button class="rework-btn" onclick="openReworkModal(${task.id})" title="Вернуть на доработку">🔄Доработка</button> <button class="rework-btn" onclick="openReworkModal(${task.id})" title="Вернуть на доработку">🔄Доработка</button>
<button class="change-deadline-btn" onclick="openChangeDeadlineModal(${task.id})" title="Изменить срок">📅</button> <button class="change-deadline-btn" onclick="openChangeDeadlineModal(${task.id})" title="Изменить срок">📅</button>
` : ''} ` : ''}
@@ -1035,7 +1035,7 @@ function openAddFileModal(taskId) {
<input type="hidden" name="task_id" value="${taskId}"> <input type="hidden" name="task_id" value="${taskId}">
<div class="form-group"> <div class="form-group">
<label for="file-input">Выберите файл:</label> <label for="file-input">Выберите один файл:</label>
<input type="file" id="file-input" name="files" multiple> <input type="file" id="file-input" name="files" multiple>
<small>Максимальный размер: 10MB</small> <small>Максимальный размер: 10MB</small>
</div> </div>
@@ -1043,11 +1043,13 @@ function openAddFileModal(taskId) {
<div class="form-group"> <div class="form-group">
<label for="file-description">Описание файла (необязательно):</label> <label for="file-description">Описание файла (необязательно):</label>
<textarea id="file-description" name="description" rows="3" <textarea id="file-description" name="description" rows="3"
placeholder="Описание файла..."></textarea> placeholder="название фаила ограничено 45 символами"></textarea>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn-cancel" onclick="closeAddFileModal()">Отмена</button> <!--
<button type="button" class="btn-primary" onclick="closeAddFileModal()">Отмена</button>
-->
<button type="submit" class="btn-primary">Добавить файл</button> <button type="submit" class="btn-primary">Добавить файл</button>
</div> </div>
</form> </form>

View File

@@ -1584,7 +1584,7 @@ initializeServer().then(() => {
// Запускаем фоновые задачи // Запускаем фоновые задачи
setInterval(checkOverdueTasks, 60000); setInterval(checkOverdueTasks, 60000);
setInterval(checkUpcomingDeadlines, 60000); setInterval(checkUpcomingDeadlines, 60000);
setInterval(() => cronJobs.checkDocumentsForCompletion(db), 5*60000); setInterval(() => cronJobs.checkDocumentsForCompletion(db), 60000);
}); });
}).catch(error => { }).catch(error => {
console.error('❌ Не удалось запустить сервер:', error); console.error('❌ Не удалось запустить сервер:', error);