Kaynağa Gözat

对接标注接口

bill 3 yıl önce
ebeveyn
işleme
86f39a8459

+ 10 - 4
src/api/constant.ts

@@ -22,10 +22,16 @@ export const UPDATE_MODEL = `/laser/sceneFusion/${params.m}/updateModel`
 export const DELETE_MODEL = `/laser/sceneFusion/${params.m}/del`
 
 // 标注列表
-export const TAGGING_LIST = ''
-export const INSERT_TAGGING = ''
-export const UPDATE_TAGGING = ''
-export const DELETE_TAGGING = ''
+export const TAGGING_LIST = `/laser/sceneTag/${params.m}/list/${params.fushId}`
+export const INSERT_TAGGING = `/laser/sceneTag/${params.m}/add`
+export const UPDATE_TAGGING = `/laser/sceneTag/${params.m}/edit`
+export const DELETE_TAGGING = `/laser/sceneTag/delete`
+
+// 标注放置列表
+export const TAGGING_POINT_LIST = `/laser/caseTagPoint/${params.m}/list/:id`
+export const INSERT_TAGGING_POINT = `/laser/caseTagPoint/${params.m}/place`
+export const UPDATE_TAGGING_POINT = `/laser/sceneTag/${params.m}/edit`
+export const DELETE_TAGGING_POINT = `/laser/caseTagPoint/${params.m}/delete`
 
 // 标注样式类型列表
 export const TAGGING_STYLE_LIST = ''

+ 10 - 5
src/api/instance.ts

@@ -1,7 +1,8 @@
 import { axiosFactory } from './setup'
 import { Message } from 'bill/index'
-import { ResCodeDesc, MODEL_LIST, UPDATE_MODEL, INSERT_MODEL, DELETE_MODEL } from './constant'
 import { showLoad, hideLoad } from '@/utils'
+import * as URL from './constant'
+import { ResCode, ResCodeDesc } from './constant'
 
 const instance = axiosFactory()
 
