chore: improve loading state management in ToolFormDrawer
--bug=1062445 --user=刘瑞斌 【工具】创建工具完成后,在抽屉收起前可以再次点击创建,导致可重复创建工具 https://www.tapd.cn/62980211/s/1781953v3.2
parent
9406a2c1da
commit
36636f2707
|
|
@ -415,9 +415,10 @@ const submit = async (formEl: FormInstance | undefined) => {
|
||||||
if (!formEl) return
|
if (!formEl) return
|
||||||
await formEl.validate((valid: any) => {
|
await formEl.validate((valid: any) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
|
loading.value = true
|
||||||
if (isEdit.value) {
|
if (isEdit.value) {
|
||||||
loadSharedApi({ type: 'tool', systemType: apiType.value })
|
loadSharedApi({ type: 'tool', systemType: apiType.value })
|
||||||
.putTool(form.value?.id as string, form.value, loading)
|
.putTool(form.value?.id as string, form.value)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
MsgSuccess(t('common.editSuccess'))
|
MsgSuccess(t('common.editSuccess'))
|
||||||
emit('refresh', res.data)
|
emit('refresh', res.data)
|
||||||
|
|
@ -426,13 +427,16 @@ const submit = async (formEl: FormInstance | undefined) => {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
visible.value = false
|
visible.value = false
|
||||||
})
|
})
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
const obj = {
|
const obj = {
|
||||||
folder_id: folder.currentFolder?.id,
|
folder_id: folder.currentFolder?.id,
|
||||||
...form.value,
|
...form.value,
|
||||||
}
|
}
|
||||||
loadSharedApi({ type: 'tool', systemType: apiType.value })
|
loadSharedApi({ type: 'tool', systemType: apiType.value })
|
||||||
.postTool(obj, loading)
|
.postTool(obj)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
MsgSuccess(t('common.createSuccess'))
|
MsgSuccess(t('common.createSuccess'))
|
||||||
emit('refresh')
|
emit('refresh')
|
||||||
|
|
@ -441,6 +445,9 @@ const submit = async (formEl: FormInstance | undefined) => {
|
||||||
.then(() => {
|
.then(() => {
|
||||||
visible.value = false
|
visible.value = false
|
||||||
})
|
})
|
||||||
|
.finally(() => {
|
||||||
|
loading.value = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue