跟进状态映射

This commit is contained in:
WindowBird 2025-11-11 12:00:18 +08:00
parent e29c26c88b
commit fa0b67a76d
4 changed files with 69 additions and 28 deletions

View File

@ -235,6 +235,11 @@ import {
getCustomerFollowTypeDict
} from '@/common/api/customer.js';
import FollowupPickers from '@/components/followup-form/FollowupPickers.vue';
import {
getCustomerStatusText,
getIntentLevelText as getIntentLevelTextFromMapping,
getFollowTypeText as getFollowTypeTextFromMapping
} from '@/utils/customerMappings';
//
const formData = ref({
@ -803,22 +808,19 @@ const formatDateTimeForInput = (date) => {
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
};
//
// 使
const getStatusText = (value) => {
const item = statusOptions.value.find(item => item.dictValue === value);
return item ? item.dictLabel : '';
return getCustomerStatusText(value, statusOptions.value);
};
//
// 使
const getIntentLevelText = (value) => {
const item = intentLevelOptions.value.find(item => item.dictValue === value);
return item ? item.dictLabel : '';
return getIntentLevelTextFromMapping(value, intentLevelOptions.value);
};
//
// 使
const getFollowTypeText = (value) => {
const item = followTypeOptions.value.find(item => item.dictValue === value);
return item ? item.dictLabel : '';
return getFollowTypeTextFromMapping(value, followTypeOptions.value);
};
//

View File

@ -185,7 +185,8 @@ import { getFollowupDetail, getCustomerFollowTypeDict } from '@/common/api/custo
import {
getCustomerStatusText,
getCustomerStatusClass,
getIntentLevelText
getIntentLevelText,
getFollowTypeText as getFollowTypeTextFromMapping
} from '@/utils/customerMappings';
//
@ -375,13 +376,9 @@ const getStatusText = getCustomerStatusText;
// getCustomerStatusClass getCustomerStatusText 使
const getIntentStrengthText = getIntentLevelText;
//
// 使
const getFollowTypeText = (followTypeValue) => {
if (!followTypeValue) return '--';
//
const option = followTypeOptions.value.find(item => item.dictValue === String(followTypeValue));
return option ? option.dictLabel : '--';
return getFollowTypeTextFromMapping(followTypeValue, followTypeOptions.value);
};
//

View File

@ -238,6 +238,11 @@ import {
getCustomerFollowTypeDict
} from '@/common/api/customer.js';
import FollowupPickers from '@/components/followup-form/FollowupPickers.vue';
import {
getCustomerStatusText,
getIntentLevelText as getIntentLevelTextFromMapping,
getFollowTypeText as getFollowTypeTextFromMapping
} from '@/utils/customerMappings';
// ID
const followId = ref('');
@ -871,22 +876,19 @@ const formatDateTimeForInput = (date) => {
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
};
//
// 使
const getStatusText = (value) => {
const item = statusOptions.value.find(item => item.dictValue === value);
return item ? item.dictLabel : '';
return getCustomerStatusText(value, statusOptions.value);
};
//
// 使
const getIntentLevelText = (value) => {
const item = intentLevelOptions.value.find(item => item.dictValue === value);
return item ? item.dictLabel : '';
return getIntentLevelTextFromMapping(value, intentLevelOptions.value);
};
//
// 使
const getFollowTypeText = (value) => {
const item = followTypeOptions.value.find(item => item.dictValue === value);
return item ? item.dictLabel : '';
return getFollowTypeTextFromMapping(value, followTypeOptions.value);
};
//

View File

@ -1,6 +1,6 @@
/**
* 客户相关映射配置
* 统一管理客户状态意向强度客户类型等映射关系
* 统一管理客户状态意向强度客户类型跟进方式等映射关系
*/
/**
@ -48,10 +48,21 @@ export const CUSTOMER_TYPE_MAP = {
/**
* 获取客户状态文本
* @param {string|number} status - 客户状态值
* @param {Array} statusOptions - 客户状态选项数组可选格式: [{dictLabel: '', dictValue: ''}] [{label: '', value: ''}]
* @returns {string} 状态文本
*/
export const getCustomerStatusText = (status) => {
export const getCustomerStatusText = (status, statusOptions = []) => {
if (!status) return '未知';
// 如果提供了字典数据,优先从字典数据中查找
if (statusOptions && statusOptions.length > 0) {
const option = statusOptions.find(item =>
String(item.dictValue || item.value) === String(status)
);
if (option) {
return option.dictLabel || option.label || '未知';
}
}
// 否则使用静态映射
return CUSTOMER_STATUS_MAP[String(status)] || '未知';
};
@ -73,10 +84,21 @@ export const getCustomerStatusClass = (status) => {
/**
* 获取意向强度文本
* @param {string|number} intentLevel - 意向强度值
* @param {Array} intentLevelOptions - 意向强度选项数组可选格式: [{dictLabel: '', dictValue: ''}] [{label: '', value: ''}]
* @returns {string} 强度文本
*/
export const getIntentLevelText = (intentLevel) => {
export const getIntentLevelText = (intentLevel, intentLevelOptions = []) => {
if (!intentLevel) return '--';
// 如果提供了字典数据,优先从字典数据中查找
if (intentLevelOptions && intentLevelOptions.length > 0) {
const option = intentLevelOptions.find(item =>
String(item.dictValue || item.value) === String(intentLevel)
);
if (option) {
return option.dictLabel || option.label || '--';
}
}
// 否则使用静态映射
return INTENT_LEVEL_MAP[String(intentLevel)] || '--';
};
@ -128,3 +150,21 @@ export const getIntentLevelOptions = () => {
}));
};
/**
* 获取跟进方式文本从字典数据中查找
* @param {string|number} followType - 跟进方式值
* @param {Array} followTypeOptions - 跟进方式选项数组格式: [{dictLabel: '', dictValue: ''}] [{label: '', value: ''}]
* @returns {string} 跟进方式文本
*/
export const getFollowTypeText = (followType, followTypeOptions = []) => {
if (!followType) return '--';
if (!followTypeOptions || followTypeOptions.length === 0) {
return '--';
}
// 从字典数据中查找
const option = followTypeOptions.find(item =>
String(item.dictValue || item.value) === String(followType)
);
return option ? (option.dictLabel || option.label) : '--';
};