refactor: worker select & employee nationality
This commit is contained in:
parent
8006314ce4
commit
9d745d8e52
5 changed files with 100 additions and 52 deletions
|
|
@ -21,7 +21,7 @@ const props = withDefaults(
|
|||
},
|
||||
);
|
||||
|
||||
defineExpose({ select });
|
||||
defineExpose({ select, assignSelect });
|
||||
|
||||
function select(item?: unknown, all?: boolean) {
|
||||
if (all) {
|
||||
|
|
@ -44,6 +44,19 @@ function select(item?: unknown, all?: boolean) {
|
|||
} else selectedItem.value.push(item);
|
||||
}
|
||||
}
|
||||
|
||||
function assignSelect(to: unknown[], from: unknown[]) {
|
||||
const existingItems = new Set(to);
|
||||
|
||||
for (let i = to.length - 1; i >= 0; i--) {
|
||||
if (!from.includes(to[i])) {
|
||||
to.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
const newItems = from.filter((item) => !existingItems.has(item));
|
||||
to.push(...newItems);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<section class="full-width column">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue