From cee338f18d22bbbb989d79c0add082fdb4e2b8ef Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Fri, 08 Sep 2023 11:09:00 +0800
Subject: [PATCH] store添加projectId
---
src/store/common.ts | 15 +++++++++++++++
src/api/wayline.ts | 4 ++--
src/pages/page-web/projects/wayline.vue | 3 ++-
src/pages/page-web/projects/project_list/list_page/components/ProjectList.vue | 3 +++
src/store/index.ts | 4 +++-
5 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/src/api/wayline.ts b/src/api/wayline.ts
index a917804..230b7a9 100644
--- a/src/api/wayline.ts
+++ b/src/api/wayline.ts
@@ -3,7 +3,7 @@
import { TaskType, TaskStatus, OutOfControlAction } from '/@/types/task'
import { WaylineType } from '/@/types/wayline'
-const HTTP_PREFIX = '/wayline/api/v1'
+const HTTP_PREFIX = 'drone/waylineFile'
// Get Wayline Files
export const getWaylineFiles = async function (wid: string, body: {}): Promise<IWorkspaceResponse<any>> {
@@ -120,7 +120,7 @@
// Upload Wayline file
export const importKmzFile = async function (workspaceId: string, file: {}): Promise<IWorkspaceResponse<any>> {
- const url = `${HTTP_PREFIX}/workspaces/${workspaceId}/waylines/file/upload`
+ const url = `api/${HTTP_PREFIX}/upload`
const result = await request.post(url, file, {
headers: {
'Content-Type': 'multipart/form-data',
diff --git a/src/pages/page-web/projects/project_list/list_page/components/ProjectList.vue b/src/pages/page-web/projects/project_list/list_page/components/ProjectList.vue
index 23a6d41..49dbb85 100644
--- a/src/pages/page-web/projects/project_list/list_page/components/ProjectList.vue
+++ b/src/pages/page-web/projects/project_list/list_page/components/ProjectList.vue
@@ -64,6 +64,8 @@
import { status, projectCard } from './data'
import { del, edit } from '/@/api/project-page'
import { Modal, message } from 'ant-design-vue'
+import { useMyStore} from "/@/store";
+const store = useMyStore()
const router = useRouter()
const emit = defineEmits(['refreshList', 'update:modelValue'])
const props = defineProps({
@@ -131,6 +133,7 @@
const goDetail = (item: any) => {
console.log(11)
+ store.commit('SET_PROJECT_ID', item.id)
router.push({
name: ERouterName.WORKSPACE,
query: { id: item.id }
diff --git a/src/pages/page-web/projects/wayline.vue b/src/pages/page-web/projects/wayline.vue
index a9a7bc5..2d8b1b0 100644
--- a/src/pages/page-web/projects/wayline.vue
+++ b/src/pages/page-web/projects/wayline.vue
@@ -98,6 +98,7 @@
const loading = ref(false)
const store = useMyStore()
+const projectId = store.state.common.projectId
const pagination :IPage = {
page: 1,
total: -1,
@@ -220,7 +221,7 @@
fileList.value.forEach(async (file: FileItem) => {
const fileData = new FormData()
fileData.append('file', file, file.name)
- await importKmzFile(workspaceId, fileData).then((res) => {
+ await importKmzFile(projectId, fileData).then((res) => {
if (res.code === 0) {
message.success(`${file.name} file uploaded successfully`)
canRefresh.value = true
diff --git a/src/store/common.ts b/src/store/common.ts
new file mode 100644
index 0000000..a6c09b2
--- /dev/null
+++ b/src/store/common.ts
@@ -0,0 +1,15 @@
+import { MutationTree } from 'vuex'
+
+const state = () => ({
+ projectId: null as string | null
+})
+export type RootStateType = ReturnType<typeof state>
+const mutations: MutationTree<RootStateType> = {
+ SET_PROJECT_ID (state, projectId: string) {
+ state.projectId = projectId
+ },
+}
+export default {
+ state,
+ mutations
+}
diff --git a/src/store/index.ts b/src/store/index.ts
index cf6b009..2d7016d 100644
--- a/src/store/index.ts
+++ b/src/store/index.ts
@@ -8,6 +8,7 @@
import getter from './getters'
import { DevicesCmdExecuteInfo } from '/@/types/device-cmd'
import map from './map'
+import common from "/@/store/common";
const initStateFunc = () => ({
Layers: [
@@ -245,7 +246,8 @@
actions,
modules: {
getter,
- map
+ map,
+ common
},
}
--
Gitblit v1.9.3