@@ -39,10 +40,14 @@ addResErrorHandler(
 addHook({ before: showLoad, after: hideLoad })
 
 addUnsetTokenURLS(
-  MODEL_LIST,
-  UPDATE_MODEL,
-  INSERT_MODEL,
-  DELETE_MODEL
+  URL.MODEL_LIST,
+  URL.UPDATE_MODEL,
+  URL.INSERT_MODEL,
+  URL.DELETE_MODEL,
+  URL.TAGGING_LIST,
+  URL.DELETE_TAGGING,
+  URL.INSERT_TAGGING,
+  URL.UPDATE_TAGGING,
 )
 setDefaultURI('/api')
 

+ 3 - 1
src/api/model.ts

@@ -50,6 +50,7 @@ interface ServiceModel {
   modelTitle: string
   opacity: number
   bottom: number
+  type: number
   transform: {
     position: SceneLocalPos, 
     rotation: SceneLocalPos, 
@@ -68,7 +69,7 @@ const serviceToLocal = (serviceModel: ServiceModel): Model => ({
   url: serviceModel.modelGlbUrl,
   title: serviceModel.modelTitle,
   fusionId: serviceModel.fusionId,
-  type: ModelType.SWMX,
+  type:  serviceModel.type === 2 ? ModelType.SWSS : ModelType.SWMX,
   size: serviceModel.modelSize,
   time: serviceModel.createTime
 })
@@ -80,6 +81,7 @@ const localToService = (model: Model): ServiceModel => ({
   fusionId: model.fusionId,
   modelDateType: model.type,
   modelGlbUrl: model.url,
+  type: model.type === ModelType.SWSS ? 2 : 3,
   modelSize: model.size,
   modelTitle: model.title,
   opacity: model.opacity,

+ 0 - 0
src/api/tagging-point.ts


+ 47 - 50
src/api/tagging.ts

@@ -8,6 +8,18 @@ import {
 
 import type { Model } from './model'
 
+interface ServerTagging {
+  "hotIconId": number,
+  "hotIconUrl": string,
+  "getMethod": string,
+  "getUser": string,
+  "id": number,
+  "meta": { "name": string, "url": string } [],
+  "remark": string,
+  "tagDescribe": string,
+  "tagTitle": string,
+}
+
 export interface TaggingPosition {
   modelId: Model['id']
   localPos: SceneLocalPos
@@ -24,67 +36,52 @@ export interface Tagging {
   positions: TaggingPosition[]
 }
 
+
 export type Taggings = Tagging[]
 
-export const fetchTaggings = async () => {
-  // axios.post<Taggings>(TAGGING_LIST)
-  return [
-    {
-      id: '1231',
-      title: 'aaaa',
-      styleId: '1231',
-      desc: '123123',
-      modelId: '123',
-      part: '123asd',
-      method: '123123a',
-      principal: 'asdasd',
-      images: [
-        'https://gw.alicdn.com/tps/TB1W_X6OXXXXXcZXVXXXXXXXXXX-400-400.png',
-        'https://gw.alicdn.com/tps/TB1W_X6OXXXXXcZXVXXXXXXXXXX-400-400.png'
-      ],
-      positions: [
-        { 
-          modelId: '124',
-          localPos: { x: 1, y: 1, z: 1 }
-        }
-      ]
-    },
 
-    {
-      id: '1231a',
-      title: 'aaaa',
-      styleId: '1231',
-      desc: '123123',
-      part: '123asd',
-      method: '123123a',
-      principal: 'asdasd',
-      images: [
-        'https://gw.alicdn.com/tps/TB1W_X6OXXXXXcZXVXXXXXXXXXX-400-400.png',
-        'https://gw.alicdn.com/tps/TB1W_X6OXXXXXcZXVXXXXXXXXXX-400-400.png'
-      ],
-      positions: [{ 
-        modelId: '123',
-        localPos: { x: 1, y: 1, z: 1 }
-      }
-      ]
-    }
-  ]
+const serviceToLocal = (serviceTagging: ServerTagging): Tagging => ({
+  id: serviceTagging.id.toString(),
+  styleId: serviceTagging.hotIconId.toString(),
+  title: serviceTagging.tagTitle,
+  desc: serviceTagging.tagDescribe,
+  part: serviceTagging.remark,
+  method: serviceTagging.getMethod,
+  principal: serviceTagging.getUser,
+  images: serviceTagging.meta.map(({url}) => url),
+  positions: []
+})
+
+const localToService = (tagging: Tagging): ServerTagging => ({
+  "hotIconId": Number(tagging.styleId),
+  "hotIconUrl": tagging.styleId,
+  "getMethod": tagging.method,
+  "getUser": tagging.principal,
+  "id": Number(tagging.id),
+  "meta": tagging.images.map(((item, i) => ({ "name": item, "url": item }))),
+  "remark": tagging.part,
+  "tagDescribe": tagging.desc,
+  "tagTitle": tagging.title,
+})
+
+
+export const fetchTaggings = async () => {
+  const staggings = await axios.post<ServerTagging[]>(TAGGING_LIST, {})
+  return staggings.map(serviceToLocal)
 }
 
-export const postAddTagging = (tagging: Tagging) => {
-  console.log('add')
-  return axios.post<Tagging>(INSERT_TAGGING, tagging)
+export const postAddTagging = async (tagging: Tagging) => {
+  const stagging = await axios.post<ServerTagging>(INSERT_TAGGING, tagging)
+  return serviceToLocal(stagging)
 }
 
-export const postUpdateTagging = async (tagging: Tagging) => {
-  console.log('update')
-  // return axios.post<undefined>(UPDATE_TAGGING, tagging)
+export const postUpdateTagging = (tagging: Tagging) => {
+  return axios.post<undefined>(UPDATE_TAGGING, localToService(tagging))
 }
   
 
 export const postDeleteTagging = (id: Tagging['id']) => {
-  console.log('delete')
-  return axios.post<undefined>(DELETE_TAGGING)
+  return axios.post<undefined>(DELETE_TAGGING, { ids: [id] })
 }
 
   

+ 3 - 2
src/env/index.ts

@@ -12,7 +12,7 @@ export const showRightCtrlPanoStack = stackFactory(ref<boolean>(true))
 export const showTaggingsStack = stackFactory(ref<boolean>(true))
 export const currentModelStack = stackFactory(ref<Model | null>(null))
 export const showModelsMapStack = stackFactory(ref<Map<Model, boolean>>(new Map))
-export const showModelsChangeStoreStack = stackFactory(ref<boolean>(false))
+export const modelsChangeStoreStack = stackFactory(ref<boolean>(false))
 export const showTaggingPositionsStack = stackFactory(ref<WeakSet<TaggingPosition>>(new WeakSet()))
 // export const showModelsChangeStoreStack = stackFactory
 
@@ -26,7 +26,7 @@ export const custom = flatStacksValue({
   showTaggings: showTaggingsStack,
   currentModel: currentModelStack,
   showModelsMap: showModelsMapStack,
-  showModelsChangeStore: showModelsChangeStoreStack,
+  modelsChangeStore: modelsChangeStoreStack,
   showTaggingPositions: showTaggingPositionsStack
 })
 
@@ -35,5 +35,6 @@ export const params = strToParams(location.search) as Params
 export type Params = { 
   m: string,
   id: string,
+  fushId: string,
   token?: string
 }

+ 11 - 5
src/layout/model-list/sign.vue

@@ -3,18 +3,24 @@
     <p>{{ model.title }}</p>
     <div class="model-action" @click.stop>
       <ui-input type="checkbox" v-model="show" />
-      <ui-icon type="del" ctrl @click="$emit('delete')" />
+      <ui-icon 
+        type="del" 
+        ctrl 
+        @click="$emit('delete')" 
+        v-if="model.type !== ModelType.SWSS && custom.modelsChangeStore" 
+      />
     </div>
   </div>
   <div class="model-desc">
-    <p><span>数据来源:</span>四维看看</p>
-    <p><span>数据大小:</span>222MB</p>
-    <p><span>拍摄时间:</span>2022-5-1</p>
+    <p><span>数据来源:</span>{{ ModelTypeDesc[model.type] }}</p>
+    <p><span>数据大小:</span>{{ model.size }}</p>
+    <p><span>拍摄时间:</span>{{ model.time }}</p>
   </div>
 </template>
 
 <script lang="ts" setup>
-import { getModelShowVariable } from '@/store'
+import { getModelShowVariable, ModelTypeDesc, ModelType } from '@/store'
+import { custom } from '@/env'
 
 import type { Model } from '@/store'
 

+ 4 - 0
src/sdk/association.ts

@@ -41,6 +41,10 @@ const associationModels = (sdk: SDK) => {
         }
       })
       sceneModel.bus.on('loadDone', () => item.loaded = true)
+      sceneModel.bus.on('loadError', () => {
+        console.error(item, '加载失败')
+        item.error = true
+      })
       sceneModel.bus.on('loadProgress', progress => item.progress = progress)
     }
     for (const item of deleted) {

+ 1 - 0
src/sdk/sdk.ts

@@ -11,6 +11,7 @@ export type SceneModel = ToChangeAPI<Omit<SceneModelAttrs, 'position' | 'rotatio
     bus: Emitter<
       Pick<SceneModelAttrs, 'select'> & 
       { 
+        loadError: void,
         loadDone: void, 
         loadProgress: number,
         changeSelect: boolean,

+ 5 - 4
src/store/model.ts

@@ -18,7 +18,7 @@ import {
 
 import type { Model as SModel } from '@/api'
 
-export type Model = SModel & { loaded: boolean, progress: number }
+export type Model = SModel & { loaded: boolean, error: boolean, progress: number }
 export type Models = Model[]
 
 export const models = ref<Models>([])
@@ -26,11 +26,11 @@ export const models = ref<Models>([])
 export const getModel = (modelId: Model['id']) => models.value.find(model => model.id === modelId)
 export const getModelShowVariable = (model: Model) => 
   computed({
-    get: () => custom.showModelsChangeStore 
+    get: () => custom.modelsChangeStore 
       ? model.show 
       : custom.showModelsMap.get(model) || false,
     set: (show: boolean) => {
-      if (custom.showModelsChangeStore) {
+      if (custom.modelsChangeStore) {
         model.show = show
       } else {
         custom.showModelsMap.set(model, show)
@@ -40,7 +40,7 @@ export const getModelShowVariable = (model: Model) =>
   
 export const modelsLoaded = ref(false)
 watchPostEffect(() => {
-  modelsLoaded.value = models.value.every(model => model.loaded === true)
+  modelsLoaded.value = models.value.every(model => model.loaded || model.error)
 })
 
 let bcModels: Models = []
@@ -55,6 +55,7 @@ export const backupModels = () => {
 
 const serviceToLocal = (model: SModel): Model => ({
   ...model, 
+  error: false,
   loaded: false, 
   progress: 0,
 })

+ 2 - 2
src/views/merge/index.vue

@@ -33,7 +33,7 @@ import { togetherCallback } from '@/utils'
 import Actions from '@/components/actions/index.vue'
 import { getSceneModel } from '@/sdk'
 import { useViewStack } from '@/hook'
-import { showLeftCtrlPanoStack, showLeftPanoStack, showModelsChangeStoreStack, custom } from '@/env'
+import { showLeftCtrlPanoStack, showLeftPanoStack, custom, modelsChangeStoreStack } from '@/env'
 import { ref } from 'vue'
 
 import type { ActionsProps } from '@/components/actions/index.vue'
@@ -66,7 +66,7 @@ const actionItems: ActionsProps['items'] = [
 useViewStack(() => togetherCallback([
   showLeftCtrlPanoStack.push(ref(false)),
   showLeftPanoStack.push(ref(true)),
-  showModelsChangeStoreStack.push(ref(true))
+  modelsChangeStoreStack.push(ref(true))
 ]))
 useViewStack(autoSaveModels)