fix event list filter
This commit is contained in:
@@ -125,7 +125,7 @@ import EventAPI from "@/api/EventAPI";
|
|||||||
import EventRecordAPI from "@/api/EventRecordAPI";
|
import EventRecordAPI from "@/api/EventRecordAPI";
|
||||||
import EventRecordCell from "@/pages/event/component/EventRecordCell.vue";
|
import EventRecordCell from "@/pages/event/component/EventRecordCell.vue";
|
||||||
import { useNavBarStore } from "@/store/navBarStore";
|
import { useNavBarStore } from "@/store/navBarStore";
|
||||||
import type { EventItem } from "@/types/EventItem";
|
import type { EventItem, EventStatus } from "@/types/EventItem";
|
||||||
import type { EventOptionStat, EventRecordPage, EventRecordPageResult, VerificationStatus } from "@/types/EventRecord";
|
import type { EventOptionStat, EventRecordPage, EventRecordPageResult, VerificationStatus } from "@/types/EventRecord";
|
||||||
import type { NavBarAction } from "@/types/NavBarAction";
|
import type { NavBarAction } from "@/types/NavBarAction";
|
||||||
import { formatEventNumberValue } from "@/utils/eventValue";
|
import { formatEventNumberValue } from "@/utils/eventValue";
|
||||||
@@ -182,7 +182,7 @@ let suppressOptionFilterReload = false;
|
|||||||
const canCreateRecord = computed(() => userStore.hasPermissions(permissionCodes.eventRecord.create));
|
const canCreateRecord = computed(() => userStore.hasPermissions(permissionCodes.eventRecord.create));
|
||||||
const dateFilterLabel = computed(() => dateOptions.find(item => item.value === dateFilterType.value)?.label || "今天");
|
const dateFilterLabel = computed(() => dateOptions.find(item => item.value === dateFilterType.value)?.label || "今天");
|
||||||
const actionOptions = computed(() => eventList.value.map(item => ({
|
const actionOptions = computed(() => eventList.value.map(item => ({
|
||||||
label: item.name || "未命名事件",
|
label: getEventDisplayName(item),
|
||||||
value: item.id || ""
|
value: item.id || ""
|
||||||
})).filter(item => item.value));
|
})).filter(item => item.value));
|
||||||
const eventFilterLabel = computed(() => {
|
const eventFilterLabel = computed(() => {
|
||||||
@@ -192,7 +192,7 @@ const eventFilterLabel = computed(() => {
|
|||||||
|
|
||||||
return eventList.value
|
return eventList.value
|
||||||
.filter(item => item.id && actionFilter.value.includes(item.id))
|
.filter(item => item.id && actionFilter.value.includes(item.id))
|
||||||
.map(item => item.name || "未命名事件")
|
.map(item => getEventDisplayName(item))
|
||||||
.join("、");
|
.join("、");
|
||||||
});
|
});
|
||||||
const selectedOptionEvent = computed(() => {
|
const selectedOptionEvent = computed(() => {
|
||||||
@@ -393,15 +393,36 @@ async function loadRecords(): Promise<void> {
|
|||||||
// ---------- 操作 ----------
|
// ---------- 操作 ----------
|
||||||
|
|
||||||
async function loadActions(): Promise<void> {
|
async function loadActions(): Promise<void> {
|
||||||
eventList.value = await EventAPI.listValid();
|
// 历史登记记录需要关联已停用或已删除的事件,不能使用只返回 ACTIVE 事件的 listValid。
|
||||||
const validEventIdList = eventList.value.map(item => item.id).filter((item): item is string => Boolean(item));
|
const result = await EventAPI.list({ index: 0, size: 1000 });
|
||||||
const validEventIdSet = new Set(validEventIdList);
|
eventList.value = result.list || [];
|
||||||
const eventIdList = parseEventIdList(route.query.eventIds).filter(eventId => validEventIdSet.has(eventId));
|
const eventIdList = eventList.value.map(item => item.id).filter((item): item is string => Boolean(item));
|
||||||
actionFilter.value = eventIdList.length ? eventIdList : validEventIdList;
|
const eventIdSet = new Set(eventIdList);
|
||||||
|
const selectedEventIdList = parseEventIdList(route.query.eventIds).filter(eventId => eventIdSet.has(eventId));
|
||||||
|
actionFilter.value = selectedEventIdList.length ? selectedEventIdList : eventIdList;
|
||||||
const optionIdSet = new Set(optionFilterOptions.value.map(item => item.value));
|
const optionIdSet = new Set(optionFilterOptions.value.map(item => item.value));
|
||||||
optionFilter.value = parseEventIdList(route.query.optionIds).filter(optionId => optionIdSet.has(optionId));
|
optionFilter.value = parseEventIdList(route.query.optionIds).filter(optionId => optionIdSet.has(optionId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getEventDisplayName(event: EventItem): string {
|
||||||
|
const name = event.name || "未命名事件";
|
||||||
|
const statusText = getEventStatusText(event.status);
|
||||||
|
return statusText ? `${name}(${statusText})` : name;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getEventStatusText(status?: EventStatus): string {
|
||||||
|
if (status === "DRAFT") {
|
||||||
|
return "草稿";
|
||||||
|
}
|
||||||
|
if (status === "INACTIVE") {
|
||||||
|
return "不可登记";
|
||||||
|
}
|
||||||
|
if (status === "DELETED") {
|
||||||
|
return "已删除";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
async function selectDateFilter(type: DropdownValue): Promise<void> {
|
async function selectDateFilter(type: DropdownValue): Promise<void> {
|
||||||
if (Array.isArray(type)) {
|
if (Array.isArray(type)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user