优化图纸编辑功能和提交逻辑

This commit is contained in:
wangqiao
2025-09-13 12:47:10 +08:00
parent ad61430545
commit f3fb25349b
2 changed files with 37 additions and 20 deletions

View File

@ -87,3 +87,10 @@ export const getWechat = () => {
export const view = (params: { id: string | number; projectId: string | number }) => {
return useDollarFetchRequest.get<IResponse<TcreateReq>>('/prod-api/app-api/business/app/project-draw/get', { query: params })
}
/**
* 编辑图纸
*/
export const edit = (data: TcreateReq & { projectId: number }) => {
return useDollarFetchRequest.put<IResponse<boolean>>('/prod-api/app-api/business/app/project/update', data)
}

View File

@ -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,15 +95,25 @@
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) {
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
}
// 跳转页面
if (form.type === 1) {
navigateTo('/drawe')
@ -112,10 +123,9 @@
navigateTo('/model')
}
}
})
.finally(() => {
} finally {
loading.value = false
})
}
} else {
console.log('error submit!')
// 弹窗提示