complaint.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. /**
  2. * 投诉管理相关常量定义
  3. * @fileoverview 投诉人类型、投诉类型、投诉状态、回复状态等枚举值和工具函数
  4. */
  5. /**
  6. * 投诉人类型枚举
  7. * @readonly
  8. * @enum {number}
  9. */
  10. export const COMPLAINANT_TYPE = {
  11. /** 终端消费者 */
  12. CONSUMER: 1,
  13. /** 门店 */
  14. STORE: 2,
  15. /** 经销商 */
  16. DEALER: 3
  17. }
  18. /**
  19. * 投诉类型枚举
  20. * @readonly
  21. * @enum {string}
  22. */
  23. export const COMPLAINT_TYPE = {
  24. /** 质量问题 */
  25. QUALITY: '质量',
  26. /** 物流问题 */
  27. LOGISTICS: '物流',
  28. /** 服务问题 */
  29. SERVICE: '服务',
  30. /** 价格问题 */
  31. PRICE: '价格',
  32. /** 其他问题 */
  33. OTHER: '其他'
  34. }
  35. /**
  36. * 投诉状态枚举
  37. * @readonly
  38. * @enum {number}
  39. */
  40. export const COMPLAINT_STATUS = {
  41. /** 待处理 */
  42. PENDING: 0,
  43. /** 处理中 */
  44. PROCESSING: 1,
  45. /** 已回复 */
  46. REPLIED: 2,
  47. /** 已关闭 */
  48. CLOSED: 3,
  49. /** 已撤销 */
  50. CANCELLED: 4
  51. }
  52. /**
  53. * 回复状态枚举
  54. * @readonly
  55. * @enum {number}
  56. */
  57. export const REPLY_STATUS = {
  58. /** 未回复 */
  59. NOT_REPLIED: 0,
  60. /** 已回复 */
  61. REPLIED: 1
  62. }
  63. /**
  64. * 回复类型枚举
  65. * @readonly
  66. * @enum {number}
  67. */
  68. export const REPLY_TYPE = {
  69. /** 系统回复 */
  70. SYSTEM: 1,
  71. /** 客户反馈 */
  72. CUSTOMER: 2,
  73. /** 申诉 */
  74. APPEAL: 3
  75. }
  76. /**
  77. * 投诉人类型配置映射
  78. * @readonly
  79. * @type {Record<number, {label: string, type: string, color: string}>}
  80. */
  81. export const COMPLAINANT_TYPE_CONFIG = {
  82. [COMPLAINANT_TYPE.CONSUMER]: {
  83. label: '终端消费者',
  84. type: 'primary',
  85. color: '#409EFF'
  86. },
  87. [COMPLAINANT_TYPE.STORE]: {
  88. label: '门店',
  89. type: 'success',
  90. color: '#67C23A'
  91. },
  92. [COMPLAINANT_TYPE.DEALER]: {
  93. label: '经销商',
  94. type: 'warning',
  95. color: '#E6A23C'
  96. }
  97. }
  98. /**
  99. * 投诉类型配置映射
  100. * @readonly
  101. * @type {Record<string, {label: string, type: string, color: string}>}
  102. */
  103. export const COMPLAINT_TYPE_CONFIG = {
  104. [COMPLAINT_TYPE.QUALITY]: {
  105. label: '质量',
  106. type: 'danger',
  107. color: '#F56C6C'
  108. },
  109. [COMPLAINT_TYPE.LOGISTICS]: {
  110. label: '物流',
  111. type: 'warning',
  112. color: '#E6A23C'
  113. },
  114. [COMPLAINT_TYPE.SERVICE]: {
  115. label: '服务',
  116. type: 'primary',
  117. color: '#409EFF'
  118. },
  119. [COMPLAINT_TYPE.PRICE]: {
  120. label: '价格',
  121. type: 'info',
  122. color: '#909399'
  123. },
  124. [COMPLAINT_TYPE.OTHER]: {
  125. label: '其他',
  126. type: 'info',
  127. color: '#909399'
  128. }
  129. }
  130. /**
  131. * 投诉状态配置映射
  132. * @readonly
  133. * @type {Record<number, {label: string, type: string, color: string}>}
  134. */
  135. export const COMPLAINT_STATUS_CONFIG = {
  136. [COMPLAINT_STATUS.PENDING]: {
  137. label: '待处理',
  138. type: 'warning',
  139. color: '#E6A23C'
  140. },
  141. [COMPLAINT_STATUS.PROCESSING]: {
  142. label: '处理中',
  143. type: 'primary',
  144. color: '#409EFF'
  145. },
  146. [COMPLAINT_STATUS.REPLIED]: {
  147. label: '已回复',
  148. type: 'success',
  149. color: '#67C23A'
  150. },
  151. [COMPLAINT_STATUS.CLOSED]: {
  152. label: '已关闭',
  153. type: 'info',
  154. color: '#909399'
  155. },
  156. [COMPLAINT_STATUS.CANCELLED]: {
  157. label: '已撤销',
  158. type: 'danger',
  159. color: '#F56C6C'
  160. }
  161. }
  162. /**
  163. * 回复状态配置映射
  164. * @readonly
  165. * @type {Record<number, {label: string, type: string, color: string}>}
  166. */
  167. export const REPLY_STATUS_CONFIG = {
  168. [REPLY_STATUS.NOT_REPLIED]: {
  169. label: '未回复',
  170. type: 'info',
  171. color: '#909399'
  172. },
  173. [REPLY_STATUS.REPLIED]: {
  174. label: '已回复',
  175. type: 'success',
  176. color: '#67C23A'
  177. }
  178. }
  179. /**
  180. * 回复类型配置映射
  181. * @readonly
  182. * @type {Record<number, {label: string, type: string, color: string}>}
  183. */
  184. export const REPLY_TYPE_CONFIG = {
  185. [REPLY_TYPE.SYSTEM]: {
  186. label: '系统回复',
  187. type: 'primary',
  188. color: '#409EFF'
  189. },
  190. [REPLY_TYPE.CUSTOMER]: {
  191. label: '客户反馈',
  192. type: 'success',
  193. color: '#67C23A'
  194. },
  195. [REPLY_TYPE.APPEAL]: {
  196. label: '申诉',
  197. type: 'warning',
  198. color: '#E6A23C'
  199. }
  200. }
  201. /**
  202. * 投诉人类型选项数据
  203. * @readonly
  204. * @type {Array<{label: string, value: number}>}
  205. */
  206. export const COMPLAINANT_TYPE_OPTIONS = [
  207. { label: '终端消费者', value: COMPLAINANT_TYPE.CONSUMER },
  208. { label: '门店', value: COMPLAINANT_TYPE.STORE },
  209. { label: '经销商', value: COMPLAINANT_TYPE.DEALER }
  210. ]
  211. /**
  212. * 投诉类型选项数据
  213. * @readonly
  214. * @type {Array<{label: string, value: string}>}
  215. */
  216. export const COMPLAINT_TYPE_OPTIONS = [
  217. { label: '质量', value: COMPLAINT_TYPE.QUALITY },
  218. { label: '物流', value: COMPLAINT_TYPE.LOGISTICS },
  219. { label: '服务', value: COMPLAINT_TYPE.SERVICE },
  220. { label: '价格', value: COMPLAINT_TYPE.PRICE },
  221. { label: '其他', value: COMPLAINT_TYPE.OTHER }
  222. ]
  223. /**
  224. * 投诉状态选项数据
  225. * @readonly
  226. * @type {Array<{label: string, value: number}>}
  227. */
  228. export const COMPLAINT_STATUS_OPTIONS = [
  229. { label: '待处理', value: COMPLAINT_STATUS.PENDING },
  230. { label: '处理中', value: COMPLAINT_STATUS.PROCESSING },
  231. { label: '已回复', value: COMPLAINT_STATUS.REPLIED },
  232. { label: '已关闭', value: COMPLAINT_STATUS.CLOSED },
  233. { label: '已撤销', value: COMPLAINT_STATUS.CANCELLED }
  234. ]
  235. /**
  236. * 回复状态选项数据
  237. * @readonly
  238. * @type {Array<{label: string, value: number}>}
  239. */
  240. export const REPLY_STATUS_OPTIONS = [
  241. { label: '未回复', value: REPLY_STATUS.NOT_REPLIED },
  242. { label: '已回复', value: REPLY_STATUS.REPLIED }
  243. ]
  244. /**
  245. * 回复类型选项数据
  246. * @readonly
  247. * @type {Array<{label: string, value: number}>}
  248. */
  249. export const REPLY_TYPE_OPTIONS = [
  250. { label: '系统回复', value: REPLY_TYPE.SYSTEM },
  251. { label: '客户反馈', value: REPLY_TYPE.CUSTOMER },
  252. { label: '申诉', value: REPLY_TYPE.APPEAL }
  253. ]
  254. /**
  255. * 获取投诉人类型标签
  256. * @param {number} complainantType - 投诉人类型值
  257. * @returns {string} 投诉人类型标签
  258. */
  259. export function getComplainantTypeLabel(complainantType) {
  260. const config = COMPLAINANT_TYPE_CONFIG[complainantType]
  261. return config ? config.label : '未知类型'
  262. }
  263. /**
  264. * 获取投诉人类型Element UI标签类型
  265. * @param {number} complainantType - 投诉人类型值
  266. * @returns {string} Element UI标签类型
  267. */
  268. export function getComplainantTypeType(complainantType) {
  269. const config = COMPLAINANT_TYPE_CONFIG[complainantType]
  270. return config ? config.type : 'info'
  271. }
  272. /**
  273. * 获取投诉人类型颜色
  274. * @param {number} complainantType - 投诉人类型值
  275. * @returns {string} 十六进制颜色值
  276. */
  277. export function getComplainantTypeColor(complainantType) {
  278. const config = COMPLAINANT_TYPE_CONFIG[complainantType]
  279. return config ? config.color : '#909399'
  280. }
  281. /**
  282. * 获取投诉类型标签
  283. * @param {string} complaintType - 投诉类型值
  284. * @returns {string} 投诉类型标签
  285. */
  286. export function getComplaintTypeLabel(complaintType) {
  287. const config = COMPLAINT_TYPE_CONFIG[complaintType]
  288. return config ? config.label : '未知类型'
  289. }
  290. /**
  291. * 获取投诉类型Element UI标签类型
  292. * @param {string} complaintType - 投诉类型值
  293. * @returns {string} Element UI标签类型
  294. */
  295. export function getComplaintTypeType(complaintType) {
  296. const config = COMPLAINT_TYPE_CONFIG[complaintType]
  297. return config ? config.type : 'info'
  298. }
  299. /**
  300. * 获取投诉类型颜色
  301. * @param {string} complaintType - 投诉类型值
  302. * @returns {string} 十六进制颜色值
  303. */
  304. export function getComplaintTypeColor(complaintType) {
  305. const config = COMPLAINT_TYPE_CONFIG[complaintType]
  306. return config ? config.color : '#909399'
  307. }
  308. /**
  309. * 获取投诉状态标签
  310. * @param {number} status - 投诉状态值
  311. * @returns {string} 投诉状态标签
  312. */
  313. export function getComplaintStatusLabel(status) {
  314. const config = COMPLAINT_STATUS_CONFIG[status]
  315. return config ? config.label : '未知状态'
  316. }
  317. /**
  318. * 获取投诉状态Element UI标签类型
  319. * @param {number} status - 投诉状态值
  320. * @returns {string} Element UI标签类型
  321. */
  322. export function getComplaintStatusType(status) {
  323. const config = COMPLAINT_STATUS_CONFIG[status]
  324. return config ? config.type : 'info'
  325. }
  326. /**
  327. * 获取投诉状态颜色
  328. * @param {number} status - 投诉状态值
  329. * @returns {string} 十六进制颜色值
  330. */
  331. export function getComplaintStatusColor(status) {
  332. const config = COMPLAINT_STATUS_CONFIG[status]
  333. return config ? config.color : '#909399'
  334. }
  335. /**
  336. * 获取回复状态标签
  337. * @param {number} replyStatus - 回复状态值
  338. * @returns {string} 回复状态标签
  339. */
  340. export function getReplyStatusLabel(replyStatus) {
  341. const config = REPLY_STATUS_CONFIG[replyStatus]
  342. return config ? config.label : '未知状态'
  343. }
  344. /**
  345. * 获取回复状态Element UI标签类型
  346. * @param {number} replyStatus - 回复状态值
  347. * @returns {string} Element UI标签类型
  348. */
  349. export function getReplyStatusType(replyStatus) {
  350. const config = REPLY_STATUS_CONFIG[replyStatus]
  351. return config ? config.type : 'info'
  352. }
  353. /**
  354. * 获取回复状态颜色
  355. * @param {number} replyStatus - 回复状态值
  356. * @returns {string} 十六进制颜色值
  357. */
  358. export function getReplyStatusColor(replyStatus) {
  359. const config = REPLY_STATUS_CONFIG[replyStatus]
  360. return config ? config.color : '#909399'
  361. }
  362. /**
  363. * 验证投诉人类型是否有效
  364. * @param {number} complainantType - 投诉人类型值
  365. * @returns {boolean} 是否为有效投诉人类型
  366. */
  367. export function isValidComplainantType(complainantType) {
  368. return Object.values(COMPLAINANT_TYPE).includes(complainantType)
  369. }
  370. /**
  371. * 验证投诉类型是否有效
  372. * @param {string} complaintType - 投诉类型值
  373. * @returns {boolean} 是否为有效投诉类型
  374. */
  375. export function isValidComplaintType(complaintType) {
  376. return Object.values(COMPLAINT_TYPE).includes(complaintType)
  377. }
  378. /**
  379. * 验证投诉状态是否有效
  380. * @param {number} status - 投诉状态值
  381. * @returns {boolean} 是否为有效投诉状态
  382. */
  383. export function isValidComplaintStatus(status) {
  384. return Object.values(COMPLAINT_STATUS).includes(status)
  385. }
  386. /**
  387. * 验证回复状态是否有效
  388. * @param {number} replyStatus - 回复状态值
  389. * @returns {boolean} 是否为有效回复状态
  390. */
  391. export function isValidReplyStatus(replyStatus) {
  392. return Object.values(REPLY_STATUS).includes(replyStatus)
  393. }
  394. /**
  395. * 获取所有投诉人类型值
  396. * @returns {Array<number>} 投诉人类型值数组
  397. */
  398. export function getAllComplainantTypeValues() {
  399. return Object.values(COMPLAINANT_TYPE)
  400. }
  401. /**
  402. * 获取所有投诉类型值
  403. * @returns {Array<string>} 投诉类型值数组
  404. */
  405. export function getAllComplaintTypeValues() {
  406. return Object.values(COMPLAINT_TYPE)
  407. }
  408. /**
  409. * 获取所有投诉状态值
  410. * @returns {Array<number>} 投诉状态值数组
  411. */
  412. export function getAllComplaintStatusValues() {
  413. return Object.values(COMPLAINT_STATUS)
  414. }
  415. /**
  416. * 获取回复类型标签
  417. * @param {number} replyType - 回复类型值
  418. * @returns {string} 回复类型标签
  419. */
  420. export function getReplyTypeLabel(replyType) {
  421. const config = REPLY_TYPE_CONFIG[replyType]
  422. return config ? config.label : '未知类型'
  423. }
  424. /**
  425. * 获取回复类型Element UI标签类型
  426. * @param {number} replyType - 回复类型值
  427. * @returns {string} Element UI标签类型
  428. */
  429. export function getReplyTypeType(replyType) {
  430. const config = REPLY_TYPE_CONFIG[replyType]
  431. return config ? config.type : 'info'
  432. }
  433. /**
  434. * 获取回复类型颜色
  435. * @param {number} replyType - 回复类型值
  436. * @returns {string} 十六进制颜色值
  437. */
  438. export function getReplyTypeColor(replyType) {
  439. const config = REPLY_TYPE_CONFIG[replyType]
  440. return config ? config.color : '#909399'
  441. }
  442. /**
  443. * 获取所有回复类型值
  444. * @returns {Array<number>} 回复类型值数组
  445. */
  446. export function getAllReplyTypeValues() {
  447. return Object.values(REPLY_TYPE)
  448. }
  449. /**
  450. * 获取所有回复状态值
  451. * @returns {Array<number>} 回复状态值数组
  452. */
  453. export function getAllReplyStatusValues() {
  454. return Object.values(REPLY_STATUS)
  455. }
  456. /**
  457. * 判断投诉状态是否可以编辑
  458. * @param {number} status - 投诉状态值
  459. * @returns {boolean} 是否可以编辑
  460. */
  461. export function isComplaintEditable(status) {
  462. return status !== COMPLAINT_STATUS.CANCELLED && status !== COMPLAINT_STATUS.CLOSED
  463. }
  464. /**
  465. * 判断投诉状态是否可以处理
  466. * @param {number} status - 投诉状态值
  467. * @returns {boolean} 是否可以处理
  468. */
  469. export function isComplaintProcessable(status) {
  470. return status === COMPLAINT_STATUS.PROCESSING
  471. }
  472. /**
  473. * 判断投诉状态是否可以关闭
  474. * @param {number} status - 投诉状态值
  475. * @returns {boolean} 是否可以关闭
  476. */
  477. export function isComplaintClosable(status) {
  478. return status !== COMPLAINT_STATUS.CANCELLED && status !== COMPLAINT_STATUS.CLOSED
  479. }