|
@@ -0,0 +1,435 @@
|
|
|
+/**
|
|
|
+ * 投诉管理相关常量定义
|
|
|
+ * @fileoverview 投诉人类型、投诉类型、投诉状态、回复状态等枚举值和工具函数
|
|
|
+ */
|
|
|
+
|
|
|
+/**
|
|
|
+ * 投诉人类型枚举
|
|
|
+ * @readonly
|
|
|
+ * @enum {number}
|
|
|
+ */
|
|
|
+export const COMPLAINANT_TYPE = {
|
|
|
+ /** 终端消费者 */
|
|
|
+ CONSUMER: 1,
|
|
|
+ /** 门店 */
|
|
|
+ STORE: 2,
|
|
|
+ /** 经销商 */
|
|
|
+ DEALER: 3
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 投诉类型枚举
|
|
|
+ * @readonly
|
|
|
+ * @enum {string}
|
|
|
+ */
|
|
|
+export const COMPLAINT_TYPE = {
|
|
|
+ /** 质量问题 */
|
|
|
+ QUALITY: '质量',
|
|
|
+ /** 物流问题 */
|
|
|
+ LOGISTICS: '物流',
|
|
|
+ /** 服务问题 */
|
|
|
+ SERVICE: '服务',
|
|
|
+ /** 价格问题 */
|
|
|
+ PRICE: '价格',
|
|
|
+ /** 其他问题 */
|
|
|
+ OTHER: '其他'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 投诉状态枚举
|
|
|
+ * @readonly
|
|
|
+ * @enum {number}
|
|
|
+ */
|
|
|
+export const COMPLAINT_STATUS = {
|
|
|
+ /** 待处理 */
|
|
|
+ PENDING: 0,
|
|
|
+ /** 处理中 */
|
|
|
+ PROCESSING: 1,
|
|
|
+ /** 已回复 */
|
|
|
+ REPLIED: 2,
|
|
|
+ /** 已关闭 */
|
|
|
+ CLOSED: 3,
|
|
|
+ /** 已撤销 */
|
|
|
+ CANCELLED: 4
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 回复状态枚举
|
|
|
+ * @readonly
|
|
|
+ * @enum {number}
|
|
|
+ */
|
|
|
+export const REPLY_STATUS = {
|
|
|
+ /** 未回复 */
|
|
|
+ NOT_REPLIED: 0,
|
|
|
+ /** 已回复 */
|
|
|
+ REPLIED: 1
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 投诉人类型配置映射
|
|
|
+ * @readonly
|
|
|
+ * @type {Record<number, {label: string, type: string, color: string}>}
|
|
|
+ */
|
|
|
+export const COMPLAINANT_TYPE_CONFIG = {
|
|
|
+ [COMPLAINANT_TYPE.CONSUMER]: {
|
|
|
+ label: '终端消费者',
|
|
|
+ type: 'primary',
|
|
|
+ color: '#409EFF'
|
|
|
+ },
|
|
|
+ [COMPLAINANT_TYPE.STORE]: {
|
|
|
+ label: '门店',
|
|
|
+ type: 'success',
|
|
|
+ color: '#67C23A'
|
|
|
+ },
|
|
|
+ [COMPLAINANT_TYPE.DEALER]: {
|
|
|
+ label: '经销商',
|
|
|
+ type: 'warning',
|
|
|
+ color: '#E6A23C'
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 投诉类型配置映射
|
|
|
+ * @readonly
|
|
|
+ * @type {Record<string, {label: string, type: string, color: string}>}
|
|
|
+ */
|
|
|
+export const COMPLAINT_TYPE_CONFIG = {
|
|
|
+ [COMPLAINT_TYPE.QUALITY]: {
|
|
|
+ label: '质量',
|
|
|
+ type: 'danger',
|
|
|
+ color: '#F56C6C'
|
|
|
+ },
|
|
|
+ [COMPLAINT_TYPE.LOGISTICS]: {
|
|
|
+ label: '物流',
|
|
|
+ type: 'warning',
|
|
|
+ color: '#E6A23C'
|
|
|
+ },
|
|
|
+ [COMPLAINT_TYPE.SERVICE]: {
|
|
|
+ label: '服务',
|
|
|
+ type: 'primary',
|
|
|
+ color: '#409EFF'
|
|
|
+ },
|
|
|
+ [COMPLAINT_TYPE.PRICE]: {
|
|
|
+ label: '价格',
|
|
|
+ type: 'info',
|
|
|
+ color: '#909399'
|
|
|
+ },
|
|
|
+ [COMPLAINT_TYPE.OTHER]: {
|
|
|
+ label: '其他',
|
|
|
+ type: 'info',
|
|
|
+ color: '#909399'
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 投诉状态配置映射
|
|
|
+ * @readonly
|
|
|
+ * @type {Record<number, {label: string, type: string, color: string}>}
|
|
|
+ */
|
|
|
+export const COMPLAINT_STATUS_CONFIG = {
|
|
|
+ [COMPLAINT_STATUS.PENDING]: {
|
|
|
+ label: '待处理',
|
|
|
+ type: 'warning',
|
|
|
+ color: '#E6A23C'
|
|
|
+ },
|
|
|
+ [COMPLAINT_STATUS.PROCESSING]: {
|
|
|
+ label: '处理中',
|
|
|
+ type: 'primary',
|
|
|
+ color: '#409EFF'
|
|
|
+ },
|
|
|
+ [COMPLAINT_STATUS.REPLIED]: {
|
|
|
+ label: '已回复',
|
|
|
+ type: 'success',
|
|
|
+ color: '#67C23A'
|
|
|
+ },
|
|
|
+ [COMPLAINT_STATUS.CLOSED]: {
|
|
|
+ label: '已关闭',
|
|
|
+ type: 'info',
|
|
|
+ color: '#909399'
|
|
|
+ },
|
|
|
+ [COMPLAINT_STATUS.CANCELLED]: {
|
|
|
+ label: '已撤销',
|
|
|
+ type: 'danger',
|
|
|
+ color: '#F56C6C'
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 回复状态配置映射
|
|
|
+ * @readonly
|
|
|
+ * @type {Record<number, {label: string, type: string, color: string}>}
|
|
|
+ */
|
|
|
+export const REPLY_STATUS_CONFIG = {
|
|
|
+ [REPLY_STATUS.NOT_REPLIED]: {
|
|
|
+ label: '未回复',
|
|
|
+ type: 'info',
|
|
|
+ color: '#909399'
|
|
|
+ },
|
|
|
+ [REPLY_STATUS.REPLIED]: {
|
|
|
+ label: '已回复',
|
|
|
+ type: 'success',
|
|
|
+ color: '#67C23A'
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 投诉人类型选项数据
|
|
|
+ * @readonly
|
|
|
+ * @type {Array<{label: string, value: number}>}
|
|
|
+ */
|
|
|
+export const COMPLAINANT_TYPE_OPTIONS = [
|
|
|
+ { label: '终端消费者', value: COMPLAINANT_TYPE.CONSUMER },
|
|
|
+ { label: '门店', value: COMPLAINANT_TYPE.STORE },
|
|
|
+ { label: '经销商', value: COMPLAINANT_TYPE.DEALER }
|
|
|
+]
|
|
|
+
|
|
|
+/**
|
|
|
+ * 投诉类型选项数据
|
|
|
+ * @readonly
|
|
|
+ * @type {Array<{label: string, value: string}>}
|
|
|
+ */
|
|
|
+export const COMPLAINT_TYPE_OPTIONS = [
|
|
|
+ { label: '质量', value: COMPLAINT_TYPE.QUALITY },
|
|
|
+ { label: '物流', value: COMPLAINT_TYPE.LOGISTICS },
|
|
|
+ { label: '服务', value: COMPLAINT_TYPE.SERVICE },
|
|
|
+ { label: '价格', value: COMPLAINT_TYPE.PRICE },
|
|
|
+ { label: '其他', value: COMPLAINT_TYPE.OTHER }
|
|
|
+]
|
|
|
+
|
|
|
+/**
|
|
|
+ * 投诉状态选项数据
|
|
|
+ * @readonly
|
|
|
+ * @type {Array<{label: string, value: number}>}
|
|
|
+ */
|
|
|
+export const COMPLAINT_STATUS_OPTIONS = [
|
|
|
+ { label: '待处理', value: COMPLAINT_STATUS.PENDING },
|
|
|
+ { label: '处理中', value: COMPLAINT_STATUS.PROCESSING },
|
|
|
+ { label: '已回复', value: COMPLAINT_STATUS.REPLIED },
|
|
|
+ { label: '已关闭', value: COMPLAINT_STATUS.CLOSED },
|
|
|
+ { label: '已撤销', value: COMPLAINT_STATUS.CANCELLED }
|
|
|
+]
|
|
|
+
|
|
|
+/**
|
|
|
+ * 回复状态选项数据
|
|
|
+ * @readonly
|
|
|
+ * @type {Array<{label: string, value: number}>}
|
|
|
+ */
|
|
|
+export const REPLY_STATUS_OPTIONS = [
|
|
|
+ { label: '未回复', value: REPLY_STATUS.NOT_REPLIED },
|
|
|
+ { label: '已回复', value: REPLY_STATUS.REPLIED }
|
|
|
+]
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取投诉人类型标签
|
|
|
+ * @param {number} complainantType - 投诉人类型值
|
|
|
+ * @returns {string} 投诉人类型标签
|
|
|
+ */
|
|
|
+export function getComplainantTypeLabel(complainantType) {
|
|
|
+ const config = COMPLAINANT_TYPE_CONFIG[complainantType]
|
|
|
+ return config ? config.label : '未知类型'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取投诉人类型Element UI标签类型
|
|
|
+ * @param {number} complainantType - 投诉人类型值
|
|
|
+ * @returns {string} Element UI标签类型
|
|
|
+ */
|
|
|
+export function getComplainantTypeType(complainantType) {
|
|
|
+ const config = COMPLAINANT_TYPE_CONFIG[complainantType]
|
|
|
+ return config ? config.type : 'info'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取投诉人类型颜色
|
|
|
+ * @param {number} complainantType - 投诉人类型值
|
|
|
+ * @returns {string} 十六进制颜色值
|
|
|
+ */
|
|
|
+export function getComplainantTypeColor(complainantType) {
|
|
|
+ const config = COMPLAINANT_TYPE_CONFIG[complainantType]
|
|
|
+ return config ? config.color : '#909399'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取投诉类型标签
|
|
|
+ * @param {string} complaintType - 投诉类型值
|
|
|
+ * @returns {string} 投诉类型标签
|
|
|
+ */
|
|
|
+export function getComplaintTypeLabel(complaintType) {
|
|
|
+ const config = COMPLAINT_TYPE_CONFIG[complaintType]
|
|
|
+ return config ? config.label : '未知类型'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取投诉类型Element UI标签类型
|
|
|
+ * @param {string} complaintType - 投诉类型值
|
|
|
+ * @returns {string} Element UI标签类型
|
|
|
+ */
|
|
|
+export function getComplaintTypeType(complaintType) {
|
|
|
+ const config = COMPLAINT_TYPE_CONFIG[complaintType]
|
|
|
+ return config ? config.type : 'info'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取投诉类型颜色
|
|
|
+ * @param {string} complaintType - 投诉类型值
|
|
|
+ * @returns {string} 十六进制颜色值
|
|
|
+ */
|
|
|
+export function getComplaintTypeColor(complaintType) {
|
|
|
+ const config = COMPLAINT_TYPE_CONFIG[complaintType]
|
|
|
+ return config ? config.color : '#909399'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取投诉状态标签
|
|
|
+ * @param {number} status - 投诉状态值
|
|
|
+ * @returns {string} 投诉状态标签
|
|
|
+ */
|
|
|
+export function getComplaintStatusLabel(status) {
|
|
|
+ const config = COMPLAINT_STATUS_CONFIG[status]
|
|
|
+ return config ? config.label : '未知状态'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取投诉状态Element UI标签类型
|
|
|
+ * @param {number} status - 投诉状态值
|
|
|
+ * @returns {string} Element UI标签类型
|
|
|
+ */
|
|
|
+export function getComplaintStatusType(status) {
|
|
|
+ const config = COMPLAINT_STATUS_CONFIG[status]
|
|
|
+ return config ? config.type : 'info'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取投诉状态颜色
|
|
|
+ * @param {number} status - 投诉状态值
|
|
|
+ * @returns {string} 十六进制颜色值
|
|
|
+ */
|
|
|
+export function getComplaintStatusColor(status) {
|
|
|
+ const config = COMPLAINT_STATUS_CONFIG[status]
|
|
|
+ return config ? config.color : '#909399'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取回复状态标签
|
|
|
+ * @param {number} replyStatus - 回复状态值
|
|
|
+ * @returns {string} 回复状态标签
|
|
|
+ */
|
|
|
+export function getReplyStatusLabel(replyStatus) {
|
|
|
+ const config = REPLY_STATUS_CONFIG[replyStatus]
|
|
|
+ return config ? config.label : '未知状态'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取回复状态Element UI标签类型
|
|
|
+ * @param {number} replyStatus - 回复状态值
|
|
|
+ * @returns {string} Element UI标签类型
|
|
|
+ */
|
|
|
+export function getReplyStatusType(replyStatus) {
|
|
|
+ const config = REPLY_STATUS_CONFIG[replyStatus]
|
|
|
+ return config ? config.type : 'info'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取回复状态颜色
|
|
|
+ * @param {number} replyStatus - 回复状态值
|
|
|
+ * @returns {string} 十六进制颜色值
|
|
|
+ */
|
|
|
+export function getReplyStatusColor(replyStatus) {
|
|
|
+ const config = REPLY_STATUS_CONFIG[replyStatus]
|
|
|
+ return config ? config.color : '#909399'
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 验证投诉人类型是否有效
|
|
|
+ * @param {number} complainantType - 投诉人类型值
|
|
|
+ * @returns {boolean} 是否为有效投诉人类型
|
|
|
+ */
|
|
|
+export function isValidComplainantType(complainantType) {
|
|
|
+ return Object.values(COMPLAINANT_TYPE).includes(complainantType)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 验证投诉类型是否有效
|
|
|
+ * @param {string} complaintType - 投诉类型值
|
|
|
+ * @returns {boolean} 是否为有效投诉类型
|
|
|
+ */
|
|
|
+export function isValidComplaintType(complaintType) {
|
|
|
+ return Object.values(COMPLAINT_TYPE).includes(complaintType)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 验证投诉状态是否有效
|
|
|
+ * @param {number} status - 投诉状态值
|
|
|
+ * @returns {boolean} 是否为有效投诉状态
|
|
|
+ */
|
|
|
+export function isValidComplaintStatus(status) {
|
|
|
+ return Object.values(COMPLAINT_STATUS).includes(status)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 验证回复状态是否有效
|
|
|
+ * @param {number} replyStatus - 回复状态值
|
|
|
+ * @returns {boolean} 是否为有效回复状态
|
|
|
+ */
|
|
|
+export function isValidReplyStatus(replyStatus) {
|
|
|
+ return Object.values(REPLY_STATUS).includes(replyStatus)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取所有投诉人类型值
|
|
|
+ * @returns {Array<number>} 投诉人类型值数组
|
|
|
+ */
|
|
|
+export function getAllComplainantTypeValues() {
|
|
|
+ return Object.values(COMPLAINANT_TYPE)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取所有投诉类型值
|
|
|
+ * @returns {Array<string>} 投诉类型值数组
|
|
|
+ */
|
|
|
+export function getAllComplaintTypeValues() {
|
|
|
+ return Object.values(COMPLAINT_TYPE)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取所有投诉状态值
|
|
|
+ * @returns {Array<number>} 投诉状态值数组
|
|
|
+ */
|
|
|
+export function getAllComplaintStatusValues() {
|
|
|
+ return Object.values(COMPLAINT_STATUS)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 获取所有回复状态值
|
|
|
+ * @returns {Array<number>} 回复状态值数组
|
|
|
+ */
|
|
|
+export function getAllReplyStatusValues() {
|
|
|
+ return Object.values(REPLY_STATUS)
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断投诉状态是否可以编辑
|
|
|
+ * @param {number} status - 投诉状态值
|
|
|
+ * @returns {boolean} 是否可以编辑
|
|
|
+ */
|
|
|
+export function isComplaintEditable(status) {
|
|
|
+ return status !== COMPLAINT_STATUS.CANCELLED && status !== COMPLAINT_STATUS.CLOSED
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断投诉状态是否可以处理
|
|
|
+ * @param {number} status - 投诉状态值
|
|
|
+ * @returns {boolean} 是否可以处理
|
|
|
+ */
|
|
|
+export function isComplaintProcessable(status) {
|
|
|
+ return status === COMPLAINT_STATUS.PROCESSING
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * 判断投诉状态是否可以关闭
|
|
|
+ * @param {number} status - 投诉状态值
|
|
|
+ * @returns {boolean} 是否可以关闭
|
|
|
+ */
|
|
|
+export function isComplaintClosable(status) {
|
|
|
+ return status !== COMPLAINT_STATUS.CANCELLED && status !== COMPLAINT_STATUS.CLOSED
|
|
|
+}
|