客户属性映射文件

This commit is contained in:
WindowBird 2025-11-11 11:19:52 +08:00
parent eedd39ab9e
commit e29c26c88b
5 changed files with 165 additions and 128 deletions

View File

@ -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 {

View File

@ -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>

View File

@ -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 = () => {

View File

@ -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
View 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
}));
};