v5 - sync employee data across all sections
This commit is contained in:
parent
ce466279af
commit
7b11eb9c85
55
index.html
55
index.html
@ -291,7 +291,7 @@ body{font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,s
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr data-id="emp1">
|
||||
<tr data-id="emp1" data-employee-name="Айгуль К.">
|
||||
<td contenteditable="true">Айгуль К.</td>
|
||||
<td contenteditable="true">Специалист АХО</td>
|
||||
<td contenteditable="true">8</td>
|
||||
@ -299,7 +299,7 @@ body{font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,s
|
||||
<td><span class="badge approved">92%</span></td>
|
||||
<td><button class="btn-save" onclick="saveEmployee(this)">Сохранить</button></td>
|
||||
</tr>
|
||||
<tr data-id="emp2">
|
||||
<tr data-id="emp2" data-employee-name="Руслан М.">
|
||||
<td contenteditable="true">Руслан М.</td>
|
||||
<td contenteditable="true">Техник</td>
|
||||
<td contenteditable="true">6</td>
|
||||
@ -307,7 +307,7 @@ body{font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,s
|
||||
<td><span class="badge approved">88%</span></td>
|
||||
<td><button class="btn-save" onclick="saveEmployee(this)">Сохранить</button></td>
|
||||
</tr>
|
||||
<tr data-id="emp3">
|
||||
<tr data-id="emp3" data-employee-name="Динара С.">
|
||||
<td contenteditable="true">Динара С.</td>
|
||||
<td contenteditable="true">Документооборот</td>
|
||||
<td contenteditable="true">5</td>
|
||||
@ -315,7 +315,7 @@ body{font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,s
|
||||
<td><span class="badge approved">95%</span></td>
|
||||
<td><button class="btn-save" onclick="saveEmployee(this)">Сохранить</button></td>
|
||||
</tr>
|
||||
<tr data-id="emp4">
|
||||
<tr data-id="emp4" data-employee-name="Алексей В.">
|
||||
<td contenteditable="true">Алексей В.</td>
|
||||
<td contenteditable="true">Кладовщик</td>
|
||||
<td contenteditable="true">5</td>
|
||||
@ -611,8 +611,51 @@ document.querySelectorAll('.employee-select').forEach(select => {
|
||||
|
||||
function saveEmployee(btn) {
|
||||
const row = btn.closest('tr');
|
||||
const name = row.cells[0].textContent;
|
||||
showNotification('Данные сотрудника "' + name + '" сохранены');
|
||||
const oldName = row.dataset.employeeName;
|
||||
const newName = row.cells[0].textContent.trim();
|
||||
const newRole = row.cells[1].textContent.trim();
|
||||
|
||||
// Обновляем данные во всех задачах
|
||||
document.querySelectorAll('.task .meta').forEach(meta => {
|
||||
if (meta.textContent.includes('Исполнитель: ' + oldName)) {
|
||||
meta.textContent = meta.textContent.replace('Исполнитель: ' + oldName, 'Исполнитель: ' + newName);
|
||||
}
|
||||
});
|
||||
|
||||
// Обновляем данные во всех закупках
|
||||
document.querySelectorAll('.table td').forEach(td => {
|
||||
if (td.textContent.trim() === oldName && td.nextElementSibling && !td.nextElementSibling.querySelector('select')) {
|
||||
td.textContent = newName;
|
||||
}
|
||||
});
|
||||
|
||||
// Обновляем данные в загрузке сотрудников
|
||||
document.querySelectorAll('.employee .name').forEach(nameEl => {
|
||||
if (nameEl.textContent.trim() === oldName) {
|
||||
nameEl.textContent = newName;
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelectorAll('.employee .role').forEach(roleEl => {
|
||||
if (roleEl.textContent.trim() === oldName || roleEl.textContent.includes(oldName)) {
|
||||
roleEl.textContent = newRole;
|
||||
}
|
||||
});
|
||||
|
||||
// Обновляем selectы с сотрудниками
|
||||
document.querySelectorAll('.employee-select').forEach(select => {
|
||||
select.querySelectorAll('option').forEach(option => {
|
||||
if (option.value === oldName) {
|
||||
option.value = newName;
|
||||
option.textContent = newName;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Сохраняем новое имя для будущих изменений
|
||||
row.dataset.employeeName = newName;
|
||||
|
||||
showNotification('Данные сотрудника "' + oldName + '" обновлены на "' + newName + '" во всех разделах');
|
||||
}
|
||||
|
||||
function savePurchase(btn) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user