切换筛选条件时可能继续显示旧数据。

This commit is contained in:
zhanchao 2026-09-09 17:06:20 +08:00
parent 31ac208134
commit 22b2881141

View File

@ -177,6 +177,7 @@ const filterVisible = ref(false);
const filterData = ref({ eventStatus: 'processing' });
const followUpType = ref('person') // person team
const { total, list, loading, page, pages, pageSize, changePage } = usePageList(getList)
let queryVersion = 0;
const certStatus = computed(() => doctorInfo.value?.verifyStatus ? certConfig[doctorInfo.value.verifyStatus] : null)
@ -197,19 +198,27 @@ function changeFilterData(data) {
const case1 = Object.keys(data).filter(i => i != 'eventStatus').length > 0;
const case2 = statusList.some(i => i.value === data.eventStatus);
filtered.value = case1 || !case2;
changePage(1);
refreshList();
}
function changeFollowType(type) {
if (followUpType.value === type) return;
followUpType.value = type;
changePage(1);
refreshList();
}
function changeStatus(val) {
if (filterData.value.eventStatus === val) return;
filterData.value.eventStatus = val;
changePage(1);
refreshList();
}
function refreshList() {
queryVersion += 1;
page.value = 1;
pages.value = 0;
list.value = [];
getList(queryVersion);
}
function getMore() {
@ -262,6 +271,8 @@ async function getList() {
list.value = []
return
}
const currentVersion = queryVersion;
const requestPage = page.value;
loading.value = true;
try {
const data = {
@ -283,6 +294,7 @@ async function getList() {
data.eventType = filterData.value.eventType;
}
const res = await api('getTeamTodos', data);
if (currentVersion !== queryVersion) return;
const arr = res && Array.isArray(res.data) ? res.data.map(i => ({
...i,
eventTypeLabel: ToDoEventType[i.eventType],
@ -293,7 +305,7 @@ async function getList() {
fileList: Array.isArray(i.fileList) ? i.fileList.filter(i => i && i.file && i.file.name) : [],
ownTeam: followUpType.value === 'team'
})) : [];
list.value = page.value === 1 ? arr : [...list.value, ...arr];
list.value = requestPage === 1 ? arr : [...list.value, ...arr];
total.value = res && res.total > 0 ? res.total : 0;
pages.value = res && res.pages > 0 ? res.pages : 0;
if (!res || !res.success) {
@ -303,7 +315,9 @@ async function getList() {
loadWhenNotScrollable();
}
} finally {
loading.value = false;
if (currentVersion === queryVersion) {
loading.value = false;
}
}
}