|
@@ -0,0 +1,250 @@
|
|
|
+/**
|
|
|
+ * 销售线索管理相关常量定义
|
|
|
+ * @fileoverview 销售线索优先级、状态等枚举值和工具函数
|
|
|
+ */
|
|
|
+
|
|
|
+/**
|
|
|
+ * 线索优先级枚举
|
|
|
+ * @readonly
|
|
|
+ * @enum {number}
|
|
|
+ */
|
|
|
+export const LEAD_PRIORITY = {
|
|
|
+ /** 低优先级 */
|
|
|
+ LOW: 1,
|
|
|
+ /** 中优先级 */
|
|
|
+ MEDIUM: 2,
|
|
|
+ /** 高优先级 */
|
|
|
+ HIGH: 3
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 线索状态枚举
|
|
|
+ * @readonly
|
|
|
+ * @enum {number}
|
|
|
+ */
|
|
|
+export const LEAD_STATUS = {
|
|
|
+ /** 待处理 */
|
|
|
+ PENDING: 0,
|
|
|
+ /** 跟进中 */
|
|
|
+ FOLLOWING: 1,
|
|
|
+ /** 已转化 */
|
|
|
+ CONVERTED: 2,
|
|
|
+ /** 已关闭 */
|
|
|
+ CLOSED: 3
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 线索优先级配置映射
|
|
|
+ * @readonly
|
|
|
+ * @type {Record<number, {label: string, type: string, color: string}>}
|
|
|
+ */
|
|
|
+export const LEAD_PRIORITY_CONFIG = {
|
|
|
+ [LEAD_PRIORITY.LOW]: {
|
|
|
+ label: '低',
|
|
|
+ type: 'success',
|
|
|
+ color: '#67C23A'
|
|
|
+ },
|
|
|
+ [LEAD_PRIORITY.MEDIUM]: {
|
|
|
+ label: '中',
|
|
|
+ type: 'warning',
|
|
|
+ color: '#E6A23C'
|
|
|
+ },
|
|
|
+ [LEAD_PRIORITY.HIGH]: {
|
|
|
+ label: '高',
|
|
|
+ type: 'danger',
|
|
|
+ color: '#F56C6C'
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 线索状态配置映射
|
|
|
+ * @readonly
|
|
|
+ * @type {Record<number, {label: string, type: string, color: string}>}
|
|
|
+ */
|
|
|
+export const LEAD_STATUS_CONFIG = {
|
|
|
+ [LEAD_STATUS.PENDING]: {
|
|
|
+ label: '待处理',
|
|
|
+ type: 'info',
|
|
|
+ color: '#909399'
|
|
|
+ },
|
|
|
+ [LEAD_STATUS.FOLLOWING]: {
|
|
|
+ label: '跟进中',
|
|
|
+ type: 'warning',
|
|
|
+ color: '#E6A23C'
|
|
|
+ },
|
|
|
+ [LEAD_STATUS.CONVERTED]: {
|
|
|
+ label: '已转化',
|
|
|
+ type: 'success',
|
|
|
+ color: '#67C23A'
|
|
|
+ },
|
|
|
+ [LEAD_STATUS.CLOSED]: {
|
|
|
+ label: '已关闭',
|
|
|
+ type: 'info',
|
|
|
+ color: '#909399'
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 线索优先级选项数据
|
|
|
+ * @readonly
|
|
|
+ * @type {Array<{label: string, value: number}>}
|
|
|
+ */
|
|
|
+export const LEAD_PRIORITY_OPTIONS = [
|
|
|
+ { label: '低', value: LEAD_PRIORITY.LOW },
|
|
|
+ { label: '中', value: LEAD_PRIORITY.MEDIUM },
|
|
|
+ { label: '高', value: LEAD_PRIORITY.HIGH }
|
|
|
+]
|
|
|
+
|
|
|
+/**
|
|
|
+ * 线索状态选项数据
|
|
|
+ * @readonly
|
|
|
+ * @type {Array<{label: string, value: number}>}
|
|
|
+ */
|
|
|
+export const LEAD_STATUS_OPTIONS = [
|
|
|
+ { label: '待处理', value: LEAD_STATUS.PENDING },
|
|
|
+ { label: '跟进中', value: LEAD_STATUS.FOLLOWING },
|
|
|
+ { label: '已转化', value: LEAD_STATUS.CONVERTED },
|
|
|
+ { label: '已关闭', value: LEAD_STATUS.CLOSED }
|
|
|
+]
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取线索优先级标签
|
|
|
+ * @param {number} priority - 优先级值
|
|
|
+ * @returns {string} 优先级标签
|
|
|
+ */
|
|
|
+export function getLeadPriorityLabel(priority) {
|
|
|
+ return (LEAD_PRIORITY_CONFIG[priority] && LEAD_PRIORITY_CONFIG[priority].label) || '未知优先级'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取线索优先级标签类型
|
|
|
+ * @param {number} priority - 优先级值
|
|
|
+ * @returns {string} Element UI标签类型
|
|
|
+ */
|
|
|
+export function getLeadPriorityType(priority) {
|
|
|
+ return (LEAD_PRIORITY_CONFIG[priority] && LEAD_PRIORITY_CONFIG[priority].type) || 'info'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取线索优先级颜色
|
|
|
+ * @param {number} priority - 优先级值
|
|
|
+ * @returns {string} 颜色值
|
|
|
+ */
|
|
|
+export function getLeadPriorityColor(priority) {
|
|
|
+ return (LEAD_PRIORITY_CONFIG[priority] && LEAD_PRIORITY_CONFIG[priority].color) || '#909399'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取线索状态标签
|
|
|
+ * @param {number} status - 状态值
|
|
|
+ * @returns {string} 状态标签
|
|
|
+ */
|
|
|
+export function getLeadStatusLabel(status) {
|
|
|
+ return (LEAD_STATUS_CONFIG[status] && LEAD_STATUS_CONFIG[status].label) || '未知状态'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取线索状态标签类型
|
|
|
+ * @param {number} status - 状态值
|
|
|
+ * @returns {string} Element UI标签类型
|
|
|
+ */
|
|
|
+export function getLeadStatusType(status) {
|
|
|
+ return (LEAD_STATUS_CONFIG[status] && LEAD_STATUS_CONFIG[status].type) || 'info'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取线索状态颜色
|
|
|
+ * @param {number} status - 状态值
|
|
|
+ * @returns {string} 颜色值
|
|
|
+ */
|
|
|
+export function getLeadStatusColor(status) {
|
|
|
+ return (LEAD_STATUS_CONFIG[status] && LEAD_STATUS_CONFIG[status].color) || '#909399'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 验证线索优先级值是否有效
|
|
|
+ * @param {number} priority - 优先级值
|
|
|
+ * @returns {boolean} 是否有效
|
|
|
+ */
|
|
|
+export function isValidLeadPriority(priority) {
|
|
|
+ return Object.values(LEAD_PRIORITY).includes(priority)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 验证线索状态值是否有效
|
|
|
+ * @param {number} status - 状态值
|
|
|
+ * @returns {boolean} 是否有效
|
|
|
+ */
|
|
|
+export function isValidLeadStatus(status) {
|
|
|
+ return Object.values(LEAD_STATUS).includes(status)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断是否为高优先级线索
|
|
|
+ * @param {number} priority - 优先级值
|
|
|
+ * @returns {boolean} 是否为高优先级
|
|
|
+ */
|
|
|
+export function isHighPriorityLead(priority) {
|
|
|
+ return priority === LEAD_PRIORITY.HIGH
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断是否为低优先级线索
|
|
|
+ * @param {number} priority - 优先级值
|
|
|
+ * @returns {boolean} 是否为低优先级
|
|
|
+ */
|
|
|
+export function isLowPriorityLead(priority) {
|
|
|
+ return priority === LEAD_PRIORITY.LOW
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断线索是否可以编辑
|
|
|
+ * @param {number} status - 状态值
|
|
|
+ * @returns {boolean} 是否可以编辑
|
|
|
+ */
|
|
|
+export function isLeadEditable(status) {
|
|
|
+ return status !== LEAD_STATUS.CLOSED
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断线索是否可以转化
|
|
|
+ * @param {number} status - 状态值
|
|
|
+ * @returns {boolean} 是否可以转化
|
|
|
+ */
|
|
|
+export function isLeadConvertible(status) {
|
|
|
+ return status === LEAD_STATUS.FOLLOWING
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断线索是否已完成(转化或关闭)
|
|
|
+ * @param {number} status - 状态值
|
|
|
+ * @returns {boolean} 是否已完成
|
|
|
+ */
|
|
|
+export function isLeadCompleted(status) {
|
|
|
+ return status === LEAD_STATUS.CONVERTED || status === LEAD_STATUS.CLOSED
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断线索是否处于活跃状态(待处理或跟进中)
|
|
|
+ * @param {number} status - 状态值
|
|
|
+ * @returns {boolean} 是否处于活跃状态
|
|
|
+ */
|
|
|
+export function isLeadActive(status) {
|
|
|
+ return status === LEAD_STATUS.PENDING || status === LEAD_STATUS.FOLLOWING
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取所有线索优先级值
|
|
|
+ * @returns {Array<number>} 所有优先级值
|
|
|
+ */
|
|
|
+export function getAllLeadPriorityValues() {
|
|
|
+ return Object.values(LEAD_PRIORITY)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取所有线索状态值
|
|
|
+ * @returns {Array<number>} 所有状态值
|
|
|
+ */
|
|
|
+export function getAllLeadStatusValues() {
|
|
|
+ return Object.values(LEAD_STATUS)
|
|
|
+}
|