客户管理列表排序
This commit is contained in:
parent
ba9d4198ba
commit
48f58b5c1a
|
|
@ -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;
|
||||||
if (statusList && statusList.length > 0) {
|
console.log('筛选今日跟进,日期:', today);
|
||||||
params.statusList = statusList;
|
|
||||||
console.log(`筛选状态: ${filterStatus.value} -> statusList:`, statusList);
|
|
||||||
} else {
|
|
||||||
console.log(`未知的筛选状态: ${filterStatus.value},跳过状态筛选`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
} else {
|
||||||
console.log('无筛选状态,返回空参数');
|
console.log('筛选状态组合未匹配到 statusList,跳过状态筛选');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user