添加过滤自己的客户
This commit is contained in:
parent
ced716d079
commit
ff51c75b6b
|
|
@ -11,7 +11,6 @@
|
||||||
* @param {string} params.excludeld 排除id
|
* @param {string} params.excludeld 排除id
|
||||||
* @param {string[]} params.ids id列表
|
* @param {string[]} params.ids id列表
|
||||||
* @param {string} params.intent 意向
|
* @param {string} params.intent 意向
|
||||||
* @param {string} params.createDate 创建日期 (yyyy-MM-dd)
|
|
||||||
* @param {string} params.joinUserld 参与人id
|
* @param {string} params.joinUserld 参与人id
|
||||||
* @param {string} params.lastFollowDate 上次跟进日期 (yyyy-MM-dd)
|
* @param {string} params.lastFollowDate 上次跟进日期 (yyyy-MM-dd)
|
||||||
* @param {string} params.nextFollowDate 下次跟进日期 (yyyy-MM-dd)
|
* @param {string} params.nextFollowDate 下次跟进日期 (yyyy-MM-dd)
|
||||||
|
|
@ -21,85 +20,42 @@
|
||||||
* @param {string[]} params.saleList 销售列表
|
* @param {string[]} params.saleList 销售列表
|
||||||
* @returns {Promise} 返回客户列表 { total: number, rows: array }
|
* @returns {Promise} 返回客户列表 { total: number, rows: array }
|
||||||
*/
|
*/
|
||||||
|
// 最终推荐版本(添加默认排序参数)
|
||||||
export const getCustomerList = (params = {}) => {
|
export const getCustomerList = (params = {}) => {
|
||||||
|
console.log('api params:', params);
|
||||||
|
|
||||||
const queryParams = [];
|
const queryParams = [];
|
||||||
|
|
||||||
// 处理分页参数
|
// 添加默认排序参数
|
||||||
if (params.pageNum !== undefined && params.pageNum !== null) {
|
const defaultParams = {
|
||||||
queryParams.push(`pageNum=${encodeURIComponent(params.pageNum)}`);
|
orderByColumn: 'nextFollowTime',
|
||||||
}
|
isAsc: 'ascending'
|
||||||
|
|
||||||
if (params.pageSize !== undefined && params.pageSize !== null) {
|
|
||||||
queryParams.push(`pageSize=${encodeURIComponent(params.pageSize)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理数组参数
|
|
||||||
if (params.statusList && Array.isArray(params.statusList) && params.statusList.length > 0) {
|
|
||||||
params.statusList.forEach(status => {
|
|
||||||
queryParams.push(`statusList=${encodeURIComponent(status)}`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.ids && Array.isArray(params.ids) && params.ids.length > 0) {
|
|
||||||
params.ids.forEach(id => {
|
|
||||||
queryParams.push(`ids=${encodeURIComponent(id)}`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.createDateRange && Array.isArray(params.createDateRange) && params.createDateRange.length > 0) {
|
|
||||||
params.createDateRange.forEach(date => {
|
|
||||||
queryParams.push(`createDateRange=${encodeURIComponent(date)}`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.saleList && Array.isArray(params.saleList) && params.saleList.length > 0) {
|
|
||||||
params.saleList.forEach(sale => {
|
|
||||||
queryParams.push(`saleList=${encodeURIComponent(sale)}`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理字符串参数
|
|
||||||
if (params.excludeld) {
|
|
||||||
queryParams.push(`excludeld=${encodeURIComponent(params.excludeld)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.intent) {
|
|
||||||
queryParams.push(`intent=${encodeURIComponent(params.intent)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.createDate) {
|
|
||||||
queryParams.push(`createDate=${encodeURIComponent(params.createDate)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.joinUserld) {
|
|
||||||
queryParams.push(`joinUserld=${encodeURIComponent(params.joinUserld)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.lastFollowDate) {
|
|
||||||
queryParams.push(`lastFollowDate=${encodeURIComponent(params.lastFollowDate)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.nextFollowDate) {
|
|
||||||
queryParams.push(`nextFollowDate=${encodeURIComponent(params.nextFollowDate)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.nextFollowDateStart) {
|
|
||||||
queryParams.push(`nextFollowDateStart=${encodeURIComponent(params.nextFollowDateStart)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (params.nextFollowDateEnd) {
|
|
||||||
queryParams.push(`nextFollowDateEnd=${encodeURIComponent(params.nextFollowDateEnd)}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
const queryString = queryParams.length > 0 ? `?${queryParams.join('&')}` : '';
|
|
||||||
|
|
||||||
return uni.$uv.http.get(`bst/customer/list${queryString}`, {
|
|
||||||
custom: {
|
|
||||||
auth: true // 启用 token 认证
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 合并参数:默认参数 + 用户传入参数(用户参数优先)
|
||||||
|
const finalParams = { ...defaultParams, ...params };
|
||||||
|
|
||||||
|
Object.entries(finalParams).forEach(([key, value]) => {
|
||||||
|
if (value == null) return; // 过滤 null 和 undefined
|
||||||
|
|
||||||
|
if (Array.isArray(value)) {
|
||||||
|
value.forEach(item => {
|
||||||
|
if (item != null) {
|
||||||
|
queryParams.push(`${encodeURIComponent(key)}=${encodeURIComponent(item.toString())}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
queryParams.push(`${encodeURIComponent(key)}=${encodeURIComponent(value.toString())}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const queryString = queryParams.join('&');
|
||||||
|
const url = `bst/customer/list${queryString ? `?${queryString}` : ''}`;
|
||||||
|
|
||||||
|
console.log('最终请求URL:', url);
|
||||||
|
|
||||||
|
return uni.$uv.http.get(url, { custom: { auth: true } });
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* 获取客户详情
|
* 获取客户详情
|
||||||
* @param {string} id 客户ID
|
* @param {string} id 客户ID
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
<!-- 顶部标题栏 -->
|
<!-- 顶部标题栏 -->
|
||||||
<view class="header">
|
<view class="header">
|
||||||
<text class="header-title">客户管理</text>
|
<text class="header-title">客户管理</text>
|
||||||
|
<uv-switch v-model="filterSelf"></uv-switch>
|
||||||
<view class="filter-btn" @click="showFilter = !showFilter">
|
<view class="filter-btn" @click="showFilter = !showFilter">
|
||||||
<text class="filter-text">筛选</text>
|
<text class="filter-text">筛选</text>
|
||||||
<text class="filter-icon" :class="{ 'rotate': showFilter }">▼</text>
|
<text class="filter-icon" :class="{ 'rotate': showFilter }">▼</text>
|
||||||
|
|
@ -105,7 +106,7 @@
|
||||||
|
|
||||||
<!-- 分配用户 -->
|
<!-- 分配用户 -->
|
||||||
<view class="detail-row">
|
<view class="detail-row">
|
||||||
<text class="detail-label">客户归属:</text>
|
<text class="detail-label">跟进人:</text>
|
||||||
<text class="detail-value">{{ customer.followName || '--' }}</text>
|
<text class="detail-value">{{ customer.followName || '--' }}</text>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
@ -161,11 +162,13 @@ import FabPlus from '@/components/FabPlus.vue';
|
||||||
import CustomerSummaryBrief from '@/components/customer/CustomerSummaryBrief.vue';
|
import CustomerSummaryBrief from '@/components/customer/CustomerSummaryBrief.vue';
|
||||||
import { usePagination } from '@/composables/usePagination';
|
import { usePagination } from '@/composables/usePagination';
|
||||||
import { getCustomerList, deleteCustomer } from '@/common/api/customer';
|
import { getCustomerList, deleteCustomer } from '@/common/api/customer';
|
||||||
|
import{useUserStore} from "@/store/user";
|
||||||
import {
|
import {
|
||||||
getStatusListByFilter
|
getStatusListByFilter
|
||||||
} from '@/utils/customerMappings';
|
} from '@/utils/customerMappings';
|
||||||
|
|
||||||
// 筛选状态
|
// 筛选状态
|
||||||
|
const filterSelf =ref(false);
|
||||||
const showFilter = ref(false);
|
const showFilter = ref(false);
|
||||||
const filterStatus = ref('');
|
const filterStatus = ref('');
|
||||||
|
|
||||||
|
|
@ -226,6 +229,10 @@ const formatDateTime = (dateTime) => {
|
||||||
const buildQueryParams = () => {
|
const buildQueryParams = () => {
|
||||||
const params = {};
|
const params = {};
|
||||||
|
|
||||||
|
params.joinUserId = filterSelf.value? useUserStore().getUserInfo.user.userId : null
|
||||||
|
console.log(filterSelf.value? useUserStore().getUserInfo.user.userId : null)
|
||||||
|
|
||||||
|
|
||||||
// 只有有效的筛选状态才添加statusList参数
|
// 只有有效的筛选状态才添加statusList参数
|
||||||
if (filterStatus.value) {
|
if (filterStatus.value) {
|
||||||
const statusList = getStatusListByFilter(filterStatus.value);
|
const statusList = getStatusListByFilter(filterStatus.value);
|
||||||
|
|
@ -364,6 +371,7 @@ watch(filterStatus, () => {
|
||||||
reset();
|
reset();
|
||||||
// 清除所有查询参数,只保留基础分页参数
|
// 清除所有查询参数,只保留基础分页参数
|
||||||
queryParams.value = {
|
queryParams.value = {
|
||||||
|
joinUserId: filterSelf.value? useUserStore().getUserInfo.user.userId : null,
|
||||||
pageNum: 1,
|
pageNum: 1,
|
||||||
pageSize: 10
|
pageSize: 10
|
||||||
};
|
};
|
||||||
|
|
@ -376,6 +384,13 @@ watch(filterStatus, () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(filterSelf, () => {
|
||||||
|
console.log('筛选是否自己变化:', filterSelf.value);
|
||||||
|
const params = buildQueryParams();
|
||||||
|
console.log('<UNK>:当前参数', params);
|
||||||
|
updateParams(params);
|
||||||
|
})
|
||||||
|
|
||||||
// 监听客户列表刷新事件
|
// 监听客户列表刷新事件
|
||||||
const handleCustomerListRefresh = () => {
|
const handleCustomerListRefresh = () => {
|
||||||
console.log('收到客户列表刷新事件');
|
console.log('收到客户列表刷新事件');
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export const Request = () => {
|
||||||
uni.$uv.http.setConfig((config) => {
|
uni.$uv.http.setConfig((config) => {
|
||||||
/* config 为默认全局配置*/
|
/* config 为默认全局配置*/
|
||||||
config.baseURL = 'http://192.168.1.5:4001'; /* 根域名 */
|
config.baseURL = 'http://192.168.1.5:4001'; /* 根域名 */
|
||||||
config.baseURL = 'https://pm.ccttiot.com/prod-api'; /* 根域名 */
|
// config.baseURL = 'https://pm.ccttiot.com/prod-api'; /* 根域名 */
|
||||||
return config
|
return config
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user