feat: 添加仅已购用户筛选功能

This commit is contained in:
2025-12-20 23:30:51 +08:00
parent 257c9a286a
commit 661a595fa7
4 changed files with 67 additions and 8 deletions

View File

@@ -1,12 +1,13 @@
import httpClient from './httpClient';
export const userService = {
getUsers({ page = 1, limit = 10, keyword = '' } = {}) {
getUsers({ page = 1, limit = 10, keyword = '', onlyBought = false } = {}) {
return httpClient.get('/users', {
params: {
page,
limit,
keyword: keyword.trim()
keyword: keyword.trim(),
onlyBought
}
});
},

View File

@@ -7,6 +7,7 @@ import Column from 'primevue/column';
import ConfirmDialog from 'primevue/confirmdialog';
import DataTable from 'primevue/datatable';
import Dialog from 'primevue/dialog';
import Dropdown from 'primevue/dropdown';
import InputText from 'primevue/inputtext';
import ProgressSpinner from 'primevue/progressspinner';
import Toast from 'primevue/toast';
@@ -25,6 +26,12 @@ const filters = ref({
status: { value: null, matchMode: 'equals' }
});
const boughtFilterOptions = ref([
{ name: '全部用户', value: false },
{ name: '仅已购用户', value: true }
]);
const onlyBought = ref(false);
// Table state
const users = ref({
items: [],
@@ -58,7 +65,8 @@ const fetchUsers = async () => {
const response = await userService.getUsers({
page: currentPage,
limit: rows.value,
keyword: globalFilterValue.value
keyword: globalFilterValue.value,
onlyBought: onlyBought.value
});
users.value = response.data;
} catch (error) {
@@ -188,6 +196,11 @@ const savePhone = async () => {
onMounted(() => {
fetchUsers();
});
const onOnlyBoughtChange = () => {
first.value = 0;
fetchUsers();
};
</script>
<template>
@@ -263,7 +276,9 @@ onMounted(() => {
</div>
<div class="card">
<div class="pb-10 flex">
<div class="pb-10 flex gap-3 items-center">
<Dropdown v-model="onlyBought" :options="boughtFilterOptions" optionLabel="name" optionValue="value"
class="w-48" @change="onOnlyBoughtChange" />
<InputText v-model="globalFilterValue" placeholder="搜索用户..." class="flex-1" @input="onSearch" />
</div>