客户管理列表排序

This commit is contained in:
WindowBird 2025-11-20 17:54:49 +08:00
parent ba9d4198ba
commit 48f58b5c1a

View File

@ -20,29 +20,34 @@
<view class="filter-options"> <view class="filter-options">
<text <text
class="filter-option" class="filter-option"
:class="{ 'active': filterStatus === '' }" :class="{ 'active': isAllSelected }"
@click="filterStatus = ''" @click="handleSelectAll"
>全部</text> >全部</text>
<text <text
class="filter-option" class="filter-option"
:class="{ 'active': filterStatus === 'potential' }" :class="{ 'active': isFilterSelected('potential') }"
@click="filterStatus = 'potential'" @click="toggleFilter('potential')"
>潜在</text> >潜在</text>
<text <text
class="filter-option" class="filter-option"
:class="{ 'active': filterStatus === 'intent' }" :class="{ 'active': isFilterSelected('intent') }"
@click="filterStatus = 'intent'" @click="toggleFilter('intent')"
>意向</text> >意向</text>
<text <text
class="filter-option" class="filter-option"
:class="{ 'active': filterStatus === 'deal' }" :class="{ 'active': isFilterSelected('deal') }"
@click="filterStatus = 'deal'" @click="toggleFilter('deal')"
>成交</text> >成交</text>
<text <text
class="filter-option" class="filter-option"
:class="{ 'active': filterStatus === 'invalid' }" :class="{ 'active': isFilterSelected('invalid') }"
@click="filterStatus = 'invalid'" @click="toggleFilter('invalid')"
>失效</text> >失效</text>
<text
class="filter-option"
:class="{ 'active': isFilterSelected(TODAY_FOLLOW_FILTER) }"
@click="toggleFilter(TODAY_FOLLOW_FILTER)"
>今日跟进</text>
</view> </view>
</view> </view>
</view> </view>
@ -174,6 +179,13 @@ import {
// //
const userStore = useUserStore(); const userStore = useUserStore();
const { userInfo, privateView } = storeToRefs(userStore); const { userInfo, privateView } = storeToRefs(userStore);
const PAGE_SIZE = 10;
const DEFAULT_SORT = {
orderByColumn: 'next_follow_time',
isAsc: 'descending'
};
const TODAY_FOLLOW_FILTER = 'todayFollow';
const filterSelf = computed({ const filterSelf = computed({
get: () => privateView.value, get: () => privateView.value,
set: (val) => userStore.setPrivateView(val) set: (val) => userStore.setPrivateView(val)
@ -185,7 +197,8 @@ const showPrivateSwitch = computed(() =>
userInfo.value?.roles?.some(r => ['admin','sys_admin'].includes(r)) userInfo.value?.roles?.some(r => ['admin','sys_admin'].includes(r))
); );
const showFilter = ref(false); const showFilter = ref(false);
const filterStatus = ref(''); const selectedFilters = ref([]);
const isAllSelected = computed(() => selectedFilters.value.length === 0);
// 使 // 使
const { const {
@ -202,8 +215,10 @@ const {
} = usePagination({ } = usePagination({
fetchData: getCustomerList, fetchData: getCustomerList,
mode: 'loadMore', mode: 'loadMore',
pageSize: 10, pageSize: PAGE_SIZE,
defaultParams: {} defaultParams: {
...DEFAULT_SORT
}
}); });
// CustomerSummaryBrief // CustomerSummaryBrief
@ -241,30 +256,71 @@ const formatDateTime = (dateTime) => {
}; };
// //
const getTodayDate = () => {
const today = new Date();
const year = today.getFullYear();
const month = String(today.getMonth() + 1).padStart(2, '0');
const day = String(today.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
};
const buildQueryParams = () => { const buildQueryParams = () => {
const params = { const params = {
joinUserId: filterSelf.value && currentUserId.value ? currentUserId.value : null ...DEFAULT_SORT,
joinUserId: filterSelf.value && currentUserId.value ? currentUserId.value : null,
nextFollowDateStart: null,
nextFollowDateEnd: null
}; };
console.log(filterSelf.value ? currentUserId.value : null)
const hasTodayFollowFilter = selectedFilters.value.includes(TODAY_FOLLOW_FILTER);
const statusFilters = selectedFilters.value.filter(item => item !== TODAY_FOLLOW_FILTER);
// statusList if (hasTodayFollowFilter) {
if (filterStatus.value) { const today = getTodayDate();
const statusList = getStatusListByFilter(filterStatus.value); params.nextFollowDateStart = today;
params.nextFollowDateEnd = today;
console.log('筛选今日跟进,日期:', today);
}
if (statusList && statusList.length > 0) { if (statusFilters.length > 0) {
params.statusList = statusList; const mergedStatusList = Array.from(
console.log(`筛选状态: ${filterStatus.value} -> statusList:`, statusList); new Set(
statusFilters.flatMap(filterKey => getStatusListByFilter(filterKey) || [])
)
);
if (mergedStatusList.length > 0) {
params.statusList = mergedStatusList;
console.log('筛选状态组合:', statusFilters, '-> statusList:', mergedStatusList);
} else { } else {
console.log(`未知的筛选状态: ${filterStatus.value},跳过状态筛选`); console.log('筛选状态组合未匹配到 statusList跳过状态筛选');
} }
} else { }
console.log('无筛选状态,返回空参数');
if (!hasTodayFollowFilter && statusFilters.length === 0) {
console.log('无筛选状态,返回默认参数');
} }
return params; return params;
}; };
const isFilterSelected = (filterKey) => selectedFilters.value.includes(filterKey);
const toggleFilter = (filterKey) => {
if (!filterKey) return;
const exists = selectedFilters.value.includes(filterKey);
if (exists) {
selectedFilters.value = selectedFilters.value.filter(item => item !== filterKey);
} else {
selectedFilters.value = [...selectedFilters.value, filterKey];
}
};
const handleSelectAll = () => {
if (selectedFilters.value.length === 0) return;
selectedFilters.value = [];
};
// //
const handleCustomerClick = (customer) => { const handleCustomerClick = (customer) => {
console.log('点击客户:', customer); console.log('点击客户:', customer);
@ -377,27 +433,25 @@ const handleAddCustomer = () => {
}; };
// //
watch(filterStatus, () => { watch(selectedFilters, () => {
console.log('筛选状态变化:', filterStatus.value); console.log('筛选状态变化:', selectedFilters.value);
// "" if (selectedFilters.value.length === 0) {
if (filterStatus.value === '') {
//
reset(); reset();
// id queryParams.value = {
queryParams.value = { ...DEFAULT_SORT,
joinUserId: filterSelf.value && currentUserId.value ? currentUserId.value : null, joinUserId: filterSelf.value && currentUserId.value ? currentUserId.value : null,
pageNum: 1, pageNum: 1,
pageSize: 10 pageSize: PAGE_SIZE,
nextFollowDateStart: null,
nextFollowDateEnd: null
}; };
//
refresh(); refresh();
} else { } else {
// 使 updateParams
const params = buildQueryParams(); const params = buildQueryParams();
updateParams(params); updateParams(params);
} }
}); }, { deep: true });
watch(filterSelf, () => { watch(filterSelf, () => {
console.log('筛选是否自己变化:', filterSelf.value); console.log('筛选是否自己变化:', filterSelf.value);