fix: on delete worker update selected worker properly
This commit is contained in:
parent
e40e85102f
commit
6fe81fc47c
1 changed files with 8 additions and 0 deletions
|
|
@ -208,9 +208,17 @@ watch(
|
|||
() => props.employeeRows,
|
||||
(a, b) => {
|
||||
if (a === undefined || b === undefined) return;
|
||||
|
||||
const removed = b.findIndex(
|
||||
(c) => !a.find((d) => JSON.stringify(c) === JSON.stringify(d)),
|
||||
);
|
||||
|
||||
if (a.length < b.length) {
|
||||
rows.value.forEach((p) => {
|
||||
const maxValue = Math.max(...p.workerIndex);
|
||||
if (removed !== -1) {
|
||||
p.workerIndex = p.workerIndex.map((i) => (i > removed ? i - 1 : i));
|
||||
}
|
||||
p.workerIndex = p.workerIndex.filter((i) => i !== maxValue);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue