客户属性映射文件
This commit is contained in:
parent
eedd39ab9e
commit
e29c26c88b
|
|
@ -169,6 +169,12 @@ import { ref, computed, onMounted, onUnmounted, watch } from 'vue';
|
|||
import FabPlus from '@/components/FabPlus.vue';
|
||||
import { usePagination } from '@/composables/usePagination';
|
||||
import { getCustomerList, deleteCustomer } from '@/common/api/customer';
|
||||
import {
|
||||
getCustomerStatusText,
|
||||
getCustomerStatusClass,
|
||||
getIntentLevelText,
|
||||
getStatusListByFilter
|
||||
} from '@/utils/customerMappings';
|
||||
|
||||
// 筛选状态
|
||||
const showFilter = ref(false);
|
||||
|
|
@ -193,36 +199,9 @@ const {
|
|||
defaultParams: {}
|
||||
});
|
||||
|
||||
// 获取状态样式类
|
||||
const getStatusClass = (status) => {
|
||||
return {
|
||||
'status-potential': status === '1', // 潜在
|
||||
'status-intent': status === '2', // 意向
|
||||
'status-deal': status === '3', // 成交
|
||||
'status-invalid': status === '4' // 失效
|
||||
};
|
||||
};
|
||||
|
||||
// 获取状态文本
|
||||
const getStatusText = (status) => {
|
||||
const statusMap = {
|
||||
'1': '潜在',
|
||||
'2': '意向',
|
||||
'3': '成交',
|
||||
'4': '失效'
|
||||
};
|
||||
return statusMap[status] || '未知';
|
||||
};
|
||||
|
||||
// 获取意向强度文本
|
||||
const getIntentLevelText = (intentLevel) => {
|
||||
const levelMap = {
|
||||
'1': '高',
|
||||
'2': '中',
|
||||
'3': '低'
|
||||
};
|
||||
return levelMap[intentLevel] || '--';
|
||||
};
|
||||
// 使用统一映射函数
|
||||
const getStatusClass = getCustomerStatusClass;
|
||||
const getStatusText = getCustomerStatusText;
|
||||
|
||||
// 截断文本
|
||||
const truncateText = (text, maxLength) => {
|
||||
|
|
@ -254,16 +233,9 @@ const buildQueryParams = () => {
|
|||
|
||||
// 只有有效的筛选状态才添加statusList参数
|
||||
if (filterStatus.value) {
|
||||
const statusMap = {
|
||||
'potential': ['1'], // 潜在
|
||||
'intent': ['2'], // 意向
|
||||
'deal': ['3'], // 成交
|
||||
'invalid': ['4'] // 失效
|
||||
};
|
||||
const statusList = getStatusListByFilter(filterStatus.value);
|
||||
|
||||
const statusList = statusMap[filterStatus.value];
|
||||
|
||||
if (statusList) {
|
||||
if (statusList && statusList.length > 0) {
|
||||
params.statusList = statusList;
|
||||
console.log(`筛选状态: ${filterStatus.value} -> statusList:`, statusList);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import { getIntentLevelText } from '@/utils/customerMappings';
|
||||
|
||||
const props = defineProps({
|
||||
customerDetail: {
|
||||
type: Object,
|
||||
|
|
@ -82,15 +84,8 @@ const formatIntents = (intents) => {
|
|||
return intents.join('、');
|
||||
};
|
||||
|
||||
// 获取意向强度文本
|
||||
const getIntentStrengthText = (intentLevel) => {
|
||||
const levelMap = {
|
||||
'1': '高',
|
||||
'2': '中',
|
||||
'3': '低'
|
||||
};
|
||||
return levelMap[intentLevel] || '--';
|
||||
};
|
||||
// 使用统一映射函数
|
||||
const getIntentStrengthText = getIntentLevelText;
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
|
|
|
|||
|
|
@ -136,6 +136,11 @@ import { getCustomerDetail, getCustomerFollowupList, getCustomerProjects, delete
|
|||
import FollowupTab from '@/components/customer-detail/FollowupTab.vue';
|
||||
import ProjectsTab from '@/components/customer-detail/ProjectsTab.vue';
|
||||
import InfoTab from '@/components/customer-detail/InfoTab.vue';
|
||||
import {
|
||||
getCustomerStatusText,
|
||||
getCustomerStatusClass,
|
||||
getIntentLevelText
|
||||
} from '@/utils/customerMappings';
|
||||
|
||||
// 页面参数
|
||||
const customerId = ref('');
|
||||
|
|
@ -217,26 +222,9 @@ const loadProjectList = async () => {
|
|||
}
|
||||
};
|
||||
|
||||
// 获取状态样式类
|
||||
const getStatusClass = (status) => {
|
||||
return {
|
||||
'status-potential': status === '1', // 潜在
|
||||
'status-intent': status === '2', // 意向
|
||||
'status-deal': status === '3', // 成交
|
||||
'status-invalid': status === '4' // 失效
|
||||
};
|
||||
};
|
||||
|
||||
// 获取状态文本
|
||||
const getStatusText = (status) => {
|
||||
const statusMap = {
|
||||
'1': '潜在',
|
||||
'2': '意向',
|
||||
'3': '成交',
|
||||
'4': '失效'
|
||||
};
|
||||
return statusMap[status] || '未知';
|
||||
};
|
||||
// 使用统一映射函数
|
||||
const getStatusClass = getCustomerStatusClass;
|
||||
const getStatusText = getCustomerStatusText;
|
||||
|
||||
// 格式化日期时间
|
||||
const formatDateTime = (dateTime) => {
|
||||
|
|
@ -269,15 +257,8 @@ const formatIntents = (intents) => {
|
|||
return '--';
|
||||
};
|
||||
|
||||
// 获取意向强度文本
|
||||
const getIntentStrengthText = (intentLevel) => {
|
||||
const levelMap = {
|
||||
'1': '高',
|
||||
'2': '中',
|
||||
'3': '低'
|
||||
};
|
||||
return levelMap[intentLevel] || '--';
|
||||
};
|
||||
// 使用统一映射函数
|
||||
const getIntentStrengthText = getIntentLevelText;
|
||||
|
||||
// 返回
|
||||
const handleBack = () => {
|
||||
|
|
|
|||
|
|
@ -182,6 +182,11 @@
|
|||
import { ref, computed, onMounted } from 'vue';
|
||||
import { onLoad } from '@dcloudio/uni-app';
|
||||
import { getFollowupDetail, getCustomerFollowTypeDict } from '@/common/api/customer';
|
||||
import {
|
||||
getCustomerStatusText,
|
||||
getCustomerStatusClass,
|
||||
getIntentLevelText
|
||||
} from '@/utils/customerMappings';
|
||||
|
||||
// 页面参数
|
||||
const followId = ref('');
|
||||
|
|
@ -364,57 +369,11 @@ const formatIntents = (intents) => {
|
|||
return '--';
|
||||
};
|
||||
|
||||
// 获取状态样式类
|
||||
const getStatusClass = (status) => {
|
||||
return {
|
||||
'status-potential': status === '1', // 潜在
|
||||
'status-intent': status === '2', // 意向
|
||||
'status-deal': status === '3', // 成交
|
||||
'status-invalid': status === '4' // 失效
|
||||
};
|
||||
};
|
||||
|
||||
// 获取状态文本
|
||||
const getStatusText = (status) => {
|
||||
const statusMap = {
|
||||
'1': '潜在',
|
||||
'2': '意向',
|
||||
'3': '成交',
|
||||
'4': '失效'
|
||||
};
|
||||
return statusMap[status] || '未知';
|
||||
};
|
||||
|
||||
// 获取客户状态样式类
|
||||
const getCustomerStatusClass = (status) => {
|
||||
return {
|
||||
'status-potential': status === '1', // 潜在
|
||||
'status-intent': status === '2', // 意向
|
||||
'status-deal': status === '3', // 成交
|
||||
'status-invalid': status === '4' // 失效
|
||||
};
|
||||
};
|
||||
|
||||
// 获取客户状态文本
|
||||
const getCustomerStatusText = (status) => {
|
||||
const statusMap = {
|
||||
'1': '潜在',
|
||||
'2': '意向',
|
||||
'3': '成交',
|
||||
'4': '失效'
|
||||
};
|
||||
return statusMap[status] || '未知';
|
||||
};
|
||||
|
||||
// 获取意向强度文本
|
||||
const getIntentStrengthText = (intentLevel) => {
|
||||
const levelMap = {
|
||||
'1': '高',
|
||||
'2': '中',
|
||||
'3': '低'
|
||||
};
|
||||
return levelMap[intentLevel] || '--';
|
||||
};
|
||||
// 使用统一映射函数(保持原有函数名以兼容模板)
|
||||
const getStatusClass = getCustomerStatusClass;
|
||||
const getStatusText = getCustomerStatusText;
|
||||
// getCustomerStatusClass 和 getCustomerStatusText 直接使用导入的函数
|
||||
const getIntentStrengthText = getIntentLevelText;
|
||||
|
||||
// 获取跟进方式文本
|
||||
const getFollowTypeText = (followTypeValue) => {
|
||||
|
|
|
|||
130
utils/customerMappings.js
Normal file
130
utils/customerMappings.js
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
/**
|
||||
* 客户相关映射配置
|
||||
* 统一管理客户状态、意向强度、客户类型等映射关系
|
||||
*/
|
||||
|
||||
/**
|
||||
* 客户状态映射
|
||||
* 状态值 -> 状态文本
|
||||
*/
|
||||
export const CUSTOMER_STATUS_MAP = {
|
||||
'1': '潜在',
|
||||
'2': '意向',
|
||||
'3': '成交',
|
||||
'4': '失效'
|
||||
};
|
||||
|
||||
/**
|
||||
* 客户状态反向映射(用于筛选)
|
||||
* 状态文本 -> 状态值数组
|
||||
*/
|
||||
export const CUSTOMER_STATUS_FILTER_MAP = {
|
||||
'potential': ['1'], // 潜在
|
||||
'intent': ['2'], // 意向
|
||||
'deal': ['3'], // 成交
|
||||
'invalid': ['4'] // 失效
|
||||
};
|
||||
|
||||
/**
|
||||
* 意向强度映射
|
||||
* 强度值 -> 强度文本
|
||||
*/
|
||||
export const INTENT_LEVEL_MAP = {
|
||||
'1': '高',
|
||||
'2': '中',
|
||||
'3': '低'
|
||||
};
|
||||
|
||||
/**
|
||||
* 客户类型映射(如果API返回固定值,可以在这里定义)
|
||||
* 注意:客户类型通常从API获取,这里提供备用映射
|
||||
*/
|
||||
export const CUSTOMER_TYPE_MAP = {
|
||||
// 根据实际业务需求添加
|
||||
// '1': '个人',
|
||||
// '2': '企业',
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取客户状态文本
|
||||
* @param {string|number} status - 客户状态值
|
||||
* @returns {string} 状态文本
|
||||
*/
|
||||
export const getCustomerStatusText = (status) => {
|
||||
if (!status) return '未知';
|
||||
return CUSTOMER_STATUS_MAP[String(status)] || '未知';
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取客户状态样式类
|
||||
* @param {string|number} status - 客户状态值
|
||||
* @returns {object} 样式类对象
|
||||
*/
|
||||
export const getCustomerStatusClass = (status) => {
|
||||
const statusStr = String(status);
|
||||
return {
|
||||
'status-potential': statusStr === '1', // 潜在
|
||||
'status-intent': statusStr === '2', // 意向
|
||||
'status-deal': statusStr === '3', // 成交
|
||||
'status-invalid': statusStr === '4' // 失效
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取意向强度文本
|
||||
* @param {string|number} intentLevel - 意向强度值
|
||||
* @returns {string} 强度文本
|
||||
*/
|
||||
export const getIntentLevelText = (intentLevel) => {
|
||||
if (!intentLevel) return '--';
|
||||
return INTENT_LEVEL_MAP[String(intentLevel)] || '--';
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取客户类型文本(从字典数据中查找)
|
||||
* @param {string|number} type - 客户类型值
|
||||
* @param {Array} typeOptions - 客户类型选项数组,格式: [{label: '', value: ''}]
|
||||
* @returns {string} 类型文本
|
||||
*/
|
||||
export const getCustomerTypeText = (type, typeOptions = []) => {
|
||||
if (!type) return '--';
|
||||
if (!typeOptions || typeOptions.length === 0) {
|
||||
// 如果提供了静态映射,使用静态映射
|
||||
return CUSTOMER_TYPE_MAP[String(type)] || '--';
|
||||
}
|
||||
// 从字典数据中查找
|
||||
const option = typeOptions.find(item => String(item.value || item.dictValue) === String(type));
|
||||
return option ? (option.label || option.dictLabel) : '--';
|
||||
};
|
||||
|
||||
/**
|
||||
* 根据筛选键获取状态值数组
|
||||
* @param {string} filterKey - 筛选键(potential/intent/deal/invalid)
|
||||
* @returns {Array<string>} 状态值数组
|
||||
*/
|
||||
export const getStatusListByFilter = (filterKey) => {
|
||||
return CUSTOMER_STATUS_FILTER_MAP[filterKey] || [];
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取所有客户状态选项(用于下拉选择等)
|
||||
* @returns {Array} 状态选项数组
|
||||
*/
|
||||
export const getCustomerStatusOptions = () => {
|
||||
return Object.entries(CUSTOMER_STATUS_MAP).map(([value, label]) => ({
|
||||
value,
|
||||
label
|
||||
}));
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取所有意向强度选项(用于下拉选择等)
|
||||
* @returns {Array} 强度选项数组
|
||||
*/
|
||||
export const getIntentLevelOptions = () => {
|
||||
return Object.entries(INTENT_LEVEL_MAP).map(([value, label]) => ({
|
||||
value,
|
||||
label
|
||||
}));
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user