优化图纸编辑功能和提交逻辑
This commit is contained in:
@ -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)
|
||||||
|
}
|
||||||
|
|||||||
@ -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,15 +95,25 @@
|
|||||||
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({
|
||||||
|
...form,
|
||||||
|
id: Number(id.value),
|
||||||
|
projectId: Number(projectId.value),
|
||||||
|
})
|
||||||
|
if (res.code === 0) {
|
||||||
// 弹窗提示
|
// 弹窗提示
|
||||||
ElMessage.success('操作成功')
|
ElMessage.success('操作成功')
|
||||||
|
if (type.value !== 'add') {
|
||||||
|
router.back()
|
||||||
|
return
|
||||||
|
}
|
||||||
// 跳转页面
|
// 跳转页面
|
||||||
if (form.type === 1) {
|
if (form.type === 1) {
|
||||||
navigateTo('/drawe')
|
navigateTo('/drawe')
|
||||||
@ -112,10 +123,9 @@
|
|||||||
navigateTo('/model')
|
navigateTo('/model')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
} finally {
|
||||||
.finally(() => {
|
|
||||||
loading.value = false
|
loading.value = false
|
||||||
})
|
}
|
||||||
} else {
|
} else {
|
||||||
console.log('error submit!')
|
console.log('error submit!')
|
||||||
// 弹窗提示
|
// 弹窗提示
|
||||||
|
|||||||
Reference in New Issue
Block a user