tagging.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import axios from './instance'
  2. import { params } from '@/env'
  3. import {
  4. TAGGING_LIST,
  5. DELETE_TAGGING,
  6. INSERT_TAGGING,
  7. UPDATE_TAGGING,
  8. TAGGING_TYPE_LIST
  9. } from './constant'
  10. import type { FuseModel } from './fuse-model'
  11. import { TaggingPosition, TaggingPositionType } from './tagging-position'
  12. import type { TaggingStyle } from './tagging-style'
  13. import { Tagging3DProps } from '@/sdk'
  14. interface ServerTagging {
  15. "hotIconId": number,
  16. "hotIconUrl": string,
  17. "getMethod": string,
  18. "getUser": string,
  19. "tagId": number,
  20. "tagImgUrl": string,
  21. "leaveBehind": string,
  22. "tagDescribe": string,
  23. "tagTitle": string,
  24. show3dTitle: number
  25. audio: string
  26. fileName: string
  27. // 提取状态
  28. tqStatus?: tqStatusEnum,
  29. // 提取时间
  30. tqTime?: string
  31. }
  32. export interface Tagging {
  33. id: string
  34. styleId: TaggingStyle['id']
  35. title: string,
  36. show3dTitle: boolean
  37. desc: string
  38. part: string
  39. method: string
  40. principal: string
  41. images: string[],
  42. audio: string
  43. audioName: string
  44. // 提取状态
  45. tqStatus?: tqStatusEnum,
  46. // 提取时间
  47. tqTime?: string
  48. }
  49. export enum tqStatusEnum {
  50. UN = '未送检',
  51. ING = '送检中',
  52. END = '完成检验'
  53. }
  54. export type Taggings = Tagging[]
  55. const serviceToLocal = (serviceTagging: ServerTagging): Tagging => ({
  56. id: serviceTagging.tagId.toString(),
  57. styleId: serviceTagging.hotIconId.toString(),
  58. title: serviceTagging.tagTitle,
  59. desc: serviceTagging.tagDescribe,
  60. part: serviceTagging.leaveBehind,
  61. // show3dTitle: true,
  62. audioName: serviceTagging.fileName,
  63. show3dTitle: Boolean(serviceTagging.show3dTitle),
  64. method: serviceTagging.getMethod,
  65. principal: serviceTagging.getUser,
  66. audio: serviceTagging.audio,
  67. images: JSON.parse(serviceTagging.tagImgUrl),
  68. // 提取状态
  69. tqStatus: serviceTagging.tqStatus,
  70. // 提取时间
  71. tqTime: serviceTagging.tqTime
  72. })
  73. const localToService = (tagging: Tagging, update = false): PartialProps<ServerTagging, 'tagId' | 'hotIconUrl'> & { fusionId: number } => ({
  74. "hotIconId": Number(tagging.styleId),
  75. "fusionId": params.caseId,
  76. "getMethod": tagging.method,
  77. show3dTitle: Number(tagging.show3dTitle),
  78. "getUser": tagging.principal,
  79. fileName: tagging.audioName,
  80. "hotIconUrl": "static/img_default/lQLPDhrvVzvNvTswMLAOU-UNqYnnZQG1YPJUwLwA_48_48.png",
  81. "tagId": update ? Number(tagging.id) : undefined,
  82. "tagImgUrl": JSON.stringify(tagging.images),
  83. "leaveBehind": tagging.part,
  84. "tagDescribe": tagging.desc,
  85. "tagTitle": tagging.title,
  86. audio: tagging.audio,
  87. // 提取状态
  88. tqStatus: tagging.tqStatus,
  89. // 提取时间
  90. tqTime: tagging.tqTime
  91. })
  92. export const fetchTaggings = async () => {
  93. axios.get(TAGGING_TYPE_LIST)
  94. const staggings = await axios.get<ServerTagging[]>(TAGGING_LIST, { params: { fusionId: params.caseId } })
  95. return staggings.map(serviceToLocal)
  96. }
  97. export const postAddTagging = async (tagging: Tagging) => {
  98. const stagging = await axios.post<ServerTagging>(INSERT_TAGGING, { ...localToService(tagging), fusionId: params.caseId })
  99. return serviceToLocal(stagging, )
  100. }
  101. export const postUpdateTagging = (tagging: Tagging) => {
  102. return axios.post<undefined>(UPDATE_TAGGING, { ...localToService(tagging, true), fusionId: params.caseId })
  103. }
  104. export const postDeleteTagging = (id: Tagging['id']) => {
  105. return axios.post<undefined>(DELETE_TAGGING, { tagId: id })
  106. }