客户管理列表排序
This commit is contained in:
parent
ba9d4198ba
commit
48f58b5c1a
|
|
@ -20,29 +20,34 @@
|
|||
<view class="filter-options">
|
||||
<text
|
||||
class="filter-option"
|
||||
:class="{ 'active': filterStatus === '' }"
|
||||
@click="filterStatus = ''"
|
||||
:class="{ 'active': isAllSelected }"
|
||||
@click="handleSelectAll"
|
||||
>全部</text>
|
||||
<text
|
||||
class="filter-option"
|
||||
:class="{ 'active': filterStatus === 'potential' }"
|
||||
@click="filterStatus = 'potential'"
|
||||
:class="{ 'active': isFilterSelected('potential') }"
|
||||
@click="toggleFilter('potential')"
|
||||
>潜在</text>
|
||||
<text
|
||||
class="filter-option"
|
||||
:class="{ 'active': filterStatus === 'intent' }"
|
||||
@click="filterStatus = 'intent'"
|
||||
:class="{ 'active': isFilterSelected('intent') }"
|
||||
@click="toggleFilter('intent')"
|
||||
>意向</text>
|
||||
<text
|
||||
class="filter-option"
|
||||
:class="{ 'active': filterStatus === 'deal' }"
|
||||
@click="filterStatus = 'deal'"
|
||||
:class="{ 'active': isFilterSelected('deal') }"
|
||||
@click="toggleFilter('deal')"
|
||||
>成交</text>
|
||||
<text
|
||||
class="filter-option"
|
||||
:class="{ 'active': filterStatus === 'invalid' }"
|
||||
@click="filterStatus = 'invalid'"
|
||||
:class="{ 'active': isFilterSelected('invalid') }"
|
||||
@click="toggleFilter('invalid')"
|
||||
>失效</text>
|
||||
<text
|
||||
class="filter-option"
|
||||
:class="{ 'active': isFilterSelected(TODAY_FOLLOW_FILTER) }"
|
||||
@click="toggleFilter(TODAY_FOLLOW_FILTER)"
|
||||
>今日跟进</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
|
@ -174,6 +179,13 @@ import {
|
|||
// 筛选状态
|
||||
const userStore = useUserStore();
|
||||
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({
|
||||
get: () => privateView.value,
|
||||
set: (val) => userStore.setPrivateView(val)
|
||||
|
|
@ -185,7 +197,8 @@ const showPrivateSwitch = computed(() =>
|
|||
userInfo.value?.roles?.some(r => ['admin','sys_admin'].includes(r))
|
||||
);
|
||||
const showFilter = ref(false);
|
||||
const filterStatus = ref('');
|
||||
const selectedFilters = ref([]);
|
||||
const isAllSelected = computed(() => selectedFilters.value.length === 0);
|
||||
|
||||
// 使用分页组合式函数
|
||||
const {
|
||||
|
|
@ -202,8 +215,10 @@ const {
|
|||
} = usePagination({
|
||||
fetchData: getCustomerList,
|
||||
mode: 'loadMore',
|
||||
pageSize: 10,
|
||||
defaultParams: {}
|
||||
pageSize: PAGE_SIZE,
|
||||
defaultParams: {
|
||||
...DEFAULT_SORT
|
||||
}
|
||||
});
|
||||
|
||||
// 本页状态映射与样式由 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 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 (filterStatus.value) {
|
||||
const statusList = getStatusListByFilter(filterStatus.value);
|
||||
|
||||
if (statusList && statusList.length > 0) {
|
||||
params.statusList = statusList;
|
||||
console.log(`筛选状态: ${filterStatus.value} -> statusList:`, statusList);
|
||||
} else {
|
||||
console.log(`未知的筛选状态: ${filterStatus.value},跳过状态筛选`);
|
||||
if (hasTodayFollowFilter) {
|
||||
const today = getTodayDate();
|
||||
params.nextFollowDateStart = today;
|
||||
params.nextFollowDateEnd = today;
|
||||
console.log('筛选今日跟进,日期:', today);
|
||||
}
|
||||
|
||||
if (statusFilters.length > 0) {
|
||||
const mergedStatusList = Array.from(
|
||||
new Set(
|
||||
statusFilters.flatMap(filterKey => getStatusListByFilter(filterKey) || [])
|
||||
)
|
||||
);
|
||||
|
||||
if (mergedStatusList.length > 0) {
|
||||
params.statusList = mergedStatusList;
|
||||
console.log('筛选状态组合:', statusFilters, '-> statusList:', mergedStatusList);
|
||||
} else {
|
||||
console.log('无筛选状态,返回空参数');
|
||||
console.log('筛选状态组合未匹配到 statusList,跳过状态筛选');
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasTodayFollowFilter && statusFilters.length === 0) {
|
||||
console.log('无筛选状态,返回默认参数');
|
||||
}
|
||||
|
||||
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) => {
|
||||
console.log('点击客户:', customer);
|
||||
|
|
@ -377,27 +433,25 @@ const handleAddCustomer = () => {
|
|||
};
|
||||
|
||||
// 监听筛选状态变化,更新查询参数并重新加载
|
||||
watch(filterStatus, () => {
|
||||
console.log('筛选状态变化:', filterStatus.value);
|
||||
watch(selectedFilters, () => {
|
||||
console.log('筛选状态变化:', selectedFilters.value);
|
||||
|
||||
// 点击"全部"时,直接重置并刷新,清除所有缓存参数
|
||||
if (filterStatus.value === '') {
|
||||
// 重置分页状态
|
||||
if (selectedFilters.value.length === 0) {
|
||||
reset();
|
||||
// 清除所有查询参数,只保留基础分页参数,保留用户id过滤参数
|
||||
queryParams.value = {
|
||||
...DEFAULT_SORT,
|
||||
joinUserId: filterSelf.value && currentUserId.value ? currentUserId.value : null,
|
||||
pageNum: 1,
|
||||
pageSize: 10
|
||||
pageSize: PAGE_SIZE,
|
||||
nextFollowDateStart: null,
|
||||
nextFollowDateEnd: null
|
||||
};
|
||||
// 直接刷新列表
|
||||
refresh();
|
||||
} else {
|
||||
// 其他筛选状态,使用 updateParams 更新参数
|
||||
const params = buildQueryParams();
|
||||
updateParams(params);
|
||||
}
|
||||
});
|
||||
}, { deep: true });
|
||||
|
||||
watch(filterSelf, () => {
|
||||
console.log('筛选是否自己变化:', filterSelf.value);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user