A8000
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.5 KiB

8 months ago
  1. // 错误码映射表
  2. const ERROR_MAP = {
  3. PASS: '通过',
  4. EMPTY: '空',
  5. EXPIRED: '转材过期',
  6. MISS_REACTION_PLATE: '没有反应板架',
  7. MISS_LITTSB: '缺少小缓冲液',
  8. MISS_LARBS: '缺少大缓冲液',
  9. MISS_IDCARD: '未找到匹配的项目ID卡',
  10. LITTSB_LOTID_MISMATCH: '小缓冲液批号不匹配',
  11. LARBS_LOTID_MISMATCH: '大缓冲液批号不匹配',
  12. CODE_ERROR_PROJINFO_IS_ERROR: '代码错误,项目信息异常',
  13. UN_SUPPORT_PROJ: '不支持的项目',
  14. REACTION_PLATE_2D_CODE_FORMATE_ERROR: '反应板二维码格式错误',
  15. } as const
  16. type ErrorCode = keyof typeof ERROR_MAP
  17. /**
  18. *
  19. * @param code
  20. * @returns
  21. */
  22. export const getErrorMessage = (code: ErrorCode): string => {
  23. return ERROR_MAP[code as ErrorCode] || '未知错误'
  24. }
  25. /**
  26. *
  27. * @param code
  28. * @returns
  29. */
  30. export const isError = (code: ErrorCode): boolean => {
  31. return code !== 'PASS'
  32. }
  33. /**
  34. *
  35. * @param reports
  36. * @returns
  37. */
  38. export const formatScanReports = (
  39. reports: Array<{
  40. chNum: number
  41. state: string
  42. projId: number
  43. lotId: string
  44. projName: string
  45. projShortName: string
  46. }>,
  47. ) => {
  48. return reports.map((item) => ({
  49. channel: item.chNum,
  50. code: item.state,
  51. message: getErrorMessage(item.state as ErrorCode),
  52. isError: isError(item.state as ErrorCode),
  53. projName: item.projName,
  54. lotId: item.lotId,
  55. }))
  56. }