123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- import axios from './instance'
- import { params } from '@/env'
- import {
- TAGGING_LIST,
- DELETE_TAGGING,
- INSERT_TAGGING,
- UPDATE_TAGGING,
- TAGGING_TYPE_LIST
- } from './constant'
- import type { FuseModel } from './fuse-model'
- import { TaggingPosition, TaggingPositionType } from './tagging-position'
- import type { TaggingStyle } from './tagging-style'
- import { Tagging3DProps } from '@/sdk'
- interface ServerTagging {
- "hotIconId": number,
- "hotIconUrl": string,
- "getMethod": string,
- "getUser": string,
- "tagId": number,
- "tagImgUrl": string,
- "leaveBehind": string,
- "tagDescribe": string,
- "tagTitle": string,
- show3dTitle: number
- audio: string
- fileName: string
- // 提取状态
- tqStatus?: tqStatusEnum,
- // 提取时间
- tqTime?: string
- }
- export interface Tagging {
- id: string
- styleId: TaggingStyle['id']
- title: string,
- show3dTitle: boolean
- desc: string
- part: string
- method: string
- principal: string
- images: string[],
- audio: string
- audioName: string
- // 提取状态
- tqStatus?: tqStatusEnum,
- // 提取时间
- tqTime?: string
- }
- export enum tqStatusEnum {
- UN = '未送检',
- ING = '送检中',
- END = '完成检验'
- }
- export type Taggings = Tagging[]
- const serviceToLocal = (serviceTagging: ServerTagging): Tagging => ({
- id: serviceTagging.tagId.toString(),
- styleId: serviceTagging.hotIconId.toString(),
- title: serviceTagging.tagTitle,
- desc: serviceTagging.tagDescribe,
- part: serviceTagging.leaveBehind,
- // show3dTitle: true,
- audioName: serviceTagging.fileName,
- show3dTitle: Boolean(serviceTagging.show3dTitle),
- method: serviceTagging.getMethod,
- principal: serviceTagging.getUser,
- audio: serviceTagging.audio,
- images: JSON.parse(serviceTagging.tagImgUrl),
- // 提取状态
- tqStatus: serviceTagging.tqStatus,
- // 提取时间
- tqTime: serviceTagging.tqTime
- })
- const localToService = (tagging: Tagging, update = false): PartialProps<ServerTagging, 'tagId' | 'hotIconUrl'> & { fusionId: number } => ({
- "hotIconId": Number(tagging.styleId),
- "fusionId": params.caseId,
- "getMethod": tagging.method,
- show3dTitle: Number(tagging.show3dTitle),
- "getUser": tagging.principal,
- fileName: tagging.audioName,
- "hotIconUrl": "static/img_default/lQLPDhrvVzvNvTswMLAOU-UNqYnnZQG1YPJUwLwA_48_48.png",
- "tagId": update ? Number(tagging.id) : undefined,
- "tagImgUrl": JSON.stringify(tagging.images),
- "leaveBehind": tagging.part,
- "tagDescribe": tagging.desc,
- "tagTitle": tagging.title,
- audio: tagging.audio,
- // 提取状态
- tqStatus: tagging.tqStatus,
- // 提取时间
- tqTime: tagging.tqTime
- })
- export const fetchTaggings = async () => {
- axios.get(TAGGING_TYPE_LIST)
- const staggings = await axios.get<ServerTagging[]>(TAGGING_LIST, { params: { fusionId: params.caseId } })
- return staggings.map(serviceToLocal)
- }
- export const postAddTagging = async (tagging: Tagging) => {
- const stagging = await axios.post<ServerTagging>(INSERT_TAGGING, { ...localToService(tagging), fusionId: params.caseId })
- return serviceToLocal(stagging, )
- }
- export const postUpdateTagging = (tagging: Tagging) => {
- return axios.post<undefined>(UPDATE_TAGGING, { ...localToService(tagging, true), fusionId: params.caseId })
- }
-
- export const postDeleteTagging = (id: Tagging['id']) => {
- return axios.post<undefined>(DELETE_TAGGING, { tagId: id })
- }
-
|