| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import axios from '@/dbo/main'
- import { list } from "@/store/measure";
- import {baseLines} from "@/store/baseLine";
- import {basePoints} from "@/store/basePoint";
- import {fixPoints} from "@/store/fixPoint";
- import {photos} from "@/store/photos";
- import {accidentPhotos} from "@/store/accidentPhotos";
- import {roadPhotos} from "@/store/roadPhotos";
- import {debounce, getId} from '@/utils'
- import {watch} from "vue";
- axios.get("/attach/sceneStore")
- .then((data) => {
- if (data.status === 200) {
- list.value = data.data.measures || []
- baseLines.value = data.data.baseLines || []
- basePoints.value = data.data.basePoints || []
- fixPoints.value = data.data.fixPoints || []
- photos.value = data.data.photos || []
- accidentPhotos.value = data.data.accidentPhotos || []
- roadPhotos.value = data.data.roadPhotos || []
- }
- syncSceneStore()
- })
- export const updateSceneStore = debounce((data) => {
- axios.post("sceneStore", data)
- }, 1000)
- export const uploadImage = async (blob: Blob) => {
- const file = new File([blob], `${getId()}.jpg`)
- const res = await axios({
- url: "/upload",
- headers: { "Content-Type": "multipart/form-data" },
- method: 'post',
- data: { file }
- });
- return res.data.data
- }
- const syncSceneStore = () => {
- return watch(
- () => ({
- measures: list.value,
- baseLines: baseLines.value,
- basePoints: basePoints.value,
- fixPoints: fixPoints.value,
- photos: photos.value,
- accidentPhotos: accidentPhotos.value,
- roadPhotos: roadPhotos.value
- }),
- (data) => {
- updateSceneStore(data)
- },
- { deep: true }
- )
- }
|