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

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 }) => { 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 }) 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 { reactive, ref, onMounted, computed } from 'vue'
import type { TcreateReq } from '~/api/upnew/types' 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 route = useRoute() // 导入路由实例,用于跳转页面
const router = useRouter() // 导入路由实例,用于跳转页面
const id = computed(() => { const id = computed(() => {
return route.query.id as string return route.query.id as string
}) })
@ -94,28 +95,37 @@
const loading = ref(false) const loading = ref(false)
const formRef = ref() const formRef = ref()
const handleSubmit = () => { const handleSubmit = () => {
formRef.value.validate((valid: boolean, val: any) => { formRef.value.validate(async (valid: boolean, val: any) => {
if (valid) { if (valid) {
loading.value = true loading.value = true
create(form) try {
.then((res) => { const res =
const { code } = res type.value === 'add'
if (code === 0) { ? await create(form)
// 弹窗提示 : await edit({
ElMessage.success('操作成功') ...form,
// 跳转页面 id: Number(id.value),
if (form.type === 1) { projectId: Number(projectId.value),
navigateTo('/drawe') })
} else if (form.type === 2) { if (res.code === 0) {
navigateTo('/text') // 弹窗提示
} else if (form.type === 3) { ElMessage.success('操作成功')
navigateTo('/model') if (type.value !== 'add') {
} router.back()
return
} }
}) // 跳转页面
.finally(() => { if (form.type === 1) {
loading.value = false navigateTo('/drawe')
}) } else if (form.type === 2) {
navigateTo('/text')
} else if (form.type === 3) {
navigateTo('/model')
}
}
} finally {
loading.value = false
}
} else { } else {
console.log('error submit!') console.log('error submit!')
// 弹窗提示 // 弹窗提示