From f3fb25349b6a8d0214520bde3ae497e63d9c2162 Mon Sep 17 00:00:00 2001 From: wangqiao Date: Sat, 13 Sep 2025 12:47:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BE=E7=BA=B8=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E5=8A=9F=E8=83=BD=E5=92=8C=E6=8F=90=E4=BA=A4=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/upnew/index.ts | 7 ++++++ pages/upnew/index.vue | 50 ++++++++++++++++++++++++++----------------- 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/api/upnew/index.ts b/api/upnew/index.ts index 6575a65..3f7d51e 100644 --- a/api/upnew/index.ts +++ b/api/upnew/index.ts @@ -87,3 +87,10 @@ export const getWechat = () => { export const view = (params: { id: string | number; projectId: string | number }) => { return useDollarFetchRequest.get>('/prod-api/app-api/business/app/project-draw/get', { query: params }) } + +/** + * 编辑图纸 + */ +export const edit = (data: TcreateReq & { projectId: number }) => { + return useDollarFetchRequest.put>('/prod-api/app-api/business/app/project/update', data) +} diff --git a/pages/upnew/index.vue b/pages/upnew/index.vue index 4e94e57..4660b82 100644 --- a/pages/upnew/index.vue +++ b/pages/upnew/index.vue @@ -32,8 +32,9 @@ import { reactive, ref, onMounted, computed } from 'vue' import type { TcreateReq } from '~/api/upnew/types' - import { create, view } from '~/api/upnew/index' + import { create, view, edit } from '~/api/upnew/index' const route = useRoute() // 导入路由实例,用于跳转页面 + const router = useRouter() // 导入路由实例,用于跳转页面 const id = computed(() => { return route.query.id as string }) @@ -94,28 +95,37 @@ const loading = ref(false) const formRef = ref() const handleSubmit = () => { - formRef.value.validate((valid: boolean, val: any) => { + formRef.value.validate(async (valid: boolean, val: any) => { if (valid) { loading.value = true - create(form) - .then((res) => { - const { code } = res - if (code === 0) { - // 弹窗提示 - ElMessage.success('操作成功') - // 跳转页面 - if (form.type === 1) { - navigateTo('/drawe') - } else if (form.type === 2) { - navigateTo('/text') - } else if (form.type === 3) { - navigateTo('/model') - } + try { + const res = + type.value === 'add' + ? await create(form) + : await edit({ + ...form, + id: Number(id.value), + projectId: Number(projectId.value), + }) + if (res.code === 0) { + // 弹窗提示 + ElMessage.success('操作成功') + if (type.value !== 'add') { + router.back() + return } - }) - .finally(() => { - loading.value = false - }) + // 跳转页面 + if (form.type === 1) { + navigateTo('/drawe') + } else if (form.type === 2) { + navigateTo('/text') + } else if (form.type === 3) { + navigateTo('/model') + } + } + } finally { + loading.value = false + } } else { console.log('error submit!') // 弹窗提示