|
@@ -1,4 +1,5 @@
|
|
|
import { defineStore } from 'pinia'
|
|
|
+import { useUserStore } from './user'
|
|
|
import {
|
|
|
fetchProject,
|
|
|
uploadProjectBimScene,
|
|
@@ -44,6 +45,7 @@ export type SelectTypeScenes = {
|
|
|
}
|
|
|
|
|
|
type CurrentState = null | Project
|
|
|
+
|
|
|
export const useProject = defineStore('project', {
|
|
|
state: () => ({
|
|
|
current: null as CurrentState
|
|
@@ -86,6 +88,7 @@ export const useProject = defineStore('project', {
|
|
|
async delete(id?: Project['projectId']) {
|
|
|
if ((id = id || this.current?.projectId)) {
|
|
|
await deleteProject(id)
|
|
|
+ await useUserStore().fetchMeta()
|
|
|
this.current = null
|
|
|
}
|
|
|
},
|
|
@@ -112,6 +115,7 @@ export const useProject = defineStore('project', {
|
|
|
async addBim(data: BimUploadData, id?: Project['projectId']) {
|
|
|
if ((id = id || this.current?.projectId)) {
|
|
|
await uploadProjectBimScene(id, data)
|
|
|
+ await useUserStore().fetchMeta()
|
|
|
await this.updateCurrent(id)
|
|
|
}
|
|
|
},
|
|
@@ -124,6 +128,7 @@ export const useProject = defineStore('project', {
|
|
|
async deleteBim(bimId?: Bim['bimId']) {
|
|
|
if ((bimId = bimId || this.current?.bimData?.bimId)) {
|
|
|
await deleteProjectBimScene(bimId)
|
|
|
+ await useUserStore().fetchMeta()
|
|
|
this.current?.bimData?.bimId === bimId && (await this.updateCurrent())
|
|
|
}
|
|
|
},
|
|
@@ -139,12 +144,14 @@ export const useProject = defineStore('project', {
|
|
|
})
|
|
|
)
|
|
|
await relaceProjectScenes({ id, sceneNumParam })
|
|
|
+ await useUserStore().fetchMeta()
|
|
|
await this.updateCurrent(id)
|
|
|
}
|
|
|
},
|
|
|
async deleteScene(num: Scene['num'], id?: Project['projectId']) {
|
|
|
if ((id = id || this.current?.projectId)) {
|
|
|
await deleteProjectScene({ projectId: id, num })
|
|
|
+ await useUserStore().fetchMeta()
|
|
|
await this.updateCurrent(id)
|
|
|
}
|
|
|
}
|