|
|
@@ -34,7 +34,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ref, watch } from "vue";
|
|
|
+import { ref, watch, nextTick } from "vue";
|
|
|
import { User } from "@element-plus/icons-vue";
|
|
|
import { localGet } from "@/utils";
|
|
|
import type { ElTable } from "element-plus";
|
|
|
@@ -53,6 +53,8 @@ export interface GuestItem {
|
|
|
const props = defineProps<{
|
|
|
modelValue: boolean;
|
|
|
selectedIds?: (string | number)[];
|
|
|
+ /** 已选嘉宾完整列表,用于合并确认结果(未出现在当前列表的嘉宾会保留) */
|
|
|
+ selectedGuests?: GuestItem[];
|
|
|
}>();
|
|
|
|
|
|
const emit = defineEmits<{
|
|
|
@@ -67,6 +69,8 @@ const guestList = ref<GuestItem[]>([]);
|
|
|
const selectedRows = ref<GuestItem[]>([]);
|
|
|
const tableRef = ref<InstanceType<typeof ElTable>>();
|
|
|
|
|
|
+const selectedIdSet = () => new Set((props.selectedIds ?? []).map(id => String(id)));
|
|
|
+
|
|
|
watch(
|
|
|
() => props.modelValue,
|
|
|
v => {
|
|
|
@@ -85,7 +89,9 @@ async function loadList() {
|
|
|
storeId: localGet("createdId") as string,
|
|
|
pageNum: 1,
|
|
|
pageSize: 100,
|
|
|
- keyword: keyword.value || undefined
|
|
|
+ onlineStatus: 0,
|
|
|
+ status: 1,
|
|
|
+ staffName: keyword.value || undefined
|
|
|
});
|
|
|
const raw = res?.data ?? res;
|
|
|
const list = raw?.records ?? raw?.list ?? (Array.isArray(raw) ? raw : []);
|
|
|
@@ -96,6 +102,8 @@ async function loadList() {
|
|
|
avatar: item.avatar ?? item.staffImage ?? item.headImg,
|
|
|
position: item.position ?? item.staffPosition ?? item.style
|
|
|
}));
|
|
|
+ await nextTick();
|
|
|
+ restoreSelection();
|
|
|
} catch (e) {
|
|
|
guestList.value = [];
|
|
|
} finally {
|
|
|
@@ -103,6 +111,15 @@ async function loadList() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+function restoreSelection() {
|
|
|
+ const ids = selectedIdSet();
|
|
|
+ const tbl = tableRef.value;
|
|
|
+ if (!tbl || !ids.size) return;
|
|
|
+ guestList.value.forEach(row => {
|
|
|
+ if (ids.has(String(row.id))) tbl.toggleRowSelection(row, true);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
function search() {
|
|
|
loadList();
|
|
|
}
|
|
|
@@ -117,7 +134,18 @@ function onSelectionChange(rows: GuestItem[]) {
|
|
|
}
|
|
|
|
|
|
function confirm() {
|
|
|
- emit("confirm", selectedRows.value);
|
|
|
+ const idsInList = new Set(guestList.value.map(r => String(r.id)));
|
|
|
+ const existingNotInList = (props.selectedGuests ?? []).filter(g => !idsInList.has(String(g.id)));
|
|
|
+ const merged = [...existingNotInList];
|
|
|
+ const seen = new Set(existingNotInList.map(g => String(g.id)));
|
|
|
+ selectedRows.value.forEach(row => {
|
|
|
+ const id = String(row.id);
|
|
|
+ if (!seen.has(id)) {
|
|
|
+ seen.add(id);
|
|
|
+ merged.push(row);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ emit("confirm", merged);
|
|
|
visible.value = false;
|
|
|
}
|
|
|
|