v6 - sync employee data from task assignment
This commit is contained in:
parent
7b11eb9c85
commit
8279540f8d
51
index.html
51
index.html
@ -597,14 +597,55 @@ document.querySelectorAll('.employee-select').forEach(select => {
|
||||
select.addEventListener('change', function() {
|
||||
const task = this.closest('.task');
|
||||
const title = task.querySelector('.title').textContent;
|
||||
const employee = this.value;
|
||||
const newEmployee = this.value;
|
||||
const meta = task.querySelector('.meta');
|
||||
const oldEmployee = meta.textContent.split('Исполнитель: ')[1]?.split(' •')[0] || '';
|
||||
|
||||
if (employee) {
|
||||
const meta = task.querySelector('.meta');
|
||||
if (newEmployee && oldEmployee !== newEmployee) {
|
||||
// Обновляем текущую задачу
|
||||
const deadline = meta.textContent.split('•')[1] || '';
|
||||
meta.textContent = 'Исполнитель: ' + employee + ' •' + deadline;
|
||||
meta.textContent = 'Исполнитель: ' + newEmployee + ' •' + deadline;
|
||||
|
||||
showNotification('Задача "' + title + '" назначена на ' + employee);
|
||||
// Обновляем данные сотрудника во всех других задачах
|
||||
document.querySelectorAll('.task .meta').forEach(m => {
|
||||
if (m !== meta && m.textContent.includes('Исполнитель: ' + oldEmployee)) {
|
||||
m.textContent = m.textContent.replace('Исполнитель: ' + oldEmployee, 'Исполнитель: ' + newEmployee);
|
||||
}
|
||||
});
|
||||
|
||||
// Обновляем данные в закупках
|
||||
document.querySelectorAll('.table td').forEach(td => {
|
||||
if (td.textContent.trim() === oldEmployee && td.nextElementSibling && !td.nextElementSibling.querySelector('select')) {
|
||||
td.textContent = newEmployee;
|
||||
}
|
||||
});
|
||||
|
||||
// Обновляем данные в загрузке сотрудников
|
||||
document.querySelectorAll('.employee .name').forEach(nameEl => {
|
||||
if (nameEl.textContent.trim() === oldEmployee) {
|
||||
nameEl.textContent = newEmployee;
|
||||
}
|
||||
});
|
||||
|
||||
// Обновляем selectы с сотрудниками
|
||||
document.querySelectorAll('.employee-select').forEach(s => {
|
||||
s.querySelectorAll('option').forEach(option => {
|
||||
if (option.value === oldEmployee) {
|
||||
option.value = newEmployee;
|
||||
option.textContent = newEmployee;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Обновляем таблицу сотрудников
|
||||
document.querySelectorAll('.table tr[data-employee-name]').forEach(row => {
|
||||
if (row.dataset.employeeName === oldEmployee) {
|
||||
row.dataset.employeeName = newEmployee;
|
||||
row.cells[0].textContent = newEmployee;
|
||||
}
|
||||
});
|
||||
|
||||
showNotification('Сотрудник "' + oldEmployee + '" заменён на "' + newEmployee + '" во всех разделах');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user